You are on page 1of 100

Safety and Liveness Properties

Model Checking
Lecture #3: Linear-Time Properties
[Baier & Katoen, Chapter 3]

Joost-Pieter Katoen and Tim Quatmann


& ] :p Spel
Software Modeling and Verification Group

Model Checking Course, RWTH Aachen, SoSe 2022

Joost-Pieter Katoen and Tim Quatmann Lecture 1/45


Safety and Liveness Properties

Overview

1 Recapitulation: Traces

2 Linear-Time Properties

3 Safety Properties

4 Liveness Properties

5 Safety versus Liveness

Joost-Pieter Katoen and Tim Quatmann Lecture 2/45


Safety and Liveness Properties

Joost-Pieter Katoen and Tim Quatmann Lecture 3/45


Safety and Liveness Properties Recapitulation: Traces

Overview

1 Recapitulation: Traces

2 Linear-Time Properties

3 Safety Properties

4 Liveness Properties

5 Safety versus Liveness

Joost-Pieter Katoen and Tim Quatmann Lecture 4/45


Safety and Liveness Properties Recapitulation: Traces

Traces

Z Actions are mainly used to model the (possibility of) interaction


synchronous or asynchronous communication

Z Here, focus on the states that are visited during executions


the states themselves are not “observable”, but just their atomic
propositions

Z Traces are sequences of the form L(s0 ) L(s1 ) L(s2 ) . . .


record the (sets of) atomic propositions along an execution

Z For transition systems without terminal states1 :


traces are infinite words over the alphabet 2 , i.e., they are in 2 ⌥
AP AP Ê

1
This is an assumption commonly used throughout this lecture.
Joost-Pieter Katoen and Tim Quatmann Lecture 5/45
Safety and Liveness Properties Recapitulation: Traces

Traces
Definition: Traces
Let TS = (S, Act, , I, AP, L) be transition system without terminal states.
Z The trace of execution

fl = s0 –1
s1 –2
s2 –3
...

is the infinite word trace(fl) = L(s0 ) L(s1 ) L(s2 ) . . . over 2 ⌥ .


AP Ê

Prefixes of traces are finite traces.

Joost-Pieter Katoen and Tim Quatmann Lecture 6/45


Safety and Liveness Properties Recapitulation: Traces

Traces
Definition: Traces
Let TS = (S, Act, , I, AP, L) be transition system without terminal states.
Z The trace of execution

fl = s0 –1
s1 –2
s2 –3
...

is the infinite word trace(fl) = L(s0 ) L(s1 ) L(s2 ) . . . over 2 ⌥ .


AP Ê

Prefixes of traces are finite traces.


Z The traces of a set of executions (or paths) is defined by:

trace( ) = { trace(fi) ∂ fi " }.

Joost-Pieter Katoen and Tim Quatmann Lecture 6/45


Safety and Liveness Properties Recapitulation: Traces

Traces
Definition: Traces
Let TS = (S, Act, , I, AP, L) be transition system without terminal states.
Z The trace of execution

fl = s0 –1
s1 –2
s2 –3
...

is the infinite word trace(fl) = L(s0 ) L(s1 ) L(s2 ) . . . over 2 ⌥ .


AP Ê

Prefixes of traces are finite traces.


Z The traces of a set of executions (or paths) is defined by:

trace( ) = { trace(fi) ∂ fi " }.

Z The traces of state s are Traces(s) = trace(Paths(s)).


Z The traces of transition system TS: Traces(TS) = s"I Traces(s).

Joost-Pieter Katoen and Tim Quatmann Lecture 6/45


Safety and Liveness Properties Recapitulation: Traces

Example
Consider the mutex transition system. Let AP = { crit1 , crit2 }.
The trace of the path:
= Ön1 , n2 , y = 1ã Öw1 , n2 , y = 1ã Öc1 , n2 , y = 0ã
Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ — “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “—“ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ —““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “œ

L=o L=o L={ crit1 }
Ön1 , n2 , y = 1ã Ön1 , w2 , y = 1ã Ön1 , c2 , y = 0ã
Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ — “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “—“ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ —““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “œ
...
L=o L=o L={ crit2 }

Joost-Pieter Katoen and Tim Quatmann Lecture 7/45


Safety and Liveness Properties Recapitulation: Traces

Example
Consider the mutex transition system. Let AP = { crit1 , crit2 }.
The trace of the path:
= Ön1 , n2 , y = 1ã Öw1 , n2 , y = 1ã Öc1 , n2 , y = 0ã
Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ — “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “—“ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ —““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “œ

L=o L=o L={ crit1 }
Ön1 , n2 , y = 1ã Ön1 , w2 , y = 1ã Ön1 , c2 , y = 0ã
Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ — “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “—“ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ —““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “œ
...
L=o L=o L={ crit2 }

is:

trace(fi) = o o { crit1 } o o { crit2 } o o { crit1 } o o { crit2 } . . .

Joost-Pieter Katoen and Tim Quatmann Lecture 7/45


Safety and Liveness Properties Recapitulation: Traces

Example
Consider the mutex transition system. Let AP = { crit1 , crit2 }.
The trace of the path:
= Ön1 , n2 , y = 1ã Öw1 , n2 , y = 1ã Öc1 , n2 , y = 0ã
Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ — “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “—“ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ —““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “œ

L=o L=o L={ crit1 }
Ön1 , n2 , y = 1ã Ön1 , w2 , y = 1ã Ön1 , c2 , y = 0ã
Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ — “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “—“ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ —““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “œ
...
L=o L=o L={ crit2 }

is:

trace(fi) = o o { crit1 } o o { crit2 } o o { crit1 } o o { crit2 } . . .

Or expressed using Ê-regular expressions:

trace(fi) = o o { crit1 } o o { crit2 }⌥


Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 7/45


Safety and Liveness Properties Recapitulation: Traces

Regular Expressions
Z Let be an alphabet, i.e. countable set of symbols, with A "

Joost-Pieter Katoen and Tim Quatmann Lecture 8/45


Safety and Liveness Properties Recapitulation: Traces

Regular Expressions
Z Let be an alphabet, i.e. countable set of symbols, with A "

Z Regular expressions over have syntax:

E ⇥⇥= o ∂ ∂ A ∂ E+E ∂ E.E ∂ E


¨ ¨ ò
Á

Joost-Pieter Katoen and Tim Quatmann Lecture 8/45


Safety and Liveness Properties Recapitulation: Traces

Regular Expressions
Z Let be an alphabet, i.e. countable set of symbols, with A "

Z Regular expressions over have syntax:

E ⇥⇥= o ∂ ∂ A ∂ E+E ∂ E.E ∂ E


¨ ¨ ò
Á

ò
Z The semantics of regular expression E is a language L(E) N :

L(o) = o, L(Á) = { Á }, L(A) = { A }

L(E+E ) = L(E) < L(E ) L(E.E ) = L(E).L(E ) L(E ) = L(E)


¨ ¨ ¨ ¨ ò ò

Joost-Pieter Katoen and Tim Quatmann Lecture 8/45


Safety and Liveness Properties Recapitulation: Traces

Regular Expressions
Z Let be an alphabet, i.e. countable set of symbols, with A "

Z Regular expressions over have syntax:

E ⇥⇥= o ∂ ∂ A ∂ E+E ∂ E.E ∂ E


¨ ¨ ò
Á

ò
Z The semantics of regular expression E is a language L(E) N :

L(o) = o, L(Á) = { Á }, L(A) = { A }

L(E+E ) = L(E) < L(E ) L(E.E ) = L(E).L(E ) L(E ) = L(E)


¨ ¨ ¨ ¨ ò ò

Z Regular expressions denote languages of finite words

Joost-Pieter Katoen and Tim Quatmann Lecture 8/45


Safety and Liveness Properties Recapitulation: Traces

Ê-Regular Expressions: Syntax


Definition: Ê-regular expression
An Ê-regular expression G over the alphabet has the form:

G = E1 .F1 + . . . + En .Fn for n " N>0


Ê Ê

where Ei , Fi are regular expressions over with Á ä L(Fi ).

Joost-Pieter Katoen and Tim Quatmann Lecture 9/45


Safety and Liveness Properties Recapitulation: Traces

Ê-Regular Expressions: Syntax


Definition: Ê-regular expression
An Ê-regular expression G over the alphabet has the form:

G = E1 .F1 + . . . + En .Fn for n " N>0


Ê Ê

where Ei , Fi are regular expressions over with Á ä L(Fi ).

Z Ê-Regular expressions denote languages of infinite words

Joost-Pieter Katoen and Tim Quatmann Lecture 9/45


Safety and Liveness Properties Recapitulation: Traces

Ê-Regular Expressions: Syntax


Definition: Ê-regular expression
An Ê-regular expression G over the alphabet has the form:

G = E1 .F1 + . . . + En .Fn for n " N>0


Ê Ê

where Ei , Fi are regular expressions over with Á ä L(Fi ).

Z Ê-Regular expressions denote languages of infinite words

Z Examples over the alphabet = { A, B }:


Z language of all words with infinitely many As: (B .A)
ò Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 9/45


Safety and Liveness Properties Recapitulation: Traces

Ê-Regular Expressions: Syntax


Definition: Ê-regular expression
An Ê-regular expression G over the alphabet has the form:

G = E1 .F1 + . . . + En .Fn for n " N>0


Ê Ê

where Ei , Fi are regular expressions over with Á ä L(Fi ).

Z Ê-Regular expressions denote languages of infinite words

Z Examples over the alphabet = { A, B }:


Z language of all words with infinitely many As: (B .A)
ò Ê

Z language of all words with finitely many As: (A + B) .B


ò Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 9/45


Safety and Liveness Properties Recapitulation: Traces

Ê-Regular Expressions: Syntax


Definition: Ê-regular expression
An Ê-regular expression G over the alphabet has the form:

G = E1 .F1 + . . . + En .Fn for n " N>0


Ê Ê

where Ei , Fi are regular expressions over with Á ä L(Fi ).

Z Ê-Regular expressions denote languages of infinite words

Z Examples over the alphabet = { A, B }:


Z language of all words with infinitely many As: (B .A)
ò Ê

Z language of all words with finitely many As: (A + B) .B


ò Ê

Z the empty language o


Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 9/45


Safety and Liveness Properties Recapitulation: Traces

Ê-Regular Expressions: Semantics

Definition: semantics of Ê-regular expressions


The semantics of Ê-regular expression G = E1 .F1 + . . . + En .Fn is the
Ê Ê

language L(G) N defined by:


Ê

LÊ (G) = L(E1 ).L(F1 ) < . . . < L(En ).L(Fn ) .


Ê Ê

= { w1 w2 w3 . . . ∂ ºi ' 0. wi " L }.
ò
where for L N , we have L
Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 10/45


Safety and Liveness Properties Recapitulation: Traces

Ê-Regular Expressions: Semantics

Definition: semantics of Ê-regular expressions


The semantics of Ê-regular expression G = E1 .F1 + . . . + En .Fn is the
Ê Ê

language L(G) N defined by:


Ê

LÊ (G) = L(E1 ).L(F1 ) < . . . < L(En ).L(Fn ) .


Ê Ê

= { w1 w2 w3 . . . ∂ ºi ' 0. wi " L }.
ò
where for L N , we have L
Ê

The Ê-regular expression G1 and G2 are equivalent,


denoted G1 G2 , if LÊ (G1 ) = LÊ (G2 ).

Joost-Pieter Katoen and Tim Quatmann Lecture 10/45


Safety and Liveness Properties Linear-Time Properties

Overview

1 Recapitulation: Traces

2 Linear-Time Properties

3 Safety Properties

4 Liveness Properties

5 Safety versus Liveness

Joost-Pieter Katoen and Tim Quatmann Lecture 11/45


Safety and Liveness Properties Linear-Time Properties

Linear-Time Properties
Definition: Linear-Time Property
A linear-time property (LT property) over AP is a subset of 2 ⌥ .
AP Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 12/45


Safety and Liveness Properties Linear-Time Properties

Linear-Time Properties
Definition: Linear-Time Property
A linear-time property (LT property) over AP is a subset of 2 ⌥ .
AP Ê

Z Linear-time properties specify desirable traces of a transition system


Z They are infinite words A0 A1 A2 . . . with Ai N AP, i.e. traces
Z No finite words, as TS is assumed to have no terminal states
Z TS satisfies property P if all its “observable” behaviours are admitted
by P

Joost-Pieter Katoen and Tim Quatmann Lecture 12/45


Safety and Liveness Properties Linear-Time Properties

Linear-Time Properties
Definition: Linear-Time Property
A linear-time property (LT property) over AP is a subset of 2 ⌥ .
AP Ê

Z Linear-time properties specify desirable traces of a transition system


Z They are infinite words A0 A1 A2 . . . with Ai N AP, i.e. traces
Z No finite words, as TS is assumed to have no terminal states
Z TS satisfies property P if all its “observable” behaviours are admitted
by P

Satisfaction relation for LT properties


Transition system TS (over AP) satisfies LT property P (over AP):

TS Ï P if and only if Traces(TS) N P.

Joost-Pieter Katoen and Tim Quatmann Lecture 12/45


Safety and Liveness Properties Linear-Time Properties

Mutual Exclusion as LT Property


“Always at most one thread is in its critical section”

Joost-Pieter Katoen and Tim Quatmann Lecture 13/45


Safety and Liveness Properties Linear-Time Properties

Mutual Exclusion as LT Property

“Always at most one thread is in its critical section”

Z Let AP = { crit1 , crit2 }


other atomic propositions are not of any relevance for this property

Joost-Pieter Katoen and Tim Quatmann Lecture 13/45


Safety and Liveness Properties Linear-Time Properties

Mutual Exclusion as LT Property

“Always at most one thread is in its critical section”

Z Let AP = { crit1 , crit2 }


other atomic propositions are not of any relevance for this property

Z Formalization as LT property
Pmutex = set of infinite words A0 A1 A2 . . .
with { crit1 , crit2 } N
/ Ai for all 0 & i

Joost-Pieter Katoen and Tim Quatmann Lecture 13/45


Safety and Liveness Properties Linear-Time Properties

Mutual Exclusion as LT Property

“Always at most one thread is in its critical section”

Z Let AP = { crit1 , crit2 }


other atomic propositions are not of any relevance for this property

Z Formalization as LT property
Pmutex = set of infinite words A0 A1 A2 . . .
with { crit1 , crit2 } N
/ Ai for all 0 & i

Z Contained in Pmutex are e.g., the infinite words:


Z ({ crit1 } { crit2 })Ê and ({ crit1 })Ê and oÊ

Joost-Pieter Katoen and Tim Quatmann Lecture 13/45


Safety and Liveness Properties Linear-Time Properties

Mutual Exclusion as LT Property

“Always at most one thread is in its critical section”

Z Let AP = { crit1 , crit2 }


other atomic propositions are not of any relevance for this property

Z Formalization as LT property
Pmutex = set of infinite words A0 A1 A2 . . .
with { crit1 , crit2 } N
/ Ai for all 0 & i

Z Contained in Pmutex are e.g., the infinite words:


Z ({ crit1 } { crit2 })Ê and ({ crit1 })Ê and oÊ

Z but not { crit1 } o { crit1 , crit2 } . . . or o { crit1 }, (o o { crit1 , crit2 })Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 13/45


Safety and Liveness Properties Linear-Time Properties

Mutual Exclusion by Semaphores

Yes, the semaphore-based algorithm satisfies Pmutex .


Joost-Pieter Katoen and Tim Quatmann Lecture 14/45
Safety and Liveness Properties Linear-Time Properties

Starvation Freedom as LT Property

“A thread that wants to enter the critical section is eventually able


to do so‘”

Joost-Pieter Katoen and Tim Quatmann Lecture 15/45


Safety and Liveness Properties Linear-Time Properties

Starvation Freedom as LT Property

“A thread that wants to enter the critical section is eventually able


to do so‘”
Z Let AP = { wait1 , crit1 , wait2 , crit2 }

Z Formalization as LT-property

Pnostarve = set of infinite words A0 A1 A2 . . . such that:

⌅ Ω j. waiti " Aj ⌦ ⌅ Ω j. criti " Aj ⌦ for each i " { 1, 2 }


ô ô

where: ⌅ Ω j. waiti " Aj ⌦ abbreviates (ºk ' 0. Ωj > k. waiti " Aj )


ô

Joost-Pieter Katoen and Tim Quatmann Lecture 15/45


Safety and Liveness Properties Linear-Time Properties

Starvation Freedom by Semaphores

Joost-Pieter Katoen and Tim Quatmann Lecture 16/45


Safety and Liveness Properties Linear-Time Properties

Starvation Freedom by Semaphores

Does the semaphore-based algorithm satisfy Pnostarve ?

Joost-Pieter Katoen and Tim Quatmann Lecture 16/45


Safety and Liveness Properties Linear-Time Properties

Starvation Freedom by Semaphores

Does the semaphore-based algorithm satisfy Pnostarve ?


No. Trace o ({ wait2 } { wait1 , wait2 } { crit1 , wait2 } ) " Traces(TS), but "
/ Pnostarve
Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 16/45


Safety and Liveness Properties Linear-Time Properties

Trace Inclusion and LT Properties

¨
For TS and TS be transition systems (over AP) without terminal states:

Traces(TS) N Traces(TS )
¨

if and only if
¨
for any LT property P: TS Ï P implies TS Ï P.

Joost-Pieter Katoen and Tim Quatmann Lecture 17/45


Safety and Liveness Properties Linear-Time Properties

Trace Inclusion and LT Properties

¨
For TS and TS be transition systems (over AP) without terminal states:

Traces(TS) N Traces(TS )
¨

if and only if
¨
for any LT property P: TS Ï P implies TS Ï P.

“ ”:

Joost-Pieter Katoen and Tim Quatmann Lecture 17/45


Safety and Liveness Properties Linear-Time Properties

Trace Inclusion and LT Properties

¨
For TS and TS be transition systems (over AP) without terminal states:

Traces(TS) N Traces(TS )
¨

if and only if
¨
for any LT property P: TS Ï P implies TS Ï P.

“⌦”:

Joost-Pieter Katoen and Tim Quatmann Lecture 17/45


Safety and Liveness Properties Linear-Time Properties

Trace Inclusion and LT Properties

¨
For TS and TS be transition systems (over AP) without terminal states:

Traces(TS) N Traces(TS )
¨

if and only if
¨
for any LT property P: TS Ï P implies TS Ï P.

Corollary
Traces(TS) = Traces(TS ) iff TS and TS satisfy the same LT properties.
¨ ¨

Joost-Pieter Katoen and Tim Quatmann Lecture 17/45


Safety and Liveness Properties Safety Properties

Overview

1 Recapitulation: Traces

2 Linear-Time Properties

3 Safety Properties

4 Liveness Properties

5 Safety versus Liveness

Joost-Pieter Katoen and Tim Quatmann Lecture 18/45


Safety and Liveness Properties Safety Properties

Invariants
Z LT property Einv over AP is an invariant if it has the form:

Einv = t A0 A1 A2 . . . " 2 ⌥ ∂ ºj ' 0. Aj Ï z


AP Ê

where (invariant condition) is a propositional logic formula over AP

Joost-Pieter Katoen and Tim Quatmann Lecture 19/45


Safety and Liveness Properties Safety Properties

Invariants
Z LT property Einv over AP is an invariant if it has the form:

Einv = t A0 A1 A2 . . . " 2 ⌥ ∂ ºj ' 0. Aj Ï z


AP Ê

where (invariant condition) is a propositional logic formula over AP

Z Note that

TS Ï Einv iff trace(fi) " Einv for all paths fi in TS


iff L(s) Ï for all states s that belong to a path of TS
iff L(s) Ï for all states s " Reach(TS)

Joost-Pieter Katoen and Tim Quatmann Lecture 19/45


Safety and Liveness Properties Safety Properties

Invariants
Z LT property Einv over AP is an invariant if it has the form:

Einv = t A0 A1 A2 . . . " 2 ⌥ ∂ ºj ' 0. Aj Ï z


AP Ê

where (invariant condition) is a propositional logic formula over AP

Z Note that

TS Ï Einv iff trace(fi) " Einv for all paths fi in TS


iff L(s) Ï for all states s that belong to a path of TS
iff L(s) Ï for all states s " Reach(TS)

Z all initial states fulfil and all transitions in the reachable fragment
of TS preserve

Joost-Pieter Katoen and Tim Quatmann Lecture 19/45


Safety and Liveness Properties Safety Properties

Example Invariants

Joost-Pieter Katoen and Tim Quatmann Lecture 20/45


Safety and Liveness Properties Safety Properties

Safety Properties
Z Safety properties may impose requirements on finite path fragments
Z and cannot be verified by considering the reachable states individually

Joost-Pieter Katoen and Tim Quatmann Lecture 21/45


Safety and Liveness Properties Safety Properties

Safety Properties
Z Safety properties may impose requirements on finite path fragments
Z and cannot be verified by considering the reachable states individually

Z Every invariant is a safety property, but not the reverse

Joost-Pieter Katoen and Tim Quatmann Lecture 21/45


Safety and Liveness Properties Safety Properties

Safety Properties
Z Safety properties may impose requirements on finite path fragments
Z and cannot be verified by considering the reachable states individually

Z Every invariant is a safety property, but not the reverse

Z A safety property which is not an invariant:


Z consider a cash dispenser, aka: automated teller machine (ATM)
Z property “money can only be withdrawn once a correct PIN has been
provided”
not an invariant, since it is not a state property

Joost-Pieter Katoen and Tim Quatmann Lecture 21/45


Safety and Liveness Properties Safety Properties

Safety Properties
Z Safety properties may impose requirements on finite path fragments
Z and cannot be verified by considering the reachable states individually

Z Every invariant is a safety property, but not the reverse

Z A safety property which is not an invariant:


Z consider a cash dispenser, aka: automated teller machine (ATM)
Z property “money can only be withdrawn once a correct PIN has been
provided”
not an invariant, since it is not a state property

Z But a safety property:


Z any infinite run violating the property has a finite prefix that is “bad”
Z i.e., in which money is withdrawn without issuing a PIN before

Joost-Pieter Katoen and Tim Quatmann Lecture 21/45


Safety and Liveness Properties Safety Properties

Safety Properties

Definition: Safety Property


LT property Esafe over AP is a safety property if for all ‡ " 2 ⌥ \ Esafe :
AP Ê

Esafe = t‡ " 2 ⌥ ∂ ‡r is a prefix of ‡ z = o.


¨ AP Ê ¨

for some prefix ‡r of ‡.

Joost-Pieter Katoen and Tim Quatmann Lecture 22/45


Safety and Liveness Properties Safety Properties

Safety Properties

Definition: Safety Property


LT property Esafe over AP is a safety property if for all ‡ " 2 ⌥ \ Esafe :
AP Ê

Esafe = t‡ " 2 ⌥ ∂ ‡r is a prefix of ‡ z = o.


¨ AP Ê ¨

for some prefix ‡r of ‡.

Z Path fragment ‡r is called a bad prefix of Esafe

Z Let BadPref(Esafe ) denote the set of bad prefixes of Esafe

Z ‡r " Esafe is minimal if no proper prefix of it is in BadPref(Esafe )

Joost-Pieter Katoen and Tim Quatmann Lecture 22/45


Safety and Liveness Properties Safety Properties

Examples

Joost-Pieter Katoen and Tim Quatmann Lecture 23/45


Safety and Liveness Properties Safety Properties

Safety Properties and Finite Traces

For transition system TS without terminal states


and safety property Esafe :

TS Ï Esafe if and only if Tracesfin (TS) = BadPref(Esafe ) = o.

Joost-Pieter Katoen and Tim Quatmann Lecture 24/45


Safety and Liveness Properties Safety Properties

Finite Prefixes
Z For trace ‡ " 2AP ⌥Ê , let pref(‡) be the set of finite prefixes of ‡:

pref(‡) = { ‡r " 2 ⌥ ∂ ‡r is a finite prefix of ‡ }


AP ò

Z if ‡ = A0 A1 . . . then pref(‡) = sÁ, A0 , A0 A1 , A0 A1 A2 , . . . y

Joost-Pieter Katoen and Tim Quatmann Lecture 25/45


Safety and Liveness Properties Safety Properties

Finite Prefixes
Z For trace ‡ " 2AP ⌥Ê , let pref(‡) be the set of finite prefixes of ‡:

pref(‡) = { ‡r " 2 ⌥ ∂ ‡r is a finite prefix of ‡ }


AP ò

Z if ‡ = A0 A1 . . . then pref(‡) = sÁ, A0 , A0 A1 , A0 A1 A2 , . . . y

Z For property P this is lifted as follows:

pref(P) = ⌫ pref(‡)
‡"P

Joost-Pieter Katoen and Tim Quatmann Lecture 25/45


Safety and Liveness Properties Safety Properties

Finite Prefixes
Z For trace ‡ " 2AP ⌥Ê , let pref(‡) be the set of finite prefixes of ‡:

pref(‡) = { ‡r " 2 ⌥ ∂ ‡r is a finite prefix of ‡ }


AP ò

Z if ‡ = A0 A1 . . . then pref(‡) = sÁ, A0 , A0 A1 , A0 A1 A2 , . . . y

Z For property P this is lifted as follows:

pref(P) = ⌫ pref(‡)
‡"P

Z For transition system TS we have:

Tracesfin (TS) = pref(Traces(TS))

Joost-Pieter Katoen and Tim Quatmann Lecture 25/45


Safety and Liveness Properties Safety Properties

Closure

Definition: closure of a property


The closure of LT property P is defined as:

cl(P) = s‡ " 2 ⌥ ∂ every prefix of ‡ is a prefix of Py


AP Ê

Z cl(P) contains the set of infinite traces whose finite prefixes are also
prefixes of P, or equivalently

Z infinite traces in the closure of P do not have a prefix that is not a


prefix of P

Joost-Pieter Katoen and Tim Quatmann Lecture 26/45


Safety and Liveness Properties Safety Properties

Safety Properties and Closure

For any LT property P over AP:


P is a safety property if and only if cl(P) = P.

Joost-Pieter Katoen and Tim Quatmann Lecture 27/45


Safety and Liveness Properties Safety Properties

Safety Properties and Closure

For any LT property P over AP:


P is a safety property if and only if cl(P) = P.

“ ”:

Joost-Pieter Katoen and Tim Quatmann Lecture 27/45


Safety and Liveness Properties Safety Properties

Safety Properties and Closure

For any LT property P over AP:


P is a safety property if and only if cl(P) = P.

“⌦”:

Joost-Pieter Katoen and Tim Quatmann Lecture 27/45


Safety and Liveness Properties Safety Properties

Safety Properties and Finite Trace Equivalence


¨
Let TS and TS be transition systems (over AP) without terminal states.

Tracesfin (TS) N Tracesfin (TS )


¨

if and only if
¨
for any safety property Esafe ⇥ TS Ï Esafe TS Ï Esafe .

Joost-Pieter Katoen and Tim Quatmann Lecture 28/45


Safety and Liveness Properties Safety Properties

Safety Properties and Finite Trace Equivalence


¨
Let TS and TS be transition systems (over AP) without terminal states.

Tracesfin (TS) N Tracesfin (TS )


¨

if and only if
¨
for any safety property Esafe ⇥ TS Ï Esafe TS Ï Esafe .

Tracesfin (TS) = Tracesfin (TS )


¨

if and only if
¨
TS and TS satisfy the same safety properties.

Joost-Pieter Katoen and Tim Quatmann Lecture 28/45


Safety and Liveness Properties Safety Properties

Finite versus Infinite Traces

¨
For TS without terminal states and finite TS :

Traces(TS) N Traces(TS ) Tracesfin (TS) N Tracesfin (TS )


¨ ¨
iff

2
Transition systems in which each state has finitely many direct successors.
Joost-Pieter Katoen and Tim Quatmann Lecture 29/45
Safety and Liveness Properties Safety Properties

Finite versus Infinite Traces

¨
For TS without terminal states and finite TS :

Traces(TS) N Traces(TS ) Tracesfin (TS) N Tracesfin (TS )


¨ ¨
iff

¨
this does not hold for infinite TS (cf. next slide)
¨ 2
but also holds for image-finite TS .

2
Transition systems in which each state has finitely many direct successors.
Joost-Pieter Katoen and Tim Quatmann Lecture 29/45
Safety and Liveness Properties Safety Properties

Trace Equivalence j Finite Trace Equivalence

Joost-Pieter Katoen and Tim Quatmann Lecture 30/45


Safety and Liveness Properties Liveness Properties

Overview

1 Recapitulation: Traces

2 Linear-Time Properties

3 Safety Properties

4 Liveness Properties

5 Safety versus Liveness

Joost-Pieter Katoen and Tim Quatmann Lecture 31/45


Safety and Liveness Properties Liveness Properties

Why Liveness?

Z Safety properties specify that:


“something bad never happens” [Lamport 1977]

Joost-Pieter Katoen and Tim Quatmann Lecture 32/45


Safety and Liveness Properties Liveness Properties

Why Liveness?

Z Safety properties specify that:


“something bad never happens” [Lamport 1977]

Z Doing nothing easily fulfils a safety property


as this will never lead to a “bad” situation

Joost-Pieter Katoen and Tim Quatmann Lecture 32/45


Safety and Liveness Properties Liveness Properties

Why Liveness?

Z Safety properties specify that:


“something bad never happens” [Lamport 1977]

Z Doing nothing easily fulfils a safety property


as this will never lead to a “bad” situation

Safety properties are complemented by liveness properties


that require some progress

Joost-Pieter Katoen and Tim Quatmann Lecture 32/45


Safety and Liveness Properties Liveness Properties

Why Liveness?

Z Safety properties specify that:


“something bad never happens” [Lamport 1977]

Z Doing nothing easily fulfils a safety property


as this will never lead to a “bad” situation

Safety properties are complemented by liveness properties


that require some progress

Z Liveness properties assert that:


”something good” will happen eventually [Lamport 1977]

Joost-Pieter Katoen and Tim Quatmann Lecture 32/45


Safety and Liveness Properties Liveness Properties

The Meaning of Liveness

The question of whether a real system satisfies a liveness property


is meaningless; it can be answered only by observing the system for
an infinite length of time, and real systems don’t run forever.
Liveness is always an approximation to the property we really care about.
We want a program to terminate within 100 years, but proving that it does
would require addition of distracting timing assumptions.
So, we prove the weaker condition that the program eventually terminates.
This doesn’t prove that the program will terminate within our lifetimes,
but it does demonstrate the absence of infinite loops.
[Lamport 2000]

Joost-Pieter Katoen and Tim Quatmann Lecture 33/45


Safety and Liveness Properties Liveness Properties

Liveness Properties
Definition: Liveness property
LT property Elive over AP is a liveness property whenever

pref(Elive ) = 2 ⌥ .
AP ò

Joost-Pieter Katoen and Tim Quatmann Lecture 34/45


Safety and Liveness Properties Liveness Properties

Liveness Properties
Definition: Liveness property
LT property Elive over AP is a liveness property whenever

pref(Elive ) = 2 ⌥ .
AP ò

Z A liveness property does not rule out any prefix

Z Liveness properties are violated in “infinite time”


Z whereas safety properties are violated in finite time
Z finite traces are of no use to decide whether Elive holds or not
Z any finite prefix can be extended such that the resulting infinite trace
satisfies Elive

Joost-Pieter Katoen and Tim Quatmann Lecture 34/45


Safety and Liveness Properties Liveness Properties

Liveness Properties
Definition: Liveness property
LT property Elive over AP is a liveness property whenever

pref(Elive ) = 2 ⌥ .
AP ò

Z A liveness property does not rule out any prefix

Z Liveness properties are violated in “infinite time”


Z whereas safety properties are violated in finite time
Z finite traces are of no use to decide whether Elive holds or not
Z any finite prefix can be extended such that the resulting infinite trace
satisfies Elive

Z Equivalently, Elive is a liveness property iff cl(Elive ) = 2AP ⌥Ê


Joost-Pieter Katoen and Tim Quatmann Lecture 34/45
Safety and Liveness Properties Liveness Properties

Example Liveness Properties for Mutual Exclusion


P = { A0 A1 A2 . . . ∂ Aj N AP & . . . } and AP = {wait1 , crit1 , wait2 , crit2 }.

Joost-Pieter Katoen and Tim Quatmann Lecture 35/45


Safety and Liveness Properties Liveness Properties

Example Liveness Properties for Mutual Exclusion


P = { A0 A1 A2 . . . ∂ Aj N AP & . . . } and AP = {wait1 , crit1 , wait2 , crit2 }.
Z Any thread eventually is in its critical section:

(Ωj ' 0. crit1 " Aj ) 0 (Ωj ' 0. crit2 " Aj )

Joost-Pieter Katoen and Tim Quatmann Lecture 35/45


Safety and Liveness Properties Liveness Properties

Example Liveness Properties for Mutual Exclusion


P = { A0 A1 A2 . . . ∂ Aj N AP & . . . } and AP = {wait1 , crit1 , wait2 , crit2 }.
Z Any thread eventually is in its critical section:

(Ωj ' 0. crit1 " Aj ) 0 (Ωj ' 0. crit2 " Aj )

Z Any thread is infinitely often in its critical section:

⌅ Ω j ' 0. crit1 " Aj ⌦ 0 ⌅ Ω j ' 0. crit2 " Aj ⌦


ô ô

Joost-Pieter Katoen and Tim Quatmann Lecture 35/45


Safety and Liveness Properties Liveness Properties

Example Liveness Properties for Mutual Exclusion


P = { A0 A1 A2 . . . ∂ Aj N AP & . . . } and AP = {wait1 , crit1 , wait2 , crit2 }.
Z Any thread eventually is in its critical section:

(Ωj ' 0. crit1 " Aj ) 0 (Ωj ' 0. crit2 " Aj )

Z Any thread is infinitely often in its critical section:

⌅ Ω j ' 0. crit1 " Aj ⌦ 0 ⌅ Ω j ' 0. crit2 " Aj ⌦


ô ô

Z Starvation freedom — no thread is "starving”:

ºj ' 0. wait1 " Aj (Ωk > j. crit1 " Ak )⌥ 0


ºj ' 0. wait2 " Aj (Ωk > j. crit2 " Ak )⌥

Joost-Pieter Katoen and Tim Quatmann Lecture 35/45


Safety and Liveness Properties Safety versus Liveness

Overview

1 Recapitulation: Traces

2 Linear-Time Properties

3 Safety Properties

4 Liveness Properties

5 Safety versus Liveness

Joost-Pieter Katoen and Tim Quatmann Lecture 36/45


Safety and Liveness Properties Safety versus Liveness

Safety versus Liveness

Z Are safety and liveness properties disjoint? Yes, almost

Joost-Pieter Katoen and Tim Quatmann Lecture 37/45


Safety and Liveness Properties Safety versus Liveness

Safety versus Liveness

Z Are safety and liveness properties disjoint? Yes, almost

Z The property 2AP ⌥Ê is both a safety and a liveness property

Joost-Pieter Katoen and Tim Quatmann Lecture 37/45


Safety and Liveness Properties Safety versus Liveness

Safety versus Liveness

Z Are safety and liveness properties disjoint? Yes, almost

Z The property 2AP ⌥Ê is both a safety and a liveness property

Z Is any linear-time property a safety or liveness property? No

Joost-Pieter Katoen and Tim Quatmann Lecture 37/45


Safety and Liveness Properties Safety versus Liveness

Safety versus Liveness

Z Are safety and liveness properties disjoint? Yes, almost

Z The property 2AP ⌥Ê is both a safety and a liveness property

Z Is any linear-time property a safety or liveness property? No

Z But:
¨
for any LT property P there exists an equivalent LT property P
which is a conjunction of a safety and a liveness property

Joost-Pieter Katoen and Tim Quatmann Lecture 37/45


Safety and Liveness Properties Safety versus Liveness

Safety versus Liveness

Z Are safety and liveness properties disjoint? Yes, almost

Z The property 2AP ⌥Ê is both a safety and a liveness property

Z Is any linear-time property a safety or liveness property? No

Z But:
¨
for any LT property P there exists an equivalent LT property P
which is a conjunction of a safety and a liveness property

safety and liveness provide a complete characterization of LT properties

Joost-Pieter Katoen and Tim Quatmann Lecture 37/45


Safety and Liveness Properties Safety versus Liveness

Alpern-Schneider Characterisation

Bowen Alpern Fred B. Schneider

Joost-Pieter Katoen and Tim Quatmann Lecture 38/45


Safety and Liveness Properties Safety versus Liveness

Neither Safe nor Live

“the machine provides infinitely often beer


after initially providing sprite three times in a row”

Joost-Pieter Katoen and Tim Quatmann Lecture 39/45


Safety and Liveness Properties Safety versus Liveness

Neither Safe nor Live

“the machine provides infinitely often beer


after initially providing sprite three times in a row”

Z This property consists of two parts:


Z it requires beer to be provided infinitely often
as any finite trace fulfills this, it is a liveness property
Z the first three drinks it provides should all be sprite
bad prefix = one of first three drinks is beer; this is a safety property

Joost-Pieter Katoen and Tim Quatmann Lecture 39/45


Safety and Liveness Properties Safety versus Liveness

Neither Safe nor Live

“the machine provides infinitely often beer


after initially providing sprite three times in a row”

Z This property consists of two parts:


Z it requires beer to be provided infinitely often
as any finite trace fulfills this, it is a liveness property
Z the first three drinks it provides should all be sprite
bad prefix = one of first three drinks is beer; this is a safety property

Z This property is thus a conjunction of a safety and a liveness property

does this apply to all such properties?

Joost-Pieter Katoen and Tim Quatmann Lecture 39/45


Safety and Liveness Properties Safety versus Liveness

Decomposition Theorem
Decomposition theorem for LT properties
For any LT property P over AP there exists a safety property Esafe and a
liveness property Elive (both over AP) such that:

P = Esafe = Elive .

Joost-Pieter Katoen and Tim Quatmann Lecture 40/45


Safety and Liveness Properties Safety versus Liveness

Decomposition Theorem
Decomposition theorem for LT properties
For any LT property P over AP there exists a safety property Esafe and a
liveness property Elive (both over AP) such that:

P = Esafe = Elive .

Proposal: P = cl(P) = P < 2 ⌥ \ cl(P)⌥⌥


AP Ê
Õ““ “ “ “— “ “ “ “ œ Õ““ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “—“ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ “ œ
=Esafe =Elive

Joost-Pieter Katoen and Tim Quatmann Lecture 40/45


Safety and Liveness Properties Safety versus Liveness

Proof
Let P be an LT Property over AP.
Show:
1) P = cl(P) = P < 2 ⌥ \ cl(P)⌥⌥
AP Ê

2) cl(P) is a safety property

3) P < 2 ⌥ \ cl(P)⌥⌥ is a liveness property


AP Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 41/45


Safety and Liveness Properties Safety versus Liveness

Proof
Let P be an LT Property over AP.
Show: P = cl(P) = P < 2 ⌥ \ cl(P)⌥⌥
AP Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 41/45


Safety and Liveness Properties Safety versus Liveness

Proof
Let P be an LT Property over AP.
Show: cl(P) is a safety property

Joost-Pieter Katoen and Tim Quatmann Lecture 41/45


Safety and Liveness Properties Safety versus Liveness

Proof
Let P be an LT Property over AP.
Show: P < 2 ⌥ \ cl(P)⌥⌥ is a liveness property
AP Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 41/45


Safety and Liveness Properties Safety versus Liveness

"Sharpest" Decomposition

Let P be an LT property and P = Esafe = Elive where Esafe is a safety


property and Elive a liveness property.
Then:
1. cl(P) N Esafe , and

2. Elive N P < 2 ⌥ \ cl(P)⌥.


AP Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 42/45


Safety and Liveness Properties Safety versus Liveness

"Sharpest" Decomposition

Let P be an LT property and P = Esafe = Elive where Esafe is a safety


property and Elive a liveness property.
Then:
1. cl(P) N Esafe , and

2. Elive N P < 2 ⌥ \ cl(P)⌥.


AP Ê

cl(P) is the strongest safety property and


2 ⌥ \ cl(P)⌥ the weakest liveness property
AP Ê

Joost-Pieter Katoen and Tim Quatmann Lecture 42/45


Safety and Liveness Properties Safety versus Liveness

Classification of LT Properties

[Alpern and Schneider, 1987]

Joost-Pieter Katoen and Tim Quatmann Lecture 43/45


Safety and Liveness Properties Safety versus Liveness

Summary
Z LT properties are finite sets of infinite words over 2AP (= traces)

Z An invariant requires a condition to hold in any reachable state

Z Each trace refuting a safety property has a finite prefix causing this
Z invariants are safety properties with bad prefix (¬ )
ò

safety properties constrain finite behaviours

Z A liveness property does not rule out any finite behaviour


liveness properties constrain infinite behaviours

Z Any LT property is equivalent to a conjunction of a safety and a


liveness property

Joost-Pieter Katoen and Tim Quatmann Lecture 44/45


Safety and Liveness Properties Safety versus Liveness

Next Lecture

Monday April 25, 10:30

Joost-Pieter Katoen and Tim Quatmann Lecture 45/45

You might also like