Internals of SMT Solvers Leonardo de Moura Microsoft Research Acknowledgements • Dejan Jovanovic (SRI International, NYU) • Grant Passmore (Univ.
Download
Report
Transcript Internals of SMT Solvers Leonardo de Moura Microsoft Research Acknowledgements • Dejan Jovanovic (SRI International, NYU) • Grant Passmore (Univ.
Internals of SMT Solvers
Leonardo de Moura
Microsoft Research
Acknowledgements
โข Dejan Jovanovic (SRI International, NYU)
โข Grant Passmore (Univ. Edinburgh)
Herbrand Award 2013
Greg Nelson
What is a SMT Solver?
Multiple Approaches
is a portfolio of solvers
Preprocessing
๐น
Modular Architecture is
a โmust haveโ
Simplify
Variable elimination
if-then-else elimination
โฆ
Solver
Equivalence Preserving Simplifications
๐น
Simplify
๐นโฒ
Examples:
๐ฅ+๐ฆ+1โ๐ฅโ2 โฆ ๐ฆ โ1
๐ โง ๐ก๐๐ข๐ โง ๐ โฆ ๐
Preprocessor API
๐น and ๐นโ may be
only equisatisfiable
๐น
Preprocessor
๐นโฒ
Model
Converter
Proof
Converter
Example
Variable
Elimination
Proof
builder
Model
builder
Example
Variable
Elimination
Proof
builder
๐, ๐(๐) = ๐(๐) + 1
Model
builder
๐
Example
Variable
Elimination
Proof
builder
๐ โ 5, ๐ โ 6
Model
builder
๐โ5
Model Converters
Extension
๐, ๐(๐) = ๐(๐) + 1
Model
builder
๐
Filter
Model Converter: Filter
๐ โจ (๐ โง โ)
Tseitin
CNF converter
๐ โจ ๐,
¬๐ โจ ๐, ¬๐ โจ โ, ๐ โจ ¬๐ โจ ¬โ
๐โ๐
Model
builder
๐
Model Converter: Filter
๐ โจ (๐ โง โ)
Tseitin
CNF converter
๐ โ ๐ก, ๐ โ ๐, โ โ ๐ก
๐ โจ ๐,
¬๐ โจ ๐, ¬๐ โจ โ, ๐ โจ ¬๐ โจ ¬โ
Model
builder
๐ โ ๐ก, ๐ โ ๐, ๐ โ ๐, โ โ ๐ก
Model Converter: Extension + Filter
๐ฅ: ๐๐๐ก๐ฃ๐๐ 4 ,
๐ฆ, ๐ง: ๐๐๐ก๐ฃ๐๐[2]
๐ฅ = ๐๐๐๐๐๐ก(๐ฆ, ๐ง)
Bit-blaster
๐ฅ3 โ ๐ฆ1 , ๐ฅ2 โ ๐ฆ0 ,
๐ฅ1 โ ๐ง1 , ๐ฅ0 โ ๐ง0
๐โฒ
Model
builder
๐
Preprocessors
1. Produce Equivalent Formula
2. Produce Equisatisfiable Formula
3. Assume โclosed worldโ (non-incremental)
Example: symmetry reduction
Simple QF_BV (bit-vector) solver
๐น
Simplify
Variable elimination
Bit-blasting
Tseitin CNF converter
SAT Solver
Under/Over-Approximations
Under-approximation
unsat answers cannot be trusted
Over-approximation
sat answers cannot be trusted
Under/Over-Approximations
Under-approximation
model finders
Over-approximation
proof finders
Under/Over-Approximations
Under-approximation
S ๏ฎ S ๏ Sโ
Over-approximation
S ๏ฎ S \ Sโ
Under/Over-Approximations
Under-approximation
Example: QF_NIA model finders
add bounds to unbounded variables (and blast)
Over-approximation
Example: Boolean abstraction
Under/Over-Approximations
Combining under and over is bad!
sat and unsat answers cannot be trusted.
Tracking: under/overapproximations
Proof and Model converters can check if the
resultant models and proofs are valid.
CEGAR is your friend
Counter-Example Guided Abstract Refinement
Using over-approximation
procedure Solver(F)
Model
Fp := Abstract(F)
loop
(R, M) := Solve(Fp)
if R = UNSAT then return UNSAT
Rโ := Check(F, M)
if Rโ = SAT then return SAT
Fp := Refine(F, Fp, M)
CEGAR is your friend
Counter-Example Guided Abstract Refinement
Using under-approximation
procedure Solver(F)
Proof
Fp := Abstract(F)
loop
(R, Pr) := Solve(Fp)
if R = SAT then return SAT
Rโ := Check(F, Pr)
if Rโ = UNSAT then return UNSAT
Fp := Refine(F, Fp, M)
CEGAR is your friend
Counter-Example Guided Abstract Refinement
Refinements:
Incremental Solver
Run over and under-approximation is parallel
Uninterpreted Functions by CEGAR
Suppose we have a Solver that does not support
uninterpreted functions (example: QF_BV solver)
Congruence Rule:
๐ฅ1 = ๐ฆ1, โฆ , ๐ฅ๐ = ๐ฆ๐ โ ๐(๐ฅ1, โฆ , ๐ฅ๐) = ๐(๐ฆ1, โฆ , ๐ฆ๐)
Uninterpreted Functions by CEGAR
Congruence Rule:
๐ฅ1 = ๐ฆ1, โฆ , ๐ฅ๐ = ๐ฆ๐ โ ๐(๐ฅ1, โฆ , ๐ฅ๐)
Abstract: replace each f-application with a fresh variable
(over-approximation)
๐ = ๐ + 1, ๐(๐ โ 1) = ๐, ๐(๐) โ ๐
๐1 โก ๐ ๐ โ 1 ,
๐2 โก ๐(๐)
๐ = ๐ + 1, ๐1 = ๐, ๐2 โ ๐
Uninterpreted Functions by CEGAR
Congruence Rule:
๐ฅ1 = ๐ฆ1, โฆ , ๐ฅ๐ = ๐ฆ๐ โ ๐(๐ฅ1, โฆ , ๐ฅ๐)
Check: check if congruence rule is satisfied
๐ = ๐ + 1, ๐1 = ๐, ๐2 โ ๐
๐1 โก ๐ ๐ โ 1 ,
๐2 โก ๐(๐)
๐ โ 1, ๐ โ 0, ๐ โ 0, ๐1 โ 0, ๐2 โ 1
Uninterpreted Functions by CEGAR
Congruence Rule:
๐ฅ1 = ๐ฆ1, โฆ , ๐ฅ๐ = ๐ฆ๐ โ ๐(๐ฅ1, โฆ , ๐ฅ๐)
Refine: expand congruence axiom ๐ โ 1 = ๐ โ ๐1 = ๐2
๐ = ๐ + 1, ๐1 = ๐, ๐2 โ ๐
๐1 โก ๐ ๐ โ 1 ,
๐2 โก ๐(๐)
๐ โ 1, ๐ โ 0, ๐ โ 0, ๐1 โ 0, ๐2 โ 1
Uninterpreted Functions by CEGAR
Congruence Rule:
๐ฅ1 = ๐ฆ1, โฆ , ๐ฅ๐ = ๐ฆ๐ โ ๐(๐ฅ1, โฆ , ๐ฅ๐)
Refine: expand congruence axiom ๐ โ 1 = ๐ โ ๐1 = ๐2
๐ = ๐ + 1, ๐1 = ๐, ๐2 โ ๐, (๐ โ 1 = ๐ โ ๐1 = ๐2 )
๐ โ 1 โ ๐ โจ ๐1 = ๐2
unsat
Simple QF_UFBV Solver
UF by CEGAR
QF_BV
solver
Simple QF_AUFBV Solver
arrays on top of UF
AUF by CEGAR
QF_BV
solver
Lemmas on Demand For Theory of Arrays [Brummayer-Biere 2009]
Simple UFBV Solver
model-based quantifier instantiation
MBQI
UF by CEGAR
QF_BV
solver
Efficiently solving quantified bit-vector formulas [Wintersteiger at al 2010]
Simple QF_NIA โsolverโ by CEGAR
nonlinear integer arithmetic
Hilbertโs 10th Problem
DPRM theorem: QF_NIA is undecidable
Idea: use (under-approximation) CEGAR
1. Add lower/upper bounds to all variables, and convert
into QF_BV
2. If SAT ๏ done
3. Otherwise, refine: increase lower/upper bounds
Lazy SMT as CEGAR
Suppose we have a Solver that can only process a conjunction of
literals.
Examples:
Congurence Closure (UF),
Simplex (Linear Real Arithmetic)
Lazy SMT as CEGAR: 1. Abstract
Basic 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], โฆ
Lazy SMT as CEGAR: 2. Solve
Basic Idea
x ๏ณ 0, y = x + 1, (y > 2 ๏ y < 1)
p1, p2, (p3 ๏ p4)
SAT
Solver
p1 ๏บ (x ๏ณ 0), p2 ๏บ (y = x + 1),
p3 ๏บ (y > 2), p4 ๏บ (y < 1)
Lazy SMT as CEGAR: 2. Solve
Basic Idea
x ๏ณ 0, y = x + 1, (y > 2 ๏ y < 1)
p1, p2, (p3 ๏ p4)
SAT
Solver
p1 ๏บ (x ๏ณ 0), p2 ๏บ (y = x + 1),
p3 ๏บ (y > 2), p4 ๏บ (y < 1)
Assignment
p1, p2, ๏p3, p4
Lazy SMT as CEGAR: 3. Check
Basic Idea
x ๏ณ 0, y = x + 1, (y > 2 ๏ y < 1)
p1, p2, (p3 ๏ p4)
SAT
Solver
p1 ๏บ (x ๏ณ 0), p2 ๏บ (y = x + 1),
p3 ๏บ (y > 2), p4 ๏บ (y < 1)
Assignment
p1, p2, ๏p3, p4
x ๏ณ 0, y = x + 1,
๏(y > 2), y < 1
Lazy SMT as CEGAR: 3. Check
Basic Idea
x ๏ณ 0, y = x + 1, (y > 2 ๏ y < 1)
p1, p2, (p3 ๏ p4)
SAT
Solver
p1 ๏บ (x ๏ณ 0), p2 ๏บ (y = x + 1),
p3 ๏บ (y > 2), p4 ๏บ (y < 1)
Assignment
p1, p2, ๏p3, p4
Unsatisfiable
x ๏ณ 0, y = x + 1, y < 1
x ๏ณ 0, y = x + 1,
๏(y > 2), y < 1
Theory
Solver
Lazy SMT as CEGAR: 4. Refine
Basic Idea
x ๏ณ 0, y = x + 1, (y > 2 ๏ y < 1)
p1, p2, (p3 ๏ p4)
SAT
Solver
New Lemma
๏p1๏๏p2๏๏p4
p1 ๏บ (x ๏ณ 0), p2 ๏บ (y = x + 1),
p3 ๏บ (y > 2), p4 ๏บ (y < 1)
Assignment
p1, p2, ๏p3, p4
Unsatisfiable
x ๏ณ 0, y = x + 1, y < 1
x ๏ณ 0, y = x + 1,
๏(y > 2), y < 1
Theory
Solver
Lazy SMT as CEGAR: 4. Refine
Basic Idea
New Lemma
๏p1๏๏p2๏๏p4
Unsatisfiable
x ๏ณ 0, y = x + 1, y < 1
AKA
Theory conflict
Theory
Solver
Lazy SMT as CEGAR: refinements
Many refinements:
Incrementality
Efficient Backtracking
Efficient Lemma Generation
Theory propagation - DPLL(T) [Ganzinger et all โ 2004]
Many SMT solvers are based on DPLL(T)
DPLL(T) weakness
Proofs
Theories are โsecond-class citizensโ.
DPLL(T) is not model-driven (key property of CDCL).
Models
CDCL: Conflict Driven Clause Learning
DPLL
Resolution
Model
Proof
DPLL(T) weakness
DPLL(T) works well only for โeasyโ theories.
Examples:
Uninterpreted functions
Difference logic (๐ฅ โ ๐ฆ โค ๐)
Linear real arithmetic
โHard theoriesโ:
Linear integer arithmetic
Arrays
Nonlinear real arithmetic
Example: Nonlinear Real Arithmetic
๐ฅ 2 โ 4๐ฅ + ๐ฆ 2 โ ๐ฆ + 8 < 1
๐ฅ๐ฆ โ 2๐ฅ โ 2๐ฆ + 4 > 1
PSPACE
PSPACE membership
Canny โ 1988,
Grigorโev โ 1988
QF_NRA
NP
NP-hardness
x is โBooleanโ๏ฎ x (x-1) = 0
x or y or z
๏ฎ x+y+z>0
The RISE of Model-Driven
Techniques in SMT
Saturation x Search
Model-finding
Proofs
Proof-finding
Models
Two procedures
Resolution
Proof-finder
Saturation
DPLL
Model-finder
Search
CDCL is model-driven
proof search
Linear Arithmetic
Fourier-Motzkin
Proof-finder
Saturation
Simplex
Model-finder
Search
Fourier-Motzkin
๐ก1 โค ๐๐ฅ,
๐๐ก1 โค ๐๐๐ฅ,
๐๐ฅ โค ๐ก2
๐๐๐ฅ โค ๐๐ก2
๐๐ก1 โค ๐๐ก2
Very similar to Resolution
Exponential time and space
Polynomial Constraints
AKA
Existential Theory of the Reals
๏คR
๐ฅ 2 โ 4๐ฅ + ๐ฆ 2 โ ๐ฆ + 8 < 1
๐ฅ๐ฆ โ 2๐ฅ โ 2๐ฆ + 4 > 1
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
CAD โBig Pictureโ
2
๐ฅ4 โ ๐ฅ2 + 1
2
๐ฅ +๐ฆ โ1<0
๐ฅ๐ฆ โ1>0
1. Saturate
๐ฅ2 โ 1
๐ฅ
2. Search
(โโ, โ๐)
โ๐
(โ๐, ๐)
๐
(๐, ๐)
๐
(๐, โ)
๐ฅ4 โ ๐ฅ2 + 1
+
+
+
+
+
+
+
๐ฅ2 โ 1
+
0
-
-
-
0
+
๐ฅ
-
-
-
0
+
+
+
CAD โBig Pictureโ
๐
๐ฅ4 โ ๐ฅ2 + 1
๐
๐ +๐ โ๐<0
๐๐ โ๐>0
1. Saturate
๐ฅ2 โ 1
๐ฅ
๐
(โโ, โ )
๐
๐
๐
โ (โ , โ)
๐
๐
4 + ๐ฆ2 โ 1
+
+
+
โ2y โ 1
+
0
-
๐๏ฎ โ ๐
2. Search
(โโ, โ๐)
โ๐
(โ๐, ๐)
๐
(๐, ๐)
๐
(๐, โ)
๐ฅ4 โ ๐ฅ2 + 1
+
+
+
+
+
+
+
๐ฅ2 โ 1
+
0
-
-
-
0
+
๐ฅ
-
-
-
0
+
+
+
CAD โBig Pictureโ
๐
๐ฅ4 โ ๐ฅ2 + 1
๐
๐ +๐ โ๐<๐
๐ฅ๐ฆ โ1>0
1. Saturate
๐ฅ2 โ 1
๐ฅ
๐
(โโ, โ )
๐
๐
๐
โ (โ , โ)
๐
๐
๐ + ๐๐ โ ๐
+
+
+
โ2y โ 1
+
0
-
๐๏ฎ โ ๐
CONFLICT
2. Search
(โโ, โ๐)
โ๐
(โ๐, ๐)
๐
(๐, ๐)
๐
(๐, โ)
๐ฅ4 โ ๐ฅ2 + 1
+
+
+
+
+
+
+
๐ฅ2 โ 1
+
0
-
-
-
0
+
๐ฅ
-
-
-
0
+
+
+
Models
Static x Dynamic
Optimistic approach
Key ideas
Proofs
NLSat: Model-Driven Search
Start the Search before Saturate/Project
We saturate on demand
Model guides the saturation
Experimental Results (1)
OUR NEW ENGINE
Experimental Results (2)
OUR NEW ENGINE
Other examples
Delayed
Theory Combination
[Bruttomesso et al 2006]
X
Model-Based
Theory Combination
Other examples
Array Theory by
Axiom Instantiation
X
Lemmas on Demand
For Theory of Array
[Brummayer-Biere 2009]
โ๐, ๐, ๐ฃ: ๐ ๐ โ ๐ฃ ๐ = ๐ฃ
โ๐, ๐, ๐, ๐ฃ: ๐ = ๐ โจ ๐ ๐ โ ๐ฃ ๐ = ๐[๐]
Other examples
(for linear arithmetic)
Generalizing DPLL to
richer logics
Fourier-Motzkin
X
[McMillan et al 2009]
Conflict Resolution
[Korovin et al 2009]
Saturation: successful instances
Polynomial time procedures
Gaussian Elimination
Congruence Closure
MCSat
Model-Driven SMT
Lift ideas from CDCL to SMT
Generalize ideas found in model-driven approaches
Easier to implement
Model construction is explicit
MCSat
๐ฅ โฅ 2,
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
MCSat
๐ฅ โฅ 2,
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฅโฅ2
Propagations
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฅโฅ1
Propagations
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆโฅ1
Propagations
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
Boolean Decisions
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1 ๐ฅ โ 2
Semantic Decisions
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1 ๐ฅ โ 2
Conflict
We canโt find a value for ๐ฆ
s.t. 4 + ๐ฆ 2 โค 1
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1 ๐ฅ โ 2
Conflict
We canโt find a value for ๐ฆ
s.t. 4 + ๐ฆ 2 โค 1
Learning that
¬ ๐ฅ 2 + ๐ฆ 2 โค 1 โจ ¬(๐ฅ= 2)
is not productive
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
¬(๐ฅ = 2)
¬ ๐ฅ 2 + ๐ฆ 2 โค 1 โจ ¬(๐ฅ = 2)
Learning that
¬ ๐ฅ 2 + ๐ฆ 2 โค 1 โจ ¬(๐ฅ= 2)
is not productive
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
¬(๐ฅ = 2) ๐ฅ โ 3
¬ ๐ฅ 2 + ๐ฆ 2 โค 1 โจ ¬(๐ฅ = 2)
Learning that
¬ ๐ฅ 2 + ๐ฆ 2 โค 1 โจ ¬(๐ฅ= 2)
is not productive
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
โSameโ Conflict
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
¬(๐ฅ = 2) ๐ฅ โ 3
¬ ๐ฅ 2 + ๐ฆ 2 โค 1 โจ ¬(๐ฅ = 2)
We canโt find a value for ๐ฆ
s.t. 9 + ๐ฆ 2 โค 1
Learning that
¬ ๐ฅ 2 + ๐ฆ 2 โค 1 โจ ¬(๐ฅ= 2)
is not productive
๐ฅ โฅ 2,
๐ฅโฅ2
๐ฆ
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1 ๐ฅ โ 2
Conflict
๐ฅ2 + ๐ฆ2 โค 1
๐ฅ
๐ฅโ2
โ1 โค ๐ฅ, ๐ฅ โค 1
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
๐ฅโค1
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
๐ฅโค1
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
Conflict
¬ ๐ฅ โฅ 2 โจ ¬(๐ฅ โค 1)
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
Learned by resolution
¬ ๐ฅ โฅ 2 โจ ¬(๐ฅ 2 + ๐ฆ 2 โค 1)
MCSat
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ¬(๐ฅ 2 + ๐ฆ 2 โค 1)
¬ ๐ฅ โฅ 2 โจ ¬(๐ฅ 2 + ๐ฆ 2 โค 1)
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
MCSat: FM Example
โ๐ฅ + ๐ง + 1 โค 0 ๐ง โ 0
โ๐ฅ + ๐ง + 1 โค 0,
โก
๐ง + 1 โค ๐ฅ,
๐ฅโ๐ฆ โค0
๐ฅโ๐ฆ โค0
๐ฆโ0
๐ง โ 0,
๐ฅโค๐ฆ
1 โค ๐ฅ,
๐ฅโค0
We canโt find a value of ๐ฅ
๐ฆโ0
MCSat: FM Example
โ๐ฅ + ๐ง + 1 โค 0 ๐ง โ 0
โ๐ฅ + ๐ง + 1 โค 0,
๐ฅโ๐ฆ โค0
๐ฅโ๐ฆ โค0
๐ฆโ0
๐ง โ 0,
๐ฆโ0
โ๐ฅ: โ๐ฅ + ๐ง + 1 โค 0 โง ๐ฅ โ ๐ฆ โค 0
๐ง+1โ๐ฆ โค0
Fourier-Motzkin
¬ โ๐ฅ + ๐ง + 1 โค 0 โจ ¬ ๐ฅ โ ๐ฆ โค 0 โจ ๐ง + 1 โ ๐ฆ โค 0
MCSat: FM Example
โ๐ฅ + ๐ง + 1 โค 0 ๐ง โ 0
๐ฅโ๐ฆ โค0
๐ง+1โ๐ฆ โค0
¬ โ๐ฅ + ๐ง + 1 โค 0 โจ ¬ ๐ฅ โ ๐ฆ โค 0 โจ ๐ง + 1 โ ๐ฆ โค 0
MCSat: FM Example
โ๐ฅ + ๐ง + 1 โค 0 ๐ง โ 0
๐ฅโ๐ฆ โค0
๐ง+1โ๐ฆ โค0
๐ฆโ1
¬ โ๐ฅ + ๐ง + 1 โค 0 โจ ¬ ๐ฅ โ ๐ฆ โค 0 โจ ๐ง + 1 โ ๐ฆ โค 0
โ๐ฅ + ๐ง + 1 โค 0,
โก
๐ง + 1 โค ๐ฅ,
๐ฅโ๐ฆ โค0
๐ง โ 0,
๐ฅโค๐ฆ
1 โค ๐ฅ,
๐ฅโค1
๐ฆโ1
MCSat: FM Example
โ๐ฅ + ๐ง + 1 โค 0 ๐ง โ 0
๐ฅโ๐ฆ โค0
๐ง+1โ๐ฆ โค0 ๐ฆ โ1 ๐ฅ โ1
¬ โ๐ฅ + ๐ง + 1 โค 0 โจ ¬ ๐ฅ โ ๐ฆ โค 0 โจ ๐ง + 1 โ ๐ฆ โค 0
โ๐ฅ + ๐ง + 1 โค 0,
โก
๐ง + 1 โค ๐ฅ,
๐ฅโ๐ฆ โค0
๐ง โ 0,
๐ฅโค๐ฆ
1 โค ๐ฅ,
๐ฅโค1
๐ฆโ1
MCSat: Another Example
โ4๐ฅ๐ฆ โ 4๐ฅ + ๐ฆ > 1,
๐ฅ 2 + ๐ฆ 2 < 1,
๐ฅ 3 + 2๐ฅ 2 + 3๐ฆ 2 โ 5 < 0
MCSat: Another Example
โ4๐ฅ๐ฆ โ 4๐ฅ + ๐ฆ > 1,
๐ฅ 2 + ๐ฆ 2 < 1,
Feasible Region
๐ฅ 3 + 2๐ฅ 2 + 3๐ฆ 2 โ 5 < 0
๐ฅ 3 + 2๐ฅ 2 + 3๐ฆ 2 โ 5 < 0
Starting search
Partial solution:
๐ฅ โ 0.5
โ4๐ฅ๐ฆ โ 4๐ฅ + ๐ฆ > 1
What is the core?
๐ฅ2 + ๐ฆ2 < 1
Can we extend it to ๐ฆ?
MCSat: Another Example
โ4๐ฅ๐ฆ โ 4๐ฅ + ๐ฆ > 1,
๐ฅ 2 + ๐ฆ 2 < 1,
Feasible Region
๐ฅ 3 + 2๐ฅ 2 + 3๐ฆ 2 โ 5 < 0
๐ฅ 3 + 2๐ฅ 2 + 3๐ฆ 2 โ 5 < 0
Starting search
Partial solution:
๐ฅ โ 0.5
โ4๐ฅ๐ฆ โ 4๐ฅ + ๐ฆ > 1
What is the core?
๐ฅ2 + ๐ฆ2 < 1
Can we extend it to ๐ฆ?
MCSat โ Finite Basis
Every theory that admits quantifier elimination has a finite
basis (given a fixed assignment order)
๐น[๐ฅ, ๐ฆ1 , โฆ , ๐ฆ๐ ]
๐ฆ1 โ ๐ผ1 , โฆ , ๐ฆ๐ โ ๐ผ๐
โ๐ฅ: ๐น[๐ฅ, ๐ฆ1 , โฆ , ๐ฆ๐ ]
๐ถ1 [๐ฆ1 , โฆ , ๐ฆ๐ ] โง โฏ โง ๐ถ๐ [๐ฆ1 , โฆ , ๐ฆ๐ ]
¬๐น ๐ฅ, ๐ฆ1 , โฆ , ๐ฆ๐ โจ ๐ถ๐ [๐ฆ1 , โฆ , ๐ฆ๐ ]
MCSat โ Finite Basis
๐น๐ [๐ฅ1, ๐ฅ2 , โฆ , ๐ฅ๐โ1 , ๐ฅ๐ ]
๐น๐โ1 [๐ฅ1, ๐ฅ2 , โฆ , ๐ฅ๐โ1 ]
โฆ
๐น2 [๐ฅ1, ๐ฅ2 ]
๐น1 [๐ฅ1 ]
MCSat โ Finite Basis
๐น๐ [๐ฅ1, ๐ฅ2 , โฆ , ๐ฅ๐โ1 , ๐ฅ๐ ]
๐น๐โ1 [๐ฅ1, ๐ฅ2 , โฆ , ๐ฅ๐โ1 ]
โฆ
๐น2 [๐ฅ1, ๐ฅ2 ]
๐น1 [๐ฅ1 ]
MCSat โ Finite Basis
๐น๐ [๐ฅ1, ๐ฅ2 , โฆ , ๐ฅ๐โ1 , ๐ฅ๐ ]
๐น๐โ1 [๐ฅ1, ๐ฅ2 , โฆ , ๐ฅ๐โ1 ]
โฆ
๐น2 [๐ฅ1, ๐ฅ2 ]
๐น1 [๐ฅ1 ]
MCSat โ Finite Basis
๐น๐ [๐ฅ1, ๐ฅ2 , โฆ , ๐ฅ๐โ1 , ๐ฅ๐ ]
๐น๐โ1 [๐ฅ1, ๐ฅ2 , โฆ , ๐ฅ๐โ1 ]
โฆ
๐น2 [๐ฅ1, ๐ฅ2 ]
๐น1 [๐ฅ1 ]
MCSat โ Finite Basis
Every โfiniteโ theory has a finite basis
Example: Fixed size Bit-vectors
๐น[๐ฅ, ๐ฆ1 , โฆ , ๐ฆ๐ ]
๐ฆ1 โ ๐ผ1 , โฆ , ๐ฆ๐ โ ๐ผ๐
¬๐น ๐ฅ, ๐ฆ1 , โฆ , ๐ฆ๐ โจ ¬(๐ฆ1 = ๐ผ1 ) โจ โฏ โจ ¬(๐ฆ๐ = ๐ผ๐ )
MCSat โ Finite Basis
Theory 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.
MCSat: Uninterpreted Functions
๐ = ๐ + 1, ๐ ๐ โ 1 < ๐, ๐ ๐ > ๐
๐ = ๐ + 1, ๐ ๐ < ๐, ๐ ๐ > ๐, ๐ = ๐ โ 1
๐ = ๐ + 1, ๐ ๐ < ๐, ๐ ๐ > ๐, ๐ = ๐ โ 1
Treat ๐(๐) and ๐(๐) as variables
Generalized variables
MCSat: Uninterpreted Functions
๐ = ๐ + 1, ๐ ๐ < ๐, ๐ ๐ > ๐, ๐ = ๐ โ 1
๐ โ 0 ๐ โ 0 ๐(๐) โ 0 ๐(๐) โ 2
Conflict: ๐ ๐ and ๐ ๐ must be equal
¬ ๐ = ๐ โจ ๐ ๐ = ๐(๐)
MCSat: Uninterpreted Functions
๐ = ๐ + 1, ๐ ๐ < ๐, ๐ ๐ > ๐, ๐ = ๐ โ 1
๐ โ 0 ๐ โ 0 ๐(๐) โ 0 ๐ = ๐
(Semantic) Propagation
¬ ๐ = ๐ โจ ๐ ๐ = ๐(๐)
MCSat: Uninterpreted Functions
๐ = ๐ + 1, ๐ ๐ < ๐, ๐ ๐ > ๐, ๐ = ๐ โ 1
๐ โ 0 ๐ โ 0 ๐(๐) โ 0 ๐ = ๐
๐ ๐ = ๐(๐)
¬ ๐ = ๐ โจ ๐ ๐ = ๐(๐)
MCSat: Uninterpreted Functions
๐ = ๐ + 1, ๐ ๐ < ๐, ๐ ๐ > ๐, ๐ = ๐ โ 1
๐ โ 0 ๐ โ 0 ๐(๐) โ 0 ๐ = ๐
๐ ๐ = ๐(๐) ๐(๐) โ 0
¬ ๐ = ๐ โจ ๐ ๐ = ๐(๐)
MCSat โ Finite Basis
We can also use literals from the finite basis in decisions.
Application: simulate branch&bound for bounded linear
integer arithmetic
๐ฅ2 6
LP solution:
๐ฅ1 โค 0
๐ฅ1 = 0
๐ฅ2 = 3
๐ฅ1 = 0.8
๐ฅ2 = 2.4
๐ฅ1 โฅ 1
๐ฅ1 = 1
๐ฅ2 = 2
5
4
3
2
1
0
1
2
3
4
5
6
๐ฅ1
MCSat: Termination
Propagations
Boolean Decisions
Semantic Decisions
MCSat
โป
Propagations
Boolean Decisions
Semantic Decisions
MCSat
โป
Propagations
Boolean Decisions
Semantic Decisions
MCSat
Maximal Elements
โฆ
|๐น๐๐๐๐ก๐๐ต๐๐ ๐๐ |
โฆ
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
Conflict
¬ ๐ฅ โฅ 2 โจ ¬(๐ฅ โค 1)
๐ฅโค1
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
Conflict
¬ ๐ฅ โฅ 2 โจ ¬(๐ฅ โค 1)
๐ฅ โฅ 2,
๐ฅโฅ2
๐ฅโค1
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ¬(๐ฅ 2 + ๐ฆ 2 โค 1)
¬ ๐ฅ โฅ 2 โจ ¬(๐ฅ 2 + ๐ฆ 2 โค 1)
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
๐ฅ โฅ 2,
๐ฅโฅ2
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
๐ฆ โฅ 1 ๐ฅ2 + ๐ฆ2 โค 1
Conflict
¬ ๐ฅ โฅ 2 โจ ¬(๐ฅ โค 1)
๐ฅ โฅ 2,
๐ฅโฅ2
๐ฅโค1
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
¬๐ฅ โฅ 1 โจ ๐ฆ โฅ 1 ,
๐ฅโฅ1
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
(๐ฅ 2 + ๐ฆ 2 โค 1 โจ ๐ฅ๐ฆ > 1)
๐ฆ โฅ 1 ¬(๐ฅ 2 + ๐ฆ 2 โค 1)
¬ ๐ฅ โฅ 2 โจ ¬(๐ฅ 2 + ๐ฆ 2 โค 1)
¬(๐ฅ 2 + ๐ฆ 2 โค 1) โจ ๐ฅ โค 1
MCSat
๐ฅ < 1 โจ ๐,
๐ฅโ1
¬๐ โจ ๐ฅ = 2
MCSat
๐ฅ < 1 โจ ๐,
๐ฅโ1
๐
¬๐ โจ ๐ฅ = 2
MCSat
๐ฅ < 1 โจ ๐,
๐ฅโ1
¬๐ โจ ๐ฅ = 2
๐
Conflict (evaluates to false)
MCSat
๐ฅ < 1 โจ ๐,
๐ฅโ1
¬๐ โจ ๐ฅ = 2
๐
New clause
๐ฅ <1โจ๐ฅ =2
MCSat
๐ฅ < 1 โจ ๐,
๐ฅโ1
¬๐ โจ ๐ฅ = 2
๐
New clause
๐ฅ <1โจ๐ฅ =2
๐ฅ<1
MCSat
๐ฅ < 1 โจ ๐,
๐ฅโ1
¬๐ โจ ๐ฅ = 2
๐
New clause
๐ฅ <1โจ๐ฅ =2
๐ฅ<1
MCSat: Architecture
Arithmetic
Arrays
Boolean
Lists
MCSat: development
MCSat prototype: 7k lines of code
Deduction Rules
Boolean Resolution
Fourier-Motzkin
Equality Split
Ackermann expansion
aka Congruence
Normalization
MCSat: preliminary results
prototype: 7k lines of code
QF_LRA
MCSat: preliminary results
prototype: 7k lines of code
QF_UFLRA and QF_UFLIA
Conclusion
Mode-driven techniques are very promising
Preprocessing
CEGAR
MCSat: new framework for developing SMT solvers
MCSat generalizes NLSat
Modular architecture
Resources: Papers
The 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 Moura
http://research.microsoft.com/en-us/um/people/leonardo/files/IJCAR2012.pdf
A Model Constructing Satisfiability Calculus, L. de Moura and D. Jovanonic
http://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 Moura
http://research.microsoft.com/en-us/um/people/leonardo/mcsat_design.pdf
Resources: Source Code
nlsat
https://z3.codeplex.com/SourceControl/latest#src/nlsat/
mcsat
https://github.com/dddejan/CVC4/tree/mcsat
tactic/preprocessors
https://z3.codeplex.com/SourceControl/latest#src/tactic/