Constraint-based Invariant Inference over Predicate Abstraction Sumit Gulwani Ramarathnam Venkatesan Microsoft Research, Redmond Saurabh Srivastava University.

Slides:



Advertisements
Similar presentations
Assertion Checking over Combined Abstraction of Linear Arithmetic and Uninterpreted Functions Sumit Gulwani Microsoft Research, Redmond Ashish Tiwari SRI.
Advertisements

Combining Abstract Interpreters Sumit Gulwani Microsoft Research Redmond, Group Ashish Tiwari SRI RADRAD.
Static Analysis of Heap-manipulating Low-level software Sumit GulwaniAshish Tiwari MSR, Redmond SRI International.
Program Verification using Probabilistic Techniques Sumit Gulwani Microsoft Research Invited Talk: VSTTE Workshop August 2006 Joint work with George Necula.
Logical Abstract Interpretation Sumit Gulwani Microsoft Research, Redmond.
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.
Demand-driven inference of loop invariants in a theorem prover
Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 1 Summer school on Formal Models.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2013 Lecture 4.
Satisfiability Modulo Computable Functions Philippe Suter, Ali Sinan Köksal, and Viktor Kuncak ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE, SWITZERLAND Photo:
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Software Model Checking with SMT Ken McMillan Microsoft Research TexPoint fonts used in EMF: A A A A A.
From Verification to Synthesis Sumit Gulwani Microsoft Research, Redmond August 2013 Marktoberdorf Summer School Lectures: Part 1.
A Program Transformation For Faster Goal-Directed Search Akash Lal, Shaz Qadeer Microsoft Research.
An Introduction to the Model Verifier verds Wenhui Zhang September 15 th, 2010.
On Solving Presburger and Linear Arithmetic with SAT Ofer Strichman Carnegie Mellon University.
Lecture #21 Software Model Checking: predicate abstraction Thomas Ball Testing, Verification and Measurement Microsoft Research.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
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.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Rahul Sharma, Saurabh Gupta, Bharath Hariharan, Alex Aiken, and Aditya Nori (Stanford, UC Berkeley, Microsoft Research India) Verification as Learning.
August Moscow meeting1August Moscow meeting1August Moscow meeting11 Deductive tools in insertion modeling verification A.Letichevsky.
Program Analysis as Constraint Solving Sumit Gulwani (MSR Redmond) Ramarathnam Venkatesan (MSR Redmond) Saurabh Srivastava (Univ. of Maryland) TexPoint.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Review of topics Final exam : -May 2nd to May 7 th - Projects due on May 7th.
Symmetry-Aware Predicate Abstraction for Shared-Variable Concurrent Programs Alastair Donaldson, Alexander Kaiser, Daniel Kroening, and Thomas Wahl Computer.
CS 355 – Programming Languages
Revisiting Generalizations Ken McMillan Microsoft Research Aws Albarghouthi University of Toronto.
Rahul Sharma Işil Dillig, Thomas Dillig, and Alex Aiken Stanford University Simplifying Loop Invariant Generation Using Splitter Predicates.
Program Verification as Probabilistic Inference Sumit Gulwani Nebojsa Jojic Microsoft Research, Redmond.
Using Statically Computed Invariants Inside the Predicate Abstraction and Refinement Loop Himanshu Jain Franjo Ivančić Aarti Gupta Ilya Shlyakhter Chao.
1 Predicate Abstraction of ANSI-C Programs using SAT Edmund Clarke Daniel Kroening Natalia Sharygina Karen Yorav (modified by Zaher Andraus for presentation.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 0 Summer School on Logic and Theorem-Proving in Programming.
Predicate Abstraction for Software and Hardware Verification Himanshu Jain Model checking seminar April 22, 2005.
VS 3 : Verification and Synthesis using SMT Solvers SMT Solvers for Program Verification Saurabh Srivastava * Sumit Gulwani ** Jeffrey S. Foster * * University.
Software Verification Bertrand Meyer Chair of Software Engineering Lecture 2: Axiomatic semantics.
Program Verification using Templates over Predicate Abstraction Saurabh Srivastava University of Maryland, College Park Sumit Gulwani Microsoft Research,
Describing Syntax and Semantics
Invisible Invariants: Underapproximating to Overapproximate Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan.
Formal Verification of SpecC Programs using Predicate Abstraction Himanshu Jain Daniel Kroening Edmund Clarke Carnegie Mellon University.
From Program Verification to Program Synthesis Saurabh Srivastava * Sumit Gulwani ♯ Jeffrey S. Foster * * University of Maryland, College Park ♯ Microsoft.
Constraint-based Invariant Inference. Invariants Dictionary Meaning: A function, quantity, or property which remains unchanged Property (in our context):
By: Pashootan Vaezipoor Path Invariant Simon Fraser University – Spring 09.
Boolean Satisfiability and SAT Solvers
Refinement Type Inference via Horn Constraint Optimization Kodai Hashimoto and Hiroshi Unno (University of Tsukuba, Japan)
Ethan Jackson, Nikolaj Bjørner and Wolfram Schulte Research in Software Engineering (RiSE), Microsoft Research 1. A FORMULA for Abstractions and Automated.
MathCheck: A Math Assistant Combining SAT with Computer Algebra Systems Ed Zulkoski, Vijay Ganesh, Krzysztof Czarnecki University of Waterloo August 7,
Application: Correctness of Algorithms Lecture 22 Section 4.5 Fri, Mar 3, 2006.
Chapter 3 Part II Describing Syntax and Semantics.
Semantics In Text: Chapter 3.
Program Verification and Synthesis using Templates over Predicate Abstraction Saurabh Srivastava # Sumit Gulwani * Jeffrey S. Foster # # University of.
Proving Non-Termination Gupta, Henzinger, Majumdar, Rybalchenko, Ru-Gang Xu presentation by erkan.
Localization and Register Sharing for Predicate Abstraction Himanshu Jain Franjo Ivančić Aarti Gupta Malay Ganai.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
Ukrprog Formal requirement language and its applications A.Letichevsky Glushkov Institute of Cybernetics.
Leonardo de Moura Microsoft Research. Applications and Challenges in Satisfiability Modulo Theories Verification/Analysis tools need some form of Symbolic.
1 Numeric Abstract Domains Mooly Sagiv Tel Aviv University Adapted from Antoine Mine.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
11/22/2016IT 3271 A formal system:Axioms and Rules, for inferring valid specification x := m; y := n; while ¬(x=y) do if x>y then x := x-y else y := y-x.
Program Analysis via Satisfiability Modulo Path Programs
SMT-Based Verification of Parameterized Systems
Introduction to Sketching
Over-Approximating Boolean Programs with Unbounded Thread Creation
Modeling Sudoku as a CNF Formula
Predicate Abstraction
Presentation transcript:

Constraint-based Invariant Inference over Predicate Abstraction Sumit Gulwani Ramarathnam Venkatesan Microsoft Research, Redmond Saurabh Srivastava University of Maryland, College Park

Introduction Last decade has seen an engineering revolution in SAT solving. Can we bring the technology to program analysis? – This talk shows how to do that for predicate abstraction by using off-the-shelf SAT solvers, e.g. Z3 We have developed constraint-based techniques: – Program Verification – Maximally-weak Precondition Inference – Inter-procedural Summary Computation – Inferring the Maximally-general Counterexamples to Safety (i.e. finding the best descriptions of bugs). 2

Introduction Last decade has seen an engineering revolution in SAT solving. Can we bring the technology to program analysis? – This talk shows how to do that for predicate abstraction by using off-the-shelf SAT solvers, e.g. Z3 We have developed constraint-based techniques: – Program Verification – Maximally-weak Precondition Inference – Inter-procedural Summary Computation – Inferring the Maximally-general Counterexamples to Safety (i.e. finding the best descriptions of bugs). 3

Predicate Abstraction Given a fixed finite set of n predicates, associate with each predicate p i a boolean indicator b i. Sound over-approximation of the invariant at each program point represented by a boolean expression involving the indicators. ° (exp(b 1,…,b n )) = exp[p 1 /b 1, …, p n /b n ] ® ( Ã ) = Æ {exp(b 1,…,b n )| Ã ) exp[p 1 /b 1, …, p n /b n ]} Boolean expression ® ( Ã ) = Æ i=1…n {b i | Ã ) p i } ® ( Ã ) in general, not computable 4

Constraint-based Invariant Inference Guess a DNF template: k disjuncts (…) Ç (…) Ç (…) : k=3 Task: Fill out each disjunct with a boolean monomial (conjunction of indicator literals) Approach: Generate boolean constraints over indicators using the program semantics and directly solve using off-the-shelf solvers. 5

Example: Cut-points loop (int m) { assume(m > 0) x:=0; y:=0; while (x<m) { x++; y++; } assert(y = m) } x:=0; y:=0 x++; y++ x<m assume(m > 0) assert(y = m) I Invariants at cut-points* (at loop header) *Cut-set: Set of cut-points such that each cycle in CFG passes through at least one cut-point 6

Example: Simple paths and VCs x:=0; y:=0 x++; y++ x<m assume(m > 0) assert(y = m) I 7

Example: Simple paths and VCs x:=0; y:=0 x++; y++ x<m assume(m > 0) assert(y = m) I 8

Example: Simple paths and VCs x:=0; y:=0 x++; y++ assume(m > 0) assert(y = m) I assume(x ¸ m) assume(x<m) * 9

Example: Simple paths and VCs Verification condition induced by each simple path (sequence of stmt) VC computed using standard backwards weakest precondition operator ! : ! (x:=e, Á ) = Á [e/x] ! (assume(p), Á ) = p ) Á ! (assert(p), Á ) = p Æ Á ! ( ¿ 1 ; ¿ 2, Á ) = ! ( ¿ 1, ! ( ¿ 2, Á )) x:=0; y:=0 x++; y++ assume(m > 0) assert(y = m) I assume(x ¸ m) assume(x<m) * 10

Example: Simple paths and VCs ! (x:=e, Á ) = Á [e/x] ! (assume(p), Á ) = p ) Á ! (assert(p), Á ) = p Æ Á ! ( ¿ 1 ; ¿ 2, Á ) = ! ( ¿ 1, ! ( ¿ 2, Á ) x:=0; y:=0 x++; y++ assume(m > 0) assert(y = m) I assume(x ¸ m) assume(x<m) * m>0 ) I [y ! 0, x ! 0] I Æ x ¸ m ) y=m I Æ x<m ) I [y ! y+1, x ! x+1]

Example: Simple paths and VCs m>0 ) I [y ! 0, x ! 0] I Æ x ¸ m ) y=m I Æ x<m ) I [y ! y+1, x ! x

Example: Boolean Constraint Generation m>0 ) I [y ! 0, x ! 0] I Æ x<m ) I [y ! y+1, x ! x+1] Unknown invariant on the RHS; constrains how strong I can be Unknown invariant on the LHS; constrains how weak I can be Unknown on both sides; combination of above cases I Æ x ¸ m ) y=m 13

Example: Boolean Constraint Generation m>0 ) I [y ! 0, x ! 0] 1 Unknown invariant on the RHS; constrains how strong I can be Unknown invariant on the LHS; constrains how weak I can be 2 I Æ x ¸ m ) y=m x · y, x ¸ y, x<y x · m, x ¸ m, x<m y · m, y ¸ m, y<m 0 · 0, 0 ¸ 0, 0<0 0 · m, 0 ¸ m, 0<m : x · y, x ¸ y, x<y x · m, x ¸ m, x<m y · m, y ¸ m, y<m : b x ¸ m Æ : b x<y Æ : b y ¸ m (b x<m ) Ç (b y · m Æ b y ¸ m ) Ç (b x · y Æ b y · m ) y · m Æ y ¸ m x<m x · y Æ y · m 1: 2: 3: Maximally-weak ways of satisfying the constraint using the given preds. (Computed using Predicate Cover) 14

ff: rest tt: b y · x ; b y · m ; b x · y SAT Solver (fixed point computation) Example: Solving using SAT : b x ¸ m Æ : b x<y Æ : b y ¸ m (b x<m ) Ç (b y · m Æ b y ¸ m ) Ç (b x · y Æ b y · m ) (b y · m ) (b y<m Ç b y · x )) Æ : b x<m Æ : b y<m loop (int m) { assume(m > 0) x:=0; y:=0; while (x<m) { x++; y++; } assert(y = m) } I: y=x Æ y · m 15 Individual local computations

16 Program Verification Maximally-weak Precondition Inference Inter-procedural Summary Computation

Maximally-weak preconditions Instead of the precondition true as in PV, treat precondition as an unknown PRE Generate constraints as for PVnow in terms of PRE and the unknowns invariant Is Solving these yields a precondition PRE, but not necessarily the maximally-weakest Iteratively, improve the current precondition T by adding the following constraint: T ) PRE Æ : (PRE ) T) 17

Context-sensitive Inter-procedural Analysis Compute context-sensitive procedure summaries as ( A i, B i ) pre/post pairs in assume- guarantee style reasoning Constraint generation – Procedure body (guarantee): – Calls (assume): 18 P(x) { S; return y; } assume(A i ); S; assert(B i ) v = P(u); assert(A i [u/x ]); assume(B i [u/x, t/y]); v:=t

Experiments: Overview Our benchmarks are academic/small benchmark programs that demonstrate the feasibility of the technique We ran our tool in two modes: program verification and weakest precondition We are able to easily generate disjunctive invariants for which specialized techniques have been proposed earlier We collected three performance statistics: – Time for verification condition generation (weakest precondition over simple paths) – Time for boolean constraint generation (includes the predicate cover operation) – Time for SAT solving (fixed point computation) 19

Experiments: Results VC generation: 0.23sec SAT solving: 0.06sec Boolean formula generation: Overall time for invariant generation is low Predicate cover called on small formulas. Our unoptimised version performs reasonably 20

Related Work Constraint-based invariant inference: – Cousot / Sankarnarayanan et.al.: LIA using mathematical solvers – Beyer et.al.: LIA+UFS by compiling away UFS to LIA – Podelski et.al. / Bradley et.al.: Discover ranking functions We describe a reduction over the very successful domain of predicate abstraction Application of SAT to program analysis: – SATURN: bit accurate modeling of loop-free programs with complicated data structures – Bounded model checking etc. Use SAT for validation; in contrast, we use it for inference of invariants that are sound over- approximations 21

Conclusions Constraint-based techniques offer two advantages over iterative fixed-point techniques: – Goal directed (may buy efficiency) – Do not require widening (may buy precision) For predicate abstraction, we have shown how to reduce various program analysis problems to constraint solving. In addition to program verification, constraint-based encoding facilitates easy extensions to inter- procedural summary computation, maximally-weak preconditions, counter-examples to safety. 22

Future Work We are exploring extensions to quantifiers and other analysis problems as future work. We are exploring the scalability of this technique along two directions: – Encodings that yield simpler SAT instances, e.g. exploiting symmetry information for the case of disjunctive solutions – Reducing programmer burden by automatically inferring predicate sets and templates VS 3 : Verification and Synthesis using SMT Solvers 23

24 Questions?

Best Description of Bugs 25 Err (int m) { error := 0; while (x<m) { x++; y++; if (y ¸ m) error:=1; goto L; } L: assert(error = 1) } Err (int m) { while (x<m) { x++; y++; assert (y<m); } Instrument Run maximally-weak precondition x<m Æ y ¸ x (x<m Æ y ¸ x) Ç (error=1 Æ y ¸ x)