• Non ci sono risultati.

Introduction to Formal Methods Chapter 04: CTL Model Checking

N/A
N/A
Protected

Academic year: 2021

Condividi "Introduction to Formal Methods Chapter 04: CTL Model Checking"

Copied!
65
0
0

Testo completo

(1)

Introduction to Formal Methods Chapter 04: CTL Model Checking

Roberto Sebastiani

DISI, Università di Trento, Italy – roberto.sebastiani@unitn.it URL: http://disi.unitn.it/rseba/DIDATTICA/fm2020/

Teaching assistant:Enrico Magnago– enrico.magnago@unitn.it

CDLM in Informatica, academic year 2019-2020

last update: Monday 18thMay, 2020, 14:48

Copyright notice: some material (text, figures) displayed in these slides is courtesy of R. Alur, M. Benerecetti, A. Cimatti, M.

Di Natale, P. Pandya, M. Pistore, M. Roveri, and S.Tonetta, who detain its copyright. Some exampes displayed in these slides are taken from [Clarke, Grunberg & Peled, “Model Checking”, MIT Press], and their copyright is detained by the authors. All the other material is copyrighted by Roberto Sebastiani. Every commercial use of this material is strictly forbidden by the copyright laws without the authorization of the authors. No copy of these slides can be displayed in public

without containing this copyright notice.

(2)

Outline

1

CTL Model Checking: general ideas

2

CTL Model Checking: a simple example

3

Some theoretical issues

4

CTL Model Checking: algorithms

5

CTL Model Checking: some examples

6

A relevant subcase: invariants

7

Exercises

(3)

CTL Model Checking

CTL Model Checking is a formal verification technique where...

...the system is represented as a Finite State Machine M:

p q

1

2

3 4

p

...the property is expressed a CTL formula ϕ:

AG(p → AFq)

...the model checking algorithm checks whether in all initial states

of M all the executions of the model satisfy the formula (M |= ϕ).

(4)

CTL Model Checking: General Idea

Two macro-steps:

1 construct the set of states where the formula holds:

[ϕ] := {s ∈ S : M, s |= ϕ}

([ϕ] is called the denotation of ϕ)

2 then compare with the set of initial states:

I ⊆ [ϕ] ?

(5)

CTL Model Checking: General Idea [cont.]

In order to compute [ϕ]:

proceed “bottom-up” on the structure of the formula, computing [ϕ

i

] for each subformula ϕ

i

of AG(p → AFq):

[q], [AFq], [p],

[p →AFq], [AG(p → AFq)]

(6)

CTL Model Checking: General Idea [cont.]

In order to compute each [ϕ

i

]:

assign Propositional atoms by labeling function handle Boolean operators by standard set operations

handle temporal operators AX, EX by computing pre-images

handle temporal operators AG, EG, AF, EF, AU, EU, by (implicitly)

applying tableaux rules, until a fixpoint is reached

(7)

Tableaux rules: a quote

“After all... tomorrow is another day."

[Scarlett O’Hara, “Gone with the Wind”]

(8)

CTL Model Checking: Example: AG(p → AFq)

p q 1

2

3 4

p

p q 1

2

3 4

p

"q" "AF q"

Recall the AF tableau rule: AFq ↔ (q ∨ AXAFq) Iteration: [AFq]

(1)

= [q]; [AFq]

(i+1)

= [q] ∪ AX[AFq]

(i)

[AFq](1)= [q] = {2}

[AFq](2)= [q ∨AXq] = {2} ∪ {1} = {1, 2}

[AFq](3)= [q ∨AX(q ∨ AXq)] = {2} ∪ {1} = {1, 2}

=⇒(fix point reached)

(9)

CTL Model Checking: Example: AG(p → AFq) [cont.]

p q 1

2

3 4

p

p q 1

2

3 4

p

p q 1

2

3 4

p

"p"

"AF q"

"p −> AF q"

(10)

CTL Model Checking: Example: AG(p → AFq) [cont.]

p q 1

2

3 4

p

p q 1

2

3 4

p

"p −> AF q" "AG(p −> AF q)"

Recall the AG tableau rule: AGϕ ↔ (ϕ ∧ AXAGϕ) Iteration: [AGϕ

(1)

] = [ϕ]; [AGϕ]

(i+1)

= [ϕ] ∩ AX[AGϕ]

(i)

1 [AGϕ](1)= [ϕ] = {1, 2, 4}

2 [AGϕ](2)= [ϕ] ∩AX[AGϕ](1)= {1, 2, 4} ∩ {1, 3} = {1}

3 [AGϕ](3)= [ϕ] ∩AX[AGϕ](2)= {1, 2, 4} ∩ {} = {}

=⇒(fix point reached)

(11)

CTL Model Checking: Example: AG(p → AFq) [cont.]

The set of states where the formula holds is empty

=⇒ the initial state does not satisfy the property

=⇒ M 6|= AG(p → AFq)

Counterexample: a lazo-shaped path: 1, 2, {3, 4}

ω

(satisfying EF(p ∧ EG¬q))

Note

Counter-example reconstruction in general is not trivial, based on

intermediate sets.

(12)

The fixed-point theory of lattice of sets

Definition

For any finite set S, the structure (2

S

, ⊆) forms a complete lattice with ∪ as join and ∩ as meet operations.

A function F : 2

S

7−→ 2

S

is monotonic provided

S

1

⊆ S

2

⇒ F (S

1

) ⊆ F (S

2

).

(13)

Fixed Points

Definition

Let h2

S

, ⊆i be a complete lattice, S finite.

Given a function F : 2

S

7−→ 2

S

, a ⊆ S is a fixed point of F iff F (a) = a

a is a least fixed point (LFP) of F , written µx .F (x ), iff, for every other fixed point a

0

of F , a ⊆ a

0

a is a greatest fixed point (GFP) of F , written νx .F (x ), iff, for every

other fixed point a

0

of F , a

0

⊆ a

(14)

Iteratively computing fixed points

Tarski’s Theorem

A monotonic function over a complete finite lattice has a least and a greatest fixed point.

(A corollary of) Kleene’s Theorem

A monotonic function F over a complete finite lattice has a least and a greatest fixed point, which can be computed as follows:

the least fixed point of F is the limit of the chain

∅ ⊆ F (∅) ⊆ F (F (∅)) . . . ,

the greatest fixed point of F is the limit of chain S ⊇ F (S) ⊇ F (F (S)) . . .

Since 2

S

is finite, convergence is obtained in a finite number of steps.

(15)

CTL Model Checking and Lattices

If M = hS, I, R, L, APi is a Kripke structure, then h2

S

, ⊆i is a complete lattice

We identify ϕ with its denotation [ϕ]

=⇒ we can see logical operators as functions F : 2

S

7−→ 2

S

on the

complete lattice h2

S

, ⊆i

(16)

Denotation of a CTL formula ϕ: [ϕ]

Definition of [ϕ]

[ϕ] := {s ∈ S : M, s |= ϕ}

Recursive definition of [ϕ]

[true] = S

[false] = {}

[p] = {s|p ∈ L(s)}

[¬ϕ

1

] = S/[ϕ

1

] [ϕ

1

∧ ϕ

2

] = [ϕ

1

] ∩ [ϕ

2

]

[EXϕ] = {s | ∃s

0

∈ [ϕ] s.t. hs, s

0

i ∈ R}

[EGβ] = νZ .( [β] ∩ [EXZ ] )

[E(β

1

2

)] = µZ .( [β

2

] ∪ ([β

1

] ∩ [EXZ ]) )

(17)

Case EX

P PreImage(P)

[EXϕ] = {s | ∃s

0

∈ [ϕ] s.t. hs, s

0

i ∈ R}

[EXϕ] is said to be the Pre-image of [ϕ] (Preimage([ϕ])) Key step of every CTL M.C. operation

Note

Preimage() is monotonic: X ⊆ X

0

=⇒ Preimage(X ) ⊆ Preimage(X

0

)

(18)

Case EG

νZ .( [β] ∩ [EXZ ] ): greatest fixed point of the function F

β

: 2

S

7−→ 2

S

, s.t.

F

β

([ϕ]) = ([β] ∩ Preimage([ϕ])

= ([β] ∩ {s | ∃s

0

∈ [ϕ] s.t. hs, s

0

i ∈ R}) F

β

Monotonic: a ⊆ a

0

=⇒ F

β

(a) ⊆ F

β

(a

0

)

(Tarski’s theorem): νx .Fβ(x ) always exists

(Kleene’s theorem): νx .Fβ(x ) can be computed as the limit S ⊇ Fβ(S) ⊇ Fβ(Fβ(S)) ⊇ . . ., in a finite number of steps.

Theorem (Clarke & Emerson)

[EGβ] = νZ .( [β] ∩ [EXZ ] )

(19)

Case EG [cont.]

We can compute X := [EGβ] inductively as follows:

X

0

:= S

X

1

:= F

β

(S) = [β]

X

2

:= F

β

(F

β

(S)) = [β] ∩ Preimage(X

1

) . . .

X

j+1

:= F

βj+1

(S) = [β] ∩ Preimage(X

j

) Noticing that X

1

= [β] and X

j+1

⊆ X

j

for every j ≥ 0, and that

([β] ∩ Y ) ⊆ X

j

⊆ [β] =⇒ ([β] ∩ Y ) = (X

j

∩ Y ), we can use instead the following inductive schema:

X1 := [β]

Xj+1:=Xj∩ Preimage(Xj)

Xj

Y

[β]

(20)

Case EU

µZ .( [β

2

] ∪ ([β

1

] ∩ [EXZ ]) ): least fixed point of the function F

β12

: 2

S

7−→ 2

S

, s.t.

F

β12

([ϕ]) = [β

2

] ∪ ([β

1

] ∩ Preimage([ϕ]))

= [β

2

] ∪ ([β

1

] ∩ {s | ∃s

0

∈ [ϕ] s.t. hs, s

0

i ∈ R}) F

β12

Monotonic: a ⊆ a

0

=⇒ F

β12

(a) ⊆ F

β12

(a

0

)

(Tarski’s theorem): µx .Fβ12(x ) always exists

(Kleene’s theorem): µx .Fβ12(x ) can be computed as the limit

∅ ⊆ Fβ12(∅) ⊆Fβ12(Fβ12(∅)) ⊆ . . ., in a finite number of steps.

Theorem (Clarke & Emerson)

[E(β

1

2

)] = µZ .( [β

2

] ∪ ([β

1

] ∩ [EXZ ]) )

(21)

Case EU [cont.]

We can compute X := [E(β

1

2

)] inductively as follows:

X

0

:= ∅

X

1

:= F

β12

(∅) = [β

2

]

X

2

:= F

β12

(F

β12

(∅)) = [β

2

] ∪ ([β

1

] ∩ Preimage(X

1

)) . . .

X

j+1

:= F

βj+1

12

(∅)) = [β

2

] ∪ ([β

1

] ∩ Preimage(X

j

)) Noticing that X

1

= [β

2

] and X

j+1

⊇ X

j

for every

j ≥ 0, and that

([β

2

] ∪ Y ) ⊇ X

j

⊇ [β

2

] =⇒ ([β

2

] ∪ Y ) = (X

j

∪ Y ), we can use instead the following inductive schema:

X1 := [β2]

Xj+1:=Xj∪ ([β1] ∩Preimage(Xj))

Y Xj

2]

(22)

A relevant subcase: EF

EFβ = E(>Uβ)

[>] = S =⇒ [>] ∩ Preimage(X

j

) = Preimage(X

j

) We can compute X := [EFβ] inductively as follows:

X1 := [β]

Xj+1:=Xj∪ Preimage(Xj)

(23)

General Schema

Assume ϕ written in terms of ¬, ∧, EX, EU, EG A general M.C. algorithm (fix-point):

1. for every ϕi ∈ Sub(ϕ), find [ϕi] 2. Check ifI ⊆ [ϕ]

Subformulas Sub(ϕ) of ϕ are checked bottom-up To compute each [ϕ

i

]: if the main operator of ϕ

i

is a

Propositional atoms: apply labeling function Boolean operator: apply standard set operations

temporal operator: appy recursively the tableaux rules, until a fixpointis reached

(24)

General M.C. Procedure

state_set Check(CTL_formula β) { case β of

true: return S;

false: return {};

p: return {s | p ∈ L(s)};

¬β

1

: return S / Check(β

1

);

β

1

∧ β

2

: return Check(β

1

) ∩ Check(β

2

);

EXβ

1

: return PreImage(Check(β

1

));

EGβ

1

: return Check_EG(Check(β

1

));

E(β

1

2

): return Check_EU(Check(β

1

),Check(β

2

));

}

(25)

PreImage

state_set PreImage(state_set [β]) { X := {};

for each s ∈ S do

for each s

0

s.t. s

0

∈ [β] and hs, s

0

i ∈ R do X := X ∪ {s};

return X ;

}

(26)

Check_EG

state_set Check_EG(state_set [β]) { X

0

:= [β]; j := 1;

repeat

X := X

0

; j := j + 1;

X

0

:= X ∩ PreImage(X );

until (X

0

= X );

return X ;

}

(27)

Check_EU

state_set Check_EU(state_set [β

1

],[β

2

]) { X

0

:= [β

2

]; j := 1;

repeat

X := X

0

; j := j + 1;

X

0

:= X ∪ ([β

1

] ∩ PreImage(X ));

until (X

0

= X );

return X ;

}

(28)

A relevant subcase: Check_EF

state_set Check_EF(state_set [β]) { X

0

:= [β]; j := 1;

repeat

X := X

0

; j := j + 1;

X

0

:= X ∪ PreImage(X );

until (X

0

= X );

return X ;

}

(29)

Example 1: fairness

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(30)

Example 1: fairness

[¬C

1

]

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(31)

Example 1: fairness

[EG¬C

1

], step 0:

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(32)

Example 1: fairness

[EG¬C

1

], step 1:

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(33)

Example 1: fairness

[EG¬C

1

], step 2:

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(34)

Example 1: fairness

[EG¬C

1

], step 3:

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(35)

Example 1: fairness

[EG¬C

1

], step 4:

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(36)

Example 1: fairness

[EG¬C

1

], FIXPOINT!

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(37)

Example 1: fairness

[EFEG¬C

1

], STEP 0

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(38)

Example 1: fairness

[EFEG¬C

1

], STEP 1

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(39)

Example 1: fairness

[EFEG¬C

1

], STEP 2

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(40)

Example 1: fairness

[EFEG¬C

1

], STEP 3

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(41)

Example 1: fairness

[EFEG¬C

1

], STEP 4

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(42)

Example 1: fairness

[EFEG¬C

1

], FIXPOINT!

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

?

(43)

Example 1: fairness

[¬EFEG¬C

1

]

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AGAFC

1

? =⇒ M |= ¬EFEG¬C

1

? =⇒ NO!

(44)

Example 2: liveness

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AG(T

1

→ AFC

1

) ? =⇒ M |= ¬EF(T

1

∧ EG¬C

1

) ?

(45)

Example 2: liveness

[T

1

]:

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AG(T

1

→ AFC

1

) ? =⇒ M |= ¬EF(T

1

∧ EG¬C

1

) ?

(46)

Example 2: liveness

[EG¬C

1

], STEPS 0-4: (see previous example)

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AG(T

1

→ AFC

1

) ? =⇒ M |= ¬EF(T

1

∧ EG¬C

1

) ?

(47)

Example 2: liveness

[T

1

∧ EG¬C

1

] :

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AG(T

1

→ AFC

1

) ? =⇒ M |= ¬EF(T

1

∧ EG¬C

1

) ?

(48)

Example 2: liveness

[EF(T

1

∧ EG¬C

1

)] :

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AG(T

1

→ AFC

1

) ? =⇒ M |= ¬EF(T

1

∧ EG¬C

1

) ?

(49)

Example 2: liveness

[¬EF(T

1

∧ EG¬C

1

)] :

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

M |= AG(T

1

→ AFC

1

) ? =⇒ M |= ¬EF(T

1

∧ EG¬C

1

) ? YES!

(50)

The property verified is...

(51)

Homework

Apply the same process to all the CTL examples of Chapter 3.

(52)

Complexity of CTL Model Checking: M |= ϕ

Step 1: compute [ϕ]

Compute [ϕ] bottom-up on the O(|ϕ|) sub-formulas of ϕ:

O(|ϕ|) steps...

... each requiring at most exploring O(|M|) states

=⇒ O(|M| · |ϕ|) steps

Step 2: check I ⊆ [ϕ]: O(|M|)

=⇒ O(|M| · |ϕ|)

(53)

Model Checking of Invariants

Invariant properties have the form AG p (e.g., AG¬bad ) Checking invariants is the negation of a reachability problem:

is there a reachable state that is also a bad state?

(AG¬bad = ¬EFbad )

Standard M.C. algorithm reasons backward from the bad by iteratively applying PreImage computations:

Y

0

:= Y ∪ PreImage(Y )

until a fixed point is reached. Then the complement is computed and I is checked for inclusion in the resulting set.

Better algorithm: reasons backward from the bad by iteratively applying PreImage computations:

Y

0

:= Y ∪ PreImage(Y )

until (i) it intersect [I] or (ii) a fixed point is reached

(54)

Model Checking of Invariants [cont.]

I

ϕ

(55)

Symbolic Forward Model Checking of Invariants

Alternative algorithm (often more efficient): forward checking Compute the set of bad states [bad ]

Compute the set of initial states I

Compute incrementally the set of reachable states from I until (i) it intersect [bad ] or (ii) a fixed point is reached

Basic step is the (Forward) Image:

Image(Y )

def

= {s

0

| s ∈ Y and R(s, s

0

) holds}

Simplest form: compute the set of reachable states.

(56)

Computing Reachable states: basic

State_Set Compute_reachable() { Y

0

:= I; Y := ∅; j := 1;

while (Y

0

6= Y ) j := j + 1;

Y := Y

0

;

Y

0

:= Y ∪ Image(Y );

} return Y;

}

Y=reachable

(57)

Computing Reachable states: advanced

State_Set Compute_reachable() { Y := F := I; j := 1;

while (F 6= ∅) j := j + 1;

F := Image(F ) \ Y ; Y := Y ∪ F ;

} return Y;

}

Y=reachable;F=frontier (new)

(58)

Computing Reachable states [cont.]

(59)

Checking of Invariant Properties: basic

bool Forward_Check_EF(State_Set BAD) { Y := I; Y

0

:= ∅; j := 1;

while (Y

0

6= Y ) and (Y

0

∩ BAD) = ∅ j := j + 1;

Y := Y

0

;

Y

0

:= Y ∪ Image(Y );

}

if (Y

0

∩ BAD) 6= ∅ // counter-example return true

else // fixpoint reached return false

}

Y=reachable;

(60)

Checking of Invariant Properties: advanced

bool Forward_Check_EF(State_Set BAD) { Y := F := I; j := 1;

while (F 6= ∅) and (F ∩ BAD) = ∅ j := j + 1;

F := Image(F ) \ Y ; Y := Y ∪ F ;

}

if (F ∩ BAD) 6= ∅ // counter-example return true

else // fixpoint reached return false

}

Y=reachable;F=frontier (new)

(61)

Checking of Invariant Properties [cont.]

(62)

Checking of Invariants: Counterexamples

if layer n intersects with the bad states, then the property is violated

a counterexample can be reconstructed proceeding backwards (i) select any state of BAD ∩ F [n] (we know it is satisfiable), call it

t[n]

(ii) compute Preimage(t [n]), i.e. the states that can result in t [n] in one step

(iii) compute Preimage(t [n]) ∩ F [n − 1], and select one state t[n − 1]

iterate (i)-(iii) until the initial states are reached

t[0], t[1], . . . , t[n] is our counterexample

(63)

Checking of Invariants: Counterexamples [cont.]

(64)

Ex: CTL Model Checking

Consider the Kripke Model M below, and the CTL property ϕdef=AG((p ∧ q) → EGq).

¬pq s0

p¬q s2

pq s1

(a) Rewrite ϕ into an equivalent formula ϕ0expressed in terms ofEX, EG, EU/EF only.

[ Solution: ϕ0= ¬EF¬((¬p ∨ ¬q) ∨ EGq) = ¬EF((p ∧ q) ∧ ¬EGq) ]

(b) Compute bottom-up the denotations of all subformulas of ϕ0. (Ex: [p] = {s1,s2}) [ Solution:

[p] = {s1,s2} [q] = {s0,s1} [(p ∧ q)] = {s1} [EGq] = {s0,s1}

[¬EGq] = {s2}

[((p ∧ q) ∧ ¬EGq)] = {}

[EF((p ∧ q) ∧ ¬EGq)] = {}

[¬EF((p ∧ q) ∧ ¬EGq)] = {s0,s1,s2} ]

(c) As a consequence of point (b), say whether M |= ϕ or not.

(65)

Ex: CTL Model Checking

Consider the Kripke Model M below, and the CTL propertyAG(AFp → AFq).

pq s0

¬p¬q s1

¬pq s2

(a) Rewrite ϕ into an equivalent formula ϕ0expressed in terms ofEX, EG, EU/EF only.

[ Solution:

ϕ0=AG(AFp → AFq) = ¬EF¬(¬EG¬p → ¬EG¬q) = ¬EF(¬EG¬p ∧ EG¬q) ] (b) Compute bottom-up the denotations of all subformulas of ϕ0. (Ex: [p] = {s1,s2})

[ Solution:

[p] = {s0}

[¬p] = {s1,s2} [EG¬p] = {s1,s2} [¬EG¬p] = {s0} [q] = {s0,s2}

[¬q] = {s1}

[EG¬q] = {s1}

[¬EG¬p ∧ EG¬q] = {}

[EF(¬EG¬p ∧ EG¬q)] = {}

[¬EF(¬EG¬p ∧ EG¬q)] = {s0,s1,s2} ]

(c) As a consequence of point (b), say whether M |= ϕ or not.

[ Solution: Yes, {s0,s1,s2} ⊆ [ϕ0]. ]

Riferimenti

Documenti correlati

handle temporal operators AX, EX by computing pre-images handle temporal operators AG, EG, AF, EF, AU, EU, by (implicitly) applying tableaux rules, until a fixpoint is reached..

Kripke structure encoded as Boolean formulas (OBDDs) All operations handled as (quantified) Boolean operations Avoids building the state graph explicitly. reduces dramatically the

(E.g., 300 Boolean vars =⇒ up to 2 300 ≈ 10 100 states!) State Space Explosion:.. too much

Copyright notice: some material (text, figures) displayed in these slides is courtesy of R..

Given a fair Kripke model M, a fair non-trivial SCC is an SCC with at least one edge that contains at least one state for every fair condition. =⇒ all states in a fair (non-trivial)

Example: although state 3 belongs to sat(¬heat Uclose), the path which loops forever in 3 does not satisfy ¬heatUclose, as close never holds in that path. We restrict the

[Alternatively: there is no positive U-subformula, so that we must add a AGAF> fairness condition, which is equivalent to say that all states belong to the fairness

Given the following generalized Büchi automaton A def = hQ, Σ, δ, I, FT i, with two sets of accepting states FT def = {F 1, F 2} s.t.. Ex: