• Non ci sono risultati.

Course “An Introduction to SAT and SMT” Chapter 1: Propositional Satisfiability (SAT)

N/A
N/A
Protected

Academic year: 2021

Condividi "Course “An Introduction to SAT and SMT” Chapter 1: Propositional Satisfiability (SAT)"

Copied!
343
0
0

Testo completo

(1)

Course “An Introduction to SAT and SMT”

Chapter 1: Propositional Satisfiability (SAT)

Roberto Sebastiani

DISI, Università di Trento, Italy – roberto.sebastiani@unitn.it URL: http://disi.unitn.it/rseba/DIDATTICA/SAT_SMT2020/

Int. Graduate School on ICT, University of Trento, Academic year 2019-2020

last update: Friday 22ndMay, 2020

Copyright notice: some material contained in these slides is courtesy of Alessandro Cimatti, Alberto Griggio and Marco Roveri, who detain its copyright. All the other material is copyrighted by Roberto Sebastiani. Any commercial use of this material is strictly forbidden by the copyright laws without the authorization of the authors. No copy of these slides can be

displayed in public without containing this copyright notice.

(2)

Outline

1 Basics on SAT

2 Basic SAT-Solving techniques

3 Modern CDCL SAT Solvers

Conflict-Driven Clause-Learning SAT solvers Further Improvements

4 Tractable subclasses of SAT

5 Random k-SAT and Phase Transition

6 Advanced Functionalities: proofs, unsat cores, interpolants, optimization

7 Some Applications

Appl. #1: (Bounded) Planning

Appl. #2: Bounded Model Checking

(3)

Outline

1 Basics on SAT

2 Basic SAT-Solving techniques

3 Modern CDCL SAT Solvers

Conflict-Driven Clause-Learning SAT solvers Further Improvements

4 Tractable subclasses of SAT

5 Random k-SAT and Phase Transition

6 Advanced Functionalities: proofs, unsat cores, interpolants, optimization

7 Some Applications

Appl. #1: (Bounded) Planning

Appl. #2: Bounded Model Checking

(4)

Boolean logic

(5)

Basic notation & definitions

Boolean formula

>, ⊥ are formulas

A propositional atom A

1

, A

2

, A

3

, ... is a formula;

if ϕ

1

and ϕ

2

are formulas, then

¬ϕ

1

, ϕ

1

∧ ϕ

2

, ϕ

1

∨ ϕ

2

, ϕ

1

→ ϕ

2

, ϕ

1

← ϕ

2

, ϕ

1

↔ ϕ

2

are formulas.

Atoms(ϕ): the set {A 1 , ..., A N } of atoms occurring in ϕ.

Literal: a propositional atom A i (positive literal) or its negation ¬A i (negative literal)

Notation: if l := ¬A

i

, then ¬l := A

i

Clause: a disjunction of literals W

j l j (e.g., (A 1 ∨ ¬A 2 ∨ A 3 ∨ ...)) Cube: a conjunction of literals V

j l j (e.g., (A 1 ∧ ¬A 2 ∧ A 3 ∧ ...))

(6)

Semantics of Boolean operators

Truth table:

ϕ 1 ϕ 2 ¬ϕ 1 ϕ 1 ∧ ϕ 2 ϕ 1 ∨ ϕ 2 ϕ 1 → ϕ 2 ϕ 1 ← ϕ 2 ϕ 1 ↔ ϕ 2

⊥ ⊥ > ⊥ ⊥ > > >

⊥ > > ⊥ > > ⊥ ⊥

> ⊥ ⊥ ⊥ > ⊥ > ⊥

> > ⊥ > > > > >

Note

∧, ∨ and ↔ are commutative:

1 ∧ ϕ 2 ) ⇐⇒ (ϕ 2 ∧ ϕ 1 ) (ϕ 1 ∨ ϕ 2 ) ⇐⇒ (ϕ 2 ∨ ϕ 1 ) (ϕ 1 ↔ ϕ 2 ) ⇐⇒ (ϕ 2 ↔ ϕ 1 )

∧ and ∨ are associative:

((ϕ 1 ∧ ϕ 2 ) ∧ ϕ 3 ) ⇐⇒ (ϕ 1 ∧ (ϕ 2 ∧ ϕ 3 )) ⇐⇒ (ϕ 1 ∧ ϕ 2 ∧ ϕ 3 )

((ϕ 1 ∨ ϕ 2 ) ∨ ϕ 3 ) ⇐⇒ (ϕ 1 ∨ (ϕ 2 ∨ ϕ 3 )) ⇐⇒ (ϕ 1 ∨ ϕ 2 ∨ ϕ 3 )

(7)

Semantics of Boolean operators

Truth table:

ϕ 1 ϕ 2 ¬ϕ 1 ϕ 1 ∧ ϕ 2 ϕ 1 ∨ ϕ 2 ϕ 1 → ϕ 2 ϕ 1 ← ϕ 2 ϕ 1 ↔ ϕ 2

⊥ ⊥ > ⊥ ⊥ > > >

⊥ > > ⊥ > > ⊥ ⊥

> ⊥ ⊥ ⊥ > ⊥ > ⊥

> > ⊥ > > > > >

Note

∧, ∨ and ↔ are commutative:

1 ∧ ϕ 2 ) ⇐⇒ (ϕ 2 ∧ ϕ 1 ) (ϕ 1 ∨ ϕ 2 ) ⇐⇒ (ϕ 2 ∨ ϕ 1 ) (ϕ 1 ↔ ϕ 2 ) ⇐⇒ (ϕ 2 ↔ ϕ 1 )

∧ and ∨ are associative:

((ϕ 1 ∧ ϕ 2 ) ∧ ϕ 3 ) ⇐⇒ (ϕ 1 ∧ (ϕ 2 ∧ ϕ 3 )) ⇐⇒ (ϕ 1 ∧ ϕ 2 ∧ ϕ 3 )

((ϕ 1 ∨ ϕ 2 ) ∨ ϕ 3 ) ⇐⇒ (ϕ 1 ∨ (ϕ 2 ∨ ϕ 3 )) ⇐⇒ (ϕ 1 ∨ ϕ 2 ∨ ϕ 3 )

(8)

Syntactic Properties of Boolean Operators

¬¬ϕ 1 ⇐⇒ ϕ 1

1 ∨ ϕ 2 ) ⇐⇒ ¬(¬ϕ 1 ∧ ¬ϕ 2 )

¬(ϕ 1 ∨ ϕ 2 ) ⇐⇒ (¬ϕ 1 ∧ ¬ϕ 2 ) (ϕ 1 ∧ ϕ 2 ) ⇐⇒ ¬(¬ϕ 1 ∨ ¬ϕ 2 )

¬(ϕ 1 ∧ ϕ 2 ) ⇐⇒ (¬ϕ 1 ∨ ¬ϕ 2 ) (ϕ 1 → ϕ 2 ) ⇐⇒ (¬ϕ 1 ∨ ϕ 2 )

¬(ϕ 1 → ϕ 2 ) ⇐⇒ (ϕ 1 ∧ ¬ϕ 2 ) (ϕ 1 ← ϕ 2 ) ⇐⇒ (ϕ 1 ∨ ¬ϕ 2 )

¬(ϕ 1 ← ϕ 2 ) ⇐⇒ (¬ϕ 1 ∧ ϕ 2 )

1 ↔ ϕ 2 ) ⇐⇒ ((ϕ 1 → ϕ 2 ) ∧ (ϕ 1 ← ϕ 2 ))

⇐⇒ ((¬ϕ 1 ∨ ϕ 2 ) ∧ (ϕ 1 ∨ ¬ϕ 2 ))

¬(ϕ 1 ↔ ϕ 2 ) ⇐⇒ (¬ϕ 1 ↔ ϕ 2 )

⇐⇒ (ϕ 1 ↔ ¬ϕ 2 )

⇐⇒ ((ϕ 1 ∨ ϕ 2 ) ∧ (¬ϕ 1 ∨ ¬ϕ 2 ))

Boolean logic can be expressed in terms of {¬, ∧} (or {¬, ∨}) only

(9)

Syntactic Properties of Boolean Operators

¬¬ϕ 1 ⇐⇒ ϕ 1

1 ∨ ϕ 2 ) ⇐⇒ ¬(¬ϕ 1 ∧ ¬ϕ 2 )

¬(ϕ 1 ∨ ϕ 2 ) ⇐⇒ (¬ϕ 1 ∧ ¬ϕ 2 ) (ϕ 1 ∧ ϕ 2 ) ⇐⇒ ¬(¬ϕ 1 ∨ ¬ϕ 2 )

¬(ϕ 1 ∧ ϕ 2 ) ⇐⇒ (¬ϕ 1 ∨ ¬ϕ 2 ) (ϕ 1 → ϕ 2 ) ⇐⇒ (¬ϕ 1 ∨ ϕ 2 )

¬(ϕ 1 → ϕ 2 ) ⇐⇒ (ϕ 1 ∧ ¬ϕ 2 ) (ϕ 1 ← ϕ 2 ) ⇐⇒ (ϕ 1 ∨ ¬ϕ 2 )

¬(ϕ 1 ← ϕ 2 ) ⇐⇒ (¬ϕ 1 ∧ ϕ 2 )

1 ↔ ϕ 2 ) ⇐⇒ ((ϕ 1 → ϕ 2 ) ∧ (ϕ 1 ← ϕ 2 ))

⇐⇒ ((¬ϕ 1 ∨ ϕ 2 ) ∧ (ϕ 1 ∨ ¬ϕ 2 ))

¬(ϕ 1 ↔ ϕ 2 ) ⇐⇒ (¬ϕ 1 ↔ ϕ 2 )

⇐⇒ (ϕ 1 ↔ ¬ϕ 2 )

⇐⇒ ((ϕ 1 ∨ ϕ 2 ) ∧ (¬ϕ 1 ∨ ¬ϕ 2 ))

Boolean logic can be expressed in terms of {¬, ∧} (or {¬, ∨}) only

(10)

Basics on SAT

Tree and DAG representation of formulas: example

Formulas can be represented either as trees or as DAGS:

DAG representation can be up to exponentially smaller (A 1 ↔ A 2 ) ↔ (A 3 ↔ A 4 )

(((A 1 ↔ A 2 ) → (A 3 ↔ A 4 ))∧ ((A 3 ↔ A 4 ) → (A 1 ↔ A 2 )))

(((A 1 → A 2 ) ∧ (A 2 → A 1 )) → ((A 3 → A 4 ) ∧ (A 4 → A 3 )))∧

(((A 3 → A 4 ) ∧ (A 4 → A 3 )) → (((A 1 → A 2 ) ∧ (A 2 → A 1 ))))

(11)

Basics on SAT

Tree and DAG representation of formulas: example

Formulas can be represented either as trees or as DAGS:

DAG representation can be up to exponentially smaller (A 1 ↔ A 2 ) ↔ (A 3 ↔ A 4 )

(((A 1 ↔ A 2 ) → (A 3 ↔ A 4 ))∧

((A 3 ↔ A 4 ) → (A 1 ↔ A 2 )))

(((A 1 → A 2 ) ∧ (A 2 → A 1 )) → ((A 3 → A 4 ) ∧ (A 4 → A 3 )))∧

(((A 3 → A 4 ) ∧ (A 4 → A 3 )) → (((A 1 → A 2 ) ∧ (A 2 → A 1 ))))

(12)

Tree and DAG representation of formulas: example

Formulas can be represented either as trees or as DAGS:

DAG representation can be up to exponentially smaller (A 1 ↔ A 2 ) ↔ (A 3 ↔ A 4 )

(((A 1 ↔ A 2 ) → (A 3 ↔ A 4 ))∧

((A 3 ↔ A 4 ) → (A 1 ↔ A 2 )))

(((A 1 → A 2 ) ∧ (A 2 → A 1 )) → ((A 3 → A 4 ) ∧ (A 4 → A 3 )))∧

(((A 3 → A 4 ) ∧ (A 4 → A 3 )) → (((A 1 → A 2 ) ∧ (A 2 → A 1 ))))

(13)

Tree and DAG repres. of formulas: example (cont)

A1 A2 A2 A1 A3 A4 A4 A3 A3 A4 A4 A3 A1 A2 A2 A1

A1 A2 A3 A4

Tree Representation

DAG Representation

(14)

Basic notation & definitions (cont)

Total truth assignment µ for ϕ:

µ : Atoms(ϕ) 7−→ {>, ⊥}.

Partial Truth assignment µ for ϕ:

µ : A 7−→ {>, ⊥}, A ⊂ Atoms(ϕ).

Set and formula representation of an assignment:

µ can be represented as a set of literals:

EX: {µ(A

1

) := >, µ(A

2

) := ⊥} =⇒ {A

1

, ¬A

2

} µ can be represented as a formula (cube):

EX: {µ(A

1

) := >, µ(A

2

) := ⊥} =⇒ (A

1

∧ ¬A

2

)

(15)

Basic notation & definitions (cont)

a total truth assignment µ satisfies ϕ (µ |= ϕ):

µ |= A

i

⇐⇒ µ(A

i

) = >

µ |= ¬ϕ ⇐⇒ not µ |= ϕ

µ |= ϕ

1

∧ ϕ

2

⇐⇒ µ |= ϕ

1

and µ |= ϕ

2

µ |= ϕ

1

∨ ϕ

2

⇐⇒ µ |= ϕ

1

or µ |= ϕ

2

µ |= ϕ

1

→ ϕ

2

⇐⇒ if µ |= ϕ

1

, then µ |= ϕ

2

µ |= ϕ

1

↔ ϕ

2

⇐⇒ µ |= ϕ

1

iff µ |= ϕ

2

a partial truth assignment µ satisfies ϕ iff it makes ϕ evaluate to true (Ex: {A 1 } |= (A 1 ∨ A 2 ))

=⇒ if µ satisfies ϕ, then all its total extensions satisfy ϕ (Ex: {A

1

, A

2

} |= (A

1

∨ A

2

) and {A

1

, ¬A

2

} |= (A

1

∨ A

2

)) ϕ is satisfiable iff µ |= ϕ for some µ

ϕ 1 entails ϕ 21 |= ϕ 2 ): ϕ 1 |= ϕ 2 iff µ |= ϕ 1 =⇒ µ |= ϕ 2 for every µ ϕ is valid (|= ϕ): |= ϕ iff µ |= ϕ for every µ

Property

ϕ is valid ⇐⇒ ¬ϕ is not satisfiable

(16)

Basic notation & definitions (cont)

a total truth assignment µ satisfies ϕ (µ |= ϕ):

µ |= A

i

⇐⇒ µ(A

i

) = >

µ |= ¬ϕ ⇐⇒ not µ |= ϕ

µ |= ϕ

1

∧ ϕ

2

⇐⇒ µ |= ϕ

1

and µ |= ϕ

2

µ |= ϕ

1

∨ ϕ

2

⇐⇒ µ |= ϕ

1

or µ |= ϕ

2

µ |= ϕ

1

→ ϕ

2

⇐⇒ if µ |= ϕ

1

, then µ |= ϕ

2

µ |= ϕ

1

↔ ϕ

2

⇐⇒ µ |= ϕ

1

iff µ |= ϕ

2

a partial truth assignment µ satisfies ϕ iff it makes ϕ evaluate to true (Ex: {A 1 } |= (A 1 ∨ A 2 ))

=⇒ if µ satisfies ϕ, then all its total extensions satisfy ϕ (Ex: {A

1

, A

2

} |= (A

1

∨ A

2

) and {A

1

, ¬A

2

} |= (A

1

∨ A

2

)) ϕ is satisfiable iff µ |= ϕ for some µ

ϕ 1 entails ϕ 21 |= ϕ 2 ): ϕ 1 |= ϕ 2 iff µ |= ϕ 1 =⇒ µ |= ϕ 2 for every µ ϕ is valid (|= ϕ): |= ϕ iff µ |= ϕ for every µ

Property

ϕ is valid ⇐⇒ ¬ϕ is not satisfiable

(17)

Basic notation & definitions (cont)

a total truth assignment µ satisfies ϕ (µ |= ϕ):

µ |= A

i

⇐⇒ µ(A

i

) = >

µ |= ¬ϕ ⇐⇒ not µ |= ϕ

µ |= ϕ

1

∧ ϕ

2

⇐⇒ µ |= ϕ

1

and µ |= ϕ

2

µ |= ϕ

1

∨ ϕ

2

⇐⇒ µ |= ϕ

1

or µ |= ϕ

2

µ |= ϕ

1

→ ϕ

2

⇐⇒ if µ |= ϕ

1

, then µ |= ϕ

2

µ |= ϕ

1

↔ ϕ

2

⇐⇒ µ |= ϕ

1

iff µ |= ϕ

2

a partial truth assignment µ satisfies ϕ iff it makes ϕ evaluate to true (Ex: {A 1 } |= (A 1 ∨ A 2 ))

=⇒ if µ satisfies ϕ, then all its total extensions satisfy ϕ (Ex: {A

1

, A

2

} |= (A

1

∨ A

2

) and {A

1

, ¬A

2

} |= (A

1

∨ A

2

)) ϕ is satisfiable iff µ |= ϕ for some µ

ϕ 1 entails ϕ 21 |= ϕ 2 ): ϕ 1 |= ϕ 2 iff µ |= ϕ 1 =⇒ µ |= ϕ 2 for every µ ϕ is valid (|= ϕ): |= ϕ iff µ |= ϕ for every µ

Property

ϕ is valid ⇐⇒ ¬ϕ is not satisfiable

(18)

Basic notation & definitions (cont)

a total truth assignment µ satisfies ϕ (µ |= ϕ):

µ |= A

i

⇐⇒ µ(A

i

) = >

µ |= ¬ϕ ⇐⇒ not µ |= ϕ

µ |= ϕ

1

∧ ϕ

2

⇐⇒ µ |= ϕ

1

and µ |= ϕ

2

µ |= ϕ

1

∨ ϕ

2

⇐⇒ µ |= ϕ

1

or µ |= ϕ

2

µ |= ϕ

1

→ ϕ

2

⇐⇒ if µ |= ϕ

1

, then µ |= ϕ

2

µ |= ϕ

1

↔ ϕ

2

⇐⇒ µ |= ϕ

1

iff µ |= ϕ

2

a partial truth assignment µ satisfies ϕ iff it makes ϕ evaluate to true (Ex: {A 1 } |= (A 1 ∨ A 2 ))

=⇒ if µ satisfies ϕ, then all its total extensions satisfy ϕ (Ex: {A

1

, A

2

} |= (A

1

∨ A

2

) and {A

1

, ¬A

2

} |= (A

1

∨ A

2

)) ϕ is satisfiable iff µ |= ϕ for some µ

ϕ 1 entails ϕ 21 |= ϕ 2 ): ϕ 1 |= ϕ 2 iff µ |= ϕ 1 =⇒ µ |= ϕ 2 for every µ ϕ is valid (|= ϕ): |= ϕ iff µ |= ϕ for every µ

Property

ϕ is valid ⇐⇒ ¬ϕ is not satisfiable

(19)

Basic notation & definitions (cont)

a total truth assignment µ satisfies ϕ (µ |= ϕ):

µ |= A

i

⇐⇒ µ(A

i

) = >

µ |= ¬ϕ ⇐⇒ not µ |= ϕ

µ |= ϕ

1

∧ ϕ

2

⇐⇒ µ |= ϕ

1

and µ |= ϕ

2

µ |= ϕ

1

∨ ϕ

2

⇐⇒ µ |= ϕ

1

or µ |= ϕ

2

µ |= ϕ

1

→ ϕ

2

⇐⇒ if µ |= ϕ

1

, then µ |= ϕ

2

µ |= ϕ

1

↔ ϕ

2

⇐⇒ µ |= ϕ

1

iff µ |= ϕ

2

a partial truth assignment µ satisfies ϕ iff it makes ϕ evaluate to true (Ex: {A 1 } |= (A 1 ∨ A 2 ))

=⇒ if µ satisfies ϕ, then all its total extensions satisfy ϕ (Ex: {A

1

, A

2

} |= (A

1

∨ A

2

) and {A

1

, ¬A

2

} |= (A

1

∨ A

2

)) ϕ is satisfiable iff µ |= ϕ for some µ

ϕ 1 entails ϕ 21 |= ϕ 2 ): ϕ 1 |= ϕ 2 iff µ |= ϕ 1 =⇒ µ |= ϕ 2 for every µ ϕ is valid (|= ϕ): |= ϕ iff µ |= ϕ for every µ

Property

ϕ is valid ⇐⇒ ¬ϕ is not satisfiable

(20)

Basic notation & definitions (cont)

a total truth assignment µ satisfies ϕ (µ |= ϕ):

µ |= A

i

⇐⇒ µ(A

i

) = >

µ |= ¬ϕ ⇐⇒ not µ |= ϕ

µ |= ϕ

1

∧ ϕ

2

⇐⇒ µ |= ϕ

1

and µ |= ϕ

2

µ |= ϕ

1

∨ ϕ

2

⇐⇒ µ |= ϕ

1

or µ |= ϕ

2

µ |= ϕ

1

→ ϕ

2

⇐⇒ if µ |= ϕ

1

, then µ |= ϕ

2

µ |= ϕ

1

↔ ϕ

2

⇐⇒ µ |= ϕ

1

iff µ |= ϕ

2

a partial truth assignment µ satisfies ϕ iff it makes ϕ evaluate to true (Ex: {A 1 } |= (A 1 ∨ A 2 ))

=⇒ if µ satisfies ϕ, then all its total extensions satisfy ϕ (Ex: {A

1

, A

2

} |= (A

1

∨ A

2

) and {A

1

, ¬A

2

} |= (A

1

∨ A

2

)) ϕ is satisfiable iff µ |= ϕ for some µ

ϕ 1 entails ϕ 21 |= ϕ 2 ): ϕ 1 |= ϕ 2 iff µ |= ϕ 1 =⇒ µ |= ϕ 2 for every µ ϕ is valid (|= ϕ): |= ϕ iff µ |= ϕ for every µ

Property

ϕ is valid ⇐⇒ ¬ϕ is not satisfiable

(21)

Equivalence and equi-satisfiability

ϕ 1 and ϕ 2 are equivalent iff, for every µ, µ |= ϕ 1 iff µ |= ϕ 2

ϕ 1 and ϕ 2 are equi-satisfiable iff

exists µ 1 s.t. µ 1 |= ϕ 1 iff exists µ 2 s.t. µ 2 |= ϕ 2 ϕ 1 , ϕ 2 equivalent

⇓ 6⇑

ϕ 1 , ϕ 2 equi-satisfiable

EX: A 1 ∨ A 2 and (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 ) are equi-satisfiable, not equivalent.

{¬A 1 , A 2 , A 3 } |= (A 1 ∨ A 2 ), but

{¬A 1 , A 2 , A 3 } 6|= (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 )

Typically used when ϕ 2 is the result of applying some transformation T to ϕ 1 : ϕ 2

def

= T (ϕ 1 ):

we say that T is validity-preserving [satisfiability-preserving] iff

T (ϕ 1 ) and ϕ 1 are equivalent [equi-satisfiable]

(22)

Equivalence and equi-satisfiability

ϕ 1 and ϕ 2 are equivalent iff, for every µ, µ |= ϕ 1 iff µ |= ϕ 2

ϕ 1 and ϕ 2 are equi-satisfiable iff

exists µ 1 s.t. µ 1 |= ϕ 1 iff exists µ 2 s.t. µ 2 |= ϕ 2 ϕ 1 , ϕ 2 equivalent

⇓ 6⇑

ϕ 1 , ϕ 2 equi-satisfiable

EX: A 1 ∨ A 2 and (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 ) are equi-satisfiable, not equivalent.

{¬A 1 , A 2 , A 3 } |= (A 1 ∨ A 2 ), but

{¬A 1 , A 2 , A 3 } 6|= (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 )

Typically used when ϕ 2 is the result of applying some transformation T to ϕ 1 : ϕ 2

def

= T (ϕ 1 ):

we say that T is validity-preserving [satisfiability-preserving] iff

T (ϕ 1 ) and ϕ 1 are equivalent [equi-satisfiable]

(23)

Equivalence and equi-satisfiability

ϕ 1 and ϕ 2 are equivalent iff, for every µ, µ |= ϕ 1 iff µ |= ϕ 2

ϕ 1 and ϕ 2 are equi-satisfiable iff

exists µ 1 s.t. µ 1 |= ϕ 1 iff exists µ 2 s.t. µ 2 |= ϕ 2 ϕ 1 , ϕ 2 equivalent

⇓ 6⇑

ϕ 1 , ϕ 2 equi-satisfiable

EX: A 1 ∨ A 2 and (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 ) are equi-satisfiable, not equivalent.

{¬A 1 , A 2 , A 3 } |= (A 1 ∨ A 2 ), but

{¬A 1 , A 2 , A 3 } 6|= (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 )

Typically used when ϕ 2 is the result of applying some transformation T to ϕ 1 : ϕ 2

def

= T (ϕ 1 ):

we say that T is validity-preserving [satisfiability-preserving] iff

T (ϕ 1 ) and ϕ 1 are equivalent [equi-satisfiable]

(24)

Equivalence and equi-satisfiability

ϕ 1 and ϕ 2 are equivalent iff, for every µ, µ |= ϕ 1 iff µ |= ϕ 2

ϕ 1 and ϕ 2 are equi-satisfiable iff

exists µ 1 s.t. µ 1 |= ϕ 1 iff exists µ 2 s.t. µ 2 |= ϕ 2 ϕ 1 , ϕ 2 equivalent

⇓ 6⇑

ϕ 1 , ϕ 2 equi-satisfiable

EX: A 1 ∨ A 2 and (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 ) are equi-satisfiable, not equivalent.

{¬A 1 , A 2 , A 3 } |= (A 1 ∨ A 2 ), but

{¬A 1 , A 2 , A 3 } 6|= (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 )

Typically used when ϕ 2 is the result of applying some transformation T to ϕ 1 : ϕ 2

def

= T (ϕ 1 ):

we say that T is validity-preserving [satisfiability-preserving] iff

T (ϕ 1 ) and ϕ 1 are equivalent [equi-satisfiable]

(25)

Equivalence and equi-satisfiability

ϕ 1 and ϕ 2 are equivalent iff, for every µ, µ |= ϕ 1 iff µ |= ϕ 2

ϕ 1 and ϕ 2 are equi-satisfiable iff

exists µ 1 s.t. µ 1 |= ϕ 1 iff exists µ 2 s.t. µ 2 |= ϕ 2 ϕ 1 , ϕ 2 equivalent

⇓ 6⇑

ϕ 1 , ϕ 2 equi-satisfiable

EX: A 1 ∨ A 2 and (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 ) are equi-satisfiable, not equivalent.

{¬A 1 , A 2 , A 3 } |= (A 1 ∨ A 2 ), but

{¬A 1 , A 2 , A 3 } 6|= (A 1 ∨ ¬A 3 ) ∧ (A 3 ∨ A 2 )

Typically used when ϕ 2 is the result of applying some transformation T to ϕ 1 : ϕ 2

def

= T (ϕ 1 ):

we say that T is validity-preserving [satisfiability-preserving] iff

T (ϕ 1 ) and ϕ 1 are equivalent [equi-satisfiable]

(26)

Complexity

For N variables, there are up to 2 N truth assignments to be checked.

The problem of deciding the satisfiability of a propositional formula is NP-complete

The most important logical problems (validity, inference,

entailment, equivalence, ...) can be straightforwardly reduced to satisfiability, and are thus (co)NP-complete.

No existing worst-case-polynomial algorithm.

(27)

POLARITY of subformulas

Polarity: the number of nested negations modulo 2.

Positive/negative occurrences ϕ occurs positively in ϕ;

if ¬ϕ

1

occurs positively [negatively] in ϕ, then ϕ

1

occurs negatively [positively] in ϕ

if ϕ

1

∧ ϕ

2

or ϕ

1

∨ ϕ

2

occur positively [negatively] in ϕ, then ϕ

1

and ϕ

2

occur positively [negatively] in ϕ;

if ϕ

1

→ ϕ

2

occurs positively [negatively] in ϕ,

then ϕ

1

occurs negatively [positively] in ϕ and ϕ

2

occurs positively [negatively] in ϕ;

if ϕ

1

↔ ϕ

2

occurs in ϕ,

then ϕ

1

and ϕ

2

occur positively and negatively in ϕ;

(28)

Negative normal form (NNF)

ϕ is in Negative normal form iff it is given only by the recursive applications of ∧, ∨ to literals.

every ϕ can be reduced into NNF:

(i) substituting all →’s and ↔’s:

ϕ 1 → ϕ 2 =⇒ ¬ϕ 1 ∨ ϕ 2

ϕ 1 ↔ ϕ 2 =⇒ (¬ϕ 1 ∨ ϕ 2 ) ∧ (ϕ 1 ∨ ¬ϕ 2 ) (ii) pushing down negations recursively:

¬(ϕ 1 ∧ ϕ 2 ) =⇒ ¬ϕ 1 ∨ ¬ϕ 2

¬(ϕ 1 ∨ ϕ 2 ) =⇒ ¬ϕ 1 ∧ ¬ϕ 2

¬¬ϕ 1 =⇒ ϕ 1

The reduction is linear if a DAG representation is used.

Preserves the equivalence of formulas.

(29)

Basics on SAT

NNF: example

(A 1 ↔ A 2 ) ↔ (A 3 ↔ A 4 )

((((A 1 → A 2 ) ∧ (A 1 ← A 2 )) → ((A 3 → A 4 ) ∧ (A 3 ← A 4 )))∧ (((A 1 → A 2 ) ∧ (A 1 ← A 2 )) ← ((A 3 → A 4 ) ∧ (A 3 ← A 4 ))))

((¬((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 )))∧ (((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ¬((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 ))))

((((A 1 ∧ ¬A 2 ) ∨ (¬A 1 ∧ A 2 )) ∨ ((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 )))∧

(((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ((A 3 ∧ ¬A 4 ) ∨ (¬A 3 ∧ A 4 ))))

(30)

Basics on SAT

NNF: example

(A 1 ↔ A 2 ) ↔ (A 3 ↔ A 4 )

((((A 1 → A 2 ) ∧ (A 1 ← A 2 )) → ((A 3 → A 4 ) ∧ (A 3 ← A 4 )))∧

(((A 1 → A 2 ) ∧ (A 1 ← A 2 )) ← ((A 3 → A 4 ) ∧ (A 3 ← A 4 ))))

((¬((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 )))∧ (((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ¬((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 ))))

((((A 1 ∧ ¬A 2 ) ∨ (¬A 1 ∧ A 2 )) ∨ ((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 )))∧

(((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ((A 3 ∧ ¬A 4 ) ∨ (¬A 3 ∧ A 4 ))))

(31)

Basics on SAT

NNF: example

(A 1 ↔ A 2 ) ↔ (A 3 ↔ A 4 )

((((A 1 → A 2 ) ∧ (A 1 ← A 2 )) → ((A 3 → A 4 ) ∧ (A 3 ← A 4 )))∧

(((A 1 → A 2 ) ∧ (A 1 ← A 2 )) ← ((A 3 → A 4 ) ∧ (A 3 ← A 4 ))))

((¬((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 )))∧

(((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ¬((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 ))))

((((A 1 ∧ ¬A 2 ) ∨ (¬A 1 ∧ A 2 )) ∨ ((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 )))∧

(((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ((A 3 ∧ ¬A 4 ) ∨ (¬A 3 ∧ A 4 ))))

(32)

NNF: example

(A 1 ↔ A 2 ) ↔ (A 3 ↔ A 4 )

((((A 1 → A 2 ) ∧ (A 1 ← A 2 )) → ((A 3 → A 4 ) ∧ (A 3 ← A 4 )))∧

(((A 1 → A 2 ) ∧ (A 1 ← A 2 )) ← ((A 3 → A 4 ) ∧ (A 3 ← A 4 ))))

((¬((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 )))∧

(((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ¬((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 ))))

((((A 1 ∧ ¬A 2 ) ∨ (¬A 1 ∧ A 2 )) ∨ ((¬A 3 ∨ A 4 ) ∧ (A 3 ∨ ¬A 4 )))∧

(((¬A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 )) ∨ ((A 3 ∧ ¬A 4 ) ∨ (¬A 3 ∧ A 4 ))))

(33)

NNF: example (cont)

A1 −A2 −A1 A2 −A3 A4A3 −A4 −A1 A2 A1 −A2 A3 −A4−A3 A4

−B1 B2 B1 −B2

A1 −A2 −A1 A2 −A3 A4A3 −A4

−B1 B2 B1 −B2

Tree Representation

DAG Representation

Note

For each non-literal subformula ϕ, ϕ and ¬ϕ have different

representations =⇒ they are not shared.

(34)

NNF: example (cont)

A1 −A2 −A1 A2 −A3 A4A3 −A4 −A1 A2 A1 −A2 A3 −A4−A3 A4

−B1 B2 B1 −B2

A1 −A2 −A1 A2 −A3 A4A3 −A4

−B1 B2 B1 −B2

Tree Representation

DAG Representation

Note

For each non-literal subformula ϕ, ϕ and ¬ϕ have different

representations =⇒ they are not shared.

(35)

Optimized polynomial representations

And-Inverter Graphs, Reduced Boolean Circuits, Boolean Expression Diagrams

Maximize the sharing in DAG representations:

{∧, ↔, ¬}-only, negations on arcs, sorting of subformulae, lifting of

¬’s over ↔’s,...

(36)

Conjunctive Normal Form (CNF)

ϕ is in Conjunctive normal form iff it is a conjunction of disjunctions of literals:

L

^

i=1 K

i

_

j

i

=1

l j

i

the disjunctions of literals W K

i

j

i

=1 l j

i

are called clauses Easier to handle: list of lists of literals.

=⇒ no reasoning on the recursive structure of the formula

(37)

Classic CNF Conversion CNF (ϕ)

Every ϕ can be reduced into CNF by, e.g., (i) converting it into NNF (not indispensible);

(ii) applying recursively the DeMorgan’s Rule:

(ϕ 1 ∧ ϕ 2 ) ∨ ϕ 3 =⇒ (ϕ 1 ∨ ϕ 3 ) ∧ (ϕ 2 ∨ ϕ 3 ) Worst-case exponential.

Atoms(CNF (ϕ)) = Atoms(ϕ).

CNF (ϕ) is equivalent to ϕ.

Rarely used in practice.

(38)

Classic CNF Conversion CNF (ϕ)

Every ϕ can be reduced into CNF by, e.g., (i) converting it into NNF (not indispensible);

(ii) applying recursively the DeMorgan’s Rule:

(ϕ 1 ∧ ϕ 2 ) ∨ ϕ 3 =⇒ (ϕ 1 ∨ ϕ 3 ) ∧ (ϕ 2 ∨ ϕ 3 ) Worst-case exponential.

Atoms(CNF (ϕ)) = Atoms(ϕ).

CNF (ϕ) is equivalent to ϕ.

Rarely used in practice.

(39)

Classic CNF Conversion CNF (ϕ)

Every ϕ can be reduced into CNF by, e.g., (i) converting it into NNF (not indispensible);

(ii) applying recursively the DeMorgan’s Rule:

(ϕ 1 ∧ ϕ 2 ) ∨ ϕ 3 =⇒ (ϕ 1 ∨ ϕ 3 ) ∧ (ϕ 2 ∨ ϕ 3 ) Worst-case exponential.

Atoms(CNF (ϕ)) = Atoms(ϕ).

CNF (ϕ) is equivalent to ϕ.

Rarely used in practice.

(40)

Classic CNF Conversion CNF (ϕ)

Every ϕ can be reduced into CNF by, e.g., (i) converting it into NNF (not indispensible);

(ii) applying recursively the DeMorgan’s Rule:

(ϕ 1 ∧ ϕ 2 ) ∨ ϕ 3 =⇒ (ϕ 1 ∨ ϕ 3 ) ∧ (ϕ 2 ∨ ϕ 3 ) Worst-case exponential.

Atoms(CNF (ϕ)) = Atoms(ϕ).

CNF (ϕ) is equivalent to ϕ.

Rarely used in practice.

(41)

Labeling CNF conversion CNF label (ϕ)

Every ϕ can be reduced into CNF by, e.g., applying recursively bottom-up the rules:

ϕ =⇒ ϕ[(l i ∨ l j )|B] ∧ CNF (B ↔ (l i ∨ l j )) ϕ =⇒ ϕ[(l i ∧ l j )|B] ∧ CNF (B ↔ (l i ∧ l j )) ϕ =⇒ ϕ[(l i ↔ l j )|B] ∧ CNF (B ↔ (l i ↔ l j )) l i , l j being literals and B being a “new” variable.

Worst-case linear.

Atoms(CNF label (ϕ)) ⊇ Atoms(ϕ).

CNF label (ϕ) is equi-satisfiable w.r.t. ϕ.

More used in practice.

(42)

Labeling CNF conversion CNF label (ϕ)

Every ϕ can be reduced into CNF by, e.g., applying recursively bottom-up the rules:

ϕ =⇒ ϕ[(l i ∨ l j )|B] ∧ CNF (B ↔ (l i ∨ l j )) ϕ =⇒ ϕ[(l i ∧ l j )|B] ∧ CNF (B ↔ (l i ∧ l j )) ϕ =⇒ ϕ[(l i ↔ l j )|B] ∧ CNF (B ↔ (l i ↔ l j )) l i , l j being literals and B being a “new” variable.

Worst-case linear.

Atoms(CNF label (ϕ)) ⊇ Atoms(ϕ).

CNF label (ϕ) is equi-satisfiable w.r.t. ϕ.

More used in practice.

(43)

Labeling CNF conversion CNF label (ϕ) (cont.)

CNF (B ↔ (l i ∨ l j )) ⇐⇒ (¬B ∨ l i ∨ l j )∧

(B ∨ ¬l i )∧

(B ∨ ¬l j ) CNF (B ↔ (l i ∧ l j )) ⇐⇒ (¬B ∨ l i )∧

(¬B ∨ l j )∧

(B ∨ ¬l i ¬l j ) CNF (B ↔ (l i ↔ l j )) ⇐⇒ (¬B ∨ ¬l i ∨ l j )∧

(¬B ∨ l i ∨ ¬l j )∧

(B ∨ l i ∨ l j )∧

(B ∨ ¬l i ∨ ¬l j )

(44)

Labeling CNF conversion CNF label – example

−A3 A1 A5 −A4 −A3 A4 A2 −A6 A1 A4 A3 −A5 −A2 A6 A1 −A4

B1 B2 B3 B4 B5 B6 B7 B8

B9 B10 B11 B12

B13 B14

B15

CNF (B

1

↔ (¬A

3

∨ A

1

)) ∧

... ∧

CNF (B

8

↔ (A

1

∨ ¬A

4

)) ∧ CNF (B

9

↔ (B

1

↔ B

2

)) ∧

... ∧

CNF (B

12

↔ (B

7

∧ B

8

)) ∧

CNF (B

13

↔ (B

9

∨ B

10

)) ∧

CNF (B

14

↔ (B

11

∨ B

12

)) ∧

CNF (B

15

↔ (B

13

∧ B

14

)) ∧

B

15

(45)

Labeling CNF conversion CNF label (improved)

As in the previous case, applying instead the rules:

ϕ =⇒ ϕ[(l i ∨ l j )|B] ∧ CNF (B → (l i ∨ l j )) if (l i ∨ l j ) pos.

ϕ =⇒ ϕ[(l i ∨ l j )|B] ∧ CNF ((l i ∨ l j ) → B) if (l i ∨ l j ) neg.

ϕ =⇒ ϕ[(l i ∧ l j )|B] ∧ CNF (B → (l i ∧ l j )) if (l i ∧ l j ) pos.

ϕ =⇒ ϕ[(l i ∧ l j )|B] ∧ CNF ((l i ∧ l j ) → B) if (l i ∧ l j ) neg.

ϕ =⇒ ϕ[(l i ↔ l j )|B] ∧ CNF (B → (l i ↔ l j )) if (l i ↔ l j ) pos.

ϕ =⇒ ϕ[(l i ↔ l j )|B] ∧ CNF ((l i ↔ l j ) → B) if (l i ↔ l j ) neg.

Smaller in size:

CNF (B → (l i ∨ l j )) = (¬B ∨ l i ∨ l j )

CNF (((l i ∨ l j ) → B)) = (¬l i ∨ B) ∧ (¬l j ∨ B)

(46)

Labeling CNF conversion CNF label (improved)

As in the previous case, applying instead the rules:

ϕ =⇒ ϕ[(l i ∨ l j )|B] ∧ CNF (B → (l i ∨ l j )) if (l i ∨ l j ) pos.

ϕ =⇒ ϕ[(l i ∨ l j )|B] ∧ CNF ((l i ∨ l j ) → B) if (l i ∨ l j ) neg.

ϕ =⇒ ϕ[(l i ∧ l j )|B] ∧ CNF (B → (l i ∧ l j )) if (l i ∧ l j ) pos.

ϕ =⇒ ϕ[(l i ∧ l j )|B] ∧ CNF ((l i ∧ l j ) → B) if (l i ∧ l j ) neg.

ϕ =⇒ ϕ[(l i ↔ l j )|B] ∧ CNF (B → (l i ↔ l j )) if (l i ↔ l j ) pos.

ϕ =⇒ ϕ[(l i ↔ l j )|B] ∧ CNF ((l i ↔ l j ) → B) if (l i ↔ l j ) neg.

Smaller in size:

CNF (B → (l i ∨ l j )) = (¬B ∨ l i ∨ l j )

CNF (((l i ∨ l j ) → B)) = (¬l i ∨ B) ∧ (¬l j ∨ B)

(47)

Labeling CNF conversion CNF label (ϕ) (cont.)

CNF (B → (l i ∨ l j )) ⇐⇒ (¬B ∨ l i ∨ l j ) CNF (B ← (l i ∨ l j )) ⇐⇒ (B ∨ ¬l i )∧

(B ∨ ¬l j ) CNF (B → (l i ∧ l j )) ⇐⇒ (¬B ∨ l i )∧

(¬B ∨ l j ) CNF (B ← (l i ∧ l j )) ⇐⇒ (B ∨ ¬l i ¬l j ) CNF (B → (l i ↔ l j )) ⇐⇒ (¬B ∨ ¬l i ∨ l j )∧

(¬B ∨ l i ∨ ¬l j ) CNF (B ← (l i ↔ l j )) ⇐⇒ (B ∨ l i ∨ l j )∧

(B ∨ ¬l i ∨ ¬l j )

(48)

Labeling CNF conversion CNF label – example

−A3 A1 A5 −A4 −A3 A4 A2 −A6 A1 A4 A3 −A5 −A2 A6 A1 −A4

B1 B2 B3 B4 B5 B6 B7 B8

B9 B10 B11 B12

B13 B14

B15

Basic Improved

CNF (B

1

↔ (¬A

3

∨ A

1

)) ∧

... ∧

CNF (B

8

↔ (A

1

∨ ¬A

4

)) ∧ CNF (B

9

↔ (B

1

↔ B

2

)) ∧

... ∧

CNF (B

12

↔ (B

7

∧ B

8

)) ∧ CNF (B

13

↔ (B

9

∨ B

10

)) ∧ CNF (B

14

↔ (B

11

∨ B

12

)) ∧ CNF (B

15

↔ (B

13

∧ B

14

)) ∧ B

15

CNF (B

1

↔ (¬A

3

∨ A

1

)) ∧

... ∧

CNF (B

8

→ (A

1

∨ ¬A

4

)) ∧ CNF (B

9

→ (B

1

↔ B

2

)) ∧

... ∧

CNF (B

12

→ (B

7

∧ B

8

)) ∧

CNF (B

13

→ (B

9

∨ B

10

)) ∧

CNF (B

14

→ (B

11

∨ B

12

)) ∧

CNF (B

15

→ (B

13

∧ B

14

)) ∧

B

15

(49)

Labeling CNF conversion CNF label – further optimizations

Do not apply CNF label when not necessary:

(e.g., CNF label1 ∧ ϕ 2 ) =⇒ CNF label1 ) ∧ ϕ 2 , if ϕ 2 already in CNF)

Apply Demorgan’s rules where it is more effective: (e.g.,

CNF label1 ∧(A → (B ∧C))) =⇒ CNF label (ϕ 1 )∧(¬A∨B)∧(¬A∨C) exploit the associativity of ∧’s and ∨’s:

... (A 1 ∨ (A 2 ∨ A 3 ))

| {z }

B

... =⇒ ...CNF (B ↔ (A 1 ∨ A 2 ∨ A 3 ))...

before applying CNF label , rewrite the initial formula so that to maximize the sharing of subformulas (RBC, BED)

...

(50)

Outline

1 Basics on SAT

2 Basic SAT-Solving techniques

3 Modern CDCL SAT Solvers

Conflict-Driven Clause-Learning SAT solvers Further Improvements

4 Tractable subclasses of SAT

5 Random k-SAT and Phase Transition

6 Advanced Functionalities: proofs, unsat cores, interpolants, optimization

7 Some Applications

Appl. #1: (Bounded) Planning

Appl. #2: Bounded Model Checking

(51)

Truth Tables

Exhaustive evaluation of all subformulas:

ϕ 1 ϕ 2 ϕ 1 ∧ ϕ 2 ϕ 1 ∨ ϕ 2 ϕ 1 → ϕ 2 ϕ 1 ↔ ϕ 2

⊥ ⊥ ⊥ ⊥ > >

⊥ > ⊥ > > ⊥

> ⊥ ⊥ > ⊥ ⊥

> > > > > >

Requires polynomial space (draw one line at a time).

Requires analyzing 2 |Atoms(ϕ)| lines.

Never used in practice.

(52)

Resolution [49, 15]

Search for a refutation of ϕ

ϕ is represented as a set of clauses

Applies iteratively the resolution rule to pairs of clauses containing a conflicting literal, until a false clause is generated or the

resolution rule is no more applicable

Many different strategies

(53)

Resolution Rule

Resolution of a pair of clauses with exactly one incompatible variable:

(

common

z }| {

l

1

∨ ... ∨ l

k

resolvent

z}|{ l ∨

C0

z }| {

l

k +10

∨ ... ∨ l

m0

) (

common

z }| {

l

1

∨ ... ∨ l

k

resolvent

z}|{ ¬l ∨

C00

z }| {

l

k +100

∨ ... ∨ l

n00

) ( l

1

∨ ... ∨ l

k

| {z }

common

∨ l

k +10

∨ ... ∨ l

m0

| {z }

C0

∨ l

k +100

∨ ... ∨ l

n00

| {z }

C00

)

EXAMPLE:

( A ∨ B ∨ C ∨ D ∨ E ) ( A ∨ B ∨ ¬C ∨ F ) ( A ∨ B ∨ D ∨ E ∨ F )

NOTE: many standard inference rules subcases of resolution:

A → B B → C

A → C (Transit.) A A → B

B (M. Ponens) ¬B A → B

¬A (M. Tollens)

(54)

Resolution Rules [15, 14]: unit propagation

Unit resolution:

Γ 0 ∧ (l) ∧ (¬l ∨ W

i l i ) Γ 0 ∧ (l) ∧ ( W

i l i ) Unit subsumption:

Γ 0 ∧ (l) ∧ (l ∨ W

i l i ) Γ 0 ∧ (l)

Unit propagation = unit resolution + unit subsumption

“Deterministic” rule: applied before other “non-deterministic” rules!

(55)

Resolution: basic strategy [15]

function DP(Γ)

if ⊥ ∈ Γ /* unsat */

then return False;

if (Resolve() is no more applicable to Γ) /* sat */

then return True;

if {a unit clause (l) occurs in Γ} /* unit */

then Γ := Unit_Propagate(l, Γ));

return DP(Γ)

A := select-variable(Γ); /* resolve */

Γ = Γ ∪ S

A∈C

0

,¬A∈C

00

{Resolve(C 0 , C 00 )} \ S

A∈C

0

,¬A∈C

00

{C 0 , C 00 }};

return DP(Γ)

Hint: drops one variable A ∈ Atoms(Γ) at a time

(56)

Resolution: Examples

(A 1 ∨ A 2 ) (A 1 ∨ ¬A 2 ) (¬A 1 ∨ A 2 ) (¬A 1 ∨ ¬A 2 )

(A 2 ) (A 2 ∨ ¬A 2 ) (¬A 2 ∨ A 2 ) (¬A 2 )

=⇒ UNSAT

(57)

Resolution: Examples

(A 1 ∨ A 2 ) (A 1 ∨ ¬A 2 ) (¬A 1 ∨ A 2 ) (¬A 1 ∨ ¬A 2 )

(A 2 ) (A 2 ∨ ¬A 2 ) (¬A 2 ∨ A 2 ) (¬A 2 )

=⇒ UNSAT

(58)

Resolution: Examples

(A 1 ∨ A 2 ) (A 1 ∨ ¬A 2 ) (¬A 1 ∨ A 2 ) (¬A 1 ∨ ¬A 2 )

(A 2 ) (A 2 ∨ ¬A 2 ) (¬A 2 ∨ A 2 ) (¬A 2 )

=⇒ UNSAT

(59)

Resolution: Examples

(A 1 ∨ A 2 ) (A 1 ∨ ¬A 2 ) (¬A 1 ∨ A 2 ) (¬A 1 ∨ ¬A 2 )

(A 2 ) (A 2 ∨ ¬A 2 ) (¬A 2 ∨ A 2 ) (¬A 2 )

=⇒ UNSAT

(60)

Resolution: Examples (cont.)

(A ∨ B ∨ C) (B ∨ ¬C ∨ ¬F ) (¬B ∨ E)

(A ∨ C ∨ E) (¬C ∨ ¬F ∨ E)

⇓ (A ∨ E ∨ ¬F )

=⇒ SAT

(61)

Resolution: Examples (cont.)

(A ∨ B ∨ C) (B ∨ ¬C ∨ ¬F ) (¬B ∨ E)

(A ∨ C ∨ E) (¬C ∨ ¬F ∨ E)

⇓ (A ∨ E ∨ ¬F )

=⇒ SAT

(62)

Resolution: Examples (cont.)

(A ∨ B ∨ C) (B ∨ ¬C ∨ ¬F ) (¬B ∨ E)

(A ∨ C ∨ E) (¬C ∨ ¬F ∨ E)

⇓ (A ∨ E ∨ ¬F )

=⇒ SAT

(63)

Resolution: Examples (cont.)

(A ∨ B ∨ C) (B ∨ ¬C ∨ ¬F ) (¬B ∨ E)

(A ∨ C ∨ E) (¬C ∨ ¬F ∨ E)

⇓ (A ∨ E ∨ ¬F )

=⇒ SAT

(64)

Resolution: Examples

(A ∨ B) (A ∨ ¬B) (¬A ∨ C) (¬A ∨ ¬C)

(A) (¬A ∨ C) (¬A ∨ ¬C)

⇓ (C) (¬C)

=⇒ UNSAT

(65)

Resolution: Examples

(A ∨ B) (A ∨ ¬B) (¬A ∨ C) (¬A ∨ ¬C)

(A) (¬A ∨ C) (¬A ∨ ¬C)

⇓ (C) (¬C)

=⇒ UNSAT

(66)

Resolution: Examples

(A ∨ B) (A ∨ ¬B) (¬A ∨ C) (¬A ∨ ¬C)

(A) (¬A ∨ C) (¬A ∨ ¬C)

⇓ (C) (¬C)

=⇒ UNSAT

(67)

Resolution – summary

Requires CNF Γ may blow up

=⇒ May require exponential space

Not very much used in Boolean reasoning (unless integrated with

DPLL procedure in recent implementations)

(68)

Semantic tableaux [55]

Search for an assignment satisfying ϕ

applies recursively elimination rules to the connectives If a branch contains A i and ¬A i , (ψ i and ¬ψ i ) for some i, the branch is closed, otherwise it is open.

if no rule can be applied to an open branch µ, then µ |= ϕ;

if all branches are closed, the formula is not satisfiable;

(69)

Tableau elimination rules

ϕ 1 ∧ ϕ 2 ϕ 1

ϕ 2

¬(ϕ 1 ∨ ϕ 2 )

¬ϕ 1

¬ϕ 2

¬(ϕ 1 → ϕ 2 ) ϕ 1

¬ϕ 2 (∧-elimination)

¬¬ϕ

ϕ (¬¬-elimination)

ϕ 1 ∨ ϕ 2 ϕ 1 ϕ 2

¬(ϕ 1 ∧ ϕ 2 )

¬ϕ 1 ¬ϕ 2

ϕ 1 → ϕ 2

¬ϕ 1 ϕ 2 (∨-elimination) ϕ 1 ↔ ϕ 2

ϕ 1 ¬ϕ 1 ϕ 2 ¬ϕ 2

¬(ϕ 1 ↔ ϕ 2 ) ϕ 1 ¬ϕ 1

¬ϕ 2 ϕ 2 (↔ -elimination).

(70)

Semantic Tableaux – example

ϕ = (A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 ) ∧ (¬A 1 ∨ A 2 ) ∧ (¬A 1 ∨ ¬A 2 )

(71)

Semantic Tableaux – example

ϕ = (A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 ) ∧ (¬A 1 ∨ A 2 ) ∧ (¬A 1 ∨ ¬A 2 )

A1 A2

A1 −A2 A1 −A2

−A1 A2 −A1 A2 −A1 A2

−A1 −A2 −A1 −A2

(72)

Tableau algorithm

function Tableau(Γ)

if A i ∈ Γ and ¬A i ∈ Γ /* branch closed */

then return False;

if1 ∧ ϕ 2 ) ∈ Γ /* ∧-elimination */

then return Tableau(Γ ∪ {ϕ 1 , ϕ 2 }\{(ϕ 1 ∧ ϕ 2 )});

if (¬¬ϕ 1 ) ∈ Γ /* ¬¬-elimination */

then return Tableau(Γ ∪ {ϕ 1 }\{(¬¬ϕ 1 )});

if1 ∨ ϕ 2 ) ∈ Γ /* ∨-elimination */

then return Tableau(Γ ∪ {ϕ 1 }\{(ϕ 1 ∨ ϕ 2 )}) or Tableau(Γ ∪ {ϕ 2 }\{(ϕ 1 ∨ ϕ 2 )});

...

return True; /* branch expanded */

(73)

Semantic Tableaux – summary

Handles all propositional formulas (CNF not required).

Branches on disjunctions

Intuitive, modular, easy to extend

=⇒ loved by logicians.

Rather inefficient

=⇒ avoided by computer scientists.

Requires polynomial space

(74)

DPLL [15, 14]

Davis-Putnam-Longeman-Loveland procedure (DPLL) Tries to build an assignment µ satisfying ϕ;

At each step assigns a truth value to (all instances of) one atom.

Performs deterministic choices first.

(75)

DPLL rules

ϕ 1 ∧ (l)

ϕ 1 [l|>] (Unit) ϕ

ϕ[l|>] (l Pure) ϕ

ϕ[l|>] ϕ[l|⊥] (split) (l is a pure literal in ϕ iff it occurs only positively).

Split applied if and only if the others cannot be applied.

Richer formalisms described in [57, 44, 45]

(76)

DPLL – example

ϕ = (A 1 ∨ A 2 ) ∧ (A 1 ∨ ¬A 2 ) ∧ (¬A 1 ∨ A 2 ) ∧ (¬A 1 ∨ ¬A 2 )

A1 −A1

A2 A2

(77)

DPLL Algorithm

function DPLL(ϕ, µ)

if ϕ = > /* base */

then return True;

if ϕ = ⊥ /* backtrack */

then return False;

if {a unit clause (l) occurs in ϕ} /* unit */

then return DPLL(assign(l, ϕ), µ ∧ l);

if {a literal l occurs pure in ϕ} /* pure */

then return DPLL(assign(l, ϕ), µ ∧ l);

l := choose-literal(ϕ); /* split */

return DPLL(assign(l, ϕ), µ ∧ l) or

DPLL(assign(¬l, ϕ), µ ∧ ¬l);

(78)

DPLL – summary

Handles CNF formulas (non-CNF variant known [2, 25]).

Branches on truth values

=⇒ all instances of an atom assigned simultaneously Postpones branching as much as possible.

Mostly ignored by logicians.

(The grandfather of) the most efficient SAT algorithms

=⇒ loved by computer scientists.

Requires polynomial space Choose_literal() critical!

Many very efficient implementations [61, 54, 4, 43].

(79)

Ordered Binary Decision Diagrams (OBDDs) [12]]

Canonical representation of Boolean formulas

“If-then-else” binary direct acyclic graphs (DAGs) with one root and two leaves: 1, 0 (or >,⊥; or T, F)

Variable ordering A 1 , A 2 , ..., A n imposed a priori.

Paths leading to 1 represent models

Paths leading to 0 represent counter-models Note

Some authors call them Reduced Ordered Binary Decision Diagrams

(ROBDDs)

(80)

Ordered Binary Decision Diagrams (OBDDs) [12]]

Canonical representation of Boolean formulas

“If-then-else” binary direct acyclic graphs (DAGs) with one root and two leaves: 1, 0 (or >,⊥; or T, F)

Variable ordering A 1 , A 2 , ..., A n imposed a priori.

Paths leading to 1 represent models

Paths leading to 0 represent counter-models Note

Some authors call them Reduced Ordered Binary Decision Diagrams

(ROBDDs)

(81)

OBDD - Examples

F T

b3 a3

b3 b2 a2

b2

b1 b1

a1 a1

a2

a3 a3 a3

a2

a3

b1 b1 b1 b1 b1 b1

b2 b2 b2 b2

b3 b3

b1 b1

T F

OBDDs of (a 1 ↔ b 1 ) ∧ (a 2 ↔ b 2 ) ∧ (a 3 ↔ b 3 ) with different variable

orderings

(82)

Ordered Decision Trees

Ordered Decision Tree: from root to leaves, variables are encountered always in the same order

Example: Ordered Decision tree for ϕ = (a ∧ b) ∨ (c ∧ d ) a

b

c c

d d d d d d d

c

d b

c

0 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1

(83)

From Ordered Decision Trees to OBDD’s: reductions

Recursive applications of the following reductions:

share subnodes: point to the same occurrence of a subtree (via hash consing)

remove redundancies: nodes with same left and right children can

be eliminated (“if A then B else B” =⇒ “B”)

(84)

From Ordered Decision Trees to OBDD’s: reductions

Recursive applications of the following reductions:

share subnodes: point to the same occurrence of a subtree (via hash consing)

remove redundancies: nodes with same left and right children can

be eliminated (“if A then B else B” =⇒ “B”)

(85)

From Ordered Decision Trees to OBDD’s: reductions

Recursive applications of the following reductions:

share subnodes: point to the same occurrence of a subtree (via hash consing)

remove redundancies: nodes with same left and right children can

be eliminated (“if A then B else B” =⇒ “B”)

(86)

Reduction: example

a b

c c

d d d d d d d

c

d b

c

0 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1

(87)

Reduction: example

Detect redundacies: a b

c c

d d d d d d d

c

d b

c

0 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1

(88)

Reduction: example

Remove redundacies: a b

c c

d d d

c b

c

0 1 0 1 0 1

0 0 0 1 1

(89)

Reduction: example

Remove redundacies: a b

c c

d d d

b c

0 1 0 1 0 1

0 0 0

1

(90)

Reduction: example

Share identical nodes: a b

c c

d d d

b c

0 1 0 1 0 1

0 0 0

1

(91)

Reduction: example

Share identical nodes: a b

c

d

b

0

1

(92)

Reduction: example

Detect redundancies: a b

c

d

b

0

1

(93)

Reduction: example Remove redundancies:

Final OBDD!

a

c

d

b

0

1

(94)

Recursive structure of an OBDD

Assume the variable ordering A 1 , A 2 , ..., A n : OBDD(>, {A 1 , A 2 , ..., A n }) = 1

OBDD(⊥, {A 1 , A 2 , ..., A n }) = 0 OBDD(ϕ, {A 1 , A 2 , ..., A n }) = if A 1

then OBDD(ϕ[A 1 |>], {A 2 , ..., A n })

else OBDD(ϕ[A 1 |⊥], {A 2 , ..., A n })

(95)

Incrementally building an OBDD

obdd _build (>, {...}) := 1, obdd _build (⊥, {...}) := 0,

obdd _build (A i , {...}) := ite(A i , 1, 0), obdd _build ((¬ϕ), {A 1 , ..., A n }) :=

apply (¬, obdd _build (ϕ, {A 1 , ..., A n })) obdd _build ((ϕ 1 op ϕ 2 ), {A 1 , ..., A n }) :=

reduce(

apply ( op,

obdd _build (ϕ 1 , {A 1 , ..., A n }), obdd _build (ϕ 2 , {A 1 , ..., A n }) ) )

op ∈ {∧, ∨, →, ↔}

“ite(A i , ϕ > i , ϕ i )” is “If A i Then ϕ > i Else ϕ i

(96)

Incrementally building an OBDD

obdd _build (>, {...}) := 1, obdd _build (⊥, {...}) := 0,

obdd _build (A i , {...}) := ite(A i , 1, 0), obdd _build ((¬ϕ), {A 1 , ..., A n }) :=

apply (¬, obdd _build (ϕ, {A 1 , ..., A n })) obdd _build ((ϕ 1 op ϕ 2 ), {A 1 , ..., A n }) :=

reduce(

apply ( op,

obdd _build (ϕ 1 , {A 1 , ..., A n }), obdd _build (ϕ 2 , {A 1 , ..., A n }) ) )

op ∈ {∧, ∨, →, ↔}

“ite(A i , ϕ > i , ϕ i )” is “If A i Then ϕ > i Else ϕ i

Riferimenti

Documenti correlati

In Tools and Algorithms for the Construction and Analysis of Systems - 21st International Conference, TACAS 2015, Held as Part of the European Joint Conferences on Theory and

combine SAT solvers with decision procedures (theory solvers) contributions from SAT, Automated Theorem Proving (ATP), formal verification (FV) and operational research (OR)... SMT

The course will concentrate mainly on formal validation and verification and, in particular, on Model Checking (MC). A laboratory will be given in which the students will experience

limited sensitivity: one good setting, does not require expert users much higher capacity (more variables) than BDD based techniques Various techniques: Bounded Model

all but one literals in η are as “old” as possible Learning: in future branches, when all-but-one literals in η are assigned, the remaining literal is assigned to false

(a) List the sequence of unit-propagations following after the last decision, each literal tagged (in square brackets) by its antecedent clause?. (b) Derive the conflict clause

Let LRA be the logic of linear arithmetic over the rationals and EUF be the logic of equality and uninterpreted functions9. (4) Thus, with either technique, we can conclude that φ

For the reduction from the parity game problem to SAT what we want is a formula of propositional logic that is satisfiable iff the existential player has a winning strategy in