Model Checking: An Introduction

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

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

Abstractions and Decision Procedures for Effective Software Model Checking

Software Verification using Predicate Abstraction and Iterative Refinement: Part 1

Finite-State Model Checking

Model Checking. Boris Feigin March 9, University College London

Lecture 2: Symbolic Model Checking With SAT

Model for reactive systems/software

Model Checking. Temporal Logic. Fifth International Symposium in Programming, volume. of concurrent systems in CESAR. In Proceedings of the

3-Valued Abstraction-Refinement

Model Checking with CTL. Presented by Jason Simas

Temporal Logic Model Checking

Automata-Theoretic Model Checking of Reactive Systems

Model checking the basic modalities of CTL with Description Logic

Predicate Abstraction: A Tutorial

MODEL CHECKING. Arie Gurfinkel

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

Algorithmic verification

CS 267: Automated Verification. Lecture 1: Brief Introduction. Transition Systems. Temporal Logic LTL. Instructor: Tevfik Bultan

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

Computation Tree Logic (CTL)

Alan Bundy. Automated Reasoning LTL Model Checking

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

Model Checking I. What are LTL and CTL? dack. and. dreq. and. q0bar

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

Formal Verification of Mobile Network Protocols

Lecture 16: Computation Tree Logic (CTL)

Temporal Logic. Stavros Tripakis University of California, Berkeley. We have designed a system. We want to check that it is correct.

Introduction to Model Checking. Debdeep Mukhopadhyay IIT Madras

Guest lecturer: Prof. Mark Reynolds, The University of Western Australia

Lecture Notes on Software Model Checking

Computation Tree Logic (CTL) & Basic Model Checking Algorithms

ESE601: Hybrid Systems. Introduction to verification

Model Checking I. What are LTL and CTL? dack. and. dreq. and. q0bar

Abstraction for Falsification

Models. Lecture 25: Model Checking. Example. Semantics. Meanings with respect to model and path through future...

State-Space Exploration. Stavros Tripakis University of California, Berkeley

Computation Tree Logic

Chapter 4: Computation tree logic

Automata-based Verification - III

Testing with model checkers: A survey

CS357: CTL Model Checking (two lectures worth) David Dill

Symbolic Trajectory Evaluation (STE): Orna Grumberg Technion, Israel

Summary. Computation Tree logic Vs. LTL. CTL at a glance. KM,s =! iff for every path " starting at s KM," =! COMPUTATION TREE LOGIC (CTL)

A brief history of model checking. Ken McMillan Cadence Berkeley Labs

Counterexample-Guided Abstraction Refinement

The Software Model Checker BLAST

Lecture Notes on Emptiness Checking, LTL Büchi Automata

Formal Verification Techniques. Riccardo Sisto, Politecnico di Torino

Probabilistic Model Checking Michaelmas Term Dr. Dave Parker. Department of Computer Science University of Oxford

Overview. overview / 357

Property Checking of Safety- Critical Systems Mathematical Foundations and Concrete Algorithms

Automata-based Verification - III

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

T Reactive Systems: Temporal Logic LTL

Verification Using Temporal Logic

A Brief Introduction to Model Checking

Linear Temporal Logic and Büchi Automata

IC3 and Beyond: Incremental, Inductive Verification

The State Explosion Problem

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

SAT-Based Verification with IC3: Foundations and Demands

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

Program Analysis Part I : Sequential Programs

Semantic Equivalences and the. Verification of Infinite-State Systems 1 c 2004 Richard Mayr

FAIRNESS FOR INFINITE STATE SYSTEMS

Axiomatic Semantics: Verification Conditions. Review of Soundness of Axiomatic Semantics. Questions? Announcements

Formal Verification. Lecture 1: Introduction to Model Checking and Temporal Logic¹

Topics in Verification AZADEH FARZAN FALL 2017

CTL Model Checking. Wishnu Prasetya.

First-order resolution for CTL

Chapter 6: Computation Tree Logic

PSPACE-completeness of LTL/CTL model checking

Revising Specifications with CTL Properties using Bounded Model Checking

Computation Tree Logic

Chapter 5: Linear Temporal Logic

Model checking, verification of CTL. One must verify or expel... doubts, and convert them into the certainty of YES [Thomas Carlyle]

Computation Tree Logic

Information Flow Analysis via Path Condition Refinement

FORMAL METHODS LECTURE IV: COMPUTATION TREE LOGIC (CTL)

Model Checking of Systems Employing Commutative Functions

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

Computer-Aided Program Design

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

NPTEL Phase-II Video course on. Design Verification and Test of. Dr. Santosh Biswas Dr. Jatindra Kumar Deka IIT Guwahati

Introduction to Axiomatic Semantics

SAT-based Model Checking: Interpolation, IC3, and Beyond

Computer Aided Verification

Linear-Time Logic. Hao Zheng

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

Timo Latvala. February 4, 2004

SAT in Formal Hardware Verification

Learning to Verify Branching Time Properties

Sanjit A. Seshia EECS, UC Berkeley

Temporal Logic of Actions

Software Verification with Abstraction-Based Methods

PLEASE DO NOT REMOVE THIS PAGE

Benefits of Interval Temporal Logic for Specification of Concurrent Systems

Requirements Validation. Content. What the standards say (*) ?? Validation, Verification, Accreditation!! Correctness and completeness

Principles. Model (System Requirements) Answer: Model Checker. Specification (System Property) Yes, if the model satisfies the specification

Transcription:

Model Checking: An Introduction Meeting 3, CSCI 5535, Spring 2013 Announcements Homework 0 ( Preliminaries ) out, due Friday Saturday This Week Dive into research motivating CSCI 5535 Next Week Begin foundations 2 1

Course Summary Course At-A-Glance Part I: Language Specification Semantics = Describing programs Evaluation strategies, imperative languages Textbook: Glynn Winskel The Formal Semantics of Programming Languages Part II: Language Design Types = Classifying programs Typed λ-calculus, functional languages Part III: Applications 4 2

Core Topics Semantics Operational semantics rules for execution on an abstract machine useful for implementing a compiler or interpreter Axiomatic semantics logical rules for reasoning about the behavior of a program useful for proving program correctness Abstract interpretation application: program analysis Types λ-calculus tiny language to study core issues in isolation 5 But first 3

First Topic: Model Checking Verify properties or find bugs in software Take an important program (eg, a device driver) Merge it with a property (eg, no deadlocks) Transform the result into a boolean program Use a model checker to exhaustively explore the resulting state space Result 1: program provably satisfies property Result 2: program violates property right here on line 92,376! 7 Who are we again? We're going to find critical bugs in important bits of software using PL techniques! You ll be enthusiastic about this and thus want to learn the gritty details 8 4

Overarching Plan Model Checking (today) ( models Transition systems (ie, Temporal properties Temporal logics: LTL and CTL Explicit-state model checking Symbolic model checking Counterexample Guided Abstraction Refinement Safety properties Predicate abstraction Software model checking Counterexample feasibility Abstraction refinement weakest pre, thrm prv 9 Take-Home Message Model checking is the exhaustive exploration of the state space of a system, typically to see if an error state is reachable It produces concrete counterexamples The state explosion problem refers to the large number of states in the model Temporal logic allows you to specify properties with concepts like eventually and always 10 5

Spoiler This stuff really works! Symbolic model checking is a massive success in the model-checking field SLAM took the PL world by storm Spawned multiple copycat projects Launched Microsoft s Static Driver Verifier (released in the Windows DDK) 11 Model Checking There are complete courses in model checking (see ECEN 5139, Prof Cerny) Model Checking by Edmund M Clarke, Orna Grumberg, and Doron A Peled Symbolic Model Checking by Ken McMillan We will skim 6

What is Model Checking? Keywords? 13 What is Model Checking? 14 7

Keywords Model checking is an automated technique Model checking verifies transition systems Model checking verifies temporal properties Model checking falsifies by generating counterexamples A model checker is a program that checks if a (transition) system satisfies a (temporal) property 15 Verification vs Falsification What is verification? What is falsification? 16 8

Verification vs Falsification An automated verification tool can report that the system is verified (with a proof); or that the system was not verified When the system was not verified, it would be helpful to explain why Model checkers can output an error counterexample: a concrete execution scenario that demonstrates the error Can view a model checker as a falsification tool The main goal is to find bugs So what can we verify or falsify? 17 Temporal Properties Temporal Property A property with time-related operators such as invariant or eventually Invariant(p) is true in a state if property p is true in every state on all execution paths starting at that state G, AG, ( globally or box or forall ) Eventually(p) is true in a state if property p is true at some state on every execution path starting from that state F, AF, } ( future or diamond or exists ) 18 9

An Example Concurrent Program A simple concurrent mutual exclusion program Two processes execute asynchronously There is a shared variable turn Two processes use the shared variable to ensure that they are not in the critical section at the same time Can be viewed as a fundamental program: any bigger concurrent one would include this one 10: while (true) { 11: wait(turn == 0); // critical section 12: work(); turn = 1; 13: } // concurrently with 20: while (true) { 21: wait(turn == 1); // critical section 22: work(); turn = 0; 23: } 19 Reachable States of the Example Program 10: while (true) { 11: wait(turn == 0); // critical section 12: work(); turn = 1; 13: } // concurrently with 10,21 10,20 11,20 t=1 10,21 t=1 10,20 t=1 11,20 20: while (true) { 21: wait(turn == 1); // critical section 22: work(); turn = 0; 23: } 11,21 12,20 t=1 10,22 t=1 11,21 Next: formalize this intuition 12,21 t=1 11,22 Each state is a valuation of all the variables: turn and the two program counters for two processes #20 10

Analyzed System is a Transition System Labeled transition system T = (S, I, R, L) Also called a Kripke Structure S = Set of states // standard FSM I S = Set of initial states // standard FSM R S S = Transition relation // standard FSM L: S 2 AP = Labeling function // this is new! AP: Set of atomic propositions (eg, x=5 2AP) Atomic propositions capture basic properties For software, atomic props depend on variable values The labeling function labels each state with the set of propositions true in that state 21 Example Properties of the Program In all the reachable states (configurations) of the system, the two processes are never in the critical section at the same time pc1=12, pc2=22 are atomic properties for being in the critical section Eventually the first process enters the critical section 22 11

Example Properties of the Program In all the reachable states (configurations) of the system, the two processes are never in the critical section at the same time pc1=12, pc2=22 are atomic properties for being in the critical section (( pc2=22 Invariant( (pc1=12 Eventually the first process enters the critical section ( Eventually(pc1=12 23 Temporal Logics For what? There are four basic temporal operators: X p Next p, p holds in the next state G p Globally p, p holds in every state, p is an invariant F p Future p, p will hold in a future state, p holds eventually p U q p Until q, assertion p will hold until q holds Precise meaning of these temporal operators are defined on execution paths 24 12

Execution Paths A path in a transition system is an infinite sequence of states (s 0, s 1, s 2, ), such that 8i 0 (s i, s i+1 ) R A path (s 0,s 1,s 2,) is an execution path if s 0 I Given a path h = (s 0, s 1, s 2, ) h i denotes the i th state: s i h i denotes the i th suffix: (s i, s i+1, s i+2, ) In some temporal logics one can quantify paths starting from a state using path quantifiers A : for all paths (eg, A h ) E : there exists a path (eg, E h ) 25 Paths and Predicates We write h ² p the path h makes the predicate p true h is a path in a transition system p is a temporal logic predicate Example: A h h ² G ( (pc1=12 pc2=22)) 26 13

Linear Time Logic (LTL) LTL properties are constructed from atomic propositions in AP; logical operators,, ; and temporal operators X, G, F, U The semantics of LTL is defined on paths Given a path h: h ² p 27 Linear Time Logic (LTL) h i denotes the i th state: s i h i denotes the i th suffix: (s i, s i+1, s i+2, ) Given a path h: h ² ap iff L(h 0, ap) atomic prop h ² X p iff h 1 ² p next h ² F p iff h ² G p iff h ² p U q iff 28 14

Linear Time Logic (LTL) LTL properties are constructed from atomic propositions in AP; logical operators,, ; and temporal operators X, G, F, U The semantics of LTL is defined on paths: Given a path h: h ² p iff L(h 0, ap) atomic prop h ² X p iff h 1 ² p next h ² F p iff 9i 0 h i ² p future h ² G p iff 8i 0 h i ² p globally h ² p U q iff 9i 0 h i ² q and 8j<i h j ² p until 29 Satisfying Linear Time Logic Given a transition system T = (S, I, R, L) and an LTL property p, T satisfies p if all paths starting from all initial states I satisfy p 30 15

Computation Tree Logic (CTL) In CTL temporal properties use path quantifiers: A : for all paths, E : there exists a path The semantics of CTL is defined on states: Given a state s s ² ap iff L(s, ap) s 0 ² EX p iff 9 a path (s 0, s 1, s 2, ) s 1 ² p s 0 ² AX p iff 8 paths (s 0, s 1, s 2, ) s 1 ² p s 0 ² EG p iff 9 a path (s 0, s 1, s 2, ) 8i 0 s i ² p s 0 ² AG p iff 8 paths (s 0, s 1, s 2, ) 8i 0 s i ² p 31 Linear vs Branching Time LTL is a linear time logic When determining if a path satisfies an LTL formula we are only concerned with a single path CTL is a branching time logic When determining if a state satisfies a CTL formula we are concerned with multiple paths In CTL the computation is instead viewed as a computation tree which contains all the paths The expressive powers of CTL and LTL are incomparable (LTL µ CTL*, CTL µ CTL*) Basic temporal properties can be expressed in both logics Not in this lecture, sorry! (Take a class on Modal Logics) 32 16

Recall the Example 10,20 t=1 10,20 10,21 11,20 t=1 10,21 t=1 11,20 11,21 12,20 t=1 10,22 t=1 11,21 12,21 t=1 11,22 This is a labeled transition system 33 Linear vs Branching Time 10,20 Linear Time View Branching Time View 10,20 10,21 10,21 11,20 10,21 11,21 10,21 11,21 11,21 12,20 11,21 12,21 A computation tree starting at state (turn=0,pc1=10,pc2=20) 12,21 t=1 10,20 t=1 10,21 One path starting at state (turn=0,pc1=10,pc2=20) 34 17

LTL Satisfiability Examples p does not hold p holds On this path: Holds Does Not Hold 35 LTL Satisfiability Examples p does not hold p holds On this path: Holds Does Not Hold 36 18

LTL Satisfiability Examples p does not hold p holds On this path: F p holds, G p does not hold, p does not hold, X p does not hold, X (X p) holds, X (X (X p)) does not hold On this path: F p holds, G p holds, p holds, X p holds, X (X p) holds, X (X (X p))) holds 37 CTL Satisfiability Examples p does not hold p holds s At state s: Holds Does Not Hold 38 19

s CTL Satisfiability Examples p does not hold p holds At state s: Holds Does Not Hold 39 CTL Satisfiability Examples p does not hold p holds s s s At state s: EF p, EX (EX p), AF ( p), p holds AF p, AG p, AG ( p), EX p, EG p, p does not hold At state s: EF p, AF p, EX (EX p), EX p, EG p, p holds AG p, AG ( p), AF ( p) does not hold At state s: EF p, AF p, AG p, EG p, Ex p, AX p, p holds EG ( p), EF ( p), does not hold #40 20

Model Checking Complexity Given a transition system T = (S, I, R, L) and a CTL formula f One can check if a state of the transition system satisfies the formula f in O( f ( S + R )) time Multiple depth first searches (one for each ( operator temporal explicit-state model checking 42 21

State Space Explosion The complexity of model checking increases linearly with respect to the size of the transition system ( S + R ) However, the size of the transition system ( S + R ) is exponential in the number of variables and number of concurrent processes This exponential increase in the state space is called the state space explosion Dealing with it is one of the major challenges in model checking research 43 Algorithm: Temporal Properties = Fixpoints States that satisfy AG(p) are all the states which are not in EF( p) (= the states that can reach p) Compute EF( p) as the fixed point of Func: 2 S 2 S Given Z µ S, ( reach-in-one-step(z Func(Z) = p Called the inverse image of Z Actually, EF( p) is the least-fixed point of Func ( Func(Z smallest set Z such that Z = to compute the least fixed point, start the iteration from Z=, and apply the Func until you reach a fixed point ( points This can be computed (unlike most other fixed 44 22

Pictorial Backward Fixed Point (Inverse Image of p) = EX( p) Initial states p (initial states that violate AG(p)) = (initial states that satisfy EF( p)) (states that can reach p = EF( p)) = (states that violate AG(p) ) This fixed point computation can be used for: verification of EF( p) or falsification of AG(p) and similar fixed points handle the other cases 45 Symbolic Model Checking Symbolic model checking represent state sets and the transition relation as Boolean logic formulas Fixed point computations manipulate sets of states rather than individual states Recall: we needed to compute reach-in-one-step(z), but Z µ S Fixed points can be computed by iteratively manipulating these formulas Use an efficient data structure for manipulation of Boolean logic formulas Binary Decision Diagrams (BDDs) SMV (Symbolic Model Verifier) was the first CTL model checker to use BDDs 46 23

Binary Decision Diagrams (BDDs) Efficient representation for boolean functions (a set can be viewed as a function) Disjunction, conjunction complexity: at most quadratic Negation complexity: constant Equivalence checking complexity: constant or linear Image computation complexity: can be exponential 47 Building Up To Software Model Checking via Counterexample Guided Abstraction Refinement There are easily dozens of papers We will skim 24

Key Terms Counterexample guided abstraction refinement (CEGAR) A successful software model-checking approach Sometimes called Iterative Abstraction Refinement SLAM = The first CEGAR project/tool Developed at MSR Lazy Abstraction = CEGAR optimization Used in the BLAST tool from Berkeley 49 What is Counterexample Guided Abstraction Refinement (CEGAR)? Verification by Model Checking? Theorem Proving? Dataflow Analysis or Program Analysis? 50 25

Verification 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; } Is this program correct? What does correct mean? How do we determine if a program is correct? 51 Verification by Model Checking 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; } 1 (Finite State) Program 2 State Transition Graph 3 Reachability - Program!Finite state model - State explosion + State exploration + Counterexamples Precise [SPIN,SMV,Bandera,JPF] 52 26

Verification by Theorem Proving 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; } 1 Loop Invariants 2 Logical Formulas 3 Check Validity Invariant: lock Æ new = old Ç lock Æ new old 53 Verification by Theorem Proving 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; } 1 Loop Invariants 2 Logical Formulas 3 Check Validity - Loop invariants - Multithreaded programs + Behaviors encoded in logic + Decision procedures Precise [ESC, PCC] 54 27

Verification by Program Analysis 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; } 1 Dataflow Facts 2 Constraint System 3 Solve Constraints - Imprecision: fixed facts + Abstraction + Type/Flow analyses Scalable [Cqual, ESP] 55 Combining Strengths Theorem Proving - Need loop invariants (will find automatically) + Behaviors encoded in logic (used to refine abstraction) + Theorem provers (used to compute successors, refine abstraction) SLAM Model Checking Program Analysis - Imprecise (will be precise) + Abstraction (will shrink the state space we must explore) - Finite-state model, state explosion (will find small good model) + State space exploration (used to get a path sensitive analysis) + Counterexamples (used to find relevant facts, refine abstraction) 56 28

For Next Time Post about today s class and reading Read Lazy Abstraction for the main ideas, ok to skim Sec 7 57 29