ctl model checking - university of maryland · cmsc 630 february 25, 2015 1 ctl model checking goal...

57
CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ , where M is a Kripke structure and σ is a CTL formula. Approach Model checking! Mathematically, M is a model of σ if s I | = M σ . So determining if M sat σ amounts means checking whether M is a model of σ c 2015 Rance Cleaveland. All rights reserved.

Upload: others

Post on 21-Jan-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 1'

&

$

%

CTL Model Checking

Goal Method for proving M sat σ, where M is a Kripke structure and σ is a

CTL formula.

Approach Model checking!

• Mathematically, M is a model of σ if sI |=M σ.

• So determining if M sat σ amounts means checking whether M is a model

of σ

c©2015 Rance Cleaveland. All rights reserved.

Page 2: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 2'

&

$

%

Recall the CTL Fragment of CTL∗

... every path modality (i.e. F,G,U) must be preceded by a path quantifier A, E.

The syntax can also be given directly as follows.

σ ::= a

| ¬σ

| σ ∨ σ

| EXσ

| E(σ U σ)

| E(σ R σ)

Other operators (AX, AU, AR, EF, AF, EG, AG, etc.) can be defined in terms of

these.

c©2015 Rance Cleaveland. All rights reserved.

Page 3: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 3'

&

$

%

So What’s the Big Deal About CTL?

− Formulas are “like” those in LTL, but more complex.

+ Model-checking problem easier to solve in CTL.

c©2015 Rance Cleaveland. All rights reserved.

Page 4: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 4'

&

$

%

Properties in CTL

Expressiveness of CTL, LTL are incomparable.

One can reasonably argue that LTL is easier to understand.

However, one can turn LTL system specs into CTL formulas that are “at least as

strong”, provided LTL formulas are in positive normal form (i.e. negations only

applied to atomic propositions).

E.g.

PNF: GF executed

Not PNF: ¬GF executed

c©2015 Rance Cleaveland. All rights reserved.

Page 5: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 5'

&

$

%

LTL, CTL and PNF

Any LTL formula can be put in PNF provided logic is extended with the necessary

duals (i.e. ∧, R).

¬(φ1 ∨ φ2) ≡ (¬φ1) ∧ (¬φ2)

¬(Xφ) ≡ X(¬φ)

¬(φ1 U φ2) ≡ (¬φ1) R (¬φ2)

c©2015 Rance Cleaveland. All rights reserved.

Page 6: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 6'

&

$

%

Generating CTL Approximations to LTL

So how do we generate CTL formulas “at least as strong” as LTL system specs?

1. Put LTL formula in PNF.

2. Insert A path quantifier in front of each path modality.

LTL CTL

G (send ⇒ F receive) AG (send ⇒ AF receive)

(GF enabled) ⇒ (GF executed) (AFAG¬enabled) ∨ (AGAF executed)

c©2015 Rance Cleaveland. All rights reserved.

Page 7: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 7'

&

$

%

PNF CTL

σ ::= a

| ¬a

| σ ∨ σ

| σ ∧ σ

| EXσ

| AXσ

| E(σ U σ)

| A(σ U σ)

| E(σ R σ)

| A(σ R σ)

c©2015 Rance Cleaveland. All rights reserved.

Page 8: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 8'

&

$

%

The CTL Model-Checking Problem

Given

• Kripke structure M = 〈S,A, R, `, sI〉

• CTL formula (in PNF) σ

Determine Does sI |=M σ?

One approach

1. Define proof rules for CTL correctness assertions s `M σ.

2. Use rules to develop proofs.

c©2015 Rance Cleaveland. All rights reserved.

Page 9: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 9'

&

$

%

Sample Proof Rules

Recall M = 〈S,A, R, `, sI〉.

a ∈ `(s)

s `M a(A)

a 6∈ `(s)

s `M ¬a(¬A)

s `M σ1

s `M σ1 ∨ σ2

(∨1)s `M σ2

s `M σ1 ∨ σ2

(∨2)

s `M σ1 s `M σ2

s `M σ1 ∧ σ2

(∧)

Are these rules sound? Complete?

c©2015 Rance Cleaveland. All rights reserved.

Page 10: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 10'

&

$

%

Proof Rules for CTL Next-Step Modalities

How can we prove assertions of form s `M EXσ? s `M AXσ?

• M contains information about transitions from states.

• Proof rules should use this information.

s′ `M σ 〈s, s′〉 ∈ R

s `M EXσ(EX)

s1 `M σ · · · sn `M σ {s1, . . . , sn} = { s′ | 〈s, s′〉 ∈ R }

s `M AXσ(AX)

c©2015 Rance Cleaveland. All rights reserved.

Page 11: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 11'

&

$

%

Proof Rules for U, R Modalities

Idea Use recursive characterizations of modalities.

Notation σ1 ≡ σ2 means: for all M, s, s |=M σ1 iff s |=M σ2.

Then: AFσ ≡ σ ∨ AX(AFσ).

σ ∨ AX (AF σ)

σ

σ

σ

σ σ

σ

AF σ

AF σ

σ

c©2015 Rance Cleaveland. All rights reserved.

Page 12: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 12'

&

$

%

Other Recursive Characterizations

EFσ ≡

AGσ ≡

E(σ1 U σ2) ≡

E(σ1 R σ2) ≡

c©2015 Rance Cleaveland. All rights reserved.

Page 13: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 13'

&

$

%

Turning Recursion into Proof Rules: U

s `M σ2

s `M E(σ1 U σ2)(EU1)

s `M σ2

s `M A(σ1 U σ2)(AU1)

s `M σ1 s′ `M E(σ1 U σ2) 〈s, s′〉 ∈ R

s `M E(σ1 U σ2)(EU2)

s `M σ1

s1 `M A(σ1 U σ2) · · · sn `M A(σ1 U σ2)

{s1, . . . , sn} = { s′ | 〈s, s′〉 ∈ R }

s `M A(σ1 U σ2)

(AU2)

c©2015 Rance Cleaveland. All rights reserved.

Page 14: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 14'

&

$

%

Turning Recursion into Proof Rules: R

s `M σ1 s `M σ2

s `M E(σ1 R σ2)(ER1)

s `M σ1 s `M σ2

s `M A(σ1 R σ2)(AR1)

s `M σ2 s′ `M E(σ1 R σ2) 〈s, s′〉 ∈ R

s `M E(σ1 R σ2)(ER2)

s `M σ2

s1 `M A(σ1 R σ2) · · · sn `M A(σ1 R σ2)

{s1, . . . , sn} = { s′ | 〈s, s′〉 ∈ R }

s `M A(σ1 R σ2)

(AR2)

c©2015 Rance Cleaveland. All rights reserved.

Page 15: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 15'

&

$

%

But What about Circular Proofs?

Consider proof of E(a U b) for Kripke structure below.

s0 : {a, c}

s1 : {a}s0 `M E(a U b)

s0 `M a s1 `M E(a U b)

a ∈ `(s0) s1 `M a

a ∈ `(s1)

s0 `M E(a U b)

Circularity is bad!

c©2015 Rance Cleaveland. All rights reserved.

Page 16: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 16'

&

$

%

But What about Circular Proofs (cont.)?

Consider proof of EG a for Kripke structure below.

s0 : {a, c}

s1 : {a}s0 `M a

a ∈ `(s0) s1 `M a

a ∈ `(s1)

s0 `M EG a

s1 `M EG a

s0 `M EG a

Circularity is good!

c©2015 Rance Cleaveland. All rights reserved.

Page 17: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 17'

&

$

%

Is Circularity Bad Or Good?

It depends on the modality ... but how? And why?

Precise answers depend on understanding fixpoint characterizations of the CTL

operators.

These characterizations will also lead to model-checking algorithms for finite-state

Kripke structures.

c©2015 Rance Cleaveland. All rights reserved.

Page 18: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 18'

&

$

%

CTL Formulas and Fixpoints

Recall:

AFσ ≡ σ ∨ AX(AFσ)

Equivalently, AFσ may be seen as:

• a solution to the equation

w ≡ σ ∨ AXw,

• a fixpoint of the function

f(w) = σ ∨ AXw

Is the solution to the above equation unique? No! Consider the formula tt:

tt ≡ σ ∨ AX tt (why?).

c©2015 Rance Cleaveland. All rights reserved.

Page 19: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 19'

&

$

%

So What?

AFσ is a solution to an equation, but not a unique solution.

How does this help us with circularity?

Answer Tarski!

... Polish emigre mathematician

... Active in early to mid 1900’s

... Well-known for work in logic, algebra, lattice theory

In 1950’s, Tarski and Knaster proved:

Theorem (Tarski-Knaster Fixpoint Theorem) Every monotonic function over a

complete lattice has a complete lattice of fixpoints.

c©2015 Rance Cleaveland. All rights reserved.

Page 20: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 20'

&

$

%

Complete Lattice?

A complete lattice consists of:

• a set E of elements

• a partial ordering (“less than or equal to”) v⊆ E × E

• a least upper-bound operator⊔

∈ 2E → E

• a greatest lower-bound operatord

∈ 2E → E

Example Let S be a set. Then take:

• E = 2S

• v=⊆•⊔

=⋃

•d

=⋂

This is a complete lattice!

c©2015 Rance Cleaveland. All rights reserved.

Page 21: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 21'

&

$

%

Facts about Lattices

Theorem Let 〈E,v,⊔,d〉 be a complete lattice. Then:

1. E has a greatest element > =⊔E =

d∅.

2. E has a least element ⊥=⊔∅ =

dE.

3. (Tarski-Knaster). Let f ∈ E → E be monotonic, i.e. if e1 v e2 then

f(e1) v f(e2). Then the structure 〈{ e | e = f(e) },v,⊔,d〉 is also a

complete lattice (“complete lattice of fixpoints”).

c©2015 Rance Cleaveland. All rights reserved.

Page 22: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 22'

&

$

%

How Can This Possibly Help?

All the equations describing CTL operators have unique least and greatest

solutions! Let M = 〈S,A, `, R, sI〉 be a Kripke structure.

• 〈2S ,⊆,⋃,⋂〉 forms a complete lattice.

• Each equation has equivalent form w = f(w) where f maps sets of states

(meanings of formulas) to sets of states.

• Each of the f turns out to be monotonic over the lattice.

• Any complete lattice has a unique greatest and least element.

c©2015 Rance Cleaveland. All rights reserved.

Page 23: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 23'

&

$

%

Example

AFσ is the unique least solution to w ≡ f(w), where f(w) ≡ σ ∨ AXw.

(More precisely, the set of states satisfying AFσ is the smallest set satisfying the

equation.)

That is, any other solution is implied by AFσ.

What is the largest?

c©2015 Rance Cleaveland. All rights reserved.

Page 24: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 24'

&

$

%

Another Example

Consider:

f(w) = σ ∧ EXw

What is the least fixpoint? Greatest fixpoint?

c©2015 Rance Cleaveland. All rights reserved.

Page 25: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 25'

&

$

%

One More Example

Consider:

f(w) = σ2 ∨ (σ1 ∧ AXw)

What is the least fixpoint? Greatest fixpoint?

c©2015 Rance Cleaveland. All rights reserved.

Page 26: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 26'

&

$

%

Recall Motivation: Circular Reasoning

Least fixpoint CTL operator: Circularity bad!

Greatest fixpoint CTL operator: Circularity good!

c©2015 Rance Cleaveland. All rights reserved.

Page 27: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 27'

&

$

%

Circularity Example #1

s0 : {a, c}

s1 : {a}s0 `M E(a U b)

s0 `M a s1 `M E(a U b)

a ∈ `(s0) s1 `M a

a ∈ `(s1)

s0 `M E(a U b)

• Circularity involves least-fixpoint operator (EU)

• This proof is therefore invalid.

c©2015 Rance Cleaveland. All rights reserved.

Page 28: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 28'

&

$

%

Circularity Example #2

s0 : {a, c}

s1 : {a}s0 `M a

a ∈ `(s0) s1 `M a

a ∈ `(s1)

s0 `M EG a

s1 `M EG a

s0 `M EG a

• Circularity involves greatest-fixpoint operator (EG)

• This proof is therefore valid.

c©2015 Rance Cleaveland. All rights reserved.

Page 29: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 29'

&

$

%

Constructing Proofs for s `M σ

• Use proof rules

A,¬A,∨1,∨2,∧, EX, AX, EU1, EU2, AU1, AU2, ER1, ER2, AR1, AR2

• Proofs are valid if they end in leaves or circularities only involve maximum

fixpoint formulas.

c©2015 Rance Cleaveland. All rights reserved.

Page 30: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 30'

&

$

%

Example (Invalid) Proof: AFAGa

s0 : {a}

s1 : { }

s2 : {a}s0 `M AFAG a

. . .

s1 `M AFAG a

s0 `M AFAG a

c©2015 Rance Cleaveland. All rights reserved.

Page 31: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 31'

&

$

%

Soundness and Completeness

• Proof construction is sound.

• Proof construction is complete for finite-state Kripke structures.

• Rules can be modified to be complete for arbitrary Kripke structures (sets of

states rather than single states on the left of `M ).

c©2015 Rance Cleaveland. All rights reserved.

Page 32: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 32'

&

$

%

Algorithmic Model Checking

• We have talked about model-checking in terms of proof.

• For certain kinds of Kripke structures (i.e. finite-state), model-checking can be

performed automatically.

• Model-checking algorithms may be seen as conducting proof search.

c©2015 Rance Cleaveland. All rights reserved.

Page 33: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 33'

&

$

%

The Finite-State Model-Checking Problem for CTL

Given

• Kripke structure M = 〈S,A, R, `, sI〉 with |S| < ∞

• CTL formula σ

Compute

• Does sI |=M σ?

c©2015 Rance Cleaveland. All rights reserved.

Page 34: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 34'

&

$

%

Traditional CTL Model-Checking Algorithms

• Compute all states in S satisfying σ.

• See if sI is in this set.

Why is the calculation of these sets of states be possible?

Because of Kleene and the recursive characterizations of operators!

c©2015 Rance Cleaveland. All rights reserved.

Page 35: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 35'

&

$

%

Continuous Functions on Lattices

Definition Let 〈E,v,⊔,d〉 be a lattice. Then f ∈ E → E is continuous if

for every chain e0 v e1 v · · ·,

f(∞⊔

i=0

ei) =∞⊔

i=0

f(ei)

Lemma

1. Every continuous function is monotonic.

2. If |E| < ∞ then every monotonic function is continous.

c©2015 Rance Cleaveland. All rights reserved.

Page 36: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 36'

&

$

%

Kleene’s Fixpoint Theorem

Let 〈E,v,⊔,d〉 be a complete lattice, and let f ∈ E → E be continuous.

Then µf ∈ E and νf ∈ E, the least and greatest fixpoints of f , respectively,

can be given as follows.

µf =∞⊔

i=0

fi, where

f0 = ⊥

fi+1 = f(fi)

νf =∞l

i=0

fi, where

f0 = >

fi+1 = f(fi)

c©2015 Rance Cleaveland. All rights reserved.

Page 37: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 37'

&

$

%

How Does This Help?

• For a finite-state Kripke structure 〈S,A, R, `, sI〉, complete lattice

〈2S ,⊆,⋃,⋂〉 is finite.

• CTL operators are least / greatest fixpoints of functions f(w) over this lattice.

• All functions for PNF CTL are monotonic, hence continuous over this lattice.

c©2015 Rance Cleaveland. All rights reserved.

Page 38: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 38'

&

$

%

Calculating the Least Solution to an Equation

Assume equation is w ≡ f(w).

• Set w = ∅ (i.e. ff).

• Compute f(w).

• If w = f(w) we’re done; otherwise set w to f(w) and repeat.

E.g. w ≡ a ∨ AXw. (In other words, which states satisfy AF a?)

w f(w)

∅ {1} |= a ∨ AX∅

{1} {1, 2} |= a ∨ AX{1}

{1, 2} {1, 2} |= a ∨ AX{1, 2}

0

1 2

3

a

c©2015 Rance Cleaveland. All rights reserved.

Page 39: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 39'

&

$

%

Another Example: E(a U b)

We need to calculate the least solution to w ≡ b ∨ (a ∧ EXw).

w f(w)

0

1 2

3

ab

aa

c©2015 Rance Cleaveland. All rights reserved.

Page 40: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 40'

&

$

%

Calculating the Largest Solution to an Equation

• Set w = S (i.e. tt)

• Compute f(w).

• If w = f(w), we’re done; otherwise, set w to f(w) and repeat.

E.g. w ≡ a ∧ EXw. (In other words, which states satisfy EG a?)

w f(w)

{0, 1} {0} |= a ∧ EX{0, 1}

{0} {0} |= a ∧ EX{0}

0a

1

c©2015 Rance Cleaveland. All rights reserved.

Page 41: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 41'

&

$

%

Least vs. Greatest: An Example

Consider the equation w ≡ b ∨ (a ∧ AXw).

Least solution:

w f(w)

Greatest solution:

w f(w)

0

1 2

3a

a

b

c©2015 Rance Cleaveland. All rights reserved.

Page 42: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 42'

&

$

%

Classical CTL Model Checking

Recall that traditional CTL model checkers:

• Calculate all states that satisfy a given formula ...

• Then ask if the start state is in this set.

So how is the set of states calculated? By processing the formula from the inside

out!

c©2015 Rance Cleaveland. All rights reserved.

Page 43: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 43'

&

$

%

Example: AFAG a

0

1

2

a

a

First: For AG a, calculate largest solution to w = a ∧ AXw.

w f(w)

Second: For AFw, compute least solution to y = w ∨ AX y.

y g(y)

c©2015 Rance Cleaveland. All rights reserved.

Page 44: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 44'

&

$

%

Pragmatics I: Solving Equations Efficiently

Let M = 〈S,A, R, `, sI〉 be a Kripke structure.

Define: |M | = |S|+ |R|.

Claim: Equations defining CTL operators can be solved in |M | time.

How? Counters

c©2015 Rance Cleaveland. All rights reserved.

Page 45: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 45'

&

$

%

Huh?

E.g. to get least solution to w = σ ∨ AXw (assuming σ already known):

• Associate counter to each state.

• Counter reflects number of transitions leading to states not in current

approximation to solution.

• When a state moves into solution, counters of states with transitions leading

to state must be updated.

c©2015 Rance Cleaveland. All rights reserved.

Page 46: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 46'

&

$

%

Example: AF a

Must calculate smallest solution to w = a ∨ AXw

w = { }

0

2

3 4a

1a

1

1

2

2

1

c©2015 Rance Cleaveland. All rights reserved.

Page 47: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 47'

&

$

%

Complexity

Best classical algorithms process each state/transition once per subformula.

How many subformulas are there in formula σ? |σ|! (|σ| is number of operators

in σ).

So for Kripke structure M , CTL formula σ, model checking takes: O(|M | · |σ|)

time.

c©2015 Rance Cleaveland. All rights reserved.

Page 48: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 48'

&

$

%

Pragmatics II: “Short-circuiting”

... stop computation once status of start state is known.

E.g. If least solution is being calculated, and start state added to intermediate

approximation, can stop.

... does not affect complexity, but can improve “practical performance.”

c©2015 Rance Cleaveland. All rights reserved.

Page 49: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 49'

&

$

%

Pragmatics III: On-the-fly Model Checking

... short-circuiting taken to the extreme.

... takes a “top-down” view (“what is the minimal information I need to compute to

check if sI |=M σ”).

Approaches can be formulated in terms of proof search involving proof rules like

the ones we have studied.

Subtlety: circularity.

c©2015 Rance Cleaveland. All rights reserved.

Page 50: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 50'

&

$

%

Pragmatics IV: Efficient Data Structures

Classical algorithms require manipulations of sets of states:

• Unions, intersections

• Equality checking

• Transitions from/to sets of states

Model-checking also suffers from the State-Explosion Problem:

• Each Kripke-structure state, transition processed in worst case

• Number of Kripke-structure states is exponential in number of bits used in

“program” from which structure is generated

The right data structure can yield dramatic time/space improvements!

c©2015 Rance Cleaveland. All rights reserved.

Page 51: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 51'

&

$

%

Example: (Ordered) Binary Decision Diagrams

In many applications states are fixed-width bit vectors.

OBDDs are data structures for compactly representing:

• functions in {0, 1}n → {0, 1}

• propositions in propositional logic over variables v0, . . . , vn−1

• sets of n-width bit vectors

Or / union, and / intersection, negation / complementation, equality all supported

efficiently.

In hardware community, most successful model checkers use OBDDs.

c©2015 Rance Cleaveland. All rights reserved.

Page 52: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 52'

&

$

%

OBDDs and Sets of Fixed-Width Bit Vectors

Assume set v0, . . . , vn−1 of (boolean) variables, total ordering on variables

An OBDD is...

• a directed acyclic graph, with

• a leaf labeled 0 and a leaf labeled 1, and

• each internal node labeled by a vi, and

• each node having two edges, one labeled 0 and one 1, and

• the label of each node preceding those of its successors in the total order

In addition, OBDDs satisfy:

1. No isomorphic subgraphs

2. No “don’t cares”

c©2015 Rance Cleaveland. All rights reserved.

Page 53: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 53'

&

$

%

Example

An OBDD for the set {000, 001, 011} with ordering v0v1v2.

0

1

01

1

0

v2

1 0

v1

v0

Equivalent proposition: ¬v0 ∧ (¬v1 ∨ v2)

c©2015 Rance Cleaveland. All rights reserved.

Page 54: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 54'

&

$

%

Example

An OBDD for the set {000, 001, 011} with ordering v2v0v1.

1

0

0

0

1

1

10

v2

v0v0

v1

1

0

Equivalent proposition is the same: ¬v0 ∧ (¬v1 ∨ v2)

c©2015 Rance Cleaveland. All rights reserved.

Page 55: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 55'

&

$

%

Facts about OBDDs

1. Variable ordering influences size of OBDDs.

2. Given a fixed variable ordering, set representation is canonical (equal sets

have isomorphic OBDDs).

3. Efficient implementations exist for union, intersection, complementation,

projection, ....

c©2015 Rance Cleaveland. All rights reserved.

Page 56: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 56'

&

$

%

How Are OBDDs Used in Model Checking?

... To represent Kripke structures

• States represented as bit-vectors of length n

• Transitions represented as bit-vectors of length 2n

... To represent approximate solutions during equation solving

• If w = f(w) is an equation, process of “applying” f to get new

approximations can be given as function on OBDDs

c©2015 Rance Cleaveland. All rights reserved.

Page 57: CTL Model Checking - University Of Maryland · CMSC 630 February 25, 2015 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula

CMSC 630 February 25, 2015 57'

&

$

%

OBDD Impact on Model Checking

• Multiple orders of magnitude improvement on Kripke-structure size

– Pre-OBDD (1989): 106 states possible

– Post-OBDD (1990): 1020 states possible

• Symbolic model checking

– OBDDs can be seen as representations of boolean propositions

– Other boolean-proposition representations have been studied, and SAT

solvers used to implement model checkers

c©2015 Rance Cleaveland. All rights reserved.