The Software Model Checker BLAST

Similar documents
Model Checking, Theorem Proving, and Abstract Interpretation: The Convergence of Formal Verification Technologies

SMT and Its Application in Software Verification

Model Checking: An Introduction

Predicate abstrac,on and interpola,on. Many pictures and examples are borrowed from The So'ware Model Checker BLAST presenta,on.

Double Header. Model Checking. Model Checking. Overarching Plan. Take-Home Message. Spoiler Space. Topic: (Generic) Model Checking

Software Verification using Predicate Abstraction and Iterative Refinement: Part 1

Predicate Abstraction: A Tutorial

Abstractions and Decision Procedures for Effective Software Model Checking

Information Flow Analysis via Path Condition Refinement

Nested Interpolants. Matthias Heizmann Jochen Hoenicke Andreas Podelski POPL University of Freiburg, Germany

Automata-Theoretic Model Checking of Reactive Systems

Applications of Craig Interpolants in Model Checking

EFFICIENT PREDICATE ABSTRACTION OF PROGRAM SUMMARIES

IC3 and Beyond: Incremental, Inductive Verification

Refinement of Trace Abstraction

3-Valued Abstraction-Refinement

Software Verification with Abstraction-Based Methods

Automatic Verification of Parameterized Data Structures

The State Explosion Problem

SAT-Based Verification with IC3: Foundations and Demands

Software Verification

Finite-State Model Checking

Lecture Notes on Software Model Checking

Computer-Aided Program Design

Chapter 4: Computation tree logic

Understanding IC3. Aaron R. Bradley. ECEE, CU Boulder & Summit Middle School. Understanding IC3 1/55

Model Checking & Program Analysis

Nested Interpolants. Matthias Heizmann Jochen Hoenicke Andreas Podelski. Abstract. 1. Introduction. University of Freiburg, Germany

Interpolant-based Transition Relation Approximation

Compositional Reasoning

Theorem Proving beyond Deduction

Ranking Verification Counterexamples: An Invariant guided approach

Automata-based Verification - III

LTL Model Checking. Wishnu Prasetya.

Temporal logics and explicit-state model checking. Pierre Wolper Université de Liège

Symmetry Reductions. A. Prasad Sistla University Of Illinois at Chicago

Bounded Model Checking with SAT/SMT. Edmund M. Clarke School of Computer Science Carnegie Mellon University 1/39

Formal Verification Techniques. Riccardo Sisto, Politecnico di Torino

Part I. Principles and Techniques

Introduction to Model Checking. Debdeep Mukhopadhyay IIT Madras

Lecture 2: Symbolic Model Checking With SAT

PLEASE DO NOT REMOVE THIS PAGE

Algorithmic verification

Axiomatic Semantics. Operational semantics. Good for. Not good for automatic reasoning about programs

Model Checking. Boris Feigin March 9, University College London

Automata, Logic and Games: Theory and Application

Non-Monotonic Refinement of Control Abstraction for Concurrent Programs

Automata-based Verification - III

or simply: IC3 A Simplified Description

Sanjit A. Seshia EECS, UC Berkeley

Overview. Discrete Event Systems Verification of Finite Automata. What can finite automata be used for? What can finite automata be used for?

The Impact of Craig s Interpolation Theorem. in Computer Science

Static Program Analysis

Predicate Abstraction and Refinement for Verifying Multi-Threaded Programs

Deductive Verification

CS 4700: Foundations of Artificial Intelligence

Programming Languages

Lecture Notes on Emptiness Checking, LTL Büchi Automata

Linear-time Temporal Logic

CSE507. Course Introduction. Computer-Aided Reasoning for Software. Emina Torlak

SAT-Solving: From Davis- Putnam to Zchaff and Beyond Day 3: Recent Developments. Lintao Zhang

Constraint Solving for Program Verification: Theory and Practice by Example

Computation Tree Logic (CTL) & Basic Model Checking Algorithms

Constraint Solving for Program Verification: Theory and Practice by Example

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements

CTL Model checking. 1. finite number of processes, each having a finite number of finite-valued variables. Model-Checking

FAIRNESS FOR INFINITE STATE SYSTEMS

Probabilistic Model Checking and Strategy Synthesis for Robot Navigation

Model for reactive systems/software

Planning Under Uncertainty II

Static Program Analysis

Ivy: Safety Verification by Interactive Generalization

Vinter: A Vampire-Based Tool for Interpolation

Complexity and algorithms for monomial and clausal predicate abstraction

CIS 842: Specification and Verification of Reactive Systems. Lecture Specifications: Specification Patterns

Model Checking with CTL. Presented by Jason Simas

Propositional Calculus - Deductive Systems

CTL satisfability via tableau A C++ implementation

Quantum Computing Approach to V&V of Complex Systems Overview

Relative Completeness of Abstraction Refinement for Software Model Checking

Verification. Arijit Mondal. Dept. of Computer Science & Engineering Indian Institute of Technology Patna

Overview of Topics. Finite Model Theory. Finite Model Theory. Connections to Database Theory. Qing Wang

Introduction. Pedro Cabalar. Department of Computer Science University of Corunna, SPAIN 2013/2014

Tutorial 1: Modern SMT Solvers and Verification

A brief introduction to Logic. (slides from

Design of Distributed Systems Melinda Tóth, Zoltán Horváth

Introduction to Temporal Logic. The purpose of temporal logics is to specify properties of dynamic systems. These can be either

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 3: Practical SAT Solving

Interpolation. Seminar Slides. Betim Musa. 27 th June Albert-Ludwigs-Universität Freiburg

Automata-Theoretic LTL Model-Checking

Property Directed Equivalence via Abstract Simulation. Grigory Fedyukovich, Arie Gurfinkel, and Natasha Sharygina

Scenario Graphs and Attack Graphs

An Interpolating Theorem Prover

Nonlinear Control as Program Synthesis (A Starter)

Hoare Logic: Reasoning About Imperative Programs

Spatial Interpolants

Program Verification Using Separation Logic

IC3, PDR, and Friends

Proving Safety with Trace Automata and Bounded Model Checking

Pushing to the Top FMCAD 15. Arie Gurfinkel Alexander Ivrii

Transcription:

The Software Model Checker BLAST http://mtc.epfl.ch/software-tools/blast/ BLAST 2.0 Team: Dirk Beyer, Tom Henzinger, Ranjit Jhala, and Rupak Majumdar Guest Lecture in Viktor Kuncak s Verification Class, 2008-05-08

Motivation Software stands for - Functionality -Flexibility - Affordability in today s products and infrastructures. Practice: - Vulnerability - Obstacle to redesign - Cost overruns - Buggy, brittle, insecure, and not interoperable.

French Guyana, June 4, 1996 $600 million software failure

Mars, December 3, 1999 Crashed due to uninitialized variable

Mars, July 4, 1997 Lost contact due to priority inversion bug

Something reliable Uptime: 68 years

Our Application Areas Verification of systems code Locking disciplines Interface specifications Temporal properties Require path-sensitive analysis Swamped by false positives Really hard to check

Specifying and Checking Properties of Programs Goals Defect detection Partial validation Properties Memory safety Temporal safety Security Many (mature) techniques - Automated deduction - Program analysis - Type checking - Model checking Many projects Bandera, Blast, ESC-Java, FeaVer, JPF, LClint, OSQ, PolyScope, PREfix, SLAM, TVLA, Verisoft, xgcc,

Property Checking Programmer gives partial specifications Code checked for consistency with spec Different from program correctness Specifications are not complete Are there actually complete specs? - Look for problems that occur often

Property 1: Double Locking lock unlock unlock lock An attempt to re-acquire an acquired lock or release a released lock will cause a deadlock. Calls to lock and unlock must alternate.

Property 2: Drop Root Privilege [Chen-Dean-Wagner 02] User applications must not run with root privilege When execv is called, must have suid 0

Property 3 : IRP Handler IRP accessible MPR2 start NP MPR3 synch not pending returned CallDriver MPR1 NP MPR completion Skip prop completion no prop completion SKIP1 CallDriver PPC N/A CallDriver CallDriver Complete request CallDriver SKIP2 IPC DC N/A synch return child status return not Pend MPR3 CallDriver start P synch MPR1 MPR2not pending returned NP MPR completion Mark Pending Skip prop completion no prop completion CallDriver SKIP1 PPC N/A CallDriver CallDriver Complete request SKIP2 IPC CallDriver DC return Pending [Fahndrich]

Does a given usage rule hold? Undecidable! Equivalent to the halting problem Restricted computable versions are prohibitively expensive (PSPACE) Why bother? Just because a problem is undecidable, it doesn t go away!

Running Example Example ( ) { 1: do{ lock(); old = new; q = q->next; 2: if (q!= NULL){ 3: q->data = new; unlock(); new ++; 4: while(new!= old); 5: unlock (); return; unlock lock unlock lock

What a program really is State Transition pc lock old new q a 3 a a 5 a 5 a 0x133a 3: 3: unlock(); new++; 4: Example Example ( ) { 1: 1: do{ do{ lock(); lock(); old old = new; new; q = q->next; 2: 2: if if (q (q!=!= NULL){ NULL){ 3: 3: q->data q->data = new; new; unlock(); new new ++; ++; 4: 4: while(new!=!= old); old); 5: 5: unlock unlock (); (); return; pc lock old new q a 4 a a 5 a 6 a 0x133a

The Safety Verification Problem Error Safe Initial Is there a path from an initial to an error state? Problem: Infinite state graph Solution : Set of states ' logical formula

Representing States as Formulas [F] states satisfying F {s s ² F F FO fmla over prog. vars [F 1 ] Å [F 2 ] F 1 Æ F 2 [F 1 ] [F 2 ] F 1 Ç F 2 [F] F [F 1 ] [F 2 ] F 1 implies F 2 i.e. F 1 Æ F 2 unsatisfiable

Idea 1: Predicate Abstraction Predicates on program state: lock old = new States satisfying same predicates are equivalent Merged into one abstract state #abstract states is finite

Abstract States and Transitions State pc lock old new q a 3 a a 5 a 5 a 0x133a 3: 3: unlock(); new++; 4: pc lock old new q a 4 a a 5 a 6 a 0x133a Theorem Prover lock old=new lock old=new

Abstraction State pc lock old new q a 3 a a 5 a 5 a 0x133a 3: 3: unlock(); new++; 4: pc lock old new q a 4 a a 5 a 6 a 0x133a Theorem Prover Existential Lifting lock old=new lock old=new

Abstraction State pc lock old new q a 3 a a 5 a 5 a 0x133a 3: 3: unlock(); new++; 4: pc lock old new q a 4 a a 5 a 6 a 0x133a lock old=new lock old=new

Analyze Abstraction Analyze finite graph Over Approximate: Safe System Safe No false negatives Problem Spurious counterexamples

Idea 2: Counterex.-Guided Refinement Solution Use spurious counterexamples to refine abstraction!

Idea 2: Counterex.-Guided Refinement Solution Use spurious counterexamples to refine abstraction 1. Add predicates to distinguish states across cut 2. Build refined abstraction Imprecision due to merge

Iterative Abstraction-Refinement Solution Use spurious counterexamples to refine abstraction [Kurshan et al 93] [Clarke et al 00] [Ball-Rajamani 01] 1. Add predicates to distinguish states across cut 2. Build refined abstraction -eliminates counterexample 3. Repeat search Till real counterexample or system proved safe

Software Model Checking CProgram Abstract Yes Safe BLAST Property Refine No Trace

Lazy Abstraction CProgram spec.opt Instrumented C file With ERROR label BLAST Yes Safe Property No Trace

Problem: Abstraction is Expensive Reachable Problem #abstract states = 2 #predicates Exponential Thm. Prover queries Observe Fraction of state space reachable #Preds ~ 100 s, #States ~ 2 100, #Reach ~ 1000 s

Solution1: Only Abstract Reachable States Safe Problem #abstract states = 2 #predicates Exponential Thm. Prover queries Solution Build abstraction during search

Solution2: Don t Refine Error-Free Regions Error Free Problem #abstract states = 2 #predicates Exponential Thm. Prover queries Solution Don t refine error-free regions

Key Idea: Reachability Tree Initial 1 2 Unroll Abstraction 1. Pick tree-node (=abs. state) 2. Add children (=abs. successors) 3. On re-visiting abs. state, cut-off 3 4 3 5 Find min infeasible suffix - Learn new predicates - Rebuild subtree with new preds.

Key Idea: Reachability Tree Initial 1 2 Unroll Abstraction 1. Pick tree-node (=abs. state) 2. Add children (=abs. successors) 3. On re-visiting abs. state, cut-off 3 6 4 5 3 3 7 Find min infeasible suffix - Learn new predicates - Rebuild subtree with new preds. Error Free

Key Idea: Reachability Tree Initial 1 2 Unroll Abstraction 1. Pick tree-node (=abs. state) 2. Add children (=abs. successors) 3. On re-visiting abs. state, cut-off 3 6 4 5 7 8 Find min infeasible suffix - Learn new predicates 3 3 1 8 1 - Rebuild subtree with new preds. Error Free SAFE S1: Only Abstract Reachable States S2: Don t refine error-free regions

Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); 1 LOCK 1 Predicates: LOCK Reachability Tree

Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); lock() old = new q=q->next 1 2 LOCK LOCK 1 2 Predicates: LOCK Reachability Tree

Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); [q!=null] 3 1 2 LOCK LOCK LOCK 1 2 3 Predicates: LOCK Reachability Tree

Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); q->data = new unlock() new++ 3 4 1 2 LOCK LOCK LOCK LOCK 4 1 2 3 Predicates: LOCK Reachability Tree

Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); 3 1 2 LOCK LOCK LOCK 4 LOCK [new==old] 5 5 LOCK 4 1 2 3 Predicates: LOCK Reachability Tree

Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); 3 1 2 LOCK LOCK LOCK 4 LOCK 5 4 1 2 3 Predicates: LOCK unlock() 5 LOCK LOCK Reachability Tree

Analyze Counterexample Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); 3 4 1 2 LOCK LOCK LOCK LOCK lock() old = new q=q->next [q!=null] q->data = new unlock() new++ [new==old] 5 5 LOCK unlock() 4 1 2 3 Predicates: LOCK LOCK Reachability Tree

Analyze Counterexample Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); 5 4 1 2 3 Predicates: LOCK 3 4 5 1 2 LOCK LOCK LOCK LOCK LOCK LOCK old = new new++ [new==old] Inconsistent new == old Reachability Tree

Repeat Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); 1 LOCK 1 Predicates: LOCK, new==old Reachability Tree

Repeat Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); 1 LOCK, new==old 2 LOCK lock() old = new q=q->next 1 2 Predicates: LOCK, new==old Reachability Tree

Repeat Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); 1 LOCK LOCK, new==old 2 LOCK, new==old 3 q->data = new unlock() LOCK, new = old 4 new++ 4 1 2 3 Predicates: LOCK, new==old Reachability Tree

Repeat Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); LOCK, new==old 2 LOCK, new==old 3 LOCK, new = old 4 [new==old] 1 LOCK 4 1 2 3 Predicates: LOCK, new==old Reachability Tree

Repeat Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); LOCK, new==old 2 LOCK, new==old 3 LOCK, new = old 4 1 [new!=old] LOCK 1 4 1 2 3 Predicates: LOCK, new==old LOCK, new == old Reachability Tree

Repeat Build-and-Search Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); LOCK, new==old LOCK, new==old 3 1 2 LOCK SAFE LOCK, new = old 4 4 LOCK, new=old 5 4 4 1 2 3 Predicates: LOCK, new==old 1 LOCK, new == old 5 LOCK, new==old Reachability Tree

Key Idea: Reachability Tree Initial 1 2 Unroll 1. Pick tree-node (=abs. state) 2. Add children (=abs. successors) 3. On re-visiting abs. state, cut-off 3 6 4 5 7 8 Find min spurious suffix - Learn new predicates 3 3 1 8 1 - Rebuild subtree with new preds. Error Free SAFE S1: Only Abstract Reachable States S2: Don t refine error-free regions

Lazy Abstraction CProgram Abstract Yes Safe Property Refine No Trace Problem: Abstraction is Expensive Solution: 1. Abstract reachable states, 2. Avoid refining error-free regions Key Idea: Reachability Tree

Technical Details Example ( ) { 1: 1: do{ do{ lock(); old old = new; q = q->next; 2: 2: if if (q (q!=!= NULL){ 3: 3: q->data = new; unlock(); new new ++; ++; 4:while(new!=!= old); 5: 5: unlock (); (); 1 LOCK Q. How to find predicates LOCK, new==old 2? LOCK, new==old LOCK, new = old 3 4 4 LOCK, new=old SAFE 1 5 5 4 Refinement 4 1 2 3 Predicates: LOCK, new==old LOCK, new == old LOCK, new==old

#Predicates grows with program size T F T while(1){ 1: if (p 1 ) lock() ; if (p 1 ) unlock() ; 2: if (p 2 ) lock() ; if (p 2 ) unlock() ; n: if (p n ) lock() ; if (p n ) unlock() ; Tracking lock not enough Problem: p 1,,p n needed for verification Exponential reachable abstract states

#Predicates grows with program size while(1){ 1: if (p 1 ) lock() ; if (p 1 ) unlock() ; 2: if (p 2 ) lock() ; if (p 2 ) unlock() ; n: if (p n ) lock() ; if (p n ) unlock() ; LOCK LOCK, p 1 LOCK, p 1 LOCK, p 1 LOCK, p 1 LOCK p 1 p 2 p 1 p 2 p 1 p 2 p 1 p 2 2 n Abstract States Problem: p 1,,p n needed for verification Exponential reachable abstract states

Predicates useful locally p 1 p 2 p n while(1){ 1: if (p 1 ) lock() ; if (p 1 ) unlock() ; 2: if (p 2 ) lock() ; if (p 2 ) unlock() ; n: if (p n ) lock() ; if (p n ) unlock() ; LOCK LOCK, p 1 LOCK, p 1 LOCK, LOCK p 1 LOCK LOCK, p 1 LOCK, p 2 LOCK, p 2 LOCK 2n Abstract States Solution: Use predicates only where needed Using Counterexamples: Q1. Find predicates Q2. Find where predicates are needed

Lazy Abstraction CProgram Abstract Yes Safe Property Refine No Trace Problem: #Preds grows w/ Program Size Solution: Localize pred. use, find where preds. needed Ctrex. Trace Refine Pred. Map PC a Preds.

Counterexample Traces 1: x = ctr; 2: ctr = ctr + 1; 3: y = ctr; 4: if (x = i-1){ 5: if (y!= i){ ERROR: 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) y = x +1

Trace Formulas 1: x = ctr 2: ctr = ctr+1 3: y = ctr 4: assume(x=i-1) 5: assume(y i) Trace 1: x 1 = ctr 0 2: ctr 1 = ctr 0 +1 3: y 1 = ctr 1 4: assume(x 1 =i 0-1) 5: assume(y 1 i 0 ) SSA Trace x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 Æ y 1 i 0 Trace Feasibility Formula Thm: Trace is feasible TF is satisfiable

The Present State Trace 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) is all the information the executing program has here 5: assume(y i) State 1. after executing trace past (prefix) 2. knows present values of variables 3. makes trace future (suffix) infeasible At pc 4, which predicate on present state shows infeasibility of future?

What Predicate is needed? Trace 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) Trace Formula (TF) x 1 = ctr 0 Æ ctr 1 = ctr 0 +1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 Æ y 1 i 0

What Predicate is needed? Trace 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) Trace Formula (TF) x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 Æ y 1 i 0 Relevant Information 1. after executing trace prefix Predicate implied by TF prefix

What Predicate is needed? Trace 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) Trace Formula (TF) x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 x 1 Æ y 1 i 0 Relevant Information 1. after executing trace prefix 2. has present values of variables Predicate implied by TF prefix on common variables

What Predicate is needed? Trace 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) Trace Formula (TF) x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 Æ y 1 i 0 Relevant Information 1. after executing trace prefix 2. has present values of variables 3. makes trace suffix infeasible Predicate implied by TF prefix on common variables & TF suffix is unsatisfiable

What Predicate is needed? Trace 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) Trace Formula (TF) x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 Æ y 1 i 0 Relevant Information 1. after executing trace prefix 2. has present values of variables 3. makes trace suffix infeasible Predicate implied by TF prefix on common variables & TF suffix is unsatisfiable

Interpolant = Predicate! Trace 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) Craig Interpolant [Craig 57] Computable from Proof of Unsat [Krajicek 97] [Pudlak 97] Trace Formula x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 ψ - Interpolate ψ + Φ Æ y 1 i 0 y 1 = x 1 + 1 Predicate implied by TF prefix on common variables & TF suffix is unsatisfiable Predicate at 4: y= x+1

Interpolant = Predicate! Trace 1: x = ctr 2: ctr = ctr + 1 Trace Formula x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 ψ - 3: y = ctr Æ y 1 = ctr Q. How to compute interpolants 1 Interpolate? Φ 4: assume(x = i-1) Æ x 1 = i 0-1 5: assume(y i) ψ + Predicate at 4: y= x+1 Æ y 1 i 0 y 1 = x 1 + 1 Craig Interpolant [Craig 57] Computable from Proof of Unsat [Krajicek 97] [Pudlak 97] Predicate implied by TF prefix on common variables & TF suffix is unsatisfiable

Building Predicate Maps Trace 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) Trace Formula x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 Æ y 1 i 0 ψ - Predicate Map 2: x= ctr Interpolate ψ + x 1 = ctr 0 Cut + Interpolate at each point Pred. Map: pc i a Interpolant from cut i

Building Predicate Maps Trace 1: x = ctr 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) Trace Formula x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 Æ y 1 i 0 ψ - ψ + Predicate Map 2: x = ctr 3: x= ctr-1 Interpolate x 1 = ctr 1-1 Cut + Interpolate at each point Pred. Map: pc i a Interpolant from cut i

Building Predicate Maps Trace 1: x = ctr Trace Formula x 1 = ctr 0 Predicate Map 2: x = ctr 3: x= ctr - 1 4: y= x + 1 2: ctr = ctr + 1 3: y = ctr 4: assume(x = i-1) 5: assume(y i) Æ ctr 1 = ctr 0 + 1 Æ y 1 = ctr 1 Æ x 1 = i 0-1 Æ y 1 i 0 ψ - ψ + Interpolate y 1 = x 1 +1 Cut + Interpolate at each point Pred. Map: pc i a Interpolant from cut i

Building Predicate Maps Trace 1: x = ctr 2: ctr = ctr + 1 Trace Formula x 1 = ctr 0 Æ ctr 1 = ctr 0 + 1 Predicate Map 2: x = ctr 3: x= ctr - 1 4: y= x + 1 5: y = i 3: y = ctr Æ y 1 = ctr 1 4: assume(x = i-1) Æ x 1 = i 0-1 5: assume(y i) Æ y 1 i 0 Cut + Interpolate at each point Pred. Map: pc i a Interpolant from cut i ψ - ψ + Interpolate y 1 = i 0

Local Predicate Use Use predicates needed at location #Preds. grows with program size #Preds per location small Predicate Map 2: x = ctr 3: x= ctr - 1 4: y= x + 1 5: y = i Local Predicate use Ex: 2n states Global Predicate use Ex: 2 n states

Property3: Localizing IRP Handler Win NT DDK Program Lines* Previous Time Predicates Time(mins) (mins) Total Average kbfiltr 12k 1 3 72 6.5 floppy 17k 7 25 240 7.7 diskprf 14k 5 13 140 10 cdaudio 18k 20 23 256 7.8 parport 61k DNF 74 753 8.1 parclss 138k DNF 77 382 7.2 * Pre-processed

Lazy Abstraction CProgram Abstract Yes Safe Property Refine No Trace Solution: Localize pred. use, find where preds. needed Refine Ctrex. Trace Problem: #Preds grows w/ Program Size Trace Feas Formula Thm Pvr Proof of Unsat Interpolate Pred. Map PC a Preds.

Lazy Abstraction: Summary Predicates: Abstract infinite program states Counterexample-guided Refinement: Find predicates tailored to prog, property 1. Abstraction : Expensive Reachability Tree 2. Refinement : Find predicates, use locations Proof of unsat of TF + Interpolation

The BLAST Query Language 1. (Possibly Infinite-State) Monitor Automata for Reachability Queries over Program Locations 2. First-Order Imperative Scripting Language for Combining Relations over Program Locations

Two-State Locking Monitor GLOBAL int locked; EVENT { PATTERN { init() ACTION { locked = 0; U unlock () lock () unlock () E L lock () EVENT { PATTERN { lock() ASSERT { locked == 0 ACTION { locked = 1; EVENT { PATTERN { unlock() ASSERT { locked == 1 ACTION { locked = 0;

Two-State Locking Monitor GLOBAL int locked; EVENT { PATTERN { init() ACTION { locked = 0; EVENT { PATTERN { lock() ASSERT { locked == 0 ACTION { locked = 1; EVENT { PATTERN { unlock() ASSERT { locked == 1 ACTION { locked = 0; lock () U unlock () unlock () E L lock () else REJECT else REJECT

Single-Lock Safety Analysis source(l1) := LOC_LABEL(l1, START ); target(l2) := TRUE(l2); error-traces(l1,l2) := REJECT(source,target,monitor); error-locs(l2) := EXISTS(l1,error-traces(l1,l2)); PRINT The following locations are reachable and cause a locking error: ; PRINT error-locs(l2); REJECT(l1,l2,monitor) is the set of all location pairs (l1,l2) such that there is a feasible program trace from l1 to l2 which is rejected by the automaton monitor.

Type-State Locking Monitor SHADOW lock_t { int locked; EVENT { PATTERN { init($1) ACTION { $1->locked = 0; EVENT { PATTERN { lock($1) ASSERT { $1->locked == 0 ACTION { $1->locked = 1; EVENT { PATTERN { unlock($1) ASSERT { $1->locked == 1 ACTION { $1->locked = 0;

Dead-Code Analysis source(l1) := LOC_LABEL(l1, START ); target(l2) := TRUE(l2); feasible-traces(l1,l2) := ACCEPT(source,target,EMPTY); reached-locs(l2) := feasible-traces(_,l2)); PRINT The following locations are not reachable: ; PRINT!reached-locs(l2);

Impact Analysis GLOBAL int defined; INITIAL { defined = 0; EVENT { PATTERN { j = $1; ACTION { defined ++ ; FINAL { defined == 1 else REJECT affected(l1,l2) := ACCEPT(LOC_LHS(l1, j ),LOC_RHS(l2, j ),monitor); PRINT affected(l1,l2);

Benefits of Two-Level Specifications 1. Separates properties from programs, while keeping a familiar syntax for writing properties 2. Treats a program as a database of facts that can be queried, and supports macros for traditional temporal-logic specifications 3. Supports the formulation of decomposition strategies for verification tasks 4. Supports the incremental maintenance of properties during program development

The BLAST Two-Level Query Language 1. (Possibly Infinite-State) Monitor Automata for Reachability Queries over Program Locations: checked by the BLAST model checking engine 2. First-Order Imperative Scripting Language for Combining Relations over Program Locations: checked by the CrocoPat relational query engine [Beyer, Noack, Lewerentz]