solvers principles and architecture spa
play

Solvers Principles and Architecture (SPA) Part 1 Anatomy of SAT - PowerPoint PPT Presentation

Solvers Principles and Architecture (SPA) Part 1 Anatomy of SAT Solvers Master Sciences Informatique (Sif) September, 2019 Rennes Khalil Ghorbal k halil.ghorbal@inria.fr K. Ghorbal (INRIA) 1 SIF M2 1 / 58 Outline 1 Propositional Logic 2


  1. Equivalence versus EquiSatisfiability Recall (Tautological) Equivalence w 1 ∼ w 2 if and only if ∀ σ. ( � w 1 � σ = 1 ← → � w 2 � σ = 1) Equisatisfiability w 1 ∼ SAT w 2 if and only if ( ∃ σ. � w 1 � σ = 1) ← → ( ∃ σ. � w 2 � σ = 1) Equisatisfiability does not imply tautological equivalence! • w 1 := s 1 ∧ ( s 1 ↔ s 2 ) and w 2 := s 1 • w 1 ∼ SAT w 2 but w 1 �∼ w 2 K. Ghorbal (INRIA) 12 SIF M2 12 / 58

  2. Equivalence versus EquiSatisfiability Recall (Tautological) Equivalence w 1 ∼ w 2 if and only if ∀ σ. ( � w 1 � σ = 1 ← → � w 2 � σ = 1) Equisatisfiability w 1 ∼ SAT w 2 if and only if ( ∃ σ. � w 1 � σ = 1) ← → ( ∃ σ. � w 2 � σ = 1) Equisatisfiability does not imply tautological equivalence! • w 1 := s 1 ∧ ( s 1 ↔ s 2 ) and w 2 := s 1 • w 1 ∼ SAT w 2 but w 1 �∼ w 2 K. Ghorbal (INRIA) 12 SIF M2 12 / 58

  3. Outline 1 Propositional Logic 2 CNF Transformation 3 DPLL-based Algorithms Unit Propagation Branching and Learning 4 Conclusion 5 Reduction Examples K. Ghorbal (INRIA) 12 SIF M2 12 / 58

  4. Definitions • Literal : propositional symbol (atomic expression) or its negation • Clause : disjunction of one or more literals • Positive Occurrence: if the symbol occurs unnegated in a clause • Negative Occurrence: if the symbol occurs negated in a clause K. Ghorbal (INRIA) 13 SIF M2 13 / 58

  5. Definitions • Literal : propositional symbol (atomic expression) or its negation • Clause : disjunction of one or more literals • Positive Occurrence: if the symbol occurs unnegated in a clause • Negative Occurrence: if the symbol occurs negated in a clause K. Ghorbal (INRIA) 13 SIF M2 13 / 58

  6. Conjunctive Normal Form (CNF) An expression w is in CNF if and only if it has the form � � w = ℓ ij i j • Each ℓ ij is a literal • Thus, a CNF is a conjunction of clauses Example: ( s 1 ∨ ¬ s 3 ) ∧ ( ¬ s 2 ∨ s 3 ∨ s 4 ) � �� � � �� � c 1 c 2 • 4 variable symbols: s 1 , s 2 , s 3 , and s 4 • clause c 1 (resp. c 2 ) has 2 (resp. 3) literals • s 3 is negative in c 1 and positive in c 2 K. Ghorbal (INRIA) 14 SIF M2 14 / 58

  7. Converting to CNF Equivalent CNF is Exponential Converting a wff w to an equivalent formula in CNF using De Morgan’s Laws and distributivity may increase the number of logical operations (Boolean gates) exponentially . Example • w 1 := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ), by distributivity (2 2 clauses) • w 1 ∼ w 2 := ( s 1 ∨ s 3 ) ∧ ( s 1 ∨ s 4 ) ∧ ( s 2 ∨ s 3 ) ∧ ( s 2 ∨ s 4 ) • w 1 := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) ∨ ( s 5 ∧ s 6 ) · · · ∨ ( s n ∧ s n +1 ) • Now w 1 ∼ w 2 , and w 2 in CNF, but w 2 has 2 n − 1 clauses! • We seek to avoid such exponential cost for the CNF reduction K. Ghorbal (INRIA) 15 SIF M2 15 / 58

  8. Converting to CNF Equivalent CNF is Exponential Converting a wff w to an equivalent formula in CNF using De Morgan’s Laws and distributivity may increase the number of logical operations (Boolean gates) exponentially . Example • w 1 := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ), by distributivity (2 2 clauses) • w 1 ∼ w 2 := ( s 1 ∨ s 3 ) ∧ ( s 1 ∨ s 4 ) ∧ ( s 2 ∨ s 3 ) ∧ ( s 2 ∨ s 4 ) • w 1 := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) ∨ ( s 5 ∧ s 6 ) · · · ∨ ( s n ∧ s n +1 ) • Now w 1 ∼ w 2 , and w 2 in CNF, but w 2 has 2 n − 1 clauses! • We seek to avoid such exponential cost for the CNF reduction K. Ghorbal (INRIA) 15 SIF M2 15 / 58

  9. Converting to CNF Equivalent CNF is Exponential Converting a wff w to an equivalent formula in CNF using De Morgan’s Laws and distributivity may increase the number of logical operations (Boolean gates) exponentially . Example • w 1 := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ), by distributivity (2 2 clauses) • w 1 ∼ w 2 := ( s 1 ∨ s 3 ) ∧ ( s 1 ∨ s 4 ) ∧ ( s 2 ∨ s 3 ) ∧ ( s 2 ∨ s 4 ) • w 1 := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) ∨ ( s 5 ∧ s 6 ) · · · ∨ ( s n ∧ s n +1 ) • Now w 1 ∼ w 2 , and w 2 in CNF, but w 2 has 2 n − 1 clauses! • We seek to avoid such exponential cost for the CNF reduction K. Ghorbal (INRIA) 15 SIF M2 15 / 58

  10. Converting to CNF Equivalent CNF is Exponential Converting a wff w to an equivalent formula in CNF using De Morgan’s Laws and distributivity may increase the number of logical operations (Boolean gates) exponentially . Example • w 1 := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ), by distributivity (2 2 clauses) • w 1 ∼ w 2 := ( s 1 ∨ s 3 ) ∧ ( s 1 ∨ s 4 ) ∧ ( s 2 ∨ s 3 ) ∧ ( s 2 ∨ s 4 ) • w 1 := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) ∨ ( s 5 ∧ s 6 ) · · · ∨ ( s n ∧ s n +1 ) • Now w 1 ∼ w 2 , and w 2 in CNF, but w 2 has 2 n − 1 clauses! • We seek to avoid such exponential cost for the CNF reduction K. Ghorbal (INRIA) 15 SIF M2 15 / 58

  11. Converting to CNF Tseytin Transformation [Tseytin 1970] Trick : Converting an expression by adding new propositional variables and substituting for nested operations. We avoid the exponential cost at the price of losing the (tautological) equivalence. Example w := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) � �� � � �� � p 1 p 2 � �� � p 3 • p 1 ↔ ( s 1 ∧ s 2 ) • p 2 ↔ ( s 3 ∧ s 4 ) • p 3 ↔ p 1 ∨ p 2 • w ∼ SAT ( p 1 ↔ ( s 1 ∧ s 2 )) ∧ ( p 2 ↔ ( s 3 ∧ s 4 )) ∧ ( p 3 ↔ p 1 ∨ p 2 ) ∧ p 3 K. Ghorbal (INRIA) 16 SIF M2 16 / 58

  12. Converting to CNF Tseytin Transformation [Tseytin 1970] Trick : Converting an expression by adding new propositional variables and substituting for nested operations. We avoid the exponential cost at the price of losing the (tautological) equivalence. Example w := ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) � �� � � �� � p 1 p 2 � �� � p 3 • p 1 ↔ ( s 1 ∧ s 2 ) • p 2 ↔ ( s 3 ∧ s 4 ) • p 3 ↔ p 1 ∨ p 2 • w ∼ SAT ( p 1 ↔ ( s 1 ∧ s 2 )) ∧ ( p 2 ↔ ( s 3 ∧ s 4 )) ∧ ( p 3 ↔ p 1 ∨ p 2 ) ∧ p 3 K. Ghorbal (INRIA) 16 SIF M2 16 / 58

  13. Converting to CNF Tseytin Transformation [Tseytin 1970] • p ↔ ( ℓ 1 ∧ ℓ 2 ) ∼ ( ¬ p ∨ ℓ 1 ) ∧ ( ¬ p ∨ ℓ 2 ) ∧ ( ¬ ℓ 1 ∨ ¬ ℓ 2 ∨ p ) (CNF) • p ↔ ( ℓ 1 ∨ ℓ 2 ) ∼ ¬ p ↔ ( ¬ ℓ 1 ∧ ¬ ℓ 2 ) • p ↔ ℓ ∼ p ↔ ℓ ∧ 1 • Each operator (gate) adds at most 3 clauses. • An expression with m operators becomes a CNF • with at most 3 m + 1, O ( m ), clauses, and • an additional m propositional variables • Linear increase in size K. Ghorbal (INRIA) 17 SIF M2 17 / 58

  14. Converting to CNF Tseytin Transformation [Tseytin 1970] • p ↔ ( ℓ 1 ∧ ℓ 2 ) ∼ ( ¬ p ∨ ℓ 1 ) ∧ ( ¬ p ∨ ℓ 2 ) ∧ ( ¬ ℓ 1 ∨ ¬ ℓ 2 ∨ p ) (CNF) • p ↔ ( ℓ 1 ∨ ℓ 2 ) ∼ ¬ p ↔ ( ¬ ℓ 1 ∧ ¬ ℓ 2 ) • p ↔ ℓ ∼ p ↔ ℓ ∧ 1 • Each operator (gate) adds at most 3 clauses. • An expression with m operators becomes a CNF • with at most 3 m + 1, O ( m ), clauses, and • an additional m propositional variables • Linear increase in size K. Ghorbal (INRIA) 17 SIF M2 17 / 58

  15. Converting to CNF Tseytin Transformation [Tseytin 1970] • p ↔ ( ℓ 1 ∧ ℓ 2 ) ∼ ( ¬ p ∨ ℓ 1 ) ∧ ( ¬ p ∨ ℓ 2 ) ∧ ( ¬ ℓ 1 ∨ ¬ ℓ 2 ∨ p ) (CNF) • p ↔ ( ℓ 1 ∨ ℓ 2 ) ∼ ¬ p ↔ ( ¬ ℓ 1 ∧ ¬ ℓ 2 ) • p ↔ ℓ ∼ p ↔ ℓ ∧ 1 • Each operator (gate) adds at most 3 clauses. • An expression with m operators becomes a CNF • with at most 3 m + 1, O ( m ), clauses, and • an additional m propositional variables • Linear increase in size K. Ghorbal (INRIA) 17 SIF M2 17 / 58

  16. Converting to CNF Tseytin Transformation [Tseytin 1970] • p ↔ ( ℓ 1 ∧ ℓ 2 ) ∼ ( ¬ p ∨ ℓ 1 ) ∧ ( ¬ p ∨ ℓ 2 ) ∧ ( ¬ ℓ 1 ∨ ¬ ℓ 2 ∨ p ) (CNF) • p ↔ ( ℓ 1 ∨ ℓ 2 ) ∼ ¬ p ↔ ( ¬ ℓ 1 ∧ ¬ ℓ 2 ) • p ↔ ℓ ∼ p ↔ ℓ ∧ 1 • Each operator (gate) adds at most 3 clauses. • An expression with m operators becomes a CNF • with at most 3 m + 1, O ( m ), clauses, and • an additional m propositional variables • Linear increase in size K. Ghorbal (INRIA) 17 SIF M2 17 / 58

  17. DiMaCS Standard • Each propositional variable is represented by a positive integer • A negative integer refers to negative occurrences • Clauses are given as sequences of integers separated by spaces • A 0 terminates the clause Example : • ( s 1 ∨ ¬ s 3 ) ∧ ( ¬ s 2 ∨ s 3 ∨ s 4 ) • 1 -3 0 -2 3 4 0 K. Ghorbal (INRIA) 18 SIF M2 18 / 58

  18. DiMaCS Standard • Each propositional variable is represented by a positive integer • A negative integer refers to negative occurrences • Clauses are given as sequences of integers separated by spaces • A 0 terminates the clause Example : • ( s 1 ∨ ¬ s 3 ) ∧ ( ¬ s 2 ∨ s 3 ∨ s 4 ) • 1 -3 0 -2 3 4 0 K. Ghorbal (INRIA) 18 SIF M2 18 / 58

  19. Outline 1 Propositional Logic 2 CNF Transformation 3 DPLL-based Algorithms Unit Propagation Branching and Learning 4 Conclusion 5 Reduction Examples K. Ghorbal (INRIA) 18 SIF M2 18 / 58

  20. EquiSAT CNF Conversion Tseytin Transformation Let w be a wff expression (a.k.a. Boolean function) of size n . Then, using Tseytin Transformation, w can be converted, in polynomial time , into an equisatisfiable expression w ′ in CNF . So, one may assume that we already have a CNF to begin with. K. Ghorbal (INRIA) 19 SIF M2 19 / 58

  21. SAT Decision Problem Given a well-formed formula w as an input, if there exists a σ that satisfies w return SAT (with σ ), otherwise return UNSAT . K. Ghorbal (INRIA) 20 SIF M2 20 / 58

  22. Brute Force Algorithm Example s 1 ∧ ( s 2 ∨ ¬ s 1 ) ∧ ( s 3 ∨ ¬ s 2 ) s 1 s 2 s 3 s 1 ∧ (( s 2 ∨ ¬ s 1 ) ∧ ( s 3 ∨ ¬ s 2 )) K. Ghorbal (INRIA) 21 SIF M2 21 / 58

  23. Brute Force Algorithm Example s 1 ∧ ( s 2 ∨ ¬ s 1 ) ∧ ( s 3 ∨ ¬ s 2 ) s 1 s 2 s 3 s 1 ∧ (( s 2 ∨ ¬ s 1 ) ∧ ( s 3 ∨ ¬ s 2 )) (1) 0 0 0 0 1 1 1 1 1 K. Ghorbal (INRIA) 21 SIF M2 21 / 58

  24. Brute Force Algorithm Example s 1 ∧ ( s 2 ∨ ¬ s 1 ) ∧ ( s 3 ∨ ¬ s 2 ) s 1 s 2 s 3 s 1 ∧ (( s 2 ∨ ¬ s 1 ) ∧ ( s 3 ∨ ¬ s 2 )) (1) 0 0 0 0 1 1 1 1 1 (2) 0 0 1 0 1 1 1 1 1 (3) 0 1 0 0 1 1 0 0 0 (4) 0 1 1 0 1 1 1 1 0 (5) 1 0 0 0 0 0 0 1 1 (6) 1 0 1 0 0 0 0 1 1 (7) 1 1 0 0 1 0 0 0 0 K. Ghorbal (INRIA) 21 SIF M2 21 / 58

  25. Brute Force Algorithm Example s 1 ∧ ( s 2 ∨ ¬ s 1 ) ∧ ( s 3 ∨ ¬ s 2 ) s 1 s 2 s 3 s 1 ∧ (( s 2 ∨ ¬ s 1 ) ∧ ( s 3 ∨ ¬ s 2 )) (1) 0 0 0 0 1 1 1 1 1 (2) 0 0 1 0 1 1 1 1 1 (3) 0 1 0 0 1 1 0 0 0 (4) 0 1 1 0 1 1 1 1 0 (5) 1 0 0 0 0 0 0 1 1 (6) 1 0 1 0 0 0 0 1 1 (7) 1 1 0 0 1 0 0 0 0 (8) 1 1 1 1 1 0 1 1 0 K. Ghorbal (INRIA) 21 SIF M2 21 / 58

  26. SAT Facts • Brute force algorithm: exponential complexity : • 2 n cases for n propositional symbol • SAT is the first problem to be proven to be NP-complete [Cook 1971] • SAT solves any decision problem in NP (that is why we call it ” complete” ) • No known Polynomial time algorithm for solving SAT (otherwise P=NP) • Yet, modern SAT Solvers are arguably efficient , why? K. Ghorbal (INRIA) 22 SIF M2 22 / 58

  27. SAT Facts • Brute force algorithm: exponential complexity : • 2 n cases for n propositional symbol • SAT is the first problem to be proven to be NP-complete [Cook 1971] • SAT solves any decision problem in NP (that is why we call it ” complete” ) • No known Polynomial time algorithm for solving SAT (otherwise P=NP) • Yet, modern SAT Solvers are arguably efficient , why? K. Ghorbal (INRIA) 22 SIF M2 22 / 58

  28. SAT Facts • Brute force algorithm: exponential complexity : • 2 n cases for n propositional symbol • SAT is the first problem to be proven to be NP-complete [Cook 1971] • SAT solves any decision problem in NP (that is why we call it ” complete” ) • No known Polynomial time algorithm for solving SAT (otherwise P=NP) • Yet, modern SAT Solvers are arguably efficient , why? K. Ghorbal (INRIA) 22 SIF M2 22 / 58

  29. SAT Facts • Brute force algorithm: exponential complexity : • 2 n cases for n propositional symbol • SAT is the first problem to be proven to be NP-complete [Cook 1971] • SAT solves any decision problem in NP (that is why we call it ” complete” ) • No known Polynomial time algorithm for solving SAT (otherwise P=NP) • Yet, modern SAT Solvers are arguably efficient , why? K. Ghorbal (INRIA) 22 SIF M2 22 / 58

  30. SAT Facts • Brute force algorithm: exponential complexity : • 2 n cases for n propositional symbol • SAT is the first problem to be proven to be NP-complete [Cook 1971] • SAT solves any decision problem in NP (that is why we call it ” complete” ) • No known Polynomial time algorithm for solving SAT (otherwise P=NP) • Yet, modern SAT Solvers are arguably efficient , why? K. Ghorbal (INRIA) 22 SIF M2 22 / 58

  31. DP Algorithm Davis, Putnam, 1960 Satisfiability-Preserving Transformations • Pure literal rule or affirmative-negative rule • Unit propagation or 1-literal rule • Resolution rule or rule for eliminating literals (atomic expressions) DP Algorithm Iteratively apply the rules till reducing the problem to a unique clause • if the clause has the form s ∧ ¬ s the problem is unsat • otherwise, the problem is sat K. Ghorbal (INRIA) 23 SIF M2 23 / 58

  32. DP Algorithm Davis, Putnam, 1960 Satisfiability-Preserving Transformations • Pure literal rule or affirmative-negative rule • Unit propagation or 1-literal rule • Resolution rule or rule for eliminating literals (atomic expressions) DP Algorithm Iteratively apply the rules till reducing the problem to a unique clause • if the clause has the form s ∧ ¬ s the problem is unsat • otherwise, the problem is sat K. Ghorbal (INRIA) 23 SIF M2 23 / 58

  33. Pure Literal Rule Pure literal i.e. appears only positively or only negatively , ℓ say Delete all clauses containing that literal • A clause containing ℓ has the form ℓ ∨ w ( w ′ has no ℓ in it) • ( ℓ ∨ w 1 ) ∧ · · · ( ℓ ∨ w m ) ∧ w ′ w ′ ∼ SAT ➻ Augment σ such that � ℓ � σ = 1 K. Ghorbal (INRIA) 24 SIF M2 24 / 58

  34. Example of Preprocessing with Pure Literal Rule (¯ (¯ 4 and ¯ (1 and 7) 2) 5) 1 ∨ 2 1 ∨ 2 1 ∨ 2 1 ∨ 3 ∨ 8 1 ∨ 3 ∨ 8 1 ∨ 3 ∨ 8 ¯ 2 ∨ ¯ 2 ∨ ¯ ¯ 2 ∨ ¯ ¯ 3 ∨ 4 3 ∨ 4 3 ∨ 4 ¯ ¯ ¯ 4 ∨ 5 ∨ 7 4 ∨ 5 ∨ 7 4 ∨ 5 ∨ 7 ¯ ¯ ¯ 4 ∨ 6 ∨ 8 4 ∨ 6 ∨ 8 4 ∨ 6 ∨ 8 5 ∨ ¯ ¯ ¯ 5 ∨ ¯ ¯ 5 ∨ ¯ 6 6 6 7 ∨ ¯ 7 ∨ ¯ 7 ∨ ¯ 8 8 8 7 ∨ ¯ 7 ∨ ¯ 7 ∨ ¯ 9 ∨ 10 9 ∨ 10 9 ∨ 10 ➻ SAT! σ = { 1 , 7 , ¯ 2 , ¯ 4 , ¯ 5 } (with anything for { 6 , 8 } ) K. Ghorbal (INRIA) 25 SIF M2 25 / 58

  35. Unit Propagation Unit clause is a clause with only one literal , ℓ say A CNF containing a unit clause ℓ has the form ℓ ∧ ( ℓ ∨ w 1 ) ∧ ( ¬ ℓ ∨ w 2 ) ∧ w 3 Remove all the clauses containing ℓ • ℓ ∧ ( ℓ ∨ w 1 ) ∧ · · · ∧ ( ℓ ∨ w m ) ∧ w ′ w ′ ∼ SAT Remove all instances of ¬ ℓ from all the clauses • ℓ ∧ ( ¬ ℓ ∨ w 1 ) ∧ · · · ∧ ( ¬ ℓ ∨ w m ) ∧ w ′ w 1 ∧ · · · ∧ w m ∧ w ′ ∼ SAT ➻ Augment σ such that � ℓ � σ = 1 K. Ghorbal (INRIA) 26 SIF M2 26 / 58

  36. Resolution Rule If ℓ or its negation do not appear in the wff w , then ( ℓ ∨ a ) ∧ ( ¬ ℓ ∨ b ) ∧ w ∼ SAT ( a ∨ b ) ∧ w � �� � resolvent Generalizing to several clauses:   � � � �  ∧ w ( ℓ ∨ a i ) ∧ ( ¬ ℓ ∨ b j ) ∧ w ∼ SAT a i ∨ b j i j i j Converting back to a CNF     � � � �  ∧ w  ∧ w a i ∨ b j ∼ ( a i ∨ b j ) i j i j K. Ghorbal (INRIA) 27 SIF M2 27 / 58

  37. Resolution Rule If ℓ or its negation do not appear in the wff w , then ( ℓ ∨ a ) ∧ ( ¬ ℓ ∨ b ) ∧ w ∼ SAT ( a ∨ b ) ∧ w � �� � resolvent Generalizing to several clauses:   � � � �  ∧ w ( ℓ ∨ a i ) ∧ ( ¬ ℓ ∨ b j ) ∧ w ∼ SAT a i ∨ b j i j i j Converting back to a CNF     � � � �  ∧ w  ∧ w a i ∨ b j ∼ ( a i ∨ b j ) i j i j K. Ghorbal (INRIA) 27 SIF M2 27 / 58

  38. Resolution Rule If ℓ or its negation do not appear in the wff w , then ( ℓ ∨ a ) ∧ ( ¬ ℓ ∨ b ) ∧ w ∼ SAT ( a ∨ b ) ∧ w � �� � resolvent Generalizing to several clauses:   � � � �  ∧ w ( ℓ ∨ a i ) ∧ ( ¬ ℓ ∨ b j ) ∧ w ∼ SAT a i ∨ b j i j i j Converting back to a CNF     � � � �  ∧ w  ∧ w a i ∨ b j ∼ ( a i ∨ b j ) i j i j K. Ghorbal (INRIA) 27 SIF M2 27 / 58

  39. Resolution Rule (cont’d) To summarize, if ℓ or its negation do not appear in the wff w , then   r s r s � � � �  ∧ w ( ℓ ∨ a i ) ∧ ( ¬ ℓ ∨ b j ) ∧ w ∼ SAT ( a i ∨ b j )  i =1 j =1 i =1 j =1 • Before applying the resolution rule the CNF had r + s clauses containing ℓ or its negation • After applying the rule, the so obtained CNF has rs clauses ... • and ℓ is resolved (eliminated, simplified). • Thus, no explicit assignment is required for ℓ . K. Ghorbal (INRIA) 28 SIF M2 28 / 58

  40. DP Algorithm: Practical Considerations Davis, Putnam, 1960 Satisfiability-Preserving Transformations • Pure literal rule or affirmative-negative rule • Unit propagation or 1-literal rule • Resolution rule or rule for eliminating literals In practice • Pure literal rule is expensive to detect dynamically • Unit propagation consumes the most significant runtime • Resolution rule can exhaust rapidly the available memory K. Ghorbal (INRIA) 29 SIF M2 29 / 58

  41. DP Algorithm: Practical Considerations Davis, Putnam, 1960 Satisfiability-Preserving Transformations • Pure literal rule or affirmative-negative rule • Unit propagation or 1-literal rule • Resolution rule or rule for eliminating literals In practice • Pure literal rule is expensive to detect dynamically • Unit propagation consumes the most significant runtime • Resolution rule can exhaust rapidly the available memory K. Ghorbal (INRIA) 29 SIF M2 29 / 58

  42. Outline 1 Propositional Logic 2 CNF Transformation 3 DPLL-based Algorithms Unit Propagation Branching and Learning 4 Conclusion 5 Reduction Examples K. Ghorbal (INRIA) 29 SIF M2 29 / 58

  43. Example Counter-Based Algorithm for BCP C 1 := x ∨ y , C 2 := ¬ x ∨ y ∨ ¬ z , C 3 := x ∨ z , C 4 := x ∨ ¬ z Suppose σ = { z } , that is z is assigned 1. Let # C := ( C ( ℓ = 0) , C ( ℓ = 1)), then # C 1 = (0 , 0) , # C 2 = (1 , 0) , # C 3 = (0 , 1) , # C 4 = (1 , 0) , The pair of lists associated with the variable x is P x := { C 1 , C 3 , C 4 } , N x := { C 2 } Observe that C 3 ( ℓ = 1) = 1, so C 3 is already satisfied by σ . K. Ghorbal (INRIA) 30 SIF M2 30 / 58

  44. Example (cont’d) Counter-Based Algorithm for BCP If x is assigned to 0, σ becomes { z , ¯ x } , and the counters # C i become # C 1 = (1 , 0) , # C 2 = (1 , 1) , # C 3 = (1 , 1) , # C 4 = (2 , 0) • C 2 ( ℓ = 1) = 1: C 2 becomes satisfied. • C 4 ( ℓ = 0) = 2 = | C 4 | : C 4 becomes conflicting . If x is assigned to 1, σ becomes { z , x } , and the counters # C i become # C 1 = (0 , 1) , # C 2 = (2 , 0) , # C 3 = (0 , 2) , # C 4 = (1 , 1) • C 1 ( ℓ = 1) = C 4 ( ℓ = 1) = 1: C 1 and C 4 become satisfied. • C 2 ( ℓ = 0) = 2 = − 1 + 3 = − 1 + | C 2 | : C 2 becomes a unit clause . K. Ghorbal (INRIA) 31 SIF M2 31 / 58

  45. Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in a clause C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 1 • Each variable s has two lists of clauses: • P s : set of clauses where the variable occurs positively • N s : set of clauses where the variable occurs negatively If s is assigned, C ( ℓ = 0) and C ( ℓ = 1) for all C in P s ∪ N s are updated • If C ( ℓ = 0) = | C | then C is a conflicting clause (more later) • If C ( ℓ = 0) = − 1 + | C | and C ( ℓ = 1) = 0 then it is a unit clause K. Ghorbal (INRIA) 32 SIF M2 32 / 58

  46. Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in a clause C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 1 • Each variable s has two lists of clauses: • P s : set of clauses where the variable occurs positively • N s : set of clauses where the variable occurs negatively If s is assigned, C ( ℓ = 0) and C ( ℓ = 1) for all C in P s ∪ N s are updated • If C ( ℓ = 0) = | C | then C is a conflicting clause (more later) • If C ( ℓ = 0) = − 1 + | C | and C ( ℓ = 1) = 0 then it is a unit clause K. Ghorbal (INRIA) 32 SIF M2 32 / 58

  47. Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in a clause C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 1 • Each variable s has two lists of clauses: • P s : set of clauses where the variable occurs positively • N s : set of clauses where the variable occurs negatively If s is assigned, C ( ℓ = 0) and C ( ℓ = 1) for all C in P s ∪ N s are updated • If C ( ℓ = 0) = | C | then C is a conflicting clause (more later) • If C ( ℓ = 0) = − 1 + | C | and C ( ℓ = 1) = 0 then it is a unit clause K. Ghorbal (INRIA) 32 SIF M2 32 / 58

  48. Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in a clause C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 1 • Each variable s has two lists of clauses: • P s : set of clauses where the variable occurs positively • N s : set of clauses where the variable occurs negatively If s is assigned, C ( ℓ = 0) and C ( ℓ = 1) for all C in P s ∪ N s are updated • If C ( ℓ = 0) = | C | then C is a conflicting clause (more later) • If C ( ℓ = 0) = − 1 + | C | and C ( ℓ = 1) = 0 then it is a unit clause K. Ghorbal (INRIA) 32 SIF M2 32 / 58

  49. Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in a clause C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 1 • Each variable s has two lists of clauses: • P s : set of clauses where the variable occurs positively • N s : set of clauses where the variable occurs negatively If s is assigned, C ( ℓ = 0) and C ( ℓ = 1) for all C in P s ∪ N s are updated • If C ( ℓ = 0) = | C | then C is a conflicting clause (more later) • If C ( ℓ = 0) = − 1 + | C | and C ( ℓ = 1) = 0 then it is a unit clause K. Ghorbal (INRIA) 32 SIF M2 32 / 58

  50. Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in a clause C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 1 • Each variable s has two lists of clauses: • P s : set of clauses where the variable occurs positively • N s : set of clauses where the variable occurs negatively If s is assigned, C ( ℓ = 0) and C ( ℓ = 1) for all C in P s ∪ N s are updated • If C ( ℓ = 0) = | C | then C is a conflicting clause (more later) • If C ( ℓ = 0) = − 1 + | C | and C ( ℓ = 1) = 0 then it is a unit clause K. Ghorbal (INRIA) 32 SIF M2 32 / 58

  51. Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in a clause C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 1 • Each variable s has two lists of clauses: • P s : set of clauses where the variable occurs positively • N s : set of clauses where the variable occurs negatively If s is assigned, C ( ℓ = 0) and C ( ℓ = 1) for all C in P s ∪ N s are updated • If C ( ℓ = 0) = | C | then C is a conflicting clause (more later) • If C ( ℓ = 0) = − 1 + | C | and C ( ℓ = 1) = 0 then it is a unit clause K. Ghorbal (INRIA) 32 SIF M2 32 / 58

  52. Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in a clause C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 1 • Each variable s has two lists of clauses: • P s : set of clauses where the variable occurs positively • N s : set of clauses where the variable occurs negatively If s is assigned, C ( ℓ = 0) and C ( ℓ = 1) for all C in P s ∪ N s are updated • If C ( ℓ = 0) = | C | then C is a conflicting clause (more later) • If C ( ℓ = 0) = − 1 + | C | and C ( ℓ = 1) = 0 then it is a unit clause K. Ghorbal (INRIA) 32 SIF M2 32 / 58

  53. Boolean Constraint Propagation (BCP) • Unit propagation is a typical instance of BCP • Consumes the most significant runtime of modern solvers Several heuristics proved efficient • Counter-based (GRASP) [Marques-Silva, Sakallah, 1996] • Head/Tail lists (SATO) [Zhang, Stickel, 1996] • 2-literal watching (Chaff) [Moskewicz et al. 2001] K. Ghorbal (INRIA) 33 SIF M2 33 / 58

  54. Outline 1 Propositional Logic 2 CNF Transformation 3 DPLL-based Algorithms Unit Propagation Branching and Learning 4 Conclusion 5 Reduction Examples K. Ghorbal (INRIA) 33 SIF M2 33 / 58

  55. Splitting (or Branching) Rule Davis-Logemann-Loveland 1962 Memory Consumption : The resolution rule can cause a quadratic expansion every time it is applied exhausting rapidly the available memory The DLL algorithm replaces the resolution rule with a Splitting Rule 1 Simplify by Unit Propagation and Pure Literals 2 Recursively pick a variable s (which one?) 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 34 SIF M2 34 / 58

  56. Splitting (or Branching) Rule Davis-Logemann-Loveland 1962 Memory Consumption : The resolution rule can cause a quadratic expansion every time it is applied exhausting rapidly the available memory The DLL algorithm replaces the resolution rule with a Splitting Rule 1 Simplify by Unit Propagation and Pure Literals 2 Recursively pick a variable s (which one?) 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 34 SIF M2 34 / 58

  57. Splitting (or Branching) Rule Davis-Logemann-Loveland 1962 Memory Consumption : The resolution rule can cause a quadratic expansion every time it is applied exhausting rapidly the available memory The DLL algorithm replaces the resolution rule with a Splitting Rule 1 Simplify by Unit Propagation and Pure Literals 2 Recursively pick a variable s (which one?) 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 34 SIF M2 34 / 58

  58. Splitting (or Branching) Rule Davis-Logemann-Loveland 1962 Memory Consumption : The resolution rule can cause a quadratic expansion every time it is applied exhausting rapidly the available memory The DLL algorithm replaces the resolution rule with a Splitting Rule 1 Simplify by Unit Propagation and Pure Literals 2 Recursively pick a variable s (which one?) 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 34 SIF M2 34 / 58

  59. Splitting (or Branching) Rule Davis-Logemann-Loveland 1962 Memory Consumption : The resolution rule can cause a quadratic expansion every time it is applied exhausting rapidly the available memory The DLL algorithm replaces the resolution rule with a Splitting Rule 1 Simplify by Unit Propagation and Pure Literals 2 Recursively pick a variable s (which one?) 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 34 SIF M2 34 / 58

  60. Splitting (or Branching) Rule Davis-Logemann-Loveland 1962 Memory Consumption : The resolution rule can cause a quadratic expansion every time it is applied exhausting rapidly the available memory The DLL algorithm replaces the resolution rule with a Splitting Rule 1 Simplify by Unit Propagation and Pure Literals 2 Recursively pick a variable s (which one?) 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 34 SIF M2 34 / 58

  61. Example w = c 1 ∧ c 2 ∧ c 3 ∧ c 4 ∧ c 5 ∧ c 6 c 1 = ( x 5 ∨ x 6 ) c 2 = ( x 1 ∨ x 7 ∨ ¬ x 2 ) c 3 = ( x 1 ∨ ¬ x 3 ) c 4 = ( x 2 ∨ x 3 ∨ x 4 ) c 5 = ( ¬ x 4 ∨ ¬ x 5 ) c 6 = ( x 8 ∨ ¬ x 4 ∨ ¬ x 6 ) K. Ghorbal (INRIA) 35 SIF M2 35 / 58

  62. Greedy Algorithm Count the number of unresolved clause for each variable x 1 : (2) , x 2 : (2) , x 3 : (2) , x 4 : ( 3 ) , x 5 : (2) , x 6 : (2) , x 7 : (1) , x 8 : (1) Branch with the variable having the largest number (here x 4 ) x 4 = 1@1 (i.e. x 4 set to 1 at decision level 1) • c 4 becomes resolved • by UP ( c 5 ), x 5 = 0@1, • by UP ( c 1 ), x 6 = 1@1, • by UP ( c 6 ), x 8 = 1@1 Count the number of unresolved clause for each remaining variable ( c 2 and c 3 ) x 1 : ( 2 ) , x 2 : (1) , x 3 : (1) , x 7 : (1) x 1 = 1@2 • c 2 and c 3 become resolved • The algorithm halts with SAT, σ = { 4 , ¯ 5 , 6 , 8 , 1 } K. Ghorbal (INRIA) 36 SIF M2 36 / 58

  63. Search Graph (Example) K. Ghorbal (INRIA) 37 SIF M2 37 / 58

  64. Branching Heuristics Which variable to branch with ? Greedy Algorithms • Exploit the statistics of the clause database • Estimate the branching effect on each variable (cost function) • Ex1: Generate the largest number of implications • Ex2: Satisfy most clauses Heuristcs • Maximum occurences on minimum sized clauses (MOM) • Literal Count Heuristcs Dynamic Largest Individual Sum (DLIS) [Marques-Silva, 1999] • Counts the number of unresolved clauses for each free variable • Chooses the variable with the largest number • State-dependent (recalculated each time before branching) K. Ghorbal (INRIA) 38 SIF M2 38 / 58

  65. Conflicts and Backtracking Conflicting Clause : a clause with all its literals assigned to 0 Solving conflicts : • If a conflict is detected at decision level @ d , the decision variable of that level is flipped before starting the UP again. • If a conflict is again detected, the algorithm goes to decision level @( d − 1) and so on. • If decision level 0 reached, return UNSAT • Essentially a Depth First Search technique. Problem : several conflicts could be caused by the same assignement made at an early decision level. The algorithm gets stuck in some sort of“local minimum”with an important number of conflicts. K. Ghorbal (INRIA) 39 SIF M2 39 / 58

  66. Conflict-Driven Clause Learning (CDCL) Marques-Silva,Sakallah,1996 and Bayardo,Schrag,1997 Modern SAT solvers learns the conflicting clauses and attempt to jumpback to an early root of the conflict. Two graphs are built iteratively • Search graph (as the one we have already seen) • Implication graph K. Ghorbal (INRIA) 40 SIF M2 40 / 58

  67. Example w = c 1 ∧ c 2 ∧ c 3 ∧ c 4 ∧ c 5 ∧ c 6 c 1 = ( x 5 ∨ x 6 ) c 2 = ( x 1 ∨ x 7 ∨ ¬ x 2 ) c 3 = ( x 1 ∨ ¬ x 3 ) c 4 = ( x 2 ∨ x 3 ∨ x 4 ) c 5 = ( ¬ x 4 ∨ ¬ x 5 ) c 6 = ( x 8 ∨ ¬ x 4 ∨ ¬ x 6 ) Assume the following decisions have been made: x 8 = 0@2 , x 7 = 0@3 , x 1 = 0@5 . K. Ghorbal (INRIA) 41 SIF M2 41 / 58

  68. Implication Graph (Example) K. Ghorbal (INRIA) 42 SIF M2 42 / 58

  69. Learning Clauses from a Conflict • Let φ := ¬ x 1 ∧ ¬ x 7 ∧ ¬ x 8 • w ∧ φ is UNSAT • Thus, w | = ¬ φ (Tautological implication) • Therefore, w ∼ w ∧ ¬ φ • ¬ φ is a learned clause Several clauses could be learned by seperating the sources from the conflict in the implication graph φ 1 := ¬ x 4 ∨ x 8 φ 2 := ¬ x 4 ∨ x 6 For instance, by adding φ 1 as a new clause to w , with respect to the decision x 8 = 0@2, x 4 will be forced to 0 (instead of 1 which would lead inevitably to a conflict according to the implication graph). K. Ghorbal (INRIA) 43 SIF M2 43 / 58

  70. Backjump In our example, one can jump back to three decision levels: 2, 3 and 5 (the current one). Unit Implication Point strategy (used in in Chaff) • One would want to backtrack to a decision that immediately exploits the learned clause to fix an additional variable without necessarily changing that decision . • For instance, by learning φ 1 and backtracking to depth 2 (as the earliest decision involved in φ ), x 4 will be set to 0 by UP. K. Ghorbal (INRIA) 44 SIF M2 44 / 58

  71. CDCL: Learn and Backjump Learn • Add a new clause to avoid reaching the same conflict again • Not unique in general (heuristics) Backjump • Jump to a past decision that caused the conflict • (not necessarily the latest like in backtracking) • Not unique in general (heuristics) K. Ghorbal (INRIA) 45 SIF M2 45 / 58

  72. CDCL: Forget and Restart Mostly used in SMT Solvers Forget • When too much clauses are learned • heuristics: forget those not frequently used by literal propagations Restart • If stuck, restart from the beginning (extreme backjumping) • Keep the learned clauses K. Ghorbal (INRIA) 46 SIF M2 46 / 58

  73. Variable State Independent Decaying Sum VSIDS. [Moskewicz et al., 2001] In modern solvers, branching heuristics exploit the learned clauses : • Keeps two scores for each variable • (# of pos occurences, # of neg occurences) • Increases the score of a variable by a constant if it appears in a learned conflicting-clause • Periodically, all the scores are divided by a constant • Branch with the variable with the highest combined score ➻ Cheap to maintain (State Independent) ➻ Captures the recently active variables K. Ghorbal (INRIA) 47 SIF M2 47 / 58

  74. Outline 1 Propositional Logic 2 CNF Transformation 3 DPLL-based Algorithms Unit Propagation Branching and Learning 4 Conclusion 5 Reduction Examples K. Ghorbal (INRIA) 47 SIF M2 47 / 58

  75. DPLL-CDCL Modern Decision Procedures Zhang, Malik, 2002 s t a t u s = p r e p r o c e s s ( ) ; ( s t a t u s !=UNKNOWN) s t a t u s ; i f return while ( true ) { decide next branch ( ) ; ( true ) { while s t a t u s = deduce ( ) ; i f ( s t a t u s == CONFLICT) { b l e v e l = a n a l y z e c o n f l i c t ( ) ; i f ( b l e v e l == 0) return UNSATISFIABLE ; else backtrack ( b l e v e l ) ; } else i f ( s t a t u s == SATISFIABLE ) return SATISFIABLE ; else break ; } } K. Ghorbal (INRIA) 48 SIF M2 48 / 58

  76. Anatomy of Modern Sat Solvers [Katebi et al., 2011] 1000 1000 900 900 800 800 700 700 CPU Time (s) Time (s) 600 600 500 500 400 300 200 100 0 0 100 200 300 400 500 600 700 800 900 1000 Instances K. Ghorbal (INRIA) 49 SIF M2 49 / 58

  77. Visualizing Boolean Functions [SATGraf, Newsham et al., 2015] K. Ghorbal (INRIA) 50 SIF M2 50 / 58

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend