Title: Propositional Satisfiability (SAT)
1Propositional Satisfiability(SAT)
- Toby Walsh
- Cork Constraint Computation Centre
- University College Cork
- Ireland
- 4c.ucc.ie/tw/sat/
2Every morning
- I cycle across the River Lee in Cork
- And see this rather drab house
3Every morning
- I read the plaque on the wall of this house
- Dedicated to the memory of George Boole
- Professor of Mathematics at Queens College (now
University College Cork)
4George Boole (1815-1864)
- Boolean algebra
- The Mathematical Analysis of Logic, Cambridge,
1847 - The Calculus of Logic, Cambridge and Dublin
Mathematical journal, vol. 3, 1848 - Reduced propositional logic to algebraic
manipulations
5George Boole (1815-1864)
- Boolean algebra
- The Mathematical Analysis of Logic, Cambridge,
1847 - The Calculus of Logic, Cambridge and Dublin
Mathematical journal, vol. 3, 1848 - Reduced propositional logic to algebraic
manipulations
Moon crater named after him close to the Babbage
crater
6Outline
- What is SAT?
- How do we solve SAT?
- Why is SAT important?
7Propositional logic
- Long history
- Aristotle
- Leibnitz
- Boole
- Foundation for formalizing deductive reasoning
- Used extensively to automate such reasoning in
Artificial Intelligence
8A diplomatic problem
- As chief of staff, you are to sent out
invitations to the embassy ball. - The ambassador instructs you to invite Peru or
exclude Qatar. - The vice-ambassador wants you to invite Qatar or
Romania or both. - A recent diplomatic incidents means that you
cannot invite both Romania and Peru - Who do you invite?
9A diplomatic problem
- As chief of staff, you are to sent out
invitations to the embassy ball. - The ambassador instructs you to invite Peru or
exclude Qatar. - The vice-ambassador wants you to invite Qatar or
Romania or both. - A recent diplomatic incidents means that you
cannot invite both Romania and Peru - Who do you invite?
10A diplomatic problem
- As chief of staff, you are to sent out
invitations to the embassy ball. - The ambassador instructs you to invite Peru or
exclude Qatar. - The vice-ambassador wants you to invite Qatar or
Romania or both. - A recent diplomatic incidents means that you
cannot invite both Romania and Peru - Who do you invite?
- P v -Q
- Q v R
- -(R P)
- P,Q,-R or -P,-Q,R
11Propositional satisfiability (SAT)
- Given a propositional formula, does it have a
model (satisfying assignment)? - 1st decision problem shown to be NP-complete
- Usually focus on formulae in clausal normal form
(CNF)
P iff Q, Q iff R, -(P iff R)
P -gt Q, -Q, P
P v Q, P -Q
12Clausal Normal Form
- Formula is a conjunction of clauses
- C1 C2
- Each clause is a disjunction of literals
- L1 v L2 v L3,
- Empty clause contains no literals (False)
- Unit clauses contains single literal
- Each literal is variable or its negation
- P, -P, Q, -Q,
P v Q, -P v -Q
P v -Q, Q v -R, P v -R
P v Q v R, -P v -R
13Clausal Normal Form
- k-CNF
- Each clause has k literals
- 3-CNF
- NP-complete
- Best current complete methods are exponential
- 2-CNF
- Polynomial (indeed, linear time)
P v Q, -P v -Q
P v -Q, Q v -R, P v -R
P v Q v R, -P v -R
14Converting to CNF
- Eliminate iff and implies
- P iff Q gt P implies Q, Q implies P
- P implies Q gt -P v Q
- Push negation down
- -(P Q) gt -P v -Q
- -(P v Q) gt -P -Q
15Converting to CNF
- Clausify using De Morgans laws
- E.g. P v (Q R) gt (P v Q) (P v R)
- In worst case, formula may grow exponentially in
size - Can introduce new literals to prevent this blow up
16How do we solve SAT?
- Systematic methods
- Truth tables
- Davis Putnam procedure
- Local search methods
- GSAT
- WalkSAT
- Tabu search, SA,
- Exotic methods
- DNA, quantum computing,
17Truth tables
- Enumerate all possible truth assignments
- P Q R C1P v Q C2-Q v -R C1C2
- T T T T F
F - T T F T T
T - T F T T T
T - T F F
18Davis Putnam procedure
- Introduced by Davis Putnam in 1960
- Resolution rule required exponential space
- Modified by Davis, Logemann and Loveland in 1962
- Resolution rule replaced by splitting rule
- Trades space for time
- Modified algorithm usually inaccurately called
Davis Putnam procedure
19Davis Putnam procedure
- Consider
- (X or Y) (-X or Z) (-Y or Z)
- Basic idea
- Try Xtrue
20Davis Putnam procedure
- Consider
- (X or Y) (-X or Z) (-Y or Z)
- Basic idea
- Try Xtrue
- Remove clauses which must be satisfied
21Davis Putnam procedure
- Consider
- (-X or Z) (-Y or Z)
- Basic idea
- Try Xtrue
- Remove clauses which must be satisfied
- Simplify clauses containing -X
22Davis Putnam procedure
- Consider
- ( Z) (-Y or Z)
- Basic idea
- Try Xtrue
- Remove clauses which must be satisfied
- Simplify clauses containing -X
- Can now deduce that Z must be true
23Davis Putnam procedure
- Consider
- ( Z) (-Y or Z)
- Basic idea
- Try Xtrue
- Remove clauses which must be satisfied
- Simplify clauses containing -X
- Can now deduce that Z must be true
- At any point, may have to backtrack and try
Xfalse instead
24Procedure DPLL(C)
- (SAT) if C then SAT
- (Empty) if empty clause in C then UNSAT
- (Unit) if unit clause, l then
- DPLL(Cl/True)
- (Split) if DPLL(Cl/True) then SAT else
- DPLL(Cl/False)
25Procedure DPLL(C)
- (Pure) if l is pure in C then
- DPLL(Cl/True)
- (Taut) if l v -l in C then
- DPLL(C - l v -l)
- Neither rules are needed for completeness and do
not tend to improve solving efficiency
26Procedure DPLL(C)
- (SAT) if C then SAT
- (Empty) if empty clause in C then UNSAT
- (Unit) if unit clause, l then
- DPLL(Cl/True)
- (Split) if DPLL(Cl/True) then SAT else
- DPLL(Cl/False)
- Unit rule not needed for completeness but
improves efficiency greatly
27Procedure DPLL(C)
- Non-deterministic
- Which literal do we branch upon?
- Good choice can reduce solving time
significantly - Popular heuristics include
- MOMs (most occurrences in minimal size clauses)
- Literal that gives most unit propagation
28Procedure DPLL(C)
- Other refinements
- Non-chronological backtracking (conflict
directed backjumping, ) - Clause learning (at end of branch, identify
cause for failure and add this as an additional
clause) - Fast data structures (two literal watching for
fast unit propagation)
29Procedure DPLL(C)
- Space complexity
- O(n)
- Time complexity
- O(1.618n)
- Average and best case often much better than this
worst case (see next lecture)
30Brief History of DP
- 1st generation (1960s)
- DP, DLL
- 2nd generation (1980s/90s)
- POSIT, Tableau,
- 3rd generation (mid 1990s)
- SATO, satz, grasp,
- 4th generation (2000s)
- Chaff, BerkMin,
- 5th generation?
Actual Japanese 5th Generation Computer (from FGC
Museum archive)
31Brief History of DP
- 1st generation (1960s)
- DP, DLL
- 2nd generation (1980s/90s)
- POSIT, Tableau,
- 3rd generation (mid 1990s)
- SATO, satz, grasp,
- 4th generation (2000s)
- Chaff, BerkMin,
- 5th generation?
- Will it need a paradigm shift?
Actual Japanese 5th Generation Computer (from FGC
Museum archive)
32Moores Law
- Are we keeping up with Moores law?
- Number of transistors doubles every 18 months
- Number of variables reported in random 3SAT
experiments doubles every 3 or 4 years - Were falling behind each year!
- Even though were getting better performance due
to Moores law!
33Local search for SAT
- Repair based methods
- Instead of building up a solution, take complete
assignment and flip variable to satisfy more
clauses - Cannot prove UNSATisfiability
- Often will solve MAX-SAT problem
34Papadimitrous procedure
- T random truth assignment
- Repeat until T satisfies all clauses
- v variable in UNSAT clause
- T T with vs value flipped
- Semi-decision procedure
- Solves 2-SAT in expected O(n2) time
35GSAT Selman, Levesque, Mitchell AAAI
92
- Repeat MAX-TRIES times or until clauses satisfied
- T random truth assignment
- Repeat MAX-FLIPS times or until clauses satisfied
- v variable which flipping maximizes number of
SAT clauses - T T with vs value flipped
- Adds restarts and greediness
- Sideways flips important (large plateaus to
explore)
36WalkSAT Selman, Kautz, Cohen AAAI 94
- Repeat MAX-TRIES times or until clauses satisfied
- T random truth assignment
- Repeat MAX-FLIPS times or until clauses satisfied
- c unsat clause chosen at random
- v var in c chosen either greedily or at random
- T T with vs value flipped
- Focuses on UNSAT clauses
37Novelty McAllester, Selman, Kautz AAAI
97
- Repeat MAX-TRIES times or until clauses satisfied
- T random truth assignment
- Repeat MAX-FLIPS times or until clauses satisfied
- c unsat clause chosen at random
- v var in c chosen greedily
- If v was last var in clause flipped and rand(1)ltp
then - v var in c with 2nd highest score
- T T with vs value flipped
- Encourages diversity (like Tabu search)
38Other local search methods
- Simulated annealing
- Tabu search
- Genetic algorithms
- Hybrid methods
- Combine best features of systematic methods (eg
unit propagation) and local search (eg quick
recovery from failure)
39Exotic methods
- Quantum computing
- DNA computing
- Ant computing
40Beyond the propositional
- Linear 0/1 inequalities
- Quantified Boolean satisfiability
- Stochastic satisfiability
- Modal satisfiability
41Linear 0/1 inequalities
- Constraints of the form
- Sum ai . Xi gt c
- SAT can easily be expressed as linear 0/1 problem
- X v -Y v Z gt X (1-Y) Z gt 1
42Linear 0/1 inequalities
- Often good for describing problems involving
arithmetic - Counting constraints
- Objective functions
- Solution methods
- Complete Davis-Putnam like methods
- Local search methods like WalkSAT(PB)
43Quantified Boolean formulae
- Propositional SAT can be expressed as
- Exists P, Q, R . (P v Q) (-Q v R)
- Can add universal quantifiers
- Forall P . Exists Q, R . (P v Q) (-Q v R) ..
- Useful in formal methods, conditional planning
44Quantified Boolean formulae
- SAT of QBF is PSPACE complete
- Can be seen as game
- Existential quantifiers trying to make it SAT
- Universal quantifiers trying to make it UNSAT
- Solution methods
- Extensions of the DPLL procedure
- Local search methods just starting to appear
45Stochastic satisfiability
- Randomized quantifier in addition to the
existential - With prob p, Q is True
- With prob (1-p), Q is False
- Can we satisfy formula in some fraction of
possible worlds? - Useful for modelling uncertainty present in real
world (eg planning under uncertainty)
46Conclusions
- Defined propositional SAT
- Complete methods
- Davis Putnam, DPLL,
- Local search procedures
- GSAT, WalkSAT, Novelty,
- Extensions