Part 3 Safety and liveness Safety vs liveness

  • Slides: 26
Download presentation
Part 3: Safety and liveness

Part 3: Safety and liveness

Safety vs. liveness Safety: something “bad” will never happen Liveness: something “good” will happen

Safety vs. liveness Safety: something “bad” will never happen Liveness: something “good” will happen (but we don’t know when)

Safety vs. liveness for sequential programs Safety: the program will never produce a wrong

Safety vs. liveness for sequential programs Safety: the program will never produce a wrong result (“partial correctness”) Liveness: the program will produce a result (“termination”)

Safety vs. liveness for sequential programs Safety: the program will never produce a wrong

Safety vs. liveness for sequential programs Safety: the program will never produce a wrong result (“partial correctness”) Liveness: the program will produce a result (“termination”)

Safety vs. liveness for state-transition graphs Safety: those properties whose violation always has a

Safety vs. liveness for state-transition graphs Safety: those properties whose violation always has a finite witness (“if something bad happens on an infinite run, then it happens already on some finite prefix”) Liveness: those properties whose violation never has a finite witness (“no matter what happens along a finite run, something good could still happen later”)

This is much easier. Safety: the properties that can be checked on finite executions

This is much easier. Safety: the properties that can be checked on finite executions Liveness: the properties that cannot be checked on finite executions (they need to be checked on infinite executions)

Example: Mutual exclusion It cannot happen that both processes are in their critical sections

Example: Mutual exclusion It cannot happen that both processes are in their critical sections simultaneously.

Example: Mutual exclusion It cannot happen that both processes are in their critical sections

Example: Mutual exclusion It cannot happen that both processes are in their critical sections simultaneously. Safety

Example: Bounded overtaking Whenever process P 1 wants to enter the critical section, then

Example: Bounded overtaking Whenever process P 1 wants to enter the critical section, then process P 2 gets to enter at most once before process P 1 gets to enter.

Example: Bounded overtaking Whenever process P 1 wants to enter the critical section, then

Example: Bounded overtaking Whenever process P 1 wants to enter the critical section, then process P 2 gets to enter at most once before process P 1 gets to enter. Safety

Example: Starvation freedom Whenever process P 1 wants to enter the critical section, provided

Example: Starvation freedom Whenever process P 1 wants to enter the critical section, provided process P 2 never stays in the critical section forever, P 1 gets to enter eventually.

Example: Starvation freedom Whenever process P 1 wants to enter the critical section, provided

Example: Starvation freedom Whenever process P 1 wants to enter the critical section, provided process P 2 never stays in the critical section forever, P 1 gets to enter eventually. Liveness

Example: Starvation freedom Whenever process P 1 wants to enter the critical section, provided

Example: Starvation freedom Whenever process P 1 wants to enter the critical section, provided process P 2 never stays in the critical section forever, P 1 gets to enter eventually. Liveness

LTL (Linear Temporal Logic) -safety & liveness -linear time [Pnueli 1977; Lichtenstein & Pnueli

LTL (Linear Temporal Logic) -safety & liveness -linear time [Pnueli 1977; Lichtenstein & Pnueli 1982]

LTL Syntax : : = a | | | | U

LTL Syntax : : = a | | | | U

LTL Model infinite trace t = t 0 t 1 t 2. . .

LTL Model infinite trace t = t 0 t 1 t 2. . . (sequence of observations)

q 1 a a, b b q 2 Run: q 3 q 1 q

q 1 a a, b b q 2 Run: q 3 q 1 q 3 q 1 q 2 Trace: a b a a, b

Language of deadlock-free state-transition graph K at state q : L(K, q) = set

Language of deadlock-free state-transition graph K at state q : L(K, q) = set of infinite traces of K starting at q (K, q) |= iff for all t L(K, q), t |= (K, q) |= iff exists t L(K, q), t |=

LTL Semantics t |= a iff a t 0 t |= iff t |=

LTL Semantics t |= a iff a t 0 t |= iff t |= and t |= iff not t |= iff t 1 t 2. . . |= t |= U iff exists n 0 s. t. 1. for all 0 i < n, ti ti+1. . . |= 2. tn tn+1. . . |= (K, q) |= iff (K, q) |=

Defined modalities X next U U until = true U F eventually = G

Defined modalities X next U U until = true U F eventually = G always W = ( U ) W waiting-for (weak-until)

Important properties Invariance a safety (pc 1=in pc 2=in) Sequencing a. Wb. Wc. Wd

Important properties Invariance a safety (pc 1=in pc 2=in) Sequencing a. Wb. Wc. Wd safety (pc 1=req (pc 2 in) W (pc 2=in) W (pc 2 in) W (pc 1=in)) Response (a b) (pc 1=req (pc 1=in)) liveness

Composed modalities a infinitely often a a almost always a

Composed modalities a infinitely often a a almost always a

Example: Starvation freedom Whenever process P 1 wants to enter the critical section, provided

Example: Starvation freedom Whenever process P 1 wants to enter the critical section, provided process P 2 never stays in the critical section forever, P 1 gets to enter eventually. (pc 2=in (pc 2=out)) (pc 1=req (pc 1=in))

State-transition graph Q set of states {q 1, q 2, q 3} A set

State-transition graph Q set of states {q 1, q 2, q 3} A set of atomic observations {a, b} Q Q transition relation q 1 q 2 [ ]: Q 2 A observation function [q 1] = {a}

(K, q) |= Tableau construction (Vardi-Wolper) (K’, q’, BA) where BA K’ Is there

(K, q) |= Tableau construction (Vardi-Wolper) (K’, q’, BA) where BA K’ Is there an infinite path starting from q’ that hits BA infinitely often? Is there a path from q’ to p BA such that p is a member of a strongly connnected component of K’?

dfs(s) { add s to dfs. Table for each successor t of s if

dfs(s) { add s to dfs. Table for each successor t of s if (t dfs. Table) then dfs(t) if (s BA) then { seed : = s; ndfs(s) } } ndfs(s) { add s to ndfs. Table for each successor t of s if (t ndfs. Table) then ndfs(t) else if (t = seed) then report error }