Lecture 9: SMV: An Introduction

Slides:



Advertisements
Similar presentations
Modeling issues Book: chapters 4.12, 5.4, 8.4, 10.1.
Advertisements

Introduction to SMV Part 2
Algorithmic Software Verification VII. Computation tree logic and bisimulations.
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Models of Concurrency Manna, Pnueli.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CS 290C: Formal Models for Web Software Lecture 3: Verification of Navigation Models with the Spin Model Checker Instructor: Tevfik Bultan.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
An Introduction to the Model Verifier verds Wenhui Zhang September 15 th, 2010.
ECE Synthesis & Verification - L271 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Model Checking basics.
1 MODULE name (parameters) “Ontology” “Program” “Properties” The NuSMV language A module can contain modules Top level: parameters less module Lower level.
Temporal Logic and the NuSMV Model Checker CS 680 Formal Methods Jeremy Johnson.
Model Checking I What are LTL and CTL?. and or dreq q0 dack q0bar.
UPPAAL Introduction Chien-Liang Chen.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Model Checking Inputs: A design (in some HDL) and a property (in some temporal logic) Outputs: Decision about whether or not the property always holds.
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
CS 267: Automated Verification Lecture 7: SMV Symbolic Model Checker, Partitioned Transition Systems, Counter-example Generation in Symbolic Model Checking.
Model Checking I What are LTL and CTL?. and or dreq q0 dack q0bar D D.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
1 Spin Model Checker Samaneh Navabpour Electrical and Computer Engineering Department University of Waterloo SE-464 Summer 2011.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
© 2011 Carnegie Mellon University Introduction to SMV Part 2 Arie Gurfinkel (SEI/CMU) based on material by Prof. Clarke and others.
© 2011 Carnegie Mellon University Introduction to SMV Arie Gurfinkel (SEI/CMU) based on material by Prof. Clarke and others.
FMuOS: Formal verification of critical program parts NuSMV system Prepared by: Alan Jović, Ph.D. Acad. year: 2014/2015.
Action Language: A Specification Language for Model Checking Reactive Systems Tevfik Bultan Department of Computer Science University of California, Santa.
SMV Examples Bug Catching in 2006 Fall Oct. 24, 2006.
1 Carnegie Mellon UniversitySPINFlavio Lerda SPIN An explicit state model checker.
Lecture 4&5: Model Checking: A quick introduction Professor Aditya Ghose Director, Decision Systems Lab School of IT and Computer Science University of.
1 Using Cadence SMV to verify temporal properties of finite-state machines : Intro to Model Checking October 9, 2008.
Review of the automata-theoretic approach to model-checking.
2/18/20051 Introduction to SMV. 2/18/20052 Symbolic Model Verifier Ken McMillan, Symbolic Model Checking: An Approach to the State Explosion Problem,
1 Formal Engineering of Reliable Software LASER 2004 school Tutorial, Lecture1 Natasha Sharygina Carnegie Mellon University.
Optimizing Symbolic Model Checking for Constraint-Rich Systems Randal E. Bryant Bwolen Yang, Reid Simmons, David R. O’Hallaron Carnegie Mellon University.
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Introduction to Software Testing Chapter 9.4 Model-Based Grammars Paul Ammann & Jeff Offutt
1 Introduction to SMV and Model Checking Mostly by: Ken McMillan Cadence Berkeley Labs Small parts by: Brandon Eames ISIS/Vanderbilt.
UPPAAL Ghaith Haddad. Introduction UPPAAL is a tool for modeling, validation and verification of real-time systems. Appropriate for systems that can be.
ECE 2372 Modern Digital System Design
CS6133 Software Specification and Verification
Lecture51 Timed Automata II CS 5270 Lecture 5.
Introduction to Formal Verification using Rulebase April 18, 2001 Rebecca Gott eServer I/O Development Hardware Verification
Algorithmic Software Verification V &VI. Binary decision diagrams.
CS5270 Lecture 41 Timed Automata I CS 5270 Lecture 4.
2/19/20031 Introduction to SMV. 2/19/20032 Useful Links CMU Model checking homepage SMV windows version
Algorithm Design.
Lecture 81 Optimizing CTL Model checking + Model checking TCTL CS 5270 Lecture 9.
CIS 842: Specification and Verification of Reactive Systems Lecture INTRO-Examples: Simple BIR-Lite Examples Copyright 2004, Matt Dwyer, John Hatcliff,
Copyright 2001, Matt Dwyer, John Hatcliff, and Radu Iosif. The syllabus and all lectures for this course are copyrighted materials and may not be used.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CS5270 Lecture 41 Timed Automata I CS 5270 Lecture 4.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Automatic Test Generation
Basic concepts of Model Checking
What is the SMV (Symbolic Model Verifier) System ?
Input Space Partition Testing CS 4501 / 6501 Software Testing
CIS 842: Specification and Verification of Reactive Systems
Timed Automata II CS 5270 Lecture Lecture5.
Instructor: Rajeev Alur
The Selection Structure
Automatic Verification
Learning to Program in Python
Propositional Calculus: Boolean Algebra and Simplification
Over-Approximating Boolean Programs with Unbounded Thread Creation
Automatic Verification of Industrial Designs
Semaphores Chapter 6.
Introduction to SMV 2/19/2003.
Presentation transcript:

Lecture 9: SMV: An Introduction Based on lectures by Dong Wang and Marius Minea.

Useful Links CMU Model checking homepage http://www.cs.cmu.edu/~modelcheck/ SMV windows version http://www.cs.cmu.edu/~modelcheck/smv.html#nt SMV man page (must read) http://www.cs.cmu.edu/~dongw/smv.txt SMV manual http://www.cs.cmu.edu/~modelcheck/smv/smvmanual.ps

SMV: Symbolic Model Verifier Ken McMillan, Symbolic Model Checking: An Approach to State Explosion Problem, 1993. Finite-state Systems described in a specialized language Specifications given as CTL formulas Internal representation using BDDs Automatically verifies specification or produce counterexamples

Language Characteristics Allows description of synchronous and asynchronous systems Modularized and hierarchical descriptions Finite data types: boolean, enum, int etc Nondeterminism Variety of specifications: safety, liveness, deadlock freedom

A Sample SMV Program MODULE main VAR request: boolean; state: {ready, busy}; ASSIGN init(state) := ready; next(state) := case state=ready & request: busy; 1: {ready, busy}; esac; SPEC AG(request -> AF (state = busy))

Variable Assignments Assignment to initial state: init(value) := 0; Assignment to next state: transition relation next(value) := value + carry_in mod 2; Assignment to current state: invariant relation carry_out := value & carry_in; SMV is a parallel assignment language all assignments executed in parallel and simultaneously SMV checks for circularities and duplicate assignments

Specifications EF p : from all initial states, a state where p holds is reachable. A[p U q] : p remains true until q is true. AG AF p : p is true infinitely often on very compution path. AG (req -> AF ack) : any request will be eventually acknowledged.

ASSIGN and DEFINE VAR a: boolean; ASSIGN a := b | c; declares a new state variable a becomes part of invariant relation DEFINE d:= b | c; is effectively a macro definition, each occurrence of d is replaced by b | c no extra BDD variable is generated for d the BDD for b | c becomes part of each expression using d Generally suitable for more complex assignments

More on Case Statement Case statement is converted to if-then-else internally, so all the guards are evaluated sequentially. If none of the guards are true, an arbitrary valid value is returned.

Nondeterminism Completely unassigned variable can model unconstrained input. {val_1, …, val_n} is an expression taking on any of the given values nondeterministically. Nondeterministic choice to model an implementation that has not been refined yet In abstract models where a value of some state variable cannot be completely determined

Modules and Hierarchy Modules can be instantiated. Each program has a module main Scoping Variables declared outside a module can be passed as parameters. Internal variables of a module can be used in enclosing modules(submodel.varname). Parameters are passed by reference. in variable declarations module_name.var_name to reference variable in a module

Modules and Hierarchy - Example MODULE main VAR bit0 : counter_cell(1); bit1 : counter_cell(bit0.carry_out); bit2 : counter_cell(bit1.carry_out); SPEC AG AF bit2.carry_out MODULE counter_cell(carry_in) VAR value : boolean; ASSIGN init(value) := 0; next(value) := value + carry_in mod 2; DEFINE carry_out := value & carry_in;

Module Composition Synchronous composition All assignments are executed in parallel and synchronously. A single step of the resulting model corresponds to a step in each of the components. Asynchronous composition A step of the composition is a step by exactly one process. Variables, not assigned in that process, are left unchanged.

Asynchronous Composition MODULE main VAR gate1: process inverter(gate3.output); gate2: process inverter(gate1.output); gate3: process inverter(gate2.output); SPEC (AG AF gate1.output) SPEC (AG AF !gate1.output) MODULE inverter(input) VAR output: boolean; ASSIGN init(output) := 0; next(output) := !input;

Counterexamples -- specification AG AF (!gate1.output) is false -- as demonstrated by the following execution state 2.1: gate1.output = 0 gate2.output = 0 gate3.output = 0 state 2.2: [executing process gate1] -- loop starts here -- state 2.3: gate1.output = 1 [stuttering] state 2.4:

Fairness Fairness constraint FAIRNESS ctl_formulae Assumed to be true infinitely often Model checker only explores paths satisfying fairness constraint FAIRNESS running

Counter Revisited MODULE main VAR count_enable: boolean; bit0 : counter_cell(count_enable); bit1 : counter_cell(bit0.carry_out); bit2 : counter_cell(bit1.carry_out); SPEC AG AF bit2.carry_out FAIRNESS count_enable

Modeling Shared Variables MODULE zero(a) ASSIGN next(a) := 0; FAIRNESS running MODULE one(b) ASSIGN next(b) := 1; MODULE main VAR x: boolean; z: process zero(x); o: process one(x); SPEC AG AF (x = 0)

Implicit Modeling INIT boolean_expr Initial states will be those satisfy boolean_expr. There is no next operator in boolean_expr. INVAR boolean_expr The set of states is restricted to those satisfy boolean_expr TRANS boolean_expr Restrict the transition relation.

Implicit Modeling Example INVAR (!enable -> stutter) TRANS ((state = idle & next(state) = request) | (state = request & sema & turn = id & (next(state) = critical & next(sema) = 0) | (state = critical & next(state) = release))

TRANS Advantages Group assignments to different variables Good for modeling guarded commands Disadvantages - easy to make mistakes Contradictory constraints Transition relation is empty, reachable states is 0. Transition relation is not total. Missing cases

Shared Data Example - main module Two users assign pid to shared data in turn MODULE main VAR data: boolean; turn: boolean; user0: user(0, data, turn); user1: user(1, data, !turn); ASSIGN next(turn) := !turn; SPEC AG (AF data & AF (!data))

Shared Data Example - user module 1 Using ASSIGN and case statement won’t work (constraining sema all the time). MODULE user(pid, data, turn) ASSIGN next(data) := case turn: pid; 1: data; esac; line 3: multiple assignment: next(data)

Shared Data Example - user module 2 TRANS is useful for changing shared data in a synchronous system between modules. MODULE user(pid, data, turn) TRANS turn -> next(data) = id

Guarded Commands guard1 : action1 guard2 : action2 … otherwise: nop TRANS (guard1 & action1) | (guard2 & action2) | (!guard1 & !gard2 & … & “nop”)

Guarded Commands Pitfall TRANS guard1 -> action1 & guard2 -> action2 & … (!guard1 & !guard2 & ... -> “nop”) For example true -> next(b) = 0 & true -> next(b) = 1 & ... This results in an empty transition relation

TRANS Guidelines Try to use ASSIGN instead Write in a disjunction of conjunctions format Do not constrain current state variable, use INVAR for that Try to cover all cases Try to make guards disjoint

SMV Steps read_model: read the input smv file flatten_hierarchy: instantiate modules and processes build_model: compile the model into BDDs(initial state, invar, transition relation) check_spec: checking specification bottom-up

Synchronous vs. Asynchronous Conjunct transition relation from each module Asynchronous N (V, V’) = N0(V, V’) | .. | Nn-1(V,V’) where Ni (V,V’) = (vi’ = Fi(V)) & ji (vj’= vj) Figure out variables each process modify Fact - SMV does not support modules having TRANS to be a process, why?

Run SMV smv [options] inputfile -c cache-size -k key-table-size -m mini-cache-size -v verbose -r prints out statistics about reachable state space -checktrans checks whether the transition relation is total

SMV Options –f computes set of reachable staes first Model checking algorithms traverse only set of reachable states instead of complete state space. useful if reachable state space is a small fraction of total state space : useful to follow progress of verification

SMV Options: Variable ordering Variable ordering is crucial for small BDD sizes and speed. Generally, variables which are related need to be close in the ordering. –i filename –o filename Input, output BDD variable ordering to given file. -reorder Invokes automatic variable reordering as soon as BDD size exceeds a certain limit

SMV Options: Transition relation smv –cp part_limit Conjunctive partitioning. Transition relation not evaluated as a whole, instead individual next() assignments are grouped into partitions that do not exceed part_limit. This method generally uses less memory and can benefit from early quantification. Only for synchronous models

Mutual Exclusion -1 MODULE user(turn, id, other) VAR state: {n, t, c}; ASSIGN init(state) := n; next(state) := case state = n : {n, t}; state = t & other = n: c; state = t & other = t & turn = id: c; state = c: n; 1: state; esac; SPEC AG(state = t -> AF (state = c))

Mutual Exclusion -2 MODULE main VAR turn: {1, 2}; user1: user(turn, 1, user2.state); user2: user(turn, 2, user1.state); ASSIGN init(turn) := 1; next(turn) := case user1.state = n & user2.state = t: 2; user2.state = n & user1.state = t: 1; 1: turn; esac; SPEC AG !(user1.state = c & user2.state = c)

Mutual Exclusion: Counterexample Specification AG (user1.state != c) is false state 1.1 turn = 1 user1.state = n user2.state = n state 1.2: user1.state = t state 1.3 user1.state = c