A Refinement Calculus for Promela

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

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 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Partial Order Reduction: Main Idea
Formalization of Health Information Portability and Accountability Act (HIPAA) Simon Berring, Navya Rehani, Dina Thomas.
CS 290C: Formal Models for Web Software Lecture 3: Verification of Navigation Models with the Spin Model Checker Instructor: Tevfik Bultan.
The cardiac pacemaker – SystemJ versus Safety Critical Java Heejong Park, Avinash Malik, Muhammad Nadeem, and Zoran Salcic. University of Auckland, NZ.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Reduction, abstraction, and atomicity: How much can we prove about concurrent programs using them? Serdar Tasiran Koç University Istanbul, Turkey Tayfun.
1 1 Regression Verification for Multi-Threaded Programs Sagar Chaki, SEI-Pittsburgh Arie Gurfinkel, SEI-Pittsburgh Ofer Strichman, Technion-Haifa Originally.
A Rely-Guarantee-Based Simulation for Verifying Concurrent Program Transformations Hongjin Liang, Xinyu Feng & Ming Fu Univ. of Science and Technology.
UPPAAL Introduction Chien-Liang Chen.
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.
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.
The Spin Model Checker Promela Introduction Nguyen Tuan Duc Shogo Sawai.
Department of Software Engineering Faculty of Mathematics and Physics CHARLES UNIVERSITY IN PRAGUE Czech Republic Extracting Zing Models from C Source.
Ashish Kundu CS590F Purdue 02/12/07 Language-Based Information Flow Security Andrei Sabelfield, Andrew C. Myers Presentation: Ashish Kundu
Symmetry-Aware Predicate Abstraction for Shared-Variable Concurrent Programs Alastair Donaldson, Alexander Kaiser, Daniel Kroening, and Thomas Wahl Computer.
1 Spin Model Checker Samaneh Navabpour Electrical and Computer Engineering Department University of Waterloo SE-464 Summer 2011.
Atomicity in Multi-Threaded Programs Prachi Tiwari University of California, Santa Cruz CMPS 203 Programming Languages, Fall 2004.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
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.
Model Checking. Used in studying behaviors of reactive systems Typically involves three steps: Create a finite state model (FSM) of the system design.
1 Carnegie Mellon UniversitySPINFlavio Lerda SPIN An explicit state model checker.
Developing Verifiable Concurrent Software Tevfik Bultan Department of Computer Science University of California, Santa Barbara
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.
Cheng/Dillon-Software Engineering: Formal Methods Model Checking.
Static and Dynamic Analysis at JPL Klaus Havelund.
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.
MODEL CHECKING WITH SPIN MODELING AND VERIFICATION WITH SPIN ANDREA ORLANDINI – ISTC (CNR) TexPoint fonts used in EMF. Read the TexPoint manual before.
Radu Iosif Introduction to SPIN Radu Iosif
1 CSEP590 – Model Checking and Automated Verification Lecture outline for August 6, 2003.
Temporal Logic Model-checking with SPIN
The Spin Model Checker : Part I Moonzoo Kim KAIST.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
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.
1 Pass the Parcel /* Pass the parcel in Promela */ /* passing is not atomic */ /* communication is asynchronous */ /* Muffy Calder, November 2000 */ mtype.
Program Analysis and Verification
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
Sept COMP60611 Fundamentals of Parallel and Distributed Systems Lecture 9 Promela, jSpin and the problem of Interference John Gurd, Graham Riley.
Symbolic Model Checking of Software Nishant Sinha with Edmund Clarke, Flavio Lerda, Michael Theobald Carnegie Mellon University.
Verification of Data-Dependent Properties of MPI-Based Parallel Scientific Software Anastasia Mironova.
Formal methods: Lecture
Model and complexity Many measures Space complexity Time complexity
Formal verification in SPIN
CSE 503 – Software Engineering
Threads Cannot Be Implemented As a Library
Formally Specified Monitoring of Temporal Properties
Program Synthesis is a Game
Hongjin Liang, Xinyu Feng & Ming Fu
Concurrency Specification
Over-Approximating Boolean Programs with Unbounded Thread Creation
Generating Optimal Linear Temporal Logic Monitors by Coinduction
The Spin Model Checker - Advanced Features
Threads and Memory Models Hal Perkins Autumn 2009
Reachability testing for concurrent programs
Language-based Security
COMP60621 Designing for Parallelism
An explicit state model checker
Frédéric Gava Bulk-Synchronous Parallel ML Implementation of the
CSE 555 Protocol Engineering
The Spin Model Checker - Advanced Features
CSE 503 – Software Engineering
Presentation transcript:

A Refinement Calculus for Promela Asankhaya Sharma Department of Computer Science National University of Singapore ICECCS 2013

Formal Development Model Checking Informal Informal Software Requirements Formal Model Executable Code Model Checking Informal Informal Generate Executable Code from Formal Model of System Code Synthesis 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela The SPIN Model Checker Uses Promela as a modeling language Message passing with Channels Non-deterministic choice operator Express temporal properties in LTL Check for validity of properties Exhaustive search of state space for violation Formal Development in SPIN End to End Verification and Validation with SPIN [CoRR 2013] 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Promela Refinement Other modeling languages have well defined refinement schemes (Event-B, Z) Existing refinement (translation) systems for Promela do not preserve LTL properties Challenges for Refinement of Promela Lack of Formal Semantics Non-determinism Synchronous communication (Rendezvous channels) 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Key Contributions A restricted subset of Promela called Featherweight Promela (FP) A novel Dual Action Semantics for FP Refinement calculus from FP to a Core language Soundness of Calculus ensures that temporal properties (LTL) are preserved by refinement 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Outline Featherweight Promela (FP) Dual Action Semantics Refinement Calculus Implementation Case Studies Conclusions and Future Work 27/2/2019 A Refinement Calculus for Promela

Featherweight Promela (FP) Restrictions for easy formalization Minimal syntax Only asynchronous message passing with channels Existing Promela models can be written in FP 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Syntax of FP Process prog ::= p* p ::= t id (t x)* { e } e ::= x | t x ; e | x := e | e1 ; e2 | :: be -> e | if e fi | do e od | e1 ! e2 | e1 ? e2 | run p | atomic e t ::= int | chan | mtype | bit x ::= true | false | v | () where id is an identifier, be is a boolean expression and v is an integer value Expression Control Flow Channels 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Dual Action Semantics A small step operational semantics in which each step has two actions Local Action (sequential) Global Action (concurrent) Dual Action Semantics is useful for Isolating concurrency Supporting non-determinism 27/2/2019 A Refinement Calculus for Promela

Operational Semantics Small Step <e , s>  <e’, s’> Dual Actions <e , G , s>  <e’ , G’ , s’> Local <e , s>  <e’’ , s’> Global choose e’ from G’ G’ = G U {e’’} Non Deterministic Round Robin LIFO FIFO Scheduler 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Example proctype A() { f0 = 1; do :: f1 -> if :: turn != 0 -> f0 = 0; turn == 0 -> skip; f0 = 1; :: else -> skip; fi :: else -> break; od; t0_incrit = 1; t0_incrit = 0; turn = 1; f0 = 0; } proctype B() { f1 = 1; do :: f0 -> if :: turn != 1 -> f1 = 0; turn == 1 -> skip; :: else -> skip; fi :: else -> break; od; t1_incrit = 1; t1_incrit = 0; turn = 0; f1 = 0; } < () , G , si > * < () , {} , sf > si G = A B s1 G = A B s2 G = A B s3 G = A B s4 G = A B s5 G = A B … … … … … … … sf G = {} 27/2/2019 A Refinement Calculus for Promela

Semantics and Refinement Captures all possible process interleaving explicitly Semantics of SPIN correspond to the global action with Non-deterministic choice Refinement applies local transformation rules that preserve state invariants Process interleaving of the refined program are subset of the original FP model 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Data Refinement (8 rules) Translates data structures Control Refinement (8 rules) Translates control flow Handles non-deterministic choice Synchronization Refinement (3 rules) Translates channels Handles message passing 27/2/2019 A Refinement Calculus for Promela

Data Refinement skip bool byte mtype x id [const] = e typedef t {decl_list} mtype = {x1,x2, … xn} chan id = [n] of {t1,t2 …} 1 bit uchar int x id [const] = e struct t {decl_list} #define x1 n ; #define x2 n-1 … struct chan {t1 x1 ,t2 x2, …} ; chan id [n] Data Structure for Channels 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Control Refinement Channel Read and Write if :: e_list fi do :: e_list do x ! v1,v2, ... vn x ? v1,v2, ... vn id (args) {e_list} init { run id (args) …} e_list while(1) { e_list } for(int i =1 ; i <= n ; i++) { enqueue(x,vi) ; } for(int i =1 ; i <= n ; i++) { vi = dequeue(x) ; } void id (args) {e_list} void main() { thread id ; … create(id,args) ; … … join(id,args) ; …} Thread Create and Join 27/2/2019 A Refinement Calculus for Promela

Non-deterministic Choice Benign Race :: be1 -> e1 :: be2 -> e2 … id1() { lock(m); if (turn == 0 ) { e1; turn = 1; } unlock(m); } id2() { lock(m); if (turn == 0 ) { e2; turn = 1; } unlock(m); } … if(be1) create(id1,()); if(be2) create(id2,()); … e1 e2 27/2/2019 A Refinement Calculus for Promela

Synchronization Refinement atomic { e } xw ! v xw ? xr Atomic Step lock(m) ; e ; unlock(m) ; xw = v ; barrier(b) ; barrier(b) ; xr = xw ; Rendezvous Channels P P P1 P2 P1 P2 xw ! v xw ? xr e e xw= v xr = xw 27/2/2019 A Refinement Calculus for Promela

Features for Core Language Target language for refinement needs Concurrency primitive like threads Locks Barriers Supported by concurrency models for many existing languages like Java C# C with POSIX 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela More in the Paper Extension for Real Time Systems Based on RT Promela Generates code using Real Time POSIX Soundness Proofs using Dual Action Semantics Preservation of temporal properties (LTL) 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Implementation Syntax directed translation based on refinement rules SpinR Tool Written in Objective Caml Generates C code from Promela models Available at github.com/codelion/SpinR 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Experiments Evaluate the refinement calculus to generate C code from Existing set of Promela models from literature Principles of the Spin Model Checker [Book] A larger case study in formal development of a cardiac pacemaker Towards A Verified Cardiac Pacemaker [NUS TR 2010] 27/2/2019 A Refinement Calculus for Promela

Results Promela Model LoC LoC (C) States States (C) Spare Channels 86 119 106 14 8-Queens Problem 50 65 41525 39225 Rate Scheduler 87 93 27 Fisher’s Algorithm 60 74 494729 4337 Chandy Lamport’s Algorithm 168 214 14632233 13063946 Pacemaker Challenge 389 431 35684919 392716 Increase in Size Reduction in Behaviors 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Limitations Refinement does not handle Non functional properties (performance) Properties that cannot be expressed in LTL Reduction in behaviors does not ensure That the refined program is always the desired program Simplest (or best) implementation of the model 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Conclusions Formalized a core subset of Promela (FP) with Dual Action Semantics Refinement rules that preserve temporal properties (LTL) Future Work Dual Action Semantics for other languages Refinement guidance for desired behavior Code generation for more languages (C#, Java) 27/2/2019 A Refinement Calculus for Promela

A Refinement Calculus for Promela Thank You SpinR Tool github.com/codelion/SpinR Formal Development Methodology End to End Verification and Validation with SPIN [CoRR 2013] Cardiac Pacemaker Model Towards A Verified Cardiac Pacemaker [NUS TR 2010] 27/2/2019 A Refinement Calculus for Promela