Computer aided verification
Lecture 4:
Algorithmic aspects of LTL
model-checking, partial-order reductions
Sławomir Lasota University of Warsaw
Algorithm
M φ ?
(i) M 7→ AM
(ii) ¬φ 7→ A¬φ (never claim) ( not φ 7→ Aφ 7→ ¯Aφ ) (iii) Lω(AM) ∩ Lω(A¬φ) = ∅ ? ( not Lω(AM) ⊆ Lω(Aφ) )
Lω(AM × A¬φ) = ∅ ? yes −→ M φ
no −→ ¬(M φ), counterexample = a path in M
// 7654 0123 ,, 7654 0123 '&%$ !"#FED ABC
(i) M 7→ A M
{p, q}
?>=< 89:;
s0** ?>=< 89:;
s1jj
{p}
?>=<
89:;
s2YY
{q}
7→
?>=<
89:; 7654 0123
i{p,q}
{p}
?>=<
89:; 7654 0123
s0{p}
%% ?>=< 89:; 7654 0123
s1 {p,q}ee
{q}
?>=<
89:; 7654 0123
s2 {p,q}MM
Algorithm
M φ ?
(i) M 7→ AM
(ii) ¬φ 7→ A¬φ (never claim) ( not φ 7→ Aφ 7→ ¯Aφ ) (iii) Lω(AM) ∩ Lω(A¬φ) = ∅ ? ( not Lω(AM) ⊆ Lω(Aφ) )
Lω(AM × A¬φ) = ∅ ? yes −→ M φ
no −→ ¬(M φ), counterexample = a path in M
// 7654 0123 ,, 7654 0123 '&%$ !"#FED ABC
(iii) L ω (A) 6= ∅?
Traversal of a graph:
[Clarke, Grumberg, Peled 2000]
(iii) L ω (A) 6= ∅?
Traversal of a graph:
[Clarke, Grumberg, Peled 2000]
// 7654 0123 ++ 7654 0123 '&%$ !"#FED XX ABC
On the fly verification
for each successsor si of s do . . .
?>=< 89:;
s~~}} }} }} }} }
A A A A A A A A A
?>=<
89:;
s1?>=< 89:;
s2Reachability: F bad state
For reachability it is enough to use DFS or BFS
[Holzmann,Peled,Yannakakis 1996]
// 7654 0123 ,, 7654 0123 '&%$ !"#
Nested DFS
[Holzmann,Peled,Yannakakis 1996]
// 7654 0123 ,, 7654 0123 '&%$ !"#FED XX ABC
Proof of correctness
Assume an acceping state p with a cycle not detected by ndfs(p). Let p – the first such state.
Proof of correctness
Assume an acceping state p with a cycle not detected by ndfs(p). Let p – the first such state.
Let r – the first state inspected by ndfs(p) that is on a p-cycle and for which {r,1} in Statespace.
Proof of correctness
Assume an acceping state p with a cycle not detected by ndfs(p). Let p – the first such state.
Let r – the first state inspected by ndfs(p) that is on a p-cycle and for which {r,1} in Statespace.
Let p’ – the accepting state such that r visited by ndfs(p’).
. . .
// GFED @ABC ?>=< 89:;
p%%
?
++
?>=<
89:;
rgg
. . .
// GFED @ABC ?>=< 89:;
p%% ?>=< 89:;
rgg
GFED
@ABC ?>=< 89:;
p′OO
GFED
@ABC ?>=< 89:;
p′OO
Partial-order reductions?
(1) On the fly verification: for each successsor si of s do . . .
Partial-order reductions?
(1) On the fly verification: for each successsor si of s do . . .
(2) Partial-order reductions: for each selected successsor si of s do . . .
selected depends on the DFS stack !
Partial-order reductions?
(1) On the fly verification: for each successsor si of s do . . .
(2) Partial-order reductions: for each selected successsor si of s do . . .
selected depends on the DFS stack !
dfs: . . .
?>=<
89:;
s~~
?>=<
89:;
s1?>=< 89:; 7654 0123
s099 ?>=< 89:;
s2ll
Partial-order reductions?
(1) On the fly verification: for each successsor si of s do . . .
(2) Partial-order reductions: for each selected successsor si of s do . . .
selected depends on the DFS stack !
dfs: . . .
?>=<
89:;
s~~
?>=<
89:;
s1?>=< 89:; 7654 0123
s099 ?>=< 89:;
s2ll
nfds: . . .
?>=<
89:;
s}}{{ {{ {{ {{ {{
B B B B B B B B B
?>=<
89:;
s1?>=< 89:; 7654 0123
s099 ?>=< 89:;
s2ll
Partial-order reductions?
(1) On the fly verification: for each successsor si of s do . . .
(2) Partial-order reductions: for each selected successsor si of s do . . .
selected depends on the DFS stack !
dfs: . . .
?>=<
89:;
s~~
?>=<
89:;
s1?>=< 89:; 7654 0123
s099 ?>=< 89:;
s2ll
nfds: . . .
?>=<
89:;
s}}{{ {{ {{ {{ {{
B B B B B B B B B
?>=<
89:;
s1?>=< 89:; 7654 0123
s099 ?>=< 89:;
s2ll
Solution: Report a cycle when a stack is hit in ndfs.
Nested DFS compatible with p.-o.red.
[Holzmann,Peled,Yannakakis 1996]
Nested DFS compatible with p.-o.red.
[Holzmann,Peled,Yannakakis 1996]
Question: Is nested DFS correct now?
np-cycles: FG ¬ progress
[Holzmann,Peled,Yannakakis 1996]
np-cycles: never claim
[Holzmann,Peled,Yannakakis 1996]
// 7654 0123 BCD
@GA 88
¬progress
// 7654 0123 '&%$ !"#FED ABC
¬progressXX
np-cycles: never claim
[Holzmann,Peled,Yannakakis 1996]
// 7654 0123 BCD
@GA 88
¬progress
// 7654 0123 '&%$ !"#FED ABC
¬progressXX
Question: What overhead is introduced, when the never claim is used?
Partial-order reductions
for each selected successsor si ofs do . . .
?>=< 89:;
s~~ A A A A A A A A A
?>=<
89:;
s1?>=< 89:;
s2Motivation
Idea: exploit indpendence (concurrency) of transitions
F¬p
?>=<
89:;
pα
}}
β
B !!B B B B B B B B GFED
@ABC
¬pβ
!!
?>=<
89:;
pα
}}|| || || || | GFED
@ABC
¬pMotivation
/.-, ()*+
α1
~~}} }} }} }}
β1A A A A A A A A /.-,
()*+
α2
~~}} }} }} }}
β1A A A A A A
A A /.-, ()*+
α1
~~}} }} }} }}
β2A A A A A A A A /.-,
()*+
β1
A A A A A A
A A /.-, ()*+
α2
~~}} }} }} }}
β2A A A A A A
A A /.-, ()*+
α1
~~}} }} }} }}
/.-, ()*+
β2
A A A A A A
A A /.-, ()*+
α2
~~}} }} }} }}
/.-,
()*+
Motivation
/.-, ()*+
β1
$ A A A A A A A A
A A A A A A A A
/.-, ()*+
α1
z }} }} }} }}
}} }} }} }}
/.-, ()*+
α2
z }} }} }} }}
}} }} }} }}
/.-, ()*+
β2
$ A A A A A A A A
A A A A A A A A
/.-,
()*+
Model
Def.: M = hS, Sinit,T, Li T – operations (transitions) for α ∈ T : enα ⊆ S, α : enα → S (determinism)
path: Π = s0 α0
−−→ s1 −−→ sα1 2 −−→ . . .α2 s0 = sinit
αi(si) = si+1
ens := {α | s ∈ enα} (α ∈ ens ⇐⇒ s ∈ enα)
Idea: amples ⊆ ens instead of ens in nested DFS ?
Cost-effectivity
Idea: amples ⊆ ens instead of ens in nested DFS ?
This makes sense, when:
– the result of verification is the same (correctness) – significantly less states visited
– time overhead reasonable (effectivity)
Correctness?
When may we ignore α ?
?>=< 89:;
pα
}}
β
B !!B B B B B B B B GFED
@ABC
¬pβ
!!
?>=<
89:;
pα
}}|| || || || | GFED
@ABC
¬pProblem 1: Property may depend on state
GFED @ABC
¬p .Problem 2:
GFED @ABC
¬p –successors unreachable otherwise.Stuttering
Def.: Π = s0 −→ s1 −→ s2 −→ . . . and Π′ = s′0 −→ s′1 −→ s′2 −→ . . . are stuttering equivalent, Π ≡ Π′, if sequences
L(s0), L(s1), L(s2), . . . L(s′0), L(s′1), L(s′2), . . . become identical after grouping is done:
Def.: M ≡ M′ if and only if – ∀Π in M ∃Π′ in M′ Π ≡ Π′ – ∀Π′ in M′ ∃Π in M Π ≡ Π′
LTL −X
LTL−X = LTL without X
Thm: If φ ∈ LTL−X and Π ≡ Π′, then Π φ ⇐⇒ Π′ φ Thm: If φ ∈ LTL−X and M ≡ M′, then M φ ⇐⇒ M′ φ
Thm: LTL−X = FO≡( ≤ )
Correctness
M partial-order reduction
// M ′
M ≡ M ′
Sufficient condition for correctness
(C0) amples = ∅ ⇐⇒ ens = ∅
(C1) . . .
(C2) . . .
(C3) . . .
Invisibility
Def.: α is invisible if L(s) = L(α(s)), ∀ s ∈ enα.
Example: If α invisible, then
?>=< 89:;
sα
~~}} }} }} }} }
β
A A A A A A A A A
?>=<
89:;
s1β
A A A A A A A A
A ?>=< 89:;
s2 α~~}} }} }} }} }
?>=<
89:;
r ss1r ≡ ss2rSufficient condition for correctness
(C0) amples = ∅ ⇐⇒ ens = ∅
(C1) if amples 6= ens then every α ∈ amples is invisible
(C2) . . .
(C3) . . .
Idea: Instead of doing sth now, do it in future!
Correctness?
Problem 1: Property may depend on state
GFED @ABC
¬p .?>=<
89:;
pα
}}
β
B !!B B B B B B B B GFED
@ABC
¬pβ
!!
?>=<
89:;
pα
}}|| || || || | GFED
@ABC
¬pSolved due to (C1) !
(C1) if amples 6= ens, then every α ∈ amples is invisible
Independence
Def.: Relation of independence I ⊆ T × T : – irreflexive and antisymmetric
– if αIβ, α ∈ ens, β ∈ ens, then (s ∈ enα ∩ enβ) – β(s) ∈ enα, α(s) ∈ enβ
– β(α(s)) = α(β(s))
?>=< 89:;
sα
}}|| || || || |
β
B !!B B B B B B B B 7654
0123
β
D !!D D D D D D D
D
αIβ7654 0123
α
}}zz zz zz zz z 7654
D = T × T \ I (dependency)
0123
Independence
Example: Independent may be:
– 2 instructions of different processes operating on local variables
Independence
Example: Independent may be:
– 2 instructions of different processes operating on local variables
– 2 instructions of different processes that increment the same global variable
Independence
Example: Independent may be:
– 2 instructions of different processes operating on local variables
– 2 instructions of different processes that increment the same global variable – 2 instructions of different processes writing to/reading from different buffers
Independence
Example: Independent may be:
– 2 instructions of different processes operating on local variables
– 2 instructions of different processes that increment the same global variable – 2 instructions of different processes writing to/reading from different buffers – 2 instructions of different processes:
one writing to a buffer
the other one reading from the same buffer
Independence
Example: Independent may be:
– 2 instructions of different processes operating on local variables
– 2 instructions of different processes that increment the same global variable – 2 instructions of different processes writing to/reading from different buffers – 2 instructions of different processes:
one writing to a buffer
the other one reading from the same buffer
Question: Can 2 instructions of the same process be independent ?
Independence
Question: Let αIβ. Is it possible that
s ∈ enα \ enβ α(s) ∈ enβ ?
?>=< 89:;
sα
}}|| || || || |
β
7654 0123
β
D !!D D D D D D D
D
αIβ7654
0123
Independence
Question: Let αIβ. Is it possible that
s ∈ enα \ enβ α(s) ∈ enβ ?
?>=< 89:;
sα
}}|| || || || |
β
7654 0123
β
D !!D D D D D D D
D
αIβ7654 0123
Yes! E.g. asynchronous reading and writing from/to the same buffer by two different processes.
Sufficient condition for correctness
(C0) amples = ∅ ⇐⇒ ens = ∅
(C1) if amples 6= ens then every α ∈ amples is invisible
(C2) ? ens \ amples I amples
(C3) . . .
Idea: Instead of doing sth now, do it in future!
(C2)
(C2) a transition dependent on some transition from amples
can not be enabled before some transition from amples is executed
(C2)
(C2) a transition dependent on some transition from amples
can not be enabled before some transition from amples is executed
(C2) for every path Π starting in s:
if α ∈ amples, β ∈ ample/ s, αDβ then β does not appear in Π
before some transition from amples is executed
(C2)
Lemma: (C2) implies ens \ amples I amples.
Proof: Let β ∈ ens \ amples, α ∈ amples, αDβ.
s −→β β(s) −→ . . . contradiction with (C2) .
Correctness?
Problem 2:
?>=< 89:;
s2 –successors unreachable otherwise.?>=<
89:;
sα
}}zz zz zz
βD !!D D D D D
?>=<
89:;
s1β
B B B B B
B
αIβ?>=< 89:;
s2~~}} }}
α}}
γA A A A A A
?>=<
89:;
rGFED @ABC
s′2e.g., let α ∈ amples,β ∈ ample/ s
Correctness?
Problem 2:
?>=< 89:;
s2 –successors unreachable otherwise.?>=<
89:;
sα
}}zz zz zz
βD !!D D D D D
?>=<
89:;
s1β
B B B B B
B
αIβ?>=< 89:;
s2~~}} }}
α}}
γA A A A A A
?>=<
89:;
rGFED @ABC
s′2e.g., let α ∈ amples,β ∈ ample/ s
by (C2) applied to βγ . . ., we deduce γIα
Problems?
Problem 2:
?>=< 89:;
s2 –successors unreachable otherwise.?>=<
89:;
sα
}}zz zz zz
β""D D D D D D
?>=<
89:;
s1β
B B B B B
B
αIβ?>=< 89:;
s2}}|| ||
α||
γA A A A A A
?>=<
89:;
rγ
αIγ
GFED @ABC
s′2~~
α?>=<
89:;
r′e.g., let α ∈ amples,β ∈ ample/ s
by (C2) applied to βγ . . ., we deduce γIα α invisible, thus ss1rr′ ≡ ss2s′2
Problems?
Problem 2∞:
?>=< 89:;
s2 –path unreachable otherwise.?>=<
89:;
sα
}}zz zz zz
β""D D D D D D
?>=<
89:;
s1β
B B B B B
B
αIβ?>=< 89:;
s2}}|| ||
α||
γA A A A A A
?>=<
89:;
rγ
αIγ
GFED @ABC
s′2~~
αγ′
>
> >
> >
> >
?>=<
89:;
r′ . . . by (C2) we deduce γIα, γ′Iα, . . .α invisible, thus ss1rr′ . . . ≡ ss2s′2 . . .
Problems?
Problem 2∞:
?>=< 89:;
s2 –path unreachable otherwise.?>=<
89:;
sα
}}zz zz zz
β""D D D D D D
?>=<
89:;
s1β
B B B B B
B
αIβ?>=< 89:;
s2}}|| ||
α||
γA A A A A A
?>=<
89:;
rγ
αIγ
GFED @ABC
s′2~~
αγ′
>
> >
> >
> >
?>=<
89:;
r′ . . . by (C2) we deduce γIα, γ′Iα, . . .α invisible, thus ss1rr′ . . . ≡ ss2s′2 . . .
Problem 2∞ does not appear under weak fairness
Fairness
Def. (weak fairness): if α enabled from some point on then α eventually executed.
Corollary: for every reachable state s, if α ∈ ens then eventually some β will be executed such that αDβ.
/.-, ()*+
α
~~~~ ~~ ~~ ~~
β
...
@ @
@ @
@ @
@ @ ?>=< 89:;
sα
}}zz zz zz
β""D D D D D D
?>=<
89:;
s1β
B B B B B
B
αIβ?>=< 89:;
s2}}|| ||
α||
γA A A A A A
?>=<
89:;
rγ
αIγ
GFED @ABC
s′2~~
αγ′
>
> >
> >
> >
?>=<
89:;
r′ . . .Enough?
Are (C0) – (C2) sufficient?
Enough?
Are (C0) – (C2) sufficient?
No!
?>=<
89:;
pβ
7654 0123
α1
GFED
@ABC
¬p7654 0123
α2
// 7654 0123
α3
``
Enough?
Are (C0) – (C2) sufficient?
No!
?>=<
89:;
pβ
7654 0123
α1
GFED
@ABC
¬p7654 0123
α2
// 7654 0123
α3
``
(C3) we forbid cycles C such that ∃β ∀s ∈ C β ∈ ens \ amples
Sufficient condition for correctness
(C0) amples = ∅ ⇐⇒ ens = ∅
(C1) if amples 6= ens then every α ∈ amples is invisible
(C2) for every path Π starting in s:
if α ∈ amples, β ∈ ample/ s, αDβ then β does not appear in Π
before some transition from amples is executed
(C3) we forbid cycles C such that ∃β ∀s ∈ C β ∈ ens \ amples
How to implement (C1) – (C3) ?
Sufficient condition for correctness
(C1) easy
(C2) hard, implemented in an approximate manner – an over-approximation of D is computed – condition (C2) is monotonic
– static analysis only
(C3) replaced by another condition which is easier but stronger:
(C3’) if amples 6= ens then ∀α ∈ amples α(s) /∈ stack
Implementation
Implementation decision:
amples = all transitions of some process i enabled in s
Implementation
Implementation decision:
amples = all transitions of some process i enabled in s
whenever
– they are independent from all operations of all other processes – no operation of any other process may enable
any other operation of process i
β enabling α (over-approximation)
– if β modifies pc so that α may be executed
– if Promela enabling condition for α depends on global variables, then any β that modifies these variables
– if α is reading from/writing to a buffer then any β that reads from/writes to this buffer
αDβ (over-approximation)
– α and β refer to the same global variable
and at least one of them modifies the variable
– α and β belong to the same process; synchronous communication is understood as belonging to both processes
– α and β write to/read from the same buffer
However reading from a buffer is independent from writing to the same buffer!
What remains independent?
Example:
Operations independent from all operations of other processes:
– operating on local variables
– reading from a buffer with xr flag set – writing to a bugger with xs flag set – test nempty(q) if xr flags is set for q – test nfull(q) if xs flag is set for q