The DPLL Procedurehomepage.cs.uiowa.edu/~tinelli/classes/196/Fall09/notes/dpll.pdfThe Original DPLL...
Transcript of The DPLL Procedurehomepage.cs.uiowa.edu/~tinelli/classes/196/Fall09/notes/dpll.pdfThe Original DPLL...
Propositional Satisfiability: SAT
• Deciding the satisfiability of a propositional formula is awell-studied and important problem.
• Theoretical interest: first established NP-Completeproblem, phase transition, . . .
• Practical interest: applications to scheduling, planning,logic synthesis, verification, . . .
• Development of algorithms and enhancements.• Implementation of extremely efficient tools.• Solvers based on the DPLL procedure have been the
most successful so far.
22c:196, Feb 2007 – p.2/17
The Original DPLL
• Tries to build incrementally a satisfying truth assignmentM for a CNF formula F .
• M is grown by• deducing the truth value of a literal from M and F ,
or• guessing a truth value.
• If a wrong guess for a literal leads to an inconsistency,the procedure backtracks and tries the opposite value.
22c:196, Feb 2007 – p.3/17
The Original DPLL – Example
Operation Assign. Formula
1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
22c:196, Feb 2007 – p.4/17
The Original DPLL – Example
Operation Assign. Formula
1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
22c:196, Feb 2007 – p.4/17
The Original DPLL – Example
Operation Assign. Formula
1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
deduce 2 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
22c:196, Feb 2007 – p.4/17
The Original DPLL – Example
Operation Assign. Formula
1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
deduce 1 1 1 ∨ 2,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 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
deduce 4 1, 2, 3, 4 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
undo 3 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1
Model Found!
22c:196, Feb 2007 – p.5/17
An Abstract Framework for DPLL
• The DPLL procedure can be described declaratively bysimple sequent-style calculi.
• Such calculi however cannot model meta-logical featuressuch as backtracking, learning and restarts.
• We model DPLL and its enhancements as transitionsystems instead.
• A transition system is a binary relation over states,induced by a set of conditional transition rules.
22c:196, Feb 2007 – p.6/17
An Abstract Framework for DPLL
Our states:
fail or M || F
where F is a CNF formula, a set of clauses, and
M is a sequence of annotated literals
denoting a partial truth assignment.
22c:196, Feb 2007 – p.7/17
An Abstract Framework for DPLL
Our states:
fail or M || F
Initial state:
• ∅ || F , where F is to be checked for satisfiability.
Expected final states:
• fail , if F is unsatisfiable
•M || G, where M is a model of G and
G is logically equivalent to F .
22c:196, Feb 2007 – p.7/17
Transition Rules for the Original DPLL
Extending the assignment:
Propagate
M || F, C ∨ l → M l || F, C ∨ l if
{
M falsifies C,
l is undefined in M
22c:196, Feb 2007 – p.8/17
Transition Rules for the Original DPLL
Extending the assignment:
Propagate
M || F, C ∨ l → M l || F, C ∨ l if
{
M falsifies C,
l is undefined in M
Decide
M || F → M l• || F if
{
l or l occurs in F,
l is undefined in M
Notation: l• annotates l as a decision literal.
22c:196, Feb 2007 – p.8/17
Transition Rules for the Original DPLL
Repairing the assignment:
Fail
M || F, C → fail if
{
M falsifies C,
M contains no decision literals
22c:196, Feb 2007 – p.9/17
Transition Rules for the Original DPLL
Repairing the assignment:
Fail
M || F, C → fail if
{
M falsifies C,
M contains no decision literals
Backtrack
M l• N || F,C → M l || F,C if
{
M l• N falsifies C,
l last decision literal
22c:196, Feb 2007 – p.9/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
p1•, p2, p3
•, p4, p5• Decide
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
p1•, p2, p3
•, p4, p5• Decide
p1•, p2, p3
•, p4, p5•, p6 Propagate 3.
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
p1•, p2, p3
•, p4, p5• Decide
p1•, p2, p3
•, p4, p5•, p6 Propagate 3.
p1•, p2, p3
•, p4, p5 Backtrack 4.
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
p1•, p2, p3
•, p4, p5• Decide
p1•, p2, p3
•, p4, p5•, p6 Propagate 3.
p1•, p2, p3
•, p4, p5 Backtrack 4.
p1•, p2, p3
•, p4, p5, p7 Propagate 5.
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
p1•, p2, p3
•, p4, p5• Decide
p1•, p2, p3
•, p4, p5•, p6 Propagate 3.
p1•, p2, p3
•, p4, p5 Backtrack 4.
p1•, p2, p3
•, p4, p5, p7 Propagate 5.
p1•, p2, p3 Backtrack 6.
22c:196, Feb 2007 – p.10/17
Original DPLL System – Example
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
p1•, p2, p3
•, p4, p5• Decide
p1•, p2, p3
•, p4, p5•, p6 Propagate 3.
p1•, p2, p3
•, p4, p5 Backtrack 4.
p1•, p2, p3
•, p4, p5, p7 Propagate 5.
p1•, p2, p3 Backtrack 6.
. . .22c:196, Feb 2007 – p.10/17
From Backtracking to BackjumpingBacktrack
M l• N || F,C → M l || F,C if
{
M l• N falsifies C,
l last decision literal
22c:196, Feb 2007 – p.11/17
From Backtracking to BackjumpingBacktrack
M l• N || F,C → M l || F,C if
{
M l• N falsifies C,
l last decision literal
Backjump
M l• N || F,C → M k || F,C if
1. M l• N falsifies C,
2. for some clause D ∨ k:
F,C |= D ∨ k,
M falsifies D,
k is undefined in M,
k or k occurs in
M l• N || F,C
22c:196, Feb 2007 – p.11/17
From Backtracking to BackjumpingBacktrack
M l• N || F,C → M l || F,C if
{
M l• N falsifies C,
l last decision literal
Backjump
M l• N || F,C → M k || F,C if
1. M l• N falsifies C,
2. for some clause D ∨ k:
F,C |= D ∨ k,
M falsifies D,
k is undefined in M,
k or k occurs in
M l• N || F,C
Note: D ∨ k is computed by conflict analysis.22c:196, Feb 2007 – p.11/17
Example Revised
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
p1•, p2, p3
•, p4, p5• Decide
p1•, p2, p3
•, p4, p5•, p6 Propagate 3.
22c:196, Feb 2007 – p.12/17
Example Revised
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
p1•, p2, p3
•, p4, p5• Decide
p1•, p2, p3
•, p4, p5•, p6 Propagate 3.
p1•, p2, p5 Backjump with p2 ∨ p5.
22c:196, Feb 2007 – p.12/17
Example Revised
F := 1. p1 ∨ p2, 2. p3 ∨ p4, 3. p6 ∨ p5 ∨ p2
4. p5 ∨ p6, 5. p5 ∨ p7, 6. p1 ∨ p5 ∨ p7
M Rule
p1• Decide
p1•, p2 Propagate 1.
p1•, p2, p3
• Decide
p1•, p2, p3
•, p4 Propagate 2.
p1•, p2, p3
•, p4, p5• Decide
p1•, p2, p3
•, p4, p5•, p6 Propagate 3.
p1•, p2, p5 Backjump with p2 ∨ p5.
. . .
22c:196, Feb 2007 – p.12/17
Basic DPLL System
At the core, current DPLL-based SAT solvers areimplementations of the transition system:
Basic DPLL
• Propagate
• Decide
• Fail
• Backjump
22c:196, Feb 2007 – p.13/17
The Basic DPLL System – CorrectnessSome terminology
Irreducible state: state to which no transition rule applies.
Execution: sequence of transitions allowed by the rules and
starting with states of the form ∅ || F .
Exhausted execution: execution ending in an irreducible state.
22c:196, Feb 2007 – p.14/17
The Basic DPLL System – CorrectnessSome terminology
Irreducible state: state to which no transition rule applies.
Execution: sequence of transitions allowed by the rules and
starting with states of the form ∅ || F .
Exhausted execution: execution ending in an irreducible state.
Proposition (Strong Termination) Every execution in BasicDPLL is finite.
Note: This is not so immediate, because of Backjump.
22c:196, Feb 2007 – p.14/17
The Basic DPLL System – CorrectnessSome terminology
Irreducible state: state to which no transition rule applies.
Execution: sequence of transitions allowed by the rules and
starting with states of the form ∅ || F .
Exhausted execution: execution ending in an irreducible state.
Proposition (Soundness) For every exhausted executionstarting with ∅ || F and ending in M || F , M satisfies F .
Proposition (Completeness) If F is unsatisfiable, everyexhausted execution starting with ∅ || F ends with fail .
22c:196, Feb 2007 – p.14/17
Enhancements to Basic DPLL
22c:196, Feb 2007 – p.15/17
Enhancements to Basic DPLL
Learn
M || F → M || F, C if
{
all atoms of C occur in F,
F |= C
22c:196, Feb 2007 – p.15/17
Enhancements to Basic DPLL
Learn
M || F → M || F, C if
{
all atoms of C occur in F,
F |= C
Forget
M || F, C → M || F if F |= C
22c:196, Feb 2007 – p.15/17
Enhancements to Basic DPLL
Learn
M || F → M || F, C if
{
all atoms of C occur in F,
F |= C
Forget
M || F, C → M || F if F |= C
Usually C is a clause identified during conflict analysis.
22c:196, Feb 2007 – p.15/17
Enhancements to Basic DPLL
Learn
M || F → M || F, C if
{
all atoms of C occur in F,
F |= C
Forget
M || F, C → M || F if F |= C
RestartM || F → ∅ || F if . . . you want to
22c:196, Feb 2007 – p.15/17
Enhancements to Basic DPLL
Learn
M || F → M || F, C if
{
all atoms of C occur in F,
F |= C
Forget
M || F, C → M || F if F |= C
RestartM || F → ∅ || F if . . . you want to
The DPLL system =
{Propagate,Decide,Fail,Backjump, Learn,Forget,Restart}
22c:196, Feb 2007 – p.15/17
The DPLL System – Strategies• Applying one Basic DPLL rule between each two Learn
and applying Restart less and less often ensurestermination.
22c:196, Feb 2007 – p.16/17
The DPLL System – Strategies• Applying one Basic DPLL rule between each two Learn
and applying Restart less and less often ensurestermination.
• In practice, Learn is usually (but not only) applied rightafter Backjump.
22c:196, Feb 2007 – p.16/17
The DPLL System – Strategies• Applying one Basic DPLL rule between each two Learn
and applying Restart less and less often ensurestermination.
• In practice, Learn is usually (but not only) applied rightafter Backjump.
• A common strategy is to apply the rules with thesepriorities:
22c:196, Feb 2007 – p.16/17
The DPLL System – Strategies• Applying one Basic DPLL rule between each two Learn
and applying Restart less and less often ensurestermination.
• In practice, Learn is usually (but not only) applied rightafter Backjump.
• A common strategy is to apply the rules with thesepriorities:
1. If n > 0 conflicts have been found so far,increase n and apply Restart.
22c:196, Feb 2007 – p.16/17
The DPLL System – Strategies• Applying one Basic DPLL rule between each two Learn
and applying Restart less and less often ensurestermination.
• In practice, Learn is usually (but not only) applied rightafter Backjump.
• A common strategy is to apply the rules with thesepriorities:
1. If n > 0 conflicts have been found so far,increase n and apply Restart.
2. If a current clause is falsified by the currentassignment,apply Fail or Backjump + Learn.
22c:196, Feb 2007 – p.16/17
The DPLL System – Strategies• Applying one Basic DPLL rule between each two Learn
and applying Restart less and less often ensurestermination.
• In practice, Learn is usually (but not only) applied rightafter Backjump.
• A common strategy is to apply the rules with thesepriorities:
1. If n > 0 conflicts have been found so far,increase n and apply Restart.
2. If a current clause is falsified by the currentassignment,apply Fail or Backjump + Learn.
3. Apply Propagate
22c:196, Feb 2007 – p.16/17
The DPLL System – Correctness
Proposition (Termination) Every execution in which(a) Learn/Forget are applied only finitely many times and(b) Restart is applied with increased periodicity
is finite.
22c:196, Feb 2007 – p.17/17
The DPLL System – Correctness
Proposition (Termination) Every execution in which(a) Learn/Forget are applied only finitely many times and(b) Restart is applied with increased periodicity
is finite.
Proposition (Soundness) For every execution∅ || F =⇒ · · · =⇒ M || F with M || F irreducible wrt. BasicDPLL, M models F .
22c:196, Feb 2007 – p.17/17
The DPLL System – Correctness
Proposition (Termination) Every execution in which(a) Learn/Forget are applied only finitely many times and(b) Restart is applied with increased periodicity
is finite.
Proposition (Soundness) For every execution∅ || F =⇒ · · · =⇒ M || F with M || F irreducible wrt. BasicDPLL, M models F .
Proposition (Completeness) If F is unsatisfiable, for everyexecution ∅ || F =⇒ · · · =⇒ S with S irreducible wrt. BasicDPLL, S = fail .
22c:196, Feb 2007 – p.17/17