SAT Solver Daniel Kroening Ofer Strichman 130 SAT

  • Slides: 30
Download presentation
SAT Solver Daniel Kroening, Ofer Strichman 1/30 SAT Solver PSWLAB Changki Hong @

SAT Solver Daniel Kroening, Ofer Strichman 1/30 SAT Solver PSWLAB Changki Hong @

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict Clauses and Resolution � Decision Heuristics � References 2/30 SAT Solver PSWLAB Changki Hong @

SAT made some progress… 3/30

SAT made some progress… 3/30

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict Clauses and Resolution � Decision Heuristics � References 4/30 SAT Solver PSWLAB Changki Hong @

Two main categories of SAT solver � Davis-Putnam-Loveland-Logemann framework (DPLL) � The solver can

Two main categories of SAT solver � Davis-Putnam-Loveland-Logemann framework (DPLL) � 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. SAT competition. Solver Changki Hong @ 5/30 PSWLAB

Status of a clause �A clause can be � Satisfied: at least one literal

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) x 1 1 0 0 x 2 0 0 0 x 3 0 0 6/30 Unresolved SAT Solver PSWLAB C Satisfied Unsatisfied Unit Changki Hong @

A Basic SAT algorithm Choose the next variable and value. Return False if all

A Basic SAT algorithm Choose the next variable and value. Return False if all variables are assigned While (true) { if (Decide() == FALSE) return (SAT); while (BCP() == “conflict”) { backtrack-level = Analyze_Conflict(); if (backtrack-level < 0) return (UNSAT); else Back. Track(backtrack-level); } Backtrack until no conflict. Return False if impossible Apply repeatedly the } clause rule. unit Return False if reached a conflict 7/30 SAT Solver PSWLAB Changki Hong @

A Basic SAT algorithm � Given in CNF: (x ∨ y ∨ z) ∧

A Basic SAT algorithm � Given in CNF: (x ∨ y ∨ z) ∧ (¬x ∨ y) ∧ (¬y ∨ z) ∧ (¬x ∨ ¬y ∨ ¬z) x=1 (y)∧ (¬y ∨ z ) ∧ (¬y ∨ ¬z ) y=1 (z) ∧ (¬z ) z=1 z=0 y=0 Decide() x=0 (y ∨ z) ∧ (¬y ∨ z ) z=1 () () X z=0 (y) ∧ (¬y) y=1 y=0 () () X X 8/30 SAT Solver PSWLAB BCP() Analyze_Conflict() Changki Hong @

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict Clauses and Resolution � Decision Heuristics � References 9/30 SAT Solver PSWLAB Changki Hong @

Boolean Constraints Propagation (BCP) � BCP is repeated application of the unit clause rule

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=v@d x ∈ {0, 1} is assigned to v at decision level d � The process of BCP is best illustrated with an implication graph. 10/30 SAT Solver PSWLAB Changki Hong @

Implication graph � Def: An implication graph is a labeled directed acyclic graph G(V,

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 = { (vi, vj) | vi, vj ∈ V, ¬vi ∈ Antecedent(vj) } denotes the set of directed edges where each edge (vi, vj) is labeled with Antecedent(vj). � 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). 11/30 SAT Solver PSWLAB Changki Hong @

Implication graphs and conflict clause Current truth assignment: {x 9=0@1 , x 10=0@3, x

Implication graphs and conflict clause Current truth assignment: {x 9=0@1 , x 10=0@3, x 11=0@3, x 12=1@2, x 13=1@2} Current decision assignment: {x 1=1@6} x 10=0@3 1 = ( x 1 x 2) 2 = ( x 1 x 3 x 9) x 2=1@6 1 3 = ( x 2 x 3 x 4) 4 = ( x 4 x 5 x 10) x 1=1@6 5 = ( x 4 x 6 x 11) 2 6 = ( x 5 x 6) 2 7 = (x 1 x 7 x 12) 8 = (x 1 x 8) 9 = ( x 7 x 8 x 13) 12/30 x 9=0@1 3 3 x 3=1@6 4 x 5=1@6 4 x 4=1@6 5 5 6 6 conflict x 6=1@6 x 11=0@3 We learn the conflict clause 10 = (¬x 1 ∨ x 9 ∨ x 11 ∨ x 10

Implication graph, flipped assignment x 13=1@2 1 = ( x 1 x 2) 2

Implication graph, flipped assignment x 13=1@2 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) x 8=1@6 x 9=0@1 10 x 10=0@3 10 8 x 1=0@6 10 x 11=0@3 Due to the conflict clause 7 7 9 9 9 ’ conflict x 7=1@6 x 12=1@2 8 = (x 1 x 8) 9 = ( x 7 x 8 x 13) 10 : ( x 1 x 9 x 11 x 10) 13/30 Another conflict clause: 11 = ( x 13 ∨ x 12 ∨ x 11 ∨ x 10 ∨ x 9)

Non-chronological backtracking 3 Which assignments caused the conflicts ? Decision level 4 x 9=

Non-chronological backtracking 3 Which assignments caused the conflicts ? Decision level 4 x 9= 0@1 x 10= 0@3 x 11= 0@3 x 12= 1@2 5 These assignments Are sufficient for Causing a conflict. x 13= 1@2 Backtrack to DL = 3 14/30 PSWLAB SAT Solver 6 ’ Nonchronological Changki Hong @ backtracking

Non-chronological backtracking � So the rule is: backtrack to the largest decision level in

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 3 = 0 x 4 = 0 x 5 = 0 x 6 = 0. . . x 5 = 1 x 7 = 1 x 9 = 0 15/30 SAT Solver PSWLAB x 9 = 1 Changki Hong @

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict Clauses and Resolution � Decision Heuristics � References 16/30 SAT Solver PSWLAB Changki Hong @

Conflict clauses � Def: A clause is asserting if the clause contains all value

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. 17/30 SAT Solver PSWLAB Changki Hong @

Unique Implication Points (UIP’s) � Definition: A Unique Implication Point (UIP) is an internal

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. 4 UIP 1 2 2 18/30 3 3 UIP 4 5 6 6 conflict 5 SAT Solver PSWLAB Changki Hong @

Conflict clauses and Resolution � The Binary-resolution : � Example:

Conflict clauses and Resolution � The Binary-resolution : � Example:

Conflict clauses and resolution This function is to return TRUE if and only if

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 20/30 SAT Solver PSWLAB Changki Hong @

Conflict clauses and resolution First UIP Resolution order : x 4, x 5, x

Conflict clauses and resolution First UIP Resolution order : x 4, x 5, x 6, x 7 21/30 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. SAT Solver PSWLAB Changki Hong @

Resolution graph Resolution Graph 4 1 4 3 3 2 6 5 2 6

Resolution graph Resolution Graph 4 1 4 3 3 2 6 5 2 6 conflict 5 1 2 3 10 4 9 10 10 8 7 7 22/30 PSWLAB 9 9 5 ’ conflict SAT Solver 6 11 7 8 9 Changki Hong @

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict Clauses and Resolution � Decision Heuristics � References 23/30 SAT Solver PSWLAB Changki Hong @

Decision heuristics - JW Jeroslow-Wang method for every clause and every variable l (in

Decision heuristics - JW Jeroslow-Wang method for every clause and every variable l (in each phase): � Compute � J(l) : = � Choose a variable l that maximizes J(l). � This gives an exponentially higher weight to literals in shorter clauses. 24/30 SAT Solver PSWLAB Changki Hong @

Decision heuristics - DLIS (Dynamic Largest Individual Sum) �Choose the assignment that satisfies the

Decision heuristics - DLIS (Dynamic Largest Individual Sum) �Choose the assignment that satisfies the largest number of currently unsatisfied clauses � Cxp – # unresolved clauses in which x appears Let x be the literal with Cxp � Let y be the literal with Cyp � If Cxp > Cyp choose x, Otherwise choose y � � Requires l (#literals) queries for each decision. 25/30 SAT Solver PSWLAB Changki Hong @

Decision heuristics – VSIDS (Variable State Independent Decaying Sum) 1. Each variable in each

Decision heuristics – VSIDS (Variable State Independent Decaying Sum) 1. Each variable in each polarity has a counter initialized to 0. 2. 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. (Implemented in Chaff) 26/30 SAT Solver PSWLAB Changki Hong @

Decision heuristics – VSIDS (cont’d) � Chaff holds a list of unassigned variables sorted

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. 27/30 SAT Solver PSWLAB Changki Hong @

Decision Heuristics - Berkmin � Keep conflict clauses in a stack � Choose the

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 28/30 gives absolute priority to conflicts. SAT Solver PSWLAB Changki Hong @

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict

Contents � Introduction � The DPLL framework � BCP and Implication Graph � Conflict Clauses and Resolution � Decision Heuristics � References 29/30 SAT Solver PSWLAB Changki Hong @

References Decision Procedures – Daniel Kroening and Ofer Strichman � The Quest for Efficient

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 � 30/30 SAT Solver PSWLAB Changki Hong @