S. Ramesh Model-Checking Distributed Software S. Ramesh IIT Bombay.

Slides:



Advertisements
Similar presentations
1 Verification by Model Checking. 2 Part 1 : Motivation.
Advertisements

Model Checking Lecture 3. Specification Automata Syntax, given a set A of atomic observations: Sfinite set of states S 0 Sset of initial states S S transition.
Model Checking Lecture 2. Three important decisions when choosing system properties: 1automata vs. logic 2branching vs. linear time 3safety vs. liveness.
1 Reasoning with Promela Safety properties bad things do not happen can check by inspecting finite behaviours Liveness properties good things do eventually.
Model Checking and Testing combined
Automatic Verification Book: Chapter 6. How can we check the model? The model is a graph. The specification should refer the the graph representation.
Modeling issues Book: chapters 4.12, 5.4, 8.4, 10.1.
M ODEL CHECKING -Vasvi Kakkad University of Sydney.
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Partial Order Reduction: Main Idea
1 Model checking. 2 And now... the system How do we model a reactive system with an automaton ? It is convenient to model systems with Transition systems.
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:
An Introduction to the Model Verifier verds Wenhui Zhang September 15 th, 2010.
ECE Synthesis & Verification - L271 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Model Checking basics.
PROTOCOL VERIFICATION & PROTOCOL VALIDATION. Protocol Verification Communication Protocols should be checked for correctness, robustness and performance,
Timed Automata.
1 Partial Order Reduction. 2 Basic idea P1P1 P2P2 P3P3 a1a1 a2a2 a3a3 a1a1 a1a1 a2a2 a2a2 a2a2 a2a2 a3a3 a3a3 a3a3 a3a3 a1a1 a1a1 3 independent processes.
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.
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.
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.
1 Formal Methods in SE Qaisar Javaid Assistant Professor Lecture # 11.
CSE 555 Protocol Engineering Dr. Mohammed H. Sqalli Computer Engineering Department King Fahd University of Petroleum & Minerals Credits: Dr. Abdul Waheed.
Temporal Logic Model- checking with SPIN COMP6004 Stéphane Lo Presti Part 4: Specifications.
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.
Witness and Counterexample Li Tan Oct. 15, 2002.
Review of the automata-theoretic approach to model-checking.
Witness and Counterexample Li Tan Oct. 15, 2002.
Automata and Formal Lanugages Büchi Automata and Model Checking Ralf Möller based on slides by Chang-Beom Choi Provable Software Lab, KAIST.
1 Formal Engineering of Reliable Software LASER 2004 school Tutorial, Lecture1 Natasha Sharygina Carnegie Mellon University.
The Model Checker SPIN Written by Gerard J. Holzmann Presented by Chris Jensen.
LTL – model checking Jonas Kongslund Peter Mechlenborg Christian Plesner Kristian Støvring Sørensen.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
1 Carnegie Mellon UniversitySPINFlavio Lerda Bug Catching SPIN An explicit state model checker.
Model Checking and Related Techniques
Cheng/Dillon-Software Engineering: Formal Methods Model Checking.
Correctness requirements. Basic Types of Claims Basic assertions End-state labels Progress-state labels Accept-state labels Never claims Trace assertions.
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Model Checking Lecture 3 Tom Henzinger. Model-Checking Problem I |= S System modelSystem property.
Scientific Computing By: Fatima Hallak To: Dr. Guy Tel-Zur.
Automatic Verification of Finite-State Concurrent Systems Using Temporal Logic Specifications 1.
CIS 842: Specification and Verification of Reactive Systems Lecture Specifications: LTL Model Checking Copyright , Matt Dwyer, John Hatcliff,
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
1 CSEP590 – Model Checking and Automated Verification Lecture outline for August 6, 2003.
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 05/06 Universität Dortmund Validation - Formal verification -
Verification & Validation By: Amir Masoud Gharehbaghi
Modelling Reactive Systems 4 Professor Muffy Calder Dept. of Computing Science University of Glasgow
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
/ 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.
1 Temporal logic. 2 Prop. logic: model and reason about static situations. Example: Are there truth values that can be assigned to x,y simultaneously.
Model Checking Lecture 1. Model checking, narrowly interpreted: Decision procedures for checking if a given Kripke structure is a model for a given formula.
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.
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
Model Checking Lecture 1: Specification Tom Henzinger.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Model Checking Lecture 2. Model-Checking Problem I |= S System modelSystem property.
Model Checking Lecture 2 Tom Henzinger. Model-Checking Problem I |= S System modelSystem property.
Formal verification in SPIN
Automatic Verification
An explicit state model checker
Translating Linear Temporal Logic into Büchi Automata
Presentation transcript:

S. Ramesh Model-Checking Distributed Software S. Ramesh IIT Bombay

S. Ramesh Distributed Software Distributed systems consists of –autonomous and concurrent processes –processes have their own speeds (clocks) –Communicate for achieving system-wide goals –channel-based asynchronous communication Many applications are distributed –many nice features: fault-tolerance, modularity, problem structure, etc. –network applications and protocols –embedded process control systems Our focus here is on –finite state distributed systems –protocols and controllers –abstract designs of real infinite-state systems

S. Ramesh Alternating Bit Protocol active proctype Sender () { bit seq_out, seq_in; do :: to_rc!msg (seq_out)  to_sc?ack (seq_in); if :: seq_in == seq_out  seq_out = !seq_out :: else  bug = 1 fi od } active proctype Receiver () { bit seq_in; do :: to_rc?msg (seq_in)  to_sc!ack (seq_in) :: timeout  to_sc!ack (seq_in) od }

S. Ramesh Pictorial Description Sender Receiver

S. Ramesh Verification Distributed Systems are complex –concurrency, asynchrony –absence of global clocks –failures: *loss of messages, message reordering, message replication *message corruption (byzantine problem) *nodes can fail Various errors –deadlocks, race conditions –channel overflow, wrong order of messages –unsolicited messages, wrong messages

S. Ramesh Testing inadequate Case for formal verification is very strong –testing is totally inadequate –every run may be unique - goes through different sequence of states –Systems are non deterministic and different runs take different paths –Irreproducibility of bugs –verification that checks all runs essential

S. Ramesh Formal Verification Three-step process –Formal Specification –Formal Models –Rigorous Verification Procedure Our focus here on finite state systems –Fixed finite no. of processes –Finite states for each process –communication channels are bounded Verification of finite state systems –much easier than infinite state sequential programs –automatic verification possible –Model-checking

S. Ramesh Origin of protocol verification Protocol analysis of the 70s –Dead-lock analysis, –Absence of unsolicited messages –Liveness analysis Protocol verification in the current days –generalization of this –Verification of general properties –Includes the above analysis

S. Ramesh Formal Specification Explicit specification of systems requirements and environmental constraints Clear, unambiguous, consistent and complete specifications Specification independent of design –pre-design activity Right specification leads to right design State what rather than how

S. Ramesh Reactive Systems Specification in terms of External interfaces Distributed systems are often reactive systems –reacts to external stimuli –keeps ongoing interaction with the environment –termination is a bad behaviour

S. Ramesh Models of Distributed Systems Contrast with conventional systems which are transformational systems

S. Ramesh Illustration System Properties: Safety: Nothing bad happens S1: Every received message is sent S2: Received messages are in order S3: Ack. message sent only if the message is received Liveness: Eventually good happens P1: Every sent message is eventually received P2: Messages are received in order P3: Eventually ack. messages are sent and received Environment Constraints: (both safety and liveness) C1: No infinite loss of messages C2: No reordering of messages C3: No corruption of messages

S. Ramesh Temporal Properties Properties and Constraints are temporal in nature –Always, Eventually, Infinitely often They specify permissible behaviours Behaviours are infinite runs (reactive systems) We need finitistic representation of such infinite objects for precision Two Major formalisms: –Symbolic Logics: Linear and Branching Temporal Logics, Linear Temporal Logic (LTL) Computational Tree Logic (CTL) –Büchi Automata

S. Ramesh Temporal Logics Logics well-known for precise specification, amenable to symbolic manipulations used in a variety of contexts: –Propositional Logic / boolean algebra for combinational HW –Predicate logics for software –Higher order logics for language semantics. –Temporal logic for hardware and protocols. Qualitative temporal statements Examples: –If it is cloudy, eventually it will rain –It never rains here

S. Ramesh Linear Temporal Logic Syntax Atomic propositions are formulae If f, g are formulae then so are ¬f, f  g, f  g, f  g, f  g (state formulae) □ f – Henceforth f ◊ f – Eventually f f U g - f until g f W g - f unless g  f - next f state formulae - no temporal operators

S. Ramesh Semantics Formulae correspond to sets of infinite sequences of states Every atomic formula corresponds to a state of valuation of variables that satisfy the formula Let  = q 0, q 1, … be a sequence –In each q i, certain atomic propositions hold Semantic definition states precisely when a state sequence is in the set corresponding to a given formula The definition is inductive on the structure of the formula

S. Ramesh Notation Given a state sequence  and a formula   ╞ A stands for the fact that  is in the set corresponding to the formula A  ╞ A iff ( ,0)╞ A ( , j) ╞ A - defined inductively Base case: ( , j) ╞ f for any state formula f iff f holds in the state  [j]

S. Ramesh Semantics of Temporal Operators ( , j) ╞ Ο f iff ( , j + 1) ╞ f

S. Ramesh Semantics Contd. □( , j) ╞ □f iff  k  j, ( , k) ╞ f

S. Ramesh Semantics Contd. ( , j) ╞ ◊f iff  k , ( ,k) ╞ f

S. Ramesh Semantics Contd. ( , j) ╞ f U g iff  k  j : ( , k) ╞ g and  i s.t. j  i  k, ( , i) ╞ f

S. Ramesh Semantics Contd. ( , j) ╞ f W g iff ( , j) ╞ f U g or ( , j) ╞ □ f

S. Ramesh Examples p  □q If p holds in the beginning then q holds always □(p  ◊ q) Whenever p holds there is a future instant in which q holds □ ◊ p p holds infinitely often ◊ □ p p holds at all but finitely many positions

S. Ramesh Examples - Properties □¬(sent_0  sent_1) □ (sent_0  ◊ recd_0) □ (sent_0  ◊ ack_0) □ (sent_0  sent_0 W ack_0) □ (sent_0  sent_0 U recd_0)

S. Ramesh Büchi Automata An alternate formalism for specifying infinite objects Extension of Finite Automata to specify properties about infinite runs (sets of infinite runs) The simplest kind is Büchi automaton: Q - finite no. of states  - Edge labels q 0 - initial state   Q x  x  Q A  Q, Accepting (not final) states

S. Ramesh Behavior of Büchi Automata starts from the initial state, `runs forever' accepts infinite sequences over label alphabet s = l0, l1, l2,... is accepted by the automaton, provided there exists q 0, q 1,… s.t. –(q i, l i, q i+1 ) Є  for i = 0, 1, … –there is an accepting state that occurs infinitely often in s.

S. Ramesh Examples All sequences containing only 1. An infinite set of infinite sequences! But finite description

S. Ramesh Examples contd. All sequences that has at least one occurrence of 1

S. Ramesh Examples contd. Sequences containing all but finitely many occurrences of 1s

S. Ramesh Examples contd. All sequences containing infinitely many 1s

S. Ramesh Features of Büchi automata useful for specifying properties and constraints precise and unambiguous consistency can be checked (Emptiness of automata) has many properties useful for verification: – closed under union, intersection and complementation Close correspondence between LTL formulae and automata

S. Ramesh Formal Models Need for abstract and formal models –Precise and unambiguous –Consistent and Complete Formal Verification –applies to mathematical models –not to real objects –hence called design model verification –Faithful models essential *False negatives (spurious errors) *False positives (models pass - system fails) Simulation/Testing can not be dispensed with

S. Ramesh Programming Languages Various Proposals for Languages for DS –Occam, ADA, Java Sequential languages + OS/Network API for communication –Too detailed –no clear semantics

S. Ramesh Formal Modeling Languages Employed by verification tools and methods enable abstract and high level descriptions Real languages often ambiguous variation in HDL semantics Real languages require more details and effort Features Limited and High Level Data Types Non determinism (arising out of abstractions) Concurrency (to structure large systems) Communication (for internal and external interaction) Fairness (abstraction of real concurrency and schedulers)

S. Ramesh Modeling Languages Tool-specific –Promela (Spin), SPL (STeP), CSP, CCS (concurrency workbench) –Esterel, CFSM (embedded controllers) –Statecharts, UML (System level models) –CRSM and Communicating Statecharts (CFDVS projects) Formal models –Beside verification, useful as design languages and for code generation Underlying model: State-Transition System Models

S. Ramesh State Transition Systems A system of state machines Finite number of states Edges connecting a pair of states Edges are labeled with communication actions Edge labels indicate communication with other state machines A single state machine describe the behavior of a process The behavior of the entire system is modeled as concurrent composition of individual state machines asynchronous composition A single transition system that models the global behavior of the whole system

S. Ramesh Dining Philosophers

S. Ramesh Global Automaton (A 1, A 2, l 0, r 0 ) (B 1, A 2, l 1, r 0 ) (C 1, A 2, l 1, r 1 ) (D 1, A 2, l 0, r 1 ) (A 1, C 2, l 1, r 1 ) (A 1, B 2, l 0, r 1 ) (B 1, B 2, l 1, r 1 ) deadlock (A 1, D 2, l 1, r 0 )

S. Ramesh Semantics of Finite State Systems The above description is syntactic Association of behaviors –Branching Time semantics *the tree of states obtained by unwinding the state machine graph *possible choices are explicitly represented –Linear Time Semantics *the set of all possible `runs' in the system *the set of all infinite paths in the state machine

S. Ramesh Formal Verification Once we have formal specification and a system model, we are ready for verification Rigorously verifying that –the given properties are satisfied by the system model Properties given as temporal logic formulae Temporal logic specification specify properties of infinite runs System model as collection of communicating state machines Global state machine specifies a set of possible system runs

S. Ramesh Verification Verification involves checking that –every infinite run of the system model satisfies the temporal properties Specification includes environmental constraints –Consider only those runs that satisfy the constraints

S. Ramesh Illustration Which of the following hold for all the sequences generated by the above ◊p, ◊¬q, □p, □ (p  q) ◊(p  q), ◊ (p  q), □◊(p  q), ◊ □p, (p  ◊q).

S. Ramesh LTL Verification Method Two related Methods: –Tableau – based –Automata – based

S. Ramesh Automata based Method –Obtain a Büchi-automaton for the negation of the formula –Take the product of system model and the automaton –Check whether the resulting automaton accepts any string at all (Emptiness Check). –Existence of an accepting cycle in the product graph –If no cycle then original property holds. –A cycle gives a counterexample - an execution trace that violates the formula; useful for debugging

S. Ramesh Example The problem is to check whether the above automaton satisfies the formula □ p.

S. Ramesh Example 1.Construct first a B ü chi Automaton for ◊¬p, the negation of □ p.

S. Ramesh Example contd. 2. Construct the product of the two automata : No reachable accepting cycle It is a model of □ p.

S. Ramesh Another Example Check whether the following automaton satisfies □◊¬p

S. Ramesh The Example contd. Büchi Automata for : ¬( ◊ □ ¬p)

S. Ramesh Product Automaton –There is a cycle and hence the automaton is not a model –If state 4 is the only accepting state then the formula holds

S. Ramesh Complexity of model-checking Polynomial on model size and exponential on formula size Formulae are generally small! Model size exponential on block size (no. of storage elements). State Explosion Problem

S. Ramesh Spin Tool Home page: Bell Labs. (G. Holzmann) Verification of asynchronous protocol descriptions Modeling Language: PROMELA Specification Language: LTL Verification Approach: Automata Containment (Explicit Model Checking)

S. Ramesh PROMELA Protocol Modeling Language Concurrent and non deterministic processes Process communication: messages via buffered and non buffered channels

S. Ramesh An Example chan in = [size] of {short} chan out1 = [16] of {short} chan out2 = [16] of {short} proctype split() {short x do :: in?x  if :: (x >= 100)  out1!x :: (x <= 100)  out2!x fi od }

S. Ramesh An Example proctype merge() { short y do :: if :: out1?y :: out2?y fi; out!y od } init {run split(); run merge() }

S. Ramesh Spin Features Random Simulation, Deadlock detection and Formal verification A clever implementation of model checking algorithm –Nested depth-first search for cycles –Clever hashing techniques –Supertrace algorithm: bit state hashing –On the fly model-checking

S. Ramesh Nested Depth First Search Algorithm discussed above is naive –Full construction of Global Machine –Construction of Büchi Automaton –Computation of product graph –Detection of cycles Two depth first computation –The global machine construction –Cycle detection Both can be combined – Nested depth first computation –As you construct, look for state repetition

S. Ramesh On-the-fly Verification No need for construction of the entire state machine Nor the Büchi automaton, nor the product The search can be terminated once a cycle is found Spin algorithm interleaves the construction of product automaton with cycle detection Even the global automaton is also constructed in an interleaved manner

S. Ramesh Counter-Examples When a cycle found, the path from the initial state to the state at which the cycle is detected can be easily constructed Thanks to the depth first search –Just read the stack contents Counter examples Useful for debugging One of the attractive features of model-checking

S. Ramesh Bit-State Hashing Spin is an explicit model-checker Direct representation of states and state sets Full representation exhaust the memory soon Exhaustive analysis possible only for small designs Partial search or more abstract designs essential Partial search techniques: –Random selection of successors, search up to finite depth, etc Bit-State hashing –One bit per state – each state hashed to one bit in memory –If a bit set, the state assumed to be visited –Claimed to give very good coverage of state space

S. Ramesh Reduction Techniques Global machine has a lot of interleavings Make statements atomic wherever possible –Local actions should be enclosed within atomic Partial order reduction –Powerful technique –Identifies equivalent interleaved paths and generates and checks only representatives –done by controlled selection of successors

S. Ramesh Other techniques Implicit representation of states and sets using Binary Decision Diagrams (symbolic representation) Program Slicing –Automatic reduction of the program –Dependent upon the property being verified Compositional Verification –Decompose the program into parts –Verify the parts and combine the results

S. Ramesh Usage of the Tool Used in Bell Labs. Many telecommunication protocols verified A large user base Annual Conference on usage, extension and improvement of the tool Open source (in C)