1/30 SAT Solver Changki PSWLAB SAT Solver Daniel Kroening, Ofer Strichman
2/30 SAT Solver Changki PSWLAB Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References
3/30 SAT made some progress…
4/30 SAT Solver Changki PSWLAB Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References
5/30 SAT Solver Changki PSWLAB Two main categories of SAT solver Davis-Putnam-Loveland-Logemann (DPLL) framework The solver can be thought of as traversing and backtracking on a binary tree. Internal nodes represent partial assignments. Leave nodes represent full assignments. Stochastic search The solver guesses a full assignment, and then, if the formula is evaluated to FALSE under this assignment, starts to flip values of variables according to some heuristics. DPLL solvers are considered better in most cases according to the annual competition.
6/30 SAT Solver Changki PSWLAB Status of a clause A clause can be Satisfied: at least one literal is satisfied Unsatisfied: all literals are assigned but non are satisfied Unit: all but one literals are assigned but none are satisfied Unresolved: all other cases Example: C = ( x 1 ∨ x 2 ∨ x 3 ) x1x1 x2x2 x3x3 C 10Satisfied 000Unsatisfied 00Unit 0Unresolved
7/30 SAT Solver Changki PSWLAB A Basic SAT algorithm While (true) { if (Decide() == FALSE) return (SAT); while (BCP() == “conflict”) { backtrack-level = Analyze_Conflict(); if (backtrack-level < 0) return (UNSAT); else BackTrack(backtrack-level); } Choose the next variable and value. Return False if all variables are assigned Apply repeatedly the unit clause rule. Return False if reached a conflict Backtrack until no conflict. Return False if impossible
8/30 SAT Solver Changki PSWLAB Given in CNF: (x ∨ y ∨ z) ∧ ( ¬ x ∨ y) ∧ ( ¬ y ∨ z) ∧ ( ¬ x ∨ ¬ y ∨ ¬ z) Decide() BCP() Analyze_Conflict() A Basic SAT algorithm (y) ∧ ( ¬ y ∨ z ) ∧ ( ¬ y ∨ ¬ z ) (y ∨ z) ∧ ( ¬ y ∨ z ) (z) ∧ ( ¬ z ) ( ) (y) ∧ ( ¬ y) ( ) x = 1x = 0 y = 1y = 0z = 1z = 0 z = 1z = 0 y = 1y = 0 X XX XX
9/30 SAT Solver Changki PSWLAB Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References
10/30 SAT Solver Changki PSWLAB Boolean Constraints Propagation (BCP) BCP is repeated application of the unit clause rule until either a conflict is encountered or there are no more implications. Each assignment is associated with the decision level at which it occurred. notation : x ∈ {0,1} is assigned to v at decision level d The process of BCP is best illustrated with an implication graph.
11/30 SAT Solver Changki PSWLAB Implication graph Def: An implication graph is a labeled directed acyclic graph G(V, E), where: V represents the literals of the current partial assignment. Each node is labeled with the literal that it represents and the decision level at which it entered the partial assignment. E with E = { (v i, v j ) | v i, v j ∈ V, ¬ v i ∈ Antecedent(v j ) } denotes the set of directed edges where each edge (v i, v j ) is labeled with Antecedent(v j ). Def: For a given unit clause C with an unassigned literal l, we say that l is implied by C and that C is the antecedent clause of l, denoted by Antecedent(l).
12/30 55 55 x 6 Implication graphs and conflict clause 1 = ( x 1 x 2 ) 2 = ( x 1 x 3 x 9 ) 3 = ( x 2 x 3 x 4 ) 4 = ( x 4 x 5 x 10 ) 5 = ( x 4 x 6 x 11 ) 6 = ( x 5 x 6 ) 7 = (x 1 x 7 x 12 ) 8 = (x 1 x 8 ) 9 = ( x 7 x 8 x 13 ) 1 = ( x 1 x 2 ) 2 = ( x 1 x 3 x 9 ) 3 = ( x 2 x 3 x 4 ) 4 = ( x 4 x 5 x 10 ) 5 = ( x 4 x 6 x 11 ) 6 = ( x 5 x 6 ) 7 = (x 1 x 7 x 12 ) 8 = (x 1 x 8 ) 9 = ( x 7 x 8 x 13 ) Current truth assignment: {x 9 10 x 11 x 12 x 13 Current decision assignment: {x 1 66 66 conflict x 9 x 1 x 10 x 11 x 5 44 44 22 22 x 3 11 x 2 33 33 x 4 We learn the conflict clause 10 = ( ¬ x 1 ∨ x 9 ∨ x 11 ∨ x 10 )
13/30 Implication graph, flipped assignment x 1 x 11 x 10 x 9 x 7 x 12 77 77 x 8 88 10 99 99 ’’ x 13 99 Due to the conflict clause 1 = ( x 1 x 2 ) 2 = ( x 1 x 3 x 9 ) 3 = ( x 2 x 3 x 4 ) 4 = ( x 4 x 5 x 10 ) 5 = ( x 4 x 6 x 11 ) 6 = ( x 5 x 6 ) 7 = (x 1 x 7 x 12 ) 8 = (x 1 x 8 ) 9 = ( x 7 x 8 x 13 ) 10 : ( x 1 x 9 x 11 x 10 ) 1 = ( x 1 x 2 ) 2 = ( x 1 x 3 x 9 ) 3 = ( x 2 x 3 x 4 ) 4 = ( x 4 x 5 x 10 ) 5 = ( x 4 x 6 x 11 ) 6 = ( x 5 x 6 ) 7 = (x 1 x 7 x 12 ) 8 = (x 1 x 8 ) 9 = ( x 7 x 8 x 13 ) 10 : ( x 1 x 9 x 11 x 10 ) Another conflict clause: 11 = ( x 13 ∨ x 12 ∨ x 11 ∨ x 10 ∨ x 9 ) conflict
14/30 SAT Solver Changki PSWLAB Non-chronological backtracking Non- chronological backtracking x ’’ Decision level Which assignments caused the conflicts ? x 9 = x 10 = x 11 = x 12 = x 13 = Backtrack to DL = 3 3 These assignments Are sufficient for Causing a conflict.
15/30 SAT Solver Changki PSWLAB Non-chronological backtracking So the rule is: backtrack to the largest decision level in the conflict clause. x 1 = 0 x 2 = 0 x 3 = 1 x 4 = 0 x 5 = 0 x 7 = 1 x 9 = 0 x 6 = 0... x 5 = 1 x 9 = 1 x 3 = 0
16/30 SAT Solver Changki PSWLAB Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References
17/30 SAT Solver Changki PSWLAB Conflict clauses Def: A clause is asserting if the clause contains all value 0 literals; and among them only one is assigned at current decision level. After backtracking, this clause will become a unit clause and force the literal to assume another value, thus bringing the search to a new space. Modern solvers only consider Asserting Clauses.
18/30 SAT Solver Changki PSWLAB Unique Implication Points (UIP’s) Definition: A Unique Implication Point (UIP) is an internal node in the implication graph that all paths from the decision to the conflict node go through it. The First-UIP is the closest UIP to the conflict. 55 55 66 66 conflict 44 44 22 22 11 33 33 UIP
Conflict clauses and Resolution The Binary-resolution : Example:
20/30 SAT Solver Changki PSWLAB Conflict clauses and resolution This function is to return TRUE if and only if cl contains the negation of the first UIP as its single literal at the current decision level
21/30 SAT Solver Changki PSWLAB Conflict clauses and resolution Resolution order : x 4, x 5, x 6, x 7 Since the c 5 contains the negation of the first UIP as its single literal at the current decision level, the stop criterion is met. c 5 is asserting clause. First UIP
22/30 SAT Solver Changki PSWLAB Resolution graph 11 22 33 44 55 66 10 77 88 99 11 77 77 88 10 99 99 ’ conflict 55 55 66 66 conflict 44 44 22 22 11 33 33 99 Resolution Graph
23/30 SAT Solver Changki PSWLAB Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References
24/30 SAT Solver Changki PSWLAB Compute for every clause and every variable l (in each phase): J ( l ) := Choose a variable l that maximizes J ( l ). This gives an exponentially higher weight to literals in shorter clauses. Decision heuristics - JW Jeroslow-Wang method
25/30 SAT Solver Changki PSWLAB Choose the assignment that satisfies the largest number of currently unsatisfied clauses C x p – # unresolved clauses in which x appears Let x be the literal with C xp Let y be the literal with C yp If C xp > C yp choose x, Otherwise choose y Requires l (#literals) queries for each decision. DLIS (Dynamic Largest Individual Sum) Decision heuristics - DLIS
26/30 SAT Solver Changki PSWLAB Decision heuristics – VSIDS (Implemented in Chaff) VSIDS (Variable State Independent Decaying Sum) 1.Each variable in each polarity has a counter initialized to When a clause is added, the counters are updated. 3. The unassigned variable with the highest counter is chosen. 4. Periodically, all the counters are divided by a constant.
27/30 SAT Solver Changki PSWLAB Decision heuristics – VSIDS (cont’d) Chaff holds a list of unassigned variables sorted by the counter value. Updates are needed only when adding conflict clauses. Thus decision is made in constant time.
28/30 SAT Solver Changki PSWLAB Decision Heuristics - Berkmin Keep conflict clauses in a stack Choose the first unresolved clause in the stack If there is no such clause, use VSIDS Choose from this clause a variable + value according to some scoring (e.g. VSIDS) This gives absolute priority to conflicts.
29/30 SAT Solver Changki PSWLAB Contents Introduction The DPLL framework BCP and Implication Graph Conflict Clauses and Resolution Decision Heuristics References
30/30 SAT Solver Changki PSWLAB References Decision Procedures – Daniel Kroening and Ofer Strichman The Quest for Efficient Boolean Satisfiability Solvers – Lintao Zhang and Sharad Malik Efficient Conflict Driven Learning in a Boolean Satisfiability Solver – Lintao Zhang, Conor F. Madigan, Matthew H. Moskewicz and Sharad Malik