- 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)whereSis a set of statesActis a set of actions→ ⊆ S x Act x Sis a transition relation- Given a state, if we perform this action, what state do we end up in?
I ⊆ Sis a set of initial statesAPis a set of atomic propositions- Possible labels for a state
L : S → 2^APis a labelling function- Given a state, what labels are active for it?
- A LTS is finite iff
S,Act, andAPare 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 ∈ Sis 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' ∈ Sis reachable froms ∈ Siff there is a finite path fromstos's ∈ Sis 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 ⊆ Actis 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
Msatisfiedψvs. not all traces inMsatisfiesψ
- 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
◇□ain CTL ∀◇∀□adoes 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₂whereFis 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
Mis 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
wis 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)whereQis a finite set of statesΣis an alphabet (actions)δ : Q x Σ -> 2^Qis a transition functionQ₀ ⊆ Qis a set of initial statesF ⊆ Qis a set of accept states
- There is an
Atransition fromqtoq'...- 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
wthat ends in someq ∈ F- Thus
wis accepted
- Thus
- The language of
αis denoted byL(α) α₁, α₂are equivalent iffL(α₁) = L(α₂)Lis a regular language iffL = L(E)for some regexELis 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
Mand regular safety propertyPM |= P ↔ Traces(M) ⊆ PM |= P ↔ Traces(M) ∩ BadPrefixes(P) = ∅
- Given an LTS
Mand an NFAαthat represents bad prefixes of PM |= P ↔ Traces(M) ∩ L(α) = ∅
- We can construct the product of
Mandα, 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 + Emean or, andE.Emean concat?
- A
ω-regular expression overΣis defined as:G = E₀.(F₀)^ω + E₁.(F₁)^ω + ... + Eₙ.(Fₙ)^ω
Lω(G) ⊆ Σ^ωis the language of aω-regular expressionGLω(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 ifPis aω-regular language over 2^AP
- Example
AP = {wait, crit}- "
critis 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 ∈ QandA ∈ Σ
- 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
Msatisfies 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^(|ψ|))