tutorial: hardware and software model checking



Similar documents
Today s Agenda. Automata and Logic. Quiz 4 Temporal Logic. Introduction Buchi Automata Linear Time Logic Summary

Formal Verification by Model Checking

The Model Checker SPIN

Algorithmic Software Verification

Formal Verification of Software

Model Checking based Software Verification

Model Checking: An Introduction

Fundamentals of Software Engineering

logic language, static/dynamic models SAT solvers Verified Software Systems 1 How can we model check of a program or system?

Testing LTL Formula Translation into Büchi Automata

T Reactive Systems: Introduction and Finite State Automata

Software Engineering using Formal Methods

Software Model Checking: Theory and Practice

Static Program Transformations for Efficient Software Model Checking

Temporal Logics. Computation Tree Logic

Formal Verification and Linear-time Model Checking

A Logic Approach for LTL System Modification

Formal verification of contracts for synchronous software components using NuSMV

Feature Specification and Automated Conflict Detection

Combining Software and Hardware Verification Techniques

The Course.

Model Checking of Software

Quick Start Guide. June 3, 2012

Introduction to SPIN. Acknowledgments. Parts of the slides are based on an earlier lecture by Radu Iosif, Verimag. Ralf Huuck. Features PROMELA/SPIN

Journal of Mathematics Volume 1, Number 1, Summer 2006 pp

Model Checking LTL Properties over C Programs with Bounded Traces

Model Checking II Temporal Logic Model Checking

Mechanizing the Powerset Construction for Restricted Classes of ω-automata

Software safety - DEF-STAN 00-55

Introduction to Software Verification

INF5140: Specification and Verification of Parallel Systems

Development of dynamically evolving and self-adaptive software. 1. Background


Software Modeling and Verification

Validated Templates for Specification of Complex LTL Formulas

Automata-based Verification - I

Lecture 9 verifying temporal logic

The Model Checker SPIN

Model checking test models. Author: Kevin de Berk Supervisors: Prof. dr. Wan Fokkink, dr. ir. Machiel van der Bijl

SHARED HASH TABLES IN PARALLEL MODEL CHECKING

VeriTech - A Framework for Translating among Model Description Notations

2 Temporal Logic Model Checking

Using Patterns and Composite Propositions to Automate the Generation of Complex LTL

Automata-Based Verification of Temporal Properties on Running Programs Dimitra Giannakopoulou Klaus Havelund

Context-Bounded Model Checking of LTL Properties for ANSI-C Software. Jeremy Morse, Lucas Cordeiro, Bernd Fischer, Denis Nicole

MODEL CHECKING OF SERVICES WORKFLOW RECONFIGURATION: A PERSPECTIVE ON DEPENDABILITY

Verification of multiagent systems via ordered binary decision diagrams: an algorithm and its implementation

Development of global specification for dynamically adaptive software

Coverability for Parallel Programs

CISC422/853: Formal Methods

Introduction to Promela and SPIN. LACL, Université Paris 12

A Classification of Model Checking-based Verification Approaches for Software Models

Introduction to Logic in Computer Science: Autumn 2006

Access Control Based on Dynamic Monitoring for Detecting Software Malicious Behaviours

Specification and Analysis of Contracts Lecture 1 Introduction

LTL Model Checking with Logic Based Petri Nets

Path Querying on Graph Databases

INF5140: Specification and Verification of Parallel Systems

Introduction to Formal Methods. Các Phương Pháp Hình Thức Cho Phát Triển Phần Mềm

On the Modeling and Verification of Security-Aware and Process-Aware Information Systems

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

Formal Verification Coverage: Computing the Coverage Gap between Temporal Specifications

System modeling. Budapest University of Technology and Economics Department of Measurement and Information Systems

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Deterministic Finite Automata

Slides based in part on previous lectures by Mahesh Vishwanathan, and by Gul Agha January 21,

Program Synthesis is a Game

Research Article Towards Support for Software Model Checking: Improving the Efficiency of Formal Specifications

Introduction to Static Analysis for Assurance

CHAPTER 7 GENERAL PROOF SYSTEMS

Finding Liveness Errors with ACO

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

HECTOR a software model checker with cooperating analysis plugins. Nathaniel Charlton and Michael Huth Imperial College London

MODEL CHECKING CONCURRENT AND REAL-TIME SYSTEMS: THE PAT APPROACH. LIU YANG (B.Sc. (Hons.), NUS)

introduction to program monitoring

An Approach to Dependable Embedded Software Development

Optimizing Description Logic Subsumption

Business Process Verification: The Application of Model Checking and Timed Automata

Software Verification and Testing. Lecture Notes: Temporal Logics

Program Monitoring with LTL in EAGLE

Fixed-Point Logics and Computation

Model-Checking Verification for Reliable Web Service

Boolean Algebra Part 1

Introducing Formal Methods. Software Engineering and Formal Methods

6.080/6.089 GITCS Feb 12, Lecture 3

Introduction to Automata Theory. Reading: Chapter 1

Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

Matching Midlet's Security Claims with a Platform Security Policy using Automata Modulo Theory

Computer Architecture Syllabus of Qualifying Examination

Formal Specification and Verification

Real-Time Component Software. slide credits: H. Kopetz, P. Puschner

Concurrent Programming

Modular Verification of Dynamically Adaptive Systems

Automata-Based Verification of Temporal Properties on Running Programs

Stylianos Basagiannis

An Automated Verification Method for Distributed Systems Software Based on Model Extraction

Compiler Construction

MATHEMATICS: CONCEPTS, AND FOUNDATIONS Vol. III - Logic and Computer Science - Phokion G. Kolaitis

Transcription:

tutorial: hardware and software model checking gerard holzmann and anuj puri { gerard anuj } @research.bell-labs.com Bell Labs, USA

outline introduction (15 mins) theory and algorithms system modeling and specifications (25 mins) algorithms and data structures (25 mins) practice (25 minutes) the role of abstraction model checking tools some applications 10/98 2

what is model checking? a model of the hardware or software system a specification Question: does system satisfy specification? key is to build a model that is an appropriate abstraction of the system a model checking tool answers: yes -- if the model definitely satisfies the specification no -- in which case it provides the user a counter-example 10/98 3

An Example: the mars pathfinder The required properties for the Mars Pathfinder control software included: mutual exclusion rules a process cannot access the databus unless it owns a mutual exclusion lock scheduling priority rules a lower priority process cannot execute when a higher priority process is ready to execute saving data to memory, for instance, has higher priority than processing data 10/98 4

the basic sequence for access to the shared bus idle waiting wait for mutex lock obtain lock running execute critical sequence release lock 10/98 5

priority rule i = idle w = waiting r = running i,i,f f = mutex lock free H = high owns lock L = low owns lock w,i,f? i,w,f obtain lock obtain lock r,i,h release? release i,r,l High priority process (dumping measurements) restricted by lock Low priority process (processing data) cannot run unless: i,-,- 10/98 6

system model idle waiting wait for mutex lock H gets lock f L gets lock obtain lock H L running execute critical sequence when a higher priority task is not waiting Lock release lock high priority and low priority tasks 10/98 7

i = idle w = waiting r = running model checking run i,i,f f = mutex lock free H = high owns lock L = low owns lock w,i,f w,w,f i,w,f release lock obtain lock obtain lock r,i,h r,w,h i,r,l release lock w,r,l the hangup problem from July 1997 10/98 8

model checking procedure build a model of the system abstracting out irrelevant details write a specification deadlocks, reachability issues, system invariants etc. run the model checker performs some variation of reachability analysis on the finite state model the possible answers are: yes -- specification satisfied no -- a counter-example provided 10/98 9

defining issues how do you formalize modeling issues specification how do you search for counter-examples explicit state model checking symbolic model checking how do you control complexity avoiding or containing state space explosion abstraction and reduction techniques 10/98 10

outline introduction (15 mins) theory and algorithms system modeling and specifications (25 mins) algorithms and data structures (25 mins) practice (25 minutes) the role of abstraction model checking tools some applications 10/98 11

system modeling hardware: - typically synchronous, clock-driven - bit-registers, signal wires, gates - modeled with hardware description language 2 bit counter: b0 b1 b1 b0 : 00 -> 01 -> 10 -> 11 -> 00 10/98 12

system modeling (cont.) software: - asynchronous, distributed processes - message passing, shared variables, higher level data structures, semaphores, rv-ports SPIN model for the Pathfinder: active proctype low_priority() provided (h_state == idle) { end: do :: l_state = waiting; atomic { mutex == free -> mutex = busy }; l_state = running; /* consumes data */ atomic { l_state = idle; mutex = free }; od } active proctype high_priority (){ end: do :: h_state = waiting; atomic { mutex == free -> mutex = busy }; h_state = running; /* produces data */ atomic { h_state = idle; mutex = free }; od } 10/98 13

system modeling (cont.) underlying model is finite automata models (hardware description language models or promela models) can be translated to finite automata 2-bit counter: b1=0 b0=0 b1=0 b0=1 b1=1 b0=1 b1=1 b0=0 10/98 14

formalizing specifications PLTL (temporal logic) propositional linear time logic first suggested by Amir Pnueli in late 70s ω-automata finite automata accepting infinite sequences many other logics CTL, u-calculus, many variations 10/98 15

formula ::= true, false Syntax of PLTL propositional symbols p, q, r, ( f ) unary_operator f f binary_operator f unary_operator ::= [] --- always, henceforth <> --- eventually! --- logical negation binary_operator ::= U --- strong until && --- logical and --- logical or -> --- implication <-> --- equivalence 10/98 16

semantics of PLTL Model: s = s[0] s[1] s[2] s[3]... for each proposition p, s[i] = p is defined temporal formulas: s[i] = []f provided j >= i s[j] = f s[i] = <>f provided j, j >= i s[j] = f s[i] = f U g s = f provided s[0] = f 10/98 17

typical PLTL formulae frequently used properties: [] p --- invariance <> p --- guarantee p -> (<> q) --- response p -> (q U r) --- precedence []<> p --- recurrence (progress) <>[] p --- stability (non-progress) <> p -> <> q --- correlation two useful equivalences:![] p <=> <>!p!<> p <=> []!p 10/98 18

model checking PLTL formulae System model: S Specification: PLTL formula f How do we model check? we need to learn about ω-automata... 10/98 19

automata theoretic approach lost send_msg s0 s1 s2 send_msg del_msg standard finite automata σ = send_msg lost send_msg del_msg run = s0 s1 s0 s1 s2 σ is accepted when s2 is final ω automata (buchi automata) σ = send_msg lost send_msg del_msg... run = s0 s1 s0 s1 s2... σ is accepted when s2 is visited infinitely often language: set of accepted strings or sequences 10/98 20

automata theoretic approach(cont.) deterministic vs. non-deterministic ω-automata are closed under all boolean operations automata A with language Lang(A) ω there exists C with Lang(C) = Σ \ Lang(A) for A and B, there exists C with Lang(C) = Lang(A) I Lang(B) checking non-emptiness: is there a reachable strongly connected component which contains a final state? 10/98 21

automata theoretic approach (cont.) Model: Lang(Model) Specification - another automaton - Lang(Spec) Model Checking Question: Lang(Model) Lang(Spec) Algorithm: Lang(Model) Lang(Spec) iff ω Lang(Model) I (Σ \ Lang(Spec)) = Yes/No(counter-example) 10/98 22

from logic to automata The truth of an PLTL formula is defined over P execution sequences where 2 For any LTL formula f there exists a buchi automaton that accepts precisely those executions for which f is true Example: the LTL formula <>[] P corresponds to the Buchi automaton: true s0 P s1 P 10/98 23

spin s on-the-fly verification procedure A Distributed System 1 2 n Abstraction 1 2 n Automata Model A Correctness Requirement LTL negation!ltl convert Global Graph is Never Explicitly Built! language intersection x Buchi Automaton Counter-Examples 10/98 24

outline introduction (15 mins) theory and algorithms system modeling and specifications (25 mins) algorithms and data structures (25 mins) practice (25 minutes) the role of abstraction model checking tools some applications 10/98 25

algorithms and data structures basic issues reachability cycle detection explicit state enumeration dfs implicit state enumeration bfs data structures for storing states 10/98 26

explicit state enumeration problem: is there a cycle containing a final state? depth first search (dfs) compute strongly connected components nested depth first search (used in Spin) state storage compression techniques 10/98 27

spin s on-the-fly verification procedure (language intersection) A Distributed System 1 2 n Abstraction 1 2 n Automata Model A Correctness Requirement Global Graph is Never Explicitly Built! language intersection x Buchi Automaton Counter-Examples 10/98 28

dfs algorithm: depth first search store = dfs(q) { if q store return; else store = store U {q}; Memory Bottleneck } for each successor s of q dfs(s); - recursively explore state graph - store as little data as possible about previously visited states - no need to store transitions 10/98 29

Example Problem: Is there a cycle through the final state? 1 2 3 4 5 6 10/98 30

Nested Depth-First Search 1 2 2 3 3 4 5 Seed 4 5 6 6 Copy 0 Copy 1 - Memory Overhead: 2 bits per state - Tarjan s dfs requires 2 x 32 bits per state - Worst case time overhead: 2 x dfs 10/98 31

computational cost Number of States: R Size of each state: S R x S dominates all costs 1) try to reduce R - model reduction (abstraction) - partial order reduction 2) try to reduce S store each state explicitly (fast - default) compress states (-DCOLLAPSE) lossy compression (ie, using hash function) compute minimized DFA recognizer for the states (-DMA=N) 10/98 32

implicit state enumeration boolean functions canonical representation using minimized dfa (obdds) basic boolean operations symbolic representation of transition relation symbolic breadth first search (bfs) 10/98 33

Boolean Functions Example: Boolean Variables: a, b, c f = ab + bc + ac n-variable boolean function: n f : {0,1} -> {0,1} Truth Table: a b c f 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 10/98 34

Minimized DFA representation of Boolean Functions f = ab + bc + ac 0 1 0 1 0 1 0,1 0 1 0,1 - Almost same as OBDDs 10/98 35

Basic Boolean Operations All boolean operations can be performed efficiently using the minimized DFA representation Disjunction: h = f + g Negation: h = ~ f Existential quantification: h(y) = x f(x,y) = f(0,y) + f(1,y) Canonical form equivalence of two boolean functions 10/98 36

Symbolic Transition Relation Transition Relation: R Q x Q (q,r) R iff there is an edge from q to r b0 b1 symbolic transition relation: (b0 = ~b0) (b1 = b1 b0) boolean function representation: 2 2 R : {0,1} x {0,1} -> {0,1} 10/98 37

symbolic breadth first search symbolic transition relation: R(q,q ) initial state: s0(q) symbolic breadth first search: states0(q) = s0(q) s1(q ) = q ( s0(q) R(q,q ) ) states1(q) = states0(q) + s1(q) s2(q ) = q ( s1(q) R(q,q ) ) states2(q) = state1(q) + s2(q) stop when states i(q) = states i-1(q) 10/98 38

minimized dfa storage in spin explicit state enumeration --- states stored as minimized dfa example: 0 1 store = { 011, 101, 110, 111 } 0 1 0 1 0, 1 0 1 0, 1 Add state s in time O( s ) time/memory tradeoff - reduces memory use by 10x-100x - but adds a time penalty of 10x-100x 10/98 39

outline introduction (15 mins) theory and algorithms system modeling and specifications (25 mins) algorithms and data structures (25 mins) practice (25 minutes) the role of abstraction model checking tools some applications 10/98 40

exponential effects in the state space Example: k integers, each taking values from -N to N number of states ~ (2N) Example: k buffers, s slots per buffer, m different items number of states ~ m sk k 10/98 41

importance of abstraction model checkers are intended to be applied to models of systems, not directly to implementations a model is a design abstraction find the appropriate abstraction modeling the interfaces between modules without modeling the internal details of modules without abstractions, simple problems can become intractable and with abstractions, even hard problems can be solved if you know which parameters to tune 10/98 42

importance of abstractions (cont.) if the problem is complex: there is no free lunch: you have to find the right design abstraction be suspicious of variables, counters, integer data items think of how you would explain the principles of the design on a blackboard to a friend model only the relevant aspects 10/98 43

tools implicit state enumeration oriented towards hardware verification smv (CTL), vis, cospan,... explicit state enumeration oriented towards software verification spin (LTL), murphi,... commercial model checking tools 10/98 44

design verification: spin 10/98 45

deep space 1 mission to mars remote agent executive resource manager - verification of a new experimental distributed controller design using SPIN tasks property locks database [ Havelund, Lowry, Penix, 1998] subscribe A ON task interrupt lock event update event maintain property daemon 10/98 46

deep space 1 - results modeling effort - 2 people from NASA/Ames Research center about 6-8 weeks (354 lines in SPIN) 1 week to run and document verification (approx. 300K states, 10 seconds/run) 2 properties checked, both failed 4 serious errors found developer s reaction you ve found a number of bugs that i am sure would not have been found otherwise. One of the bugs revealed a major design flaw. So I d say you have had a substantial impact. 10/98 47

processor verification pentium floating-point division bug cost Intel $475 million plenty of dollars to do a lot of formal verification specialized techniques ALU verification pipelines etc. much commercial activity by EDA tool vendors and chip design companies 10/98 48

intel looking to hire... although formal verification methods have been in widespread use at Intel for several years, sequential formal verification (using model checking) has seen its first wide deployment on the Merced project in the Santa Clara Processor Division we have trained a large number of engineers in the techniques of formal specification and proof, made great strides in mastering the technology, improving the tools and developing methodologies of usage; but most importantly, we have found numerous bugs, some of them very sneaky, and established FV as a valuable contributior to the quality of logic design. we are looking for a small number of exceptional candidates to own the formal verification of blocks of Merced logic design. The work involves defining a comprehensive set of assertions which describe the behavior of the blocks, formulating them in a formal language, and proving these properties using our automated proof tools. Our current focus is on model checking as the primary proof mechanism, but we have access to and will make use of other tools as appropriate. 10/98 49

summary real problem: find bugs in design model checking: build a model of the system, then the model checking tool will automatically check whether the specification is satisfied abstractions are key in building tractable models theory of model checking good tool support both software and hardware model checking are becoming mainstream, after having proven their value in academic and industrial use 10/98 50

some references Gerard Holzmann, Design and Validation of Computer Protocols, Prentice-Hall, 1991. good introduction on spin and protocol verification Ken McMillan, Symbolic Model Checking, Kluwer Academic Publishers, 1993. good introduction to SMV, hardware and symbolic verification K.Havelund, M.Lowry, J.Penix, Formal Analysis of a Space Craft Controller using SPIN, 1998. nice application of model checking 10/98 51