Linear real and integer arithmetic. Fixed-size bit-vectors Uninterpreted functions Extensional arrays Quantifiers Model generation Several input formats.

Slides:



Advertisements
Similar presentations
Logical Abstract Interpretation Sumit Gulwani Microsoft Research, Redmond.
Advertisements

SMELS: Sat Modulo Equality with Lazy Superposition Christopher Lynch – Clarkson Duc-Khanh Tran - MPI.
Measurement of a Pond Basics of plane geometry Idea of the Coordinate Plane Confining an Area Practical skill Cooperation in the Group Lake measurement.
Quantified Invariant Generation using an Interpolating Saturation Prover Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
Consequence Generation, Interpolants, and Invariant Discovery Ken McMillan Cadence Berkeley Labs.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Satisfiability modulo the Theory of Bit Vectors
The Derivative in Graphing and Application
Program verification: flowchart programs Book: chapter 7.
LEARNIN HE UNIFORM UNDER DISTRIBUTION – Toward DNF – Ryan ODonnell Microsoft Research January, 2006.
CS201: Data Structures and Discrete Mathematics I Linked Lists, Stacks and Queues.
ScalaZ3 Integrating SMT and Programming
Syntax-Guided Synthesis Rajeev Alur Joint work with R.Bodik, G.Juniwal, M.Martin, M.Raghothaman, S.Seshia, R.Singh, A.Solar-Lezama, E.Torlak, A.Udupa 1.
Satisfiability Modulo Theories and Network Verification Nikolaj Bjørner Microsoft Research Formal Methods and Networks Summer School Ithaca, June
Software Model Checking with SMT Ken McMillan Microsoft Research TexPoint fonts used in EMF: A A A A A.
PROOF BY CONTRADICTION
Using SMT solvers for program analysis Shaz Qadeer Research in Software Engineering Microsoft Research.
SymDiff: Leveraging Program Verification for Comparing Programs Shuvendu Lahiri Research in Software Engineering (RiSE), Microsoft Research, Redmond Jointly.
Synthesis, Analysis, and Verification Lecture 04c Lectures: Viktor Kuncak VC Generation for Programs with Data Structures “Beyond Integers”
Series and Parallel Circuits
5 x4. 10 x2 9 x3 10 x9 10 x4 10 x8 9 x2 9 x4.
MS 101: Algorithms Instructor Neelima Gupta
Chapter 8: The Solver and Mathematical Programming Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
Computational Facility Layout
The Project Problem formulation (one page) Literature review –“Related work" section of final paper, –Go to writing center, –Present paper(s) to class.
50.530: Software Engineering
Finding bugs: Analysis Techniques & Tools Symbolic Execution & Constraint Solving CS161 Computer Security Cho, Chia Yuan.
Satisfiability Modulo Theories (An introduction)
SMT Solvers (an extension of SAT) Kenneth Roe. Slide thanks to C. Barrett & S. A. Seshia, ICCAD 2009 Tutorial 2 Boolean Satisfiability (SAT) ⋁ ⋀ ¬ ⋁ ⋀
Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI.
Lecture # 21 Chapter 6 Uptill 6.4. Type System A type system is a collection of rules for assigning type expressions to the various parts of the program.
Leonardo de Moura and Nikolaj Bjørner Microsoft Research.
Proof translation from CVC3 to Hol light Yeting Ge Acsys Mar 5, 2008.
PROOF TRANSLATION AND SMT LIB CERTIFICATION Yeting Ge Clark Barrett SMT 2008 July 7 Princeton.
Plan for today Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search.
1 Satisfiability Modulo Theories Sinan Hanay. 2 Boolean Satisfiability (SAT) Is there an assignment to the p 1, p 2, …, p n variables such that  evaluates.
Program Exploration with Pex Nikolai Tillmann, Peli de Halleux Pex
Fixing Broken Programs. How do you figure out what’s wrong? Look carefully at the error message. Locate the error – Most messages have line numbers –
Nikolaj Bjørner Leonardo de Moura Nikolai Tillmann Microsoft Research August 11’th 2008.
ECI 2007: Specification and Verification of Object- Oriented Programs Lecture 4.
1 A propositional world Ofer Strichman School of Computer Science, Carnegie Mellon University.
Chapter 10 Sequences, Induction, and Probability Copyright © 2014, 2010, 2007 Pearson Education, Inc Mathematical Induction.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Deciding a Combination of Theories - Decision Procedure - Changki pswlab Combination of Theories Daniel Kroening, Ofer Strichman Presented by Changki.
CAS- 734 (Presentation -1) By : Vasudha Kapil
CSE373: Data Structures and Algorithms Lecture 2b: Proof by Induction and Powers of Two Nicki Dell Spring 2014.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
1 MVD 2010 University of Iowa New York University Comparing Proof Systems for Linear Real Arithmetic Using LFSC Andrew Reynolds September 17, 2010.
HW #1. Due Mar 22 Midnight Verify the following program using SAT solver 1. Translate the program into a SSA form 2. Create a Boolean formula from.
CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu.
Institute for Applied Information Processing and Communications (IAIK) – Secure & Correct Systems 1 Robert Könighofer and Roderick Bloem IAIK – Graz University.
The Satisfiability Modulo Theories Library (SMT-LIB) Moonzoo Kim CS Dept. KAIST.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
Finding Conflicting Instances of Quantified Formulas in SMT Andrew Reynolds Cesare Tinelli Leonardo De Moura July 18, 2014.
Nikolaj Bjørner Microsoft Research DTU Winter course January 4 th 2012 Organized by Hanne Riis Nielson, Flemming Nielson.
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
Bit-Vector Optimization ALEXANDER NADER AND VADIM RYVCHIN INTEL TACAS 2016.
Satisfiability Modulo Theories and DPLL(T) Andrew Reynolds March 18, 2015.
Mathematical Induction. The Principle of Mathematical Induction Let S n be a statement involving the positive integer n. If 1.S 1 is true, and 2.the truth.
Daniel Kroening and Ofer Strichman 1 Decision Procedures for Equality Logic 1.
Decision Procedures in First Order Logic
Logical path planning Róbert Baláž Technical University of Košice
Satisfiability Modulo Theories
Lazy Proofs for DPLL(T)-Based SMT Solvers
Chapter 3 The Real Numbers.
Solving Linear Arithmetic with SAT-based MC
Satisfiability Modulo Theories
Sequences F.LE.1, 2, 5 F.BF.1, 2 A.SSE.1.a F.IF.1, 2, 3, 4
The Satisfiability Modulo Theories Library (SMT-LIB)
The SMT-LIB Initiative
Presentation transcript:

Linear real and integer arithmetic. Fixed-size bit-vectors Uninterpreted functions Extensional arrays Quantifiers Model generation Several input formats (Simplify, SMT-LIB, Z3, Dimacs) Extensive API (C/C++,.Net, OCaml)

Theories Core Theory SAT solver Rewriting Simplification Bit-Vectors Arithmetic Partial orders Tuples E-matching Arrays OCaml Text.NET C C

Given arrays: bool a1[bool]; bool a2[bool]; bool a3[bool]; bool a4[bool]; All can be distinct. Add: bool a5[bool]; Two of a1,..,a5 must be equal.

(benchmark integer-linear-arithmetic :status sat :logic QF_LIA :extrafuns ((x1 Int) (x2 Int) (x3 Int) (x4 Int) (x5 Int)) :formula (and (>= (- x1 x2) 1) (<= (- x1 x2) 3) (= x1 (+ (* 2 x3) x5)) (= x3 x5) (= x2 (* 6 x4))) ) (benchmark array :logic QF_AUFLIA :status unsat :extrafuns ((a Array) (b Array) (c Array)) :extrafuns ((i Int) (j Int)) :formula (and (= (store a i v) b) (= (store a j w) c) (= (select b j) w) (= (select c i) v) (not (= b c)) )

benchmark ::= (benchmark name [:status (sat | unsat | unknown)] :logic logic-name declaration*) declaration ::= :extrafuns (func-decl*) | :extrapreds (pred-decl*) | :extrasorts (sort-decl*) | :assumption fmla | :formula fmla sort-decl::= id- identifier func-decl ::= id sort-decl* sort-decl- name of function, domain, range pred-decl ::= id sort-decl* - name of predicate, domain fmla::= (and fmla*) | (or fmla*) | (not fmla) | (if_then_else fmla fmla fmla) | (= term term) | (implies fmla fmla) (iff fmla fmla) | (predicate term*) Term::= (ite fmla term term) | (id term*)- function application | id- constant

Logics: QF_UF – Un-interpreted functions. Built-in sort U QF_AUFLIA – Arrays and Integer linear arithmetic. Built-in Sorts: Int, Array (of Int to Int) Built-in Predicates: =,, Built-in Functions: +, *, -, select, store. Constants: 0, 1, 2, …

Q: There is no built-in function for max or min. How do I encode it? (max x y) is the same as (ite (> x y) x y) Also: replace (max x y) by fresh constant max_x_y add assumptions: :assumption (implies (> x y) (= max_x_y x)) :assumption (implies (<= x y) (= max_x_y y)) Q: Encode the predicate (even n), that is true when n is even.

Quantified formulas in SMT-LIB: fmla::= … | (forall bound* fmla) | (exists bound* fmla) Bound::= ( id sort-id ) Q: I want f to be an injective function. Write an axiom that forces f to be injective. Patterns: guiding the instantiation of quantifiers (Lecture 5) fmla::= … | (forall (?x A) (?y B) fmla :pat { term }) | (exists (?x A) (?y B) fmla :pat { term }) Q: what are the patterns for the injectivity axiom?

open Microsoft.Z3 open System.Collections.Generic open System let par = new Config() do par.SetParamValue("MODEL", "true") let z3 = new TypeSafeContext(par) Create a context z3: let check (fmla) = z3.Push(); z3.AssertCnstr(fmla); (match z3.Check() with | LBool.False -> Printf.printf "unsat\n" | LBool.True -> Printf.printf "sat\n" | LBool.Undef -> Printf.printf "unknown\n" | _ -> assert false); z3.Pop(1ul) Check a formula -Push -AssertCnstr -Check -Pop

let fmla1 = ((x === f(f(f(f(f(f x))))) && (x === f(f(f x)))) ==> (x === (f x)) do check (neg fmla1) let (===) x y = z3.MkEq(x,y) let (==>) x y = z3.MkImplies(x,y) let (&&) x y = z3.MkAnd(x,y) let neg x = z3.MkNot(x) let a = z3.MkType(“a”) let f_decl = z3.MkFuncDecl("f",a,a) let x = z3.MkConst(“x”,a) let f x = z3.MkApp(f_decl,x) Declaring z3 shortcuts, constants and functions Proving a theorem (benchmark euf :logic QF_UF :extrafuns ((f U U) (x U)) :formula (not (implies (and (= x (f(f(f(f(f x)))))) (= x (f(f(f x))))) (= x (f x)))) compared to

We want to find models for But we only care about different

Representing the problem void Test() { Config par = new Config(); par.SetParamValue("MODEL", "true"); z3 = new TypeSafeContext(par); intT = z3.MkIntType(); i1 = z3.MkConst("i1", intT); i2 = z3.MkConst("i2", intT); i3 = z3.MkConst("i3", intT); z3.AssertCnstr(Num(2) < i1 & i1 <= Num(5)); z3.AssertCnstr(Num(1) < i2 & i2 <= Num(7)); z3.AssertCnstr(Num(-1) < i3 & i3 <= Num(17)); z3.AssertCnstr(Num(0) <= i1 + i2 + i3 & Eq(i2 + i3, i1)); Enumerate(); par.Dispose(); z3.Dispose(); }

Enumeration: void Enumerate() { TypeSafeModel model = null; while (LBool.True == z3.CheckAndGetModel(ref model)) { model.Display(Console.Out); int v1 = model.GetNumeralValueInt(model.Eval(i1)); TermAst block = Eq(Num(v1),i1); Console.WriteLine("Block {0}", block); z3.AssertCnstr(!block); model.Dispose(); } TermAst Eq(TermAst t1, TermAst t2) { return z3.MkEq(t1,t2); } TermAst Num(int i) { return z3.MkNumeral(i, intT); }

int Maximize(TermAst a, int lo, int hi) { while (lo < hi) { int mid = (lo+hi)/2; Console.WriteLine("lo: {0}, hi: {1}, mid: {2}",lo,hi,mid); z3.Push(); z3.AssertCnstr(Num(mid+1) <= a & a <= Num(hi)); TypeSafeModel model = null; if (LBool.True == z3.CheckAndGetModel(ref model)) { lo = model.GetNumeralValueInt(model.Eval(a)); model.Dispose(); } else hi = mid; z3.Pop(); } return hi; } Maximize(i3,-1,17):

int Maximize(TermAst a, int lo, int hi) { while (lo < hi) { int mid = (lo+hi)/2; Console.WriteLine("lo: {0}, hi: {1}, mid: {2}",lo,hi,mid); z3.Push(); z3.AssertCnstr(Num(mid+1) <= a & a <= Num(hi)); TypeSafeModel model = null; if (LBool.True == z3.CheckAndGetModel(ref model)) { lo = model.GetNumeralValueInt(model.Eval(a)); model.Dispose(); lo = Maximize(a, lo, hi); } else hi = mid; z3.Pop(); } return hi; }