CIS 725 Guarded Command Notation. Programming language style notation Guarded actions en(a)  a en(a): guard of the action boolean condition or boolean.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
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.
The SPIN System. What is SPIN? Model-checker. Based on automata theory. Allows LTL or automata specification Efficient (on-the-fly model checking, partial.
CS 101 Introductory Programming - Lecture 7: Loops In C & Good Coding Practices Presenter: Ankur Chattopadhyay.
Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
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.
Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
Formal verification in SPIN Karthikeyan Bhargavan, Davor Obradovic CIS573, Fall 1999.
/ 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.
Wishnu Prasetya Model Checking with SPIN Modeling and Verification with SPIN.
Failure detector The story goes back to the FLP’85 impossibility result about consensus in presence of crash failures. If crash can be detected, then consensus.
CSE 522 UPPAAL – A Model Checking Tool Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee
The Spin Model Checker Promela Introduction Nguyen Tuan Duc Shogo Sawai.
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.
Example: Infinite Split and Merge #define N 128 #define size 16 chan in = [size] of {short}; chan large = [size] of {short}; chan small = [size] of {short};
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.
PZ12A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ12A - Guarded commands Programming Language Design.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
© 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.
OOTI Workshop on Model Checking and Static Analysis Day 3 Dragan Bošnački Eindhoven University of Technology The Netherlands.
Temporal Logic Model- checking with SPIN COMP6004 Stéphane Lo Presti Part 5: Some PROMELA examples.
1 Carnegie Mellon UniversitySPINFlavio Lerda SPIN An explicit state model checker.
Automating Checking of Models Built Using a Graphically Based Formal Language Robert John Walters.
CS 290C: Formal Models for Web Software Lecture 4: Model Checking Navigation Models with Spin Instructor: Tevfik Bultan.
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
Wishnu Prasetya Model Checking with SPIN A Bit More about SPIN.
Representing distributed algorithms Why do we need these? Don’t we already know a lot about programming? Well, you need to capture the notions of atomicity,
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.
Today’s Agenda  Quiz 4 next Tuesday  Quick Review  Continue on SPIN Overview.
The Complexity of Distributed Algorithms. Common measures Space complexity How much space is needed per process to run an algorithm? (measured in terms.
CIS 842: Specification and Verification of Reactive Systems Lecture SPIN-Soldiers: Soldiers Case Study Copyright , Matt Dwyer, John Hatcliff,
Temporal Logic Model-checking with SPIN
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
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,
CIS 720 Asynchronous Message Passing. Asynchronous message passing Send is non-blocking Modeling a channel c: 1.Two variables: sent c, recv c 2.Queue.
Lecture 4 Introduction to Promela. Promela and Spin Promela - process meta language G. Holzmann, Bell Labs (Lucent) C-like language + concurrency dyamic.
Lesson thirteen Conditional Statement "if- else" ©
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
1 Pass the Parcel /* Pass the parcel in Promela */ /* passing is not atomic */ /* communication is asynchronous */ /* Muffy Calder, November 2000 */ mtype.
CIS 725 Lecture 2. Finite State Machine Model FSM = (A, S, T, s 0 ) A = set of actions S = set of states s 0 = initial states T = transition relation.
CIS 720 Asynchronous Message Passing. Dining philosophers problem P 0 : do hungry acquire left and right fork eat release forks sleep od.
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
Wishnu Prasetya Model Checking with SPIN Modeling and Verification with Promela.
CSE 555 Protocol Engineering Dr. Mohammed H. Sqalli Computer Engineering Department King Fahd University of Petroleum & Minerals Credits: Dr. Abdul Waheed.
November COMP60621 Designing for Parallelism Lecture 14 Deadlock + Channels in Promela John Gurd, Graham Riley Centre for Novel Computing School.
Model and complexity Many measures Space complexity Time complexity
Formal verification in SPIN
CSE 503 – Software Engineering
COMP60611 Fundamentals of Parallel and Distributed Systems
Incrementing ITP © Ron Poet Lecture 8.
Atomicity, Non-determinism, Fairness
The Spin Model Checker - Advanced Features
An explicit state model checker
A Refinement Calculus for Promela
CSE 555 Protocol Engineering
Asynchronous Message Passing
The Spin Model Checker - Advanced Features
Asynchronous Message Passing
Asynchronous Message Passing
CSE 503 – Software Engineering
Presentation transcript:

CIS 725 Guarded Command Notation

Programming language style notation Guarded actions en(a)  a en(a): guard of the action boolean condition or boolean condition + receive statement

Normal form init; do en(a 1 )  a 1 [] en(a 2 )  a 2 : od

The execution of each iteration proceeds as follows: - All guards are first evaluated. - Among all of the true guards, one of them is selected non-deterministically, and the corresponding action is executed. Weak Fairness: If a guard is true and remains true, then it is eventually selected for execution

Token-based system P1: hold1 = false; in_cs1 = false do ? token  hold1 = true [] hold1 /\ not in_cs1  !token; hold1 =false [] hold1  in_cs1 = true [] in_cs1  in_cs1 = false od

Request-based system P1: hold = false; in_cs = false; req_sent = false; req_recd = false do ? token  hold = true [] hold /\ not in_cs /\ req_recd  ! token; hold =false; req_recd = false [] hold /\ not in_cs  in_cs = true [] in_cs  in_cs = false [] not hold  !req; req_sent = true [] ? req  req_recd = true od

Example 2 Three processes A, B and C In each iteration, C sends message for a meeting. A and B non-deterministically send a “yes” or a “no” message If C receives yes from both, it sends a meet message to A and B If C receives a no from anyone, it sends an cancel message to A and B. After sending meet/cancel message, C can send a message for a meeting again.

Example 2 C: recdA = false; recdB = false; next_round = true; start = false; do [] next_round  A ! meeting; B ! meeting; next_round = false [] A ? x  recdA = true [] B ? y  recdB = true [] recdA /\ recdB  if x = yes and y = yes then A ! meet; B ! meet; start = true; else A ! cancel; B ! cancel; recdA = false; recdB = false; next_round = true; [] start  A ! meeting_done; B ! meeting_done; next_round = true; start = false od

Example 2 A: waiting = false do [] ! waiting; C ? meeting  C ! yes; waiting = true [] ! waiting; C ? meeting  C ! no; waiting = true [] waiting; C ? meet  start = true; [] waiting; C ? Cancel  waiting = false [] C ? meeting_done  waiting = false od

Example 2 - Modified A: waiting = false do [] ! waiting; C ? meeting  C ! yes; waiting = true [] ! waiting; C ? meeting  C ! no; waiting = false [] waiting; C ? meet  start = true; [] waiting; C ? Cancel  waiting = false [] C ? meeting_done  waiting = false od

Example 2: Modified C: recdA = false; recdB = false; next_round = true; start = true; do [] next_round  A ! meeting; B ! meeting; next_round = false [] A ? x  recdA = true; if x == no then A ! cancel; B ! cancel; next_round = true; recdA = false [] B ? y  recdB = true; if y == no then A ! cancel; B ! cancel; next_round = true; recdB = false [] recdA /\ recdB  if x = yes and y = yes then A ! meet; B ! meet; start = true; else A ! cancel; B ! cancel; recdA = false; recdB = false; next_round = true; [] start  A ! meeting_done; B ! meeting_done; next_round = true; start = false od

Example 2: Modified C: recdA = 0; recdB = 0; next_round = true; round = 0; start = true; do [] next_round  A ! meeting; B ! meeting; next_round = false [] recA = round /\ A ? x  recdA++; if x == no then B ! cancel; next_round = true; round++ [] recdA < round /\ A ? x  recdA++; [] recdB = round /\ B ? y  recdB++; if y == no then A ! cancel; next_round = true; round++ [] recdB < round /\ B ? x  recdB++; [] recdA /\ recdB  A ! meet; B ! meet; start = true; [] start  A ! meeting_done; B ! meeting_done; next_round = true; start = false; round++ od

Promela Protocol Meta Language Modeling language Verification of the model

Example 1 int state = 1 proctype A() { state == 1  state = state + 1 } proctype B() { state == 1  state = state – 1 } init { run A(); run B() }

Example 2 chan a,b = [3] of {int} proctype A() { int x; x = 1; a ! x; b ? x } proctype B() { int y; a ? y; b ! y + 1} init { run A(); B() }

do :: a > b; x = x + 1 :: a < b; x = x - 1 :: timeout  go to done od; done: y = y + 1

Data types int, bool, bytes, arrays Conditions: a == b, a < b, a <= b, ….. atomic statement atomic { a; b }

Control statements if :: a != b  x = x + 1 :: a == b  x = x - 1 fi if :: a > b; x = x + 1 :: a < b; x = x - 1 :: else x = l fi

do :: a > b; x = x + 1 :: a < b; x = x - 1 :: timeout  go to done od; done: y = y + 1

proctype P1() { int hold, incs; hold = 1; incs = 0; do :: (hold == 1) && incs==0  ch0!token; hold = 0 :: ch1 ? token  hold = 1 :: hold == 1& incs == 0  incs = 1 :: incs == 1  incs = 0 od } init { run P1(); run P2() }

#define token 1 chan ch[2] of {int, int}; proctype P1(int id, int holdvalue) { int myid, other; hold = holdvalue; incs = 0; myid = id; other = (myid + 1) % 2; do :: (hold == 1) && incs==0  ch[myid]!token; hold = 0 :: ch[other] ? Token  hold = 1 :: hold == 1& incs == 0  incs = 1 :: incs == 1  incs = 0 od }

init { run P(0,0), P(1,1) }