The SMT solver Z3 Lecture 3, 2012
description
Transcript of The SMT solver Z3 Lecture 3, 2012
![Page 1: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/1.jpg)
The SMT solver Z3
Lecture 3, 2012
Nikolaj Bjørner Microsoft ResearchDTU Winter course January 4th 2012Organized by Hanne Riis Nielson, Flemming Nielson
![Page 2: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/2.jpg)
Plan
Overview and architecture of Z3
What is Z3
How to use Z3
![Page 3: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/3.jpg)
Takeaways:
You will have an idea of what Z3 is and ways of using it
![Page 4: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/4.jpg)
Follow-on questions
![Page 5: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/5.jpg)
What is Z3?
TheoriesBit-Vectors
Lin-arithmetic Groebner basis
Free (uninterpreted) functions
Arrays
Quantifiers:E-matching
OCaml
.NET
CNative
SMT-LIB
Model Generation:Finite Models
Simplify
Comb. Array LogicRecursive Datatypes
Quantifiers:Super-position
Proof objects
Parallel Z3Assumption
tracking
By Leonardo de Moura & Nikolaj Bjørner http://research.microsoft.com/projects/z3
F# quote
![Page 6: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/6.jpg)
Z3: Little Engines of Proof
CongruenceClosur
e
SAT Solve
r
Simplifier
Quant.Instan
ces
Simplex
Bit-Arith
Super-positio
n
Arrays
Datatypes
User-Theori
es
MBQI
Q- Elim
Freely available from http://research.microsoft.com/projects/z3
![Page 7: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/7.jpg)
Input Formats
![Page 8: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/8.jpg)
Input FormatsText:
SMT-LIB2 - main exchange format for SMT solversSimplify - legacy format by Simplify Theorem ProverNative Z3 - low-level for storing formulas (and replay)Log - low-level log for replayTPTP - format used for first-order theorem provers
Programmatic:C - API functions exposed for COcaml - Ocaml wrapper around C API.NET - .NET wrapper around C APIScala, Python - by Phillip Suter and Sascha Böhme
![Page 9: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/9.jpg)
A Primer on SMT-LIB2See online Interactive tutorial
http://rise4fun.com/z3tutorial
![Page 10: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/10.jpg)
LINQ/F#: Sample layer on top of API
SMT@Microsoft
open Microsoft.Z3 open Microsoft.Z3.Quotations
do Solver.prove <@ Logic.declare (fun t11 t12 t21 t22 t31 t32 -> not ((t11 >= 0I) && (t12 >= t11 + 2I) && (t12 + 1I <= 8I) && (t21 >= 0I) && (t22 >= t21 + 3I) && (t32 + 1I <= 8I) && (t31 >= 0I) && (t32 >= t31 + 2I) && (t32 + 3I <= 8I) && (t11 >= t21 + 3I || t21 >= t11 + 2I) && (t11 >= t31 + 2I || t31 >= t11 + 2I) && (t21 >= t31 + 2I || t31 >= t21 + 3I) && (t12 >= t22 + 1I || t22 >= t12 + 1I) && (t12 >= t32 + 3I || t32 >= t12 + 1I) && (t22 >= t32 + 3I || t32 >= t22 + 1I) ) ) @>
Create Quoted
Expression
![Page 11: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/11.jpg)
Theories
![Page 12: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/12.jpg)
Theories
Uninterpreted functionsArithmetic (linear)Bit-vectorsAlgebraic data-typesArraysUser-defined
![Page 13: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/13.jpg)
Uninterpreted functionsArithmetic (linear)Bit-vectorsAlgebraic data-typesArraysUser-defined
Theories
![Page 14: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/14.jpg)
Theories
Uninterpreted functionsArithmetic (linear)Bit-vectorsAlgebraic data-typesArraysUser-defined
![Page 15: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/15.jpg)
Theories
Uninterpreted functionsArithmetic (linear)Bit-vectorsAlgebraic data-typesArraysUser-defined
![Page 16: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/16.jpg)
Theories
Uninterpreted functionsArithmetic (linear)Bit-vectorsAlgebraic data-typesArraysUser-defined
![Page 17: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/17.jpg)
User-interaction
and Guidance
![Page 18: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/18.jpg)
Interaction modelsText: SMT-LIB, SMT-LIB2, Native Yices (high-level), Native Z3 (low-level), SimplifyProgrammatic APIs: C, Ocaml, .NET, LINQ,
![Page 19: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/19.jpg)
Interaction
Logical Formula
Sat/Model
![Page 20: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/20.jpg)
Interaction
Logical Formula
Unsat/Proof
![Page 21: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/21.jpg)
Interaction
Simplify
Logical Formula
![Page 22: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/22.jpg)
Interaction
ImpliedEqualities
- x and y are equal- z + y and x + z are equal
Logical Formula
![Page 23: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/23.jpg)
Interaction
QuantifierEliminatio
n
Logical Formula
![Page 24: The SMT solver Z3 Lecture 3, 2012](https://reader035.fdocuments.in/reader035/viewer/2022062309/56814bf4550346895db8e4a5/html5/thumbnails/24.jpg)
Interaction
Logical Formula
Unsat. Core