Conflict - Leonardo de Moura

advertisement
Model-Driven Decision Procedures
for Arithmetic
SYNASC 2013
Leonardo de Moura
Microsoft Research
Logic Engines as a Service
SAGE
𝑆𝑐𝑎𝑙𝑎 𝑍3
Satisfiability
Solution/Model
ð‘Ĩ2
+
ð‘Ķ2
< 1 𝑎𝑛𝑑 ð‘Ĩð‘Ķ > 0.1
ð‘Ĩ 2 + ð‘Ķ 2 < 1 𝑎𝑛𝑑 ð‘Ĩð‘Ķ > 1
=
7
8
unsat, Proof
Is execution path P feasible?
SAGE
sat, ð‘Ĩ =
1
,ð‘Ķ
8
Is assertion X violated?
W
I
T
N
E
S
S
Is Formula F Satisfiable?
The RISE of Model-Driven
Techniques
Saturation x Search
Model-finding
Proofs
Proof-finding
Models
SAT
𝑝1 ∨ ¬ð‘2,
𝑝1 = ð‘Ąð‘Ÿð‘Ē𝑒,
¬ð‘1 ∨ 𝑝2 ∨ 𝑝3,
𝑝2 = ð‘Ąð‘Ÿð‘Ē𝑒,
𝑝3
𝑝3 = ð‘Ąð‘Ÿð‘Ē𝑒
CNF is a set (conjunction) set of clauses
Clause is a disjunction of literals
Literal is an atom or the negation of an atom
Two procedures
Resolution
Proof-finder
Saturation
DPLL
Model-finder
Search
Resolution
ðķ ∨ 𝑙, 𝐷 ∨ ¬ð‘™ ⇒ ðķ ∨ 𝐷
𝑙, ¬ð‘™
⇒ unsat
Improvements
Delete tautologies 𝑙 ∨ ¬ð‘™ ∨ ðķ
Ordered Resolution
Subsumption (delete redundant clauses)
ðķ 𝑠ð‘Ē𝑏𝑠ð‘Ē𝑚𝑒𝑠 ðķ ∨ 𝐷
…
Resolution: Example
Resolution: Example
Resolution: Example
Resolution: Example
Resolution: Example
Resolution: Problem
Exponential time and space
Unit Resolution
ðķ ∨ 𝑙, ¬ð‘™
⇒ ðķ
ðķ
subsumes
ðķ∨𝑙
DPLL
Split rule
𝑆
𝑆, 𝑝
𝑆, ¬ð‘
DPLL = Unit Resolution + Split rule
DPLL
ð‘Ĩ ∨ ð‘Ķ,
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ĩ ∨ ð‘Ķ,
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ ∨ ¬ð‘Ķ,
ð‘Ĩ
ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ ∨ ¬ð‘Ķ
DPLL
ð‘Ĩ ∨ ð‘Ķ,
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ĩ ∨ ð‘Ķ,
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ ∨ ¬ð‘Ķ,
ð‘Ĩ
ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ ∨ ¬ð‘Ķ
DPLL
ð‘Ĩ ∨ ð‘Ķ,
ð‘Ķ,
¬ð‘Ķ,
ð‘Ĩ
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ ∨ ¬ð‘Ķ
DPLL
ð‘Ĩ ∨ ð‘Ķ,
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ķ,
¬ð‘Ķ,
ð‘Ĩ,
ð‘Ēð‘›ð‘ ð‘Žð‘Ą
ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ ∨ ¬ð‘Ķ
DPLL
ð‘Ĩ ∨ ð‘Ķ,
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ķ,
¬ð‘Ķ,
ð‘Ĩ,
ð‘Ēð‘›ð‘ ð‘Žð‘Ą
ð‘Ĩ ∨ ¬ð‘Ķ,
ð‘Ĩ ∨ ð‘Ķ,
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ
¬ð‘Ĩ ∨ ¬ð‘Ķ
DPLL
ð‘Ĩ ∨ ð‘Ķ,
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ķ,
¬ð‘Ķ,
ð‘Ĩ,
ð‘Ēð‘›ð‘ ð‘Žð‘Ą
ð‘Ĩ ∨ ¬ð‘Ķ,
ð‘Ĩ ∨ ð‘Ķ,
¬ð‘Ĩ ∨ ð‘Ķ,
ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ ∨ ¬ð‘Ķ,
¬ð‘Ĩ
¬ð‘Ĩ ∨ ¬ð‘Ķ
CDCL: Conflict Driven Clause Learning
DPLL
Resolution
Model
Proof
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
Applications
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-Based Search
Start the Search before Saturate/Project
We saturate on demand
Model guides the saturation
NLSAT (1)
Two kinds of decision
1. case-analysis (Boolean)
ð‘Ĩ2 + ð‘Ķ2 < 1 ∨ 𝒙 < 𝟎 ∨ ð‘Ĩ ð‘Ķ > 1
2. model construction (CAD lifting)
𝒙ï‚Ū − 𝟐
(−∞, −𝟏)
−𝟏
(−𝟏, 𝟎)
𝟎
(𝟎, 𝟏)
𝟏
(𝟏, ∞)
ð‘Ĩ4 − ð‘Ĩ2 + 1
+
+
+
+
+
+
+
ð‘Ĩ2 − 1
+
0
-
-
-
0
+
ð‘Ĩ
-
-
-
0
+
+
+
NLSAT (1)
Two kinds of decision
1. case-analysis (Boolean)
2. model construction (CAD lifting)
Parametric calculus: 𝑒ð‘Ĩ𝑝𝑙𝑎𝑖𝑛 ðđ, 𝑀
Finite basis explanation function
Explanations may contain new literals
They evaluate to false in the current state
NLSAT (2)
Key ideas: Use partial solution to guide the search
Feasible Region
ð‘Ĩ 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 ð‘Ķ?
NLSAT (2)
Key ideas: Use partial solution to guide the search
Feasible Region
ð‘Ĩ 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 ð‘Ķ?
NLSAT (3)
Key ideas: Solution based Project/Saturate
Standard project operators are pessimistic.
Coefficients can vanish!
NLSAT (4)
Key ideas: Lemma Learning
Prevent a Conflict from happening again.
Current assignment
ð‘Ĩ → 0.75
ð‘Ķ → 0.75
Conflict
ð‘Ĩ2 + ð‘Ķ2 + 𝑧2 < 1
Current assignments does
not satisfy new constraint.
Lemma
−1 < ð‘Ĩ < 1 ∧ ð‘Ķ > ð‘Ÿð‘œð‘œð‘Ą2 1 − ð‘Ķ 2 − ð‘Ĩ 2 ⇒ ⊥
NLSAT (5)
Key ideas: Nonchronological Backtracking
Conflict
ð‘Ĩð‘Ī=1
𝒘
𝒛=1
The values chosen for 𝑧 and ð‘Ķ
are irrelevant.
𝒚= 𝟐
𝒙=𝟎
Machinery
Multivariate & univariate Polynomials
Basic operations, Pseudo-division,
GCD, Resultant, PSC, Factorization,
Root isolation algorithms, Sturm sequences
Binary rationals
𝑎
2𝑘
Real Algebraic Numbers
Experimental Results (1)
OUR NEW ENGINE
Experimental Results (2)
OUR NEW ENGINE
Other examples
(for linear arithmetic)
Generalizing DPLL to
richer logics
Fourier-Motzkin
X
[McMillan et al 2009]
Conflict Resolution
[Korovin et al 2009]
Other examples
Array Theory by
Axiom Instantiation
X
Lemmas on Demand
For Theory of Array
[Brummayer-Biere 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 – 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 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
Logic as a Service
Model-Based techniques are very promising
MCSat
http://z3.codeplex.com
http://rise4fun.com/z3
Download