Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers ›...

47
LPAR’06 - Phnom Penh (Cambodia) Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis, Albert Oliveras, Cesare Tinelli New York Univ. Techn. Univ. Catalonia Univ. of Iowa LPAR’06 November 17th, 2006, Phom Penh (Cambodia) LPAR’06. Splitting on Demang in SAT Modulo Theories – p.1/18

Transcript of Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers ›...

Page 1: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Splitting on Demand in

SAT Modulo Theories

Clark Barrett, Robert Nieuwenhuis, Albert Oliveras, Cesare Tinelli

New York Univ. Techn. Univ. Catalonia Univ. of Iowa

LPAR’06

November 17th, 2006, Phom Penh (Cambodia)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.1/18

Page 2: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Overview of the talk

Introduction to SMT

Eager approach

Lazy approach: Boolean engine DPLL(X) + T-solver

Inside the T-solver

What does DPLL(X) need from T-solver?

Splitting on Demand

Use of Splitting on Demand for Nelson-Oppen

Conclusions

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.2/18

Page 3: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Introduction to SMT

Some problems are more naturally expressed in other logicsthan propositional logic, e.g:

Software verification needs reasoning about equality,arithmetic, data structures, ...

SMT consists of deciding the satisfiability of a (ground) FOformula with respect to a background theory T

Example ( Equality with Uninterpreted Functions – EUF ):

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

Wide range of applications:

Predicate abstraction

Model checking

Equivalence checking

Static analysis

Scheduling

...

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.3/18

Page 4: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Eager approach vs lazy approach

EAGER APPROACH:

Methodology: translate problem into equisatisfiablepropositional formula and use off-the-shelf SAT solver[Bryant, Velev, Pnueli, Lahiri, Seshia, Strichman, ...]

Why “eager”? Search uses all theory information from thebeginning

Tools: UCLID [Lahiri, Seshia and Bryant]

LAZY APPROACH:

Methodology: integration of a SAT-solver with a theory solver

Why “lazy”? Theory information used lazily when checkingT-consistency of propositional models

Tools: CVC-Lite, Yices, MathSAT, TSAT+, Barcelogic ...

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.4/18

Page 5: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach example

Consider EUF and

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

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.5/18

Page 6: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach example

Consider EUF and

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]

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.5/18

Page 7: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach example

Consider EUF and

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 says T-inconsistent

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.5/18

Page 8: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach example

Consider EUF and

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 says T-inconsistent

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

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.5/18

Page 9: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach example

Consider EUF and

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 says T-inconsistent

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

SAT solver returns model [1, 2, 3, 4]

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.5/18

Page 10: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach example

Consider EUF and

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 says T-inconsistent

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

SAT solver returns model [1, 2, 3, 4]

Theory solver says T-inconsistent

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.5/18

Page 11: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach example

Consider EUF and

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 says T-inconsistent

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

SAT solver returns model [1, 2, 3, 4]

Theory solver says T-inconsistent

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

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.5/18

Page 12: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach example

Consider EUF and

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 says T-inconsistent

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

SAT solver returns model [1, 2, 3, 4]

Theory solver says T-inconsistent

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

SAT solver detects it UNSATISFIABLE

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.5/18

Page 13: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach optimizations

Several optimizations for enhancing efficiency:

Check T-consistency only of full propositional models

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.6/18

Page 14: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach optimizations

Several optimizations for enhancing efficiency:

Check T-consistency only of full propositional models

Check T-consistency of partial assignment while being built

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.6/18

Page 15: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach optimizations

Several optimizations for enhancing efficiency:

Check T-consistency only of full propositional models

Check T-consistency of partial assignment while being built

Given a T-inconsistent assignment M, add ¬M as a clause

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.6/18

Page 16: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach optimizations

Several optimizations for enhancing efficiency:

Check T-consistency only of full propositional models

Check T-consistency of partial assignment while being built

Given a T-inconsistent assignment M, add ¬M as a clause

Given a T-inconsistent assignment M, identify aT-inconsistent subset M0 ⊆ M and add ¬M0 as a clause

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.6/18

Page 17: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach optimizations

Several optimizations for enhancing efficiency:

Check T-consistency only of full propositional models

Check T-consistency of partial assignment while being built

Given a T-inconsistent assignment M, add ¬M as a clause

Given a T-inconsistent assignment M, identify aT-inconsistent subset M0 ⊆ M and add ¬M0 as a clause

Upon a T-inconsistency, add clause and restart

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.6/18

Page 18: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

SMT - Lazy approach optimizations

Several optimizations for enhancing efficiency:

Check T-consistency only of full propositional models

Check T-consistency of partial assignment while being built

Given a T-inconsistent assignment M, add ¬M as a clause

Given a T-inconsistent assignment M, identify aT-inconsistent subset M0 ⊆ M and add ¬M0 as a clause

Upon a T-inconsistency, add clause and restart

Upon a T-inconsistency, use the conflicting clause ¬M0 tobackjump to some point where the assignment was stillT-consistent, as in SAT-solvers.

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.6/18

Page 19: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Overview of the talk

Introduction to SMT

Eager approach

Lazy approach: Boolean engine DPLL(X) + T-solver

Inside the T-solver ⇐What does DPLL(X) need from T-solver?

Splitting on Demand

Use of Splitting on Demand for Nelson-Oppen

Conclusions

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.6/18

Page 20: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

What does DPLL(X) need from T-Solver?

T-consistency check of a set of literals M, with:

Explain of T-inconsistency: find (small) T-inconsistentsubset of M [minimal wrt. size?, wrt. ⊆?]

Incrementality: if l is added to M, check for M l faster thanreprocessing M l from scratch.

Theory propagation: find input T-consequences of M, with:

Explain T-Propagate of l: find (small) subset of M thatT-entails l (needed in conflict analysis).

Backtrack n: undo last n literals added

PAPER FOCUSES only on T-consistency checks

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.7/18

Page 21: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

A T-Solver for EUF

Theory solvers can usually be described using inference rules

The input conjunction of literals C is saturated wrt the rules

C is unsat iff ⊥ has been derived

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.8/18

Page 22: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

A T-Solver for EUF

Theory solvers can usually be described using inference rules

The input conjunction of literals C is saturated wrt the rules

C is unsat iff ⊥ has been derived

A congruence closure algorithm (a solver for EUF) can be describedwith the following rules:

Reflexitivy: Symmetry: Transitivity:

t = tu = tt = u

t = u u = vt = v

Monotonicity: Contradiction:t1 = u1 . . . tn = un

f (t1, . . . , tn) = f (u1, . . . , un)

t = u t 6= u

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.8/18

Page 23: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

A T-solver for difference logic (in R)

Atoms are of the form x ./ y + d, being x and y variables, d a realconstant and ./∈ {<,≤}, or of the form x = y + d.

Transitivity:

x ≤ z + c z ./ y + d

x ./ y + (c + d)

x < z + c z ./ y + d

x < y + (c + d)

Equality treatment:

x ≤ y + c y ≤ x − c

x = y + c

x = y + c

x ≤ y + c, y ≤ x − c

Contradiction:

x < x + c

⊥(if c ≤ 0)

x = y + c x 6= y + c

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.9/18

Page 24: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

A T-solver for difference logic (in Z)

Consider the unsatisfiable set of literals{1 ≤ x − y, x − y ≤ 2, x 6= y + 1, x 6= y + 2}

Saturation wrt the previous inference rules only adds{y ≤ y + 1}.

To obtain a (refutationally) complete inference system:

Add splitting rule:

x 6= y + c

x < y + c x > y + c

Or add splitting rules of the form:

c ≤ x − y x − y ≤ (c + k)

x − y = c x − y = c + 1 . . . x − y = c + k

This may give an exponential amount of work, but problem isNP-hard anyway.

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.10/18

Page 25: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Other theories requiring case-splitting

T-solvers requiring internal case-splitting are common:

Theory of arrays:

read(write(A, i, v), j) = read(A, j)

i 6= j i = j , read(A, j) = v

A x y A’ v y

i j i j

Fragments of set theory:

S1 6= S2

e ∈ S1, e 6∈ S2 e 6∈ S1, e ∈ S2

This type of solvers are much more difficult to implement than“deterministic” ones

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.11/18

Page 26: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Other theories requiring case-splitting

T-solvers requiring internal case-splitting are common:

Theory of arrays:

read(write(A, i, v), j) = read(A, j)

i 6= j i = j , read(A, j) = v

A x A’ v

i i

Fragments of set theory:

S1 6= S2

e ∈ S1, e 6∈ S2 e 6∈ S1, e ∈ S2

This type of solvers are much more difficult to implement than“deterministic” ones

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.11/18

Page 27: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Our proposal: splitting on demand

INFORMALLY:

IDEA: pass theory case-splits to the DPLL engine as clauses

BENEFITS:

Split-backtrack infrastructure is not duplicated

Allow flexibility in T-reasoning (cheap computations first)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.12/18

Page 28: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Our proposal: splitting on demand

INFORMALLY:

IDEA: pass theory case-splits to the DPLL engine as clauses

BENEFITS:

Split-backtrack infrastructure is not duplicated

Allow flexibility in T-reasoning (cheap computations first)

FORMALLY:

Given initial state ∅ || F, consider L the finite set of all literalsthat might need case splitting.

Modify T-Learn: also clauses with literals form L may belearned.

L avoids termination problems (under certain conditions)

T-solvers complete only when all atoms in L are decided

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.12/18

Page 29: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Example

Consider again Diff. Logic over Z and the formula:

x ≤ y + 1︸ ︷︷ ︸

1

∧ ( x < y︸ ︷︷ ︸

2

∨ x 6= y + 1︸ ︷︷ ︸

3

) ∧ x 6=y︸ ︷︷ ︸

4

∅ || 1, 2 ∨ 3, 4 ⇒ (UnitPropagate x 2)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.13/18

Page 30: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Example

Consider again Diff. Logic over Z and the formula:

x ≤ y + 1︸ ︷︷ ︸

1

∧ ( x < y︸ ︷︷ ︸

2

∨ x 6= y + 1︸ ︷︷ ︸

3

) ∧ x 6=y︸ ︷︷ ︸

4

∅ || 1, 2 ∨ 3, 4 ⇒ (UnitPropagate x 2)

1 4 || 1, 2 ∨ 3, 4 ⇒ (T-Learn with 5 ≡ x > y)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.13/18

Page 31: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Example

Consider again Diff. Logic over Z and the formula:

x ≤ y + 1︸ ︷︷ ︸

1

∧ ( x < y︸ ︷︷ ︸

2

∨ x 6= y + 1︸ ︷︷ ︸

3

) ∧ x 6=y︸ ︷︷ ︸

4

∅ || 1, 2 ∨ 3, 4 ⇒ (UnitPropagate x 2)

1 4 || 1, 2 ∨ 3, 4 ⇒ (T-Learn with 5 ≡ x > y)

1 4 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (Decide)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.13/18

Page 32: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Example

Consider again Diff. Logic over Z and the formula:

x ≤ y + 1︸ ︷︷ ︸

1

∧ ( x < y︸ ︷︷ ︸

2

∨ x 6= y + 1︸ ︷︷ ︸

3

) ∧ x 6=y︸ ︷︷ ︸

4

∅ || 1, 2 ∨ 3, 4 ⇒ (UnitPropagate x 2)

1 4 || 1, 2 ∨ 3, 4 ⇒ (T-Learn with 5 ≡ x > y)

1 4 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (Decide)

1 4 5 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (T-Propagate x 2)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.13/18

Page 33: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Example

Consider again Diff. Logic over Z and the formula:

x ≤ y + 1︸ ︷︷ ︸

1

∧ ( x < y︸ ︷︷ ︸

2

∨ x 6= y + 1︸ ︷︷ ︸

3

) ∧ x 6=y︸ ︷︷ ︸

4

∅ || 1, 2 ∨ 3, 4 ⇒ (UnitPropagate x 2)

1 4 || 1, 2 ∨ 3, 4 ⇒ (T-Learn with 5 ≡ x > y)

1 4 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (Decide)

1 4 5 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (T-Propagate x 2)

1 4 5 2 3 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (Backjump)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.13/18

Page 34: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Example

Consider again Diff. Logic over Z and the formula:

x ≤ y + 1︸ ︷︷ ︸

1

∧ ( x < y︸ ︷︷ ︸

2

∨ x 6= y + 1︸ ︷︷ ︸

3

) ∧ x 6=y︸ ︷︷ ︸

4

∅ || 1, 2 ∨ 3, 4 ⇒ (UnitPropagate x 2)

1 4 || 1, 2 ∨ 3, 4 ⇒ (T-Learn with 5 ≡ x > y)

1 4 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (Decide)

1 4 5 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (T-Propagate x 2)

1 4 5 2 3 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (Backjump)

1 4 5 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (UnitPropagate)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.13/18

Page 35: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Example

Consider again Diff. Logic over Z and the formula:

x ≤ y + 1︸ ︷︷ ︸

1

∧ ( x < y︸ ︷︷ ︸

2

∨ x 6= y + 1︸ ︷︷ ︸

3

) ∧ x 6=y︸ ︷︷ ︸

4

∅ || 1, 2 ∨ 3, 4 ⇒ (UnitPropagate x 2)

1 4 || 1, 2 ∨ 3, 4 ⇒ (T-Learn with 5 ≡ x > y)

1 4 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (Decide)

1 4 5 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (T-Propagate x 2)

1 4 5 2 3 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (Backjump)

1 4 5 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 ⇒ (UnitPropagate)

1 4 5 2 || 1, 2 ∨ 3, 4, 4 ∨ 2 ∨ 5 (Model found)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.13/18

Page 36: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Overview of the talk

Introduction to SMT

Eager approach

Lazy approach: Boolean engine DPLL(X) + T-solver

Inside the T-solver

What does DPLL(X) need from T-solver?

Splitting on Demand

Use of Splitting on Demand for Nelson-Oppen ⇐Conclusions

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.13/18

Page 37: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Nelson-Oppen: combination of theories

SMT problems usually involve more than one theory:

a=b+2 ∧ A=write(B, a+1, 4) ∧ ( read(A, b+3)=2 ∨ f (a−1) 6= f (b+1) )

Combination problem:

INPUT:

Two theories T1 and T2.

A T1-solver and a T2-solver

OUTPUT:

A (T1 ∪ T2)−solver

Nelson-Oppen provides a combination procedure if:

Theories are signature disjoint

Theories are stably-infinite

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.14/18

Page 38: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Nelson-Oppen: example

Γ = { f ( f ( x ) − f ( y ) ) 6= f (z), x ≤ y, y + z ≤ x, z ≥ 0}

1. Purify literals: introduce new variablesw1 = f (x), w2 = f (y), w3 = w1 − w2

2. Now we get

ΓR = {x ≤ y, y + z ≤ x, z ≥ 0, w3 = w1 − w2} andΓE = { f (w3) 6= f (z), w1 = f (x), w2 = f (y)}

with shared variables {x, y, z, w1, w2, w3}.

3. N-O: Γ SAT in the combined theory iff exists arrangement A(for each pair of shared variables, say whether they are equalor distinct) such that ΓR ∧A is TR-SAT and ΓE ∧A is TE-SAT.

Ideal implementation: T-solvers exchange entailed equations untilfix point or unsatisfiability is detected by a single T-solver.

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.15/18

Page 39: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Nelson-Oppen: example(2)

ΓR = {x ≤ y, y + z ≤ x, z ≥ 0, w3 = w1 − w2}

ΓE = { f (w3) 6= f (z), w1 = f (x), w2 = f (y)}

with shared variables {x, y, z, w1, w2, w3}.

Arrangement A (init. empty) is seen by both solvers:

TR-solver detects x = y is entailed (and added to A)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.16/18

Page 40: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Nelson-Oppen: example(2)

ΓR = {x ≤ y, y + z ≤ x, z ≥ 0, w3 = w1 − w2}

ΓE = { f (w3) 6= f (z), w1 = f (x), w2 = f (y)}

with shared variables {x, y, z, w1, w2, w3}.

Arrangement A (init. empty) is seen by both solvers:

TR-solver detects x = y is entailed (and added to A)

TE-solver detects w1 = w2 is entailed (and added to A)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.16/18

Page 41: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Nelson-Oppen: example(2)

ΓR = {x ≤ y, y + z ≤ x, z ≥ 0, w3 = w1 − w2}

ΓE = { f (w3) 6= f (z), w1 = f (x), w2 = f (y)}

with shared variables {x, y, z, w1, w2, w3}.

Arrangement A (init. empty) is seen by both solvers:

TR-solver detects x = y is entailed (and added to A)

TE-solver detects w1 = w2 is entailed (and added to A)

TR-solver detects z = w3 is entailed (and added to A)

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.16/18

Page 42: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Nelson-Oppen: example(2)

ΓR = {x ≤ y, y + z ≤ x, z ≥ 0, w3 = w1 − w2}

ΓE = { f (w3) 6= f (z), w1 = f (x), w2 = f (y)}

with shared variables {x, y, z, w1, w2, w3}.

Arrangement A (init. empty) is seen by both solvers:

TR-solver detects x = y is entailed (and added to A)

TE-solver detects w1 = w2 is entailed (and added to A)

TR-solver detects z = w3 is entailed (and added to A)

TE-solver detects ΓE ∧A is TE-unsat

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.16/18

Page 43: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Nelson-Oppen: example(2)

ΓR = {x ≤ y, y + z ≤ x, z ≥ 0, w3 = w1 − w2}

ΓE = { f (w3) 6= f (z), w1 = f (x), w2 = f (y)}

with shared variables {x, y, z, w1, w2, w3}.

Arrangement A (init. empty) is seen by both solvers:

TR-solver detects x = y is entailed (and added to A)

TE-solver detects w1 = w2 is entailed (and added to A)

TR-solver detects z = w3 is entailed (and added to A)

TE-solver detects ΓE ∧A is TE-unsat

But exchanging entailed equalities does not always suffice:

ΓZ = {1 ≤ x − y, x − y ≤ 2, w1 = y + 1, w2 = y + 2}

ΓE = { f (x) 6= f (w1), f (x) 6= f (w2)}

is UNSAT, but no equation is entailed.

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.16/18

Page 44: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Nelson-Oppen with non-convex theories

Why didn’t it work with

ΓZ = {1 ≤ x − y, x − y ≤ 2, w1 = y + 1, w2 = y + 2}

ΓE = { f (x) 6= f (w1), f (x) 6= f (w2)} ?

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.17/18

Page 45: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Nelson-Oppen with non-convex theories

Why didn’t it work with

ΓZ = {1 ≤ x − y, x − y ≤ 2, w1 = y + 1, w2 = y + 2}

ΓE = { f (x) 6= f (w1), f (x) 6= f (w2)} ?

ΓZ does not entail any equation between shared variables

But ΓZ |=T x = w1 ∨ x = w2 (non-convex theory)

For non-convex theories, DISJUNCTIONS of equalities shouldbe communicated. Possibilities:

Send clauses from solver to solver

Force DPLL(X) to split on equalities between sharedvariables [DTC]

Send clauses from solvers to DPLL(X) only as necessary[DTC,Splitting on Demand]

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.17/18

Page 46: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Overview of the talk

Introduction to SMT

Eager approach

Lazy approach: Boolean engine DPLL(X) + T-solver

Inside the T-solver

What does DPLL(X) need from T-solver?

Splitting on Demand

Use of Splitting on Demand for Nelson-Oppen

Conclusions ⇐

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.17/18

Page 47: Splitting on Demand in SAT Modulo Theories › ~oliveras › espai › papers › lpar06-slides.pdf · Splitting on Demand in SAT Modulo Theories Clark Barrett, Robert Nieuwenhuis,

LPAR’06 - Phnom Penh (Cambodia)

Conclusions

Expensive theories easily dealt with the appropriateinfrastructure

This infrastructure allows greater flexibility

Nelson-Oppen easily accommodated

LPAR’06. Splitting on Demang in SAT Modulo Theories – p.18/18