/ PSWLAB S PIN Search Optimization from “THE SPIN MODEL CHECKER” by G. Holzmann Presented by Hong,Shin 23 th Nov 2007 2016-01-121SPIN Search.

Slides:



Advertisements
Similar presentations
Automatic Verification Book: Chapter 6. How can we check the model? The model is a graph. The specification should refer the the graph representation.
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.
Problems and Their Classes
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Partial Order Reduction: Main Idea
Introduction to Computer Science 2 Lecture 7: Extended binary trees
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:
UPPAAL Introduction Chien-Liang Chen.
/ PSWLAB P ROMELA Semantics from “THE SPIN MODEL CHECKER” by G. J. Holzmann Presented by Hong,Shin 5 th Oct :021PROMELA Semantics.
תרגול 9 META LABELS. Basic types of claims State properties.
Data Structures Using C++ 2E
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree.
Efficient Reachability Analysis for Verification of Asynchronous Systems Nishant Sinha.
CS 267: Automated Verification Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking.
PSWLAB S PIN Search Algorithm from “THE SPIN MODEL CHECKER” by G Holzmann Presented by Hong,Shin 9 th Nov SPIN Search Algorithm.
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.
S. Ramesh Model-Checking Distributed Software S. Ramesh IIT Bombay.
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.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
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.
Hashing CS 3358 Data Structures.
1 Formal Methods in SE Qaisar Javaid Assistant Professor Lecture # 11.
1 Carnegie Mellon UniversitySPINFlavio Lerda SPIN An explicit state model checker.
CS 206 Introduction to Computer Science II 11 / 17 / 2008 Instructor: Michael Eckmann.
Hash Tables1 Part E Hash Tables  
Hashing COMP171 Fall Hashing 2 Hash table * Support the following operations n Find n Insert n Delete. (deletions may be unnecessary in some applications)
Temporal Logic Model- checking with SPIN COMP6004 Stéphane Lo Presti Part 3: The PROMELA Semantics.
1 Formal Engineering of Reliable Software LASER 2004 school Tutorial, Lecture1 Natasha Sharygina Carnegie Mellon University.
CS 290C: Formal Models for Web Software Lecture 4: Model Checking Navigation Models with Spin Instructor: Tevfik Bultan.
The Model Checker SPIN Written by Gerard J. Holzmann Presented by Chris Jensen.
CS 206 Introduction to Computer Science II 04 / 06 / 2009 Instructor: Michael Eckmann.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
1. 2 Problem RT&T is a large phone company, and they want to provide enhanced caller ID capability: –given a phone number, return the caller’s name –phone.
1 Carnegie Mellon UniversitySPINFlavio Lerda Bug Catching SPIN An explicit state model checker.
Regular Model Checking Ahmed Bouajjani,Benget Jonsson, Marcus Nillson and Tayssir Touili Moran Ben Tulila
Wishnu Prasetya Model Checking with SPIN A Bit More about SPIN.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture8.
CS212: DATA STRUCTURES Lecture 10:Hashing 1. Outline 2  Map Abstract Data type  Map Abstract Data type methods  What is hash  Hash tables  Bucket.
Correctness requirements. Basic Types of Claims Basic assertions End-state labels Progress-state labels Accept-state labels Never claims Trace assertions.
Scientific Computing By: Fatima Hallak To: Dr. Guy Tel-Zur.
Korea Advanced Institute of Science and Technology The Spin Model Checker - Advanced Features Moonzoo Kim CS Dept. KAIST.
Concurrency. A process is a program executing on a virtual computer Processor speed and multiplexing of shared resources are ignored Order of thread execution.
MODEL CHECKING WITH SPIN MODELING AND VERIFICATION WITH SPIN ANDREA ORLANDINI – ISTC (CNR) TexPoint fonts used in EMF. Read the TexPoint manual before.
1 HASHING Course teacher: Moona Kanwal. 2 Hashing Mathematical concept –To define any number as set of numbers in given interval –To cut down part of.
Can’t provide fast insertion/removal and fast lookup at the same time Vectors, Linked Lists, Stack, Queues, Deques 4 Data Structures - CSCI 102 Copyright.
1 CSEP590 – Model Checking and Automated Verification Lecture outline for August 6, 2003.
Temporal Logic Model-checking with SPIN
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
1 CSCD 326 Data Structures I Hashing. 2 Hashing Background Goal: provide a constant time complexity method of searching for stored data The best traditional.
Hashing COMP171. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
CS6045: Advanced Algorithms Data Structures. Hashing Tables Motivation: symbol tables –A compiler uses a symbol table to relate symbols to associated.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
/ PSWLAB Thread Modular Model Checking by Cormac Flanagan and Shaz Qadeer (published in Spin’03) Hong,Shin Thread Modular Model.
Today’s Agenda  Quiz 5 (end of the class)  Quick Review  Finish Search Algorithms Formal Methods in Software Engineering1.
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 6 Arrays.
Symbolic Model Checking of Software Nishant Sinha with Edmund Clarke, Flavio Lerda, Michael Theobald Carnegie Mellon University.
Complexity Relief Techniques for Model Checking METU, Aug SOFTWARE VERIFICATION WORKSHOP Hüsnü Yenigün Sabanci University Informatics Institute,
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Automatic Verification
The Spin Model Checker - Advanced Features
An explicit state model checker
The Spin Model Checker - Advanced Features
Presentation transcript:

/ PSWLAB S PIN Search Optimization from “THE SPIN MODEL CHECKER” by G. Holzmann Presented by Hong,Shin 23 th Nov SPIN Search Optimization

/ PSWLAB Introduction (1/1) In explicit model checking, verification problem is reduced to the reachability problem in a graph. The hard problem in explicit model checking to solve is finding effective ways to scale reachability checking algorithm to handle large to very large graph.  Approaches (1) Reduce the number of reachable states to check - Partial order reduction, Statement merging (2) Reduce the amount of memory that is needed to store visited states. - Loseless compression : Collapse compression, Minimized automaton - Lossy compression : Bitstate hashing, Hash compact SPIN Search Optimization2

/ PSWLAB Partial Order Reduction (1/9) SPIN Search Optimization L0L0 L1L1 L2L2 x=1g=g+2 L’ 0 L’ 1 L’ 2 y=1g=g*2 T1: T2: byte g = 0 ; active proctype T1() { byte x ; x = 1 ; g = g + 2 ; } active proctype T2() { byte y ; y = 1 ; g = g * 2 ; }

/ PSWLAB Partial Order Reduction (2/9) SPIN Search Optimization4 0,0,0 L 0, L’ 0 1,0,0 L 1,L’ 0 0,1,0 L 0,L’ 1 1,1,0 L 1,L’ 1 1,0,2 L 2,L’ 0 0,1,0 L 0,L’ 2 1,1,2 L 2,L’ 1 1,1,0 L 1,L’ 2 1,1,4 L 2,L’ 2 1,1,2 L 2,L’ 2 x=1 y=1 x=1 y=1 g=g*2 x=1 g=g+2g=g*2 y=1 g=g+2 g=g*2 x,y,g L, L’

/ PSWLAB Partial Order Reduction (3/9) For two statements a and b, if two interleavings of these statements from any state result different states or two interleavings are impossible, then a and b are dependent to each other. - Dependent statements pairs g=g*2 and g=g+2 because both touch same data object. x=1 and g=g+2 the order of statements are fixed. y=1 and g=g*2 the order of statements are fixed. - Independent statements pairs x=1 and y=1 x=1 and g=g*2 y=1 and g=g SPIN Search Optimization5

/ PSWLAB Partial Order Reduction (4/9) ¾ 1 ={ (0,0,0,L 0, L’ 0 ), (1,0,0,L 1, L’ 0 ), (1,0,2,L 2, L’ 0 ), (1,1,2,L 2,L’ 1 ), (1,1,4,L 2,L’ 2 ) } ¾ 2 ={ (0,0,0,L 0, L’ 0 ), (1,0,0,L 1, L’ 0 ), (1,1,0,L 1, L’ 1 ), (1,1,2,L 2,L’ 1 ), (1,1,4,L 2,L’ 2 ) } ¾ 3 ={ (0,0,0,L 0, L’ 0 ), (1,0,0,L 1, L’ 0 ), (1,1,0,L 1, L’ 1 ), (1,1,0,L 1,L’ 2 ), (1,1,2,L 2,L’ 2 ) } ¾ 4 ={ (0,0,0,L 0, L’ 0 ), (0,1,0,L 0, L’ 1 ), (0,1,0,L 0, L’ 2 ), (1,1,0,L 1,L’ 2 ), (1,1,2,L 2,L’ 2 ) } ¾ 5 ={ (0,0,0,L 0, L’ 0 ), (0,1,0,L 0, L’ 1 ), (1,1,0,L 1, L’ 1 ), (1,1,0,L 1,L’ 2 ), (1,1,2,L 2,L’ 2 ) } ¾ 6 ={ (0,0,0,L 0, L’ 0 ), (0,1,0,L 0, L’ 1 ), (1,1,0,L 1, L’ 1 ), (1,1,2,L 2,L’ 1 ), (1,1,4,L 2,L’ 2 ) } These runs can be classified into two groups according to the end state.  { ¾ 1, ¾ 2, ¾ 6 }, { ¾ 3, ¾ 4, ¾ 5 } SPIN Search Optimization6

/ PSWLAB Partial Order Reduction (5/9) ¼ 1 = { x=1 ; g=g+2 ; y=1 ; g=g*2;} ¼ 2 = { x=1 ; y=1 ; g=g+2 ; g=g*2;} ¼ 6 = { y=1 ; x=1 ; g=g+2 ; g=g*2;} ¼ 3 = { x=1 ; y=1 ; g=g*2 ; g=g+2;} ¼ 5 = { y=1 ; x=1 ; g=g*2 ; g=g+2;} ¼ 4 = { y=1 ; g=g*2 ; x=1 ; g=g+2;} SPIN Search Optimization7 Independent statements pairs x=1 and y=1 x=1 and g=g*2 y=1 and g=g+2 Within each class, each run can be obtained from the other runs by one or more permutations of adjacent independent transitions. The eventual outcome of a computation remains unchanged under such permutations. For verification, it therefore would suffice to consider just one run from each class.

/ PSWLAB Partial Order Reduction (6/9) SPIN Search Optimization8 0,0,0 L 0, L’ 0 1,0,0 L 1,L’ 0 0,1,0 L 0,L’ 1 1,1,0 L 1,L’ 1 1,0,2 L 2,L’ 0 0,1,0 L 0,L’ 2 1,1,2 L 2,L’ 1 1,1,0 L 1,L’ 2 1,1,4 L 2,L’ 2 1,1,2 L 2,L’ 2 x,y,g L, L’ x=1 y=1 x=1 y=1 g=g*2 x=1 g=g+2g=g*2 y=1 g=g+2 g=g*2

/ PSWLAB Partial Order Reduction (7/9) For previous example, it would be suffice to consider only runs ¾ 2 and ¾ 3. to accurately prove LTL formulae such as – Always( g = 0) – Eventually(2 · g ) SPIN Search Optimization9

/ PSWLAB Partial Order Reduction (8/9) ¼ 1 = { x=1 ; g=g+2 ; y=1 ; g=g*2;} ¼ 2 = { x=1 ; y=1 ; g=g+2 ; g=g*2;} ¼ 6 = { y=1 ; x=1 ; g=g+2 ; g=g*2;} ¼ 3 = { x=1 ; y=1 ; g=g*2 ; g=g+2;} ¼ 5 = { y=1 ; x=1 ; g=g*2 ; g=g+2;} ¼ 4 = { y=1 ; g=g*2 ; x=1 ; g=g+2;} SPIN Search Optimization10 Independent statements pairs x=1 and g=g*2 y=1 and g=g+2 What if “Always( y · x )” ? → The formula secretly introduces dependency between x=1 and y=1.

/ PSWLAB Partial Order Reduction (9/9) S PIN constructs global reachability graph on the fly. S PIN uses a static reduction method for partial order reduction. – The dependency relations are computed offline. Pre-evaluated dependency relations are used to decide which successors to search at each state exploration in S PIN SPIN Search Optimization11

/ PSWLAB Statement Merging (1/5) Merge sequences of transitions within a process into a single step to avoid the creation of unnecessary intermediate system states. Automatically add d_step constructs into a specification whenever a sequence of statements meets merging condition SPIN Search Optimization12

/ PSWLAB Statement Merging (2/5) Merging can be safely done if a sequence of statements in a process (1) accesses only local data. (2) does not have any guarded condition ( if or do statements). Statement merging is enabled in default. And this can be disabled by –o3 option SPIN Search Optimization13

/ PSWLAB Statement Merging (3/5) active proctype merging() { byte c ; if :: c = 0 ; :: c = 1 ; :: c = 2 ; fi ; do :: c c++ ; :: c > 0 -> c-- ; od ; } SPIN Search Optimization14 L0L0 L1L1 L2L2 L3L3 c=2 c=0 c=1 [c<2][c>0] c++ c--

/ PSWLAB Statement Merging (4/5) SPIN Search Optimization15 0,L 0 0,L 1 1,L 1 2,L 1 0,L 2 1,L 2 1,L 3 2,L 3 c=0c=1c=2 [c<2] [c>0] c++ c-- c, L

/ PSWLAB Statement Merging (5/5) SPIN Search Optimization16 L0L0 L1L1 c=2 c=0 c=1 [c<2] c++ [c>0] c-- 0,L 0 0,L 1 1,L 1 2,L 1 c=0c=1c=2 [c<2] c++ [c>0] c-- active proctype merging() { byte c ; if :: c = 0 ; :: c = 1 ; :: c = 2 ; fi ; do :: d_step {c c++ ; } :: d_step {c > 0 -> c-- ; } od ; }

/ PSWLAB Collapse Compression (1/3) Replicating a complete description of all local component of the system state in each global state that is stored is wasteful technique. Collapse compression mode tries to store smaller state components separately while assigning small unique index numbers to each one SPIN Search Optimization17

/ PSWLAB Collapse Compression (2/3) Def. System State (gvars, procs, chans, exclusive, handshake, timeout, else, stutter) gvars : a finite set of variables with global scope procs : a finite set of processes chans : a finite set of message channels exclusive, handshake are integers timeout, else, stutter are booleans Def. Process (pid, lvars, lstates, initial, curstate, trans) lvars : a finite set of local variables lstates : a finite set of integer initial : an element of lstates trans : a finite set of transitions on lstates. 22:18PROMELA Semantics18

/ PSWLAB Collapse Compression (3/3) Break down a global state into separate components – first component: the set of all global data objects such as global variables and all message channels. – one component for each active process: its control state and local states of the process SPIN Search Optimization19

/ PSWLAB Minimized Automaton (1/4) Use a minimized deterministic automaton for storage of statespace instead of conventional lookup table. If a state descriptor is accepted by the minimized deterministic automaton, then that state was visited. Lookup and update operation has a time complexity of O( S ) where S is the maximum length of a state descriptor. – Both minimized automaton and lookup table have same order time complexity for the operations, minimized automaton takes much more time for the operations. The user should provide an initial estimate of the maximum depth of the graph that is constructed for the minimized automaton representation using –DMA option for pan SPIN Search Optimization20

/ PSWLAB Minimized Automaton (2/4) SPIN Search Optimization21 Automaton Structure After Storing {000, 001, 101} 1 0

/ PSWLAB Minimized Automaton (3/4) SPIN Search Optimization22 Automaton Structure After Storing {000, 001, 101, 100} 1 0

/ PSWLAB Minimized Automaton (4/4) In verification of SM_ReadSector() model where SECT_PER_U is 4, NUM_LS_USED is 6, and MAX_VUN is 5. SPIN result with –DSAFETY –DCOLLAPSE options - memory: total actual memory usage - time: 0m17.509s SPIN result with –DSAFETY –DCOLLAPSE –DMA option - memory: total actual memory usage - time: 13m55.321s SPIN Search Optimization23

/ PSWLAB Bitstate Hashing (1/4) S PIN uses standard hash table as statespace storage. - Each slot in hash table has a sorted linked list of states of the same hash value SPIN Search Optimization24

/ PSWLAB Bitstate Hashing (2/4) R : the number of states stored in hash table H : the number of slots in hash table. when R > H, - The hash function computes the same value for different states(hash collision). - The average number of comparisons for a lookup or update operation is R/2H. when H >> R, - Each state can be stored in a different slot. - The lists stored in each slot will either be empty or contains one single states SPIN Search Optimization25

/ PSWLAB Bitstate Hashing (3/4) R : the number of reachable states M : the memory size that hash table can use S : the memory size that each state holds H : the number of slots in hash table In standard hash table, H = M/S and If R*S >> M, only (M/S*R) of system state can be covered. If M >> R, assume that hash table has M slots. → Then we can assume that there is either no state or one state in each slot. → Therefore only one bit is enough to represent each slot SPIN Search Optimization26

/ PSWLAB Bitstate Hashing (4/4) In bitstate hashing, it is possible to cover at most M states where M is the memory size for statespace in bits. Using a hash function hash ( state s) that maps a state descriptor to a value in range of 0.. M -1. For a state s, if slot ( hash ( s )) is true then state s was visited during the searching. But this method can not guarantee exhaustive search.  For a state s where k = hash ( s ), if slots ( k ) = true, it is impossible to distinguish whether s was visited or some other state s ’ where hash ( s ’)= k was visited.  But this method does not report false error SPIN Search Optimization27

/ PSWLAB Hash Compact (1/2) If M · R*S, then we can assign b M/R c bits for each reachable state. In hash compact, the hash function hash ( state s) returns values in range of 0..2 b M/R c -1 SPIN stores these hash values instead of state descriptor. The hash compact method can be enabled by compiling a verifier with –DHC4. For example, M=10 9 and R=10 7 In bitstate hashing, R/M=1/10 2 In hash compact, R/2 M/R = 10 7 /2 100 ~ 1/ SPIN Search Optimization28

/ PSWLAB Hash Compact (2/2) SPIN Search Optimization29 Measured Coverage of Double Bitstate Hashing(k=2) compared with Hash- Compact(hc), and Exhaustive Search Problem size: reachable states, state descriptor size 1376 bits

/ PSWLAB Further Study Partial Order Reduction – Static reduction technique used in S PIN SPIN Search Optimization30

/ PSWLAB References [1]“THE SPIN MODEL CHECKER” by G. J. Holzmann. [2]The Engineering of a Model Checker: the Gnu i-Protocol Case Study Revisited, G. J. Holzmann. [3]An Improvement in Formal Verification, G.J. Holzmann and Doron Peled SPIN Search Optimization31