dpll method - profs area scienze ed...

49

Upload: others

Post on 15-Oct-2019

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL method

Page 2: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Summary

DPLL procedure

DPLL example

Page 3: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL procedure: Intro

Basic facts

Pobably the most e�cient procedure for checking

satis�ability of ground clauses

Input: a set of ground clauses

Output: decides whether the set of clauses is unsatis�ableor not

if the set of clauses is satis�able the algorithm outputs an

assignment that satis�es the set of clauses

Page 4: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL procedure: history

History

DPLL = Davis-Putnam-Logemann-Loveland.

Introduced in two article in 1960.

Impressive engineering work to make it e�cient over the

years.

Page 5: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

The SAT problem

SAT

Given a propositional formula �nd an assignment that

satis�es the formula or show that such an assignment does

not exists

SAT is decidable, but computationally untractable: SAT isNP-Complete

NP-Complete: any NP problems can be reduced to SAT in

polynomial time: e.g. Travelling Salesman Problem.

Since SAT is NP-Complete it is very important to �nd

e�cient procedures

Many applications to practical problems: e.g. hardware

veri�cation.

Page 6: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL procedure: general concepts

general concepts

Start from a ground CNF formula

Try to build an assignment that veri�es the formula

The assignment is built using a backtracking mechanism

Page 7: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL procedure: simple sketch

Simple sketch

A tree of possible assignments is used to guide theprocedure

Each node is a set of clauses Si

At each node one of the Literal is assigned a truth value

Truth values are propagated to reduce the number of

future assignments

Page 8: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL procedure: Algorithm

Algorithm

Input: S = C0 = {C1, · · · ,Ck} whereCi = L1 ∨ L2 ∨ · · · ∨ Lri .Set C0 as the root of the tree.

Apply (inference) rules to leaves, expanding the tree.

A branch of the tree is no longer expanded if Si = { } or� ∈ Si where � is the empty clause.

If Si = { } then S is satis�able and we can stop the

procedure.

If � ∈ Si for all branches then the set is unsatis�able.

Page 9: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL procedure: Applying rules

Applying Rules

We apply a given set of rules that preserve satis�ability.

When we apply a rule, we build at the same time a partial

interpretation for S .

Rules:

1 Tautology elimination

2 One-Literal

3 Pure Literal

4 Splitting

Page 10: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Tautology Elimination

Tautology Elimination

Delete all the ground clauses from S that are tautologies. The

remaining set S ′ is unsatis�able i� S is unsatis�able.

Example (Tautology elimination)

S = {(¬P ∨ Q ∨ P ∨ ¬R) ∧ Q ∧ R}S ′ = {Q ∧ R}

Page 11: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

One-Literal

One-Literal (Unit clause)

If there is a unit ground clause L ∈ S , obtain S ′ from S by

deleting those ground clauses in S containing L. If S ′ = { } thenS is satis�able Otherwise obtain a set S ′′ from S ′ by deleting ¬Lfrom all clauses. S is unsatis�able i� S ′′ is.unsatis�able. When

we apply this rule we �x L = > in the partial assignment.

Example (One-Literal)

S = {P ∨ Q ∨ ¬R,P ∨ ¬Q,¬P,R,U}Apply One-Literal rule with L = ¬P :S ′ = {P ∨ Q ∨ ¬R,P ∨ ¬Q,R,U}Remove ¬L = P from cluases in S ′ S ′′ = {Q ∨ ¬R,¬Q,R,U}We �x L = > therefore P = ⊥

Page 12: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Pure-Literal

De�nition (Pure Literal)

L ∈ S is a pure literal i� ¬L 6∈ S

Pure-Literal Rule

If there is a pure literal L ∈ S , obtain S ′ from S by deleting all

clauses where L appears. S ′ is unsatis�able i� S ′ is unsatis�able.When we apply this rule we �x L = > in the partial assignment.

Example (Pure-Literal)

S = {P ∨ Q,P ∨ ¬Q,R ∨ Q,R ∨ ¬Q}Apply Pure-Literal rule with L = P :

S ′ = {R ∨ Q,R ∨ ¬Q}We �x L = > therefore P = >

Page 13: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Splitting

Splitting Rule

If we can write S in the following form:

S = (C1 ∨ L) ∧ · · · ∧ (Cm ∨ L)∧(D1 ∨ ¬L) ∧ · · · ∧ (Dm ∨ ¬L)∧Sr

Where Ci and Di are clauses in which L and ¬L do not appear,

and where Sr is a set of clauses where L and ¬L do not appear.

Then we can obtain two sets S ′ = C1 ∧ · · · ∧ Cm ∧ Sr and S ′′ =D1 ∧ · · · ∧ Dm ∧ Sr . The set S is unsatis�able i� S ′ and S ′′ areunsatis�able. When we apply this rule we split the tree and we

�x L = > for the branch of S ′′ and L = ⊥ in the branch of S ′.

Page 14: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Splitting:Example

Example (Splitting)

S = {P ∨ ¬Q ∨ R,¬P ∨ Q,Q ∨ ¬R,¬Q ∨ ¬R}Apply Splitting on P

S ′ = {¬Q ∨ R,Q ∨ ¬R,¬Q ∨ ¬R}, P = ⊥S ′′ = {Q,Q ∨ ¬R,¬Q ∨ ¬R}, P = >

Page 15: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example I

Example (Example I)

S = (P ∨ Q ∨ ¬R) ∧ (P ∨ ¬Q) ∧ ¬P ∧ R ∧ U

{ } (P ∨ Q ∨ ¬R) ∧ (P ∧ ¬Q) ∧ ¬P ∧ R ∧ U One-Literal on ¬P{¬P} (Q ∨ ¬R) ∧ ¬Q ∧ R ∧ U One-Literal on ¬Q

{¬P,¬Q} ¬R ∧ R ∧ U One-Literal on R

{¬P,¬Q} ¬R ∧ R ∧ U One-Literal on R

{¬P,¬Q,R} � ∧ U unsatis�able

Page 16: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example II

Example (Example II)

S = (P ∨ Q) ∧ ¬Q ∧ (¬P ∨ Q ∨ ¬R)

{ } S = (P ∨ Q) ∧ ¬Q ∧ (¬P ∨ Q ∨ ¬R) One-Literal on ¬Q{¬Q} P ∧ (¬P ∨ ¬R) One-Literal on P

{¬Q,P} ¬R One-Literal on ¬R{¬Q,P,¬R} { } Satis�able

Page 17: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Soundness of DPLL rules

Soundness

DPLL rules must be sound

If the original set S is unsatis�able then the remaining set

S ′ after applying the rule is still unsatis�able and viceversa.

Soundness of Tautology Elimination

Need to show that S ′ is unsatis�able i� S is unsatis�able.

Since a tautology is satis�ed by every interpretation, S ′ is unsat-is�able i� S is unsatis�able.

Page 18: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Soundness of One-Literal I

Soundness of One-Literal I

Recall that:

S ′ obtained by removing all clauses containing L from S .

S ′′ obtained by removing ¬L from clauses in S ′.

Need to show that:

If S ′ = { } then S is satis�able.

If S ′ is empty then any clause in S contains L therefore any

interpretation containing L satis�es S

Page 19: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Soundness of One-Literal II

Soundness of One-Literal II

Recall that:

S ′ obtained by removing all clauses containing L from S .

S ′′ obtained by removing ¬L from S ′.

Need to show that:

S ′′ is unstais�able i� S is unsatis�able.

⇒ Suppose S ′′ is unsatis�able and S is satis�able, then

there is I such that L ∈ I and I |= S . I must satisfy all

clauses which are not in S ′′; since I falsi�es ¬L then I must

satisfy all clauses in S that contains ¬L. Then I |= S ′′.

⇐ Suppose S is unsatis�able and S ′′ is satis�able, Thenthere is I |= S ′′. Since S ′′ does not contain L and ¬L, wecan build I ′ by adding L to I , I ′ |= S .

Page 20: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Soundness of Pure-Literal

Soundness of Pure Literal

Recall that:

S ′ obtained by removing all clauses containing L from S .

Need to show that:

S ′ unsatis�able i� S is unsatis�able.

⇒ suppose S ′ unsat. and S sat. Then there is I |= S ,

since S ′ ⊆ S then I |= S ′

⇐ suppose S unsat and S ′ sat. Then there is I |= S ′, sinceL 6∈ S ′ and ¬L 6∈ S ′ we can build I ′ adding L to I , and

I ′ |= S .

Page 21: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Soundness of Splitting

Soundness of Splitting

Recall that:

S = (C1 ∨ L) ∧ · · · ∧ (Cm ∨ L) ∧(D1 ∨ ¬L) ∧ · · · ∧ (Dm ∨ ¬L) ∧ SrS ′ = C1 ∧ · · · ∧ Cm ∧ SrS ′′ = D1 ∧ · · · ∧ Dm ∧ Sr

Need to show that:

S is unsatis�able i� S ′ and S ′′ are unsatis�able.

⇒ suppose S unsat and S ′ or S ′′ are sat. If S ′(S ′′) has amodel I then for any interpretation I ′ = ¬L(L) ∪ I we haveI ′ |= S .

⇐ suppose S ′ and S ′′ are unsat. and S is sat. Then there

is I |= S . If I contains ¬L(L) then I |= S ′ (I |= S ′′)therefore either S ′ or S ′′ is satis�able.

Page 22: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 23: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 24: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 25: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 26: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 27: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 28: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 29: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 30: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 31: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬R

S′′ {P,Q,¬R} { } Satis�able!

Page 32: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example III

Example (Example III)

S = (P ∨ Q) ∧ (P ∨ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R)

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′ {¬P} Q ∧ ¬Q One-Literal on Q

S′ {¬P,Q} � S′ Unsat

Backtrack

{ } (P ∨ Q) ∧ (P ∧ ¬Q) ∧ (¬P ∨ Q) ∧ (¬P ∨ ¬R) Split on P

S′′ {P} Q ∧ ¬R One-Literal on Q

S′′ {P,Q} ¬R One-Literal on ¬RS′′ {P,Q,¬R} { } Satis�able!

Page 33: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 34: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 35: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 36: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 37: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 38: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 39: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 40: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 41: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 42: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 43: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting �rst

Example (Example IV: using splitting �rst)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′ {¬P} ¬Q ∧ Q One-Literal on Q

S ′ {¬P,Q} � S ′ Unsat

Backtrack

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q Split on P

S ′′ {P} R ∧ Q One-Literal on Q

S ′′ {P,Q} R One-Literal on R

S ′′ {P,Q,R} { } Satis�able!

Page 44: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting last

Example (Example IV: usin splitting last)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q One-Literal on Q

{Q} P ∧ (¬P ∨ R) Pure-Literal on R

{Q,R, } P One-Literal on P

{Q,R,P} { } Satis�able!

Page 45: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting last

Example (Example IV: usin splitting last)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q One-Literal on Q

{Q} P ∧ (¬P ∨ R) Pure-Literal on R

{Q,R, } P One-Literal on P

{Q,R,P} { } Satis�able!

Page 46: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting last

Example (Example IV: usin splitting last)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q One-Literal on Q

{Q} P ∧ (¬P ∨ R) Pure-Literal on R

{Q,R, } P One-Literal on P

{Q,R,P} { } Satis�able!

Page 47: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

DPLL Example IV: using splitting last

Example (Example IV: usin splitting last)

S = (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q

{ } (P ∨ ¬Q) ∧ (¬P ∨ R) ∧ Q One-Literal on Q

{Q} P ∧ (¬P ∨ R) Pure-Literal on R

{Q,R, } P One-Literal on P

{Q,R,P} { } Satis�able!

Page 48: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Exercise on DPLL I

Exercise

Decide whether the following set of clauses are satis�ableusing DPLL

1 p ∨ q,¬p ∨ q,¬r ∨ ¬q, r ∨ ¬q2 p ∨ q ∨ r , ¬p ∨ ¬q ∨ ¬r , ¬p ∨ q ∨ r , ¬q ∨ r , q ∨ ¬r3 ¬q ∨ p, ¬p ∨ ¬q, q ∨ r , ¬q ∨ ¬r , ¬p ∨ ¬r , p ∨ ¬r

Page 49: DPLL method - Profs Area Scienze ed Ingegneriaprofs.sci.univr.it/~farinelli/courses/ar/slides/DPLL.pdf · DPLL method One-Literal One-Literal (Unit clause) If there is a unit ground

DPLLmethod

Exercise on DPLL II

Exercise

Solve the Quack and Doctors problem using Gilmore +DPLL

1 F1 , Some patients like all doctors

(∃x)(P(x) ∧ (∀y)(D(y) → L(x , y)))

2 F2 , No patient likes any quack:

(∀x)(P(x) → (∀y)(Q(y) → ¬L(x , y)))3 F3 , No doctor is a quack:

(∀x)(D(x) → ¬Q(x))

4 F1 ∧ F2 |= F3 ?