The Spin Model Checker - Advanced Features

Slides:



Advertisements
Similar presentations
The SPIN System. What is SPIN? Model-checker. Based on automata theory. Allows LTL or automata specification Efficient (on-the-fly model checking, partial.
Advertisements

The SPIN System. What is SPIN? Model-checker. Based on automata theory. Allows LTL or automata specification Efficient (on-the-fly model checking, partial.
Modeling issues Book: chapters 4.12, 5.4, 8.4, 10.1.
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
CS 290C: Formal Models for Web Software Lecture 3: Verification of Navigation Models with the Spin Model Checker Instructor: Tevfik Bultan.
Statement-Level Control Structures
CSCI 330: Programming Language Concepts Instructor: Pranava K. Jha Control Flow-II: Execution Order.
/ PSWLAB P ROMELA Semantics from “THE SPIN MODEL CHECKER” by G. J. Holzmann Presented by Hong,Shin 5 th Oct :021PROMELA Semantics.
An Overview of PROMELA. A protocol Validation Language –A notation for the specification and verification of procedure rules. –A partial description of.
The model checker SPIN1 The Model Checker SPIN. The model checker SPIN2 SPIN & Promela SPIN(=Simple Promela Interpreter) –tool for analyzing the logical.
תרגול 9 META LABELS. Basic types of claims State properties.
Wishnu Prasetya Model Checking with SPIN Modeling and Verification with SPIN.
The Spin Model Checker Promela Introduction Nguyen Tuan Duc Shogo Sawai.
1 Spin Model Checker Samaneh Navabpour Electrical and Computer Engineering Department University of Waterloo SE-464 Summer 2011.
Spin Tutorial (some verification options). Assertion is always executable and has no other effect on the state of the system than to change the local.
© 2011 Carnegie Mellon University SPIN: Part Bug Catching: Automated Program Verification and Testing Sagar Chaki November 2, 2011.
© 2011 Carnegie Mellon University SPIN: Part Bug Catching: Automated Program Verification and Testing Sagar Chaki October 31, 2011.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
1 Carnegie Mellon UniversitySPINFlavio Lerda SPIN An explicit state model checker.
Temporal Logic Model- checking with SPIN COMP6004 Stéphane Lo Presti Part 3: The PROMELA Semantics.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
CONTROL STATEMENTS Lakhbir Singh(Lect.IT) S.R.S.G.P.C.G. Ludhiana.
Wishnu Prasetya Model Checking with SPIN A Bit More about SPIN.
Correctness requirements. Basic Types of Claims Basic assertions End-state labels Progress-state labels Accept-state labels Never claims Trace assertions.
Korea Advanced Institute of Science and Technology The Spin Model Checker - Advanced Features Moonzoo Kim CS Dept. KAIST.
1 Rendez-Vous Logical extension of chan buffer = [N] of byte is chan port = [0] of byte Channel port is a rendez-vous port (binary handshake). Two processes,
Concurrency. A process is a program executing on a virtual computer Processor speed and multiplexing of shared resources are ignored Order of thread execution.
sequence of execution of high-level statements
Control Structures sequence of execution of high-level statements.
Radu Iosif Introduction to SPIN Radu Iosif
Temporal Logic Model-checking with SPIN
The Spin Model Checker : Part I Moonzoo Kim KAIST.
Hwajung Lee. Well, you need to capture the notions of atomicity, non-determinism, fairness etc. These concepts are not built into languages like JAVA,
Hwajung Lee. Why do we need these? Don’t we already know a lot about programming? Well, you need to capture the notions of atomicity, non-determinism,
/ PSWLAB S PIN Search Optimization from “THE SPIN MODEL CHECKER” by G. Holzmann Presented by Hong,Shin 23 th Nov SPIN Search.
Lecture 4 Introduction to Promela. Promela and Spin Promela - process meta language G. Holzmann, Bell Labs (Lucent) C-like language + concurrency dyamic.
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
Control structures in C by Dr P.Padmanabham Professor (CSE)&Director Bharat Institute of Engineering &Technology Hyderabad Mobile
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
Wishnu Prasetya Model Checking with SPIN Modeling and Verification with Promela.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
November COMP60621 Designing for Parallelism Lecture 14 Deadlock + Channels in Promela John Gurd, Graham Riley Centre for Novel Computing School.
Session Three Review & Conditional Control Flow. Java File Hierarchy Projects Packages Classes Methods.
Chapter 6: Loops.
8.1 Introduction - Levels of Control Flow: 1. Within expressions
Formal verification in SPIN
CSE 503 – Software Engineering
COMP60611 Fundamentals of Parallel and Distributed Systems
Advanced Programming Behnam Hatami Fall 2017.
Writing Functions( ) (Part 5)
Arrays, For loop While loop Do while loop
Looping and Repetition
Statement-Level Control Structures
Starting JavaProgramming
Outline Altering flow of control Boolean expressions
CS1100 Computational Engineering
Control Structures In Text: Chapter 8.
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
Sudipto Ghosh CS 406 Fall 99 November 16, 1999
COMP60621 Designing for Parallelism
An explicit state model checker
A Refinement Calculus for Promela
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Program Flow.
CSE 555 Protocol Engineering
Introduction to Programming
Review of Previous Lesson
The Spin Model Checker - Advanced Features
CSE 503 – Software Engineering
Looping and Repetition
Presentation transcript:

The Spin Model Checker - Advanced Features Moonzoo Kim CS Dept. KAIST

Review: 6 Types of Basic Statements Assignment: always executable Ex. x=3+x, x=run A() Print: always executable Ex. printf(“Process %d is created.\n”,_pid); Assertion: always executable Ex. assert( x + y == z) Expression: depends on its value Ex. x+3>0, 0, 1, 2 Ex. skip, true Send: depends on buffer status Ex. ch1!m is executable only if ch1 is not full Receive: depends on buffer status Ex. ch1?m is executable only if ch1 is not empty

Usages of If-statement x == 0 /* necessity of else */ /* in C, if(x==0) y=10; */ If :: x == 0 -> y = 10 :: else /* i.e., x != 0 */ fi /* find the max of x and y */ If :: x >= y -> m =x :: x <= y -> m = y fi else y = 10 /* Random assignment */ If :: n=0 :: n=1 :: n=2 fi /* dubious use of else with receive statement */ If :: ch?msg1 -> … :: ch?msg2 -> :: else -> … /* use empty(ch) instead*/ fi

Usages of Do-statement :: (x == y) -> break :: else -> skip od Loop: if :: (x == y) -> skip :: else -> goto Loop fi (x == y) else else x==y skip x==y x==y Note that break or goto is not a statement, but control-flow modifiers

More Usages of Various Operators More operators The standard C preprocessors can be used #define, #if, #ifdef, #include To overcome limitation of lack of functions #define add(a,b,c) c = a + b inline add(a,b,c) { c = a + b } Note that these two facilities still do not return a value Build multi-dimension array typedef array {byte y[3];} array x[2]; x[2].y[1] = 10; ( cond -> v1: v2) is used as (cond? v1: v2) in C

More Usages of Various Operators Predefined variable else: true iff no statement in the current process is executable timeout : 1 iff no statement in the model is executable _: a scratch variable _pid: an ID of current process _nr_pr: a total # of active processes _last: an ID of the process executed at previous step STDIN: a predefined channel used for simulation active proctype A() { chan STDIN;STDIN?x;printf(“x=%c\n”,x);} Remote reference name[pid]@label_name name: proctype name name[pid]:var_name

If any statement other than the guard blocks, atomicity is lost. atomic { g1; s1;s2;s3;s4} A sequence of statements g1;s1;s2;s3;s4 is executed without interleaving with other processes Executable if the guard statement (g1)is executable g1 can be other statement than expression If any statement other than the guard blocks, atomicity is lost. Atomicity can be regained when the statement becomes executable

Used to perform intermediate computations as a single indivisible step d_step d_step { g1; s1; s2;s3} g1,s1, s2, and s3 must be deterministic (non-determinism is not allowed) g1,s1,s2, and s3 must not be blocked Used to perform intermediate computations as a single indivisible step If non-determinisim is present inside of d_step, it is resolved in a fixed and deterministic way For instance, by always selecting the first true guard in every selection and repetition structure Ex. Sorting, or mathematical computation Goto-jumps into and out of d_step sequences are forbidden

atomic v.s. d_step Atomic and d_step are often used in order to reduce the size of a target model Both sequences are executable only when the guard statement is executable atomic: if any other statement blocks, atomicity is lost at that point; it can be regained once the statement becomes executable later d_step: it is an error if any statement other than the guard statement blocks Other differences: d_step: the entire sequence is executed as one single transition. atomic: the sequence is executed step-by-step, but without interleaving, it can make non-deterministic choices Caution: infinite loops inside atomic or d_step sequences are not detected the execution of this type of sequence models an indivisible step, which means that it cannot be infinite

Examples: atomic v.s. d_step B s1 t1 s2 s1 t2 t1 s1 t1 t1 s2 s1 t2 s2 t2 t2 s2 s1 t1 t1 s1;s2 atomic{s1;s2} s2 s1 t2 t2 s1;s2 t1 s2 s1 t1 s1;s2 d_step{s1;s2} t2 s2 t2

Rendezvous Comm. within atomic Sequences A sender performs a sending operation and a receiver performs a receiving operation at the same time for rendezvous communication If a sender has ch!msg in the atomic clause, after the rendezvous handshake, the sender loses its atomicity If a receiver has ch?msg in the atomic clause, after the rendezvous handshake, the receiver continues its atomicity Therefore, if both operations are in atomic clauses, atomicity moves from a sender to a receiver in a rendezvous handshake

unless {guard1; <stmts1>} unless {guard2; <stmts2>} To provide exception handling, or preemption capability The unless statement is executable if either the guard statement of the main sequence is executable, or the guard statement of the escape sequence is executable <stmts1> can be executed until guard2 becomes true. If then, <stmts2> becomes executable and <stmts1> is not executable anymore Unless clause (<stmts2>) preempts a main clause (<stmts1>) if guard2 is executable, i.e., main clause is stopped. Once unless clause becomes executable, no return to the main clause Resembles exception handling in languages like Java and ML

Embedded C Code Spin versions 4.0 and later support the inclusion of embedded C code into Promela model c_expr : a user defined boolean guard c_code : a user defined C statement c_decl : declares data types c_state: declares data objects c_track: to guide the verifier whether it should track the value of data object or not Embedded C codes are trusted blindly and copied through from the text of the model into the code of pan.c

Example 1 c_decl {typedef struct Coord {int x, y; } Coord;} c_state “Coord pt” “Global” /* goes inside state vector */ int z = 3; /* standard global declaration */ active proctype example() { c_code { now.pt.x = now.pt.y = 0;}; do :: c_expr {now.pt.x == now.pt.y } -> c_code {now.pt.y++} :: else -> break od; c_code { printf(“values %d:%d,%d,%d\n”, Pexample-> _pid, now.z, now.pt.x, now.pt.y); }; assert(false); }

Communication between Embedded C and Promela c_state primitive introduces a new global data object pt of type Coord into the state vector The object is initialized to zero according to the convention of Promela A global data object in a Promela model can be accessed through now.<var> in embedded C codes A local data object in a Promela model can be accessed through P<procname>-><var>

Example 2 c_decl {typedef struct Coord {int x, y; } Coord;} c_code {Coord pt;} /* Embedded declaration goes inside state vector */ int z = 3; /* standard global declaration */ active proctype example() { c_code { pt.x = pt.y = 0;}; do :: c_expr {pt.x == pt.y } -> c_code {pt.y++} :: else -> break od; c_code { printf(“values %d:%d,%d,%d\n”, Pexample-> _pid, now.z, pt.x, pt.y); }; assert(false); }

Weak Fairness v.s. Strong Fairness An !-run ¾ satisfies the strong fairness requirement if it contains infinitely many transitions from every component automaton that is enabled infinitely often in ¾ FAIRNESS running in NuSMV Weak fairness An !-run ¾ satisfies the weak fairness requirement if it contains infinitely many transitions from every component automaton that is enabled infinitely long in ¾ Automata A Automata A Automata B Automata B Automata C Automata C !-run ¾ !-run ¾’

Examples byte x; byte x; active proctype A() { do od;} active proctype B() { :: atomic{x==2 -> x=1;} /* [] <> (x==1) F: if weak fairness is applied */ byte x; active proctype A() { do :: x=2; od;} active proctype B() { :: atomic{x==2 -> x=1;} /* [] <> (x==1) F: no fairness T: weak fairness, thus T with strong fairness */ byte x; active proctype A() { do :: x=2; :: x=3; od;} /* [] <> x==2 F: no fairness F: weak fairness */