Lecture #11 Software Model Checking: automating the search for abstractions Thomas Ball Testing, Verification and Measurement Microsoft Research.

Slides:



Advertisements
Similar presentations
1 Verification by Model Checking. 2 Part 1 : Motivation.
Advertisements

Advanced programming tools at Microsoft
Copyright 2000 Cadence Design Systems. Permission is granted to reproduce without modification. Introduction An overview of formal methods for hardware.
The Static Driver Verifier Research Platform
The SLAM Project: Debugging System Software via Static Analysis
Demand-driven inference of loop invariants in a theorem prover
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
1 Thorough Static Analysis of Device Drivers Byron Cook – Microsoft Research Joint work with: Tom Ball, Vladimir Levin, Jakob Lichtenberg,
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
Chair of Software Engineering Software Verification Stephan van Staden Lecture 10: Model Checking.
Automatic Predicate Abstraction of C-Programs T. Ball, R. Majumdar T. Millstein, S. Rajamani.
Thomas Ball, Rupak Majumdar, Todd Millstein, Sriram K. Rajamani Presented by Yifan Li November 22nd In PLDI 01: Programming Language.
Verification of parameterised systems
BLAST-A Model Checker for C Developed by Thomas A. Henzinger (EPFL) Rupak Majumdar (UC Los Angeles) Ranjit Jhala (UC San Diego) Dirk Beyer (Simon Fraser.
An Integration of Program Analysis and Automated Theorem Proving Bill J. Ellis & Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt.
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor Formal Methods in Software Engineering1.
Termination Proofs for Systems Code Andrey Rybalchenko, EPFL/MPI joint work with Byron Cook, MSR and Andreas Podelski, MPI PLDI’2006, Ottawa.
Using Statically Computed Invariants Inside the Predicate Abstraction and Refinement Loop Himanshu Jain Franjo Ivančić Aarti Gupta Ilya Shlyakhter Chao.
Lazy Abstraction Thomas A. Henzinger Ranjit Jhala Rupak Majumdar Grégoire Sutre UC Berkeley.
Counterexample-Guided Focus TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAA A A A AA A A Thomas Wies Institute of.
Proof-system search ( ` ) Interpretation search ( ² ) Main search strategy DPLL Backtracking Incremental SAT Natural deduction Sequents Resolution Main.
Synergy: A New Algorithm for Property Checking
Secrets of Software Model Checking Thomas Ball Sriram K. Rajamani Software Productivity Tools Microsoft Research
1 Predicate Abstraction of ANSI-C Programs using SAT Edmund Clarke Daniel Kroening Natalia Sharygina Karen Yorav (modified by Zaher Andraus for presentation.
CS 267: Automated Verification Lectures 14: Predicate Abstraction, Counter- Example Guided Abstraction Refinement, Abstract Interpretation Instructor:
Automatically Validating Temporal Safety Properties of Interfaces Thomas Ball and Sriram K. Rajamani Software Productivity Tools, Microsoft Research Presented.
Software Reliability Methods Sorin Lerner. Software reliability methods: issues What are the issues?
Predicate Abstraction for Software and Hardware Verification Himanshu Jain Model checking seminar April 22, 2005.
Temporal-Safety Proofs for Systems Code Thomas A. Henzinger Ranjit Jhala Rupak Majumdar George Necula Westley Weimer Grégoire Sutre UC Berkeley.
From last time S1: l := new Cons p := l S2: t := new Cons *p := t p := t l p S1 l p tS2 l p S1 t S2 l t S1 p S2 l t S1 p S2 l t S1 p L2 l t S1 p S2 l t.
Computing Over­Approximations with Bounded Model Checking Daniel Kroening ETH Zürich.
Efficient Software Model Checking of Data Structure Properties Paul T. Darga Chandrasekhar Boyapati The University of Michigan.
Specifying and Checking Properties of Programs Thomas Ball Sriram K. Rajamani Software Productivity Tools Microsoft Research.
Describing Syntax and Semantics
Lazy Abstraction Tom Henzinger Ranjit Jhala Rupak Majumdar Grégoire Sutre.
Formal verification Marco A. Peña Universitat Politècnica de Catalunya.
Formal Verification of SpecC Programs using Predicate Abstraction Himanshu Jain Daniel Kroening Edmund Clarke Carnegie Mellon University.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Formal Methods 1. Software Engineering and Formal Methods  Every software engineering methodology is based on a recommended development process  proceeding.
CS527: (Advanced) Topics in Software Engineering Overview of Software Quality Assurance Tao Xie ©D. Marinov, T. Xie.
Software Model Checking with SLAM Thomas Ball Testing, Verification and Measurement Sriram K. Rajamani Software Productivity Tools Microsoft Research
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Proof Carrying Code Zhiwei Lin. Outline Proof-Carrying Code The Design and Implementation of a Certifying Compiler A Proof – Carrying Code Architecture.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 3: Modular Verification with Magic, Predicate Abstraction.
Rule Checking SLAM Checking Temporal Properties of Software with Boolean Programs Thomas Ball, Sriram K. Rajamani Microsoft Research Presented by Okan.
Aditya V. Nori, Sriram K. Rajamani Microsoft Research India.
SLAM :Software Model Checking From Theory To Practice Sriram K. Rajamani Software Productivity Tools Microsoft Research.
Newton: A tool for generating abstract explanations of infeasibility1 The Problem P (C Program) BP (Boolean Program of P) CFG(P) CFG(BP)
Thomas Ball Sriram K. Rajamani
1 Introduction to Software Engineering Lecture 1.
Use of Models in Analysis and Design Sriram K. Rajamani Rigorous Software Engineering Microsoft Research, India.
© Andrew IrelandDependable Systems Group Static Analysis and Program Proof Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt University.
Automatically Validating Temporal Safety Properties of Interfaces Thomas Ball, Sriram K. MSR Presented by Xin Li.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
11 Counter-Example Based Predicate Discovery in Predicate Abstraction Satyaki Das and David L. Dill Computer Systems Lab Stanford University
The Yogi Project Software property checking via static analysis and testing Aditya V. Nori, Sriram K. Rajamani, Sai Deep Tetali, Aditya V. Thakur Microsoft.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
1 Automatically Validating Temporal Safety Properties of Interfaces - Overview of SLAM Parts of the slides are from
CS357 Lecture 13: Symbolic model checking without BDDs Alex Aiken David Dill 1.
R-Verify: Deep Checking of Embedded Code James Ezick † Donald Nguyen † Richard Lethin † Rick Pancoast* (†) Reservoir Labs (*) Lockheed Martin The Eleventh.
Counter Example Guided Refinement CEGAR Mooly Sagiv.
Software Design and Development Development Methodoligies Computing Science.
Presentation Title 2/4/2018 Software Verification using Predicate Abstraction and Iterative Refinement: Part Bug Catching: Automated Program Verification.
Tutorial: Proving termination and liveness
Predicate Abstraction
Course: CS60030 Formal Systems
Presentation transcript:

Lecture #11 Software Model Checking: automating the search for abstractions Thomas Ball Testing, Verification and Measurement Microsoft Research

Lecture #12 People Behind SLAM Microsoft Research –Thomas Ball and Sriram Rajamani Summer interns –Sagar Chaki, Todd Millstein, Rupak Majumdar (2000) –Satyaki Das, Wes Weimer, Robby (2001) –Jakob Lichtenberg, Mayur Naik (2002) –Georg Weissenbacher, Fei Xie (2003) Visitors –Giorgio Delzanno, Andreas Podelski, Stefan Schwoon Windows Partners –Byron Cook -> MSR Cambridge –Vladimir Levin, Abdullah Ustuner, Con McGarvey, Bohus Ondrusek –Jakob Lichtenberg

Lecture #13 Thanks Also to Friends of SLAM BLAST –Ranjit Jhala –Thomas Henzinger –Rupak Majumdar –Gregoire Sutre MOPED –Stefan Schwoon MAGIC –Sagar Chaki

Lecture #14 Outline Lecture 1 –automating the search for program abstractions Lecture 2 –predicate abstraction with procedures + pointers Lecture 3 –predicate discovery via interpolants Lecture 4 –relative completeness of abstraction refinement with respect to widening Lecture 5 –predicate abstraction and testing

Lecture #15 Name as many examples of software as you can

Lecture #16 What major inventions have improved software development in the past 50 years?

Lecture #17 How does a researcher demonstrate that an invention is a good idea?

Lecture #18 Lessons Software products are varied, so is development –Niche: desktop, net, consumer device, command & control –Relation to other software: first vs nth version, member of family –Seriousness of purpose: safety critical, prototype, one-use script –Installation base: all consumers, all PC owners, company-specific –… SE researchers produce many research products –Tools and algorithms, yes, but also... –Processes, methodologies –Guidance, recipes, patterns, distilled experience –Formulas for scheduling, cost estimation, quality assessment, … –Notations, languages, descriptive tools Validating a SE invention often harder than inventing it –True cost effectiveness typically too hard to measure –Controlled experiments often impossible or too expensive –Ideas need time to develop before validation stage

Lecture #19 Automating Verification of Software Remains a “grand challenge” of computer science but a “minor player” in practice Behavioral abstraction is central to this effort Abstractions simplify our view of program behavior Proofs over the abstractions carry over to proofs over the program

Lecture #110 How many program abstractions can you list?

Lecture #111 No “Silver Bullet” According to Frederick Brooks, there is no “silver bullet” that will improve software production by an order of magnitude. A corollary is that there is no “gold abstraction” Development of abstractions is dependent on –class of programs –class of properties

Lecture #112 The Usefulness of Abstractions Prove a theorem and write a paper Experimentation –Efficiency run-time memory consumption –Precision # spurious counterexamples / total # of counterexamples –Termination sometimes hard to distinguish from efficiency (or lack thereof)

Lecture #113 Abstraction Refinement: PLDI’03 Case Study of Blanchet et al. “… the initial design phase is an iterative manual refinement of the analyzer.” “Each refinement step starts with a static analysis of the program, which yields false alarms. Then a manual backward inspection of the program starting from sample false alarms leads to the understanding of the origin of the imprecision of the analysis.” “There can be two different reasons for the lack of precision: –some local invariants are expressible in the current version of the abstract domain but were missed –some local invariants are necessary in the correctness proof but are not expressible in the current version of the abstract domain.”

Lecture #114 Software Verification: Search for the Right Abstraction A complex search space with a fitness function Can a machine beat a human at search? Deep Blue beat Kasparov

Lecture #115 Automating the Search for Abstractions A knowledge base of useful abstractions A way to generate, combine and refine abstractions A fitness function A brute force search engine

Lecture #116 Puzzle Pieces Application Programming Interfaces (APIs) Model checking Theorem proving Program analysis

Lecture #117 A Brief History of Microsoft Richness Win16 Win32 COM MFC Components Services APIs Windows 3.0

Lecture #118 APIs and Usage Rules Rules in documentation –Incomplete, unenforced, wordy –Order of ops. & data access –Resource management Breaking rules has bad effects –System crash or deadlock –Unexpected exceptions –Failed runtime checks No compile-time checking

Lecture #119 Socket API the "communication domain" in which communication is to take place; see protocols(5). Sockets of type SOCK_STREAM are full-duplex byte streams, similar to pipes. A stream socket must be in a connected state before any data may be sent or received on it. A con- nection to another socket is created with a connect(2) call. Once connected, data may be transferred using read(2V) and write(2V) calls or some variant of the send(2) and recv(2) calls. When a session has been completed a close(2V), may be performed. Out-of-band data may also be transmitted as described in send(2) and received as described in recv(2). The communications protocols used to implement a SOCK_STREAM insure that data is not lost or duplicated. If a piece of

Lecture #120 Model Checking Algorithmic exploration of state space of a (finite state) system Advances in the past decades: –symbolic model checking based on BDDs [Bryant, 1986] [Burch, Clarke, McMillan, Dill, Hwang, 1992] –predicate abstraction (parametric analysis) [Graf,Saidi, 1997] –symmetry reductions –partial order reductions –compositional model checking –bounded model checking using SAT solvers Most hardware companies use a model checker in the validation cycle

Lecture #121 Model Checking Strengths –Fully automatic (when it works) –Computes inductive invariants I such that F(I)  I –Provides error traces Weaknesses –Scale –Operates only on models, usually provided by humans

Lecture #122 Theorem proving –Early theorem provers were proof checkers built to support assertional reasoning cumbersome and hard to use –Greg Nelson’s thesis in early 80s paved the way for automatic theorem provers theories of equality with uninterpreted functions, lists, linear arithmetic combination of the above ! –Automatic theorem provers based on Nelson’s work are widely used SAL/ICS, ESC/Java, Proof Carrying Code –Makes predicate abstraction possible

Lecture #123 Automatic theorem proving Strengths –Handles unbounded domains naturally –Good implementations for equality with uninterpreted functions linear inequalities combination of theories Weaknesses –Hard to compute fixpoints (no abstraction) –Requires inductive invariants Pre and post conditions Loop invariants

Lecture #124 Program analysis Originated in optimizing compilers –constant propagation –live variable analysis –dead code elimination –loop index optimization Type systems use similar analysis –are the type annotations consistent? Theory of abstraction interpretation

Lecture #125 Program analysis Strengths –Works on code –Pointer aware –Integrated into compilers –Precision/efficiency tradeoffs well studied flow (in)sensitive context (in)sensitive Weaknesses –Abstraction is hardwired and done by the designer of the analysis –Not targeted at property checking (traditionally)

Lecture #126 Model Checking, Theorem Proving and Program Analysis Very related to each other Different histories –different emphasis –different tradeoffs Complementary, in some ways Combination can be extremely powerful

Lecture #127 Stretch!

Lecture #128 The Windows Driver Problem Device drivers –glue between OS and devices –many are kernel plug-ins –huge part of PC ecosystem Windows Driver Model –complex legacy API –direct access to Windows kernel –low-level binary debugging

Lecture #129 Source Code Testing Development Precise API Usage Rules (SLIC) Software Model Checking Read for understanding New API rules Drive testing tools Defects 100% path coverage Rules Static Driver Verifier

Lecture #130 State Machine for Locking UnlockedLocked Error Rel Acq Rel state { enum {Locked,Unlocked} s = Unlocked; } KeAcquireSpinLock.entry { if (s==Locked) abort; else s = Locked; } KeReleaseSpinLock.entry { if (s==Unlocked) abort; else s = Unlocked; } Locking Rule in SLIC

Lecture #131 The SLAM Process: counterexample-driven refinement #include predicate abstraction boolean program path feasibility & predicate discovery symbolic reachability Harness SLIC Rule + refinement predicates error path [Clarke et al. ’00] [Ball, Rajamani ’00] [Kurshan et al. ’93]

Lecture #132 do { KeAcquireSpinLock(); nPacketsOld = nPackets; if(request){ request = request->Next; KeReleaseSpinLock(); nPackets++; } } while (nPackets != nPacketsOld); KeReleaseSpinLock(); Example Does this code obey the locking rule?

Lecture #133 do { KeAcquireSpinLock(); if(*){ KeReleaseSpinLock(); } } while (*); KeReleaseSpinLock(); Example Reachability in boolean program model checker U L L L L U L U U U E

Lecture #134 do { KeAcquireSpinLock(); nPacketsOld = nPackets; if(request){ request = request->Next; KeReleaseSpinLock(); nPackets++; } } while (nPackets != nPacketsOld); KeReleaseSpinLock(); Example Is error path feasible in C program? theorem prover U L L L L U L U U U E

Lecture #135 do { KeAcquireSpinLock(); nPacketsOld = nPackets; b = true; if(request){ request = request->Next; KeReleaseSpinLock(); nPackets++; b = b ? false : *; } } while (nPackets != nPacketsOld); !b KeReleaseSpinLock(); Example Add new predicate to boolean program predicate abstraction theorem prover b : (nPacketsOld == nPackets) U L L L L U L U U U E

Lecture #136 do { KeAcquireSpinLock(); b = true; if(*){ KeReleaseSpinLock(); b = b ? false : *; } } while ( !b ); KeReleaseSpinLock(); b b b b Example Model checking refined boolean program b : (nPacketsOld == nPackets) U L L L L U L U U U E b b !b

Lecture #137 Example do { KeAcquireSpinLock(); b = true; if(*){ KeReleaseSpinLock(); b = b ? false : *; } } while ( !b ); KeReleaseSpinLock(); b : (nPacketsOld == nPackets) b b b b U L L L L U L U U b b !b Model checking refined boolean program

Lecture #138 Observations about SLAM Automatic discovery of invariants –driven by property and a finite set of (false) execution paths –predicates are not invariants, but observations –abstraction + model checking computes inductive invariants (boolean combinations of observations) A hybrid dynamic/static analysis that –“executes” a finite set of “concrete” paths symbolically –explores all paths through abstraction A new form of program slicing –program code and data not relevant to property are dropped –non-determinism allows slices to have more behaviors

Lecture #139 Static Driver Verifier

Lecture #140 Static Driver Verifier Driver: Parallel port device driver Rule: Checks that driver dispatch routines do not call IoCompleteRequest(…) twice on the I/O request packet passed to it by the OS or another driver

Lecture #141

Lecture #142

Lecture #143

Lecture #144

Lecture #145

Lecture #146

Lecture #147

Lecture #148

Lecture #149

Lecture #150

Lecture #151

Lecture #152

Lecture #153

Lecture #154

Lecture #155

Lecture #156

Lecture #157

Lecture #158 SLAM Results Boolean program model has proved itself Successful for device driver contracts –control-dominated safety properties –few boolean variables needed to do proof or find real errors Counterexample-driven refinement –terminates in practice –incompleteness of theorem prover not an issue

Lecture #159 SLAMming on the shoulders of … Model checking –predicate abstraction –counterexample-driven refinement –BDDs and symbolic model checking Program analysis –abstract interpretation –points-to analysis –dataflow via CFL- reachability Automated deduction –weakest preconditions –theorem proving Software –AST toolkit –Das’s Golf –CU and CMU BDD –Simplify –OCaml

Lecture #160 SLAM/SDV History –foundations, algorithms, prototyping –papers in CAV, PLDI, POPL, SPIN, TACAS March 2002 –Bill Gates review May 2002 –Windows committed to hire two Ph.D.s in model checking to support Static Driver Verifier July 2002 –running SLAM on 100+ drivers, 20+ properties September 3, 2002 –made initial release of SDV to Windows (friends and family) April 1, 2003 –made wide release of SDV to Windows (any internal driver developer) September, 2003 –team of six in Windows working on SDV –researchers moving into “consultant” role November, 2003 –demonstration at Driver Developer Conference Release on DDK in late 2004!

Lecture #161 Summary Use APIs and properties to guide search for appropriate abstractions Predicate abstraction provides parametric abstraction algorithm Predicates generated by analysis of spurious counterexamples

Lecture #162 Glossary Model checkingChecking properties by systematic exploration of the state-space of a model. Properties are usually specified as state machines, or using temporal logics Safety propertiesProperties whose violation can be witnessed by a finite run of the system. The most common safety properties are invariants ReachabilitySpecialization of model checking to invariant checking. Properties are specified as invariants. Most common use of model checking. Safety properties can be reduced to reachability. Boolean programs“C”-like programs with only boolean variables. Invariant checking and reachability is decidable for boolean programs. PredicateA Boolean expression over the state-space of the program eg. (x < 5) Predicate abstractionA technique to construct a boolean model from a system using a given set of predicates. Each predicate is represented by a boolean variable in the model. Weakest preconditionThe weakest precondition of a set of states S with respect to a statement T is the largest set of states from which executing T, when terminating, always results in a state in S.