SAT Solvers: Theory and Practice Clark Barrett barrett@cs.nyu.edu - - PowerPoint PPT Presentation

sat solvers theory and practice
SMART_READER_LITE
LIVE PREVIEW

SAT Solvers: Theory and Practice Clark Barrett barrett@cs.nyu.edu - - PowerPoint PPT Presentation

SAT Solvers: Theory and Practice Clark Barrett barrett@cs.nyu.edu New York University Summer School on Verification Technology, Systems & Applications, September 17, 2008 p. 1/98 Formal Verification [Formal] software verification


slide-1
SLIDE 1

SAT Solvers: Theory and Practice

Clark Barrett

barrett@cs.nyu.edu

New York University

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 1/98

slide-2
SLIDE 2

Formal Verification

  • “[Formal] software verification . . . has been the Holy Grail
  • f computer science for many decades”
  • Bill Gates [Gat02]
  • Formal verification techniques can, in theory, prove

beyond a doubt that a system is implemented correctly.

  • In practice, there are still many challenges, but there are

also success stories, and the technology is getting better.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 2/98

slide-3
SLIDE 3

Steps of Formal Verification

  • 1. Modeling: Create a mathematical model of the system
  • A modeling error can introduce false bugs or mask

real bugs

  • For many systems, this step can be done automatically
  • 2. Specification: The properties which the system should

satisfy must be stated in a formal language

  • Challenge to translate informal specifications into

formal ones

  • Many languages: UML, CTL, PSL, Spec#, etc.
  • 3. Proof: Prove that the model satisfies the specification
  • Better than testing: covers all cases
  • ...when it succeeds: this is the hard part

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 3/98

slide-4
SLIDE 4

Automatic Theorem Provers

Many real-world verification efforts require human expertise to complete the proofs If a computer can do the proof automatically, this greatly improves the feasibility of formal verification Automatic theorem provers have improved significantly in recent years, enabling formal verification of larger and more complex systems In these lectures, we will look at two techniques for automated theorem proving: SAT solvers and SMT solvers.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 4/98

slide-5
SLIDE 5

Circuit Example

  • =

+1 +2

1 1 1

test

x y z a a a

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 5/98

slide-6
SLIDE 6

Circuit Example

In this example, the value of test is always supposed to be

True.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 6/98

slide-7
SLIDE 7

Circuit Example

In this example, the value of test is always supposed to be

True.

Under what conditions does this hold?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 6/98

slide-8
SLIDE 8

Circuit Example

In this example, the value of test is always supposed to be

True.

Under what conditions does this hold? How do we prove it?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 6/98

slide-9
SLIDE 9

Circuit Example

In this example, the value of test is always supposed to be

True.

Under what conditions does this hold? How do we prove it? We will come back to this question.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 6/98

slide-10
SLIDE 10

Roadmap

Boolean Satisfiability

  • Propositional Logic
  • Solving SAT
  • Modeling for SAT

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 7/98

slide-11
SLIDE 11

The Language of SAT solvers: Propositional Logic

A SAT solver solves the Boolean satisfiabiliy problem. In order to understand the satisfiability problem, we must first define the language in which the problem is phrased. The language is propositional logic [End00].

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 8/98

slide-12
SLIDE 12

What is Logic?

A formal logic is defined by its syntax and semantics.

Syntax

  • An alphabet is a set of symbols.
  • A finite sequence of these symbols is called an

expression.

  • A set of rules defines the well-formed expressions.

Semantics

  • Gives meaning to well-formed expressions
  • Formal notions of induction and recursion are required to

provide a rigorous semantics.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 9/98

slide-13
SLIDE 13

Propositional Logic: Syntax

Alphabet

( Left parenthesis Begin group ) Right parenthesis End group ¬ Negation symbol English: not ∧ Conjunction symbol English: and ∨ Disjunction symbol English: or (inclusive) → Conditional symbol English: if, then ↔ Bi-conditional symbol English: if and only if A1 First propositional symbol A2 Second propositional symbol . . . An nth propositional symbol . . .

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 10/98

slide-14
SLIDE 14

Propositional Logic: Syntax

Alphabet

  • Propositional connective symbols: ¬, ∧, ∨, →, ↔.
  • Logical symbols: ¬, ∧, ∨, →, ↔, (, ).
  • Parameters or nonlogical symbols: A1, A2, A3, . . .

The meaning of logical symbols is always the same. The meaning of nonlogical symbols depends on the context.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 11/98

slide-15
SLIDE 15

Propositional Logic: Syntax

An expression is a sequence of symbols. A sequence is denoted explicitly by a comma separated list enclosed in angle brackets: <a1, . . . ,am>.

Examples

<(, A1, ∧, A3, )> <(, (, ¬, A1, ), →, A2, )> <), ), ↔, ), A5>

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 12/98

slide-16
SLIDE 16

Propositional Logic: Syntax

An expression is a sequence of symbols. A sequence is denoted explicitly by a comma separated list enclosed in angle brackets: <a1, . . . ,am>.

Examples

<(, A1, ∧, A3, )> (A1 ∧ A3) <(, (, ¬, A1, ), →, A2, )> ((¬A1) → A2) <), ), ↔, ), A5> )) ↔)A5 For convenience, we will write sequences as a simple string

  • f symbols.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 12/98

slide-17
SLIDE 17

Propositional Logic: Syntax

An expression is a sequence of symbols. A sequence is denoted explicitly by a comma separated list enclosed in angle brackets: <a1, . . . ,am>.

Examples

<(, A1, ∧, A3, )> (A1 ∧ A3) <(, (, ¬, A1, ), →, A2, )> ((¬A1) → A2) <), ), ↔, ), A5> )) ↔)A5 For convenience, we will write sequences as a simple string

  • f symbols.

Not all expressions make sense. Part of the job of defining a syntax is to restrict the kinds of expressions that will be allowed.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 12/98

slide-18
SLIDE 18

Propositional Logic: Well-Formed Formulas

We use a formal inductive definition to define the set W of well-formed formulas (wffs) in propositional logic.

  • U =
  • B =
  • F =

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 13/98

slide-19
SLIDE 19

Propositional Logic: Well-Formed Formulas

We use a formal inductive definition to define the set W of well-formed formulas (wffs) in propositional logic.

  • U = the set of all expressions.
  • B =
  • F =

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 13/98

slide-20
SLIDE 20

Propositional Logic: Well-Formed Formulas

We use a formal inductive definition to define the set W of well-formed formulas (wffs) in propositional logic.

  • U = the set of all expressions.
  • B = the set of expressions consisting of a single

propositional symbol.

  • F =

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 13/98

slide-21
SLIDE 21

Propositional Logic: Well-Formed Formulas

We use a formal inductive definition to define the set W of well-formed formulas (wffs) in propositional logic.

  • U = the set of all expressions.
  • B = the set of expressions consisting of a single

propositional symbol.

  • F = the set of formula-building operations:
  • E¬(α) = (¬α)
  • E∧(α, β) = (α ∧ β)
  • E∨(α, β) = (α ∨ β)
  • E→(α, β) = (α → β)
  • E↔(α, β) = (α ↔ β)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 13/98

slide-22
SLIDE 22

Propositional Logic: Well-Formed Formulas

We use a formal inductive definition to define the set W of well-formed formulas (wffs) in propositional logic.

  • U = the set of all expressions.
  • B = the set of expressions consisting of a single

propositional symbol.

  • F = the set of formula-building operations:
  • E¬(α) = (¬α)
  • E∧(α, β) = (α ∧ β)
  • E∨(α, β) = (α ∨ β)
  • E→(α, β) = (α → β)
  • E↔(α, β) = (α ↔ β)

W is the set generated from F by B.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 13/98

slide-23
SLIDE 23

Propositional Logic: Well-Formed Formulas

We use a formal inductive definition to define the set W of well-formed formulas (wffs) in propositional logic.

  • U = the set of all expressions.
  • B = the set of expressions consisting of a single

propositional symbol.

  • F = the set of formula-building operations:
  • E¬(α) = (¬α)
  • E∧(α, β) = (α ∧ β)
  • E∨(α, β) = (α ∨ β)
  • E→(α, β) = (α → β)
  • E↔(α, β) = (α ↔ β)

In fact, W is freely generated, meaning there is only one way to generate each member of the set.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 13/98

slide-24
SLIDE 24

Propositional Logic: Semantics

Intuitively, given a wff α and a value (either T or F) for each propositional symbol in α, we should be able to determine the value of α.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 14/98

slide-25
SLIDE 25

Propositional Logic: Semantics

Intuitively, given a wff α and a value (either T or F) for each propositional symbol in α, we should be able to determine the value of α. How do we make this precise?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 14/98

slide-26
SLIDE 26

Propositional Logic: Semantics

Intuitively, given a wff α and a value (either T or F) for each propositional symbol in α, we should be able to determine the value of α. How do we make this precise? Let v be a function from B to {F, T}. We call this function a truth assignment.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 14/98

slide-27
SLIDE 27

Propositional Logic: Semantics

Now, we define v, a function from W to {F, T} as follows (we compute with F and T as if they were 0 and 1 respectively).

  • For each propositional symbol Ai, v(Ai) = v(Ai).
  • v(E¬(α)) = T − v(α)
  • v(E∧(α, β)) = min(v(α), v(β))
  • v(E∨(α, β)) = max(v(α), v(β))
  • v(E→(α, β)) = max(T − v(α), v(β))
  • v(E↔(α, β)) = T − |v(α) − v(β)|

The fact that W is freely generated ensures that v is well-defined.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 15/98

slide-28
SLIDE 28

Truth Tables

There are other ways to present the semantics which are less formal but perhaps more intuitive. α ¬α T F α β α ∧ β T T T F F T F F α β α ∨ β T T T F F T F F α β α → β T T T F F T F F α β α ↔ β T T T F F T F F

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 16/98

slide-29
SLIDE 29

Truth Tables

There are other ways to present the semantics which are less formal but perhaps more intuitive. α ¬α T F F T α β α ∧ β T T T F F T F F α β α ∨ β T T T F F T F F α β α → β T T T F F T F F α β α ↔ β T T T F F T F F

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 16/98

slide-30
SLIDE 30

Truth Tables

There are other ways to present the semantics which are less formal but perhaps more intuitive. α ¬α T F F T α β α ∧ β T T T T F F F T F F F F α β α ∨ β T T T F F T F F α β α → β T T T F F T F F α β α ↔ β T T T F F T F F

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 16/98

slide-31
SLIDE 31

Truth Tables

There are other ways to present the semantics which are less formal but perhaps more intuitive. α ¬α T F F T α β α ∧ β T T T T F F F T F F F F α β α ∨ β T T T T F T F T T F F F α β α → β T T T T F F F T T F F T α β α ↔ β T T T T F F F T F F F T

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 16/98

slide-32
SLIDE 32

Complex truth tables

Truth tables can also be used to calculate all possible values

  • f v for a given wff: We associate a column with each

propositional symbol and a column with each propositional

  • connective. There is a row for each possible truth assignment

to the propositional connectives. A1 A2 A3 (A1 ∨ (A2 ∧ ¬A3)) T T T T T T T F T T T F T T F T F F T F F T T F T F T F F T F F T F F F F F F F

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 17/98

slide-33
SLIDE 33

Complex truth tables

Truth tables can also be used to calculate all possible values

  • f v for a given wff: We associate a column with each

propositional symbol and a column with each propositional

  • connective. There is a row for each possible truth assignment

to the propositional connectives. A1 A2 A3 (A1 ∨ (A2 ∧ ¬A3)) T T T T T F T T F T T T T F T T F F T F F T F T F T T F T F F T F F T T F F T F F F F F F F F T

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 17/98

slide-34
SLIDE 34

Complex truth tables

Truth tables can also be used to calculate all possible values

  • f v for a given wff: We associate a column with each

propositional symbol and a column with each propositional

  • connective. There is a row for each possible truth assignment

to the propositional connectives. A1 A2 A3 (A1 ∨ (A2 ∧ ¬A3)) T T T T T F F T T F T T T T T F T T F F F T F F T F F T F T T F T F F F T F F T T T F F T F F F F F F F F F F T

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 17/98

slide-35
SLIDE 35

Complex truth tables

Truth tables can also be used to calculate all possible values

  • f v for a given wff: We associate a column with each

propositional symbol and a column with each propositional

  • connective. There is a row for each possible truth assignment

to the propositional connectives. A1 A2 A3 (A1 ∨ (A2 ∧ ¬A3)) T T T T T T F F T T F T T T T T T F T T T F F F T F F T T F F T F T T F F T F F F T F F T T T T F F T F F F F F F F F F F F F T

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 17/98

slide-36
SLIDE 36

Definitions

If α is a wff, then a truth assignment v satisfies α if v(α) = T.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 18/98

slide-37
SLIDE 37

Definitions

If α is a wff, then a truth assignment v satisfies α if v(α) = T. A wff α is satisfiable if there exists some truth assignment v which satisfies α.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 18/98

slide-38
SLIDE 38

Definitions

If α is a wff, then a truth assignment v satisfies α if v(α) = T. A wff α is satisfiable if there exists some truth assignment v which satisfies α. Suppose Σ is a set of wffs. Then Σ tautologically implies α, Σ | = α, if every truth assignment which satisfies each formula in Σ also satisfies α.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 18/98

slide-39
SLIDE 39

Definitions

If α is a wff, then a truth assignment v satisfies α if v(α) = T. A wff α is satisfiable if there exists some truth assignment v which satisfies α. Suppose Σ is a set of wffs. Then Σ tautologically implies α, Σ | = α, if every truth assignment which satisfies each formula in Σ also satisfies α.

  • If ∅ |

= α, then we say α is a tautology or α is valid and write | = α.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 18/98

slide-40
SLIDE 40

Definitions

If α is a wff, then a truth assignment v satisfies α if v(α) = T. A wff α is satisfiable if there exists some truth assignment v which satisfies α. Suppose Σ is a set of wffs. Then Σ tautologically implies α, Σ | = α, if every truth assignment which satisfies each formula in Σ also satisfies α.

  • If ∅ |

= α, then we say α is a tautology or α is valid and write | = α.

  • If Σ is unsatisfiable, then Σ |

= α for every wff α.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 18/98

slide-41
SLIDE 41

Definitions

If α is a wff, then a truth assignment v satisfies α if v(α) = T. A wff α is satisfiable if there exists some truth assignment v which satisfies α. Suppose Σ is a set of wffs. Then Σ tautologically implies α, Σ | = α, if every truth assignment which satisfies each formula in Σ also satisfies α.

  • If ∅ |

= α, then we say α is a tautology or α is valid and write | = α.

  • If Σ is unsatisfiable, then Σ |

= α for every wff α.

  • If α |

= β (shorthand for {α} | = β) and β | = α, then α and β are tautologically equivalent.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 18/98

slide-42
SLIDE 42

Definitions

If α is a wff, then a truth assignment v satisfies α if v(α) = T. A wff α is satisfiable if there exists some truth assignment v which satisfies α. Suppose Σ is a set of wffs. Then Σ tautologically implies α, Σ | = α, if every truth assignment which satisfies each formula in Σ also satisfies α.

  • If ∅ |

= α, then we say α is a tautology or α is valid and write | = α.

  • If Σ is unsatisfiable, then Σ |

= α for every wff α.

  • If α |

= β (shorthand for {α} | = β) and β | = α, then α and β are tautologically equivalent.

  • Σ |

= α if and only if (Σ) → α is valid.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 18/98

slide-43
SLIDE 43

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-44
SLIDE 44

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B) is satisfiable, but not valid.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-45
SLIDE 45

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B) is satisfiable, but not valid.
  • (A ∨ B) ∧ (¬A ∨ ¬B) ∧ (A ↔ B)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-46
SLIDE 46

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B) is satisfiable, but not valid.
  • (A ∨ B) ∧ (¬A ∨ ¬B) ∧ (A ↔ B) is unsatisfiable.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-47
SLIDE 47

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B) is satisfiable, but not valid.
  • (A ∨ B) ∧ (¬A ∨ ¬B) ∧ (A ↔ B) is unsatisfiable.
  • {A, A → B} |

= B

  • {A, ¬A} |

= (A ∧ ¬A)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-48
SLIDE 48

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B) is satisfiable, but not valid.
  • (A ∨ B) ∧ (¬A ∨ ¬B) ∧ (A ↔ B) is unsatisfiable.
  • {A, A → B} |

= B

  • {A, ¬A} |

= (A ∧ ¬A)

  • ¬(A ∧ B) is tautologically equivalent to ¬A ∨ ¬B

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-49
SLIDE 49

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B) is satisfiable, but not valid.
  • (A ∨ B) ∧ (¬A ∨ ¬B) ∧ (A ↔ B) is unsatisfiable.
  • {A, A → B} |

= B

  • {A, ¬A} |

= (A ∧ ¬A)

  • ¬(A ∧ B) is tautologically equivalent to ¬A ∨ ¬B

Suppose you had an algorithm SAT which would take a wff α as input and return True if α is satisfiable and False otherwise. How would you use this algorithm to verify each of the claims made above?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-50
SLIDE 50

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B) is satisfiable, but not valid.
  • (A ∨ B) ∧ (¬A ∨ ¬B) ∧ (A ↔ B) is unsatisfiable.
  • {A, A → B} |

= B (A ∧ (A → B) ∧ (¬B))

  • {A, ¬A} |

= (A ∧ ¬A)

  • ¬(A ∧ B) is tautologically equivalent to ¬A ∨ ¬B

Suppose you had an algorithm SAT which would take a wff α as input and return True if α is satisfiable and False otherwise. How would you use this algorithm to verify each of the claims made above?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-51
SLIDE 51

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B) is satisfiable, but not valid.
  • (A ∨ B) ∧ (¬A ∨ ¬B) ∧ (A ↔ B) is unsatisfiable.
  • {A, A → B} |

= B (A ∧ (A → B) ∧ (¬B))

  • {A, ¬A} |

= (A ∧ ¬A) (A ∧ (¬A) ∧ ¬(A ∧ ¬A))

  • ¬(A ∧ B) is tautologically equivalent to ¬A ∨ ¬B

Suppose you had an algorithm SAT which would take a wff α as input and return True if α is satisfiable and False otherwise. How would you use this algorithm to verify each of the claims made above?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-52
SLIDE 52

Examples

  • (A ∨ B) ∧ (¬A ∨ ¬B) is satisfiable, but not valid.
  • (A ∨ B) ∧ (¬A ∨ ¬B) ∧ (A ↔ B) is unsatisfiable.
  • {A, A → B} |

= B (A ∧ (A → B) ∧ (¬B))

  • {A, ¬A} |

= (A ∧ ¬A) (A ∧ (¬A) ∧ ¬(A ∧ ¬A))

  • ¬(A ∧ B) is tautologically equivalent to ¬A ∨ ¬B

¬(¬(A ∧ B) ↔ (¬A ∨ ¬B)) Suppose you had an algorithm SAT which would take a wff α as input and return True if α is satisfiable and False otherwise. How would you use this algorithm to verify each of the claims made above?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 19/98

slide-53
SLIDE 53

Some tautologies

Associative and Commutative laws for ∧, ∨, ↔ Distributive Laws

  • (A ∧ (B ∨ C)) ↔ ((A ∧ B) ∨ (A ∧ C)).
  • (A ∨ (B ∧ C)) ↔ ((A ∨ B) ∧ (A ∨ C)).

De Morgan’s Laws

  • ¬(A ∧ B) ↔ (¬A ∨ ¬B)
  • ¬(A ∨ B) ↔ (¬A ∧ ¬B)

Implication

  • (A → B) ↔ (¬A ∨ B)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 20/98

slide-54
SLIDE 54

Determining Satisfiability using Truth Tables

An Algorithm for Satisfiability

To check whether α is satisfiable, form the truth table for α. If there is a row in which T appears as the value for α, then α is

  • satisfiable. Otherwise, α is unsatisfiable.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 21/98

slide-55
SLIDE 55

Determining Satisfiability using Truth Tables

An Algorithm for Satisfiability

To check whether α is satisfiable, form the truth table for α. If there is a row in which T appears as the value for α, then α is

  • satisfiable. Otherwise, α is unsatisfiable.

An Algorithm for Tautological Implication

To check whether {α1, . . . , αk} | = β, check the satisfiability of (α1 ∧ · · · ∧ αk) ∧ (¬β). If it is unsatisfiable, then {α1, . . . , αk} | = β, otherwise {α1, . . . , αk} | = β.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 21/98

slide-56
SLIDE 56

Determining Satisfiability using Truth Tables

Example

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

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-57
SLIDE 57

Determining Satisfiability using Truth Tables

Example

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

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-58
SLIDE 58

Determining Satisfiability using Truth Tables

Example

A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) A B C A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) F F F F T T T T T

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-59
SLIDE 59

Determining Satisfiability using Truth Tables

Example

A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) A B C A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) F F F F T T T T T F F T F T T T T T

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-60
SLIDE 60

Determining Satisfiability using Truth Tables

Example

A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) A B C A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) F F F F T T T T T F F T F T T T T T F T F F T T F F F

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-61
SLIDE 61

Determining Satisfiability using Truth Tables

Example

A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) A B C A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) F F F F T T T T T F F T F T T T T T F T F F T T F F F F T T F T T T T F

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-62
SLIDE 62

Determining Satisfiability using Truth Tables

Example

A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) A B C A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) F F F F T T T T T F F T F T T T T T F T F F T T F F F F T T F T T T T F T F F F F F F T T

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-63
SLIDE 63

Determining Satisfiability using Truth Tables

Example

A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) A B C A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) F F F F T T T T T F F T F T T T T T F T F F T T F F F F T T F T T T T F T F F F F F F T T T F T F F F F T T

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-64
SLIDE 64

Determining Satisfiability using Truth Tables

Example

A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) A B C A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) F F F F T T T T T F F T F T T T T T F T F F T T F F F F T T F T T T T F T F F F F F F T T T F T F F F F T T T T F F T F F F F

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-65
SLIDE 65

Determining Satisfiability using Truth Tables

Example

A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) A B C A ∧ ((B ∨ ¬A) ∧ (C ∨ ¬B)) F F F F T T T T T F F T F T T T T T F T F F T T F F F F T T F T T T T F T F F F F F F T T T F T F F F F T T T T F F T F F F F T T T T T F T T F

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 22/98

slide-66
SLIDE 66

Determining Satisfiability using Truth Tables

What is the complexity of this algorithm?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 23/98

slide-67
SLIDE 67

Determining Satisfiability using Truth Tables

What is the complexity of this algorithm? 2n where n is the number of propositional symbols.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 23/98

slide-68
SLIDE 68

Determining Satisfiability using Truth Tables

What is the complexity of this algorithm? 2n where n is the number of propositional symbols. Can we do better?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 23/98

slide-69
SLIDE 69

Determining Satisfiability using Truth Tables

What is the complexity of this algorithm? 2n where n is the number of propositional symbols. Can we do better? SAT was the first problem shown to be NP-complete [Coo71]: all of the problems in the class NP can be solved by translating them (in polynomial time) into SAT.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 23/98

slide-70
SLIDE 70

Determining Satisfiability using Truth Tables

What is the complexity of this algorithm? 2n where n is the number of propositional symbols. Can we do better? SAT was the first problem shown to be NP-complete [Coo71]: all of the problems in the class NP can be solved by translating them (in polynomial time) into SAT. So, if we could somehow build a fast solver for SAT, it could be used to solve lots of other problems.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 23/98

slide-71
SLIDE 71

Determining Satisfiability using Truth Tables

What is the complexity of this algorithm? 2n where n is the number of propositional symbols. Can we do better? SAT was the first problem shown to be NP-complete [Coo71]: all of the problems in the class NP can be solved by translating them (in polynomial time) into SAT. So, if we could somehow build a fast solver for SAT, it could be used to solve lots of other problems. In theory, this seems dubious, as problems in NP are known to take exponential time in the worst case.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 23/98

slide-72
SLIDE 72

Determining Satisfiability using Truth Tables

What is the complexity of this algorithm? 2n where n is the number of propositional symbols. Can we do better? SAT was the first problem shown to be NP-complete [Coo71]: all of the problems in the class NP can be solved by translating them (in polynomial time) into SAT. So, if we could somehow build a fast solver for SAT, it could be used to solve lots of other problems. In theory, this seems dubious, as problems in NP are known to take exponential time in the worst case. Remarkably, modern SAT solvers are very fast most of the time!

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 23/98

slide-73
SLIDE 73

Roadmap

Boolean Satisfiability

  • Propositional Logic
  • Solving SAT
  • Modeling for SAT

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 24/98

slide-74
SLIDE 74

Converting to CNF

Given an arbitrary formula in propostitional logic, most algorithms for determining satisfiability first convert the formula into conjunctive normal form (CNF). Some definitions:

  • A literal is a propositional variable or its negation
  • A clause is a disjunction of one or more literals
  • A formula is in CNF if it consists of a conjunction of

clauses

  • A propositional symbol occurs positively if it occurs

unnegated in a clause.

  • A propositional symbol occurs negatively if it occurs

negated in a clause.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 25/98

slide-75
SLIDE 75

Converting to CNF

Examples

  • Literals: Pi, ¬Pi
  • Clauses: (P1 ∨ ¬P3 ∨ P5), (P2 ∨ ¬P2)
  • CNF: (P1 ∨ ¬P3) ∧ (¬P2 ∨ P3 ∨ P5)
  • In the above formula, P1 occurs positively and P2 occurs

negatively To provide intuition for how to convert to CNF , we first explore the connection between propositional formulas and Boolean circuits.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 26/98

slide-76
SLIDE 76

Boolean Gates

Consider an electrical device having n inputs and one output. Assume that to each input we apply a signal that is either T

  • r F, and that this uniquely determines whether the output is

T or F.

X2 X3 F (X1, X2, X3) X1

The behavior of such a device is described by a Boolean function: F(X1, . . . , Xn) = the output signal given the input signals X1, . . . , Xn. We call such a device a Boolean gate.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 27/98

slide-77
SLIDE 77

Boolean Gates

Some common Boolean gates include AND, OR, and NOT gates.

OR AND NOT

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 28/98

slide-78
SLIDE 78

Boolean Circuits

The inputs and outputs of Boolean gates can be connected together to form a combinational Boolean circuit.

D C B A

A combinational Boolean circuit corresponds to a directed acyclic graph (DAG) whose leaves are inputs and each of whose nodes is labeled with the name of a Boolean gate. One or more of the nodes may be identified as outputs.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 29/98

slide-79
SLIDE 79

Boolean Circuits

The inputs and outputs of Boolean gates can be connected together to form a combinational Boolean circuit.

D C B A

There is a natrual correspondence between Boolean circuits and formulas of propositional logic. The formula corresponding to the above circuit is: (D ∧ (A ∧ B)) ∨ ((A ∧ B) ∧ ¬C).

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 30/98

slide-80
SLIDE 80

Sharing Sub-Expressions

(D ∧ (A ∧ B)) ∨ ((A ∧ B) ∧ ¬C) This formula highlights an inefficiency in the logic representation as compared with the circuit representation.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 31/98

slide-81
SLIDE 81

Sharing Sub-Expressions

(D ∧ (A ∧ B)) ∨ ((A ∧ B) ∧ ¬C) This formula highlights an inefficiency in the logic representation as compared with the circuit representation. If we are only concerned with the satisfiability of the formula, we can overcome this inefficiency by introducing new propositional symbols: ((D ∧ E) ∨ (E ∧ ¬C)) ∧ (E ↔ (A ∧ B))

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 31/98

slide-82
SLIDE 82

Sharing Sub-Expressions

(D ∧ (A ∧ B)) ∨ ((A ∧ B) ∧ ¬C) This formula highlights an inefficiency in the logic representation as compared with the circuit representation. If we are only concerned with the satisfiability of the formula, we can overcome this inefficiency by introducing new propositional symbols: ((D ∧ E) ∨ (E ∧ ¬C)) ∧ (E ↔ (A ∧ B)) Note that the new formula is not tautologically equivalent to the original formula: why?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 31/98

slide-83
SLIDE 83

Sharing Sub-Expressions

(D ∧ (A ∧ B)) ∨ ((A ∧ B) ∧ ¬C) This formula highlights an inefficiency in the logic representation as compared with the circuit representation. If we are only concerned with the satisfiability of the formula, we can overcome this inefficiency by introducing new propositional symbols: ((D ∧ E) ∨ (E ∧ ¬C)) ∧ (E ↔ (A ∧ B)) Note that the new formula is not tautologically equivalent to the original formula: why? But it is equisatisfiable: the original formula is satisfiable iff the new formula is satisfiable.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 31/98

slide-84
SLIDE 84

Converting to CNF

This same idea is behind a simple algorithm for converting any formula to CNF [Tse70]. We view the formula as a directed acyclic graph (DAG).

Conversion to CNF

  • 1. Label each non-leaf node of the DAG with a new

propositional symbol.

  • 2. For each non-leaf node, construct a conjunction of

clauses relating the inputs of that node to its output.

  • 3. Take the conjunction of all of these clauses together with

a single clause consisting of the symbol for the root node. The resulting formula is satisfiable iff the original formula is satisfiable.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 32/98

slide-85
SLIDE 85

Converting to CNF: Example

D C B A F E G H I

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-86
SLIDE 86

Converting to CNF: Example

D C B A F E G H I

(A ∧ B) ↔ E

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-87
SLIDE 87

Converting to CNF: Example

D C B A F E G H I

(A ∧ B) ↔ E ((A ∧ B) → E) ∧ (E → (A ∧ B))

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-88
SLIDE 88

Converting to CNF: Example

D C B A F E G H I

(A ∧ B) ↔ E ((A ∧ B) → E) ∧ (E → (A ∧ B)) (¬(A ∧ B) ∨ E) ∧ (¬E ∨ (A ∧ B))

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-89
SLIDE 89

Converting to CNF: Example

D C B A F E G H I

(A ∧ B) ↔ E ((A ∧ B) → E) ∧ (E → (A ∧ B)) (¬(A ∧ B) ∨ E) ∧ (¬E ∨ (A ∧ B)) (¬A ∨ ¬B ∨ E) ∧ (¬E ∨ A) ∧ (¬E ∨ B)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-90
SLIDE 90

Converting to CNF: Example

D C B A F E G H I

(¬A ∨ ¬B ∨ E) ∧ (¬E ∨ A) ∧ (¬E ∨ B) ∧

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-91
SLIDE 91

Converting to CNF: Example

D C B A F E G H I

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

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-92
SLIDE 92

Converting to CNF: Example

D C B A F E G H I

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

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-93
SLIDE 93

Converting to CNF: Example

D C B A F E G H I

(¬A ∨ ¬B ∨ E) ∧ (¬E ∨ A) ∧ (¬E ∨ B) ∧ (¬C ∨ F) ∧ (¬F ∨ C) ∧ (¬D ∨ ¬E ∨ G) ∧ (¬G ∨ D) ∧ (¬G ∨ E) ∧ (¬E ∨ ¬F ∨ H) ∧ (¬H ∨ E) ∧ (¬H ∨ F) ∧

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-94
SLIDE 94

Converting to CNF: Example

D C B A F E G H I

(¬A ∨ ¬B ∨ E) ∧ (¬E ∨ A) ∧ (¬E ∨ B) ∧ (¬C ∨ F) ∧ (¬F ∨ C) ∧ (¬D ∨ ¬E ∨ G) ∧ (¬G ∨ D) ∧ (¬G ∨ E) ∧ (¬E ∨ ¬F ∨ H) ∧ (¬H ∨ E) ∧ (¬H ∨ F) ∧ (G ∨ H ∨ ¬I) ∧ (I ∨ ¬G) ∧ (I ∨ ¬H) ∧

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-95
SLIDE 95

Converting to CNF: Example

D C B A F E G H I

(¬A ∨ ¬B ∨ E) ∧ (¬E ∨ A) ∧ (¬E ∨ B) ∧ (¬C ∨ F) ∧ (¬F ∨ C) ∧ (¬D ∨ ¬E ∨ G) ∧ (¬G ∨ D) ∧ (¬G ∨ E) ∧ (¬E ∨ ¬F ∨ H) ∧ (¬H ∨ E) ∧ (¬H ∨ F) ∧ (G ∨ H ∨ ¬I) ∧ (I ∨ ¬G) ∧ (I ∨ ¬H) ∧ (I)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 33/98

slide-96
SLIDE 96

CNF: Alternative notations

(¬A ∨ ¬B ∨ E) ∧ (¬E ∨ A) ∧ (¬E ∨ B) ∧ (¬C ∨ F) ∧ (¬F ∨ C) ∧ (¬D ∨ ¬E ∨ G) ∧ (¬G ∨ D) ∧ (¬G ∨ E) ∧ (¬E ∨ ¬F ∨ H) ∧ (¬H ∨ E) ∧ (¬H ∨ F) ∧ (G ∨ H ∨ ¬I) ∧ (I ∨ ¬G) ∧ (I ∨ ¬H) ∧ (I) (A′ + B′ + E)(E′ + A)(E′ + B) (C′ + F)(F ′ + C) (D′ + E′ + G)(G′ + D)(G′ + E) (E′ + F ′ + H)(H′ + E)(H′ + F) (G + H + I′)(I + G′)(I + H′) (I)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 34/98

slide-97
SLIDE 97

CNF: Alternative notations

DIMACS standard

Each variable is represented by a positive integer. A negative integer refers to the negation of the variable. Clauses are given as sequences of integers separated by spaces. A 0 terminates the clause. (A′ + B′ + E)(E′ + A)(E′ + B) (C′ + F)(F ′ + C) (D′ + E′ + G)(G′ + D)(G′ + E) (E′ + F ′ + H)(H′ + E)(H′ + F) (G + H + I′)(I + G′)(I + H′) (I)

  • 1 -2 5 0
  • 5 1 0
  • 5 2 0
  • 3 6 0
  • 6 3 0
  • 4 -5 7 0
  • 7 4 0
  • 7 5 0
  • 5 -6 8 0
  • 8 5 0
  • 8 6 0

7 8 -9 0 9 -7 0 9 -8 0 9 0

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 35/98

slide-98
SLIDE 98

Davis-Putnam Algorithm

From now on, unless otherwise indicated, we assume formulas are in CNF , or, equivalently, that we have a set of clauses to check for satisfiability (i.e. the conjunction is implicit). The first algorithm to try something more sophisticated than the truth-table method was the Davis-Putnam (DP) algorithm, published in 1960 [DP60]. It is often confused with the later, more popular algorithm presented by Davis, Logemann, and Loveland in 1962 [DLL62], which we will refer to as Davis-Putnam-Logemann-Loveland (DPLL). We first consider the original DP algorithm.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 36/98

slide-99
SLIDE 99

Davis-Putnam Algorithm

There are three satisfiability-preserving transformations in DP .

  • The 1-literal rule
  • The affirmative-negative rule
  • The rule for eliminating atomic formulas

The first two steps reduce the total number of literals in the formula. The last step reduces the number of variables in the formula. By repeatedly applying these rules, eventually we obtain a formula containing an empty clause, indicating unsatisfiability,

  • r a formula with no clauses, indicating satisfiability.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 37/98

slide-100
SLIDE 100

Davis-Putnam Algorithm

The 1-literal rule

Also called unit propagation. Suppose (p) is a unit clause (clause containing only one literal). Let −p denote the negation of p where double negation is collapsed (i.e. −¬q ≡ q).

  • Remove all instances of −p from clauses in the formula

(shortening the corresponding clauses).

  • Remove all clauses containing p (including the unit clause

itself).

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 38/98

slide-101
SLIDE 101

Davis-Putnam Algorithm

The affirmative-negative rule

Also called the pure literal rule. If a literal appears only positively or only negatively, delete all clauses containing that literal. Why does this preserve satisfiability?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 39/98

slide-102
SLIDE 102

Davis-Putnam Algorithm

Rule for eliminating atomic formulas

Also called the resolution rule.

  • Choose a propositional symbol p which occurs positively

in at least one clause and negatively in at least one other clause.

  • Let P be the set of all clauses in which p occurs positively.
  • Let N be the set of all clauses in which p occurs

negatively.

  • Replace the clauses in P and N with those obtained by

resolution on p using all pairs of clauses from P and N. For a single pair of clauses, (p ∨ l1 ∨ · · · ∨ lm) and (¬p ∨ k1 ∨ · · · ∨ kn), resolution on p forms the new clause (l1 ∨ · · · ∨ lm ∨ k1 ∨ · · · ∨ kn).

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 40/98

slide-103
SLIDE 103

DPLL Algorithm

In the worst case, the resolution rule can cause a quadratic expansion every time it is applied. For large formulas, this can quickly exhaust the available memory. The DPLL algorithm replaces resolution with a splitting rule.

  • Choose a propositional symbol p occuring in the formula.
  • Let ∆ be the current set of clauses.
  • Test the satisfiability of ∆ ∪ {(p)}.
  • If satisfiable, return True.
  • Otherwise, return the result of testing ∆ ∪ {(¬p)} for

satisfiability.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 41/98

slide-104
SLIDE 104

Some Experimental Results [Har09]

Problem tautology dptaut dplltaut prime 3 0.00 0.00 0.00 prime 4 0.02 0.06 0.04 prime 9 18.94 2.98 0.51 prime 10 11.40 3.03 0.96 prime 11 28.11 2.98 0.51 prime 16 >1 hour

  • ut of memory

9.15 prime 17 >1 hour

  • ut of memory

3.87 ramsey 3 3 5 0.03 0.06 0.02 ramsey 3 3 6 5.13 8.28 0.31 mk_adder_test 3 2 >>1 hour 6.50 7.34 mk_adder_test 4 2 >>1 hour 22.95 46.86 mk_adder_test 5 2 >>1 hour 44.83 170.98 mk_adder_test 5 3 >>1 hour 38.27 250.16 mk_adder_test 6 3 >>1 hour

  • ut of memory

1186.4 mk_adder_test 7 3 >>1 hour

  • ut of memory

3759.9

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 42/98

slide-105
SLIDE 105

DPLL Algorithm

The DPLL algorithm is the basis for most modern SAT solvers. We will look at DPLL in more detail, but first we consider two more alternative algorithms.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 43/98

slide-106
SLIDE 106

Incomplete SAT: GSAT [SLM92]

Input: a set of clauses F, MAX-FLIPS, MAX-TRIES Output: a satisfying truth assignment of F

  • r ∅, if none found

for i := 1 to MAX-TRIES v := a randomly generated truth assignment for j := 1 to MAX-FLIPS if v satisfies F then return v p := a propositional variable such that a change in its truth assignment gives the largest increase in the total number of clauses of F that are satisfied by v v := v with the assignment to p reversed end for end for return ∅

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 44/98

slide-107
SLIDE 107

Stålmarck’s Method [SS98]

Breadth-first approach instead of depth-first.

Dilemma Rule

Given a set of formulas ∆ and any basic deduction algorithm, R, the dilemma rule performs a case split on some literal p by considering the new sets of formulas ∆ ∪ {(¬p)} and ∆ ∪ {(p)}. To each of these sets, the algorithm R is applied to yield ∆0 and ∆1 respectively. The original set ∆ is then augmented with ∆0 ∩ ∆1.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 45/98

slide-108
SLIDE 108

Stålmarck’s Method [SS98]

Breadth-first approach instead of depth-first.

Dilemma Rule

Given a set of formulas ∆ and any basic deduction algorithm, R, the dilemma rule performs a case split on some literal p by considering the new sets of formulas ∆ ∪ {(¬p)} and ∆ ∪ {(p)}. To each of these sets, the algorithm R is applied to yield ∆0 and ∆1 respectively. The original set ∆ is then augmented with ∆0 ∩ ∆1. In 1994, Kunz and Pradhan developed a technique they called recursive learning which is very similar to the dilemma rule [KP94].

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 45/98

slide-109
SLIDE 109

Stålmarck’s Method

Stålmarck’s Method takes as input a set of formulas ∆ and a set of basic deduction rules S0. Applying S0 to ∆ until no further deductions are possible is called 0-saturation. Applying the dilemma rule with R = S0 until no further deductions are possible is called 1-saturation, and the result is denoted S1. Note that in order to acheive 1-saturation, the dilemma rule is applied for every variable. This is why Stålmarck’s Method can be classified as a breadth-first strategy. Repeatedly applying the dilemma rule with R = S1 is called 2-saturation, and denoted S2. In general, Sn+1 or (n + 1)-saturation is obtained by applying the dilemma rule with R = Sn.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 46/98

slide-110
SLIDE 110

Stålmarck’s Method

If a set of formulas ∆ is decidable by n-saturation, then ∆ is said to be n-easy. If, in addition, it is not decidable by (n − 1)-saturation, it is said to be n-hard. If ∆ contains at most n propositional symbols, then ∆ is clearly n-easy. Why?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 47/98

slide-111
SLIDE 111

Stålmarck’s Method

If a set of formulas ∆ is decidable by n-saturation, then ∆ is said to be n-easy. If, in addition, it is not decidable by (n − 1)-saturation, it is said to be n-hard. If ∆ contains at most n propositional symbols, then ∆ is clearly n-easy. Why? The merit of Stålmarck’s method is that for some applications, the problems are nearly always n-easy for small values of n,

  • ften just n = 1.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 47/98

slide-112
SLIDE 112

Stålmarck’s Method: Implementation

Triplets

Stålmarck’s Method does not use CNF . Instead, it first translates a formula into a set of triplets: pi ↔ pj ⊲ ⊳ pk. The translation is analagous to the conversion to CNF except that the equivalences for each node are not transformed into clauses: they are left as equivalences.

Example

D C B A F E G H I

(E ↔ A ∧ B),(G ↔ D ∧ E), (H ↔ E ∧ ¬C), (I ↔ G ∨ H)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 48/98

slide-113
SLIDE 113

Stålmarck’s Method: Implementation

Simple Rules

The rules for 0-saturation simply enumerate the new equivalences that can be deduced from a triplet given a set of existing equivalences.

Example

Consider the triplet p ↔ q ∧ r

  • If r ↔ True, then p ↔ q.
  • If p ↔ True, then q ↔ True and r ↔ True.
  • If q ↔ False, then p ↔ False.
  • If q ↔ r, then p ↔ q and p ↔ r.
  • If p ↔ ¬q, then q ↔ True and r ↔ False.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 49/98

slide-114
SLIDE 114

Stålmarck’s Method: Implementation

These rules are called triggers. 0-saturation is done by using the triggers to deduce new equivalences until nothing new can be obtained or a contradiction (True ↔ False) is derived.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 50/98

slide-115
SLIDE 115

Stålmarck’s Method: Implementation

The overall algorithm works as follows:

  • 1. The formula is negated and converted to triplets.
  • 2. 0-saturation is performed. If a contradiction is obtained,

we are done.

  • 3. Otherwise, 1-saturation is performed: for each variable,

the dilemma rule is used with R = S0 to deduce new

  • equivalences. If a contradiction is obtained, we are done.
  • 4. Continue performing additional levels of saturation until a

contradiction is obtained. Note that the algorithm as given does not detect satisfiable formulas, only unsatisfiable formulas. With some modification, the algorithm can be adapted to detect satisfiability as well.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 51/98

slide-116
SLIDE 116

Stålmarck’s Method: Performance

The procedure is quite effective in many cases. For primality formulas, it is generally comparable to DPLL. For Ramsey formulas, significantly worse. But for adder formulas it is substantially better. Another class of formulas on which Stålmarck performs well is the so-called urquhart formulas: p1 ↔ p2 ↔ · · · ↔ pn ↔ p1 ↔ p2 ↔ · · · ↔ pn. These formulas are all 2-easy, whereas DPLL must search through nearly all possible cases to prove them. In general, if a formula with m connectives is n-easy, Stålmarck’s Method can decide it in time O(m2n+1).

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 52/98

slide-117
SLIDE 117

Abstract DPLL

We now return to DPLL. To facilitate a deeper look at DPLL, we use a high-level framework called Abstract DPLL [NOT06].

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 53/98

slide-118
SLIDE 118

Abstract DPLL

We now return to DPLL. To facilitate a deeper look at DPLL, we use a high-level framework called Abstract DPLL [NOT06].

  • Abstract DPLL uses states and transitions to model the

progress of the algorithm.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 53/98

slide-119
SLIDE 119

Abstract DPLL

We now return to DPLL. To facilitate a deeper look at DPLL, we use a high-level framework called Abstract DPLL [NOT06].

  • Abstract DPLL uses states and transitions to model the

progress of the algorithm.

  • Most states are of the form M |

| F, where

  • M is a sequence of annotated literals denoting a

partial truth assignment, and

  • F is the CNF formula being checked, represented as a

set of clauses.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 53/98

slide-120
SLIDE 120

Abstract DPLL

We now return to DPLL. To facilitate a deeper look at DPLL, we use a high-level framework called Abstract DPLL [NOT06].

  • Abstract DPLL uses states and transitions to model the

progress of the algorithm.

  • Most states are of the form M |

| F, where

  • M is a sequence of annotated literals denoting a

partial truth assignment, and

  • F is the CNF formula being checked, represented as a

set of clauses.

  • The initial state is ∅ |

| F, where F is to be checked for satisfiability.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 53/98

slide-121
SLIDE 121

Abstract DPLL

We now return to DPLL. To facilitate a deeper look at DPLL, we use a high-level framework called Abstract DPLL [NOT06].

  • Abstract DPLL uses states and transitions to model the

progress of the algorithm.

  • Most states are of the form M |

| F, where

  • M is a sequence of annotated literals denoting a

partial truth assignment, and

  • F is the CNF formula being checked, represented as a

set of clauses.

  • The initial state is ∅ |

| F, where F is to be checked for satisfiability.

  • Transitions between states are defined by a set of

conditional transition rules.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 53/98

slide-122
SLIDE 122

Abstract DPLL

The final state is either:

  • a special fail state: fail, if F is unsatisfiable, or
  • M |

| G, where G is a CNF formula equisatisfiable with the

  • riginal formula F, and M satisfies G

We write M | = C to mean that for every truth assignment v, v(M) = True implies v(C) = True.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 54/98

slide-123
SLIDE 123

Abstract DPLL Rules

UnitProp :

M | | F, C ∨ l = ⇒ M l | | F, C ∨ l if 8 < : M | = ¬C l is undefined in M

PureLiteral :

M | | F = ⇒ M l | | F if 8 > > < > > : l occurs in some clause of F −l occurs in no clause of F l is undefined in M

Decide :

M | | F = ⇒ M ld | | F if 8 < : l or ¬l occurs in a clause of F l is undefined in M

Backtrack :

M ld N | | F, C = ⇒ M ¬l | | F, C if 8 < : M ld N | = ¬C N contains no decision literals

Fail :

M | | F, C = ⇒ fail if 8 < : M | = ¬C M contains no decision literals

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 55/98

slide-124
SLIDE 124

Example

∅ | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (PureLiteral) 4 1d 2 3 | |

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 56/98

slide-125
SLIDE 125

Example

∅ | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (PureLiteral) 4 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 4 1d 2 3 | |

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 57/98

slide-126
SLIDE 126

Example

∅ | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (PureLiteral) 4 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Decide) 4 1d | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 4 1d 2 3 | |

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 58/98

slide-127
SLIDE 127

Example

∅ | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (PureLiteral) 4 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Decide) 4 1d | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 4 1d 2 3 | |

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 59/98

slide-128
SLIDE 128

Example

∅ | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (PureLiteral) 4 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Decide) 4 1d | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 3 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 60/98

slide-129
SLIDE 129

Example

∅ | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (PureLiteral) 4 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Decide) 4 1d | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 3 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Backtrack) 4 1 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 61/98

slide-130
SLIDE 130

Example

∅ | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (PureLiteral) 4 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Decide) 4 1d | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 3 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Backtrack) 4 1 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1 2 3 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 62/98

slide-131
SLIDE 131

Example

∅ | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (PureLiteral) 4 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Decide) 4 1d | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 3 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Backtrack) 4 1 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1 2 3 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Fail) fail

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 63/98

slide-132
SLIDE 132

Example

∅ | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (PureLiteral) 4 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Decide) 4 1d | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1d 2 3 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Backtrack) 4 1 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (UnitProp) 4 1 2 3 | | 1∨2, 1∨2, 2∨3, 3∨2, 1∨4 = ⇒ (Fail) fail Result: Unsatisfiable

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 63/98

slide-133
SLIDE 133

Abstract DPLL: Backjumping and Learning

The basic rules can be improved by replacing the Backtrack rule with the more powerful Backjump rule and adding a Learn rule:

Backjump :

M ld N | | F, C = ⇒ M l′ | | F, C if 8 > > > > > > > < > > > > > > > : M ld N | = ¬C, and there is some clause C′ ∨ l′ such that: F, C | = C′ ∨ l′ and M | = ¬C′, l′ is undefined in M, and l′ or ¬l′ occurs in F or in M ld N

Learn :

M | | F = ⇒ M | | F, C if 8 < : all atoms of C occur in F F | = C

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 64/98

slide-134
SLIDE 134

Abstract DPLL: Backjumping and Learning

The Backjump rule is best understood by introducing the notion

  • f implication graph, a directed graph associated with a state

M | | F of Abstract DPLL:

  • The vertices are the variables in M
  • There is an edge from v1 to v2 if v2 was assigned a value

as the result of an application of UnitProp using a clause containing v2. When we reach a state in which M | = ¬C for some C ∈ F, we add an extra conflict vertex and edges from each of the variables in C to the conflict vertex.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 65/98

slide-135
SLIDE 135

Abstract DPLL: Backjumping and Learning

The clause to use for backjumping (called the conflict clause) is obtained from the resulting graph:

  • We first cut the graph along edges in such a way that it

separates the conflict vertex from all of the decision vertices.

  • Then, every vertex with an outgoing edge that was cut is

marked.

  • For each literal l in M whose variable is marked, −l is

added to the conflict clause. To avoid ever having the same conflict again, we can learn the conflict clause using the learn rule.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 66/98

slide-136
SLIDE 136

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 1d 2 3d 5d 6 | |

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 67/98

slide-137
SLIDE 137

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 1d 2 3d 5d 6 | |

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 68/98

slide-138
SLIDE 138

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 1d 2 3d 5d 6 | |

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 69/98

slide-139
SLIDE 139

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 1d 2 3d 5d 6 | |

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 70/98

slide-140
SLIDE 140

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d 5d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 1d 2 3d 5d 6 | |

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 71/98

slide-141
SLIDE 141

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d 5d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 3d 5d 6 | | 1∨2, 3∨4, 5∨6, 2∨5∨6

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 72/98

slide-142
SLIDE 142

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d 5d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 3d 5d 6 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Learn) 1d 2 3d 5d 6 | | 1∨2, 3∨4, 5∨6, 2∨5∨6, 2∨5

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 73/98

slide-143
SLIDE 143

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d 5d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 3d 5d 6 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Learn) 1d 2 3d 5d 6 | | 1∨2, 3∨4, 5∨6, 2∨5∨6, 2∨5 = ⇒ (Backjump) 1d 2 5 | | 1∨2, 3∨4, 5∨6, 2∨5∨6, 2∨5

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 74/98

slide-144
SLIDE 144

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d 5d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 3d 5d 6 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Learn) 1d 2 3d 5d 6 | | 1∨2, 3∨4, 5∨6, 2∨5∨6, 2∨5 = ⇒ (Backjump) 1d 2 5 | | 1∨2, 3∨4, 5∨6, 2∨5∨6, 2∨5 = ⇒ (Decide) 1d 2 5 3d | | 1∨2, 3∨4, 5∨6, 2∨5∨6, 2∨5

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 75/98

slide-145
SLIDE 145

Example

∅ | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Decide) 1d 2 3d 5d | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (UnitProp) 1d 2 3d 5d 6 | | 1∨2, 3∨4, 5∨6, 2∨5∨6 = ⇒ (Learn) 1d 2 3d 5d 6 | | 1∨2, 3∨4, 5∨6, 2∨5∨6, 2∨5 = ⇒ (Backjump) 1d 2 5 | | 1∨2, 3∨4, 5∨6, 2∨5∨6, 2∨5 = ⇒ (Decide) 1d 2 5 3d | | 1∨2, 3∨4, 5∨6, 2∨5∨6, 2∨5 Result: Satisfiable

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 75/98

slide-146
SLIDE 146

Abstract DPLL Modulo Theories Rules

Two final rules also have to do with learning:

  • If too many clauses are learned, performance suffers. It is

useful to forget some clauses (typically those that have not participated in an application of UnitProp for a while).

  • If we are stuck, we can restart by throwing away M.

Since we have learned clauses, this means our efforts were not entirely wasted. Randomly restarting can improve performance dramatically.

Forget :

M | | F, C = ⇒ M | | F if n F | = C

Restart :

M | | F = ⇒ ∅ | | F

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 76/98

slide-147
SLIDE 147

Decision Heuristics

The rules do not give any strategy for how to pick a variable when applying Decide. In practice, this is critical for performance. There are many heuristics, but the most successful currently use very cheap heuristics to try to prefer variables that are frequently involved in conflicts.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 77/98

slide-148
SLIDE 148

Boolean Constraint Propagation

The most expensive part of a SAT solver is the part that checks for and applies instances of the UnitProp rule. A key insight that can be used to speed this up is that as long as a clause has at least two unassigned literals, it cannot participate in an application of UnitProp. For every clause, we assign two of its unassigned literals as the watched literals. Every time a literal is assigned, only those clauses in which it is watched need to be checked for a possible triggering of the

UnitProp rule.

For those clauses that are inspected, if UnitProp is not triggered, a new unassigned literal is chosen to be watched.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 78/98

slide-149
SLIDE 149

Other Considerations

Modern SAT solvers [ES03, MMZ+01, MSS96, Zha97] have a number of other tricks to speed things up:

  • Highly tuned code
  • Optimization for cache performance
  • Preprocessing and clever CNF encodings
  • Automatic tuning of program parameters

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 79/98

slide-150
SLIDE 150

What is the state-of-the-art?

  • D. le Berre, O. Roussel, L. Simon. “The SAT ’07 Contest”

http://www.cril.univ-artois.fr/SAT07/

SAT 2007 Competition

  • 44 solvers
  • 3 benchmark categories
  • Industrial
  • Crafted
  • Random

Some of the winners:

  • Industrial: RSat, picosat, minisat
  • Crafted: SATzilla, minisat, March-KS
  • Random: SATzilla, March-KS, gnovelty+

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 80/98

slide-151
SLIDE 151

Roadmap

Boolean Satisfiability

  • Propositional Logic
  • Solving SAT
  • Modeling for SAT

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 81/98

slide-152
SLIDE 152

Modeling for SAT

Modeling

  • Define a finite set of possibilities called states.
  • Model states using (vectors of) propositional variables.
  • Use propositional formulas to describe legal and illegal

states.

  • Construct a propositional formula describing the desired

state.

Solving

  • Translate the formula into CNF

.

  • If the formula is satisfiable, the satisfying assignment

gives the desired state.

  • If the formula is not satisfiable, the desired state does not

exist.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 82/98

slide-153
SLIDE 153

Example: Graph Coloring

Problems involving graph coloring are important in both theoretical and applied computer science. Recall that a graph consists of a set V of vertices and a set E

  • f edges, where each edge is an unordered pair of distinct

vertices. A complete graph on n vertices is a graph with |V | = n such that E contains all possible pairs of vertices.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 83/98

slide-154
SLIDE 154

Example: Graph Coloring

Problems involving graph coloring are important in both theoretical and applied computer science. Recall that a graph consists of a set V of vertices and a set E

  • f edges, where each edge is an unordered pair of distinct

vertices. A complete graph on n vertices is a graph with |V | = n such that E contains all possible pairs of vertices. How many edges are in a complete graph?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 83/98

slide-155
SLIDE 155

Example: Graph Coloring

Problems involving graph coloring are important in both theoretical and applied computer science. Recall that a graph consists of a set V of vertices and a set E

  • f edges, where each edge is an unordered pair of distinct

vertices. A complete graph on n vertices is a graph with |V | = n such that E contains all possible pairs of vertices. How many edges are in a complete graph?

n(n−1) 2

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 83/98

slide-156
SLIDE 156

Example: Graph Coloring

Suppose we wish to color each edge of a complete graph without creating any triangles in which all the edges have the same color. What is the largest complete graph for which this is possible? The answer depends on the number of colors we are allowed to use.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 84/98

slide-157
SLIDE 157

Example: Graph Coloring

Suppose we wish to color each edge of a complete graph without creating any triangles in which all the edges have the same color. What is the largest complete graph for which this is possible? The answer depends on the number of colors we are allowed to use. What if you are only allowed one color?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 84/98

slide-158
SLIDE 158

Example: Graph Coloring

Suppose we wish to color each edge of a complete graph without creating any triangles in which all the edges have the same color. What is the largest complete graph for which this is possible? The answer depends on the number of colors we are allowed to use. What if you are only allowed one color?

Answer: n = 2

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 84/98

slide-159
SLIDE 159

Example: Graph Coloring

Suppose we wish to color each edge of a complete graph without creating any triangles in which all the edges have the same color. What is the largest complete graph for which this is possible? The answer depends on the number of colors we are allowed to use. What if you are only allowed one color?

Answer: n = 2

What if the number of colors is 2?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 84/98

slide-160
SLIDE 160

Example: Graph Coloring

Suppose we wish to color each edge of a complete graph without creating any triangles in which all the edges have the same color. What is the largest complete graph for which this is possible? The answer depends on the number of colors we are allowed to use. What if you are only allowed one color?

Answer: n = 2

What if the number of colors is 2?

Answer: n = 5

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 84/98

slide-161
SLIDE 161

Example: Graph Coloring

Suppose we wish to color each edge of a complete graph without creating any triangles in which all the edges have the same color. What is the largest complete graph for which this is possible? The answer depends on the number of colors we are allowed to use. What if you are only allowed one color?

Answer: n = 2

What if the number of colors is 2?

Answer: n = 5

What if the number of colors is 3?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 84/98

slide-162
SLIDE 162

Example: Graph Coloring

Suppose we wish to color each edge of a complete graph without creating any triangles in which all the edges have the same color. What is the largest complete graph for which this is possible? The answer depends on the number of colors we are allowed to use. What if you are only allowed one color?

Answer: n = 2

What if the number of colors is 2?

Answer: n = 5

What if the number of colors is 3? This is a job for SAT

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 84/98

slide-163
SLIDE 163

Example: Graph Coloring

  • Define a finite set of possibilities called states.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 85/98

slide-164
SLIDE 164

Example: Graph Coloring

  • Define a finite set of possibilities called states.

For this problem, each possible coloring is a state. There are 3|E| possible states.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 85/98

slide-165
SLIDE 165

Example: Graph Coloring

  • Define a finite set of possibilities called states.

For this problem, each possible coloring is a state. There are 3|E| possible states.

  • Model states using (vectors of) propositional variables.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 85/98

slide-166
SLIDE 166

Example: Graph Coloring

  • Define a finite set of possibilities called states.

For this problem, each possible coloring is a state. There are 3|E| possible states.

  • Model states using (vectors of) propositional variables.

A simple encoding uses two propositional variables for each edge. Since there are 4 possible combinations of values of two variables, this gives us a state space of 4|E|, which is larger than we need, but keeps the encoding simple.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 85/98

slide-167
SLIDE 167

Example: Graph Coloring

  • Define a finite set of possibilities called states.

For this problem, each possible coloring is a state. There are 3|E| possible states.

  • Model states using (vectors of) propositional variables.

A simple encoding uses two propositional variables for each edge. Since there are 4 possible combinations of values of two variables, this gives us a state space of 4|E|, which is larger than we need, but keeps the encoding simple.

  • Use propositional formulas to describe legal and illegal

states.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 85/98

slide-168
SLIDE 168

Example: Graph Coloring

  • Define a finite set of possibilities called states.

For this problem, each possible coloring is a state. There are 3|E| possible states.

  • Model states using (vectors of) propositional variables.

A simple encoding uses two propositional variables for each edge. Since there are 4 possible combinations of values of two variables, this gives us a state space of 4|E|, which is larger than we need, but keeps the encoding simple.

  • Use propositional formulas to describe legal and illegal

states. Since the color of each edge is modeled with 2 variables, there are 4 possible colors. We can write a set of formulas which disallow the fourth color.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 85/98

slide-169
SLIDE 169

Example: Graph Coloring

  • Define a finite set of possibilities called states.

For this problem, each possible coloring is a state. There are 3|E| possible states.

  • Model states using (vectors of) propositional variables.

A simple encoding uses two propositional variables for each edge. Since there are 4 possible combinations of values of two variables, this gives us a state space of 4|E|, which is larger than we need, but keeps the encoding simple.

  • Use propositional formulas to describe legal and illegal

states. For example, if e1 and e2 are the variables for edge e, we simply require ¬(e1 ∧ e2).

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 85/98

slide-170
SLIDE 170

Example: Graph Coloring

  • Construct a propositional formula describing the desired

state.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 86/98

slide-171
SLIDE 171

Example: Graph Coloring

  • Construct a propositional formula describing the desired

state. The desired state is one in which there are no triangles of the same color. For each triangle made up of edges e, f, g, we require: ¬((e1 ↔ f1) ∧ (f1 ↔ g1) ∧ (e2 ↔ f2) ∧ (f2 ↔ g2)).

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 86/98

slide-172
SLIDE 172

Example: Graph Coloring

  • Construct a propositional formula describing the desired

state. The desired state is one in which there are no triangles of the same color. For each triangle made up of edges e, f, g, we require: ¬((e1 ↔ f1) ∧ (f1 ↔ g1) ∧ (e2 ↔ f2) ∧ (f2 ↔ g2)).

  • Translate the formula into an equisatisfiable CNF formula.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 86/98

slide-173
SLIDE 173

Example: Graph Coloring

  • Construct a propositional formula describing the desired

state. The desired state is one in which there are no triangles of the same color. For each triangle made up of edges e, f, g, we require: ¬((e1 ↔ f1) ∧ (f1 ↔ g1) ∧ (e2 ↔ f2) ∧ (f2 ↔ g2)).

  • Translate the formula into an equisatisfiable CNF formula.

This can be done using the CNF conversion algorithm described earlier.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 86/98

slide-174
SLIDE 174

Example: Graph Coloring

  • Construct a propositional formula describing the desired

state. The desired state is one in which there are no triangles of the same color. For each triangle made up of edges e, f, g, we require: ¬((e1 ↔ f1) ∧ (f1 ↔ g1) ∧ (e2 ↔ f2) ∧ (f2 ↔ g2)).

  • Translate the formula into an equisatisfiable CNF formula.

This can be done using the CNF conversion algorithm described earlier.

  • If the formula is satisfiable, the satisfying assignment

gives the desired state.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 86/98

slide-175
SLIDE 175

Example: Graph Coloring

  • Construct a propositional formula describing the desired

state. The desired state is one in which there are no triangles of the same color. For each triangle made up of edges e, f, g, we require: ¬((e1 ↔ f1) ∧ (f1 ↔ g1) ∧ (e2 ↔ f2) ∧ (f2 ↔ g2)).

  • Translate the formula into an equisatisfiable CNF formula.

This can be done using the CNF conversion algorithm described earlier.

  • If the formula is satisfiable, the satisfying assignment

gives the desired state. An actual coloring can be constructed by looking at the values of each variable given by the satisfying assignment.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 86/98

slide-176
SLIDE 176

Example: Graph Coloring

  • If the formula is not satisfiable, the desired state does not

exist.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 87/98

slide-177
SLIDE 177

Example: Graph Coloring

  • If the formula is not satisfiable, the desired state does not

exist. If the formula can be shown to be unsatisfiable, this is proof that there is no coloring.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 87/98

slide-178
SLIDE 178

Example: Graph Coloring

  • If the formula is not satisfiable, the desired state does not

exist. If the formula can be shown to be unsatisfiable, this is proof that there is no coloring. What if the number of colors is 3?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 87/98

slide-179
SLIDE 179

Example: Graph Coloring

  • If the formula is not satisfiable, the desired state does not

exist. If the formula can be shown to be unsatisfiable, this is proof that there is no coloring. What if the number of colors is 3?

Answer: n = 16

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 87/98

slide-180
SLIDE 180

Modeling

Let us consider again the circuit example we saw before.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 88/98

slide-181
SLIDE 181

Circuit Example

  • =

+1 +2

1 1 1

test

x y z a a a

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 89/98

slide-182
SLIDE 182

Modeling

One way to prove the property of the circuit is by induction. The inductive step is essentially the following: (y = x + 1 AND z = x + 2 AND x’ = IF a THEN x ELSE y AND y’ = IF a THEN y ELSE z AND z’ = IF a THEN z ELSE y + 2) IMPLIES y’ = x’ + 1 AND z’ = x’ + 2 We can prove this formula by showing that the negation is unsatisfiable. We can write this formula in propositional logic by using one propositional variable for each bit in the current and next states.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 90/98

slide-183
SLIDE 183

Modeling

Assuming a bit-width of 2 for simplicity and skipping the details, we get the following formula: (z1 ↔ ¬x1) ∧ (z0 ↔ x0)∧ (y1 ↔ (x1 ⊕ x0)) ∧ (y0 ↔ ¬x0)∧ (a → ((xp1 ↔ x1) ∧ (xp0 ↔ x0)))∧ (¬a → ((xp1 ↔ y1) ∧ (xp0 ↔ y0)))∧ (a → ((yp1 ↔ y1) ∧ (yp0 ↔ y0)))∧ (¬a → ((yp1 ↔ z1) ∧ (yp0 ↔ z0)))∧ (a → ((zp1 ↔ z1) ∧ (zp0 ↔ z0)))∧ (¬a → ((zp1 ↔ ¬y1) ∧ (zp0 ↔ y0)))∧ (¬(zp1 ↔ ¬xp1) ∨ ¬(zp0 ↔ xp0)∨ ¬(yp1 ↔ (xp1 ⊕ xp0)) ∧ (yp0 ↔ ¬xp0)

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 91/98

slide-184
SLIDE 184

Modeling: Transition Systems

Often, we want to model a system as a transition system: a system with a set of states and a set of possible transitions between states. Suppose Q is a set of states, Q0 ⊆ Q a set of initial states, and T a transition relation on states (i.e. T ⊆ Q × Q). Since Q is finite, we can find an m such that 2m ≥ |Q|. We can then use m variables: x = [x1, . . . , xm] to represent the

  • states. These are called state variables.

To represent T, we need m additional variables, y = [y1, . . . , ym], which we call next-state variables. We can write formulas FQ0(x) and FT(y) such that the solutions of FQ0(x) correspond to initial states in Q0 and the solutions of FT(x, y) correspond to valid transitions in T.

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 92/98

slide-185
SLIDE 185

Bounded Model Checking

Bounded Model Checking [BCCZ99, CBRZ01] can be used to determine whether a state is reachable from the initial state in some bounded number of transitions. To perofrm bounded model checking to a depth of n using SAT, we need n extra copies of the state variables and a set

  • f states QP that we are trying to reach.

Let x0, . . . , xn be n + 1 copies of the state variables. And let FQP (x) be a formula that is true for the states in QP. QP is reachable in n steps iff the following formula is satisfiable: FQ0(x0) ∧ FT(x0, x1) ∧ · · · ∧ FT(xn−1, x) ∧ FQP (xn).

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 93/98

slide-186
SLIDE 186

Exercise

You have probably seen the following puzzle before. There is a triangle of 15 pegs with one missing. You have to jump pegs until there is only one left. X X X X O X X X X X X X X X X

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 94/98

slide-187
SLIDE 187

Exercise

Can you solve this puzzle?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 95/98

slide-188
SLIDE 188

Exercise

Can you solve this puzzle? Can you solve this puzzle using SAT?

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 95/98

slide-189
SLIDE 189

Exercise

Can you solve this puzzle? Can you solve this puzzle using SAT? Code for graph coloring problem is at http://www.cs.nyu.edu/∼barrett/tmp/colors.tar

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 95/98

slide-190
SLIDE 190

Exercise

Can you solve this puzzle? Can you solve this puzzle using SAT? Code for graph coloring problem is at http://www.cs.nyu.edu/∼barrett/tmp/colors.tar Solution on Friday...

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 95/98

slide-191
SLIDE 191

References

[BCCZ99] A. Biere, A. Cimatti, E. Clarke, and Y. Zhu. Symbolic model checking without

  • BDDs. In Proceedings of the 5th Workshop on Tools and Algorithms for the

Construction and Analysis of Systems (TACAS ’99), volume 1573 of LNCS, pages 193–207. Springer-Verlag, 1999

[CBRZ01] E. Clarke, A. Biere, R. Raimi, and Y. Zhu. Solving SAT and SAT Modulo Theories:

from an Abstract Davis-Putnam-Logemann-Loveland Procedure to DPLL(T). Formal Methods in System Design, 19(1):7–34, 2001

[Coo71] S. A. Cook. The complexity of theorem proving procedures. In Proceedings of the

Third Annual ACM Symposium on the Theory of Computing, pages 151–158, 1971

[DP60] Martin Davis and Hilary Putnam. A computing procedure for quantification theory.

Journal of the ACM, 7(3):201–215, July 1960

[DLL62] Martin Davis, George Logemann, and Donald Loveland. A machine program for

theorem proving. Communications of the ACM, 5(7):394–397, July 1962

[End00] Herbert B. Enderton. A Mathematical Introduction to Logic. Undergraduate Texts in

  • Mathematics. Academic Press, second edition edition, 2000

[ES03] Niklas Een and Niklas Sörensson. An extensible sat-solver. In SAT ’03, 2003

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 96/98

slide-192
SLIDE 192

References

[Gat02] Bill Gates. Keynote address at WinHec 2002, April 2002 [Har09] John Harrison. Introduction to Logic and Automated Theorem Proving. 2009.

Unpublished, used with permission

[KP94] W. Kunz and D. K. Pradhan. Recursive learning: A new implication technique for

efficient solutions to CAD problems–test, verification, and optimization. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, 13(9):1143–1157, September 1994

[MMZ+01] Matthew W. Moskewicz, Conor F. Madigan, Ying Zhao, Lintao Zhang, and Sharad

  • Malik. Chaff: Engineering an efficient SAT solver. In Proceedings of the 38th Design

Automation Conference (DAC’01), June 2001

[MSS96] Joao P

. Marques-Silva and Karem A. Sakallah. GRASP - A New Search Algorithm for Satisfiability. In Proceedings of IEEE/ACM International Conference on Computer-Aided Design, pages 220–227, November 1996

[NOT06] Robert Nieuwenhuis, Albert Oliveras, and Cesare Tinelli. Solving SAT and SAT

Modulo Theories: from an Abstract Davis-Putnam-Logemann-Loveland Procedure to DPLL(T). Journal of the ACM, 53(6):937–977, November 2006

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 97/98

slide-193
SLIDE 193

References

[SLM92] Bart Selman, Hector Levesque, and David Mitchell. A new method for solving hard

satisfiability problems. In Proceedings of the 10th National Conference on Artificial Intelligence, pages 440–446, 1992

[SS98] Mary Sheeran and Gunnar Stålmarck. A tutorial on Stålmarck’s proof procedure for

propositional logic. In G. Gopalakrishnan and P . J Windley, editors, Proceedings of the 2nd International Conference on Formal Methods in Computer-Aided Design (FMCAD ’98), volume 1522 of LNCS, pages 82–99. Springer, November 1998

[Tse70] G. Tseitin. On the complexity of derivation in propositional calculus. Studies in

Constructive Mathematics and Mathematical Logic, part II, pages 115–125, 1970

[Zha97] H. Zhang. SATO: An efficient propositional prover. In William McCune, editor,

Proceedings of the 14th International Conference on Automated Deduction, volume 1249 of Lecture Notes in Artificial Intelligence, pages 272–275. Springer, July 1997

Summer School on Verification Technology, Systems & Applications, September 17, 2008 – p. 98/98