Linear Time Properties

Slides:



Advertisements
Similar presentations
Model Checking Lecture 1.
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.
Modeling issues Book: chapters 4.12, 5.4, 8.4, 10.1.
Mutual Exclusion – SW & HW By Oded Regev. Outline: Short review on the Bakery algorithm Short review on the Bakery algorithm Black & White Algorithm Black.
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Partial Order Reduction: Main Idea
Models of Concurrency Manna, Pnueli.
Part 3: Safety and liveness
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.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Program correctness The State-transition model A global state S  s 0 x s 1 x … x s m {s k = local state of process k} S0  S1  S2  … Each state transition.
PROTOCOL VERIFICATION & PROTOCOL VALIDATION. Protocol Verification Communication Protocols should be checked for correctness, robustness and performance,
Temporal Logic and the NuSMV Model Checker CS 680 Formal Methods Jeremy Johnson.
Hybrid Systems Presented by: Arnab De Anand S. An Intuitive Introduction to Hybrid Systems Discrete program with an analog environment. What does it mean?
Multiprocessor Synchronization Algorithms ( ) Lecturer: Danny Hendler The Mutual Exclusion problem.
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.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Pushdown Systems Koushik Sen EECS, UC Berkeley Slide Source: Sanjit A. Seshia.
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.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Temporal Logic Model- checking with SPIN COMP6004 Stéphane Lo Presti Part 4: Specifications.
1 Wednesday, June 28, 2006 Command, n.: Statement presented by a human and accepted by a computer in such a manner as to make the human feel that he is.
Model Checking. Used in studying behaviors of reactive systems Typically involves three steps: Create a finite state model (FSM) of the system design.
Temporal Logic and Model Checking. Reactive Systems We often classify systems into two types: Transformational: functions from inputs available at the.
Review of the automata-theoretic approach to model-checking.
ESE601: Hybrid Systems Introduction to verification Spring 2006.
1 Formal Engineering of Reliable Software LASER 2004 school Tutorial, Lecture1 Natasha Sharygina Carnegie Mellon University.
Model Checking LTL over (discrete time) Controllable Linear System is Decidable P. Tabuada and G. J. Pappas Michael, Roozbeh Ph.D. Course November 2005.
Induction and recursion
1 Carnegie Mellon UniversitySPINFlavio Lerda Bug Catching SPIN An explicit state model checker.
Linear and Branching Time Safety, Liveness, and Fairness
Correctness requirements. Basic Types of Claims Basic assertions End-state labels Progress-state labels Accept-state labels Never claims Trace assertions.
CIS 842: Specification and Verification of Reactive Systems Lecture Specifications: Sequencing Properties Copyright , Matt Dwyer, John Hatcliff,
CS6133 Software Specification and Verification
Automatic Verification of Finite-State Concurrent Systems Using Temporal Logic Specifications 1.
Sept COMP60611 Fundamentals of Parallel and Distributed Systems Lecture 15 More Advanced Program Properties: Temporal logic and jSpin John Gurd,
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Program correctness The State-transition model The set of global states = so x s1 x … x sm {sk is the set of local states of process k} S0 ---> S1 --->
Program correctness The State-transition model A global states S  s 0 x s 1 x … x s m {s k = set of local states of process k} S0  S1  S2  Each state.
Hwajung Lee. The State-transition model The set of global states = s 0 x s 1 x … x s m {s k is the set of local states of process k} S0  S1  S2  Each.
Hwajung Lee. The State-transition model The set of global states = s 0 x s 1 x … x s m {s k is the set of local states of process k} S0  S1  S2  Each.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Lecture 12 Handling Deadlock – Prevention, avoidance and detection.
1 CSEP590 – Model Checking and Automated Verification Lecture outline for July 9, 2003.
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.
Program Correctness. The designer of a distributed system has the responsibility of certifying the correctness of the system before users start using.
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
Presented by: Belgi Amir Seminar in Distributed Algorithms Designing correct concurrent algorithms Spring 2013.
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
1 Partial Orderings Epp, section Introduction An equivalence relation is a relation that is reflexive, symmetric, and transitive A partial ordering.
Breadth-First Search (BFS)
Chapter 7: Deadlocks.
Basic concepts of Model Checking
Formal methods: Lecture
Semantically Equivalent Formulas
Depth-First Search.
Modeling Mutual Exclusion Algorithms
ITEC452 Distributed Computing Lecture 5 Program Correctness
Formal Methods in software development
Translating Linear Temporal Logic into Büchi Automata
Scalability in Model Checking
Introduction to verification
Formal Methods in software development
COMP60621 Designing for Parallelism
Presentation transcript:

Linear Time Properties Course: CS60030 FORMAL SYSTEMS Pallab Dasgupta Professor, Dept. of Computer Sc & Engg

Overview Lecture #2 Paths and traces Linear-time (LT) properties Trace equivalence and LT properties Invariants

Recall model checking we now consider: what are properties? requirements system Formalizing Modeling property specification system model Model Checking satisfied violated + counterexample Simulation location error we now consider: what are properties?

Recall executions A finite execution fragment δ of TS is an alternating sequence of states and actions ending with a state: An infinite execution fragment ρ of TS is an infinite, sequence , alternating of states and actions: An execution of TS is an initial, maximal execution fragment a maximal execution fragment is either finite ending in a terminal state, or infinite an execution fragment is initial if s0 ∈ I

State graph The state graph of TS, notation G(TS), is the digraph (V, E) with vertices V = S and edges E = {(s, s‘ ) ∈ S × S | s' ∈ Post(s)} ⇒ omit all state and transition labels in TS and ignore being initial Post∗(s) is the set of states reachable G(TS) from s The notations Pre∗(s) and Pre∗(C) have analogous meaning The set of reachable states: Reach(TS) = Post∗(I)

Path fragments A path fragment is an execution fragment without actions A finite path fragment 𝜋 TS is a state sequence: An infinite path fragment π of TS is an infinite state sequence: A path of TS is an initial, maximal path fragment a maximal path fragment is either finite ending in a terminal state, or infinite a path fragment is initial if s0 ∈ I Paths(s) is the set of maximal path fragments π with first(π) = s 𝜋 = s0 s1 . . . sn such that si+1 ∈ Post(si) for all 0 <= i < n where n >= 0 π =s0 s1 s2 . . . such that si+1 ∈ Post(si) for all i >= 0

Semaphore-based mutual exclusion PG1 : PG2 : noncrit1 noncrit2 y := y+1 wait1 y := y+1 wait2 y > 0 : y := y−1 y > 0 : y := y−1 crit1 crit2 y=0 means “lock is currently possessed”; y=1 means “lock is free”

Transition system TS(PG1 ||| PG2) (n1, n2, y=1) y := y+1 y := y+1 (n1, w2, y=1) (w1, n2, y=1) (c1, n2, y=0) (w1, w2, y=1) (n1, c2, y=0) y := y−1 (c1, w2, y=0) (w1, c2, y=0)

Example paths

Traces Actions are mainly used to model the (possibility of) interaction synchronous or asynchronous communication Here, focus on the states that are visited during executions the states themselves are not “observable”, but just their atomic propositions Consider sequences of the form L(s0) L(s1) L(s2) . . . just register the (set of) atomic propositions that are valid along the execution instead of execution s −−α→0 s −−α→1 s . . . 0 1 2 ⇒ this is called a trace For a transition system without terminal states: traces are infinite words over the alphabet 2AP, i.e., they are in (2AP) ω

Traces Let transition system TS = (S, Act, →, I, AP, L) without terminal states. – all maximal paths (and excutions) are infinite The trace of path fragment π = s0 s1 . . . is trace(π) = L(s0) L(s1) . . . – the trace of 𝝅 = s0 s1 . . . sn is trace( 𝝅 ) = L(s0) L(s1) . . . L(sn) The set of traces of a set Π of paths: trace(Π) = { trace(π) | π ∈ Π } Traces(s) = trace(Paths(s)) Traces(TS) = ⋃s∈I Traces(s) Tracesfin (s) = trace(Paths fin (s)) Tracesfin (TS) = ⋃s∈ITracesfin (s)

Example traces Let AP = { crit1, crit2 } Example path: π = (n1, n2, y = 1) → (w1, n2, y = 1) → (c1, n2, y = 0) → (n1, n2, y = 1) → (n1, w2, y = 1) → (n1, c2, y = 0) → . . . The trace of this path is the infinite word: trace(π) = ∅ ∅ { crit1 } ∅ ∅ { crit2 } ∅ ∅ { crit1 } ∅ ∅ { crit2 } . . . The trace of the finite path fragment: 𝝅 = (n1, n2, y = 1) → (w1, n2, y = 1) → (w1, w2, y = 1) → (w1, c2, y = 0) → (w1, n2, y = 1) → (c1, n2, y = 0) is: trace( 𝝅 ) = ∅ ∅ ∅ { crit2 } ∅ { crit1 }

Linear-time properties Linear-time properties specify the traces that a TS must exhibit LT-property specifies the admissible behaviour of system under consideration later, a logic will be introduced for specifying LT properties A linear-time property (LT property) over AP is a subset of (2AP )ω finite words are not needed, as it is assumed that there are no terminal states TS (over AP) satisfies LT property P (over AP): TS |= P if and only if Traces(TS) ⊆ P TS satisfies the LT property P if all its “observable” behaviors are admissible state s ∈ S satisfies P , notation s |= P , whenever Traces(s) ⊆ P

How to specify mutual exclusion? “Always at most one process is in its critical section” Let AP = { crit1, crit2 } – other atomic propositions are not of any relevance for this property Formalization as LT property Pmutex = set of infinite words A0 A1 A2 . . . with { crit1, crit2 } ⫋ Ai for all 0 ⪳ i Contained in Pmutex are e.g., the infinite words: ({ crit1 } { crit2 })ω and { crit1 } { crit1 } { crit1 } . . . and ∅ ∅ ∅ . . . but not { crit1 } ∅ { crit1, crit2 } . . . or ∅ { crit1 }, ∅ ∅ { crit1, crit2 }∅ . . . Does the semaphore-based algorithm satisfy Pmutex ?

Does the semaphore-based algorithm satisfy Pmutex ? ∅ (n1, n2, y=1) ∅ (w1, n2, y=1) ∅ (n1, w2, y=1) ∅ (w1, w2, y=1) (c1, n2, y=0) { crit1 } { crit2 } (n1, c2, y=0) { crit1 } (c1, w2, y=0) (w1, c2, y=0) { crit2 } Yes as there is no reachable state labeled with { crit1, crit2 }

How to specify starvation freedom? “A process that wants to enter the critical section is eventually able to do so‘” Let AP = { wait1, crit1, wait2, crit2 } Formalization as LT-property Pnostarve =set of infinite words A0 A1 A2 . . . such that: Does the semaphore-based algorithm satisfy Pnostarve ?

Does the semaphore-based algorithm satisfy Pnostarve ? ∅ (n1, n2, y=1) { wait1 } (w1, n2,y=1) { wait2 } (n1, w2,y=1) { wait1, wait2 } (w1, w2, y=1) (c1, n2, y=0) { crit1 } { crit2 } (n1, c2, y=0) { crit1, wait2 } (c1, w2, y=0) (w1, c2, y=0) { wait1, crit2 } No. Trace ∅ ({ wait2 } { wait1, wait2 } { crit1, wait2 } )ω ∈ Traces(TS), but ∉ Pnostarve

Mutual exclusion algorithm revisited (n1, n2, y=1) (w1, n2, y=1) (n1, w2, y=1) (c1, n2, y=0) (w1, w2, y=1) (n1, c2, y=0) (c1, w2, y=0) (w1, c2, y=0) this algorithm satisfies Pmutex

Refining mutual exclusion algorithm (n1, n2, y=1) (w1, n2, y=1) (n1, w2, y=1) (c1, n2, y=0) (w1, w2, y=1) (n1, c2, y=0) (c1, w2, y=0) (w1, c2, y=0) this variant algorithm with an omitted edge also satisfies Pmutex

Trace equivalence and LT properties For TS and TS′ be transition systems (over AP) without terminal states: Traces(TS) ⊆ Traces(TS′) if and only if for any LT property P : TS′ |= P implies TS|=P Traces(TS) = Traces(TS′) if and only if TS and TS′ satisfy the same LT properties

there is no LT-property that can distinguish between these machines Two beverage vending machines pay pay τ τ τ sprite select beer select1 sprite beer select2 τ AP = { pay , sprite, beer } there is no LT-property that can distinguish between these machines

Invariants Safety properties ≈ “nothing bad should happen” [Lamport 1977] Typical safety property: mutual exclusion property the bad thing (having > 1 process in the critical section) never occurs Another typical safety property is deadlock freedom ⇒ These properties are in fact invariants An invariant is an LT property that is given by a condition Φ for the states and requires that Φ holds for all reachable states e.g., for mutex property Φ ≡ ¬crit1 ∨ ¬crit2

Invariants An LT property Pinv over AP is an invariant if there is a propositional logic formula Φ over AP such that: Pinv = { A0A1A2 . . . ∈ ( 2AP)ω | ∀j >= 0. Aj |= Φ } – Φ is called an invariant condition of Pinv Note that Φ has to be fulfilled by all initial states and – satisfaction of Φ is invariant under all transitions in the reachable fragment of TS TS |= Pinv iff trace(π) ∈ Pinv for all paths π in TS iff iff L(s) |= Φ for all states s that belong to a path of TS L(s) |= Φ for all states s ∈ Reach(TS)

Checking an invariant Checking an invariant for the propositional formula Φ = check the validity of Φ in every reachable state ⇒ use a slight modification of standard graph traversal algorithms (DFS and BFS) provided the given transition system TS is finite Perform a forward depth-first search at least one state s is found with s |≠ Φ ⇒ the invariance of Φ is violated Alternative: backward search starts with all states where Φ does not hold calculates (by a DFS or BFS) the set ⋃s∈S,s| ≠ Φ Pre∗(s)

A naive invariant checking algorithm Input: finite transition system TS and propositional formula Φ Output: true if TS satisfies the invariant ”always Φ”, otherwise false set of state R := ∅; stack of state U := ε; bool b := true; for all s ∈ I do if s ∈/ R then visit(s) fi od return b (* the set of visited states *) (* the empty stack *) (* all states in R satisfy Φ *) (* perform a dfs for each unvisited initial state *)

error indication is state refuting Φ A naive invariant checking algorithm procedure visit (state s) push(s, U ); R := R ∪ { s }; repeat s′ := top(U ); if Post(s′) ⊆ R then pop(U ); b := b ∧ (s′ |= Φ); else let s′′ ∈ Post(s′) \ R push(s′′, U ); R := R ∪ { s′′ }; fi until (U = ε) endproc (* push s on the stack *) (* mark s as reachable *) (* check validity of Φ in s′ *) (* state s′′ is a new reachable state *) error indication is state refuting Φ initial path fragment s0 s1 s2 . . . sn with si |= Φ (i ≠ n) and sn |≠ Φ is more useful

Invariant checking by DFS Input: finite transition system TS and propositional formula Φ Output: ”yes” if TS |= ”always Φ”, otherwise ”no” plus a counterexample set of states R := ∅; stack of states U := ε; bool b := true; while (I \ R ≠ ∅ ∧ b) do let s ∈ I \ R; visit(s); od if b then return(”yes”) else return(”no”, reverse(U )) fi (* the set of reachable states *) (* the empty stack *) (* all states in R satisfy Φ *) (* choose an arbitrary initial state not in R *) (* perform a DFS for each unvisited initial state *) (* TS |= ”always Φ” *) (* counterexample arises from the stack content *)

Invariant checking by DFS procedure visit (state s) push(s, U ); R := R ∪ { s }; repeat s′ := top(U ); if Post(s′) ⊆ R then pop(U ); b := b ∧ (s′ |= Φ); else let s′′ ∈ Post(s′) \ R push(s′′, U ); R := R ∪ { s′′ }; fi until ((U = ε) ∨ ¬ b) endproc (* push s on the stack *) (* mark s as reachable *) (* check validity of Φ in s′ *) (* state s′′ is a new reachable state *)

The time complexity for invariant checking is O( N ∗ (1 + |Φ|) + M ) Under the assumption that s′ ∈ Post(s) can be encountered in time Θ(|Post(s)|) ⇒ this holds for a representation of Post(s) by adjacency lists The time complexity for invariant checking is O( N ∗ (1 + |Φ|) + M ) where N denotes the number of reachable states, and M =∑s∈S |Post(s)| the number of transitions in the reachable fragment of TS The adjacency lists are typically given implicitly e.g., by a syntactic description of the concurrent processes as program graphs Post(s) is obtained by the rules for the transition relation