Johannes Kepler University Linz, Austria 2008 Leonardo de Moura and Nikolaj Bjørner Microsoft Research.

Slides:



Advertisements
Similar presentations
Demand-driven inference of loop invariants in a theorem prover
Advertisements

Writing specifications for object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 21 Jan 2005 Invited talk, AIOOL 2005 Paris,
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Challenges in increasing tool support for programming K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 23 Sep 2004 ICTAC Guiyang, Guizhou, PRC joint.
Leonardo de Moura Microsoft Research. Z3 is a new solver developed at Microsoft Research. Development/Research driven by internal customers. Free for.
Satisfiability Modulo Theories and Network Verification Nikolaj Bjørner Microsoft Research Formal Methods and Networks Summer School Ithaca, June
Synthesis, Analysis, and Verification Lecture 04c Lectures: Viktor Kuncak VC Generation for Programs with Data Structures “Beyond Integers”
50.530: Software Engineering
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) ⋁ ⋀ ¬ ⋁ ⋀
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
1 Regression-Verification Benny Godlin Ofer Strichman Technion.
Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI.
Logic as the lingua franca of software verification Ken McMillan Microsoft Research TexPoint fonts used in EMF: A A A A A Joint work with Andrey Rybalchenko.
Interpolants from Z3 proofs Ken McMillan Microsoft Research TexPoint fonts used in EMF: A A A A A.
Panel on Decision Procedures Panel on Decision Procedures Randal E. Bryant Lintao Zhang Nils Klarlund Harald Ruess Sergey Berezin Rajeev Joshi.
Automatic Predicate Abstraction of C-Programs T. Ball, R. Majumdar T. Millstein, S. Rajamani.
Leonardo de Moura and Nikolaj Bjørner Microsoft Research.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA, USA Invited talk Informatics Education in Europe (IEE III’08)
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
An Integration of Program Analysis and Automated Theorem Proving Bill J. Ellis & Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.
Nikolaj Bjørner Microsoft Research Lecture 3. DayTopicsLab 1Overview of SMT and applications. SAT solving, Z3 Encoding combinatorial problems with Z3.
Contracts, tools, verification K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Keynote, ASWEC 2010; Auckland, NZ;
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.
Proof-system search ( ` ) Interpretation search ( ² ) Main search strategy DPLL Backtracking Incremental SAT Natural deduction Sequents Resolution Main.
1 Deciding separation formulas with SAT Ofer Strichman Sanjit A. Seshia Randal E. Bryant School of Computer Science, Carnegie Mellon University.
Yeting Ge Leonardo de Moura New York University Microsoft Research.
Program Exploration with Pex Nikolai Tillmann, Peli de Halleux Pex
Nikolaj Bjørner Leonardo de Moura Nikolai Tillmann Microsoft Research August 11’th 2008.
Describing Syntax and Semantics
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Caltech Pasadena, CA 12 November 2009.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Nikolaj Bjørner and Leonardo de Moura Microsoft Research Microsoft Corporation McMaster University, November 28, 2007.
Leonardo de Moura Microsoft Research. Quantifiers in Satisfiability Modulo Theories Logic is “The Calculus of Computer Science” (Z. Manna). High computational.
Towards Scalable Modular Checking of User-defined Properties Thomas Ball, MSR Brian Hackett, Mozilla Shuvendu Lahiri, MSR Shaz Qadeer, MSR Julien Vanegue,
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
Leonardo de Moura and Nikolaj Bjørner Microsoft Research.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Leonardo de Moura Microsoft Research. Is formula F satisfiable modulo theory T ? SMT solvers have specialized algorithms for T.
SAT & SMT. Software Verification & Testing SAT & SMT Test case generation Predicate Abstraction Verifying Compilers.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
Leonardo de Moura Microsoft Research. SATTheoriesSMT Arithmetic Bit-vectors Arrays …
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

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.
Boolean Satisfiability Present and Future
Automated tactics for separation logic VeriML Reconstruct Z3 Proof Safe incremental type checker Certifying code transformation Proof carrying hardware.
Symbolic and Concolic Execution of Programs Information Security, CS 526 Omar Chowdhury 10/7/2015Information Security, CS 5261.
Welcome to CS 477 Formal Methods in Software Development Spring 2011 Madhusudan Parthasarathy ( Madhu )
Nikolaj Bjørner Microsoft Research DTU Winter course January 2 nd 2012 Organized by Flemming Nielson & Hanne Riis Nielson.
Leonardo de Moura Microsoft Research. Applications and Challenges in Satisfiability Modulo Theories Verification/Analysis tools need some form of Symbolic.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
Logic Engines as a Service Leonardo de Moura and Nikolaj Bjørner Microsoft Research.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Finding Conflicting Instances of Quantified Formulas in SMT Andrew Reynolds Cesare Tinelli Leonardo De Moura July 18, 2014.

Dafny An automatic program verifier for functional correctness
Specification techniques for verifying object-oriented software
Satisfiability Modulo Theories
Reasoning about Comprehensions with First-Order SMT Solvers
Matching Logic An Alternative to Hoare/Floyd Logic
A Progressive Approach for Satisfiability Modulo Theories
Dafny An automatic program verifier for functional correctness
Presentation transcript:

Johannes Kepler University Linz, Austria 2008 Leonardo de Moura and Nikolaj Bjørner Microsoft Research

Industry tools rely on powerful verification engines. Boolean satisfiability (SAT) solvers. Binary decision diagrams (BDDs). Satisfiability Modulo Theories (SMT) The next generation of verification engines. SAT solver + Theories Some problems are more naturally expressed in SMT. More automation. Microsoft

ArithmeticArithmetic Array Theory Uninterpreted Functions

SMT-Solvers: Argo-Lib, Ario, Barcelogic, CVC, CVC Lite, CVC3, ExtSAT, Fx7, Fx8, Harvey, HTP, ICS, Jat, MathSAT, Sateen, Simplify, Spear, STeP, STP, SVC, TSAT, TSAT++, UCLID, Yices, Zap, Z3 (Microsoft) SMT-LIB: library of benchmarks. SMT-Comp: annual SMT-Solver competition. Microsoft

Test-case generation. Pex, Yogi, Vigilante, Sage Verifying compiler. Spec#, VCC, Havoc ESC/Java Model Checking & Predicate Abstraction. SLAM/SDV, Yogi Bounded Model Checking (BMC) & k-induction Planning & Scheduling Equivalence Checking. Microsoft

Z3 is a new SMT solver developed at Microsoft. Version 0.1 competed in SMT-COMP’07. Version 1.2 is the latest release. Free for academic research. It is used in several program analysis, verification, test- case generation projects at Microsoft. Microsoft

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) Microsoft

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

Model-based Theory Combination How to efficiently combine theory solvers? Use models to control Theory Combination. E-matching abstract machine Term indexing data-structures for incremental matching modulo equalities. Relevancy propagation Use Tableau advantages with DPLL engine Microsoft

Test (correctness + usability) is 95% of the deal: Dev/Test is 1-1 in products. Developers are responsible for unit tests. Tools: Annotations and static analysis (SAL, ESP) File Fuzzing Unit test case generation: program analysis tools, automated theorem proving. Microsoft

Security bugs can be very expensive: Cost of each MS Security Bulletin: $600K to $Millions. Cost due to worms (Slammer, CodeRed, etc.): $Billions. The real victim is the customer. Most security exploits are initiated via files or packets: Ex: Internet Explorer parses dozens of files formats. Security testing: hunting for million-dollar bugs Write A/V (always exploitable), Read A/V (sometimes exploitable), NULL-pointer dereference, Division-by-zero (harder to exploit but still DOS attack),... Microsoft

Two main techniques used by “black hats”: Code inspection (of binaries). Black box fuzz testing. Black box fuzz testing: A form of black box random testing. Randomly fuzz (=modify) a well formed input. Grammar-based fuzzing: rules to encode how to fuzz. Heavily used in security testing At MS: several internal tools. Conceptually simple yet effective in practice Microsoft

Execution Path Run Test and Monitor Path Condition Unexplored path Solve seed New input Test Inputs Nikolai Tillmann, Peli de Halleux, Patrice Godefroid Aditya Nori, Jean Philippe Martin, Miguel Castro, Manuel Costa, Lintao Zhang Constraint System Known Paths Vigilante

Microsoft error(); z > x-y Return z Input x, y z := x + y z > x-y Return z Input x, y z := x + y error(); z > x-y Input x, y z := x + y Solve: z = x + y  z > x - ySolve: z = x + y  z  x - y x = 1, y = 2 x = -2, y = -3

Formulas may be a big conjunction Pre-processing step Eliminate variables and simplify input format Incremental: solve several similar formulas New constraints are asserted. push and pop: (user) backtracking Lemma reuse Microsoft

“Small Models” Given a formula F, find a model M, that minimizes the value of the variables x 0 … x n Eager (cheap) Solution: Assert C. While satisfiable Peek x i such that M[x i ] is big Assert x i < c, where c is a small constant Return last found model True Arithmetic × Machine Arithmetic Microsoft

A verifying compiler uses automated reasoning to check the correctness of a program that is compiles. Correctness is specified by types, assertions,... and other redundant annotations that accompany the program. Tony Hoare 2004

Microsoft VCC Boogie Hyper-V Rustan Leino, Mike Barnet, Michal Mosƙal, Shaz Qadeer, Shuvendu Lahiri, Herman Venter, Peter Muller, Wolfram Schulte, Ernie Cohen Verification condition Bug path HAVOC

Source Language C# + goodies = Spec# Specifications method contracts, invariants, field and type annotations. Program Logic: Dijkstra’s weakest preconditions. Automatic Verification type checking, verification condition generation (VCG), automatic theorem proving (SMT) Microsoft Spec# (annotated C#) Boogie PL Spec# Compiler VC Generator Formulas Automatic Theorem Prover

Spec# (annotated C#) ⇒ Boogie PL ⇒ Formulas Example: class C { private int a, z; invariant z > 0; public void M() requires a != 0; { z = 100/a; } } Weakest preconditions: wp(S; T,Q) = wp(S, wp(T,Q)) wp(assert C,Q) = C ∧ Q Microsoft

Meta OS: small layer of software between hardware and OS. Mini: 60K lines of non-trivial concurrent systems C code. Critical: simulates a number of virtual x64 machines Trusted: a grand verification challenge. Microsoft Hardware Hypervisor

VCC translates an annotated C program into a Boogie PL program. Boogie generates verification conditions: Z3 (automatic) Isabelle (interactive) A C-ish memory model Abstract heaps Bit-level precision The verification project has very recently started. It is a multi-man multi-year effort. Microsoft

A tool for specifying and checking properties of systems software written in C. It also translates annotated C into Boogie PL. It allows the expression of richer properties about the program heap and data structures such as linked lists and arrays. HAVOC is being used to specify and check: Complex locking protocols over heap-allocated data structures in Windows. Properties of collections such as IRP queues in device drivers. Correctness properties of custom storage allocators. Microsoft

Quantifiers, quantifiers, quantifiers, … Modeling the runtime Frame axioms (“what didn’t change”) Users provided assertions (e.g., the array is sorted) Prototyping decision procedures (e.g., reachability, heaps, …) Solver must be fast in satisfiable instances. Trade-off between precision and performance. Candidate (Potential) Models Microsoft

Semantically, ∀ x 1, …, x n.F is equivalent to the infinite conjunction  1 (F)   2 (F)  … Solvers use heuristics to select from this infinite conjunction those instances that are “relevant”. The key idea is to treat an instance (F) as relevant whenever it contains enough terms that are represented in the solver state. Non ground terms p from F are selected as patterns. E-matching (matching modulo equalities) is used to find instances of the patterns. Example: f(a, b) matches the pattern f(g(x), x) if a = g(b). Microsoft

E-matching is NP-Hard The number of matches can be exponential. It is not refutationally complete. In practice: Indexing techniques for fast retrieval. Incremental E-matching. Microsoft

∀ x.f(g(x)) = x Pattern: f(g(x)) Atoms: a = g(b), b = c, f(a) ≠ c Instantiate f(g(b)) = b Microsoft

Z3 uses a E-matching abstract machine. Patterns → code sequence. Abstract machine executes the code. Z3 uses new algorithms that identify matches on E- graphs incrementally and efficiently. E-matching code trees. Inverted path index. Z3 garbage collects clauses, together with their atoms and terms, that were useless in closing branches. Microsoft

Ella Bounimova, Vlad Levin, Jakob Lichtenberg, Tom Ball, Sriram Rajamani, Byron Cook

SLAM/SDV is a software model checker. Application domain: device drivers. Architecture: c2bp C program → boolean program (predicate abstraction). bebop Model checker for boolean programs. newton Model refinement (check for path feasibility) SMT solvers are used to perform predicate abstraction and to check path feasibility. c2bp makes several calls to the SMT solver. The formulas are relatively small. Microsoft

Given a C program P and F = {p 1, …, p n }. Produce a Boolean program B(P, F) Same control flow structure as P. Boolean variables {b 1, …, b n } to match {p 1, …, p n }. Properties true in B(P, F) are true in P. Each p i is a pure Boolean expression. Each p i represents set of states for which p i is true. Performs modular abstraction. Microsoft

Implies F (e) Best Boolean function over F that implies e. ImpliedBy F (e) Best Boolean function over F that is implied by e. ImpliedBy F (e) = not Implies F (not e) Microsoft

minterm m = l 1 ∧... ∧ l n, where l i = p i, or l i = not p i. Implies F (e): disjunction of all minterms that imply e. Naive approach Generate all 2 n possible minterms. For each minterm m, use SMT solver to check validity of m ⇒ e. Many possible optimizations Microsoft

Given an error path p in the Boolean program B. Is p a feasible path of the corresponding C program? Yes: found a bug. No: find predicates that explain the infeasibility. Execute path symbolically. Check conditions for inconsistency using SMT solver. Microsoft

Z3 is part of SDV 2.0 (Windows 7) All-SAT Fast Predicate Abstraction Unsatisfiable cores: Why the path is not feasible?

Bounded model-checking of model programs Termination Security protocols Business application modeling Cryptography Model Based Testing (SQL-Server) Your killer-application here Microsoft

Coming soon (Z3 2.0): Proofs & Unsat cores Superposition Calculus Decidable Fragments Machine Learning Non linear arithmetic (Gröbner Bases) Inductive Datatypes Improved Array & Bit-vector theories Several performance improvements More “customers” & Applications Microsoft

Formal verification is hot at Microsoft. Z3 is a new SMT solver from Microsoft Research. Z3 is used in several projects. Z3 is freely available for academic research: Microsoft

© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. Your SMT problem. Our joy.