IIT Bombay - CFDVS
SAT Solvers
Aditya Parameswaran Luv Kumar 1st June, 2005 and 14th June, 2005
Aditya Parameswaran, Luv Kumar: SAT Solvers, 1
SAT Solvers Aditya Parameswaran Luv Kumar 1st June, 2005 and 14th - - PowerPoint PPT Presentation
IIT Bombay - CFDVS SAT Solvers Aditya Parameswaran Luv Kumar 1st June, 2005 and 14th June, 2005 Aditya Parameswaran, Luv Kumar: SAT Solvers, 1 Outline Outline The Satisfiability Problem Types of Solvers The basic DPLL
IIT Bombay - CFDVS
Aditya Parameswaran Luv Kumar 1st June, 2005 and 14th June, 2005
Aditya Parameswaran, Luv Kumar: SAT Solvers, 1
Outline
Branching Heuristics Deduction Mechanism Conflict Analysis and Learning Other Techniques
Comparison of BerkMin and Chaff on Branching Heuristics Comparison of Chaff and SATO in BCP
Equivalence Classes
Aditya Parameswaran, Luv Kumar: SAT Solvers, 2
The Satisfiability Problem
◮ Given a Boolean propositional formula, does there exist
assignment of values such that the formula becomes true?
◮ We consider a CNF formula, C1 ∧ C2 ∧ C3 ∧ C4 . . . , where, ◮ Ci is a disjunction of literals like a, ¬b, c, . . .
Aditya Parameswaran, Luv Kumar: SAT Solvers, 3
The Satisfiability Problem
History of the SAT Problem
◮ Davis Putnam - Resolution based, 1960, later proposed Search
based algorithm, 1962
◮ Proved NP Complete by Cook, 1971 ◮ Stalmarcks algorithm - Patented, 1995 ◮ Conflict driven Learning and Non chronological backtracking
in GRASP, 1996
◮ Local Search, 1997 ◮ SATO - DPLL Based, 1997 ◮ Chaff - DPLL Based, 2001 ◮ BerkMin - DPLL Based, 2002
Aditya Parameswaran, Luv Kumar: SAT Solvers, 4
Types of Solvers
Two Types:
◮ Complete - find a solution or prove that none exist, e.g.
Resolution, Search, Stalmarcks, BDDs
◮ Stochastic - do not prove unsatisfiability, can get some
solutions quickly, e.g. Local Search
Aditya Parameswaran, Luv Kumar: SAT Solvers, 5
The basic DPLL Framework
Algorithm: DPLL(formula, assignment) { if (deduce(formula, assignment) == SAT) return SAT; else if (deduce(formula, assignment) == CONF) return CONF; else { v = new_variable(formula, assignment); a = new_assignment(formula, assignment, v, 0); if (DPLL(formula, a) == SAT) return SAT; else { a = new_assignment(formula, assignment, v, 1); return DPLL(formula, a); } } }
Aditya Parameswaran, Luv Kumar: SAT Solvers, 6
Variations to the DPLL Algorithm
Iterative Algorithm while(1) { decide_next_branch(); //branching heuristics while (true) { status = deduce(); //deduction mechanism if (status == CONF) { bl = analyze_conflict(); //conflict analysis if (bl == 0) return UNSAT; else backtrack(bl); } else if (status == SATISFIABLE) return SAT; else break; } }
Aditya Parameswaran, Luv Kumar: SAT Solvers, 7
Variations to the DPLL Algorithm
Branching Heuristics Deduction Mechanism Conflict Analysis and Learning Other Techniques
Comparison of BerkMin and Chaff on Branching Heuristics Comparison of Chaff and SATO in BCP
Equivalence Classes
Aditya Parameswaran, Luv Kumar: SAT Solvers, 8
Variations to the DPLL Algorithm
Branching Heuristics
◮ Branching Heuristics alter the search path and thereby change
the structure of the search tree
◮ In the original DPLL paper, a branch was randomly chosen ◮ DLCS (Dynamic Largest Combined Sum)
unresolved clauses
Aditya Parameswaran, Luv Kumar: SAT Solvers, 9
Variations to the DPLL Algorithm
◮ VSIDS (Variable State Independent Decaying Sum)
the variable
◮ BerkMin method
for the conflict have their scores increased
Aditya Parameswaran, Luv Kumar: SAT Solvers, 10
Variations to the DPLL Algorithm
Deduction Mechanism
◮ Most important part of the solver (maximum time spent here) ◮ The function deduce() tries to see if by the current
assignment of values to variables, some conclusions can be got regarding the satisfiability of the formula
◮ It returns SAT if the assignment causes a satisfying instance
and CONF if it causes a conflict, else returns UNKNOWN and updates the program state.
◮ All SAT solvers use the unit clause rule ◮ The unit clause rule states that if all but one of the literals in
a clause are assigned false, then that literal is assigned true
◮ Such clauses are called unit clauses the unassigned literal is a
unit literal, the process of assigning 1 to all such literals is called BCP (Boolean Constraint Propagation)
◮ Counter Method is used in GRASP, Head-Tail List Method is
from SATO, and Two-Literal watch was first used in Chaff
Aditya Parameswaran, Luv Kumar: SAT Solvers, 11
Variations to the DPLL Algorithm
Deduction Mechanism (contd.)
◮ Counter Method
clause is contradictory
and number of 1 value literals equals 0 then it is an unit clause
clause then on an average ml/n counters are updated
Aditya Parameswaran, Luv Kumar: SAT Solvers, 12
Variations to the DPLL Algorithm
◮ Head-Tail List method
pos-tail, neg-tail, each of which contain pointers to the clauses which have their head/tail literal in the positive/negative phases of the variable.
a literal which does not evaluate to 1 such that,
is sat., and we stop
literal, then we move the head pointer
is a unit clause with tail literal as unit literal
conflicting clause
backtrack
Aditya Parameswaran, Luv Kumar: SAT Solvers, 13
Variations to the DPLL Algorithm
◮ Two Literal Watch method
containing pointers to all the clauses where the variable is watched in positive or negative phases
the neg-watched list, we search for a literal that is not set to 0
literal, then we make u the watched literal
then it is a unit clause
to 1, then it is sat.
then clause is conflicting
Aditya Parameswaran, Luv Kumar: SAT Solvers, 14
Variations to the DPLL Algorithm
Conflict Analysis and Learning
◮ Conflict Analysis tries to find the reason for the conflict and
tries to resolve it
◮ Original DPLL paper used Chronological Backtracking, in
which the last assignment that has not been flipped is flipped
◮ Non-Chronological Backtracking need not flip the last
assignment and could backtrack to a earlier decision level
◮ This was first introduced in GRASP ◮ Conflict Directed Learning incorporates learned Conflict
Clauses
◮ Conflict Clauses are obtained using Implication Graphs ◮ In Implication Graphs, all the variables, whose values are
either known or are implied are depicted
◮ Directed edges are drawn from the variables that make up part
Aditya Parameswaran, Luv Kumar: SAT Solvers, 15
Variations to the DPLL Algorithm
In the conflict clause, we include the following:
◮ The antecedents of the conflict which are decisions made in
the current decision level
◮ The antecedents of the conflict in previous decision levels ◮ Recursively, this procedure is applied to the antecedents which
are part of the current decision level, but are not decisions The backtrack level is the maximum of the decision levels of all the variables in the conflict clause
Aditya Parameswaran, Luv Kumar: SAT Solvers, 16
Variations to the DPLL Algorithm
Other Techniques
◮ In the deduce() function, some solvers use the pure literal rule
in addition to the unit clause rule
◮ Some solvers use Random Restarts inorder to discard the
search tree and start over
◮ Some solvers have a function preprocess() which tries to arrive
at conclusions before the start of the algorithm
◮ The learned clauses are deleted after a given period
Aditya Parameswaran, Luv Kumar: SAT Solvers, 17
Stalmarcks Algorithm
◮ Essentially breadth first search, we try both sides of a branch
to find forced decisions
◮ To prove validity of a formula, we assume the formula to be
false, and try to arrive at a contradiction
◮ All formulae are represented using → and ⊥, which is
represented as 0 in the triplet
◮ A formula is represented using a set of triplets ◮ A triplet (x, y, z) is an abbreviation for x ↔ (y → z) ◮ Example: p → (q → p) is represented as
◮ A terminal triplet is one that gives a contradiction, like
Aditya Parameswaran, Luv Kumar: SAT Solvers, 18
Stalmarcks Algorithm
◮ Triggering rules to be used for manipulation of formulae:
(0,y,z) y/1 z/0
(r2)
(x,y,1) x/1
(x,0,z) x/1
(r4)
(x,1,z) x/z
(x,y,0) x/¬y
(r6)
(x,x,z) x/1
(x,y,y) x/1
intersection of the assignments produced by the two derivations) T T[x/1] T[x/0] D1 D2 U[S1] V [S0] T[S]
applying the dilemma rule is the result of the other derivation
Aditya Parameswaran, Luv Kumar: SAT Solvers, 19
More Details And Examples
Chaff Branching Algorithm (VSIDS)
number of instances of that variable with the polarity
value incremented
chosen at each decision; ties broken at random by default
BerkMin Branching Algorithm
number of instances of that variable with the polarity
clause and those responsible for the conflict are incremented
chosen at each decision from the most recent clause added to the clause database; ties broken at random by default
Aditya Parameswaran, Luv Kumar: SAT Solvers, 20
More Details And Examples
BCP Algorithms:- SATO List Method If (neg_assigned(literal)) { from-pos-head(literal); from-pos-tail(literal); } If (pos_assigned(literal)) { from-neg-head(literal); from-neg-tail(literal); } from-pos-head(literal) { for all the clauses in pos-head list for i = head_lit + 1 to tail_lit if (truth_val (ith literal) == unknown) if (ith literal == tail literal) unit clause, add to unit clauses stack exclude clause; return else move pointer to ith literal; return else if (truth_val (ith literal) == TRUE) exclude clause; return conflict }
Aditya Parameswaran, Luv Kumar: SAT Solvers, 21
More Details And Examples
BCP Algorithms:- Two Literal Watch Method If (neg_assigned(literal)) for all the clauses in pos-watched list if there is a literal != 0 and != o. w. literal move the pointer to the given location if (literal == 1) then exclude clause else if (o. w. literal == undefined) unit clause, add to unit clauses list exclude clause else if (o. w. literal == 1) exclude clause else conflict end for If (pos_assigned(literal)) for all the clauses in neg-watched list ...
Aditya Parameswaran, Luv Kumar: SAT Solvers, 22
Local Search
◮ A cost function is assigned to every variable assignment, the
procedure tries to minimise the cost function by moving to “neighboring” assignments
◮ A greedy procedure is one which constantly tries to minimise
the cost function
◮ A move which does not change the cost function is a sideways
move with a sequence of such moves as a plateau
◮ Has a probability of getting stuck in a local minima. In order
to get out of a local minima, the following procedures are adopted:
unsatisfied clause is flipped, and with prob. (1-p) the greedy algorithm is followed
variable
◮ In most cases, if the initial assignment is close to the global
minima, then the solution can be obtained by minimising the cost function
Aditya Parameswaran, Luv Kumar: SAT Solvers, 23
Local Search
GSAT Algorithm a = set of clauses for i = 1 to MAX_TRIES T = a randomly generated truth assignment for j = 1 to MAX_FLIPS if T satisfies a then return T p = a prop. variable such that change in its truth assignment gives the largest increase in total number of clauses of a that are satisfied by T T = T with the truth assignment of p reversed end for return "no satifying assignment found" end
Aditya Parameswaran, Luv Kumar: SAT Solvers, 24
Phase Transitions
◮ Clauses are created randomly of fixed length ◮ The parameters of interest are: number of clauses(L), number
◮ Formulae with few clauses are underconstrained and usually
satisfiable
◮ Formulae with many clauses are overconstrained and usually
unsatisfiable
◮ Satisfiability of formulae in either extreme is easy to determine ◮ A phase transition tends to occur in between when the
problems are critically constrained and it is difficult to determine their satisfiability
◮ For random 2-SAT, the transition has been proven to occur at
L/N = 1
◮ For random 3-SAT, the transition has been experimentally
found to occur at L/N ≈ 4.3
Aditya Parameswaran, Luv Kumar: SAT Solvers, 25
Phase Transitions
Aditya Parameswaran, Luv Kumar: SAT Solvers, 26
More Details on Stalmarcks method
Equivalence Classes
◮ Are used to show relationships between variables ◮ Two formulae are said to be in the same equivalence class,
denoted as a ∼ b, if they have the same truth value
◮ It is not necessary to store the complementary class ◮ Initially there are the individual variable “undeterminate”
equivalence classes, and also the ⊤ and ⊥ classes
◮ Propagation rules merge atleast two equivalence classes, as
the proof progresses
◮ Instead of branching on truth/false we can branch by merging
equivalence classes (A ≡ B or A ≡ ¬B)
Aditya Parameswaran, Luv Kumar: SAT Solvers, 27
More Details on Stalmarcks method
Hardness, Proof Depth and Saturation
◮ A proof is said to be k-hard if there is no proof involving less
than k applications of the dilemma rule, and there exists a proof which involves k applications of dilemma rule
◮ Proof Depth has the following definition:
depth the maximum of the two above proofs
then the depth of the whole system is max(d1, d2) + 1
◮ Alternatively, proof depth is the maximum number of
simultaneously open branches
◮ A relation is k-saturated iff proofs of depth k or less do not
add any equivalences between the subformulas
Aditya Parameswaran, Luv Kumar: SAT Solvers, 28
References
quantification theory, Journal of ACM (1960)
for theorem proving, Communications of ACM (1962)
Automated deduction (1997)
propagation, Int. Symp. on AI and mathematics, 1996
solver, DATE - 2002
algorithm for satisfiability, IEEE (Int. Conf. on tools with AI)
procedure for propositional logic
Chaff: Engineering an efficient SAT solver, 39th Design
Aditya Parameswaran, Luv Kumar: SAT Solvers, 29
References
Automation Conf. 2001
solving hard satisfiability problems, National Conf. on AI, July 1992
http://www.inf.ed.ac.uk/teaching/courses/propm/papers/Zhang/
http://www-ti.informatik.uni-tuebingen.de/ ∼fmg/teaching/verif0405/BMC.pdf
Satisfiability Solvers
Presentation, www.inf.ed.ac.uk/teaching/courses/propm/papers/cav- cade2002.pdf All of these are available at www.cse.iitb.ac.in/∼ adityagp/sat/
Aditya Parameswaran, Luv Kumar: SAT Solvers, 30