Dr. Falak Sher on Model Checking
Dr. Falak Sher on Model Checking
February 4, 2019
Dr. Falak Sher (ITU Punjab) Introduction to Model Checking September 11, 2017 1/2
Acknowledgement
Dr. Falak Sher (ITU Punjab) Introduction to Model Checking September 11, 2017 2/2
Overview overview2.1
Introduction
Modelling parallel systems
Transition systems ←−
Modeling hard- and software systems
Parallelism and communication
Linear Time Properties
Regular Properties
Linear Temporal Logic
Computation-Tree Logic
Equivalences and Abstraction
1 / 628
Transition systems Transsys/ts1.4-1
real system
semantics
abstraction y
semantic model
2 / 628
Transition systems Transsys/ts1.4-1
real system
x
semantics implementation
abstraction y refinement
semantic model
3 / 628
Transition systems Transsys/ts1.4-1
real system
x
semantics implementation
abstraction y refinement
semantic model
The semantic model yields a formal representation of:
4 / 628
Transition systems Transsys/ts1.4-1
real system
x
semantics implementation
abstraction y refinement
semantic model
The semantic model yields a formal representation of:
• the states of the system
• the stepwise behaviour
• the initial states
5 / 628
Transition systems Transsys/ts1.4-1
real system
x
semantics implementation
abstraction y refinement
semantic model
The semantic model yields a formal representation of:
• the states of the system
↑
control component + information on “relevant” data
• the stepwise behaviour
• the initial states
6 / 628
Transition systems =
b extended digraphs Transsys/ts1.4-1
real system
x
semantics implementation
abstraction y refinement
semantic model
The semantic model yields a formal representation of:
• the states of the system ←− nodes
↑
control component + information on “relevant” data
• the stepwise behaviour ←− edges
• the initial states
7 / 628
Transition systems =
b extended digraphs Transsys/ts1.4-1
real system
x
semantics implementation
abstraction y refinement
semantic model
The semantic model yields a formal representation of:
• the states of the system ←− nodes
↑
control component + information on “relevant” data
• the stepwise behaviour ←− transitions
• the initial states
8 / 628
Transition systems =
b extended digraphs Transsys/ts1.4-1
real system
x
semantics implementation
abstraction y refinement
semantic model
The semantic model yields a formal representation of:
• the states of the system ←− nodes
• the stepwise behaviour ←− transitions
• the initial states
• additional information on
communication
state properties
9 / 628
Transition systems =
b extended digraphs Transsys/ts1.4-1
real system
x
semantics implementation
abstraction y refinement
semantic model
The semantic model yields a formal representation of:
• the states of the system ←− nodes
• the stepwise behaviour ←− transitions
• the initial states
• additional information on
communication ←− actions
state properties ←− atomic proposition
10 / 628
Transition system (TS) ts1.4-TS-def
11 / 628
Transition system (TS) ts1.4-TS-def
12 / 628
Transition system (TS) ts1.4-TS-def
13 / 628
Transition system (TS) ts1.4-TS-def
14 / 628
Transition system (TS) ts1.4-TS-def
15 / 628
Transition system (TS) ts1.4-TS-def
16 / 628
Transition system (TS) ts1.4-TS-def
pay
select
coke sprite
18 / 628
Transition system for beverage machine ts1.4-2
pay
select
coke sprite
19 / 628
Transition system for beverage machine ts1.4-2
pay
get coke get sprite actions:
coin coin
τ
select
τ τ get sprite
sprite get coke
coke
state space S = {pay , select, coke, sprite}
set of initial states: S0 = {pay }
20 / 628
Transition system for beverage machine ts1.4-2
pay
get coke get sprite actions:
coin coin
τ
select
τ τ get sprite
sprite get coke
coke
state space S = {pay , select, coke, sprite}
set of initial states: S0 = {pay }
set of atomic propositions: AP = {pay , drink}
labeling function: L(coke) = L(sprite) = {drink}
L(pay ) = {pay }}, L(select) = ∅
21 / 628
Transition system for beverage machine ts1.4-2
pay
get coke get sprite actions:
coin coin
τ
select
τ τ get sprite
sprite get coke
coke
state space S = {pay , select, coke, sprite}
set of initial states: S0 = {pay }
set of atomic propositions: AP = S
labeling function: L(s) = {s} for each state s
22 / 628
“Behaviour” of transition systems ts1.4-3
23 / 628
“Behaviour” of transition systems ts1.4-3
24 / 628
“Behaviour” of transition systems ts1.4-3
26 / 628
Possible meanings of nondeterminism in TS ts1.4-3a
27 / 628
Transition system for parallel actions ts1.4-4
28 / 628
Transition system for parallel actions ts1.4-4
29 / 628
Transition system for parallel actions ts1.4-4
30 / 628
Transition system for parallel actions ts1.4-4
31 / 628
parallel execution of independent actions ← interleaving
x =0
α y =5 β
x =1 x = 0 x := x+1 ||| y := y −3
y =5 y = 2 | {z } | {z }
β x =1 α action α action β
y =2
32 / 628
parallel execution of independent actions ← interleaving
x =0
α y =5 β
x =1 x = 0 x := x+1 ||| y := y −3
y =5 y = 2 | {z } | {z }
β x =1 α action α action β
y =2
parallel execution of dependent actions ← competition
33 / 628
parallel execution of independent actions ← interleaving
x =0
α y =5 β
x =1 x = 0 x := x+1 ||| y := y −3
y =5 y = 2 | {z } | {z }
β x =1 α action α action β
y =2
parallel execution of dependent actions ← competition
x =0
α y =0 β
x =1 x =0 x| :={zx+1} ||| y := 2∗x
y =0 y =0 | {z }
action α action β
β α
x =1 x =1
y =2 y =0
34 / 628
Possible meanings of nondeterminism in TS ts1.4-4a
35 / 628
Implementation freedom ts1.4-5
36 / 628
Implementation freedom ts1.4-5
fax
unknown
sender receiver
email
37 / 628
Implementation freedom ts1.4-5
fax
unknown
sender receiver
email
realization by a TS:
generate message
... ...
38 / 628
Implementation freedom ts1.4-5
fax
unknown
sender receiver
email
realization by a TS:
generate message
... ...
fax
known without
sender HH receiver email access
email
H
HH
realization by a TS:
generate message
... ...
fax
known without
sender HH receiver email access
email
H
HH
42 / 628
Underspecification ts1.4-6
produce message
try to send
lost delivered
43 / 628
Underspecification ts1.4-6
produce message
try to send
44 / 628
Possible meanings of nondeterminism in TS ts1.4-6a
45 / 628
Possible meanings of nondeterminism in TS ts1.4-6a
46 / 628
Incomplete information on the environment ts1.4-7
off
on
0 1 ... 9 menu
47 / 628
Incomplete information on the environment ts1.4-7
off
on
0 1 ... 9 menu
48 / 628
Possible meanings of nondeterminism in TS ts1.4-8
concurrency (interleaving) α β
α ||| β is represented by
β α
competitions x=0
Introduction
Modelling parallel systems
Transition systems
Modeling hard- and software systems ←−
Parallelism and communication
Linear Time Properties
Regular Properties
Linear Temporal Logic
Computation-Tree Logic
Equivalences and Abstraction
50 / 628
Model checking ts1.4-9
transition
specification spec
system T
model checker
does T satisfy spec ?
specification spec
transition
system T
model checker
does T satisfy spec ?
transition
system T
model checker
does T satisfy spec ?
x1 , . . . , xn y1 , . . . , ym
input bits circuit output bits
register r1, . . . , rk
54 / 628
Modelling of sequential circuits by TS ts1.4-10
x1 , . . . , xn y1 , . . . , ym output
input bits circuit functions
λ1 , . . . , λm
transition
functions
δ1 , . . . , δk
register r1, . . . , rk
55 / 628
Modelling of sequential circuits by TS ts1.4-10
x1 , . . . , xn y1 , . . . , ym output
input bits circuit functions
λ1 , . . . , λm
transition
functions
δ1 , . . . , δk
register r1, . . . , rk
56 / 628
Modelling of sequential circuits by TS ts1.4-10
x1 , . . . , xn y1 , . . . , ym output
input bits circuit functions
λ1 , . . . , λm
transition
functions
δ1 , . . . , δk
register r1, . . . , rk
57 / 628
Modelling of sequential circuits by TS ts1.4-10
x1 , . . . , xn y1 , . . . , ym output
input bits circuit functions
λ1 , . . . , λm
transition
functions
δ1 , . . . , δk
register r1, . . . , rk
58 / 628
Modelling of sequential circuits by TS ts1.4-10
x1 , . . . , xn y1 , . . . , ym output
input bits circuit functions
λ1 , . . . , λm
transition
functions
δ1 , . . . , δk
register r1, . . . , rk
59 / 628
Modelling of sequential circuits by TS ts1.4-10
x1 , . . . , xn y1 , . . . , ym output
input bits circuit functions
λ1 , . . . , λm
transition
functions
δ1 , . . . , δk
register r1, . . . , rk
60 / 628
Modelling of sequential circuits by TS ts1.4-10
x1 , . . . , xn y1 , . . . , ym output
input bits circuit functions
λ1 , . . . , λm
transition
functions
δ1 , . . . , δk
register r1, . . . , rk
61 / 628
Modelling of sequential circuits by TS ts1.4-10
x1 , . . . , xn y1 , . . . , ym output
input bits circuit functions
λ1 , . . . , λm
transition
functions
δ1 , . . . , δk
register r1, . . . , rk
63 / 628
Example: sequential circuit ts1.4-11a
transition function: δr = x ∨ r
64 / 628
Example: TS for sequential circuit ts1.4-11
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
65 / 628
Example: TS for sequential circuit ts1.4-11
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
66 / 628
Example: TS for sequential circuit ts1.4-11
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
x=0 r =0 x=1 r =0
x=0 r =1 x=1 r =1
67 / 628
Example: TS for sequential circuit ts1.4-11
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
x=0 r =0 x=1 r =0
x=0 r =1 x=1 r =1
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
x=0 r =0 x=1 r =0
x=0 r =1 x=1 r =1
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
x=0 r =0 x=1 r =0
x=0 r =1 x=1 r =1
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
x=0 r =0 x=1 r =0
x=0 r =1 x=1 r =1
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
{y }
x=0 r =0 x=1 r =0
x=0 r =1 x=1 r =1
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
{y } {x}
x=0 r =0 x=1 r =0
x=0 r =1 x=1 r =1
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
{y } {x}
x=0 r =0 x=1 r =0
x=0 r =1 x=1 r =1
{r }
initial register evaluation: r =0
74 / 628
Example: TS for sequential circuit ts1.4-11
output function
λy = ¬(x ⊕ r )
transition function
δr = x ∨ r
transition system
{y } {x}
x=0 r =0 x=1 r =0
x=0 r =1 x=1 r =1
{r } {x, r , y }
initial register evaluation: r =0
75 / 628
How many states . . . ts1.4-12
1000 gates y
1 output bit
r1, . . . , r100 no input
100 registers
76 / 628
How many states . . . ts1.4-12
1000 gates y
1 output bit
r1, . . . , r100 no input
100 registers
answer: 2100
77 / 628
How many states . . . ts1.4-12
1000 gates y
1 output bit
r1, . . . , r100 no input
100 registers
answer: 2100
x ...
no output
1 input bit
r1 , . . . , r100 100 registers
78 / 628
How many states . . . ts1.4-12
1000 gates y
1 output bit
r1, . . . , r100 no input
100 registers
answer: 2100
x ...
no output
1 input bit
r1 , . . . , r100 100 registers
answer: 2100 ∗ 21 = 2101
79 / 628
Data-dependent systems ts1.4-13
80 / 628
Data-dependent systems ts1.4-13
81 / 628
Data-dependent systems ts1.4-13
82 / 628
Data-dependent systems ts1.4-13
83 / 628
Data-dependent systems ts1.4-13
initially: x = 22, y = 0
ℓ1→ WHILE x > 0 DO
x := x−1
ℓ2→ y := y +1
OD
ℓ3→ . . .
program graph
y :=y +1 if x ≤ 0
ℓ1
ℓ3
ℓ2 if x > 0 then
x := x−1
86 / 628
Example: TS for sequential program ts1.4-14
initially: x = 22, y = 0 ℓ1 x = 2 y = 0
ℓ1→ WHILE x > 0 DO
x := x−1 ℓ2 x = 1 y = 0
ℓ2→ y := y +1
OD
ℓ3→ . . . ℓ1 x = 1 y = 1
program graph
ℓ2 x = 0 y = 1
y :=y +1 if x ≤ 0
ℓ1
ℓ1 x = 0 y = 2
ℓ3
ℓ2 if x > 0 then
x := x−1 ℓ3 x = 0 y = 2
87 / 628
Example: TS for sequential program ts1.4-14
initially: x = 22, y = 0 ℓ1 x = 2 y = 0
ℓ1→ WHILE x > 0 DO α
x := x−1 ← action α ℓ2 x = 1 y = 0
ℓ2→ y := y +1 ← action β β
OD
ℓ3→ . . . ℓ1 x = 1 y = 1
α
program graph
ℓ2 x = 0 y = 1
ℓ1 if x ≤ 0 then β
β loop exit
ℓ1 x = 0 y = 2
ℓ2 ℓ3 loop exit
if x > 0
then α ℓ3 x = 0 y = 2
88 / 628
Typed variables Transsys/pc2.2-typed-variables
89 / 628
Typed variables Transsys/pc2.2-typed-variables
90 / 628
Typed variables Transsys/pc2.2-typed-variables
91 / 628
Typed variables Transsys/pc2.2-typed-variables
92 / 628
Typed variables Transsys/pc2.2-typed-variables
94 / 628
Conditions on typed variables pc2.2-typed-cond
95 / 628
Conditions on typed variables pc2.2-typed-cond
96 / 628
Conditions on typed variables pc2.2-typed-cond
98 / 628
Effect-function for actions pc2.2-typed-effect
99 / 628
Effect-function for actions pc2.2-typed-effect
x:=2x+y ” then:
if α is “x:=2x+y
Effect(α, [x=1, yy=3,
=3, . . . ]) = [x=5, yy=3,
=3, . . . ]
100 / 628
Effect-function for actions pc2.2-typed-effect
x:=2x+y ” then:
if α is “x:=2x+y
Effect(α, [x=1, yy=3,
=3, . . . ]) = [x=5, yy=3,
=3, . . . ]
x:=2x+y ; y :=1−x
if β is “x:=2x+y :=1−x” then:
Effect(β, [x=1, y =3, . . . ]) = [x=5, y =−4, . . . ]
101 / 628
Effect-function for actions pc2.2-typed-effect
x:=2x+y ” then:
if α is “x:=2x+y
Effect(α, [x=1, yy=3,
=3, . . . ]) = [x=5, yy=3,
=3, . . . ]
x:=2x+y ; y :=1−x
if β is “x:=2x+y :=1−x” then:
Effect(β, [x=1, y =3, . . . ]) = [x=5, y =−4, . . . ]
(x, yy)) := (2x+y , 1−x)
if γ is “(x, 1−x)” then:
Effect(γ, [x=1, yy=3,
=3, . . . ]) = [x=5, yy=0,
=0, . . . ]
102 / 628
Program graph (PG) Transsys/ts-program-graph-def-1
103 / 628
Program graph (PG) Transsys/ts-program-graph-def
104 / 628
Program graph (PG) Transsys/ts-program-graph-def
105 / 628
Program graph (PG) Transsys/ts-program-graph-def
106 / 628
Program graph (PG) Transsys/ts-program-graph-def
107 / 628
Program graph (PG) Transsys/ts-program-graph-def
108 / 628
Program graph (PG) Transsys/ts-program-graph-def
110 / 628
Program graph (PG) Transsys/ts-program-graph-def
112 / 628
Program graph (PG) Transsys/ts-program-graph-def
115 / 628
TS-semantics of a program graph ts-PG-sem
116 / 628
TS-semantics of a program graph ts-PG-sem
117 / 628
TS-semantics of a program graph ts-program-graph-sem
118 / 628
TS-semantics of a program graph ts-program-graph-sem
119 / 628
TS-semantics of a program graph ts-program-graph-sem
120 / 628
TS-semantics of a program graph ts-program-graph-sem
121 / 628
Structured operational semantics (SOS) ts-PG-SOS
premise
conclusion
122 / 628
Structured operational semantics (SOS) ts-PG-SOS
124 / 628
Labeling of the states ts-PG-lab
125 / 628
Labeling of the states ts-PG-lab
by Dijkstra
128 / 628
Guarded Command Language (GCL) ts1.4-15
by Dijkstra
129 / 628
Guarded Command Language (GCL) ts1.4-15
by Dijkstra
130 / 628
Guarded Command Language (GCL) ts1.4-15
131 / 628
Guarded Command Language (GCL) ts1.4-15
132 / 628
Guarded Command Language (GCL) ts1.4-15
repetitive command/loop:
DO :: g ⇒ stmt OD
133 / 628
Guarded Command Language (GCL) ts1.4-15
repetitive command/loop:
DO :: g ⇒ stmt OD ← WHILE g DO stmt OD
134 / 628
Guarded Command Language (GCL) ts1.4-15
repetitive command/loop:
DO :: g ⇒ stmt OD ← WHILE g DO stmt OD
conditional command:
IF :: g ⇒ stmt1
:: ¬g ⇒ stmt2
FI
135 / 628
Guarded Command Language (GCL) ts1.4-15
repetitive command/loop:
DO :: g ⇒ stmt OD ← WHILE g DO stmt OD
conditional command:
IF :: g ⇒ stmt1 IF g THEN stmt1
:: ¬g ⇒ stmt2 ← ELSE stmt2
FI FI
136 / 628
Guarded Command Language (GCL) ts1.4-15
repetitive command/loop:
DO :: g ⇒ stmt OD ← WHILE g DO stmt OD
conditional command:
IF :: g ⇒ stmt1 IF g THEN stmt1
:: ¬g ⇒ stmt2 ← ELSE stmt2
FI FI
137 / 628
Guarded Command Language (GCL) ts1.4-16
138 / 628
Guarded Command Language (GCL) ts1.4-16
140 / 628
GCL-program for beverage machine pc2.1-GCL-getraenkeautomat
141 / 628
GCL-program for beverage machine pc2.1-GCL-getraenkeautomat
142 / 628
GCL-program for beverage machine pc2.1-GCL-getraenkeautomat
143 / 628
GCL-program for beverage machine pc2.1-GCL-getraenkeautomat
144 / 628
GCL-program for beverage machine pc2.1-GCL-getraenkeautomat
FI
:: true ⇒ #sprite := max; #coke := max
OD
146 / 628
GCL-program for beverage machine pc2.1-GCL-2
FI
:: true ⇒ #sprite := max; #coke := max
OD
147 / 628
GCL-program for beverage machine pc2.1-GCL-2
FI
:: true ⇒ #sprite := max; #coke := max
OD
148 / 628
GCL-program for beverage machine pc2.1-GCL-2
149 / 628
GCL-program for beverage machine pc2.1-GCL-2
150 / 628
GCL-program for beverage machine pc2.1-GCL-2
FI
:: true ⇒ refill
OD
151 / 628
GCL-program for beverage machine pc2.1-GCL-2
152 / 628
GCL-program for beverage machine pc2.1-GCL-2
start start
insert coin insert get
coinsprite
selectget coke select
get coke startget sprite
start start
insert coin insert coin insert coin
select get sprite selectget sprite select