1/71
Basics of model checking
Paul Gastin
LIAFA (Paris) and LSV (Cachan) Paul.Gastin@liafa.jussieu.fr Paul.Gastin@lsv.ens-cachan.fr
Basics of model checking Paul Gastin LIAFA (Paris) and LSV (Cachan) - - PowerPoint PPT Presentation
Basics of model checking Paul Gastin LIAFA (Paris) and LSV (Cachan) Paul.Gastin@liafa.jussieu.fr Paul.Gastin@lsv.ens-cachan.fr MOVEP, Dec. 2004 1/71 Outline Introduction 1 Models 2 Specification 3 Linear Time Specifications Branching
1/71
LIAFA (Paris) and LSV (Cachan) Paul.Gastin@liafa.jussieu.fr Paul.Gastin@lsv.ens-cachan.fr
2/71
1
2
3
3/71
◮ Transport ◮ Energy ◮ Medicine ◮ Communication ◮ Finance ◮ Embedded systems ◮ . . .
◮ Theorem prover ◮ Model checking ◮ Test
3/71
◮ Transport ◮ Energy ◮ Medicine ◮ Communication ◮ Finance ◮ Embedded systems ◮ . . .
◮ Theorem prover ◮ Model checking ◮ Test
4/71
◮ Constructing the model M (transition systems) ◮ Formalizing the specification ϕ (temporal logics) ◮ Checking whether M |
◮ Size of models (combinatorial explosion) ◮ Expressivity of models or logics ◮ Decidability and complexity of the model-checking problem ◮ Efficiency of tools
◮ Extend models and algorithms to cope with more systems.
◮ Scale current tools to cope with real-size systems.
4/71
◮ Constructing the model M (transition systems) ◮ Formalizing the specification ϕ (temporal logics) ◮ Checking whether M |
◮ Size of models (combinatorial explosion) ◮ Expressivity of models or logics ◮ Decidability and complexity of the model-checking problem ◮ Efficiency of tools
◮ Extend models and algorithms to cope with more systems.
◮ Scale current tools to cope with real-size systems.
4/71
◮ Constructing the model M (transition systems) ◮ Formalizing the specification ϕ (temporal logics) ◮ Checking whether M |
◮ Size of models (combinatorial explosion) ◮ Expressivity of models or logics ◮ Decidability and complexity of the model-checking problem ◮ Efficiency of tools
◮ Extend models and algorithms to cope with more systems.
◮ Scale current tools to cope with real-size systems.
5/71
◮ The Temporal Logic of Reactive and Concurrent Systems: Specification.
◮ Temporal Verification of Reactive Systems: Safety. Z. Manna and A. Pnueli.
◮ Model Checking. E.M. Clarke, O. Grumberg, D.A. Peled. MIT Press, 1999. ◮ Systems and Software Verification. Model-Checking Techniques and Tools.
6/71
1
2
3
7/71
◮ State = who is on which side of the river ◮ Transition = crossing the river
7/71
◮ State = who is on which side of the river ◮ Transition = crossing the river
8/71
9/71
◮ S: set of states (often finite) ◮ T ⊆ S × A × S: set of transitions ◮ I ⊆ S: set of initial states ◮ AP: set of atomic propositions ◮ ℓ : S → 2AP: labelling function.
9/71
◮ S: set of states (often finite) ◮ T ⊆ S × A × S: set of transitions ◮ I ⊆ S: set of initial states ◮ AP: set of atomic propositions ◮ ℓ : S → 2AP: labelling function.
9/71
◮ S: set of states (often finite) ◮ T ⊆ S × A × S: set of transitions ◮ I ⊆ S: set of initial states ◮ AP: set of atomic propositions ◮ ℓ : S → 2AP: labelling function.
10/71
11/71
◮ V: set of (typed) variables, e.g., boolean, [0..4], . . . ◮ Condition: formula involving variables ◮ Update: modification of variables ◮ Transition: p
condition,label,update
◮ Program counter = states ◮ Instructions = transitions ◮ Variables = variables
11/71
◮ V: set of (typed) variables, e.g., boolean, [0..4], . . . ◮ Condition: formula involving variables ◮ Update: modification of variables ◮ Transition: p
condition,label,update
◮ Program counter = states ◮ Instructions = transitions ◮ Variables = variables
12/71
13/71
1 2 3 4 OPEN A B A cpt < n B, C cpt++ cpt < n A cpt++ cpt < n C cpt++ cpt < n B, C cpt++ 5 ERROR cpt = n B, C cpt++ cpt = n A, C cpt++ cpt = n B, C cpt++
14/71
◮ Cabin:
◮ Door for level i:
◮ Call for level i:
14/71
◮ Cabin:
◮ Door for level i:
◮ Call for level i:
15/71
◮ Components: Mi = (Si, Ai, Ti, Ii, APi, ℓi) ◮ Product: M = (S, A, T, I, AP, ℓ) with
i Si,
i(Ai ∪ {ε}),
i Ii
(a1,...,an)
i APi and ℓ(p1, . . . , pn) = i ℓ(pi)
◮ Synchronous: Async = i Ai ◮ Asynchronous: Async = i Ai ◮ By states: Ssync ⊆ S ◮ By labels: Async ⊆ A ◮ By transitions: Tsync ⊆ T
15/71
◮ Components: Mi = (Si, Ai, Ti, Ii, APi, ℓi) ◮ Product: M = (S, A, T, I, AP, ℓ) with
i Si,
i(Ai ∪ {ε}),
i Ii
(a1,...,an)
i APi and ℓ(p1, . . . , pn) = i ℓ(pi)
◮ Synchronous: Async = i Ai ◮ Asynchronous: Async = i Ai ◮ By states: Ssync ⊆ S ◮ By labels: Async ⊆ A ◮ By transitions: Tsync ⊆ T
15/71
◮ Components: Mi = (Si, Ai, Ti, Ii, APi, ℓi) ◮ Product: M = (S, A, T, I, AP, ℓ) with
i Si,
i(Ai ∪ {ε}),
i Ii
(a1,...,an)
i APi and ℓ(p1, . . . , pn) = i ℓ(pi)
◮ Synchronous: Async = i Ai ◮ Asynchronous: Async = i Ai ◮ By states: Ssync ⊆ S ◮ By labels: Async ⊆ A ◮ By transitions: Tsync ⊆ T
15/71
◮ Components: Mi = (Si, Ai, Ti, Ii, APi, ℓi) ◮ Product: M = (S, A, T, I, AP, ℓ) with
i Si,
i(Ai ∪ {ε}),
i Ii
(a1,...,an)
i APi and ℓ(p1, . . . , pn) = i ℓ(pi)
◮ Synchronous: Async = i Ai ◮ Asynchronous: Async = i Ai ◮ By states: Ssync ⊆ S ◮ By labels: Async ⊆ A ◮ By transitions: Tsync ⊆ T
15/71
◮ Components: Mi = (Si, Ai, Ti, Ii, APi, ℓi) ◮ Product: M = (S, A, T, I, AP, ℓ) with
i Si,
i(Ai ∪ {ε}),
i Ii
(a1,...,an)
i APi and ℓ(p1, . . . , pn) = i ℓ(pi)
◮ Synchronous: Async = i Ai ◮ Asynchronous: Async = i Ai ◮ By states: Ssync ⊆ S ◮ By labels: Async ⊆ A ◮ By transitions: Tsync ⊆ T
15/71
◮ Components: Mi = (Si, Ai, Ti, Ii, APi, ℓi) ◮ Product: M = (S, A, T, I, AP, ℓ) with
i Si,
i(Ai ∪ {ε}),
i Ii
(a1,...,an)
i APi and ℓ(p1, . . . , pn) = i ℓ(pi)
◮ Synchronous: Async = i Ai ◮ Asynchronous: Async = i Ai ◮ By states: Ssync ⊆ S ◮ By labels: Async ⊆ A ◮ By transitions: Tsync ⊆ T
15/71
◮ Components: Mi = (Si, Ai, Ti, Ii, APi, ℓi) ◮ Product: M = (S, A, T, I, AP, ℓ) with
i Si,
i(Ai ∪ {ε}),
i Ii
(a1,...,an)
i APi and ℓ(p1, . . . , pn) = i ℓ(pi)
◮ Synchronous: Async = i Ai ◮ Asynchronous: Async = i Ai ◮ By states: Ssync ⊆ S ◮ By labels: Async ⊆ A ◮ By transitions: Tsync ⊆ T
16/71
Idle Wait Print Idle Wait Print I, I I, W I, P W, I W, W W, P P, I P, W
17/71
18/71
1 2 3 4 OPEN A B A B, C A C B, C 1,0 2,0 3,0 4,0 OPEN A B A 1,1 2,1 3,1 4,1 OPEN A B A B, C C B, C A 1,2 2,2 3,2 4,2 OPEN A B A B, C C B, C A 5,3 ERROR B, C A, C B, C 1 2 3 ERROR
19/71
19/71
20/71
◮ Sequential programs = transition system with variables ◮ Concurrent programs with shared variables ◮ Concurrent programs with Rendez-vous ◮ Concurrent programs with FIFO communication ◮ Petri net ◮ . . .
21/71
◮ Automata with 2 integer variables = Turing powerful
◮ Asynchronous communication: unbounded fifo channels = Turing powerful
◮ Petri nets. Several unbounded integer variables but no zero-test. ◮ Pushdown automata. Model for recursive procedure calls. ◮ Timed automata. ◮ . . .
21/71
◮ Automata with 2 integer variables = Turing powerful
◮ Asynchronous communication: unbounded fifo channels = Turing powerful
◮ Petri nets. Several unbounded integer variables but no zero-test. ◮ Pushdown automata. Model for recursive procedure calls. ◮ Timed automata. ◮ . . .
22/71
1
2
3
23/71
23/71
24/71
◮ These specifications can be written in FO(<). ◮ FO(<) has a good expressive power.
◮ FO(<) is decidable.
◮ no variables: time is implicit. ◮ quantifications and variables are replaced by modalities. ◮ Usual specifications are easy to write and read. ◮ Good complexity for satisfiability and model checking problems.
24/71
◮ These specifications can be written in FO(<). ◮ FO(<) has a good expressive power.
◮ FO(<) is decidable.
◮ no variables: time is implicit. ◮ quantifications and variables are replaced by modalities. ◮ Usual specifications are easy to write and read. ◮ Good complexity for satisfiability and model checking problems.
25/71
25/71
26/71
1
2
3
27/71
27/71
27/71
27/71
27/71
28/71
◮ Eventually:
◮ Always:
◮ Weak until: ϕ W ψ = G ϕ ∨ ϕ U ψ ◮
◮ Release:
◮ Next until:
◮
28/71
◮ Eventually:
◮ Always:
◮ Weak until: ϕ W ψ = G ϕ ∨ ϕ U ψ ◮
◮ Release:
◮ Next until:
◮
28/71
◮ Eventually:
◮ Always:
◮ Weak until: ϕ W ψ = G ϕ ∨ ϕ U ψ ◮
◮ Release:
◮ Next until:
◮
28/71
◮ Eventually:
◮ Always:
◮ Weak until: ϕ W ψ = G ϕ ∨ ϕ U ψ ◮
◮ Release:
◮ Next until:
◮
28/71
◮ Eventually:
◮ Always:
◮ Weak until: ϕ W ψ = G ϕ ∨ ϕ U ψ ◮
◮ Release:
◮ Next until:
◮
28/71
◮ Eventually:
◮ Always:
◮ Weak until: ϕ W ψ = G ϕ ∨ ϕ U ψ ◮
◮ Release:
◮ Next until:
◮
28/71
◮ Eventually:
◮ Always:
◮ Weak until: ϕ W ψ = G ϕ ∨ ϕ U ψ ◮
◮ Release:
◮ Next until:
◮
29/71
◮ Safety:
◮ MutEx:
◮ Liveness:
◮ Response:
◮ Response’:
◮ Release:
◮ Strong fairness:
◮ Weak fairness:
29/71
◮ Safety:
◮ MutEx:
◮ Liveness:
◮ Response:
◮ Response’:
◮ Release:
◮ Strong fairness:
◮ Weak fairness:
29/71
◮ Safety:
◮ MutEx:
◮ Liveness:
◮ Response:
◮ Response’:
◮ Release:
◮ Strong fairness:
◮ Weak fairness:
29/71
◮ Safety:
◮ MutEx:
◮ Liveness:
◮ Response:
◮ Response’:
◮ Release:
◮ Strong fairness:
◮ Weak fairness:
29/71
◮ Safety:
◮ MutEx:
◮ Liveness:
◮ Response:
◮ Response’:
◮ Release:
◮ Strong fairness:
◮ Weak fairness:
29/71
◮ Safety:
◮ MutEx:
◮ Liveness:
◮ Response:
◮ Response’:
◮ Release:
◮ Strong fairness:
◮ Weak fairness:
29/71
◮ Safety:
◮ MutEx:
◮ Liveness:
◮ Response:
◮ Response’:
◮ Release:
◮ Strong fairness:
◮ Weak fairness:
29/71
◮ Safety:
◮ MutEx:
◮ Liveness:
◮ Response:
◮ Response’:
◮ Release:
◮ Strong fairness:
◮ Weak fairness:
30/71
30/71
31/71
31/71
31/71
31/71
31/71
31/71
31/71
32/71
32/71
32/71
32/71
33/71
33/71
34/71
◮ Universal MC:
◮ Existential MC:
34/71
◮ Universal MC:
◮ Existential MC:
34/71
◮ Universal MC:
◮ Existential MC:
35/71
s∈S
∈ℓ(s)
35/71
s∈S
∈ℓ(s)
35/71
s∈S
∈ℓ(s)
36/71
1
1
2
2
n
n
k → ¬aij W sk)
k → ¬aij W sk)
j) ∧ (¬sj−1 U xf j )
36/71
1
1
2
2
n
n
k → ¬aij W sk)
k → ¬aij W sk)
j) ∧ (¬sj−1 U xf j )
36/71
1
1
2
2
n
n
k → ¬aij W sk)
k → ¬aij W sk)
j) ∧ (¬sj−1 U xf j )
36/71
1
1
2
2
n
n
k → ¬aij W sk)
k → ¬aij W sk)
j) ∧ (¬sj−1 U xf j )
37/71
37/71
37/71
38/71
◮ Q: finite set of states ◮ Σ: finite set of labels ◮ I ⊆ Q: set of initial states ◮ T ⊆ Q × Σ × Q: transitions ◮ F ⊆ Q: set of accepting states (repeated, final)
38/71
◮ Q: finite set of states ◮ Σ: finite set of labels ◮ I ⊆ Q: set of initial states ◮ T ⊆ Q × Σ × Q: transitions ◮ F ⊆ Q: set of accepting states (repeated, final)
39/71
◮ Σp = {a ∈ Σ | p ∈ a}
◮ Σp∧q = Σp ∩ Σq
◮ Σp∧¬q = Σp \ Σq
39/71
◮ Σp = {a ∈ Σ | p ∈ a}
◮ Σp∧q = Σp ∩ Σq
◮ Σp∧¬q = Σp \ Σq
39/71
◮ Σp = {a ∈ Σ | p ∈ a}
◮ Σp∧q = Σp ∩ Σq
◮ Σp∧¬q = Σp \ Σq
39/71
◮ Σp = {a ∈ Σ | p ∈ a}
◮ Σp∧q = Σp ∩ Σq
◮ Σp∧¬q = Σp \ Σq
40/71
40/71
40/71
40/71
40/71
41/71
41/71
41/71
42/71
◮ Union: trivial ◮ Intersection: easy (exercice) ◮ complement: hard
43/71
◮ Construct a B¨
◮ Construct a B¨
43/71
◮ Construct a B¨
◮ Construct a B¨
43/71
◮ Construct a B¨
◮ Construct a B¨
44/71
44/71
45/71
46/71
◮ ¬ X ϕ = X ¬ϕ ◮ ¬(ϕ U ψ) = (¬ϕ) R (¬ψ) ◮ ¬(ϕ R ψ) = (¬ϕ) U (¬ψ) ◮ ¬(ϕ ∨ ψ) = (¬ϕ) ∧ (¬ψ) ◮ ¬(ϕ ∧ ψ) = (¬ϕ) ∨ (¬ψ)
46/71
◮ ¬ X ϕ = X ¬ϕ ◮ ¬(ϕ U ψ) = (¬ϕ) R (¬ψ) ◮ ¬(ϕ R ψ) = (¬ϕ) U (¬ψ) ◮ ¬(ϕ ∨ ψ) = (¬ϕ) ∧ (¬ψ) ◮ ¬(ϕ ∧ ψ) = (¬ϕ) ∨ (¬ψ)
47/71
◮ formulas in Z are of the form p, ¬p, or X β, ◮ ⊥ /
◮ Vertices: subsets of NNF ◮ Edges: Let Y ⊆ NNF and let α ∈ Y maximal not reduced.
α
48/71
48/71
48/71
48/71
48/71
49/71
◮ Red(Y ) = {Z reduced | Y
∗
◮ Redα(Y ) = {Z reduced | Y
∗
◮ next(Z) = {α | X α ∈ Z} ◮ ΣZ =
◮ States: Q = 2sub(ϕ),
◮ Transitions: T = {Y
ΣZ
◮ Acceptance: Tα = {Y
ΣZ
49/71
◮ Red(Y ) = {Z reduced | Y
∗
◮ Redα(Y ) = {Z reduced | Y
∗
◮ next(Z) = {α | X α ∈ Z} ◮ ΣZ =
◮ States: Q = 2sub(ϕ),
◮ Transitions: T = {Y
ΣZ
◮ Acceptance: Tα = {Y
ΣZ
49/71
◮ Red(Y ) = {Z reduced | Y
∗
◮ Redα(Y ) = {Z reduced | Y
∗
◮ next(Z) = {α | X α ∈ Z} ◮ ΣZ =
◮ States: Q = 2sub(ϕ),
◮ Transitions: T = {Y
ΣZ
◮ Acceptance: Tα = {Y
ΣZ
50/71
50/71
50/71
50/71
50/71
50/71
50/71
50/71
51/71
◮ |Q| ≤ 2|ϕ| ◮ number of acceptance tables = number of until sub-formulas.
51/71
◮ |Q| ≤ 2|ϕ| ◮ number of acceptance tables = number of until sub-formulas.
51/71
◮ |Q| ≤ 2|ϕ| ◮ number of acceptance tables = number of until sub-formulas.
52/71
◮ Sistla & Clarke 85. Complexity of propositional temporal logics. JACM 32(3),
◮ Lichtenstein & Pnueli 85. Checking that finite state concurrent programs
◮ Gabbay, Pnueli, Shelah & Stavi 80. On the temporal analysis of fairness.
◮ Gabbay 87. The declarative past and imperative future: Executable temporal
53/71
1
2
3
54/71
55/71
◮ E: for some infinite run ◮ A: for all infinite run
◮ EF ϕ: ϕ is possible ◮ AG ϕ: ϕ is an invariant ◮ AF ϕ: ϕ is unavoidable ◮ EG ϕ: ϕ holds globally along some path
55/71
◮ E: for some infinite run ◮ A: for all infinite run
◮ EF ϕ: ϕ is possible ◮ AG ϕ: ϕ is an invariant ◮ AF ϕ: ϕ is unavoidable ◮ EG ϕ: ϕ holds globally along some path
56/71
56/71
56/71
57/71
57/71
58/71
◮
◮
◮
◮
◮
◮
58/71
◮
◮
◮
◮
◮
◮
58/71
◮
◮
◮
◮
◮
◮
58/71
◮
◮
◮
◮
◮
◮
59/71
59/71
59/71
60/71
◮ EF ϕ = E ⊤ U ϕ
◮ EG ϕ = ¬ AF ¬ϕ
60/71
◮ EF ϕ = E ⊤ U ϕ
◮ EG ϕ = ¬ AF ¬ϕ
61/71
61/71
61/71
61/71
61/71
61/71
61/71
62/71
◮ AX ϕ = ¬ EX ¬ϕ, ◮
◮ A G(req → F grant) = AG(req → AF grant) ◮ A G F ϕ = AG AF ϕ
◮ E F G ϕ = EF EG ϕ
◮ EG EF ϕ = E G F ϕ ◮ AF AG ϕ = A F G ϕ ◮ EG EX ϕ = E G X ϕ
62/71
◮ AX ϕ = ¬ EX ¬ϕ, ◮
◮ A G(req → F grant) = AG(req → AF grant) ◮ A G F ϕ = AG AF ϕ
◮ E F G ϕ = EF EG ϕ
◮ EG EF ϕ = E G F ϕ ◮ AF AG ϕ = A F G ϕ ◮ EG EX ϕ = E G X ϕ
62/71
◮ AX ϕ = ¬ EX ¬ϕ, ◮
◮ A G(req → F grant) = AG(req → AF grant) ◮ A G F ϕ = AG AF ϕ
◮ E F G ϕ = EF EG ϕ
◮ EG EF ϕ = E G F ϕ ◮ AF AG ϕ = A F G ϕ ◮ EG EX ϕ = E G X ϕ
62/71
◮ AX ϕ = ¬ EX ¬ϕ, ◮
◮ A G(req → F grant) = AG(req → AF grant) ◮ A G F ϕ = AG AF ϕ
◮ E F G ϕ = EF EG ϕ
◮ EG EF ϕ = E G F ϕ ◮ AF AG ϕ = A F G ϕ ◮ EG EX ϕ = E G X ϕ
62/71
◮ AX ϕ = ¬ EX ¬ϕ, ◮
◮ A G(req → F grant) = AG(req → AF grant) ◮ A G F ϕ = AG AF ϕ
◮ E F G ϕ = EF EG ϕ
◮ EG EF ϕ = E G F ϕ ◮ AF AG ϕ = A F G ϕ
◮ EG EX ϕ = E G X ϕ
63/71
63/71
64/71
65/71
66/71
67/71
◮ Each process is enabled infinitely often:
◮ No process stays ultimately in the critical section:
67/71
◮ Each process is enabled infinitely often:
◮ No process stays ultimately in the critical section:
67/71
◮ Each process is enabled infinitely often:
◮ No process stays ultimately in the critical section:
68/71
◮ Mk, 2k |
◮ If ϕ ∈ CTL and |ϕ| ≤ m ≤ k then Mk, 2k |
68/71
2k 2k − 1 2k − 2 2k − 3 · · · 4 3 2 1 p p p p ¬p ¬p ¬p ¬p
◮ Mk, 2k |
◮ If ϕ ∈ CTL and |ϕ| ≤ m ≤ k then Mk, 2k |
68/71
2k 2k − 1 2k − 2 2k − 3 · · · 4 3 2 1 p p p p ¬p ¬p ¬p ¬p
◮ Mk, 2k |
◮ If ϕ ∈ CTL and |ϕ| ≤ m ≤ k then Mk, 2k |
69/71
69/71
69/71
70/71
70/71
71/71
◮ Symbolic model checking for CTL using BDDs. ◮ µ- calculus ◮ . . .