introduction to smt lecture 2, 2012
DESCRIPTION
Introduction to SMT Lecture 2, 2012. Nikolaj Bjørner Microsoft Research DTU Winter course January 3 rd 2012 Organized by Hanne Riis Nielson, Flemming Nielson. Background Reading. September 2011. Plan. General overview of what is SMT Compare with SAT, first-order theorem proving,.. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/1.jpg)
Introduction to SMT
Lecture 2, 2012Nikolaj Bjørner Microsoft ResearchDTU Winter course January 3rd 2012Organized by Hanne Riis Nielson, Flemming Nielson
![Page 2: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/2.jpg)
Background Reading
September 2011
![Page 3: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/3.jpg)
PlanGeneral overview of what is SMT
Compare with SAT, first-order theorem proving,..
Refresher on SAT and modern DPLL
Introduction to SMT solving techniques
Selected SMT applications (more Jan 4,5th)
![Page 4: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/4.jpg)
Takeaways - this section should teach:The syntax and semantics of
SAT/SMT.
Algorithmic principles of modern SAT solvers
Algorithmic principles of modern SMT solvers
![Page 5: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/5.jpg)
Some context
On Theorem Proving
![Page 6: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/6.jpg)
Symbolic Engines: SAT, FTP and SMT
SAT: Propositional Satisfiability.(Tie Shirt) (Tie Shirt) (Tie
Shirt)
FTP: First-order Theorem Proving.X,Y,Z [X*(Y*Z) = (X*Y)*Z] X [X*inv(X) = e] X [X*e = e]
SMT: Satisfiability Modulo background Theories
b + 2 = c A[3] ≠ A[c-b+1]
![Page 7: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/7.jpg)
SAT - Milestonesyear Milestone1960 Davis-Putnam procedure1962 Davis-Logeman-Loveland1984 Binary Decision Diagrams 1992 DIMACS SAT challenge1994 SATO: clause indexing1997 GRASP: conflict clause
learning1998 Search Restarts2001 zChaff: 2-watch literal,
VSIDS2005 Preprocessing techniques2007 Phase caching2008 Cache optimized indexing2009 In-processing, clause
management
2010 Blocked clause elimination
2002 2010
Problems impossible 10 years ago are trivial today
Concept
Millions of variables from HW designs Courtesy Daniel le Berre
![Page 8: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/8.jpg)
FTP - MilestonesYear Milestone Who Year Milestone Who
1930 Hebrand's theorem Herbrand 1970 Completion and saturation procedures
many people and provers
1934 Sequent calculi Gentzen 1970 Knuth-Bendix ordering Knuth; Bendix1934 Inverse method Gentzen 1971 Selection function Kowalski; Kuehner1955 Semantic tableaux Beth 1972 Built-in equational theories Plotkin
1960 Herbrand-based theorem proving Wang Hao 1972 Prolog Colmerauer
1960 Ordered resolution Davis; Putnam 1974 Saturation algorithms Overbeek
1962 DLL Davis; Logemann; Loveland 1975 Completeness of paramodulation Brand
1963 First-order inverse method Maslov 1975 AC-unification Stickel1965 Unification J. Robinson 1976 Resolution as a decision procedure Joyner1965 First-order resolution J. Robinson 1979 Basic paramodulation Degtyarev1965 Subsumption J. Robinson 1980 Lexicographic path orderings Kamin; Levy1967 Orderings Slagle 1985 Theory resolution Stickel
1967 Demodulation or rewriting Wos; G. Robinson; Carson; Shalla 1986
Definitional clause form transformation Plaisted; Greenbaum
1968 Model elimination Loveland 1988 Superposition Zhang1969 Paramodulation G. Robinson; Wos 1988 Model construction Zhang
1989 Term indexing Stickel; Overbeek
1990 General theory of redundancy Bachmair; Ganzinger1992 Basic superposition Nieuwenhuis; Rubio1993 First instance-based methods Billon; Plaisted1993 Discount saturation algorithm Avenhaus; Denzinger1998 Finite model finding using SAT McCune2000 First-order DPLL Baumgartner2003 iProver method Ganzinger; Korovin2008 Sine selection Hoder
Some success stories:- Open Problems (of 25 years):
XCB: X ((X Y) (Z Y)) Z)is a single axiom for equivalence
- Knowledge Ontologies GBs of formulas Courtesy Andrei Voronkov, Manchester U
![Page 9: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/9.jpg)
SMT - Milestonesyear Milestone1977 Efficient Equality Reasoning1979 Theory Combination
Foundations1979 Arithmetic + Functions 1982 Combining Canonizing
Solvers1992-8
Systems: PVS, Simplify, STeP, SVC
2002 Theory Clause Learning2005 SMT competition2006 Efficient SAT + Simplex2007 Efficient Equality Matching2009 Combinatory Array Logic, …
SATTheor
ySolver
sSMT
15KLOC + 285KLOC = Z3
Includes progress from SAT:
Simplify (of ’01) time
1sec
1
10
100
1000
Z3TimeOn VCCRegression
Nov 08 March 09
Z3(of ’07)TimeOn BoogieRegression
![Page 10: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/10.jpg)
Introducing SMT byexamples
![Page 11: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/11.jpg)
Satisfiability Modulo Theories (SMT)
Is formula satisfiable modulo theory T ?
SMT solvers have specialized algorithms for
T
![Page 12: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/12.jpg)
Satisfiability Modulo Theories (SMT)
ArithmeticArray Theory Uninterpreted Functions
𝑥+2=𝑦⇒ 𝑓 (𝑠𝑒𝑙𝑒𝑐𝑡 (𝑠𝑡𝑜𝑟𝑒 (𝑎 ,𝑥 ,3 ) , 𝑦−2 ) )= 𝑓 (𝑦−𝑥+1)
![Page 13: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/13.jpg)
Satisfiability Modulo Theories (SMT)
b + 2 = c and f(select(store(a,b,3), c-2)) ≠ f(c-b+1)
![Page 14: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/14.jpg)
Satisfiability Modulo Theories (SMT)
Arithmetic
b + 2 = c and f(select(store(a,b,3), c-2)) ≠ f(c-b+1)
![Page 15: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/15.jpg)
Satisfiability Modulo Theories (SMT)
ArithmeticArray Theory
b + 2 = c and f(select(store(a,b,3), c-2)) ≠ f(c-b+1)
![Page 16: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/16.jpg)
Satisfiability Modulo Theories (SMT)
ArithmeticArray TheoryUninterpreted Functions
b + 2 = c and f(select(store(a,b,3), c-2)) ≠ f(c-b+1)
![Page 17: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/17.jpg)
Satisfiability Modulo Theories (SMT)
b + 2 = c and f(select(store(a,b,3), c-2)) ≠ f(c-b+1)
Substituting c by b+2
![Page 18: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/18.jpg)
Satisfiability Modulo Theories (SMT)
b + 2 = c and f(select(store(a,b,3), b+2-2)) ≠ f(b+2-b+1)
Simplifying
![Page 19: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/19.jpg)
Satisfiability Modulo Theories (SMT)
b + 2 = c and f(select(store(a,b,3), b)) ≠ f(3)
![Page 20: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/20.jpg)
Satisfiability Modulo Theories (SMT)
b + 2 = c and f(select(store(a,b,3), b)) ≠ f(3)
Applying array theory axiom
![Page 21: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/21.jpg)
Satisfiability Modulo Theories (SMT)
b + 2 = c and f(3) ≠ f(3)
Inconsistent/Unsatisfiable
![Page 22: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/22.jpg)
Job Shop Scheduling
Machines
Jobs
P = NP? Laundry 𝜁 (𝑠 )=0⇒ 𝑠=12 +𝑖𝑟
Tasks
![Page 23: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/23.jpg)
Job Shop SchedulingConstraints:
Precedence: between two tasks of the same job
Resource: Machines execute at most one job at a time
413
2
[ 𝑠𝑡𝑎𝑟 𝑡2 , 2 ..𝑒𝑛𝑑2 , 2 ]∩ [𝑠𝑡𝑎𝑟 𝑡 4 , 2 ..𝑒𝑛𝑑4 , 2 ]=∅
![Page 24: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/24.jpg)
Job Shop SchedulingConstraints:Encoding:
Precedence: - start time of job 2 on mach 3 - duration of job 2 on mach 3Resource:
413
2
[ 𝑠𝑡𝑎𝑟 𝑡2,2 ..𝑒𝑛𝑑2,2 ]∩ [ 𝑠𝑡𝑎𝑟 𝑡4,2 ..𝑒𝑛𝑑4,2 ]=∅
Not convex
![Page 25: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/25.jpg)
Job Shop Scheduling
![Page 26: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/26.jpg)
Job Shop Scheduling
case split
case split
Efficient solvers:- Floyd-Warshal algorithm- Ford-Fulkerson algorithm
𝑧−𝑧=5 – 2 –3 – 2=−2<0
![Page 27: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/27.jpg)
SAT solving
![Page 28: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/28.jpg)
Modern DPLL in a nutshellInitialize Decide Propagate
Conflict Resolve
Learn Backjump
Unsat Sat Restart
Adapted and modified from [Nieuwenhuis, Oliveras, Tinelli J.ACM 06]
![Page 29: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/29.jpg)
SMT solving
![Page 30: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/30.jpg)
DPLL(T) solver interactionT- Propagate
T- Conflict
h𝑤 𝑒𝑟𝑒𝑎>𝑏 ,𝑏>𝑐 ,𝑎≤𝑐⊆𝑀T- Conflict
T- Propagate
![Page 31: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/31.jpg)
Main components of modern SMT Solvers
2 ( ( ( , ,3), 2)) ( 1)x y f read write a x y f y x
2 ( ) ( 1)( ( , ,3), 2)
x y f v f y xread write a x y v
Purification
Note: read is just another name for select, write is just another name for store
![Page 32: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/32.jpg)
Main components of modern SMT Solvers
2 ( ) ( 1)( ( , ,3), 2)
x y f v f y xread write a x y v
2 1( ( , ,3), 2)
( ) ( )
x y u y xread write a x y vf v f u
Purification
![Page 33: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/33.jpg)
Main components of modern SMT Solvers
2 1( ( , ,3), 2)
( ) ( )
x y u y xread write a x y vf v f u
Purification
2 1 3 2( ( , , ), )
( ) ( )
x y u y x z w yread write a x z w vf v f u
ArithmeticArrraysFunctions
![Page 34: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/34.jpg)
Main components of modern SMT SolversPropositional Abstraction
3
1 2 4
5
6
2 1 3 2
( ( , , ), )
( ) ( )
pp p p
p
p
x y u y x z w y
read write a x z w v
f v f u
2 1 3 2( ( , , ), )
( ) ( )
x y u y x z w yread write a x z w vf v f u
![Page 35: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/35.jpg)
Main components of modern SMT SolversPropositional Assignment
3
1 2 4
5
6
2 1 3 2
( ( , , ), )
( ) ( )
pp p p
p
p
x y u y x z w y
read write a x z w v
f v f u
1
2
3
4
5
6
,,,,,
p truep truep truep truep truep false
Using SAT solver
![Page 36: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/36.jpg)
Main components of modern SMT SolversTheory Solving
2 1 3 2x y u y x z w y
( ( , , ), )read write a x z w v
( ) ( )f v f u
w x
z v
3u z
Arithmetic
Arrays
Free functions
Theories exchange equalities between shared variables.
But how?
![Page 37: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/37.jpg)
Model-based CombinationThe running example was easy. But what about:
Either or . or (are integers)
Arithmetic module needs to somehow
learnthat . - Integer linear arithmetic is non-convex.
![Page 38: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/38.jpg)
Model-based combinationDelayed Theory Combination solution
[2006 Bruttomesso et.al.]Add equality literals for every pair of shared variables:
: Solvers work completely independently.: Works with non-convex theories.: O(n2) up-front cost. No use of
propagation.
( ), ( ), ( )x y x y x z x z y z y z
![Page 39: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/39.jpg)
Model-based combinationIdea:
Have solvers produce models.Use models to introduce equalities on demand.
If Then guess
: No up-front O(n2) cost of adding equalities: Works with non-convex theories: Models are conservative approximations then
![Page 40: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/40.jpg)
Model-based - Example
![Page 41: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/41.jpg)
Model-based - Example
![Page 42: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/42.jpg)
Model-based - Example
![Page 43: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/43.jpg)
Model-based - Example
![Page 44: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/44.jpg)
Model-based - Example
![Page 45: Introduction to SMT Lecture 2, 2012](https://reader036.vdocument.in/reader036/viewer/2022062315/568162be550346895dd34c1b/html5/thumbnails/45.jpg)
Model-based - Example