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 K. Ghorbal (INRIA) 14 SIF M2 14 / 42
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 K. Ghorbal (INRIA) 14 SIF M2 14 / 42
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) 14 SIF M2 14 / 42
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) 14 SIF M2 14 / 42
SAT Facts • Brute force algorithm: exponential complexity : • 2 n 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 • Modern SAT Solvers are arguably efficient , why? • SAT expects an input in Conjunctive Normal Form K. Ghorbal (INRIA) 15 SIF M2 15 / 42
SAT Facts • Brute force algorithm: exponential complexity : • 2 n 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 • Modern SAT Solvers are arguably efficient , why? • SAT expects an input in Conjunctive Normal Form K. Ghorbal (INRIA) 15 SIF M2 15 / 42
SAT Facts • Brute force algorithm: exponential complexity : • 2 n 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 • Modern SAT Solvers are arguably efficient , why? • SAT expects an input in Conjunctive Normal Form K. Ghorbal (INRIA) 15 SIF M2 15 / 42
SAT Facts • Brute force algorithm: exponential complexity : • 2 n 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 • Modern SAT Solvers are arguably efficient , why? • SAT expects an input in Conjunctive Normal Form K. Ghorbal (INRIA) 15 SIF M2 15 / 42
SAT Facts • Brute force algorithm: exponential complexity : • 2 n 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 • Modern SAT Solvers are arguably efficient , why? • SAT expects an input in Conjunctive Normal Form K. Ghorbal (INRIA) 15 SIF M2 15 / 42
Converting to CNF 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) 16 SIF M2 16 / 42
Converting to CNF 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) 16 SIF M2 16 / 42
Converting to CNF 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) 16 SIF M2 16 / 42
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 • w 2 := ( s 1 ∨ s 3 ) ∧ ( s 1 ∨ s 4 ) ∧ ( s 2 ∨ s 3 ) ∧ ( s 2 ∨ s 4 ) • Add extra pairs to w 1 , ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) ∨ ( s 5 ∧ s 6 ) . . . • The number of the involved logical operations is exponential K. Ghorbal (INRIA) 17 SIF M2 17 / 42
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 • w 2 := ( s 1 ∨ s 3 ) ∧ ( s 1 ∨ s 4 ) ∧ ( s 2 ∨ s 3 ) ∧ ( s 2 ∨ s 4 ) • Add extra pairs to w 1 , ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) ∨ ( s 5 ∧ s 6 ) . . . • The number of the involved logical operations is exponential K. Ghorbal (INRIA) 17 SIF M2 17 / 42
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 • w 2 := ( s 1 ∨ s 3 ) ∧ ( s 1 ∨ s 4 ) ∧ ( s 2 ∨ s 3 ) ∧ ( s 2 ∨ s 4 ) • Add extra pairs to w 1 , ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) ∨ ( s 5 ∧ s 6 ) . . . • The number of the involved logical operations is exponential K. Ghorbal (INRIA) 17 SIF M2 17 / 42
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 • w 2 := ( s 1 ∨ s 3 ) ∧ ( s 1 ∨ s 4 ) ∧ ( s 2 ∨ s 3 ) ∧ ( s 2 ∨ s 4 ) • Add extra pairs to w 1 , ( s 1 ∧ s 2 ) ∨ ( s 3 ∧ s 4 ) ∨ ( s 5 ∧ s 6 ) . . . • The number of the involved logical operations is exponential K. Ghorbal (INRIA) 17 SIF M2 17 / 42
Converting to CNF Tseytin Transformation [Tseytin 1970] Idea : Converting a w by adding new propositional variables and substitute for nested operations. Example ( 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 • CNF: ( p 1 ↔ ( s 1 ∧ s 2 )) ∧ ( p 2 ↔ ( s 3 ∧ s 4 )) ∧ ( p 3 ↔ p 1 ∨ p 2 ) ∧ p 3 K. Ghorbal (INRIA) 18 SIF M2 18 / 42
Converting to CNF Tseytin Transformation [Tseytin 1970] Idea : Converting a w by adding new propositional variables and substitute for nested operations. Example ( 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 • CNF: ( p 1 ↔ ( s 1 ∧ s 2 )) ∧ ( p 2 ↔ ( s 3 ∧ s 4 )) ∧ ( p 3 ↔ p 1 ∨ p 2 ) ∧ p 3 K. Ghorbal (INRIA) 18 SIF M2 18 / 42
Converting to CNF Tseytin Transformation [Tseytin 1970] • p ↔ ( s 1 ◦ s 2 ) has at most 3 clauses for any ◦ ∈ {¬ , ∧ , ∨ , ¯ ∧ , ¯ ∨} • For n logical operation, the increase is linear O ( n ) • Drawback: the number of propositional variables increases (linearly)! K. Ghorbal (INRIA) 19 SIF M2 19 / 42
Converting to CNF Tseytin Transformation [Tseytin 1970] • p ↔ ( s 1 ◦ s 2 ) has at most 3 clauses for any ◦ ∈ {¬ , ∧ , ∨ , ¯ ∧ , ¯ ∨} • For n logical operation, the increase is linear O ( n ) • Drawback: the number of propositional variables increases (linearly)! K. Ghorbal (INRIA) 19 SIF M2 19 / 42
Converting to CNF Tseytin Transformation [Tseytin 1970] • p ↔ ( s 1 ◦ s 2 ) has at most 3 clauses for any ◦ ∈ {¬ , ∧ , ∨ , ¯ ∧ , ¯ ∨} • For n logical operation, the increase is linear O ( n ) • Drawback: the number of propositional variables increases (linearly)! K. Ghorbal (INRIA) 19 SIF M2 19 / 42
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) 20 SIF M2 20 / 42
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) 20 SIF M2 20 / 42
Outline 1 Introduction 2 Propositional Logic 3 SAT Solving 4 DPLL-based Algorithms K. Ghorbal (INRIA) 20 SIF M2 20 / 42
Definitions • Literal : propositional symbol (atomic formula) or its negation • Clause : disjunction of one or more literals • Conjunctive Normal Form (CNF): conjunction of clauses • Positive Occurrence: if the symbol occurs unnegated in a clause • Negative Occurrence: if the symbol occurs negated in a clause ( s 1 ∨ ¬ s 3 ) ∧ ( ¬ s 2 ∨ s 3 ∨ s 4 ) K. Ghorbal (INRIA) 21 SIF M2 21 / 42
Definitions • Literal : propositional symbol (atomic formula) or its negation • Clause : disjunction of one or more literals • Conjunctive Normal Form (CNF): conjunction of clauses • Positive Occurrence: if the symbol occurs unnegated in a clause • Negative Occurrence: if the symbol occurs negated in a clause ( s 1 ∨ ¬ s 3 ) ∧ ( ¬ s 2 ∨ s 3 ∨ s 4 ) K. Ghorbal (INRIA) 21 SIF M2 21 / 42
Definitions • Literal : propositional symbol (atomic formula) or its negation • Clause : disjunction of one or more literals • Conjunctive Normal Form (CNF): conjunction of clauses • Positive Occurrence: if the symbol occurs unnegated in a clause • Negative Occurrence: if the symbol occurs negated in a clause ( s 1 ∨ ¬ s 3 ) ∧ ( ¬ s 2 ∨ s 3 ∨ s 4 ) K. Ghorbal (INRIA) 21 SIF M2 21 / 42
Definitions • Literal : propositional symbol (atomic formula) or its negation • Clause : disjunction of one or more literals • Conjunctive Normal Form (CNF): conjunction of clauses • Positive Occurrence: if the symbol occurs unnegated in a clause • Negative Occurrence: if the symbol occurs negated in a clause ( s 1 ∨ ¬ s 3 ) ∧ ( ¬ s 2 ∨ s 3 ∨ s 4 ) K. Ghorbal (INRIA) 21 SIF M2 21 / 42
Definitions • Literal : propositional symbol (atomic formula) or its negation • Clause : disjunction of one or more literals • Conjunctive Normal Form (CNF): conjunction of clauses • Positive Occurrence: if the symbol occurs unnegated in a clause • Negative Occurrence: if the symbol occurs negated in a clause ( s 1 ∨ ¬ s 3 ) ∧ ( ¬ s 2 ∨ s 3 ∨ s 4 ) K. Ghorbal (INRIA) 21 SIF M2 21 / 42
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 formulas) 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) 22 SIF M2 22 / 42
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 formulas) 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) 22 SIF M2 22 / 42
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 • ( ℓ ↔ 1) ∧ ( ℓ ∨ w 1 ) ∧ w 2 ∼ SAT w 2 • Repeat till no more clauses contain ℓ ➻ Augment σ such that � ℓ � σ = 1 Nota: not used dynamically while solving as expensive to detect. K. Ghorbal (INRIA) 23 SIF M2 23 / 42
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 } K. Ghorbal (INRIA) 24 SIF M2 24 / 42
Unit Propagation Unit clause is a clause with only one literal , ℓ say Remove all the clauses containing ℓ • A clause containing ℓ has the form ℓ ∨ w • ( ℓ ↔ 1) ∧ ( ℓ ∨ w ) ∼ SAT 1 • Repeat till no more clauses contain ℓ Remove all instances of ¬ ℓ from all the clauses • A clause containing ¬ ℓ has the form ℓ ∨ w • � ¬ ℓ � σ = 0 • ( ℓ ↔ 1) ∧ ( ¬ ℓ ∨ w ) ∼ SAT w • Repeat till no more clauses contain ¬ ℓ ➻ Augment σ such that � ℓ � σ = 1 K. Ghorbal (INRIA) 25 SIF M2 25 / 42
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) 26 SIF M2 26 / 42
Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 0 • 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) 27 SIF M2 27 / 42
Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 0 • 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) 27 SIF M2 27 / 42
Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 0 • 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) 27 SIF M2 27 / 42
Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 0 • 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) 27 SIF M2 27 / 42
Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 0 • 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) 27 SIF M2 27 / 42
Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 0 • 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) 27 SIF M2 27 / 42
Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 0 • 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) 27 SIF M2 27 / 42
Counter-Based Algorithm for BCP • Denote by | C | the total number of literals in C • Each clause C has two counters: • C ( ℓ = 0) := # ℓ such that � ℓ � σ = 0 • C ( ℓ = 1) := # ℓ such that � ℓ � σ = 0 • 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) 27 SIF M2 27 / 42
Watched 2-Literal Empirical fact : Find and perform literal prorogation is expensive Watched Literals • For every clause, pick two literals to be watched • If a literal is assigned, check only those clauses in which the literal is watched • When inspecting, if the propagation is not triggered, pick a new literal to watch K. Ghorbal (INRIA) 28 SIF M2 28 / 42
Watched 2-Literal Empirical fact : Find and perform literal prorogation is expensive Watched Literals • For every clause, pick two literals to be watched • If a literal is assigned, check only those clauses in which the literal is watched • When inspecting, if the propagation is not triggered, pick a new literal to watch K. Ghorbal (INRIA) 28 SIF M2 28 / 42
Watched 2-Literal Empirical fact : Find and perform literal prorogation is expensive Watched Literals • For every clause, pick two literals to be watched • If a literal is assigned, check only those clauses in which the literal is watched • When inspecting, if the propagation is not triggered, pick a new literal to watch K. Ghorbal (INRIA) 28 SIF M2 28 / 42
Watched 2-Literal Empirical fact : Find and perform literal prorogation is expensive Watched Literals • For every clause, pick two literals to be watched • If a literal is assigned, check only those clauses in which the literal is watched • When inspecting, if the propagation is not triggered, pick a new literal to watch K. Ghorbal (INRIA) 28 SIF M2 28 / 42
Resolution Rule If s does not appear in the wff w , then ( s ∨ a ) ∧ ( ¬ s ∨ b ) ∧ w ∼ SAT ( a ∨ b ) ∧ w � �� � resolvent � � � � ∧ w ( s ∨ a i ) ∧ ( ¬ s ∨ b j ) ∧ w ∼ SAT a i ∨ b j i j i j � � � � ∧ w ∧ w a i ∨ ∼ ( a i ∨ b j ) b j i j i j Resolution Rule • Simplifies by s . No explicit assignment for s ! K. Ghorbal (INRIA) 29 SIF M2 29 / 42
Resolution Rule If s does not appear in the wff w , then ( s ∨ a ) ∧ ( ¬ s ∨ b ) ∧ w ∼ SAT ( a ∨ b ) ∧ w � �� � resolvent � � � � ∧ w ( s ∨ a i ) ∧ ( ¬ s ∨ b j ) ∧ w ∼ SAT a i ∨ b j i j i j � � � � ∧ w ∧ w a i ∨ ∼ ( a i ∨ b j ) b j i j i j Resolution Rule • Simplifies by s . No explicit assignment for s ! K. Ghorbal (INRIA) 29 SIF M2 29 / 42
Resolution Rule If s does not appear in the wff w , then ( s ∨ a ) ∧ ( ¬ s ∨ b ) ∧ w ∼ SAT ( a ∨ b ) ∧ w � �� � resolvent � � � � ∧ w ( s ∨ a i ) ∧ ( ¬ s ∨ b j ) ∧ w ∼ SAT a i ∨ b j i j i j � � � � ∧ w ∧ w a i ∨ ∼ ( a i ∨ b j ) b j i j i j Resolution Rule • Simplifies by s . No explicit assignment for s ! K. Ghorbal (INRIA) 29 SIF M2 29 / 42
Resolution Rule If s does not appear in the wff w , then ( s ∨ a ) ∧ ( ¬ s ∨ b ) ∧ w ∼ SAT ( a ∨ b ) ∧ w � �� � resolvent � � � � ∧ w ( s ∨ a i ) ∧ ( ¬ s ∨ b j ) ∧ w ∼ SAT a i ∨ b j i j i j � � � � ∧ w ∧ w a i ∨ ∼ ( a i ∨ b j ) b j i j i j Resolution Rule • Simplifies by s . No explicit assignment for s ! K. Ghorbal (INRIA) 29 SIF M2 29 / 42
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 hard core variable s 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 30 SIF M2 30 / 42
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 hard core variable s 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 30 SIF M2 30 / 42
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 hard core variable s 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 30 SIF M2 30 / 42
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 hard core variable s 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 30 SIF M2 30 / 42
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 hard core variable s 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 30 SIF M2 30 / 42
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 hard core variable s 3 Test if ( w ∧ s ) is SAT 4 Otherwise return the result for ( w ∧ ¬ s ) K. Ghorbal (INRIA) 30 SIF M2 30 / 42
DPLL Modern Decision Procedure 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) 31 SIF M2 31 / 42
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) 32 SIF M2 32 / 42
Variable State Independent Decaying Sum VSIDS. [Moskewicz et al., 2001] • 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) 33 SIF M2 33 / 42
Conflict-Driven Clause Learning (CDCL) Marques-Silva,Sakallah,1996 and Bayardo,Schrag,1997 Modern SAT solvers essentially implements a backtracking-based search algorithm Two graphs are built iteratively • Search graph • Implication graph K. Ghorbal (INRIA) 34 SIF M2 34 / 42
Search Graph DPLL related Graphs s 3 BCP s 1 Next Branch s 4 BCP s 2 K. Ghorbal (INRIA) 35 SIF M2 35 / 42
Backtracking Conflicting Clause : a clause with all its literals assigned to 0 Backtrack when a conflict occurs • No future decisions are possible • Backtrack to the immediately previous decision made • Flip the assignement and continue • If decision level 0 reached, return unsat K. Ghorbal (INRIA) 36 SIF M2 36 / 42
Backtracking Conflicting Clause : a clause with all its literals assigned to 0 Backtrack when a conflict occurs • No future decisions are possible • Backtrack to the immediately previous decision made • Flip the assignement and continue • If decision level 0 reached, return unsat K. Ghorbal (INRIA) 36 SIF M2 36 / 42
Implication Graph Gomes et al. Handbook of Knowledge Representation, Chapter2. 2008 No incident edges for decision nodes! a cut corresponding conflict to clause ( ¬ a ∨ ¬ b ) variable ¬ p ¬ x 1 y a ¬ q Λ ¬ t ¬ x 2 ¬ y ¬ ¬ ¬ b ¬ x 3 reason side conflict side Figure 2.1: A conflict graph K. Ghorbal (INRIA) 37 SIF M2 37 / 42
DPLL: Backjump and Learn Backjump • Jump to a past decision that caused the conflict • (not necessarily the latest like in backtracking) • Not unique in general (heuristics) Learn • Add a new clause to avoid reaching the same conflict again • Not unique in general (heuristics) Example : ¯ 1 ∨ 2, 3 ∨ 4, ¯ 5 ∨ ¯ 6, ¯ 2 ∨ ¯ 5 ∨ 6 (Satisfiable) K. Ghorbal (INRIA) 38 SIF M2 38 / 42
DPLL: Backjump and Learn Backjump • Jump to a past decision that caused the conflict • (not necessarily the latest like in backtracking) • Not unique in general (heuristics) Learn • Add a new clause to avoid reaching the same conflict again • Not unique in general (heuristics) Example : ¯ 1 ∨ 2, 3 ∨ 4, ¯ 5 ∨ ¯ 6, ¯ 2 ∨ ¯ 5 ∨ 6 (Satisfiable) K. Ghorbal (INRIA) 38 SIF M2 38 / 42
DPLL: Backjump and Learn Backjump • Jump to a past decision that caused the conflict • (not necessarily the latest like in backtracking) • Not unique in general (heuristics) Learn • Add a new clause to avoid reaching the same conflict again • Not unique in general (heuristics) Example : ¯ 1 ∨ 2, 3 ∨ 4, ¯ 5 ∨ ¯ 6, ¯ 2 ∨ ¯ 5 ∨ 6 (Satisfiable) K. Ghorbal (INRIA) 38 SIF M2 38 / 42
DPLL: Forget and Restart Mostly used in SMT Solvers Forget • When too much clauses are learned • heuristics: those not frequently used by literal propagations Restart • If stuck, restart from the beginning (extreme backjumping) • Keep the learned clauses K. Ghorbal (INRIA) 39 SIF M2 39 / 42
DPLL: Forget and Restart Mostly used in SMT Solvers Forget • When too much clauses are learned • heuristics: those not frequently used by literal propagations Restart • If stuck, restart from the beginning (extreme backjumping) • Keep the learned clauses K. Ghorbal (INRIA) 39 SIF M2 39 / 42
Summary SAT Problem • Equisatisfiability • SAT for proving tautological implications/equivalences • CNF transformation CDCL-DPLL Algorithm • Unit Propagation • Pure Literal • Resolution/Splitting/Conflict Learning K. Ghorbal (INRIA) 40 SIF M2 40 / 42
Recommend
More recommend