- Modelling sequential and parallel systems
- Labeled transition systems (LTS)
- Parallel computation
- Temporal logic
- LTL, CTL, CTL*
- Model checking
- CTL model checking algorithms
- Automata-theoretic model checking (LTL)
- Verification tools (SPIN)
- Not on exam
- Advanced verification techniques
- Bounded model checking
- A tuple
(S, Act, →, I, AP, L)
whereS
is a set of statesAct
is a set of actions→ ⊆ S x Act x S
is a transition relation- Given a state, if we perform this action, what state do we end up in?
I ⊆ S
is a set of initial statesAP
is a set of atomic propositions- Possible labels for a state
L : S → 2^AP
is a labelling function- Given a state, what labels are active for it?
- A LTS is finite iff
S
,Act
, andAP
are finite - This module mostly assumes finite LTSs
s -α-> s'
iff(s, α, s) ∈ →
- Direct successors:
Post(s, α) = {s' ∈ S | s -α-> s'}
Post(s) = union(Post(a, α) for α in Act)
- Direct predecessors:
Pre(s, α) = {s' ∈ S | s' -α-> s}
Pre(s) = union(Pre(a, α) for α in Act)
- Terminal states
s ∈ S
is terminal iffPost(s) = ø
- This means no outgoing transitions
- Sequence of alternating states and actions
- i.e.
s₀α₀s₁α₁s₂α₂...
such thatsᵢ -αᵢ-> sᵢ₋₁
- i.e.
- A finite path is a finite prefix of an infinite path
- Reachability
s' ∈ S
is reachable froms ∈ S
iff there is a finite path froms
tos'
s ∈ S
is a reachable state iff it is reachable from somes₀ ∈ I
- Outcome of event is not known in advance
- e.g. 10% likelihood a message send fails
- Can resemble an abstraction of a system
- Can resemble interaction with another system (e.g. a human)
- We can model two LTSs working in parallel
- If
M₁, M₂
are LTSs, to asynchronously combine them, we writeM₁ ||| M₂
- Each transition becomes whether
M₁
orM₂
is moved forward one step - Typically the actions/progressions are written as
α, β
- Formally
M₁, M₂
are LTSsMᵢ = (Sᵢ, Actᵢ, →ᵢ, Iᵢ, APᵢ, Lᵢ)
fori = [1, 2]
M₁ ||| M₂ = (S₁ x S₂, Act₁ ∪ Act₂, →', I₁ x I₂, AP₁ ∪ AP₂, L')
whereL'((s₁, s₂)) = L₁(s₁) ∪ L₂(s₂)
- if
(s₁, α₁, s₁') ∈ →₁
then((s₁, s₂), α₁, (s₁', s₂')) ∈ →'
for alls₁ ∈ S₂, s₂ ∈ S₂
(and vice versa)
- Written as
M₁ ||ₕ M₂
- Where
h ⊆ Act
is a set of handshake actions
- Where
- Synchronise only on actions in
h
- Formally
- Same as asynchronous, except from
→'
- if
(s₁, α, s₁') ∈ →₁ ^ (s₂, α, s₂') ∈ →₂
then((s₁, s₂), α, (s₁', s₂') ∈ →'
- Same as asynchronous, except from
- If we move actions from
h
, we start to see deadlocks in the system, because the combined LTS does not know what to do when an action occurs in one LTS but not the other
We say M |= P
if M
is a LTS and P
is a property and M
conforms to P
.
Can also be written as Traces(M) ⊆ P
(i.e. all possible traces of M
are
captured by P
).
- Traces, up til now, were interleaved states and actions
- We can ignore actions, as they don't provide anything for linear time
properties
- Only need to know where we can end up, not how
- Even further, we don't especially care about the states, just the labels
- So a trace is now a series of sets of labels
trace(π) = {s₀, α₀, s₁, α₁...}
= {s₀, s₁, s₂, s₃...}
= {L(s₀), L(s₁), L(s₂), L(s₃)...}
= {{a, b}, {a}, {b}, {}, {a, b}...}
- Invariants
- Something good is always true
InvariantProperty = {{A₀, A₁, A₂...} | Aᵢ |= φ}
- All traces where every state conforms to some proposition
φ
- Can easily check - just ensure it is true for all reachable states
- Safety properties
- A failure does not occur
- We can define a bad prefix that summarises traces that break the property
- All invariants are safety properties, but not all safety properties are
invariants
- "the traffic lights never both show green" i.e.
¬(g₁ ^ g₂)
- Invariant, but can be expressed as safety property
- "
g₁
is always preceded byg₂
"- Can not express as invariant
- "the traffic lights never both show green" i.e.
- Liveness properties
- Something good happens in the long run
- e.g. the program always eventually terminates
- Does not rule out any prefixes
LivenessProperty ⊆ (2^AP)^ω
is a liveness property if for all finite wordsσ ∈ (2^AP)*
, there exists a infinite wordσ' ∈ (2^AP)^ω
such thatσσ' ∈ LivenessProperty
ψ ::= true
| a ∈ AP
| ψ ^ ψ
| ¬ψ
| ○ ψ
| ψ U ψ
// The rest are derivable from the above
| ψ v ψ
| false
| □ ψ
| ◇ ψ
○ ψ
: Next- In the next state,
ψ
is true ○ a ⇒ {?, a, ?, ...}
- In the next state,
ψ₁ U ψ₂
: Untilψ₂
is true eventually, andψ₂
is true until thena U b ⇒ {a^¬b, a^¬b, b, ?, ...}
□ ψ
: Alwaysψ
is always true in all states- Equivalent to
false U ψ
□ a ⇒ {a, a, a, a, ...}
◇ ψ
: Eventuallyψ
will eventually be true- Equivalent to
true U ψ
◇ a ⇒ {¬a, ¬a, ¬a, a, ?, ...}
- We can express invariants (
□ φ
) - We can express safety properties (
□ (receive → ○ ack)
) - We can express liveness properties (
◇ terminates
) - Two formulas
ψ₁, ψ₂
are equivalent if they are satisfied by the same traces(ψ₁ ≡ ψ₂) ↔ (σ |= ψ₁ ↔ σ |= ψ₂)
for all tracesσ
□ ψ ≡ ¬◇¬ψ
,◇ψ ≡ ¬□¬ψ
□ □ ψ ≡ □ ψ
◇ ψ ≡ ψ v (○ ◇ ψ)
□(ψ₁ ^ ψ₂) ≡ (□ ψ₁) ^ (□ ψ₂)
σ |= ¬ψ ↔ σ |≠ ψ
- However,
M |= ¬ψ ↔ M |≠ ψ
is not true - No trace in
M
satisfiedψ
vs. not all traces inM
satisfiesψ
- However,
- In CTL, impossible to express "for every execution, it is always possible to return to the initial state of the program"
- Therefore, we introduce CTL with two quantifiers:
∀
for all paths∃
there exists a path
φ ::= true | a | φ ^ φ | ¬φ | ∀ψ | ∃ψ
ψ ::= ○ φ | φ U φ | ◇ φ | □ φ
∀ψ ≡ ¬∃¬ψ
∃ψ ≡ ¬∀¬ψ
New grammar:
φ ::= true | a | φ ^ φ | ¬φ | ∃ (○ φ) | ∃ (φ U φ) | ∃ (□ φ)
- No
ψ
, everything encapsulated inφ
- No
∀
, no∃◇
- Done using previously mentioned equivalences
- We've seen you can represent things in CTL that you can't in LTL
- However, you can't represent
◇□a
in CTL ∀◇∀□a
does not work- Consider a LTS with three states:
s₀
whereL(s₀) = {a}
, has a loop and leads tos₁
s₁
whereL(s₁) = {}
, leads tos₂
s₂
whereL(s₂) = {a}
, has a loop
- CTL formula would break because not all paths have always
a
- Consider a LTS with three states:
- Same for
∀□∃◇a
Superset of CTL and LTL
φ ::= true | a | φ ^ φ | ¬φ | ∀ψ | ∃ψ
ψ ::= φ | ψ ^ ψ | ¬ψ | ○ ψ | ψ U ψ | ◇ ψ | □ ψ
- Introduce another LTS that picks which of the two other LTSs to execute
- So
M₁ ||| M₂
becomesM₁ || F || M₂
whereF
is the fairness LTS that choses betweenM₁
andM₂
||
uses the actions that need to be executed by eitherM₁, M₂
- Given an LTS
M
, and a CTL formulaφ
, check whetherM |= φ
- i.e. check whether
s |= φ
for all initials tatess ∈ I
- Assume
M
is finite, and has no terminal states
- i.e. check whether
Sat(φ)
is the satisfaction set for CTL formulaφ
- i.e. set of all states that satisfy
φ
- i.e.
Sat(φ) = {s ∈ S | s |= φ}
- i.e. set of all states that satisfy
- So we check if
I ⊆ Sat(φ)
- Done recursively
- Done on ENF
Sat(true) = S
Sat(a) = {s ∈ S | a ∈ L(s)}
Sat(φ₁ ^ φ₂) = Sat(φ₁) ∩ Sat(φ₂)
Sat(¬φ) = S \ Sat(φ)
// All states where one of the next states satisfies `φ`
Sat(∃ (○ φ)) = {s ∈ S | Post(s) ∩ Sat(φ) ≠ ∅}
// Uses graph search algorithms
Sat(∃ (φ₁ U φ₂)) = CheckExistsUntil(Sat(φ₁), Sat(φ₂))
Sat(∃ (□ φ)) = CheckExistsAlways(Sat(φ))
- Trying to calculate
∃ (φ₁ U φ₂)
- Given
Sat(φ₁), Sat(φ₂)
- Backwards search of the LTS from
Sat(φ₂)
T₀ := Sat(φ₂)
Tᵢ := Tᵢ₋₁ ∪ {s ∈ Sat(φ₁) | Post(s) ∩ Tᵢ₋₁ ≠ ∅}
- Until
Tᵢ = Tᵢ₋₁
Sat(∃U)
is the finalTᵢ
- Trying to calculate
∃ (□ φ)
- Given
Sat(φ)
- Again, backwards search of the LTS from
Sat(φ)
T₀ := Sat(φ)
Tᵢ := Tᵢ₋₁ ∩ {s ∈ Sat(φ | Post(s) ∩ Tᵢ₋₁ ≠ ∅}
- Until
Tᵢ = Tᵢ₋₁
Sat(∃□)
is the finalTᵢ
- Alternative: Strongly Connected Components (SCCs)
- SSC is a maximal connected subgraph
- Non-trivial SSC is an SSC with at least one transition
- Remove all states not satisfying
φ
makingM'
- Find non-trivial SSCs in
M'
Sat(∃□)
is the set of states that can reach an SSC inM'
O(|M| * |φ|)
|M|
numer of states + transitions|φ|
number of operators
w = {A₀, A₁, ..., Aₙ}
- Finite word over alphabet
Σ
whereAᵢ ∈ Σ
- Finite word over alphabet
σ = {A₀, A₁, ...}
- Infinite word over alphabet
Σ
whereAᵢ ∈ Σ
- Infinite word over alphabet
w
is a prefix ofσ
with lengthn
, ending atAₙ
σ'
is a infinite suffix ofσ
, starting atAₙ
Σ*
set of finite words overΣ
Σ^ω
set of infinite words overΣ
- Tuple
α = (Q, Σ, δ, Q₀, F)
whereQ
is a finite set of statesΣ
is an alphabet (actions)δ : Q x Σ -> 2^Q
is a transition functionQ₀ ⊆ Q
is a set of initial statesF ⊆ Q
is a set of accept states
- There is an
A
transition fromq
toq'
...- Written as
q -A-> q'
- If
q' ∈ δ(q, A)
- Written as
- There is a run of
α
on a finite wordw = {A₀, A₁, ...}
if- There is a sequence of states
{q₀, q₁, ...}
where q₀ ∈ Q₀
andqᵢ -Aᵢ-> qᵢ₊₁
for alli
- There is a sequence of states
- An accepting run is an
w
that ends in someq ∈ F
- Thus
w
is accepted
- Thus
- The language of
α
is denoted byL(α)
α₁, α₂
are equivalent iffL(α₁) = L(α₂)
L
is a regular language iffL = L(E)
for some regexE
L
is a regular language iffL = L(α)
for some NFAα
- Example
- "A failure never occurs",
□ ¬ fail
AP = {fail}
,2^AP = {∅, {fail}}
- NFA
α
:q₀
,L(q₀) = ∅
, transition to self andq₁
, initial stateq₁
,L(q₁) = {fail}
, accepting state
L(α) = {{{fail}}, {∅, {fail}}, {∅, ∅, {fail}}, ...}
.*{fail}
- "A failure never occurs",
- Given an LTS
M
and regular safety propertyP
M |= P ↔ Traces(M) ⊆ P
M |= P ↔ Traces(M) ∩ BadPrefixes(P) = ∅
- Given an LTS
M
and an NFAα
that represents bad prefixes of PM |= P ↔ Traces(M) ∩ L(α) = ∅
- We can construct the product of
M
andα
, written asM ⊙ α
M = (S, Act, →, I, AP, L)
α = (Q, Σ, δ, Q₀, F)
M ⊙ α = (S x Q, Act, →', I', {accept}, L')
I' = {(s₀, q) | s₀ ∈ I, q₀ -L(s₀)-> q, q₀ ∈ Q₀}
L'((s, q)) = if q ∈ F then {accept} else ∅
→'
:- If
s -act-> s'
andq -L(s')-> q'
- Then
(s, q) -act-> (s', q')
- If
- Therefore:
M |= P ↔ M ⊙ α |= □ ¬ accept
- i.e. if there's no reachable accept state in
M ⊙ α
- A regular expression over
Σ
is defined as:E ::= ∅ | ε | A ∈ Σ | E + E | E.E | E*
- TODO: Does
E + E
mean or, andE.E
mean concat?
- A
ω
-regular expression overΣ
is defined as:G = E₀.(F₀)^ω + E₁.(F₁)^ω + ... + Eₙ.(Fₙ)^ω
Lω(G) ⊆ Σ^ω
is the language of aω
-regular expressionG
Lω(G) = L(E₀).L(F₀)^ω ∪ L(E₁).L(F₁)^ω ∪ ... ∪ L(Eₙ).L(Fₙ)^ω
L ⊆ Σ^ω
is aω
-regular language ifL = Lω(G)
for someω
-regular expressionG
P ⊆ (2^AP)^ω
is aω
-regular property ifP
is aω
-regular language over 2^AP
- Example
AP = {wait, crit}
- "
crit
is true infinitely often" ((¬crit)*crit)^ω
- Identical syntactically to NFAs
- Acceptance condition changes
- The accept state does not need to be visited once, but has to be visited inifinitely often
- Represent
ω
-regular languages
- An NBA is non-blocking if every symbol/action is available in every state
- i.e.
δ(q, A) ≠ ∅
for allq ∈ Q
andA ∈ Σ
- i.e.
- We can always convert a blocking NBA to a non-blocking NBA by adding a trap
state:
- All undefined actions lead to it
- It loops unconditionally to itself
- We can do product of LTS and NBA, as with safety properties
- And then we need to find a reachable cycle in the product that contains an accepting state
- This means that there is a path in the LTS that satisfies the property the NBA describes
- This is not the procedure for checking the property on an LTS
- To check whether an LTS
M
satisfies an LTL propertyψ
:M |= ψ
Traces(M) ⊆ Words(ψ)
Traces(M) ∩ Words(¬ψ) = ∅
Traces(M) ∩ Lω(α)
whereα
is an NBA that represents¬ω
M |= ψ
iff there is no accepting path (cycle) inM ⊙ α
- Complexity is
O(|M| * 2^(|ψ|))