Model Checking Lecture 2 Tom Henzinger

74
Model Checking Lecture 2 Tom Henzinger

description

Model Checking Lecture 2 Tom Henzinger. Model-Checking Problem. I |= S. System model. System property. System model: State-transition graph. q1. a. b. a,b. q2. q3. StatesQ = { q1, q2, q3 } Atomic observations A = { a, b } Transition relation   Q  Q - PowerPoint PPT Presentation

Transcript of Model Checking Lecture 2 Tom Henzinger

Page 1: Model Checking Lecture 2 Tom Henzinger

Model Checking

Lecture 2

Tom Henzinger

Page 2: Model Checking Lecture 2 Tom Henzinger

Model-Checking Problem

I |= S

System model System property

Page 3: Model Checking Lecture 2 Tom Henzinger

a

a,b b

q1

q3q2

System model: State-transition graph

States Q = { q1, q2, q3 }

Atomic observations A = { a, b }

Transition relation Q Q

Observation function [ ] : Q 2A

Page 4: Model Checking Lecture 2 Tom Henzinger

Run: sequence of states q1, q2

Observation: set of atomic observations

Trace: sequence of observations {a}, {a,b}

Page 5: Model Checking Lecture 2 Tom Henzinger

-safety (finite runs) vs. liveness (infinite runs)

-linear time (traces) vs. branching time (runs)

-logic (declarative) vs. automata (executable)

System property: 2x2x2 choices

Page 6: Model Checking Lecture 2 Tom Henzinger

STL (Safe Temporal Logic)

-safety (only finite runs)

-branching (runs, not traces)

-logic

Page 7: Model Checking Lecture 2 Tom Henzinger

Defining a logic

1. Syntax:

What are the formulas?

2. Semantics:

What are the models?

Does model M satisfy formula ?

M |=

Page 8: Model Checking Lecture 2 Tom Henzinger

Propositional logics:

1. boolean variables (a,b) & boolean operators (,)

2. model = truth-value assignment for variables

Propositional modal (e.g. temporal) logics:

1. ... & modal operators (,)

2. model = set of (e.g. temporally) related prop. models

Page 9: Model Checking Lecture 2 Tom Henzinger

Propositional logics:

1. boolean variables (a,b) & boolean operators (,)

2. model = truth-value assignment for variables

Propositional modal (e.g. temporal) logics:

1. ... & modal operators (,)

2. model = set of (e.g. temporally) related prop. models observations

state-transition graph (“Kripke structure”)

Page 10: Model Checking Lecture 2 Tom Henzinger

STL Syntax

::= a | | | | U

boolean variable (atomic

observation)

boolean operators

modal operators

Page 11: Model Checking Lecture 2 Tom Henzinger

STL Model

( K, q )

state-transition graph

state of K

Page 12: Model Checking Lecture 2 Tom Henzinger

STL Semantics

(K,q) |= a iff a [q]

(K,q) |= iff (K,q) |= and (K,q) |=

(K,q) |= iff not (K,q) |=

(K,q) |= iff exists q’ s.t. q q’ and (K,q’) |=

(K,q) |= U iff exist q0, ..., qn s.t. 1. q = q0 q1 ...

qn 2. for all 0 i < n, (K,qi) |= 3. (K,qn) |=

Page 13: Model Checking Lecture 2 Tom Henzinger

EX exists next

= AX forall next

U EU exists until

= true U EF exists eventually

= AG forall always

W = ( () U ( ))

AW forall waiting-for (forall weak-

until)

Defined modalities

Page 14: Model Checking Lecture 2 Tom Henzinger

Important safety properties

Invariance a

Sequencing a W b W c W d

= a W (b W (c W d))

Page 15: Model Checking Lecture 2 Tom Henzinger

Important safety properties: mutex protocol

Invariance (in_cs1 in_cs2)

Sequencing ( req_cs1

in_cs2 W in_cs2 W in_cs2 W in_cs1 )

Page 16: Model Checking Lecture 2 Tom Henzinger

Branching properties

Deadlock freedom true

Possibility (a b)

(req_cs1 in_cs1)

Page 17: Model Checking Lecture 2 Tom Henzinger

CTL (Computation Tree Logic)

-safety & liveness

-branching time

-logic

[Clarke & Emerson; Queille & Sifakis 1981]

Page 18: Model Checking Lecture 2 Tom Henzinger

CTL Syntax

::= a | | | | U |

Page 19: Model Checking Lecture 2 Tom Henzinger

CTL Model

( K, q )

fair state-transition graph state of K

Page 20: Model Checking Lecture 2 Tom Henzinger

CTL Semantics

(K,q) |= iff exist q0, q1, ... s.t.

1. q = q0 q1 ... is an infinite fair run

2. for all i 0, (K,qi) |=

Page 21: Model Checking Lecture 2 Tom Henzinger

EG exists always

= AF forall eventually

W = ( U ) ( )

U = ( W ) ()

Defined modalities

Page 22: Model Checking Lecture 2 Tom Henzinger

Important liveness property

Response (a b)

(req_cs1 in_cs1)

Page 23: Model Checking Lecture 2 Tom Henzinger

If only universial properties are of interest,

why not omit the path quantifiers?

Page 24: Model Checking Lecture 2 Tom Henzinger

LTL (Linear Temporal Logic)

-safety & liveness

-linear time

-logic

[Pnueli 1977; Lichtenstein & Pnueli 1982]

Page 25: Model Checking Lecture 2 Tom Henzinger

LTL Syntax

::= a | | | | U

Page 26: Model Checking Lecture 2 Tom Henzinger

LTL Model

infinite trace t = t0 t1 t2 ...

Page 27: Model Checking Lecture 2 Tom Henzinger

(K,q) |= iff for all t L(K,q), t |=

(K,q) |= iff exists t L(K,q), t |=

Language of deadlock-free state-transition graph K at state q :

L(K,q) ... set of infinite traces of K starting at q

Page 28: Model Checking Lecture 2 Tom Henzinger

LTL Semantics

t |= a iff a t0

t |= iff t |= and t |=

t |= iff not t |=

t |= iff t1 t2 ... |=

t |= U iff exists n 0 s.t.1. for all 0 i < n, ti ti+1 ... |

= 2. tn tn+1 ... |=

Page 29: Model Checking Lecture 2 Tom Henzinger

X next

U U until

= true U F eventually

= G always

W = ( U ) W waiting-for (weak-until)

Defined modalities

Page 30: Model Checking Lecture 2 Tom Henzinger

Important properties

Invariance a

(in_cs1 in_cs2)

Sequencing a W b W c W d

( req_cs1

in_cs2 W in_cs2 W in_cs2 W in_cs1 )

Response (a b)

(req_cs1 in_cs1)

Page 31: Model Checking Lecture 2 Tom Henzinger

Composed modalities

a infinitely often a

a almost always a

Page 32: Model Checking Lecture 2 Tom Henzinger

Where did fairness go ?

Page 33: Model Checking Lecture 2 Tom Henzinger

Unlike in CTL, fairness can be expressed in LTL !

So there is no need for fairness in the model.

Weak (Buchi) fairness :

(enabled taken )

(enabled taken)

Strong (Streett) fairness :

( enabled ) ( taken )

Page 34: Model Checking Lecture 2 Tom Henzinger

Starvation freedom, corrected

(in_cs2 out_cs2)

(req_cs1 in_cs1)

Page 35: Model Checking Lecture 2 Tom Henzinger

CTL cannot express fairness

a a

b b

ba aq0

q1 q2

Page 36: Model Checking Lecture 2 Tom Henzinger

LTL cannot express branching

Possibility (a b)

So, LTL and CTL are incomparable.

(There are branching logics that can express fairness, e.g. CTL* = CTL + LTL, but they lose the computational attractiveness of CTL.)

Page 37: Model Checking Lecture 2 Tom Henzinger

Finite Automata

-safety (no infinite runs)

-linear or branching time

-automata (not logic)

Page 38: Model Checking Lecture 2 Tom Henzinger

Specification Automata

Syntax, given a set A of atomic observations:

S finite set of states

S0 S set of initial states

S S transition relation

: S PL(A) where the formulas of PL are

::= a | |

for a A

Page 39: Model Checking Lecture 2 Tom Henzinger

Language L(M) of specification automaton

M = (S, S0, , ) :

finite trace t0, ..., tn L(M)

iff

there exists a finite run s0 s1 ... sn of M

such that

for all 0 i n, ti |= (si)

Page 40: Model Checking Lecture 2 Tom Henzinger

(K,q) |=L M iff L(K,q) L(M)

Linear semantics of specification automata:

language containment

state-transition graph

state of K

specification automaton

finite traces

Page 41: Model Checking Lecture 2 Tom Henzinger

Invariance specification automaton

in_cs1

in_cs2

Page 42: Model Checking Lecture 2 Tom Henzinger

Starvation freedom specification automaton

out_cs1

req_cs1

in_cs2req_cs1

in_cs2

in_cs1 req_cs1

in_cs2

Page 43: Model Checking Lecture 2 Tom Henzinger

Automata are more expressive than logic, because temporal logic cannot count :

This cannot be expressed in LTL.

(How about a (a a) ?)

a true

Page 44: Model Checking Lecture 2 Tom Henzinger

Checking language containment between finite automata is PSPACE-complete !

L(K,q) L(M)

iff

L(K,q) complement( L(M) ) =

involves determinization (subset construction)

Page 45: Model Checking Lecture 2 Tom Henzinger

In practice:

1. require deterministic specification automata

2. use monitor automata

3. use branching semantics

Page 46: Model Checking Lecture 2 Tom Henzinger

Monitor Automata

Syntax:

same as specification automata, except also set E S of error states

Semantics:

define L(M) s.t. runs must end in error states

(K,q) |=C M iff L(K,q) L(M) =

Page 47: Model Checking Lecture 2 Tom Henzinger

Invariance monitor automaton

in_cs1

in_cs2

in_cs1

in_cs2

Page 48: Model Checking Lecture 2 Tom Henzinger

Starvation freedom monitor automaton

out_cs1

req_cs1

in_cs2req_cs1

in_cs2

in_cs1 req_cs1

in_cs2

req_cs1

in_cs2

Page 49: Model Checking Lecture 2 Tom Henzinger

Specification automaton Monitor automaton

M complement(M)

-describe correct traces -describe error traces

-check language containment-check emptiness (linear): (exponential) reachability of error states

“All safety verification is reachability checking.”

Page 50: Model Checking Lecture 2 Tom Henzinger

Main problem with deterministic specifications and monitor automata:

not suitable for stepwise refinement / abstraction

S1 |= S2 |= S3

“refines”

Page 51: Model Checking Lecture 2 Tom Henzinger

In practice:

1. require deterministic specification automata

2. use monitor automata

3. use branching semantics

Page 52: Model Checking Lecture 2 Tom Henzinger

(K,q) |=B M

iff

there exists a simulation relation R Q S s.t. (q,s) R for some initial state s of M

Branching semantics of specification automata:

simulation

states of K

states of M

Page 53: Model Checking Lecture 2 Tom Henzinger

R Q S is a simulation relation

iff

(q,s) R implies

1. [q] |= (s)

2. for all q’ s.t. q q’ , exists s’ s.t. s s’

and (q’,s’) R.

[Milner 1974]

Page 54: Model Checking Lecture 2 Tom Henzinger

(K,q) |=L M M language contains (K,q) :exponential check

(K,q) |=B M M simulates (K,q) :quadratic check

X

involves only traces (hence linear !)

involves states (hence branching !)

Page 55: Model Checking Lecture 2 Tom Henzinger

In practice, simulation is usually the “right” notion.

(If there is language containment, but not simulation, this is usually accidental, not by design.)

Page 56: Model Checking Lecture 2 Tom Henzinger

Finite Omega-Automata

-safety & liveness (infinite runs !)

-linear or branching time

-automata (not logic)

Page 57: Model Checking Lecture 2 Tom Henzinger

-specification vs. monitor automata

-linear (language containment) vs. branching (simulation) semantics

We discuss only the linear specification case.

Page 58: Model Checking Lecture 2 Tom Henzinger

Specification Omega-Automata

Syntax as for finite automata, in addition one of the following acceptance conditions:

Buchi: BA S

coBuchi: CA S

Streett: SA 2S 2S

Rabin: RA 2S 2S

Page 59: Model Checking Lecture 2 Tom Henzinger

Language L(M) of specification omega-automaton

M = (S, S0, , , A ) :

infinite trace t0, t1, ... L(M)

iff

there exists an infinite run s0 s1 ... of M

such that

1. s0 s1 ... satisfies A

2. for all i 0, ti |= (si)

Page 60: Model Checking Lecture 2 Tom Henzinger

Let Inf(s) = { p | p = si for infinitely many i }.

The infinite run s satisfies the acceptance condition A

iff

Buchi: Inf(s) BA

coBuchi: Inf(s) CA

Streett: for all (l,r) SA, if Inf(s) l then Inf(s) r

Rabin: for some (l,r) RA, Inf(s) l = and Inf(s) r

Page 61: Model Checking Lecture 2 Tom Henzinger

Buchi: BA

coBuchi: CA

Streett: (l r)

Rabin: (l r)

Page 62: Model Checking Lecture 2 Tom Henzinger

(K,q) |=L M iff L(K,q) L(M)

Linear semantics of specification omega-automata:

omega-language containment

infinite traces

Page 63: Model Checking Lecture 2 Tom Henzinger

Response specification automaton :

(a b) assuming (a b) = false

a b

ba

s1

s2

s3

s0

Buchi condition { s0, s3 }

Page 64: Model Checking Lecture 2 Tom Henzinger

a a

s0s1

Buchi condition { s0 }

No coBuchi condition

a

Streett condition { ({s0,s1}, {s0}) }

Rabin condition { (,{s0}) }

Page 65: Model Checking Lecture 2 Tom Henzinger

a a

s0s1

No Buchi condition

coBuchi condition { s0 }

a

Streett condition { ({s1}, ) }

Rabin condition { ({s1}, {s0,s1}) }

Page 66: Model Checking Lecture 2 Tom Henzinger

a a

s0s1

Buchi condition { s2 }

a

a

s2

Page 67: Model Checking Lecture 2 Tom Henzinger

-Buchi and coBuchi automata cannot be determinized

-Streett and Rabin automata can be determinized

nondeterministic Buchi =

deterministic Streett = deterministic Rabin =

nondeterministic Streett = nondeterministic Rabin =

omega-regular [Buchi 1960]

Page 68: Model Checking Lecture 2 Tom Henzinger

Omega-automaton determinization is even harder (conceptually, at least) than finite-automaton determinization [Safra 1989].

So monitor automata and simulation are particularly important.

Page 69: Model Checking Lecture 2 Tom Henzinger

Omega-automata are strictly more expressive than LTL

Omega-automata: omega-regular languages

LTL: counter-free omega-regular languages

Page 70: Model Checking Lecture 2 Tom Henzinger

Omega-automata: omega-regular languages = second-order theory of monadic

predicates & successor = omega-regular expressions

LTL: counter-free omega-regular languages = first-order theory of monadic predicates & successor = star-free omega-regular expressions

Page 71: Model Checking Lecture 2 Tom Henzinger

Structure of the omega-regular languages

Streett = Rabin

Buchi coBuchi

FinitecoFinite

Page 72: Model Checking Lecture 2 Tom Henzinger

Structure of the counter-free omega-regular languages

positive boolean combinations of and

Page 73: Model Checking Lecture 2 Tom Henzinger

The location of a linear-time property in the Borel hierarchy indicates how hard (theoretically as well as conceptually) the corresponding model-checking problem is.

Page 74: Model Checking Lecture 2 Tom Henzinger

positive boolean combinations of and

safety

weak fair

strong fair

response