Averest


SatSolver Module

This module implements functions for checking the satisfiability of boolean expressions. The SAT checking procedures are based on Shannon graphs which are unreduced unordered binary decision diagrams. This has the advantage that one can construct an equivalent Shannon graph for a given BoolExpr in linear time.

Types

Type Description

AtomIndex

AtomIndex is used to uniquely identify atomic formulas (see maps Index2BoolExpr and BoolExpr2Index)

Clause

a clause consists of a pair of sets of atom indices that are the indices of the positive and negative atoms of the clause; note that these are implicitly disjunctively combined and clauses are often used in combination with a cube that filters out only unassigned atoms

ClauseIndex

ClauseIndex is used as type for indices of clauses in the ClauseArray

Cube

A cube is a type to define a truth assignments to the considered atoms such that each atom is either true, false or don't care (=None). Cubes are ordered in a lattice.

ShannonGraph

Shannon graphs are unreduced and unordered binary decision diagrams. Additionally, we add negations to allow a linear representation of equivalences.

Functions and values

Function or value Description

BoolExpr2Clauses phi

Full Usage: BoolExpr2Clauses phi

Parameters:
Returns: Set<BoolExpr> * Set<int> * Set<Set<int> * Set<int>>

Given a BoolExpr phi, BoolExpr2Clauses phi computes (vrs,atoms,cls) where vrs are the variables (as BoolExprs) that where used to abbreviate subformulas occurring in phi into clauses, atoms is a set of atom indices including all atoms that occur in the clauses (i.e., vrs Abbreviated variables have names starting with "__def".

phi : BoolExpr
Returns: Set<BoolExpr> * Set<int> * Set<Set<int> * Set<int>>

BoolExpr2Index

Full Usage: BoolExpr2Index

Returns: Map<BoolExpr, int> ref

mapping boolean expressions to their index

Returns: Map<BoolExpr, int> ref

BoolExpr2ShannonGraph e

Full Usage: BoolExpr2ShannonGraph e

Parameters:
Returns: ShannonGraph

convert a BoolExpr to a Shannon graph (it is assumed that the atoms of e are at least a subset of the atom set used with Initialize)

e : BoolExpr
Returns: ShannonGraph

Clause2String cube (arg2, arg3)

Full Usage: Clause2String cube (arg2, arg3)

Parameters:
Returns: string

convert a clause to a string

cube : Cube
arg1 : Set<int>
arg2 : Set<int>
Returns: string

DPLL quiet write debug atomSet clauseArr numClauses

Full Usage: DPLL quiet write debug atomSet clauseArr numClauses

Parameters:
    quiet : bool
    write : string -> unit
    debug : bool
    atomSet : Set<AtomIndex>
    clauseArr : Clause[]
    numClauses : int

Returns: Clause[] * int * Cube option

DPLL is the famous Davis-Putnam-Logemann-Loveland algorithm to check the satisfiability of an array of clauses over a set of atoms atomSet. Given clauses clauseArr over the atoms in atomSet, the procedure searches a satisfying assignment of the clause set. Argument numClauses partitions the clauses of the clause array into original clauses clauseArr[0..numClauses-1] and learnt ones due to a previous run of DPLL. Searching a model is done by the DPLL procedure by case splitting and unit propagation until a model or a conflict is found. Conflicts are used to learn a clause that avoids that the same conflict is repeated and that allows one to backtrack sometimes to higher decision levels. This implementation of DPLL computes for each found conflict of a branch a single assertion clause, and learns the one that leads to the largest backtrack step. The procedure returns a tuple (ca,nc,copt) where ca is the given clause array extended by learnt clauses, nc is still the number of original clauses, and copt is None if the set of clauses is unsatisfiable, and otherwise, it contains a cube that satisfies the given clause set. Arguments quite, write, and debug are used to determine whether notes on the computation are printed by the function write. If quiet holds, nothing is printed, otherwise some information is printed, and more information is printed when quiet is false and debug is true.

quiet : bool
write : string -> unit
debug : bool
atomSet : Set<AtomIndex>
clauseArr : Clause[]
numClauses : int
Returns: Clause[] * int * Cube option

Index2BoolExpr

Full Usage: Index2BoolExpr

Returns: BoolExpr[] ref

Index2BoolExpr maps node indices to the corresponding boolean expression

Returns: BoolExpr[] ref

Initialize atomS

Full Usage: Initialize atomS

Parameters:

Initialize the package by a set of boolean atoms. This set can e.g. be computed by AtomsOfBoolExpr from a BoolExpr.

atomS : Set<BoolExpr>

NextSatDPLL quiet write debug ats ca nc mold

Full Usage: NextSatDPLL quiet write debug ats ca nc mold

Parameters:
    quiet : bool
    write : string -> unit
    debug : bool
    ats : Set<int>
    ca : Clause[]
    nc : int
    mold : Cube

Returns: Set<int> * Clause[] * int * Cube option

This function continues with a previous DPLL search that computed the result (ds,ats,ca,nc,mold) as described by function OneSatDPLL. The result is also as described there, just containing another model or the information that no more model exists.

quiet : bool
write : string -> unit
debug : bool
ats : Set<int>
ca : Clause[]
nc : int
mold : Cube
Returns: Set<int> * Clause[] * int * Cube option

OneSatDPLL quiet write debug phi

Full Usage: OneSatDPLL quiet write debug phi

Parameters:
    quiet : bool
    write : string -> unit
    debug : bool
    phi : BoolExpr

Returns: Set<int> * Clause[] * int * Cube option

This function translates the given BoolExpr phi to a clause set, and runs DPLL with the arguments quiet, write, and debug as described with function DPLL. It returns a tuple (ds,ats,ca,m) where ds is the final decision stack (the final branch in the search tree), ats the set of atoms contained in phi, ca the clause array generated from phi as well as of the learnt clauses

quiet : bool
write : string -> unit
debug : bool
phi : BoolExpr
Returns: Set<int> * Clause[] * int * Cube option

OneSatSG quiet phi

Full Usage: OneSatSG quiet phi

Parameters:

quiet : bool
phi : BoolExpr

ShannonGraph2Dot ostr s

Full Usage: ShannonGraph2Dot ostr s

Parameters:

write a Shannon graph to a dot file

ostr : TextWriter
s : ShannonGraph

WriteCube write m

Full Usage: WriteCube write m

Parameters:
    write : string -> unit
    m : Cube

print a variable assignment (a cube)

write : string -> unit
m : Cube