Transcript
Page 1: Internals of SMT Solvers

Internals of SMT Solvers

Leonardo de MouraMicrosoft Research

Page 2: Internals of SMT Solvers

Acknowledgements

β€’ Dejan Jovanovic (SRI International, NYU)β€’ Grant Passmore (Univ. Edinburgh)

Page 3: Internals of SMT Solvers

Herbrand Award 2013

Greg Nelson

Page 4: Internals of SMT Solvers

What is a SMT Solver?

Page 5: Internals of SMT Solvers

Multiple Approaches

is a portfolio of solvers

Page 6: Internals of SMT Solvers

Preprocessing

Simplify

Variable elimination

if-then-else elimination

…

𝐹

Solver

Modular Architecture is a β€œmust have”

Page 7: Internals of SMT Solvers

Equivalence Preserving Simplifications

Simplify

𝐹

𝐹 β€²Examples:

Page 8: Internals of SMT Solvers

Preprocessor API

Preprocessor

𝐹

𝐹 β€²

ModelConverter

ProofConverter

and may be only equisatisfiable

Page 9: Internals of SMT Solvers

Example

VariableElimination

Proofbuilder

Modelbuilder

Page 10: Internals of SMT Solvers

Example

VariableElimination

Proofbuilder

Modelbuilder

𝑀

𝑀 ,𝑀 (π‘Ž)=𝑀 (𝑏)+1

Page 11: Internals of SMT Solvers

Example

VariableElimination

Proofbuilder

Modelbuilder

𝑏→5

𝑏→5 ,π‘Žβ†’6

Page 12: Internals of SMT Solvers

Model Converters

Extension Filter

Modelbuilder

𝑀

𝑀 ,𝑀 (π‘Ž)=𝑀 (𝑏)+1

Page 13: Internals of SMT Solvers

Model Converter: Filter

π‘βˆ¨(π‘žβˆ§h)

TseitinCNF converter

Modelbuilder

𝑀

𝑀 βˆ–π‘˜

Page 14: Internals of SMT Solvers

Model Converter: Filter

π‘βˆ¨(π‘žβˆ§h)

TseitinCNF converter

Modelbuilder

𝑝→ 𝑑 ,π‘˜β†’ 𝑓 ,π‘žβ†’ 𝑓 , h→𝑑

𝑝→ 𝑑 ,π‘žβ†’ 𝑓 , hβ†’ 𝑑

Page 15: Internals of SMT Solvers

Model Converter: Extension + Filter

Bit-blaster

Modelbuilder

𝑀

𝑀 β€²

Page 16: Internals of SMT Solvers

Preprocessors1. Produce Equivalent Formula2. Produce Equisatisfiable Formula3. Assume β€œclosed world” (non-incremental)Example: symmetry reduction

Page 17: Internals of SMT Solvers

Simple QF_BV (bit-vector) solver

Simplify

Variable elimination

𝐹

Bit-blasting

Tseitin CNF converter SAT Solver

Page 18: Internals of SMT Solvers

Under/Over-Approximations

Under-approximationunsat answers cannot be trusted

Over-approximationsat answers cannot be trusted

Page 19: Internals of SMT Solvers

Under/Over-Approximations

Under-approximationmodel finders

Over-approximationproof finders

Page 20: Internals of SMT Solvers

Under/Over-Approximations

Under-approximationS S S’

Over-approximationS S \ S’

Page 21: Internals of SMT Solvers

Under/Over-Approximations

Under-approximationExample: QF_NIA model finders

add bounds to unbounded variables (and blast)

Over-approximationExample: Boolean abstraction

Page 22: Internals of SMT Solvers

Under/Over-Approximations

Combining under and over is bad!sat and unsat answers cannot be trusted.

Page 23: Internals of SMT Solvers

Tracking: under/over-approximations

Proof and Model converters can check if the resultant models and proofs are valid.

Page 24: Internals of SMT Solvers

CEGAR is your friendCounter-Example Guided Abstract Refinement

procedure Solver(F)Fp := Abstract(F)loop

(R, M) := Solve(Fp)if R = UNSAT then return

UNSATR’ := Check(F, M)if R’ = SAT then return SAT Fp := Refine(F, Fp, M)

Using over-approximation

Model

Page 25: Internals of SMT Solvers

CEGAR is your friendCounter-Example Guided Abstract Refinement

procedure Solver(F)Fp := Abstract(F)loop

(R, Pr) := Solve(Fp)if R = SAT then return SATR’ := Check(F, Pr)if R’ = UNSAT then return

UNSATFp := Refine(F, Fp, M)

Using under-approximation

Proof

Page 26: Internals of SMT Solvers

CEGAR is your friendCounter-Example Guided Abstract Refinement

Refinements:

Incremental Solver

Run over and under-approximation is parallel

Page 27: Internals of SMT Solvers

Uninterpreted Functions by CEGAR

Suppose we have a Solver that does not supportuninterpreted functions (example: QF_BV solver)

Congruence Rule:

Page 28: Internals of SMT Solvers

Uninterpreted Functions by CEGARCongruence Rule:

Abstract: replace each f-application with a fresh variable(over-approximation)

π‘Ž=𝑏+1 , 𝑓 (π‘Žβˆ’1)=𝑐 , 𝑓 (𝑏)≠𝑐

π‘Ž=𝑏+1 ,π‘˜1=𝑐 ,π‘˜2≠𝑐

Page 29: Internals of SMT Solvers

Uninterpreted Functions by CEGARCongruence Rule:

Check: check if congruence rule is satisfied

π‘Ž=𝑏+1 ,π‘˜1=𝑐 ,π‘˜2≠𝑐

π‘Žβ†’1 ,𝑏→0 ,𝑐→0 ,π‘˜1β†’0 ,π‘˜2β†’1

Page 30: Internals of SMT Solvers

Uninterpreted Functions by CEGARCongruence Rule:

Refine: expand congruence axiom

π‘Ž=𝑏+1 ,π‘˜1=𝑐 ,π‘˜2≠𝑐

π‘Žβ†’1 ,𝑏→0 ,𝑐→0 ,π‘˜1β†’0 ,π‘˜2β†’1

Page 31: Internals of SMT Solvers

Uninterpreted Functions by CEGARCongruence Rule:

Refine: expand congruence axiom

unsatπ‘Žβˆ’1β‰ π‘βˆ¨π‘˜1=π‘˜2

Page 32: Internals of SMT Solvers

UF by CEGAR

Simple QF_UFBV Solver

QF_BVsolver

Page 33: Internals of SMT Solvers

AUF by CEGAR

Simple QF_AUFBV Solverarrays on top of UF

QF_BVsolver

Lemmas on Demand For Theory of Arrays [Brummayer-Biere 2009]

Page 34: Internals of SMT Solvers

Simple UFBV Solvermodel-based quantifier instantiation

MBQI

UF by CEGAR

QF_BVsolver

Efficiently solving quantified bit-vector formulas [Wintersteiger at al 2010]

Page 35: Internals of SMT Solvers

Simple QF_NIA β€œsolver” by CEGARnonlinear integer arithmetic

Hilbert’s 10th ProblemDPRM theorem: QF_NIA is undecidable

Idea: use (under-approximation) CEGAR1. Add lower/upper bounds to all variables, and convert

into QF_BV2. If SAT done3. Otherwise, refine: increase lower/upper bounds

Page 36: Internals of SMT Solvers

Lazy SMT as CEGARSuppose we have a Solver that can only process a conjunction of literals.

Examples: Congurence Closure (UF), Simplex (Linear Real Arithmetic)

Page 37: Internals of SMT Solvers

Lazy SMT as CEGAR: 1. AbstractBasic Idea

x 0, y = x + 1, (y > 2 y < 1)

p1, p2, (p3 p4) p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1)

[Audemard et al - 2002], [Barrett et al - 2002], [de Moura et al - 2002][Flanagan et al - 2003], …

Page 38: Internals of SMT Solvers

Lazy SMT as CEGAR: 2. SolveBasic Idea

x 0, y = x + 1, (y > 2 y < 1)

p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1)

p1, p2, (p3 p4)

SAT Solver

Page 39: Internals of SMT Solvers

Lazy SMT as CEGAR: 2. SolveBasic Idea

x 0, y = x + 1, (y > 2 y < 1)

p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1)

p1, p2, (p3 p4)

SAT Solver

Assignmentp1, p2, p3, p4

Page 40: Internals of SMT Solvers

Lazy SMT as CEGAR: 3. CheckBasic Idea

x 0, y = x + 1, (y > 2 y < 1)

p1, p2, (p3 p4)

SAT Solver

Assignmentp1, p2, p3, p4

p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1)

x 0, y = x + 1, (y > 2), y < 1

Page 41: Internals of SMT Solvers

Lazy SMT as CEGAR: 3. CheckBasic Idea

x 0, y = x + 1, (y > 2 y < 1)

p1, p2, (p3 p4)

SAT Solver

Assignmentp1, p2, p3, p4

p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1)

x 0, y = x + 1, (y > 2), y < 1

TheorySolver

Unsatisfiablex 0, y = x + 1, y <

1

Page 42: Internals of SMT Solvers

Lazy SMT as CEGAR: 4. RefineBasic Idea

x 0, y = x + 1, (y > 2 y < 1)

p1, p2, (p3 p4)

SAT Solver

Assignmentp1, p2, p3, p4

p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1)

x 0, y = x + 1, (y > 2), y < 1

TheorySolver

Unsatisfiablex 0, y = x + 1, y <

1

New Lemmap1p2p4

Page 43: Internals of SMT Solvers

Lazy SMT as CEGAR: 4. RefineBasic Idea

TheorySolver

Unsatisfiablex 0, y = x + 1, y <

1

New Lemmap1p2p4

AKATheory conflict

Page 44: Internals of SMT Solvers

Lazy SMT as CEGAR: refinements

Many refinements:IncrementalityEfficient BacktrackingEfficient Lemma GenerationTheory propagation - DPLL(T) [Ganzinger et all – 2004]

Many SMT solvers are based on DPLL(T)

Page 45: Internals of SMT Solvers

DPLL(T) weaknessTheories are β€œsecond-class citizens”.DPLL(T) is not model-driven (key property of CDCL).

Models

Proo

fsConflict

Resolution

Page 46: Internals of SMT Solvers

CDCL: Conflict Driven Clause Learning

Resolution

DPLLConflict

Resolution

Proof

Model

Page 47: Internals of SMT Solvers

DPLL(T) weakness

DPLL(T) works well only for β€œeasy” theories.Examples:

Uninterpreted functionsDifference logic ()Linear real arithmetic

β€œHard theories”:Linear integer arithmeticArraysNonlinear real arithmetic

Page 48: Internals of SMT Solvers

Example: Nonlinear Real Arithmetic

PSPACE

QF_NRANP-hardnessx is β€œBoolean” x (x-1) = 0 x or y or z x + y + z > 0

PSPACE membershipCanny – 1988,Grigor’ev – 1988

NP

Page 49: Internals of SMT Solvers

The RISE of Model-Driven Techniques in SMT

Page 50: Internals of SMT Solvers

Saturation x Search

Proof-finding Model-finding

Models

Proo

fsConflict

Resolution

Page 51: Internals of SMT Solvers

Two procedures

Resolution DPLLProof-finder Model-finderSaturation Search

CDCL is model-driven proof search

Page 52: Internals of SMT Solvers

Linear Arithmetic

Fourier-Motzkin SimplexProof-finder Model-finderSaturation Search

Page 53: Internals of SMT Solvers

Fourier-Motzkin

Very similar to Resolution

Exponential time and space

𝑑1β‰€π‘Žπ‘₯ ,𝑏π‘₯≀ 𝑑 2

𝑏𝑑1β‰€π‘Žπ‘π‘₯ ,π‘Žπ‘π‘₯β‰€π‘Žπ‘‘ 2

𝑏𝑑1β‰€π‘Žπ‘‘2

Page 54: Internals of SMT Solvers

Polynomial Constraints

AKAExistential Theory of the Reals

R

Page 55: Internals of SMT Solvers

CAD β€œBig Picture”1. Project/Saturate set of polynomials 2. Lift/Search: Incrementally build assignment

Isolate roots of polynomials Select a feasible cell , and assign some If there is no feasible cell, then backtrack

Page 56: Internals of SMT Solvers

CAD β€œBig Picture”π‘₯2+ 𝑦2βˆ’1<0π‘₯ π‘¦βˆ’1>0 1. Saturate

π‘₯4βˆ’π‘₯2+1

π‘₯π‘₯2βˆ’1

+ + + + + + ++ 0 - - - 0 +- - - 0 + + +

2. Search

Page 57: Internals of SMT Solvers

CAD β€œBig Pictureβ€π’™πŸ+π’šπŸβˆ’πŸ<0𝒙 π’š βˆ’πŸ>0 1. Saturate

π‘₯4βˆ’π‘₯2+1

π‘₯π‘₯2βˆ’1

+ + + + + + ++ 0 - - - 0 +- - - 0 + + +

π’™βˆ’πŸ

+ + ++ 0 -

2. Search

Page 58: Internals of SMT Solvers

CAD β€œBig Pictureβ€π’™πŸ+π’šπŸβˆ’πŸ<𝟎π‘₯ π‘¦βˆ’1>0 1. Saturate

π‘₯4βˆ’π‘₯2+1

π‘₯π‘₯2βˆ’1

+ + + + + + ++ 0 - - - 0 +- - - 0 + + +

π’™βˆ’πŸ

+ + ++ 0 -

2. Search

CONFLICT

Page 59: Internals of SMT Solvers

NLSat: Model-Driven SearchStatic x DynamicOptimistic approachKey ideas

Start the Search before Saturate/ProjectWe saturate on demandModel guides the saturation

Models

Proo

fs

Conflict

Resolution

Page 60: Internals of SMT Solvers

Experimental Results (1)OUR NEW ENGINE

Page 61: Internals of SMT Solvers

Experimental Results (2)

OUR NEW ENGINE

Page 62: Internals of SMT Solvers

Other examples

Delayed Theory Combination[Bruttomesso et al 2006]

Model-Based Theory CombinationX

Page 63: Internals of SMT Solvers

Other examples

Array Theory byAxiom Instantiation

Lemmas on DemandFor Theory of Array

[Brummayer-Biere 2009]X

Page 64: Internals of SMT Solvers

Other examples(for linear arithmetic)

Fourier-Motzkin

Generalizing DPLL to richer logics

[McMillan et al 2009]

Conflict Resolution[Korovin et al 2009]

X

Page 65: Internals of SMT Solvers

Saturation: successful instances

Polynomial time procedures

Gaussian EliminationCongruence Closure

Page 66: Internals of SMT Solvers

MCSat

Model-Driven SMTLift ideas from CDCL to SMT

Generalize ideas found in model-driven approachesEasier to implement

Model construction is explicit

Page 67: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

Page 68: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Propagations

Page 69: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Propagations

π‘₯β‰₯1

Page 70: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Propagations

π‘₯β‰₯1 𝑦 β‰₯1

Page 71: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Boolean Decisions

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1

Page 72: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Semantic Decisions

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1π‘₯β†’2

Page 73: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Conflict

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1π‘₯β†’2

We can’t find a value for s.t.

Page 74: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Conflict

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1π‘₯β†’2

We can’t find a value for s.t.

Learning that = 2)is not productive

Page 75: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1

Learning that = 2)is not productive

Β¬(π‘₯=2)

= 2)

Page 76: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1

Learning that = 2)is not productive

Β¬(π‘₯=2)

= 2)

π‘₯β†’3

Page 77: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1

Learning that = 2)is not productive

Β¬(π‘₯=2)

= 2)

π‘₯β†’3

β€œSame” Conflict

We can’t find a value for s.t.

Page 78: Internals of SMT Solvers

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2

Conflict

π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1π‘₯β†’2

𝑦

π‘₯

π‘₯2+ 𝑦2≀1 π‘₯β†’2

βˆ’1≀ π‘₯ , π‘₯≀1

Β¬(π‘₯2+ 𝑦2≀1)∨π‘₯≀1

Page 79: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1

Page 80: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1ConflictΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯≀1)

Page 81: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1Learned by resolutionΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯2+𝑦2≀1)

Page 82: Internals of SMT Solvers

MCSat

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1Β¬(π‘₯2+𝑦2≀1)

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1Β¬ (π‘₯β‰₯2 )∨¬(π‘₯2+𝑦2≀1)

Page 83: Internals of SMT Solvers

MCSat: FM Example

, 𝑧→0 , 𝑦→0

, ≑

,

βˆ’π‘₯+𝑧+1≀0𝑧→0 𝑦→0π‘₯βˆ’ 𝑦 ≀0

We can’t find a value of

Page 84: Internals of SMT Solvers

MCSat: FM Example

, 𝑧→0 , 𝑦→0

𝑧+1βˆ’ 𝑦 ≀0

βˆ’π‘₯+𝑧+1≀0𝑧→0 𝑦→0π‘₯βˆ’ 𝑦 ≀0

Β¬ (βˆ’π‘₯+𝑧+1≀ 0 )∨¬ (π‘₯βˆ’ 𝑦 ≀0 )βˆ¨π‘§+1βˆ’ 𝑦 ≀0

Fourier-Motzkin

Page 85: Internals of SMT Solvers

MCSat: FM Example

βˆ’π‘₯+𝑧+1≀0𝑧→0 𝑧+1βˆ’ 𝑦 ≀0π‘₯βˆ’ 𝑦 ≀0

Β¬ (βˆ’π‘₯+𝑧+1≀ 0 )∨¬ (π‘₯βˆ’ 𝑦 ≀0 )βˆ¨π‘§+1βˆ’ 𝑦 ≀0

Page 86: Internals of SMT Solvers

MCSat: FM Example

βˆ’π‘₯+𝑧+1≀0𝑧→0 𝑧+1βˆ’ 𝑦 ≀0π‘₯βˆ’ 𝑦 ≀0

Β¬ (βˆ’π‘₯+𝑧+1≀ 0 )∨¬ (π‘₯βˆ’ 𝑦 ≀0 )βˆ¨π‘§+1βˆ’ 𝑦 ≀0

𝑦→1

, 𝑧→0 , 𝑦→1

, ≑

,

Page 87: Internals of SMT Solvers

MCSat: FM Example

βˆ’π‘₯+𝑧+1≀0𝑧→0 𝑧+1βˆ’ 𝑦 ≀0π‘₯βˆ’ 𝑦 ≀0

Β¬ (βˆ’π‘₯+𝑧+1≀ 0 )∨¬ (π‘₯βˆ’ 𝑦 ≀0 )βˆ¨π‘§+1βˆ’ 𝑦 ≀0

𝑦→1

, 𝑧→0 , 𝑦→1

, ≑

,

π‘₯β†’1

Page 88: Internals of SMT Solvers

MCSat: Another Exampleβˆ’4 π‘₯π‘¦βˆ’4 π‘₯+ 𝑦>1 ,π‘₯2+ 𝑦2<1 ,π‘₯3+2π‘₯2+3 𝑦2βˆ’5<0

Page 89: Internals of SMT Solvers

MCSat: Another Example

π‘₯3+2π‘₯2+3 𝑦 2βˆ’5<0

π‘₯2+ 𝑦2<1

βˆ’4 π‘₯π‘¦βˆ’4 π‘₯+ 𝑦>1

Feasible Region

Starting searchPartial solution:

Can we extend it to ?

What is the core?

βˆ’4 π‘₯π‘¦βˆ’4 π‘₯+ 𝑦>1 ,π‘₯2+ 𝑦2<1 ,π‘₯3+2π‘₯2+3 𝑦2βˆ’5<0

Page 90: Internals of SMT Solvers

MCSat: Another Example

π‘₯3+2π‘₯2+3 𝑦 2βˆ’5<0

π‘₯2+ 𝑦2<1

βˆ’4 π‘₯π‘¦βˆ’4 π‘₯+ 𝑦>1

Feasible Region

Starting searchPartial solution:

Can we extend it to ?

What is the core?

βˆ’4 π‘₯π‘¦βˆ’4 π‘₯+ 𝑦>1 ,π‘₯2+ 𝑦2<1 ,π‘₯3+2π‘₯2+3 𝑦2βˆ’5<0

Page 91: Internals of SMT Solvers

MCSat – Finite BasisEvery theory that admits quantifier elimination has a finite basis (given a fixed assignment order)

𝐹 [π‘₯ , 𝑦1 ,…, π‘¦π‘š]

βˆƒπ‘₯ :𝐹 [π‘₯ , 𝑦1 ,…, π‘¦π‘š]

𝐢1[𝑦1 ,…, π‘¦π‘š]βˆ§β€¦βˆ§πΆπ‘˜[𝑦1 ,…, π‘¦π‘š ]

¬𝐹 [π‘₯ , 𝑦1 ,…, π‘¦π‘š ]βˆ¨πΆπ‘˜[𝑦1 ,…, π‘¦π‘š ]

Page 92: Internals of SMT Solvers

MCSat – Finite Basis

𝐹 1[π‘₯1]

𝐹 2[π‘₯1 ,π‘₯2]

𝐹 𝑛[π‘₯1 ,π‘₯2,…, π‘₯π‘›βˆ’1 ,π‘₯𝑛]

𝐹 π‘›βˆ’1[π‘₯1 ,π‘₯2 ,…, π‘₯π‘›βˆ’1]…

Page 93: Internals of SMT Solvers

MCSat – Finite Basis

𝐹 1[π‘₯1]

𝐹 2[π‘₯1 ,π‘₯2]

𝐹 𝑛[π‘₯1 ,π‘₯2,…, π‘₯π‘›βˆ’1 ,π‘₯𝑛]

𝐹 π‘›βˆ’1[π‘₯1 ,π‘₯2 ,…, π‘₯π‘›βˆ’1]…

Page 94: Internals of SMT Solvers

MCSat – Finite Basis

𝐹 1[π‘₯1]

𝐹 2[π‘₯1 ,π‘₯2]

𝐹 𝑛[π‘₯1 ,π‘₯2,…, π‘₯π‘›βˆ’1 ,π‘₯𝑛]

𝐹 π‘›βˆ’1[π‘₯1 ,π‘₯2 ,…, π‘₯π‘›βˆ’1]…

Page 95: Internals of SMT Solvers

MCSat – Finite Basis

𝐹 1[π‘₯1]

𝐹 2[π‘₯1 ,π‘₯2]

𝐹 𝑛[π‘₯1 ,π‘₯2,…, π‘₯π‘›βˆ’1 ,π‘₯𝑛]

𝐹 π‘›βˆ’1[π‘₯1 ,π‘₯2 ,…, π‘₯π‘›βˆ’1]…

Page 96: Internals of SMT Solvers

MCSat – Finite BasisEvery β€œfinite” theory has a finite basisExample: Fixed size Bit-vectors

𝐹 [π‘₯ , 𝑦1 ,…, π‘¦π‘š]

¬𝐹 [π‘₯ , 𝑦1 ,…, π‘¦π‘š ]∨¬(𝑦1=𝛼1)βˆ¨β€¦βˆ¨Β¬(π‘¦ΒΏΒΏπ‘š=π›Όπ‘š)ΒΏ

Page 97: Internals of SMT Solvers

MCSat – Finite BasisTheory of uninterpreted functions has a finite basis

Theory of arrays has a finite basis [Brummayer- Biere 2009]

In both cases the Finite Basis is essentially composed of equalities between existing terms.

Page 98: Internals of SMT Solvers

MCSat: Uninterpreted Functions

π‘Ž=𝑏+1 , 𝑓 (π‘Žβˆ’1 )<𝑐 , 𝑓 (𝑏 )>π‘Ž

π‘Ž=𝑏+1 , 𝑓 (π‘˜ )<𝑐 , 𝑓 (𝑏 )>π‘Ž ,π‘˜=π‘Žβˆ’1

π‘Ž=𝑏+1 , 𝑓 (π‘˜ )<𝑐 , 𝑓 (𝑏 )>π‘Ž ,π‘˜=π‘Žβˆ’1

Treat and as variablesGeneralized variables

Page 99: Internals of SMT Solvers

MCSat: Uninterpreted Functionsπ‘Ž=𝑏+1 , 𝑓 (π‘˜ )<𝑐 , 𝑓 (𝑏 )>π‘Ž ,π‘˜=π‘Žβˆ’1

π‘˜β†’0𝑏→0𝑓 (π‘˜)β†’0𝑓 (𝑏)β†’2

Conflict: and must be equal

Β¬ (π‘˜=𝑏)∨ 𝑓 (π‘˜ )= 𝑓 (𝑏)

Page 100: Internals of SMT Solvers

MCSat: Uninterpreted Functionsπ‘Ž=𝑏+1 , 𝑓 (π‘˜ )<𝑐 , 𝑓 (𝑏 )>π‘Ž ,π‘˜=π‘Žβˆ’1

π‘˜β†’0𝑏→0𝑓 (π‘˜)β†’0

Β¬ (π‘˜=𝑏)∨ 𝑓 (π‘˜ )= 𝑓 (𝑏)

π‘˜=𝑏

(Semantic) Propagation

Page 101: Internals of SMT Solvers

MCSat: Uninterpreted Functionsπ‘Ž=𝑏+1 , 𝑓 (π‘˜ )<𝑐 , 𝑓 (𝑏 )>π‘Ž ,π‘˜=π‘Žβˆ’1

π‘˜β†’0𝑏→0𝑓 (π‘˜)β†’0

Β¬ (π‘˜=𝑏)∨ 𝑓 (π‘˜ )= 𝑓 (𝑏)

π‘˜=𝑏 𝑓 (π‘˜ )= 𝑓 (𝑏)

Page 102: Internals of SMT Solvers

MCSat: Uninterpreted Functionsπ‘Ž=𝑏+1 , 𝑓 (π‘˜ )<𝑐 , 𝑓 (𝑏 )>π‘Ž ,π‘˜=π‘Žβˆ’1

π‘˜β†’0𝑏→0𝑓 (π‘˜)β†’0

Β¬ (π‘˜=𝑏)∨ 𝑓 (π‘˜ )= 𝑓 (𝑏)

π‘˜=𝑏 𝑓 (π‘˜ )= 𝑓 (𝑏)𝑓 (𝑏)β†’0

Page 103: Internals of SMT Solvers

MCSat – Finite BasisWe can also use literals from the finite basis in decisions.

Application: simulate branch&bound for bounded linear integer arithmetic

LP solution:

1 2 3 4 5 6π‘₯1

123456

0

π‘₯2

π‘₯1β‰₯1π‘₯1≀0

Page 104: Internals of SMT Solvers

MCSat: Termination

Propagations

Boolean Decisions

Semantic Decisions

Page 105: Internals of SMT Solvers

MCSat

≻Propagations

Boolean Decisions

Semantic Decisions

Page 106: Internals of SMT Solvers

MCSat

≻

Propagations

Boolean Decisions

Semantic Decisions

Page 107: Internals of SMT Solvers

MCSat

ΒΏπΉπ‘–π‘›π‘–π‘‘π‘’π΅π‘Žπ‘ π‘–π‘ βˆ¨ΒΏ

…Maximal Elements

…

Page 108: Internals of SMT Solvers

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1ConflictΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯≀1)

Page 109: Internals of SMT Solvers

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1ConflictΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯≀1)

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1Β¬(π‘₯2+𝑦2≀1)

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1Β¬ (π‘₯β‰₯2 )∨¬(π‘₯2+𝑦2≀1)

Page 110: Internals of SMT Solvers

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1π‘₯2+ 𝑦2≀1 π‘₯≀1

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1ConflictΒ¬ (π‘₯β‰₯2 )∨¬(π‘₯≀1)

π‘₯β‰₯2 , (Β¬π‘₯β‰₯1∨ 𝑦 β‰₯1 ) ,(π‘₯2+ 𝑦2≀1∨π‘₯𝑦>1)

π‘₯β‰₯2 π‘₯β‰₯1 𝑦 β‰₯1Β¬(π‘₯2+𝑦2≀1)

Β¬(π‘₯2+𝑦2≀1)∨π‘₯≀1Β¬ (π‘₯β‰₯2 )∨¬(π‘₯2+𝑦2≀1)

Page 111: Internals of SMT Solvers

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

Page 112: Internals of SMT Solvers

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

Page 113: Internals of SMT Solvers

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

Conflict (evaluates to false)

Page 114: Internals of SMT Solvers

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

New clauseπ‘₯<1∨π‘₯=2

Page 115: Internals of SMT Solvers

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

New clauseπ‘₯<1∨π‘₯=2

π‘₯<1

Page 116: Internals of SMT Solvers

π‘₯<1βˆ¨π‘ ,Β¬π‘βˆ¨π‘₯=2

π‘₯β†’1

MCSat

𝑝

New clauseπ‘₯<1∨π‘₯=2

π‘₯<1

Page 117: Internals of SMT Solvers

MCSat: Architecture

Arithmetic

Boolean Lists

Arrays

Page 118: Internals of SMT Solvers

MCSat: development

Page 119: Internals of SMT Solvers

MCSat prototype: 7k lines of codeDeduction Rules

Boolean Resolution

Fourier-Motzkin

Equality Split

Ackermann expansionaka Congruence

Normalization

Page 120: Internals of SMT Solvers

MCSat: preliminary resultsprototype: 7k lines of code

QF_LRA

Page 121: Internals of SMT Solvers

MCSat: preliminary resultsprototype: 7k lines of code

QF_UFLRA and QF_UFLIA

Page 122: Internals of SMT Solvers

ConclusionMode-driven techniques are very promising

Preprocessing

MCSat: new framework for developing SMT solversMCSat generalizes NLSat

Modular architecture

CEGAR

Page 123: Internals of SMT Solvers

Resources: PapersThe Strategy Challenge in SMT Solving, L. de Moura and G. Passmore.http://research.microsoft.com/en-us/um/people/leonardo/files/smt-strategy.pdf

Solving non-linear arithmetic, D. Jovanovic and L. de Mourahttp://research.microsoft.com/en-us/um/people/leonardo/files/IJCAR2012.pdf

A Model Constructing Satisfiability Calculus, L. de Moura and D. Jovanonichttp://research.microsoft.com/en-us/um/people/leonardo/files/mcsat.pdf

The Design and Implementation of the Model Constructing Satisfiability Calculus, D. Jovanovic, C. Barrett , L. de Mourahttp://research.microsoft.com/en-us/um/people/leonardo/mcsat_design.pdf

Page 124: Internals of SMT Solvers

Resources: Source Code

nlsathttps://z3.codeplex.com/SourceControl/latest#src/nlsat/

mcsathttps://github.com/dddejan/CVC4/tree/mcsat

tactic/preprocessorshttps://z3.codeplex.com/SourceControl/latest#src/tactic/


Top Related