Leonardo de Moura Microsoft Research. Quantifiers in Satisfiability Modulo Theories Logic is “The Calculus of Computer Science” (Z. Manna). High computational.

Slides:



Advertisements
Similar presentations
SMELS: Sat Modulo Equality with Lazy Superposition Christopher Lynch – Clarkson Duc-Khanh Tran - MPI.
Advertisements

Quantified Invariant Generation using an Interpolating Saturation Prover Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
Automated Theorem Proving
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Quantified Invariant Generation using an Interpolating Saturation Prover Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
The Model Evolution Calculus with Built-in Theories Peter Baumgartner MPI Informatik, Saarbrücken
Inference Rules Universal Instantiation Existential Generalization
50.530: Software Engineering
SLD-resolution Introduction Most general unifiers SLD-resolution
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) ⋁ ⋀ ¬ ⋁ ⋀
Verification of Functional Programs in Scala Philippe Suter (joint work w/ Ali Sinan Köksal and Viktor Kuncak) ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE,
Linked List Implementation class List { private List next; private Object data; private static List root; private static int size; public static void addNew(Object.
UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Interpolants from Z3 proofs Ken McMillan Microsoft Research TexPoint fonts used in EMF: A A A A A.
CSC 685 Logic Review. Logic: Modeling Human Reasoning syllogistic logic Syllogistic Logic (Aristotle). all/some X are/not Y Propositional Logic (Boole).
Leonardo de Moura and Nikolaj Bjørner Microsoft Research.
Proof translation from CVC3 to Hol light Yeting Ge Acsys Mar 5, 2008.
Leonardo de Moura Microsoft Research. Satisfiability Modulo Theories: A Calculus of Computation Verification/Analysis tools need some form of Symbolic.
Computability and Complexity 9-1 Computability and Complexity Andrei Bulatov Logic Reminder (Cnt’d)
Computability and Complexity 8-1 Computability and Complexity Andrei Bulatov Logic Reminder.
Plan for today Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Nikolaj Bjørner Microsoft Research Lecture 3. DayTopicsLab 1Overview of SMT and applications. SAT solving, Z3 Encoding combinatorial problems with Z3.
Automated Theorem Proving Lecture 4.   Formula := A |  |    A  Atom := b | t = 0 | t < 0 | t  0 t  Term := c | x | t + t | t – t | ct | Select(m,t)
Yeting Ge Leonardo de Moura New York University Microsoft Research.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
ECI 2007: Specification and Verification of Object- Oriented Programs Lecture 4.
Austin, Texas 2011 Theorem Proving Tools for Program Analysis SMT Solvers: Yices & Z3 Austin, Texas 2011 Nikolaj Bjørner 2, Bruno Dutertre 1, Leonardo.
1 First order theories. 2 Satisfiability The classic SAT problem: given a propositional formula , is  satisfiable ? Example:  Let x 1,x 2 be propositional.
Leonardo de Moura Microsoft Research. Many approaches Graph-based for difference logic: a – b  3 Fourier-Motzkin elimination: Standard Simplex General.
Deciding a Combination of Theories - Decision Procedure - Changki pswlab Combination of Theories Daniel Kroening, Ofer Strichman Presented by Changki.
Nikolaj Bjørner, Leonardo de Moura Microsoft Research Bruno Dutertre SRI International.
Boolean Satisfiability and SAT Solvers
CMU, Oct 4 DPLL-based Checkers for Satisfiability Modulo Theories Cesare Tinelli Department of Computer Science The University of Iowa Joint work with.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
Leonardo de Moura and Nikolaj Bjørner Microsoft Research.
UIUC CS 497: Section EA Lecture #3 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Introduction to Satisfiability Modulo Theories
Leonardo de Moura Microsoft Research. Satisfiability Modulo Theories: An Appetizer Verification/Analysis tools need some form of Symbolic Reasoning.
Leonardo de Moura Microsoft Research. Is formula F satisfiable modulo theory T ? SMT solvers have specialized algorithms for T.
The Bernays-Schönfinkel Fragment of First-Order Autoepistemic Logic Peter Baumgartner MPI Informatik, Saarbrücken.
SAT & SMT. Software Verification & Testing SAT & SMT Test case generation Predicate Abstraction Verifying Compilers.
First Order Predicate Logic
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Leonardo de Moura Microsoft Research. SATTheoriesSMT Arithmetic Bit-vectors Arrays …
Resolution Strategies One common strategy for applying resolution is called level saturation. Here you try to resolve every pair of clauses from the original.
Leonardo de Moura Microsoft Research. Quantifiers in Satisfiability Modulo Theories Logic is “The Calculus of Computer Science” (Z. Manna). High computational.
Leonardo de Moura Microsoft Research. Verification/Analysis tools need some form of Symbolic Reasoning.
Decision methods for arithmetic Third summer school on formal methods Leonardo de Moura Microsoft Research.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 18 of 41 Friday, 01 October.
Leonardo de Moura and Nikolaj Bjørner Microsoft Research.
Symbolic and Concolic Execution of Programs Information Security, CS 526 Omar Chowdhury 10/7/2015Information Security, CS 5261.
Nikolaj Bjørner Microsoft Research DTU Winter course January 2 nd 2012 Organized by Flemming Nielson & Hanne Riis Nielson.
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
Leonardo de Moura Microsoft Research. Applications and Challenges in Satisfiability Modulo Theories Verification/Analysis tools need some form of Symbolic.
AN INTERPOLATING THEOREM PROVER K.L. McMillan Cadence Berkley Labs.
CS357 Lecture 13: Symbolic model checking without BDDs Alex Aiken David Dill 1.
Logic Engines as a Service Leonardo de Moura and Nikolaj Bjørner Microsoft Research.
Finding Conflicting Instances of Quantified Formulas in SMT Andrew Reynolds Cesare Tinelli Leonardo De Moura July 18, 2014.
Selected Decision Procedures and Techniques for SMT More on combination – theories sharing sets – convex theory Un-interpreted function symbols (quantifier-free.
Knowledge Repn. & Reasoning Lecture #9: Propositional Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2005.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Satisfiability Modulo Theories and DPLL(T) Andrew Reynolds March 18, 2015.
SMT-Based Verification of Parameterized Systems
Prolog syntax + Unification
Herbrand Semantics Computational Logic Lecture 15
Resolution Preliminaries
Presentation transcript:

Leonardo de Moura Microsoft Research

Quantifiers in Satisfiability Modulo Theories Logic is “The Calculus of Computer Science” (Z. Manna). High computational complexity

Quantifiers in Satisfiability Modulo Theories Is formula F satisfiable modulo theory T ? SMT solvers have specialized algorithms for T

Quantifiers in Satisfiability Modulo Theories b + 2 = c and f(read(write(a,b,3), c-2) ≠ f(c-b+1)

Quantifiers in Satisfiability Modulo Theories ArithmeticArithmetic b + 2 = c and f(read(write(a,b,3), c-2) ≠ f(c-b+1)

Quantifiers in Satisfiability Modulo Theories ArithmeticArithmetic Array Theory b + 2 = c and f(read(write(a,b,3), c-2) ≠ f(c-b+1)

Quantifiers in Satisfiability Modulo Theories ArithmeticArithmetic Array Theory Uninterpreted Functions b + 2 = c and f(read(write(a,b,3), c-2) ≠ f(c-b+1)

A Theory is a set of sentences Alternative definition: A Theory is a class of structures Th(M) is the set of sentences that are true in the structure M Quantifiers in Satisfiability Modulo Theories

VCC Hyper-V Terminator T-2 NModel HAVOC F7 SAGE Vigilante SpecExplorer

Quantifiers in Satisfiability Modulo Theories Z3 is a new solver developed at Microsoft Research. Development/Research driven by internal customers. Free for academic research. Interfaces: Z3 TextC/C++.NETOCaml

Quantifiers in Satisfiability Modulo Theories F  TF  T First-order Theorem Prover T may not have a finite axiomatization

Quantifiers in Satisfiability Modulo Theories For some theories, SMT can be reduced to SAT bvmul 32 (a,b) = bvmul 32 (b,a) Higher level of abstraction

For most SMT solvers: F is a set of ground formulas Quantifiers in Satisfiability Modulo Theories Many Applications Bounded Model Checking Test-Case Generation

M | F Quantifiers in Satisfiability Modulo Theories Partial model Set of clauses

Guessing Quantifiers in Satisfiability Modulo Theories p,  q | p  q,  q  r p | p  q,  q  r

Deducing Quantifiers in Satisfiability Modulo Theories p, s| p  q,  p  s p | p  q,  p  s

Backtracking Quantifiers in Satisfiability Modulo Theories p, s| p  q, s  q,  p   q p,  s, q | p  q, s  q,  p   q

Efficient decision procedures for conjunctions of ground atoms. Quantifiers in Satisfiability Modulo Theories a=b, a 10 Difference LogicBelmann-Ford Uninterpreted functionsCongruence closure Linear arithmeticSimplex Efficient algorithms

How to represent the model of satisfiable formulae? Functor: Given a model M for T Generate a model M’ for F (modulo T) Example: F: f(a) = 0 and a > b and f(b) > f(a) + 1 Quantifiers in Satisfiability Modulo Theories SymbolInterpretation a1 b0 fite(x=1, 0, 2) M’:

How to represent the model of satisfiable formulae? Functor: Given a model M for T Generate a model M’ for F (modulo T) Example: F: f(a) = 0 and a > b and f(b) > f(a) + 1 Quantifiers in Satisfiability Modulo Theories SymbolInterpretation a1 b0 fite(x=1, 0, 2) Interpretation is given using T-symbols M’:

How to represent the model of satisfiable formulae? Functor: Given a model M for T Generate a model M’ for F (modulo T) Example: F: f(a) = 0 and a > b and f(b) > f(a) + 1 Quantifiers in Satisfiability Modulo Theories SymbolInterpretation a1 b0 fite(x=1, 0, 2) Non ground term (lambda expression) Non ground term (lambda expression) M’:

Quantifiers in Satisfiability Modulo Theories SymbolInterpretation a1 b0 fite(x=1, 0, 2) M’: Is  x: f(x) > 0 satisfied by M’? Yes, not (ite(k=1,0,2) > 0) is unsatisfiable

SymbolInterpretation a1 b0 fite(x=1, 0, 2) M’: Is  x: f(x) > 0 satisfied by M’? Yes, not (ite(k=1,0,2) > 0) is unsatisfiable Negated quantifier Replaced f by its interpretation Replaced x by fresh constant k Negated quantifier Replaced f by its interpretation Replaced x by fresh constant k

Quantifiers in Satisfiability Modulo Theories Annotated Program Verification Condition F pre/post conditions invariants and other annotations pre/post conditions invariants and other annotations

BIG and-or tree (ground) BIG and-or tree (ground)  Axioms ( (non-ground)  Axioms ( (non-ground) Control & Data Flow

Quantifiers, quantifiers, quantifiers, … Modeling the runtime  h,o,f: IsHeap(h)  o ≠ null  read(h, o, alloc) = t  read(h,o, f) = null  read(h, read(h,o,f),alloc) = t Quantifiers in Satisfiability Modulo Theories

Quantifiers, quantifiers, quantifiers, … Modeling the runtime Frame axioms  o, f: o ≠ null  read(h 0, o, alloc) = t  read(h 1,o,f) = read(h 0,o,f)  (o,f)  M Quantifiers in Satisfiability Modulo Theories

Quantifiers, quantifiers, quantifiers, … Modeling the runtime Frame axioms User provided assertions  i,j: i  j  read(a,i)  read(b,j) Quantifiers in Satisfiability Modulo Theories

Quantifiers, quantifiers, quantifiers, … Modeling the runtime Frame axioms User provided assertions Theories  x: p(x,x)  x,y,z: p(x,y), p(y,z)  p(x,z)  x,y: p(x,y), p(y,x)  x = y Quantifiers in Satisfiability Modulo Theories

Quantifiers, quantifiers, quantifiers, … Modeling the runtime Frame axioms User provided assertions Theories Solver must be fast in satisfiable instances. Quantifiers in Satisfiability Modulo Theories We want to find bugs!

Grand challenge: Microsoft Hypervisor 70k lines of dense C code VCs have several Mb Thousands of non ground clauses Developers are willing to wait at most 5 min per VC Quantifiers in Satisfiability Modulo Theories

Heuristic quantifier instantiationCombining SMT with Saturation proversComplete quantifier instantiationDecidable fragmentsModel based quantifier instantiation Quantifiers in Satisfiability Modulo Theories

SMT solvers use heuristic quantifier instantiation. E-matching (matching modulo equalities). Example:  x: f(g(x)) = x { f(g(x)) } a = g(b), b = c, f(a)  c Trigger

Quantifiers in Satisfiability Modulo Theories SMT solvers use heuristic quantifier instantiation. E-matching (matching modulo equalities). Example:  x: f(g(x)) = x { f(g(x)) } a = g(b), b = c, f(a)  c x=b f(g(b)) = b Equalities and ground terms come from the partial model M

Quantifiers in Satisfiability Modulo Theories Integrates smoothly with DPLL. Software verification problems are big & shallow. Decides useful theories: Arrays Partial orders …

Quantifiers in Satisfiability Modulo Theories E-matching is NP-Hard. In practice

Quantifiers in Satisfiability Modulo Theories Trigger: f(x1, g(x1, a), h(x2), b) Trigger: f(x1, g(x1, a), h(x2), b) Instructions: 1.init(f, 2) 2.check(r4, b, 3) 3.bind(r2, g, r5, 4) 4.compare(r1, r5, 5) 5.check(r6, a, 6) 6.bind(r3, h, r7, 7) 7.yield(r1, r7) Instructions: 1.init(f, 2) 2.check(r4, b, 3) 3.bind(r2, g, r5, 4) 4.compare(r1, r5, 5) 5.check(r6, a, 6) 6.bind(r3, h, r7, 7) 7.yield(r1, r7) CompilerCompiler Similar triggers share several instructions. Combine code sequences in a code tree

Quantifiers in Satisfiability Modulo Theories E-matching needs ground seeds.  x: p(x),  x: not p(x)

Quantifiers in Satisfiability Modulo Theories E-matching needs ground seeds. Bad user provided triggers:  x: f(g(x))=x { f(g(x)) } g(a) = c, g(b) = c, a  b Trigger is too restrictive

Quantifiers in Satisfiability Modulo Theories E-matching needs ground seeds. Bad user provided triggers:  x: f(g(x))=x { g(x) } g(a) = c, g(b) = c, a  b More “liberal” trigger More “liberal” trigger

Quantifiers in Satisfiability Modulo Theories E-matching needs ground seeds. Bad user provided triggers:  x: f(g(x))=x { g(x) } g(a) = c, g(b) = c, a  b, f(g(a)) = a, f(g(b)) = b a=b

Quantifiers in Satisfiability Modulo Theories E-matching needs ground seeds. Bad user provided triggers. It is not refutationally complete. False positives

Quantifiers in Satisfiability Modulo Theories Tight integration: DPLL + Saturation solver. BIG and-or tree (ground) BIG and-or tree (ground) Axioms ( (non-ground) Axioms ( (non-ground) Saturation Solver DPLL + Theories

Quantifiers in Satisfiability Modulo Theories Inference rule: DPLL(  ) is parametric. Examples: Resolution Superposition calculus …

Quantifiers in Satisfiability Modulo Theories M | F Partial model Set of clauses

Quantifiers in Satisfiability Modulo Theories p(a) | p(a)  q(a),  x:  p(x)  r(x),  x: p(x)  s(x)

Quantifiers in Satisfiability Modulo Theories p(a) | p(a)  q(a),  p(x)  r(x), p(x)  s(x)

Quantifiers in Satisfiability Modulo Theories p(a) | p(a)  q(a),  p(x)  r(x), p(x)  s(x) p(a) | p(a)  q(a),  p(x)  r(x), p(x)  s(x), r(x)  s(x) Resolution

Using ground atoms from M: M | F Main issue: backtracking. Hypothetical clauses: H  C Quantifiers in Satisfiability Modulo Theories (regular) Clause (hypothesis) Ground literals (hypothesis) Ground literals Track literals from M used to derive C

Quantifiers in Satisfiability Modulo Theories p(a) | p(a)  q(a),  p(x)  r(x) p(a) | p(a)  q(a),  p(x)  r(x), p(a)  r(a) p(a),  p(x)  r(x) r(a)

Quantifiers in Satisfiability Modulo Theories p(a), r(a) | p(a)  q(a),  p(a)  r(a), p(a)  r(a), …

Quantifiers in Satisfiability Modulo Theories p(a), r(a) | p(a)  q(a),  p(a)  r(a), p(a)  r(a), … p(a) is removed from M  p(a) | p(a)  q(a),  p(a)  r(a), …

Quantifiers in Satisfiability Modulo Theories Saturation solver ignores non-unit ground clauses. p(a) | p(a)  q(a),  p(x)  r(x)

Quantifiers in Satisfiability Modulo Theories Saturation solver ignores non-unit ground clauses. It is still refutanionally complete if:  has the reduction property. BIG and-or tree (ground) BIG and-or tree (ground) Axioms ( (non-ground) Axioms ( (non-ground) Saturation Solver DPLL + Theories

DPLL + Theories DPLL + Theories Saturation Solver Saturation Solver Quantifiers in Satisfiability Modulo Theories Saturation solver ignores non-unit ground clauses. It is still refutanionally complete if:  has the reduction property. Ground literals Ground clauses

Quantifiers in Satisfiability Modulo Theories Interpreted symtbols  (f(a) > 2), f(x) > 5 It is refutationally complete if Interpreted symbols only occur in ground clauses Non ground clauses are variable inactive “Good” ordering is used

Quantifiers in Satisfiability Modulo Theories There is no sound and refutationally complete procedure for linear arithmetic + unintepreted function symbols

Quantifiers in Satisfiability Modulo Theories Universal variables only occur as arguments of uninterpreted symbols.  x: f(x) + 1 > g(f(x))  x,y: f(x+y) = f(x) + f(y)

Quantifiers in Satisfiability Modulo Theories Relax restriction on the occurrence of universal variables. not (x  y) not (x  t) f(x + c) x = c t …

Quantifiers in Satisfiability Modulo Theories If F is in the almost uninterpreted fragment Convert F into an equisatisfiable (modulo T) set of ground clauses F* F* may be infinite It is a decision procedure if F* is finite Subsumes EPR, Array Property Fragment, Stratified Vocabularies for Many Sorted Logic

Quantifiers in Satisfiability Modulo Theories F induces a system  F of set constraints S k,i set of ground instances for variable x i in clause C k A f,j set of ground j-th arguments of f j-th argument of f in clause C k Set Constraint a ground term t t  A f,j t [x 1,…,x n ] t [S k,1,…,S k,n ]  A f,j xixi S k,i  A f,j F* is generated using the least solution of  F F* = { C k [S k,1,…,S k,n ] | C k  F }

Quantifiers in Satisfiability Modulo Theories F induces a system  F of set constraints S k,i set of ground instances for variable x i in clause C k A f,j set of ground j-th arguments of f j-th argument of f in clause C k Set Constraint a ground term t t  A f,j t [x 1,…,x n ] t [S k,1,…,S k,n ]  A f,j xixi S k,i  A f,j F* is generated using the least solution of  F F* = { C k [S k,1,…,S k,n ] | C k  F } We assume the least solution is not empty

Quantifiers in Satisfiability Modulo Theories g(x 1, x 2 ) = 0  h(x 2 ) = 0, g(f(x 1 ),b) + 1 < f(x 1 ), h(b) = 1, f(a) = 0 S 1,1 = A g,1 = { f(a) } S 1,2 = A g,2 = A h,1 = {b} S 2,1 = A f,1 = {a} S 1,1 = A g,1, S 1,2 = A g,2, S 1,2 = A h,1 S 2,1 = A f,1, f(S 2,1 )  A g,1, b  A g,2 b  A h,1, a  A f,1 Least solution F FF g(f(a), b) = 0  h(b) = 0, g(f(a),b) + 1 < f(a), h(b) = 1, f(a) = 0 F*

Quantifiers in Satisfiability Modulo Theories Compactness A set F of first order sentences is unsatisifiable iff it contains an unsatisfiable finite subset If we view T as a set of sentences Apply compactness to T  F*

Quantifiers in Satisfiability Modulo Theories  x: f(f(x)) > f(x)  x: f(x) < a f(0) = 0 f(f(0)) > f(0), f(f(f(0))) > f(f(0)), … f(0) < a, f(f(0)) < a, … f(0) = 0 Satisfiable if T is Th(Z), but unsatisfiable T is the the class of structures Exp(Z)

Quantifiers in Satisfiability Modulo Theories Generate candidate model Model check Instantiate quantifiers

Quantifiers in Satisfiability Modulo Theories There is no winner Portfolio of algorithms/techniques

Joint work with Y. Hamadi (MSRC) and C. Wintersteiger Multi-core & Multi-node (HPC) Different strategies in parallel Collaborate exchanging lemmas Quantifiers in Satisfiability Modulo Theories Strategy 1 Strategy 2 Strategy 3 Strategy 4 Strategy 5

Quantifiers in Satisfiability Modulo Theories Some VCs produced by verifying compilers are very challenging Most VCs contain many non ground formulas Z3 2.0 won all  -divisions in SMT-COMP’08 Many challenges Many approaches/algorithms Thank You!