82
Formalizing DPLL-based Solvers for Propositional Satisfiability and for Satisfiability Modulo Theories Cesare Tinelli (joint work with Robert Nieuwenhuis and Albert Oliveras) [email protected] The University of Iowa Cambridge, June 2005 – p.1/37

Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Formalizing DPLL-based Solversfor

Propositional Satisfiabilityand for

Satisfiability Modulo Theories

Cesare Tinelli(joint work with Robert Nieuwenhuis and Albert Oliveras)

[email protected]

The University of Iowa

Cambridge, June 2005 – p.1/37

Page 2: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Propositional Satisfiability: SAT

Deciding the satisfiability of a propositional formula is awell-studied and important problem.

Theoretical interest: first established NP-Completeproblem, phase transition, . . .

Practical interest: applications to scheduling, planning,logic synthesis, verification, . . .

Development of algorithms and enhancements.

Implementation of extremely efficient tools.

Solvers based on the DPLL procedure have been themost successful so far.

Cambridge, June 2005 – p.2/37

Page 3: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Satisfiability Modulo Theories

Any SAT solver can be used to decide the satisfiability ofground (i.e., variable-free) first-order formulas.

Cambridge, June 2005 – p.3/37

Page 4: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Satisfiability Modulo Theories

Any SAT solver can be used to decide the satisfiability ofground (i.e., variable-free) first-order formulas.

Often, however, one is interested in the satisfiability ofcertain ground formulas in a given first-order theory:

Cambridge, June 2005 – p.3/37

Page 5: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Satisfiability Modulo Theories

Any SAT solver can be used to decide the satisfiability ofground (i.e., variable-free) first-order formulas.

Often, however, one is interested in the satisfiability ofcertain ground formulas in a given first-order theory:

Pipelined microprocessors: theory of equality, atomslike f(g(a, b), c) = g(c, a).

Cambridge, June 2005 – p.3/37

Page 6: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Satisfiability Modulo Theories

Any SAT solver can be used to decide the satisfiability ofground (i.e., variable-free) first-order formulas.

Often, however, one is interested in the satisfiability ofcertain ground formulas in a given first-order theory:

Pipelined microprocessors: theory of equality, atomslike f(g(a, b), c) = g(c, a).

Timed automata, planning: theory of integers/reals,atoms like x − y < 2.

Cambridge, June 2005 – p.3/37

Page 7: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Satisfiability Modulo Theories

Any SAT solver can be used to decide the satisfiability ofground (i.e., variable-free) first-order formulas.

Often, however, one is interested in the satisfiability ofcertain ground formulas in a given first-order theory:

Pipelined microprocessors: theory of equality, atomslike f(g(a, b), c) = g(c, a).

Timed automata, planning: theory of integers/reals,atoms like x − y < 2.

Software verification: combination of theories, atomslike 5 + car(a + 2) = cdr(a[j] + 1).

Cambridge, June 2005 – p.3/37

Page 8: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Satisfiability Modulo Theories

Any SAT solver can be used to decide the satisfiability ofground (i.e., variable-free) first-order formulas.

Often, however, one is interested in the satisfiability ofcertain ground formulas in a given first-order theory:

Pipelined microprocessors: theory of equality, atomslike f(g(a, b), c) = g(c, a).

Timed automata, planning: theory of integers/reals,atoms like x − y < 2.

Software verification: combination of theories, atomslike 5 + car(a + 2) = cdr(a[j] + 1).

We refer to this general problems as (ground)Satisfiability Modulo Theories, or SMT.

Cambridge, June 2005 – p.3/37

Page 9: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Satisfiability Modulo a Theory T

Note: The T -satisfiability of ground formulas is decidableiff the T -satisfiability of sets of literals is decidable.

Fact: Many theories of interest have (efficient) decisionprocedures for sets of literals.

Problem: In practice, dealing with Boolean combinationsof literals is as hard as in the propositional case.

Current solution: Exploit propositional satisfiabilitytechnology.

Cambridge, June 2005 – p.4/37

Page 10: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Lifting SAT to SMT

Eager approach [UCLID]:

translate into an equisatisfiable propositional formula,

feed it to any SAT solver.

Lazy approach [CVC, ICS, MathSAT, Verifun, Zap]:

abstract the input formula into a propositional one,

feed it to a DPLL-based SAT solver,

use a theory decision procedure to refine the formula.

DPLL(T ) [DPLLT, Sammy]:

use the decision procedure to guide the search of aDPLL solver.

Cambridge, June 2005 – p.5/37

Page 11: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Goals of This Work

Develop a declarative formal framework to:

Reason formally about DPLL-based solvers for SAT andfor SMT.

Model modern features such as non-chronologicalbactracking, lemma learning or restarts.

Describe different strategies and prove their correctness.

Compare different systems at a higher level.

Get new insights for further enhancements of DPPLsolvers.

Cambridge, June 2005 – p.6/37

Page 12: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Talk Overview

Motivation: SAT and SMT

The DPLL procedure

An Abstract Framework

SAT case

The Original DPLL Procedure

The Basic and the Enhanced DPLL System

SMT caseVery Lazy Theory Learning

Lazy Theory Learning

Theory Propagation

Cambridge, June 2005 – p.7/37

Page 13: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure

Tries to build incrementally a satisfying truth assignmentM for a CNF formula F .

M is grown by

deducing the truth value of a literal from M and F , or

guessing a truth value.

If a wrong guess for a literal leads to an inconsistency, theprocedure backtracks and tries the opposite value.

Cambridge, June 2005 – p.8/37

Page 14: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure – Example

Operation Assign. Formula1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

Cambridge, June 2005 – p.9/37

Page 15: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure – Example

Operation Assign. Formula1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

Cambridge, June 2005 – p.9/37

Page 16: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure – Example

Operation Assign. Formula1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 2 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

Cambridge, June 2005 – p.9/37

Page 17: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure – Example

Operation Assign. Formula1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 2 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

Cambridge, June 2005 – p.9/37

Page 18: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure – Example

Operation Assign. Formula1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 2 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 4 1, 2, 3, 4 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

Cambridge, June 2005 – p.9/37

Page 19: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure – Example

Operation Assign. Formula1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 2 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 4 1, 2, 3, 4 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

Inconsistency!

Cambridge, June 2005 – p.9/37

Page 20: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure – Example

Operation Assign. Formula1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 2 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 4 1, 2, 3, 4 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

undo 3 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

Cambridge, June 2005 – p.10/37

Page 21: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure – Example

Operation Assign. Formula1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 2 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 4 1, 2, 3, 4 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

undo 3 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

Cambridge, June 2005 – p.10/37

Page 22: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Original DPLL Procedure – Example

Operation Assign. Formula1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 1 1 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 2 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

deduce 4 1, 2, 3, 4 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

undo 3 1, 2 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

guess 3 1, 2, 3 1 ∨ 2, 2 ∨ 3 ∨ 4, 1 ∨ 2, 1 ∨ 3 ∨ 4, 1

Model Found!

Cambridge, June 2005 – p.10/37

Page 23: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Talk Overview

Motivation: SAT and SMT

The DPLL procedure

An Abstract Framework

SAT case

The Original DPLL Procedure

The Basic and the Enhanced DPLL System

SMT caseVery Lazy Theory Learning

Lazy Theory Learning

Theory Propagation

Cambridge, June 2005 – p.11/37

Page 24: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

An Abstract Framework for DPLL

The DPLL procedure can be described declaratively bysimple sequent-style calculi.

Such calculi however cannot model meta-logical featuressuch as backtracking, learning and restarts.

We model DPLL and its enhancements as transitionsystems instead.

A transition system is a binary relation over states,induced by a set of conditional transition rules.

Cambridge, June 2005 – p.12/37

Page 25: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

An Abstract Framework for DPLL

Our states:

fail or M || F

where F is a CNF formula, a set of clauses, andM is a sequence of annotated literalsdenoting a partial truth assignment.

Cambridge, June 2005 – p.13/37

Page 26: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

An Abstract Framework for DPLL

Our states:

fail or M || F

Initial state:

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

Expected final states:

fail , if F is unsatisfiable

M || G, where M is a model of G andG is logically equivalent to F .

Cambridge, June 2005 – p.13/37

Page 27: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Transition Rules for the Original DPLL

Extending the assignment:

UnitProp

M || F, C ∨ l → M l || F, C ∨ l if

{M |= ¬C,

l is undefined in M

Cambridge, June 2005 – p.14/37

Page 28: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Transition Rules for the Original DPLL

Extending the assignment:

UnitProp

M || F, C ∨ l → M l || F, C ∨ l if

{M |= ¬C,

l is undefined in M

Decide

M || F → M ld || F if

{l or l occurs in F,

l is undefined in M

Notation: ld annotates l as a decision literal.Cambridge, June 2005 – p.14/37

Page 29: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Transition Rules for the Original DPLL

Repairing the assignment:

Fail

M || F, C → fail if

{M |= ¬C,

M contains no decision literals

Cambridge, June 2005 – p.15/37

Page 30: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Transition Rules for the Original DPLL

Repairing the assignment:

Fail

M || F, C → fail if

{M |= ¬C,

M contains no decision literals

Backtrack

M ld N || F,C → M l || F,C if

{M ld N |= ¬C,

l last decision literal

Cambridge, June 2005 – p.15/37

Page 31: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Talk Overview

Motivation: SAT and SMT

The DPLL procedure

An Abstract Framework

SAT case

The Original DPLL Procedure

The Basic and the Enhanced DPLL System

SMT caseVery Lazy Theory Learning

Lazy Theory Learning

Theory Propagation

Cambridge, June 2005 – p.16/37

Page 32: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

From Backtracking to Backjumping

Backtrack

M ld N || F,C → M l || F,C if

{M ld N |= ¬C,

l last decision literal

Cambridge, June 2005 – p.17/37

Page 33: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

From Backtracking to Backjumping

Backtrack

M ld N || F,C → M l || F,C if

{M ld N |= ¬C,

l last decision literal

Backjump

M ld N || F,C → M k || F,C if

1. M ld N |= ¬C,

2. for some clause D ∨ k:F,C ⊢ D ∨ k,

M |= ¬D,

k is undefined in M,

k or k occurs inM ld N || F,C

Cambridge, June 2005 – p.17/37

Page 34: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

From Backtracking to Backjumping

Backtrack

M ld N || F,C → M l || F,C if

{M ld N |= ¬C,

l last decision literal

Backjump

M ld N || F,C → M k || F,C if

1. M ld N |= ¬C,

2. for some clause D ∨ k:F,C ⊢ D ∨ k,

M |= ¬D,

k is undefined in M,

k or k occurs inM ld N || F,C

Note: Condition (1) is actually not necessary.Cambridge, June 2005 – p.17/37

Page 35: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Basic DPLL System

At the core, current DPLL-based SAT solvers areimplementations of the transition system:

Basic DPLL

UnitProp

Decide

Fail

Backjump

Cambridge, June 2005 – p.18/37

Page 36: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Basic DPLL System – Correctness

Some terminology

Irreducible state: state to which no transition rule applies.

Execution: sequence of transitions allowed by the rules andstarting with states of the form ∅ || F .

Exhausted execution: execution ending in an irreducible state.

Cambridge, June 2005 – p.19/37

Page 37: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Basic DPLL System – Correctness

Some terminology

Irreducible state: state to which no transition rule applies.

Execution: sequence of transitions allowed by the rules andstarting with states of the form ∅ || F .

Exhausted execution: execution ending in an irreducible state.

Proposition (Strong Termination) Every execution in BasicDPLL is finite.

Note: This is not so immediate, because of Backjump.

Cambridge, June 2005 – p.19/37

Page 38: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The Basic DPLL System – Correctness

Some terminology

Irreducible state: state to which no transition rule applies.

Execution: sequence of transitions allowed by the rules andstarting with states of the form ∅ || F .

Exhausted execution: execution ending in an irreducible state.

Proposition (Soundness) For every exhausted executionstarting with ∅ || F and ending in M || F , M |= F .

Proposition (Completeness) If F is unsatisfiable, everyexhausted execution starting with ∅ || F ends with fail .

Cambridge, June 2005 – p.19/37

Page 39: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Enhancements to Basic DPLL

Cambridge, June 2005 – p.20/37

Page 40: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Enhancements to Basic DPLL

Learn

M || F → M || F, C if

{all atoms of C occur in F,

F ⊢ C

Cambridge, June 2005 – p.20/37

Page 41: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Enhancements to Basic DPLL

Learn

M || F → M || F, C if

{all atoms of C occur in F,

F ⊢ C

Forget

M || F, C → M || F if F ⊢ C

Cambridge, June 2005 – p.20/37

Page 42: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Enhancements to Basic DPLL

Learn

M || F → M || F, C if

{all atoms of C occur in F,

F ⊢ C

Forget

M || F, C → M || F if F ⊢ C

Usually C is a clause identified during conflict analysis.

Cambridge, June 2005 – p.20/37

Page 43: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Enhancements to Basic DPLL

Learn

M || F → M || F, C if

{all atoms of C occur in F,

F ⊢ C

Forget

M || F, C → M || F if F ⊢ C

RestartM || F → ∅ || F if . . . you want to

Cambridge, June 2005 – p.20/37

Page 44: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Enhancements to Basic DPLL

Learn

M || F → M || F, C if

{all atoms of C occur in F,

F ⊢ C

Forget

M || F, C → M || F if F ⊢ C

RestartM || F → ∅ || F if . . . you want to

The DPLL system ={UnitProp, Decide, Fail, Backjump, Learn, Forget, Restart}

Cambridge, June 2005 – p.20/37

Page 45: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The DPLL System – Strategies

Applying one Basic DPLL rule between each two Learnand applying Restart less and less often ensurestermination.

Cambridge, June 2005 – p.21/37

Page 46: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The DPLL System – Strategies

Applying one Basic DPLL rule between each two Learnand applying Restart less and less often ensurestermination.

In practice, Learn is usually (but not only) applied rightafter Backjump.

Cambridge, June 2005 – p.21/37

Page 47: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The DPLL System – Strategies

Applying one Basic DPLL rule between each two Learnand applying Restart less and less often ensurestermination.

In practice, Learn is usually (but not only) applied rightafter Backjump.

A common strategy is to apply the rules with thesepriorities:

Cambridge, June 2005 – p.21/37

Page 48: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The DPLL System – Strategies

Applying one Basic DPLL rule between each two Learnand applying Restart less and less often ensurestermination.

In practice, Learn is usually (but not only) applied rightafter Backjump.

A common strategy is to apply the rules with thesepriorities:

1. If n > 0 conflicts have been found so far,increase n and apply Restart.

Cambridge, June 2005 – p.21/37

Page 49: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The DPLL System – Strategies

Applying one Basic DPLL rule between each two Learnand applying Restart less and less often ensurestermination.

In practice, Learn is usually (but not only) applied rightafter Backjump.

A common strategy is to apply the rules with thesepriorities:

1. If n > 0 conflicts have been found so far,increase n and apply Restart.

2. If a current clause is falsified by the currentassignment,apply Fail or Backjump + Learn.

Cambridge, June 2005 – p.21/37

Page 50: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The DPLL System – Strategies

Applying one Basic DPLL rule between each two Learnand applying Restart less and less often ensurestermination.

In practice, Learn is usually (but not only) applied rightafter Backjump.

A common strategy is to apply the rules with thesepriorities:

1. If n > 0 conflicts have been found so far,increase n and apply Restart.

2. If a current clause is falsified by the currentassignment,apply Fail or Backjump + Learn.

3. Apply UnitPropCambridge, June 2005 – p.21/37

Page 51: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The DPLL System – Correctness

Proposition (Termination) Every execution in which(a) Learn/Forget are applied only finitely many times and(b) Restart is applied with increased periodicity

is finite.

Cambridge, June 2005 – p.22/37

Page 52: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The DPLL System – Correctness

Proposition (Termination) Every execution in which(a) Learn/Forget are applied only finitely many times and(b) Restart is applied with increased periodicity

is finite.

Proposition (Soundness) For every execution∅ || F =⇒ · · · =⇒ M || F with M || F irreducible wrt. BasicDPLL, M |= F .

Cambridge, June 2005 – p.22/37

Page 53: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

The DPLL System – Correctness

Proposition (Termination) Every execution in which(a) Learn/Forget are applied only finitely many times and(b) Restart is applied with increased periodicity

is finite.

Proposition (Soundness) For every execution∅ || F =⇒ · · · =⇒ M || F with M || F irreducible wrt. BasicDPLL, M |= F .

Proposition (Completeness) If F is unsatisfiable, for everyexecution ∅ || F =⇒ · · · =⇒ S with S irreducible wrt. BasicDPLL, S = fail .

Cambridge, June 2005 – p.22/37

Page 54: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Talk Overview

Motivation: SAT and SMT

The DPLL procedure

An Abstract Framework

SAT case

The Original DPLL Procedure

The Basic and the Enhanced DPLL System

SMT caseVery Lazy Theory Learning

Lazy Theory Learning

Theory Propagation

Cambridge, June 2005 – p.23/37

Page 55: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

(Very) Lazy Approach for SMT – Example

g(a) = c ∧ f(g(a)) 6= f(c) ∨ g(a) = d ∧ c 6= d

Theory: Equality

Cambridge, June 2005 – p.24/37

Page 56: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

(Very) Lazy Approach for SMT – Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

Cambridge, June 2005 – p.24/37

Page 57: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

(Very) Lazy Approach for SMT – Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

Send {1, 2 ∨ 3, 4} to SAT solver.

Cambridge, June 2005 – p.25/37

Page 58: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

(Very) Lazy Approach for SMT – Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

Send {1, 2 ∨ 3, 4} to SAT solver.

SAT solver returns model {1, 2, 4}.Theory solver finds {1, 2} E-unsatisfiable.

Cambridge, June 2005 – p.25/37

Page 59: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

(Very) Lazy Approach for SMT – Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

Send {1, 2 ∨ 3, 4} to SAT solver.

SAT solver returns model {1, 2, 4}.Theory solver finds {1, 2} E-unsatisfiable.

Send {1, 2 ∨ 3, 4, 1 ∨ 2} to SAT solver.

Cambridge, June 2005 – p.25/37

Page 60: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

(Very) Lazy Approach for SMT – Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

Send {1, 2 ∨ 3, 4} to SAT solver.

SAT solver returns model {1, 2, 4}.Theory solver finds {1, 2} E-unsatisfiable.

Send {1, 2 ∨ 3, 4, 1 ∨ 2} to SAT solver.

SAT solver returns model {1, 2, 3, 4}.Theory solver finds {1, 3, 4} E-unsatisfiable.

Cambridge, June 2005 – p.25/37

Page 61: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

(Very) Lazy Approach for SMT – Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

Send {1, 2 ∨ 3, 4} to SAT solver.

SAT solver returns model {1, 2, 4}.Theory solver finds {1, 2} E-unsatisfiable.

Send {1, 2 ∨ 3, 4, 1 ∨ 2} to SAT solver.

SAT solver returns model {1, 2, 3, 4}.Theory solver finds {1, 3, 4} E-unsatisfiable.

Send {1, 2 ∨ 3, 4, 1 ∨ 2, 1 ∨ 3 ∨ 4} to SAT solver.

Cambridge, June 2005 – p.25/37

Page 62: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

(Very) Lazy Approach for SMT – Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

Send {1, 2 ∨ 3, 4} to SAT solver.

SAT solver returns model {1, 2, 4}.Theory solver finds {1, 2} E-unsatisfiable.

Send {1, 2 ∨ 3, 4, 1 ∨ 2} to SAT solver.

SAT solver returns model {1, 2, 3, 4}.Theory solver finds {1, 3, 4} E-unsatisfiable.

Send {1, 2 ∨ 3, 4, 1 ∨ 2, 1 ∨ 3 ∨ 4} to SAT solver.

SAT solver finds {1, 2∨ 3, 4, 1∨ 2, 1∨ 3∨ 4} unsatisfiable.Cambridge, June 2005 – p.25/37

Page 63: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Modeling the Lazy Approach

Let T be the background theory.

The previous process can be modeled in Abstract DPLL usingthe following rules:

UnitProp, Decide, Fail, Restart

(as in the propositional case) and

T -Backjump, T -Learn, T -Forget, Very Lazy Theory Learning

Note: The first component of a state M || F is still a truthassignment, but now for ground, first-order literals.

Cambridge, June 2005 – p.26/37

Page 64: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Modeling the Lazy Approach

T -Backjump

M ld N || F,C → M k || F,C if

1. M ld N |= ¬C,

2. for some clause D ∨ k:F,C ⊢T D ∨ k,

M |= ¬D,

k is undefined in M,

k or k occurs inM ld N || F,CF or M ld N

Only change: ⊢T instead of ⊢

F ⊢T G iff every model of T that satisfies F satisfies G.

Cambridge, June 2005 – p.27/37

Page 65: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Modeling the Lazy Approach

T -Backjump

M ld N || F,C → M k || F,C if

1. M ld N |= ¬C,

2. for some clause D ∨ k:F,C ⊢T D ∨ k,

M |= ¬D,

k is undefined in M,

k or k occurs inM ld N || F,CF or M ld N

T -Learn

M || F → M || F, C if

{all atoms of C occur in F,

F ⊢T C

T -Forget

M || F, C → M || F if F ⊢T CCambridge, June 2005 – p.27/37

Page 66: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Modeling the Lazy Approach

The interaction between theory solver and SAT solver in theprevious example can be modeled with the rule

Very Lazy Theory Learning

M || F → ∅ || F, l1 ∨ . . . ∨ ln if

M |= F

{l1, . . . , ln} ⊆ M

l1 ∧ · · · ∧ ln ⊢T ⊥

Cambridge, June 2005 – p.28/37

Page 67: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Modeling the Lazy Approach

The interaction between theory solver and SAT solver in theprevious example can be modeled with the rule

Very Lazy Theory Learning

M || F → ∅ || F, l1 ∨ . . . ∨ ln if

M |= F

{l1, . . . , ln} ⊆ M

l1 ∧ · · · ∧ ln ⊢T ⊥

A better approach is to detect partial assignments that arealready T -unsatisfiable.

Cambridge, June 2005 – p.28/37

Page 68: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Modeling the Lazy Approach

Lazy Theory Learning

M || F → M || F, l1 ∨ . . . ∨ ln if

{l1, . . . , ln} ⊆ M

l1 ∧ · · · ∧ ln ⊢T ⊥

l1 ∨ · · · ∨ ln /∈ F

Cambridge, June 2005 – p.29/37

Page 69: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Modeling the Lazy Approach

Lazy Theory Learning

M || F → M || F, l1 ∨ . . . ∨ ln if

{l1, . . . , ln} ⊆ M

l1 ∧ · · · ∧ ln ⊢T ⊥

l1 ∨ · · · ∨ ln /∈ F

The learned clause is false in M , hence either Backjump orFail applies.

If this is always done, the third condition of the rule isunnecessary

In some solvers, the rule is applied as soon as possible,i.e., with M = N ln.

Cambridge, June 2005 – p.29/37

Page 70: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Lazy Approach – Strategies

Ignoring Restart (for simplicity), a common strategy is to applythe rules using the following priorities:

1. If a current clause is falsified by the current assignment,apply Fail/Backjump + Learn.

2. If the assignment is T -unsatisfiable,apply Lazy Theory Learning + (Fail/Backjump).

3. Apply UnitProp.

4. Apply Decide.

Cambridge, June 2005 – p.30/37

Page 71: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Talk Overview

Motivation: SAT and SMT

The DPLL procedure

An Abstract Framework

SAT case

The Original DPLL Procedure

The Basic and the Enhanced DPLL System

SMT caseVery Lazy Theory Learning

Lazy Theory Learning

Theory Propagation

Cambridge, June 2005 – p.31/37

Page 72: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

DPLL( T ) – Eager Theory Propagation

Use the theory information as soon as possible by eagerlyapplying

Theory Propagate

M || F → M l || F if

M ⊢T l

l or l occurs in F

l is undefined in M

Cambridge, June 2005 – p.32/37

Page 73: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Eager Theory Propagation - Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

∅ || 1, 2 ∨ 3, 4

Cambridge, June 2005 – p.33/37

Page 74: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Eager Theory Propagation - Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

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

1 || 1, 2 ∨ 3, 4

Cambridge, June 2005 – p.33/37

Page 75: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Eager Theory Propagation - Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

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

1 || 1, 2 ∨ 3, 4 =⇒ (Theory Propagate)

1 2 || 1, 2 ∨ 3, 4

Cambridge, June 2005 – p.33/37

Page 76: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Eager Theory Propagation - Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

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

1 || 1, 2 ∨ 3, 4 =⇒ (Theory Propagate)

1 2 || 1, 2 ∨ 3, 4 =⇒ (UnitProp)

1 2 3 || 1, 2 ∨ 3, 4

Cambridge, June 2005 – p.33/37

Page 77: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Eager Theory Propagation - Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

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

1 || 1, 2 ∨ 3, 4 =⇒ (Theory Propagate)

1 2 || 1, 2 ∨ 3, 4 =⇒ (UnitProp)

1 2 3 || 1, 2 ∨ 3, 4 =⇒ (Theory Propagate)

1 2 3 4 || 1, 2 ∨ 3, 4

Cambridge, June 2005 – p.33/37

Page 78: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Eager Theory Propagation - Example

g(a) = c︸ ︷︷ ︸

1

∧ f(g(a)) 6= f(c)︸ ︷︷ ︸

2

∨ g(a) = d︸ ︷︷ ︸

3

∧ c 6= d︸ ︷︷ ︸

4

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

1 || 1, 2 ∨ 3, 4 =⇒ (Theory Propagate)

1 2 || 1, 2 ∨ 3, 4 =⇒ (UnitProp)

1 2 3 || 1, 2 ∨ 3, 4 =⇒ (Theory Propagate)

1 2 3 4 || 1, 2 ∨ 3, 4 =⇒ (Fail)

fail

Cambridge, June 2005 – p.33/37

Page 79: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Eager Theory Propagation

By eagerly applying Theory Propagate every assignment isT -satisfiable, since M l is T -unsatisfiable iff M ⊢T l.

As a consequence, Lazy Theory Learning never applies.

For some logics, e.g., difference logic, his approach isextremely effective.

For some others, e.g., the theory of equality, it is tooexpensive to detect all T -consequences.

If Theory Propagate is not applied eagerly, Lazy Theory Learningis needed to repair T -unsatisfiable assignments.

Cambridge, June 2005 – p.34/37

Page 80: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Non-Exhaustive Theory Propagation

The six rules of the DPLL system plus Theory Propagate andLazy Theory Learning provide a decision procedure for SMT.

Termination can be guaranteed this way:

1. Apply at least one Basic DPLL rule between any twoconsecutive Learn applications.

2. Apply Fail/Backjump immediately afterLazy Theory Learning.

Soundness and completeness are proved similarly to thepropositional case.

Cambridge, June 2005 – p.35/37

Page 81: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Conclusions

The DPLL procedure can be modelled abstractly by atransition system.

Modern features such as backjumping, learning andrestarts can be captured with our transition systems.

Extensions to SMT are simple and clean.

We can reason formally about the termination andcorrectness of DPLL variants for SAT/SMT.

We can compare different systems at a higher level.

We got new insights for further enhancements of DPLLsolvers for SMT. (Stay tuned.)

Cambridge, June 2005 – p.36/37

Page 82: Formalizing DPLL-based Solvers for ... - cs.tau.ac.ilmsagiv/courses/ATP/Microsoft-05.pdf · Software verification: combination of theories, atoms like 5 + car(a+2) = cdr(a[j]+1)

Thank you

Cambridge, June 2005 – p.37/37