Propositional Satisfiability Brian C Williams 16 410 13
Propositional Satisfiability Brian C. Williams 16. 410 -13 November 17 th & 22 nd , 2004 3/19/2003 copyright Brian Williams 1
Propositional Satisfiability Find a truth assignment that satisfies logical sentence T: • Reduce sentence T to clausal form. • Perform search similar to MAC = (BT+CP) Propositional satisfiability testing: 1990: 100 variables / 200 clauses (constraints) 1998: 10, 000 - 100, 000 vars / 10^6 clauses Novel applications: e. g. diagnosis, planning, software / circuit testing, machine learning, and protein folding 3/19/2003 copyright Brian Williams 2
Reading Assignments: Propositional Satisfiability & Logic • AIMA Ch. 6 – Propositional Logic 3/19/2003 copyright Brian Williams 3
Outline: Propositional Satisfiability • • Propositional Clauses Backtrack Search Unit Propagation DPLL: Unit Propagation + Backtrack Search Appendix: • Local search using GSAT • Characteristics of DPLL 3/19/2003 copyright Brian Williams 4
Propositional Clauses • Variables: • Domain: • Constraints: • Clause Propositions {True, False} Clauses that must be true (not A or B or E) • A disjunction of Literals • Literal: Proposition or its negation • Positive Literal • Negative Literal 3/19/2003 B Not A copyright Brian Williams 5
Propositional Satisfiability • A truth assignment to all propositions such that all clauses are satisfied: • A clause is satisfied if and only if at least one literal is true. • A clause is violated if and only if all literals are false. C 1: Not A or B C 2: Not C or A C 3: Not B or C 3/19/2003 copyright Brian Williams 6
Outline: Propositional Satisfiability • • Propositional Clauses Backtrack Search Unit Propagation DPLL: Unit Propagation + Backtrack Search Appendix: • Local search using GSAT • Characteristics of DPLL 3/19/2003 copyright Brian Williams 7
Propositional Satisfiability using Backtrack Search • Assign true or false to an unassigned proposition. • Backtrack as soon as a clause is violated. Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C 3/19/2003 A F B F S C S F S copyright Brian Williams 8
Propositional Satisfiability using Backtrack Search • Assign true or false to an unassigned proposition. • Backtrack as soon as a clause is violated. Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C 3/19/2003 A F B F S C u F T S copyright Brian Williams 9
Propositional Satisfiability using Backtrack Search • Assign true or false to an unassigned proposition. • Backtrack as soon as a clause is violated. Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C 3/19/2003 A F B F S C S F T C T F v copyright Brian Williams 10
Propositional Satisfiability using Backtrack Search • Assign true or false to an unassigned proposition. • Backtrack as soon as a clause is violated. Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C 3/19/2003 A F B F S C v F C T F T T S copyright Brian Williams 11
Propositional Satisfiability using Backtrack Search • Assign true or false to an unassigned proposition. • Backtrack as soon as a clause is violated. Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C 3/19/2003 A F B F v C S F C T F T B F T C T S copyright Brian Williams 12
Propositional Satisfiability using Backtrack Search • Assign true or false to an unassigned proposition. • Backtrack as soon as a clause is violated. Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C 3/19/2003 A F B F S C S F C T F T B F T C T T C F v copyright Brian Williams 13
Propositional Satisfiability using Backtrack Search • Assign true or false to an unassigned proposition. • Backtrack as soon as a clause is violated. Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C 3/19/2003 A F B F S C S F C T F T B F T C T T C F T S copyright Brian Williams 14
Clausal Backtrack Search: Recursive Definition BT(Phi, A) Input: A cnf theory Phi, An assignment A to propositions in Phi Output: A decision of whether Phi is satisfiable. 1. If a clause is violated, Return false; 2. Else If all propositions are assigned, Return true; 3. Else Q = some unassigned proposition in Phi; 4. Return (BT(Phi, A[Q = True]) or 5. BT(Phi, A[Q = False]) 3/19/2003 copyright Brian Williams 15
Outline: Propositional Satisfiability • • Propositional Clauses Backtrack Search Unit Propagation DPLL: Unit Propagation + Backtrack Search Appendix: • Local search using GSAT • Characteristics of DPLL 3/19/2003 copyright Brian Williams 16
Unit Propagation Idea: Arc consistency (AC-3) on binary clauses (not A or B) {F} {T, F} ? {T} {T, F} ? Unit resolution rule: If all literals are false save L, then assign true to L: • 3/19/2003 (not A) (not B) C (A or B or C) copyright Brian Williams 17
Unit Propagation Examples • • C 1: Not A or B C 2: Not C or A C 3: Not B or C C 4: A Satisfied 3/19/2003 Satisfied True C 4 A True C 1 C 3 B copyright Brian Williams True C 18
Unit Propagation Examples • • C 1: Not A or B C 2: Not C or A C 3: Not B or C C 4: A • C 4’: Not B Satisfied True C 4 A Satisfied False A 3/19/2003 True C 1 C 3 B True C False C 4’ False C 1 copyright Brian Williams B C C 2 19
Unit Propagation true r false t q C 1 : ¬r q p C 2: ¬ p ¬ t p procedure propagate(C) // C is a clause if all literals in C are false except L, and L is unassigned then assign true to L and record C as a support for L and for each clause C’ mentioning “not L”, propagate(C’) 3/19/2003 copyright Brian Williams end propagate 20
Unit Propagation true r false t q C 1 : ¬r q p C 2: ¬ p ¬ t p procedure propagate(C) // C is a clause if all literals in C are false except L, and L is unassigned then assign true to L and record C as a support for L and for each clause C’ mentioning “not L”, propagate(C’) 3/19/2003 copyright Brian Williams end propagate 21
Unit Propagation true r false t q C 1 : ¬r q p true C 2: ¬ p ¬ t p procedure propagate(C) // C is a clause if all literals in C are false except L, and L is unassigned then assign true to L and record C as a support for L and for each clause C’ mentioning “not L”, propagate(C’) 3/19/2003 copyright Brian Williams end propagate 22
Unit Propagation true r false t q C 1 : ¬r q p true C 2: ¬ p ¬ t p procedure propagate(C) // C is a clause if all literals in C are false except L, and L is unassigned then assign true to L and record C as a support for L and for each clause C’ mentioning “not L”, propagate(C’) 3/19/2003 copyright Brian Williams end propagate 23
Unit Propagation true r false t q C 1 : ¬r q p true C 2: ¬ p ¬ t p procedure propagate(C) // C is a clause if all literals in C are false except L, and L is unassigned then assign true to L and record C as a support for L and for each clause C’ mentioning “not L”, propagate(C’) 3/19/2003 copyright Brian Williams end propagate 24
Unit Propagation true r false t q C 1 : ¬r q p true false C 2: ¬ p ¬ t p procedure propagate(C) // C is a clause if all literals in C are false except L, and L is unassigned then assign true to L and record C as a support for L and for each clause C’ mentioning “not L”, propagate(C’) 3/19/2003 copyright Brian Williams end propagate 25
Outline: Propositional Satisfiability • • Propositional Clauses Backtrack Search Unit Propagation DPLL: Unit Propagation + Backtrack Search Appendix: • Local search using GSAT • Characteristics of DPLL 3/19/2003 copyright Brian Williams 26
How Do We Combine Unit Resolution and Back Track Search? Backtrack Search • Assign true or false to an unassigned proposition. • Backtrack as soon as a clause is violated. • Theory is satisfiable if assignment is complete. Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C 3/19/2003 A F B F C T F T B F T C T F T T § Similar to MAC and Forward Checking: § Perform limited form of inference § apply inference rule after assigning each variable. copyright Brian Williams 27
Propositional Satisfiability by DPLL [Davis, Putnam, Logmann, Loveland, 1962] Initially: • Unit propagate. Repeat: 1. Assign true or false to an unassigned proposition. 2. Unit propagate. 3. Backtrack as soon as a clause is violated. 4. Satisfiable if assignment is complete. 3/19/2003 Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C Propagate: F C=F B=F copyright Brian Williams S S S A 28
Propositional Satisfiability by DPLL [Davis, Putnam, Logmann, Loveland, 1962] Initially: • Unit propagate. Repeat: 1. Assign true or false to an unassigned proposition. 2. Unit propagate. 3. Backtrack as soon as a clause is violated. 4. Satisfiable if assignment is complete. 3/19/2003 Example: • C 1: Not A or B • C 2: Not C or A • C 3: Not B or C Propagate: F C=F B=F copyright Brian Williams A T S S S Propagate: B=T C=T 29
DPLL Procedure [Davis, Putnam Logmann, Loveland, 1962] DPLL(Phi, A) Input: A cnf theory Phi, An assignment A to propositions in Phi Output: A decision of whether Phi is satisfiable. 1. A’ = propagate(Phi); 2. If a clause is violated given A’ return(false); 3. Else if all propositions in A’ are assigned, return(true); 4. Else Q = some unassigned proposition in Phi; 6. Return (DPLL(Phi, A’[Q = True]) or 7. DPLL(Phi, A’[Q = False]) 3/19/2003 copyright Brian Williams 30
Outline: Propositional Satisfiability • • Propositional Clauses Backtrack Search Unit Propagation DPLL: Unit Propagation + Backtrack Search Appendix: • Local search using GSAT • Characteristics of DPLL 3/19/2003 copyright Brian Williams 31
Incremental Repair (min-conflict heuristic) Spike Hubble Telescope Scheduler [Minton et al. ] 1. Initialize a candidate solution using “greedy” heuristic – get solution “near” correct one. 2. Select a variable in conflict and assign it a value that minimizes the number of conflicts (break ties randomly). V 1 Graph Coloring Initial Domains R, G, B V 2 R, G 3/19/2003 Different-color constraint G copyright Brian Williams V 3 32
1. Init: Pick random assignment GSAT • C 1: Not A or B • C 2: Not C or Not A • C 3: or B or Not C C 1, C 2, C 3 violated 3/19/2003 2. Check effect of flipping each assignment, counting violated clauses. 3. Pick assignment with fewest violations, 4. End if consistent, Else goto 2 False True A B C False True False C 3 violated C 2 violated C 1 violated copyright Brian Williams 33
1. Init: Pick random assignment GSAT • C 1: Not A or B • C 2: Not C or Not A • C 3: or B or Not C C 1 violated 2. Check effect of flipping each assignment, counting violated clauses. 3. Pick assignment with fewest violations, 4. End if consistent, Else goto 2 False True False A B C False Satisfied 3/19/2003 True Satisfied copyright Brian Williams True C 1, C 2, C 3 violated 34
1. Init: Pick random assignment GSAT • C 1: Not A or B • C 2: Not C or Not A • C 3: or B or Not C Satisfied 2. Check effect of flipping each assignment, counting violated clauses. 3. Pick assignment with fewest violations, 4. End if consistent, Else goto 2 True False A B C Problem: Pure hill climbers get stuck in local minima. Solution: Add random moves to get out of minima (Walk. SAT) 3/19/2003 copyright Brian Williams 35
Satisfiability Testing Procedures • Reduce to CNF (Clausal Form) then: • Systematic, complete procedures • Depth-first backtrack search (Davis, Putnam, & Loveland 1961) • unit propagation, shortest clause heuristic • State-of-the-art implementations: • ntab (Crawford & Auton 1997) • itms (Nayak & Williams 1997) • many others! See SATLIB 1998 / Hoos & Stutzle • Stochastic, incomplete procedures • GSAT (Selman et. al 1993) • Walksat (Selman & Kautz 1993) • greedy local search + noise to escape local minima 3/19/2003 copyright Brian Williams 36
Outline: Propositional Satisfiability • • Propositional Clauses Backtrack Search Unit Propagation DPLL: Unit Propagation + Backtrack Search Appendix: • Local search using GSAT • Characteristics of DPLL 3/19/2003 copyright Brian Williams 37
3/19/2003 copyright Brian Williams 38
3/19/2003 copyright Brian Williams 39
3/19/2003 copyright Brian Williams 40
Intuition • At low ratios: • few clauses (constraints) • many assignments • easily found • At high ratios: • many clauses • inconsistencies easily detected 3/19/2003 copyright Brian Williams 41
Phase Transitions for Different Numbers of Variables Fraction of Formulae Unsatisfied 1. 0 1 0 0 0. 8 2 0 5 0 1 2 4 0 2 4 U N S A T 0. 6 Ph a se 0. 4 SA T P h a s e 0. 2 0 3 4 5 6 7 M / N 3/19/2003 copyright Brian Williams 42
- Slides: 42