Satisfiability Modulo Theories and Z3
Nikolaj Bjørner Microsoft Research
ReRISE Winter School, Linz, Austria February 3, 2014
Satisfiability Modulo Theories and Z3 Nikolaj Bjrner Microsoft - - PowerPoint PPT Presentation
Satisfiability Modulo Theories and Z3 Nikolaj Bjrner Microsoft Research ReRISE Winter School, Linz, Austria February 3, 2014 SMT : Basic Architecture Theory SAT SMT Solvers Equality + UF Arithmetic Case Analysis Bit-vectors Nikolaj is
Nikolaj Bjørner Microsoft Research
ReRISE Winter School, Linz, Austria February 3, 2014
Case Analysis
Nikolaj is Sober ∨ Nikolaj is Somber ∨ (Nikolaj is Drunk ∧ Nikolaj is Happy) Theory[Alcohol]: Sober ⊗ Drunk Theory[Moodswings]: Somber ⊗ Happy
Leonardo de Moura, Nikolaj Bjørner, Christoph Wintersteiger Not all is hopeless
September 2011
Program Verification Auditing Type Safety Over- Approximation Under- Approximation Testing Analysis Synthesis
BEK
𝑡𝑓𝑚𝑓𝑑𝑢(𝑡𝑢𝑝𝑠𝑓 𝑏, 𝑗, 𝑤 , 𝑗) = 𝑤 𝑗 ≠ 𝑘 ⇒ 𝑡𝑓𝑚𝑓𝑑𝑢(𝑡𝑢𝑝𝑠𝑓 𝑏, 𝑗, 𝑤 , 𝑘) = 𝑡𝑓𝑚𝑓𝑑𝑢(𝑏, 𝑘)
Job Shop Scheduling
Machines Jobs P = NP? Laundry
𝜂 𝑡 = 0 ⇒ 𝑡 = 1 2 + 𝑗𝑠
Tasks
4 1 3 2 𝑡𝑢𝑏𝑠𝑢2,2. . 𝑓𝑜𝑒2,2 ∩ 𝑡𝑢𝑏𝑠𝑢4,2. . 𝑓𝑜𝑒4,2 = ∅
4 1 3 2 𝑡𝑢𝑏𝑠𝑢2,2. . 𝑓𝑜𝑒2,2 ∩ 𝑡𝑢𝑏𝑠𝑢4,2. . 𝑓𝑜𝑒4,2 = ∅
𝑢2,2 + 𝑒2,2 ≤ 𝑢4,2 ∨ 𝑢4,2 + d4,2 ≤ 𝑢2,2
case split case split Efficient solvers:
𝑨 − 𝑨 = 5 – 2 – 3 – 2 = −2 < 0
(∀𝑦 𝑔 𝑑, 𝑦 = 𝑦) ∧ 𝑏 = 𝑐, 𝑐 ∧ 𝑐 = 𝑑 ∧ 𝑔 𝑏 ≠ 𝑑 ∧ ∀𝑦 𝑔 𝑑, 𝑦 = 𝑦 → 𝑔 𝑑, 𝑐 = 𝑐
[de Moura, B. CADE 2007]
[B. IJCAR 2010] Presburger Arithmetic, Algebraic Data-types, Quadratic polynomials SMT integration to prune branches
[de Moura, Ge. CAV 2008] [Bonachnia, Lynch, de Moura CADE 2009] [de Moura, B. IJCAR 2010]
[Hoder, B. SAT 2012]
∀𝒀. 𝒀 > 𝟐𝟏𝟏 mc(𝒀, 𝒀 − 𝟐𝟏) ∀𝒀, 𝒁, 𝑺. 𝒀 ≤ 𝟐𝟏𝟏 mc(𝒀 + 𝟐𝟐, 𝒁) mc(𝒁, 𝑺) mc(𝒀, 𝑺) ∀𝒀, 𝑺. mc(𝒀, 𝑺) ∧ 𝒀 ≤ 𝟐𝟏𝟐 → 𝑺 = 𝟘𝟐
Logical Formula
Sat/Model
Logical Formula
Unsat/Proof
Logical Formula
Logical Formula
Composi
tion
ctics: cs:
Case Analysis
x 0, y = x + 1, (y > 2 y < 1) p1, p2, (p3 p4) Abstract (aka “naming” atoms) p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1)
x 0, y = x + 1, (y > 2 y < 1) p1, p2, (p3 p4) Abstract (aka “naming” atoms) p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1) SAT Solver
x 0, y = x + 1, (y > 2 y < 1) p1, p2, (p3 p4) Abstract (aka “naming” atoms) p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1) SAT Solver Assignment p1, p2, p3, p4
x 0, y = x + 1, (y > 2 y < 1) p1, p2, (p3 p4) Abstract (aka “naming” atoms) p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1) SAT Solver Assignment p1, p2, p3, p4 x 0, y = x + 1,
x 0, y = x + 1, (y > 2 y < 1) p1, p2, (p3 p4) Abstract (aka “naming” atoms) p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1) SAT Solver Assignment p1, p2, p3, p4 x 0, y = x + 1,
Theory Solver Unsatisfiable x 0, y = x + 1, y < 1
x 0, y = x + 1, (y > 2 y < 1) p1, p2, (p3 p4) Abstract (aka “naming” atoms) p1 (x 0), p2 (y = x + 1), p3 (y > 2), p4 (y < 1) SAT Solver Assignment p1, p2, p3, p4 x 0, y = x + 1,
Theory Solver Unsatisfiable x 0, y = x + 1, y < 1 New Lemma
Theory Solver Unsatisfiable x 0, y = x + 1, y < 1 New Lemma
Conflict Clauses
literal assignments
Backjump Propagate
Initialize 𝜗| 𝐺 𝐺 𝑗𝑡 𝑏 𝑡𝑓𝑢 𝑝𝑔 𝑑𝑚𝑏𝑣𝑡𝑓𝑡 Decide 𝑁 𝐺 ⟹ 𝑁, ℓ 𝐺 ℓ 𝑗𝑡 𝑣𝑜𝑏𝑡𝑡𝑗𝑜𝑓𝑒 Propagate 𝑁 𝐺, 𝐷 ∨ ℓ ⟹ 𝑁, ℓ𝐷∨ℓ 𝐺, 𝐷 ∨ ℓ 𝐷 𝑗𝑡 𝑔𝑏𝑚𝑡𝑓 𝑣𝑜𝑒𝑓𝑠 𝑁 Sat 𝑁 |𝐺 ⟹ 𝑁 𝐺 𝑢𝑠𝑣𝑓 𝑣𝑜𝑒𝑓𝑠 𝑁 Conflict 𝑁 𝐺, 𝐷 ⟹ 𝑁 𝐺, 𝐷 | 𝐷 𝐷 𝑗𝑡 𝑔𝑏𝑚𝑡𝑓 𝑣𝑜𝑒𝑓𝑠 𝑁 Learn 𝑁 𝐺 | 𝐷 ⟹ 𝑁 𝐺, 𝐷 | 𝐷 Unsat 𝑁 𝐺 ∅ ⟹ 𝑉𝑜𝑡𝑏𝑢 Backjump 𝑁𝑁′ 𝐺 | 𝐷 ∨ ℓ ⟹ 𝑁ℓ𝐷∨ℓ 𝐺 𝐷 ⊆ 𝑁, ¬ℓ ∈ 𝑁′ Resolve 𝑁 𝐺 | 𝐷′ ∨ ¬ℓ ⟹ 𝑁 𝐺 | 𝐷′ ∨ 𝐷 ℓ𝐷∨ℓ ∈ 𝑁 Forget 𝑁 𝐺, 𝐷 ⟹ 𝑁 𝐺 𝐷 is a learned clause Restart 𝑁 𝐺 ⟹ 𝜗 𝐺 [Nieuwenhuis, Oliveras, Tinelli J.ACM 06] customized