University of Toronto Department of Computer Science © 2004-5 Steve Easterbrook. This presentation is available free for non-commercial use with attribution.

Slides:



Advertisements
Similar presentations
1 Reasoning with Promela Safety properties bad things do not happen can check by inspecting finite behaviours Liveness properties good things do eventually.
Advertisements

Auto-Generation of Test Cases for Infinite States Reactive Systems Based on Symbolic Execution and Formula Rewriting Donghuo Chen School of Computer Science.
Metodi formali dello sviluppo software a.a.2013/2014 Prof.Anna Labella.
CS 267: Automated Verification Lecture 2: Linear vs. Branching time. Temporal Logics: CTL, CTL*. CTL model checking algorithm. Counter-example generation.
M ODEL CHECKING -Vasvi Kakkad University of Sydney.
Algorithmic Software Verification VII. Computation tree logic and bisimulations.
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Partial Order Reduction: Main Idea
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:
An Introduction to the Model Verifier verds Wenhui Zhang September 15 th, 2010.
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.
CS6133 Software Specification and Verification
UPPAAL Introduction Chien-Liang Chen.
Timed Automata.
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.
1 Temporal Claims A temporal claim is defined in Promela by the syntax: never { … body … } never is a keyword, like proctype. The body is the same as for.
August Moscow meeting1August Moscow meeting1August Moscow meeting11 Deductive tools in insertion modeling verification A.Letichevsky.
1 Model Checking, Abstraction- Refinement, and Their Implementation Based on slides by: Orna Grumberg Presented by: Yael Meller June 2008.
Action Language: A Specification Language for Model Checking Reactive Systems Tevfik Bultan Department of Computer Science University of California, Santa.
Model Checking. Used in studying behaviors of reactive systems Typically involves three steps: Create a finite state model (FSM) of the system design.
Lecture 4&5: Model Checking: A quick introduction Professor Aditya Ghose Director, Decision Systems Lab School of IT and Computer Science University of.
© Betty HC Cheng. This presentation is available free for non-commercial use with attribution under a creative commons license. Acknowledge: S.
Review of the automata-theoretic approach to model-checking.
Embedded Systems Laboratory Department of Computer and Information Science Linköping University Sweden Formal Verification and Model Checking Traian Pop.
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
ESE601: Hybrid Systems Introduction to verification Spring 2006.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
1 Formal Engineering of Reliable Software LASER 2004 school Tutorial, Lecture1 Natasha Sharygina Carnegie Mellon University.
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
University of Toronto Department of Computer Science CSC444 Lec04- 1 Lecture 4: Software Lifecycles The Software Process Waterfall model Rapid Prototyping.
University of Toronto Department of Computer Science © 2001, Steve Easterbrook CSC444 Lec17 1 Lecture 17: Formal Modeling Methods Formal Modeling Techniques.
1 Carnegie Mellon UniversitySPINFlavio Lerda Bug Catching SPIN An explicit state model checker.
Cheng/Dillon-Software Engineering: Formal Methods Model Checking.
University of Toronto Department of Computer Science © 2001, Steve Easterbrook CSC444 Lec13 1 Lecture 13: Representing software designs Viewpoints Structural.
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Introduction to Formal Methods Based on Jeannette M. Wing. A Specifier's Introduction to Formal Methods. IEEE Computer, 23(9):8-24, September,
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
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.
On Reducing the Global State Graph for Verification of Distributed Computations Vijay K. Garg, Arindam Chakraborty Parallel and Distributed Systems Laboratory.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Requirements Specification. Welcome to Software Engineering: “Requirements Specification” “Requirements Specification”  Verb?  Noun?  “Specification”
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Deriving Operational Software Specification from System Goals Xin Bai EEL 5881 Course Fall, 2003.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 05/06 Universität Dortmund Validation - Formal verification -
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Verification & Validation By: Amir Masoud Gharehbaghi
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
1 CSEP590 – Model Checking and Automated Verification Lecture outline for July 9, 2003.
1 CEN 4020 Software Engineering PPT4: Requirement analysis.
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
Writing, Verifying and Exploiting Formal Specifications for Hardware Designs Chapter 3: Verifying a Specification Presenter: Scott Crosby.
Model Checking Lecture 2. Model-Checking Problem I |= S System modelSystem property.
Abstraction and Abstract Interpretation. Abstraction (a simplified view) Abstraction is an effective tool in verification Given a transition system, we.
York University Department of Computer Science © Castro, Mylopoulos and Easterbrook Lecture 11: Modelling “State”  What is State?  statespace.
Model Checking Lecture 2 Tom Henzinger. Model-Checking Problem I |= S System modelSystem property.
Complexity of Compositional Model Checking of Computation Tree Logic on Simple Structures Krishnendu Chatterjee Pallab Dasgupta P.P. Chakrabarti IWDC 2004,
CIS 842: Specification and Verification of Reactive Systems
CSCI1600: Embedded and Real Time Software
Computer Security: Art and Science, 2nd Edition
CSCI1600: Embedded and Real Time Software
Program correctness Branching-time temporal logics
Program correctness Model-checking CTL
Presentation transcript:

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 1 Lecture 16: Modelling “events” Ü Focus on states or events?  E.g. SCR table-based models  Explicit event semantics Ü Comparing notations for state transition models  FSMs vs. Statecharts vs. SCR Ü Checking properties of state transition models  Consistency Checking  Model Checking, using Temporal Logic Ü When to use formal methods

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 2 What are we modelling? Ü Starting point:  States of the environment  (Application domain) events that change the state of the environment Ü Requirements expressed as:  Constraints over states and events of the application domain  E.g. “When the aircraft is in the air, the pilot should be prevented from accidentally engaging the reverse thrust” Ü To get to a specification:  For each relevant application domain event, find a corresponding input event  For each relevant state, ensure there is a way for the machine to detect it  For each required action, find a corresponding output event Application Domain Machine Domain D - domain properties R - requirements C - computers P - programs

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 3 software Monitored Variables Enviro- ment System input devices input data items data items output devices output Controlled Variables Enviro- ment Tabular Specifications: SCR Dictionaries: Monitored/Controlled Variables Types Constants Mode Transition Tables Event Tables Condition Tables Tables: also: Assertions, Scenarios,... Four Variable Model: SCR Specification

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 4 SCR basics Ü Modes and Mode classes  A mode class is a finite state machine, with states called system modes  Transitions in each mode class are triggered by events  Complex systems described using several mode classes operating in parallel  System State is defined as:  the system is in exactly one mode from each mode class…  …and each variable has a unique value Ü Events  Single input assumption - only one input event can occur at once  An event occurs when any system entity changes value  An input event occurs when an input variable changes value  Notation:  We may need to refer to both the old and new value of a variable:  Used primed values to denote values after the event   c   y  1  y’=1  c   c’  A conditioned event is an event with a predicate WHEN d   c  c’  d Source: Adapted from Heitmeyer et. al

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 5 Ü Mode Class Tables  Define a (disjoint) set of modes (states) that the software can be in.  Each mode class has a mode table showing which events cause mode changes  A mode table defines a partial function from modes and events to modes Ü Example: Defining Mode Classes Source: Adapted from Heitmeyer et. al

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 6 Ü Event Tables  defines how a controlled variable changes in response to input events  Defines a partial function from modes and events to variable values  Example: Ü Condition Tables  defines the value of a controlled variable under every possible condition  Defines a total function from modes and conditions to variable values  Example: Defining Controlled Variables Source: Adapted from Heitmeyer et. al

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 7 offhook idleconnectedringtonedialtone busytone on hook off hook Dial [callee busy] Dial [callee idle] Callee accepts Callee disconnects idleconnectedringtonedialtone busytone on hook off hook Dial [callee busy] Dial [callee idle] Callee accepts Callee disconnects Refresher: FSMs and Statecharts

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 8 SCR Equivalent Ü Interpretation:  In WHEN callee_offhook takes you to Ringing  In takes you to Idle  Etc…

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 9 State Machine Models vs. SCR Ü All 3 models on previous slides are (approx) equivalent Ü State machine models  Emphasis is on states & transitions  No systematic treatment of events  Different event semantics can be applied  Graphical notation easy to understand (?)  Composition achieved through statechart nesting  Hard to represent complex conditions on transitions  Hard to represent real-time constraints (e.g. elapsed time) Ü SCR models  Emphasis is on events  Clear event semantics based on changes to environmental variables  Single input assumption simplifies modelling  Tabular notation easy to understand (?)  Composition achieved through parallel mode classes  Hard to represent real-time constraints (e.g. elapsed time)

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 10 Formal Analysis Ü Consistency analysis and typechecking  “Is the formal model well-formed?”  [assumes a modeling language where well-formedness is a useful thing to check] Ü Validation:  Animation of the model on small examples  Formal challenges:  “if the model is correct then the following property should hold...”  ‘What if’ questions:  reasoning about the consequences of particular requirements;  reasoning about the effect of possible changes  State exploration  E.g. use a model checking to find traces that satisfy some property  Checking application properties:  “will the system ever do the following...” Ü Verifying design refinement  “does the design meet the requirements?”

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 11 E.g. Consistency Checks in SCR Ü Syntax  did we use the notation correctly? Ü Type Checks  do we use each variable correctly? Ü Disjointness  is there any overlap between rows of the mode tables?  ensures we have a deterministic state machine Ü Coverage  does each condition table define a value for all possible conditions? Ü Mode Reachability  is there any mode that cannot ever happen? Ü Cycle Detection  have we defined any variable in terms of itself?

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 12 Model Checking Ü Has revolutionized formal verification:  emphasis on partial verification of partial models  E.g. as a debugging tool for state machine models Ü What it does:  Mathematically – computes the “satisfies” relation:  Given a temporal logic theory, checks whether a given finite state machine is a model for that theory.  Engineering view – checks whether properties hold:  Given a state machine model, checks whether the model obeys various safety and liveness properties Ü How to apply it in RE:  The model is an (operational) Specification  Check whether particular requirements hold of the spec  The model is (an abstracted portion of) the Requirements  Carry out basic validity tests as the model is developed  The model is a conjunction of the Requirements and the Domain  Formalise assumptions and test whether the model respects them

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 13 Model Checking Basics Ü Build a finite state machine model  E.g. PROMELA - processes and message channels  E.g. SCR - tables for state transitions and control actions  E.g. RSML - statecharts + truth tables for action preconditions Ü Express validation property as a logic specification  Propositions in first order logic (for invariants)  Temporal Logic (for safety & liveness properties)  E.g. CTL, LTL,... Ü Run the model checker:  Computes the value of:model property Ü Explore counter-examples  If the answer is ‘no’ find out why the property doesn’t hold  Counter-example is a trace through the model

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 14 Temporal Logic Ü LTL (Linear Temporal Logic)  Expresses properties of infinite traces through a state machine model  adds two temporal operators to propositional logic: ◊p - p is true eventually (in some future state)  p - p is true always (now and in the future) Ü CTL (Computational Tree Logic)  branching-time logic - can quantify over possible futures  Each operator has two parts: EX p - p is true in some next states AX p - p is true in all next states EF p - along some path, p is true in some future state AF p - along all paths… E[p U q] - along some path, p holds until q holds; A[p U q] - along all paths… EG p - along some path, p holds in every state; AG p - along all paths…

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 15 Example Ü Sample Properties  If you are connected you can hang up:  AG(CONNECTED  EX(¬OFFHOOK)  If you are connected, hanging up always disconnects you:  AG(CONNECTED  AX(¬OFFHOOK  ¬CONNECTED))  A connection doesn’t start until you pick up the phone:  AG(¬CONNECTED  A[¬CONNECTED U OFFHOOK])  If you make a call, the phone cannot ring without returning to idle first:  AG((RINGTONE  BUSYTONE)  A[¬RINGING U IDLE]) offhook idleconnectedringtonedialtone busytone on hook off hook Dial [callee busy] Dial [callee idle] Callee accepts Callee disconnects

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 16 Complexity Issues Ü The problem:  Model Checking is exponential in the size of the model and the property  Current MC engines can explore states…  using highly optimized data structures (BDDs)  …and state space reduction techniques  …that’s roughly 400 propositional variables  integer and real variables cause real problems  Realistic models are often to large to be model checked Ü The solution:  Abstraction:  Replace related groups of states with a single superstate  Replace real & integer variables with propositional variables  Projection:  Slice the model to remove parts unrelated to the property  Compositional verification - break large model into smaller pieces  (But it’s hard to verify that the composition preserves properties)

University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 17 Summary Ü SCR vs UML Statecharts  Tabular view allows more detail - e.g. complex conditions  Graphical view shows hierarchical structure more clearly  Event Semantics  SCR has a precisely defined meaning for “events”  UML Statecharts do not  Uses:  UML statecharts good for sketches, design models  SCR good for writing precise specifications Ü Analysis:  “Model checkers” are debugging tools for state machine models  Write temporal logic properties and test whether they hold  Very good at finding subtle errors in specifications