Model Check
Model Check
1
Temporal Logic Model Checking
2
Why Model Checking?
Advantages:
No proofs!!!
Fast
Counterexamples
No problem with partial specifications
Logics can easily express many concurrency properties
3
Model of Computation
a b
State Transition Graph or
Kripke Model
b c c
a b
b c c
a b c c
4
Model of Computation (Cont.)
5
Computation Tree Logics
6
The Logic CTL
1. Path quantifier:
A—“for every path”
E—“there exists a path”
2. Linear-time operators:
Xp—p holds next time.
Fp—p holds sometime in the future
Gp—p holds globally in the future
pUq—p holds until q holds
7
Path Formulas and State Formulas
8
State Formulas (Cont.)
1. s j= p , p 2 L(s).
2. s j= :f1 , s 6j= f1.
3. s j= f1 _ f2, s j= f1 or s j= f2.
4. s j= E(g) , there exists a path starting with
s such that j= g.
9
Path Formulas (Cont.)
10
Standard Abbreviations
A(f ) : E(:f )
Ff U truef
Gf :F:f
11
CTL and LTL
12
Expressive Power
13
Basic CTL Operators
14
Basic CTL Operators
The four most widely used CTL operators are illustrated below.
Each computation tree has the state s0 as its root.
g g g
g g g g g g
. . . . . . . .
. . . . . . . .
. . . . . . . .
M; s0 j= AG g M; s0 j= AF g
g
g g
. . . . . . . .
. . . . . . . .
. . . . . . . .
M; s0 j= EF g M; s0 j= EG g
15
Typical CTL Formulas
16
Model Checking Problem
M; s j= f
17
Explicit Traversal
CTL formulas
18
Symbolic Model Checking
19
Symbolic Model Checking with BDDs
20
Fixpoint Algorithms
EF p = p _ EX EF p
p
21
Fixpoint Algorithms (cont.)
Key properties of EF p:
1. EF p = p _ EX EF p
2. U = p _ EX U implies EF p U
How to compute EF p:
U0 = False
U1 _
= p EX U0
U2 _
= p EX U1
U3 _
= p EX U2
..
22
= EF
M; s0 j ?
p
s
0
U0 = ;
23
= EF
M; s0 j ?
p
s
0
U1 = p _ EX U0
24
= EF
M; s0 j ?
p
s
0
U2 = p _ EX U1
25
= EF
M; s0 j ?
p
s
0
U3 = p _ EX U2
26
Ordered Binary Decision Trees and Diagrams
a
1
0 1
b b
1 1
0 0 1
1
a a a a
aa 22 aa 22 aa 2 aa 2
2 2 22 22
0 1 0 1 0 1 0 1
b b b b b b b b
2 b 2 2 b 2 2 b 2 2 b 2
1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1
27
From Binary Decision Trees to Diagrams
28
OBDD for Comparator Example
a
1
0 1
b 1 b
1 1
a 1 0
2
1
0
b b
2 1 2
0
0 1
1 0
29
Variable Ordering Problem
aa1
1
0 1
a aa
2 22
0 1 0 1
b 0 b b 1 b
1 1 1 1
0 1 0
1
1 0
1
b b
2 2
0
0
1
1
1 0
30
Variable Ordering Problem (Cont.)
31
Logical operations on OBDD’s
32
Logical operations (cont.)
33
Symbolic Model Checking Algorithm
34
Symbolic Model Checking (cont.)
a a, b
(a ^ :b ^ a0 ^ b0)
_ (a ^ b ^ a0 ^ b0)
_ (a ^ b ^ a0 ^ :b0)
Now, represent as an OBDD!
35
Symbolic Model Checking (cont.)
Consider f = EX p.
36
Symbolic Model Checking (cont.)
EF p = Lfp U: p _ EX U
Introduce state variables:
37
Notable Examples
38
Notable Examples–IEEE Futurebus+
39
Notable Examples–HDLC
40
Notable Examples–PowerPC 620
Microprocessor
41
Problems with BDDs
42
Advantages of SAT Procedures
43
Bounded Model Checking
45
Example To Illustrate New Technique
00 11
01 10
47
Example (Cont.)
48
Example (Cont.)
49
Example (Cont.)
50
Example (Cont.)
51
Example (Cont.)
52
General Translation
53
Complexity
54
General Strategy
To construct [[ M; f ]]k :
55
Sequential Multiplier Example
56
DME Example
57
“Buggy” DME Example
58
Queue Example
59
Combinational Circuit Example
60
Model Checking with the
Partial Order Reduction
61
Asynchronous Computation
62
The State Explosion Problem
1 3
2
? R
3
2 1
? 3R 1 R ?2
3 2
R ? 1
63
Partial Order Reduction
s
R
s1 s2
R
r
64
Partial Order Reduction (Cont.)
The full state graph, which may be too big to fit in memory, is
never constructed.
65
Partial Order Reduction (Cont.)
D. Peled. All from one, one for all: on model checking using
representatives. In Proc. 5th Workshop on Comput.-Aided
Verification, pages 409–423, 1993.
66
Modified Kripke Structures
the set of states S , the set of initial states S0, and the labeling
function L are defined as for Kripke structures, and
68
Basic Definitions (Cont.)
69
Reduced State Graph
70
Depth-First-Search Algorithm
1 hash(s0);
2 set on stack (s0 );
3 expand state(s0 );
71
Depth-First-Search Algorithm (Cont.)
72
Depth-First-Search Algorithm (Cont.)
73
Ample Sets
74
Dependence and Independence
Note
75
Potential Problems
s
R
s1 s2
R
r
76
Visible and Invisible Transitions
Let L : S ! 2AP be the function that labels each state with a set
of atomic propositions.
77
Stuttering Equivalence
= s0 !0
s1 ! 1
: : : and = r0 !
0
r1 !
1
:::
Then and are stuttering equivalent, denoted st , if there
are two infinite sequences of integers
78
Stuttering Equivalence (Cont.)
p; q p; q p; :q :p; :q :p; :q p; :q
p; q p; :q p; :q p; :q :p; :q p; :q
79
Stuttering Equivalence Example
s
R
s1 s2
R
r
80
LTL and Stuttering Equivalence
A
An LTL formula f is invariant under stuttering if and only if
for each pair of paths and 0 such that st 0,
j= f if and only if 0 j= f:
We denote the subset of the logic LTL without the next time
operator by LTL X .
81
Stuttering Equivalent Structures
82
DFS Algorithm and Ample Sets
83
Correctness of Reduction
Intuitively, if the state has at least one successor, then the reduced
state graph also contains a successor for this state.
84
Correctness of Reduction (Cont.)
C1 Along every path in the full state graph that starts at s, the
following condition holds:
A transition that is dependent on a transition in ample(s) can
not be executed without one in ample(s) occurring first.
85
Correctness of Reduction (Cont.)
Proof:
Let
2 enabled(s) n ample(s).
Suppose that (
; ) 2 D, where 2 ample(s).
Since
is enabled in s, there is a path starting with
in the full
graph.
But then a transition dependent on some transition in ample(s) is
executed before a transition in ample(s).
This contradicts condition C1.
86
Correctness of Reduction (Cont.)
87
Correctness of Reduction (Cont.)
88
Correctness of Reduction (Cont.)
Thus, if the reduced state graph does not contain the sequence
01 : : : m that reaches r, we can construct from s another
sequence that reaches r.
s = s0
0
s1
1 r0
s2 0
2 r1
1
sm m
2 r2
m
r = rm
89
Another Correctness Condition
90
Correctness of Reduction (Cont.)
91
Problem with Correctness Conditions
92
Problem with Correctness Condition (Cont.)
But, the reduced state graph does not contain any sequences
where p is changed from true to false!!
93
Cycle Closing Condition
Note that at each state on the cycle (s1 ; s2; s3; s1) is deferred to
a possible future state.
94
Problem 1 Again
R
r
95
Problem 2 Again
96
Heuristics for Ample Sets
97
Heuristics for Ample Sets (Cont.)
Two send transitions that use the same message queue are
dependent. Similarly, two receive transitions are dependent.
Note that a transition that involves handshaking or rendezvous
communication as in CSP or ADA can be treated as a joint
transition of both processes. Therefore, it depends on all of the
transitions of both processes.
98
Heuristics for Ample Sets (Cont.)
There are two cases in which this selection might violate C1.
In both of these cases, some transitions independent of those
in Ti (s) are executed, eventually enabling a transition that is
dependent on Ti(s).
99
Heuristics for Ample Sets (First Case)
100
Heuristics for Ample Sets (Second Case)
101
If all else fails : : :
102
Future Research Directions
104