• Ingen resultater fundet

Basic Model Checking Algorithms

N/A
N/A
Info
Hent
Protected

Academic year: 2022

Del "Basic Model Checking Algorithms"

Copied!
37
0
0

Indlæser.... (se fuldtekst nu)

Hele teksten

(1)

Computation Tree Logic (CTL) &

Basic Model Checking Algorithms

Martin Fr¨anzle

Carl von Ossietzky Universit ¨at Dpt. of Computing Science Res. Grp. Hybride Systeme

Oldenburg, Germany

(2)

What you’ll learn

1. Rationale behind declarative specifications:

Why operational style is insufficient 2. Computation Tree Logic CTL:

Syntax

Semantics: Kripke models

3. Explicit-state model checking of CTL:

Recursive coloring

(3)

Operational models

Nowadays, a lot of ES design is based on executable behavioral models of the system under design, e.g. using

Statecharts (a syntactically sugared variant of Moore automata)

VHDL.

Such operational models are good at

supporting system analysis

simulation / virtual prototyping

supporting incremental design

executable models

supporting system deployment

executable model as “golden device”

code generation for rapid prototyping or final product

hardware synthesis

(4)

Operational models

...are bad at

supporting non-operational descriptions:

What instead of how.

E.g.: Every request is eventually answered.

supporting negative requirements:

“Thou shalt not...”

E.g.: The train ought not move, unless it is manned.

providing a structural match for requirement lists:

System has to satisfy R1 and R2 and ...

If system fails to satisfy R1 then R2 should be satisfied.

(5)

Multiple viewpoints

Requirements

analysis Programming

"How?"

Algorithmics

"What?"

Aspects Requirements

analysis Programming

"How?"

Algorithmics

"What?"

Aspects

Consistent?

Requirements

analysis Programming

"How?"

Algorithmics

"What?"

Aspects

Consistent?

"Consistent?"

Tests & proofs

Validation / verification

(6)

Model checking

Device Specification

Device Descript.

architecture behaviour of processor is

process fetch if halt=0 then if mem_wait=0 then nextins <= dport ...

Model Checker

♦(π ⇐ φ)

Hello world This is DeDuCe V 1.4 Give me your design

Approval/

Counterexample

(7)

Exhaustive state-space search

Automatic verification/falsification of invariants

(8)

In

Approach Empty

Empty

enter! leave!

Safety requirement: Gate has to be closed whenever a train is in “In”.

(9)

The gate model

Open

Opening

~enter?

enter?

~leave?

leave?

Closing

Closed

Track model

— safe abstraction —

leave!

enter!

Empty Appr. In

(10)

Automatic check

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing

Open ~enter

~leave

~enter

~leave

~enter

~leave enter

enter ~enter

~leave ~leave

leave

leave

Empty Appr. In

Appr. In

Empty

Empty

Empty

Appr.

Appr. In

In

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing Open

Empty Empty

Empty

Empty App.

App.

App.

App.

In In

In 0 In

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing Open

Empty Empty

Empty

Empty App.

App.

App.

App.

In In

In 0 In

1

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing Open

Empty Empty

Empty

Empty App.

App.

App.

App.

In In

In 0 In

1

2 2

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing Open

Empty Empty

Empty

Empty App.

App.

App.

App.

In In

In In

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing Open

Empty Empty

Empty

Empty App.

App.

App.

App.

In In

In 0 In

1

2 2

3

4

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing Open

Empty Empty

Empty

Empty App.

App.

App.

App.

In In

In 0 In

1

2 2

3

4 5

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing Open

Empty Empty

Empty

Empty App.

App.

App.

App.

In In

In 0 In

1

2 2

3

4 5

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing Open

Empty Empty

Empty

Empty App.

App.

App.

App.

In In

In In

(11)

Verification result

0

1

2 2

3

4 5

Closed Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing Open

Empty Empty

Empty

Empty App.

App.

App.

App.

In In

In In

Stimuli: Empty, Approach, In , Empty , Approach, In.

Gate reaction: Open , Closing , Closed, Opening, Open , Open.

(12)

Computation Tree Logic

(13)

Syntax of CTL

We start from a countable set AP of atomic propositions.

The CTL formulae are then defined inductively:

Any proposition p ∈ AP is a CTL formula.

The symbols ⊥ and > are CTL formulae.

If φ and ψ are CTL formulae, so are

¬φ, φ ∧ ψ, φ ∨ ψ, φ → ψ EX φ, AX φ

EF φ, AF φ EG φ, AG φ

φ EU ψ, φ AU ψ

(14)

Semantics (informal)

E and A are path quantifiers:

A: for all paths in the computation tree . . .

E: for some path in the computation tree . . .

X, F, G und U are temporal operators which refer to the path under investigation, as known from LTL:

Xφ (Next) : evaluate φ in the next state on the path

Fφ (Finally) : φ holds for some state on the path

Gφ (Globally) : φ holds for all states on the path

φUψ (Until) : φ holds on the path at least until ψ holds

N.B. Path quantifiers and temporal operators are compound in CTL: there never is an isolated path quantifier or an isolated tem- poral operator. There is a lot of things you can’t express in CTL because of this...

(15)

Semantics (formal)

CTL formulae are interpreted over Kripke structures.:

A Kripke structure K is a quadruple K = (V, E, L, I) with

V a set of vertices (interpreted as system states),

E ⊆ V × V a set of edges (interpreted as possible transitions),

L ∈ V → P(AP) labels the vertices with atomic propositions that apply in the individual vertices,

I ⊆ V is a set of initial states.

q1

q

q3 q4

p

q2

p,q

p,r

(16)

Paths in Kripke structures

A path π in a Kripke structure K = (V, E, L, I) is an edge-consistent infinite sequence of vertices:

π ∈ Vω,

i, πi+1) ∈ E for each i ∈ IN.

Note that a path need not start in an initial state!

The labelling L assigns to each path π a propositional trace trπ = L(π) def= hL(π0), L(π1), L(π2), . . .i

that path formulae (Xφ, Fφ, Gφ, φUψ) can be interpreted on.

(17)

Semantics (formal)

Let K = (V, E, L, I) be a Kripke structure and v ∈ V a vertex of K.

v, K |= >

v, K 6|= ⊥

v, K |= p for p ∈ AP iff p ∈ L(v)

v, K |= ¬φ iff v, K 6|= φ,

v, K |= φ ∧ ψ iff v, K |= φ and v, K |= ψ,

v, K |= φ ∨ ψ iff v, K |= φ or v, K |= ψ,

v, K |= φ ⇒ ψ iff v, K 6|= φ or v, K |= ψ.

(18)

Semantics (contd.)

v, K |= EXφ iff there is a path π in K s.t. v = π1 and π2, K |= φ,

v, K |= AXφ iff all paths π in K with v = π1 satisfy π2, K |= φ,

v, K |= EFφ iff there is a path π in K s.t. v = π1 and πi, K |= φ for some i,

v, K |= AFφ iff all paths π in K with v = π1 satisfy πi, K |= φ for some i (that may depend on the path),

v, K |= EGφ iff there is a path π in K s.t. v = π1 and πi, K |= φ for all i,

v, K |= AGφ iff all paths π in K with v = π1 satisfy πi, K |= φ for all i,

v, K |= φ EUψ , iff there is a path π in K s.t. v = π1 and some k IN s.t.

πi, K |= φ for each i < k and πk, K |= ψ,

v, K |= φ AUψ , iff all paths π in K with v = π1 have some k IN s.t.

πi, K |= φ for each i < k and πk, K |= ψ.

A Kripke structure K = (V, E, L, I) satisfies φ iff all its initial states satisfy φ, i.e. iff is, K |= φ for all is I.

(19)

CTL Model Checking Explicit-state algorithm

(20)

Rationale

We will extend the idea of verification/falsification by exhaustive state-space exploration to full CTL.

Main technique will again be breadth-first search, i.e. graph coloring.

Need to extend this to other modalities than AG ..

Need to deal with nested modalities.

(21)

Model-checking CTL: General layout

Given: a Kripke structure K = (V, E, L, I) and a CTL formula φ

Core algorithm: find the set Vφ ⊆ V of vertices in K satisfying φ by 1. for each atomic subformula p of φ, mark the set Vp ⊆ V of

vertices in K satisfying φ

2. for increasingly larger subformulae ψ of φ, synthesize the marking Vψ ⊆ V of nodes satisfying ψ from the markings for ψ’s immediate subformulae

until all subformulae of φ have been processed (including φ itself)

Result: report “K |= φ” iff Vφ ⊇ I

(22)

Reduction

The tautologies

φ ∨ ψ ⇔ ¬(¬φ ∧ ¬ψ) AX φ ⇔ ¬EX ¬φ

AG φ ⇔ ¬EF ¬φ EF φ ⇔ > EU φ EG φ ⇔ ¬AF ¬φ

φ AU ψ ⇔ ¬((¬ψ) EU ¬(φ ∨ ψ)) ∧ AF ψ

indicate that we can rewrite each formula to one only containing atomic propositions, ¬, ∧, EX , EU , AF .

After preprocessing, our algorithm need only tackle these!

(23)

Model-checking CTL: Atomic propositions

Given: A finite Kripke structure with vertices V and edges E and a labelling function L assigning atomic propositions to vertices.

Furthermore an atomic proposition p to be checked.

Algorithm: Mark all vertices that have p as a label.

Complexity: O(|V|)

(24)

Model-checking CTL: ¬φ

Given: A set Vφ of vertices satisfying formula φ.

Algorithm: Mark all vertices not belonging to Vφ.

Complexity: O(|V|)

(25)

Model-checking CTL: φ ∧ ψ

Given: Sets Vφ and Vψ of vertices satisfying formulae φ or ψ, resp.

Algorithm: Mark all vertices belonging to Vφ ∩ Vψ.

Complexity: O(|V|)

(26)

Model-checking CTL: EX φ

Given: Set Vφ of vertices satisfying formulae φ.

Algorithm: Mark all vertices that have a successor state in Vφ.

Complexity: O(|V| + |E|)

(27)

Model-checking CTL: φ EU ψ

Given: Sets Vφ and Vψ of vertices satisfying formulae φ or ψ, resp.

Algorithm: Incremental marking by

1. Mark all vertices belonging to Vψ. 2. Repeat

if there is a state in Vφ that has some successor state marked then mark it also

until no new state is found.

Termination: Guaranteed due to finiteness of Vφ ⊂ V.

Complexity: O(|V| + |E|) if breadth-first search is used.

(28)

Model-checking CTL: AF φ

Given: Set Vφ of vertices satisfying formula φ.

Algorithm: Incremental marking by

1. Mark all vertices belonging to Vφ. 2. Repeat

if there is a state in V that has all successor states marked then mark it also

until no new state is found.

Termination: Guaranteed due to finiteness of V.

Complexity: O(|V| · (|V| + |E|)).

(29)

Model-checking CTL: EG φ , for efficiency

Given: Set Vφ of vertices satisfying formula φ.

Algorithm: Incremental marking by

1. Strip Kripke structure to Vφ-states:

(V, E) (Vφ, E ∩ (Vφ × Vφ)). Complexity: O(|V| + |E|)

2. Mark all states belonging to loops in the reduced graph.

Complexity: O(|Vφ| + |Eφ|) by identifying strongly connected components.

3. Repeat

if there is a state in Vφ that has some successor states marked then mark it also

until no new state is found.

Complexity: O(|Vφ| + |Eφ|)

Complexity: O(|V| + |E|).

(30)

Model-checking CTL: Main result

Theorem: It is decidable whether a finite Kripke structure (V, E, L, I) satisfies a CTL formula φ.

The complexity of the decision procedure is O(|φ| · (|V| + |E|)), i.e.

linear in the size of the formula, given a fixed Kripke structure,

linear in the size of the Kripke structure, given a fixed formula.

However, size of Kripke structure is exponential in number of parallel components in the system model.

(31)

Appendix

Fair Kripke Structures &

Fair CTL Model Checking

(32)

Fair Kripke Structures

A fair Kripke structure is a pair (K, F), where

K = (V, E, L, I) is a Kripke structure

F ⊆ P(V) is set of vertice sets, called a fairness condition.

A fair path π in a fair Kripke structure ((V, E, L, I), F) is an

edge-consistent infinite sequence of vertices which visits each set F ∈ F infinitely often:

π ∈ Vω,

i, πi+1) ∈ E for each i ∈ IN,

∀ F ∈ F. ∃i ∈ IN. πi ∈ F.

Note the similarity to (generalized) Büchi acceptance!

(33)

Fair CTL: Semantics

v, K,F |=F EXφ iff there is a fair path π in K s.t. v = π0 and π1, K,F |=F φ,

v, K,F |=F AXφ iff all fair paths π in K with v = π0 satisfy π1, K, F |=F φ,

v, K,F |=F EFφ iff there is a fair path π in K s.t. v = π0 and πi, K,F |=F φ for some i,

v, K,F |=F AFφ iff all fair paths π in K with v = π0 satisfy πi, K,F |=F φ for some i (that may depend on the fair path),

v, K,F |=F EGφ iff there is a fair path π in K s.t. v = π0 and πi, K,F |=F φ for all i,

v, K,F |=F AGφ iff all fair paths π in K with v = π0 satisfy πi, K,F |=F φ for all i,

v, K,F |=F φEUψ , iff there is a fair path π in K s.t. v = π0 and some k IN s.t. πi, K,F |=F φ for each i < k and πk, K,F |=F ψ,

v, K,F |=F φAUψ , iff all fair paths π in K with v = π0 have some k IN s.t.

πi, K, F |=F φ for each i < k and πk, K,F |=F ψ.

A fair Kripke structure ((V, E, L, I),F) satisfies φ, denoted ((V, E, L, I),F) |=F φ, iff all its initial states satisfy φ, i.e. iff is, K,F |=F φ for all is I.

(34)

Model-checking CTL: Fair states

Lemma: Given a fair Kripke structure (((V, E, L, I), F), the set

Fair ⊆ V of states from which a fair path originates can be determined algorithmically.

Alg.: This is a problem of finding adequate SCCs:

1. Find all SCCs in K.

2. Select those SCCs that do contain at least one state from each fairness set F ∈ F.

3. Find all states from which at least one of the selected SCCs is reachable.

(35)

Model-checking fair CTL: EX φ

Given: Set Vφ of vertices fairly satisfying formulae φ.

Algorithm: Mark all vertices that have a successor state in VφFair.

Note that the intersection with Fair is necessary even though the states in Vφ fairly satisfy φ:

φ may be an atomic proposition, in which case fairness is irrelevant;

φ may start with an A path quantifier that is trivially satisfied by non- existence of a fair path.

(36)

Model-checking fair CTL: φ EU ψ

Given: Sets Vφ and Vψ of vertices fairly satisfying formulae φ or ψ, resp.

Algorithm: Incremental marking by

1. Mark all vertices belonging to VψFair. 2. Repeat

if there is a state in Vφ that has some successor state marked then mark it also

until no new state is found.

(37)

Model-checking fair CTL: EG φ

Given: Set Vφ of vertices fairly satisfying formula φ.

Algorithm: Incremental marking by

1. Strip Kripke structure to Vφ-states:

(V, E) (Vφ, E ∩ (Vφ × Vφ)).

2. Mark all states that can reach a fair SCC in the reduced graph.

(Same algorithm as for finding the set Fair, yet applied to the reduced graph.)

Referencer

RELATEREDE DOKUMENTER

Most specific to our sample, in 2006, there were about 40% of long-term individuals who after the termination of the subsidised contract in small firms were employed on

The 2014 ICOMOS International Polar Heritage Committee Conference (IPHC) was held at the National Museum of Denmark in Copenhagen from 25 to 28 May.. The aim of the conference was

“racists” when they object to mass immigration, any more than all Muslim immigrants should be written off as probable terrorists. Ultimately, we all must all play the hand that we

H2: Respondenter, der i høj grad har været udsat for følelsesmæssige krav, vold og trusler, vil i højere grad udvikle kynisme rettet mod borgerne.. De undersøgte sammenhænge

Spali nski [Sp] has given the category of cyclic sets a closed model category structure such that the weak equivalences are the maps that induce an equivalence on fixed-points for

maripaludis Mic1c10, ToF-SIMS and EDS images indicated that in the column incubated coupon the corrosion layer does not contain carbon (Figs. 6B and 9 B) whereas the corrosion

In this study, a national culture that is at the informal end of the formal-informal continuum is presumed to also influence how staff will treat guests in the hospitality

During the 1970s, Danish mass media recurrently portrayed mass housing estates as signifiers of social problems in the otherwise increasingl affluent anish