Docsity

Simulations and Abstraction Methods in Program Verification - Prof. Jose Meseguer, Study notes of Computer Science

Partial preview of the text

Download Simulations and Abstraction Methods in Program Verification - Prof. Jose Meseguer and more Study notes Computer Science in PDF only on Docsity!

Program Verification:

Lecture 26

Jos´

e Meseguer

Computer Science Department

University of Illinois at Urbana-Champaign

1

Simulations

Given two Kripke structures

A

A,

A

, L

A

, and

B

B,

B

, L

B

, both having the same set

AP

of atomic

propositions, an

AP

simulation

H

A −→ B

of

A

by

B

is a

binary relation

H

A

×

B

such that, denoting pairs

a, b

H

by

aHb

, we have:

if

a

A

a

′

and

aHb

, then there is a

b

′

B

such that

b

B

b

′

and

a

′

Hb

′

, and

a

A

b

B

aHb

L

B

b

L

A

a

.

If the relation

H

is a

function

, then we call

H

an

AP

simulation map

. If both

H

and

H

−

1

are

AP

-simulations,

then we call

H

a

bisimulation

.

2

Simulations Reflect Satisfaction of

LT L

Formulae

We say that an

AP

-simulation

H

A −→ B

reflects

the

satisfaction of an

LT L

formula

ϕ

iff

B

, b

ϕ

and

aHb

imply

A

, a

ϕ

.

A fundamental result, allowing us to prove the satisfactionof an

LT L

formula

ϕ

in an infinite-state system

A

by

proving the same satisfaction in a finite-state system

B

that

simulates it is the following, Theorem

:

AP

-simulations always reflect satisfaction of

LT L

AP

formulae.

4

Simulations Reflect Satisfaction of

LT L

Formulae (II)

Proof:

First of all, note that we can extend

H

to a binary

relation

H

P ath

A

P ath

B

, where,

π

Hρ

n

IN

π

n

Hρ

n

Lemma

: If

aHb

, than for each

π

P ath

A

such that

π

a

there is a

ρ

P ath

B

such that

ρ

b

and

π

Hρ

.

Proof of Lemma1:

The proof amounts to an inductive

argument that, if we have built the first

n

stages of

ρ

, then

we can always build the

n

stage. So, assume that we

have

ρ

defined for

i

n

with

ρ

b

, and with:

5

Simulations Reflect Satisfaction of

LT L

Formulae (IV)

Proof of Lemma

: The proof is by structural induction on

the structure of

LT L

formulae. We prove the base case and

the case

ϕ

ψ

, and leave the rest as an exercise.

For

p

AP

we have,

B

, b, ρ

p

iff

p

L

B

b

, which by

H

simulation and

aHb

is equivalent to

p

L

A

a

, which is itself

equivalent to,

A

, a, π

ϕ

.

Assume that the result holds for

ψ

. Let us then show that

it holds for

ϕ

ψ

. We have,

B

, b, ρ

ψ

iff

B

, ρ

, s

ρ

ψ

. But note that if

π

Hρ

, then for any

n

IN

we

have,

s

n

π

Hs

n

ρ

. Therefore, by the induction hypothesis we

can conclude that,

A

, π

, s

π

ψ

, which is equivalent to,

A

, a, π

ψ

. q.e.d.

7

Simulations Reflect Satisfaction of

LT L

Formulae (V)

We are now essentially done. Suppose

B

, b

ϕ

and

aHb

.

Then we have,

B

, b, ρ

ϕ

for any

ρ

P ath

B

such that

ρ

b

. To prove

A

, a

ϕ

, we have to show that for each

π

P ath

A

with

π

a

we have,

A

, a, π

ϕ

. But, by

Lemma1, for each such

π

we have a

ρ

such that,

ρ

b

,

and

π

Hρ

. Then, by Lemma2, we have,

A

, a, π

ϕ

. q.e.d.

We say that an

AP

-simulation

H

A −→ B

preserves

the

satisfaction of an

LT L

formula

ϕ

iff

A

, a

ϕ

and

aHb

imply

B

, b

ϕ

.

Corollary

:

AP

-bisimulations always reflect and preserve

satisfaction of

LT L

AP

formulae.

8

Quotient Abstractions

Let

A

A,

A

, L

A

be a Kripke structure on

AP

. We call

an equivalence relation

on

A

label-preserving

if

a

a

′

L

A

a

L

A

a

′

. We can use a label-preserving

equivalence relation

to define a new Kripke structure,

A

A/

A

/

≡

, L

A

/

≡

, where:

[

a

1

]

A

/

≡

[

a

2

]

iff

a

′ 1

[

a

1

]

a

′ 2

[

a

2

]

s.t.

a

′ 1

A

a

′ 2

.

L

A

/

≡

([

a

]) =

L

A

a

It is then trivial to check that the projection map toequivalence classes

q

≡

a

[

a

]

is an

AP

-simulation map

q

≡

A −→ A

, which we call the

quotient abstraction

defined by

.

10

Equational Quotient Abstractions

We are of course particularly interested in abstractionmethods for systems specified by rewrite theories. Recallthat, given a rewrite theory

R

, E, φ, R

plus equations

D

defining state predicates

in a kind

k

of states, we have

associated to it the Kripke structure,

K

R

, k

Π

T

Σ

/E,k

1 R

, L

Π

This Kripke structure may be infinite-state, so that wecannot use an

LT L

model checker to verify its properties; or

it can have a finite state space too big to make modelchecking feasible. We are therefore interested in definingquotient abstractions of Kripke structures of this kind.

11

Equational Quotient Abstractions (III)

Then, a quite general method for defining quotientabstractions of the Kripke structure K

R

, k

Π

T

Σ

/E,k

1 R

, L

Π

is adapting to Kripke

structures the method followed in Lecture 23 to defineequational abstractions for invariants. That is, we can addto

E

a set

G

of equations such that

′

, E

G

D

also

protects

BOOL

, and consider the rewrite theory

R

/G

, E

G, φ, R

, which has an associated Kripke

structure

K

R

/G, k

Π

T

Σ

/E

∪

G,k

1 R

/G

, L

Π

/G

, with

L

Π

/G

([

t

]

E

∪

G

θ

p

AP

Π

E

G

D

t

θ

p

true

Note that we have an equivalence relation

G

on

T

Σ

/E,k

,

namely,

[

t

]

E

G

[

t

′

]

E

E

G

t

t

′

[

t

]

E

∪

G

= [

t

′

]

E

∪

G

13

Equational Quotient Abstractions (IV)

And of course we have a bijection

T

Σ

/E,k

G

T

Σ

/E

∪

G,k

.

The key question now is: under what conditions is the map q

≡

G

: [

t

]

E

[

t

]

E

∪

G

a quotient abstraction of Kripke structures

q

≡

G

K

R

, k

Π

−→ K

R

/G, k

Π

If it is so, we will call

K

R

/G, k

Π

T

Σ

/E

∪

G,k

1 R

/G

, L

Π

/G

the

equational quotient abstraction

of

K

R

, k

Π

defined by

G

.

Of course, to use

R

/G

as a system module in Maude to

model check

LT L

properties of

R

, we will also need to

require that

R

/G

satisfies the usual executability conditions.

14

Equational Quotient Abstractions (V)

Theorem 2

. Let

R

, E, φ, R

be a

k

-deadlock free

rewrite theory, and let

D

be equations defining (possibly

parametric) state predicates

fully defined for all states of

kind

k

as either

true

or

false

, and assume that

′

, E

D

protects

BOOL

. Let then

G

be a set of

-equations such that

′

, E

G

D

also protects

BOOL

. Then the map

q

≡

G

: [

t

]

E

[

t

]

E

∪

G

is a quotient abstraction of Kripke

structures

q

≡

G

K

R

, k

Π

−→ K

R

/G, k

Π

Proof:

Since

R

is

k

-deadlock free, it is trivial to check that

R

/G

is also

k

-deadlock free and that therefore we have

1 R

/G

1 R

/G

1 R

G

16

Equational Quotient Abstractions (VI)

The only remaining thing to check is that

G

is

label-preserving. This is equivalent to proving the followingequivalences for each

p

and ground substitution

θ

:

E

D

t

θ

p

true

E

G

D

t

θ

p

true

E

D

t

θ

p

false

E

G

D

t

θ

p

false

The

follow by monotonicity of equational reasoning.

The

follow from the protecting

BOOL

assumption, since

we can reason by contradiction. Suppose, for example, that E

G

D

t

θ

p

true

but

E

D

t

θ

p

true

. By the

protecting

BOOL

assumption this forces

E

D

t

θ

p

false

, which implies

E

G

D

t

θ

p

false

, contradicting the protection of

BOOL

. q.e.d.

17

Executability of Equational Quotient Abstractions (II)

The checks for executability may be positive or negative.But if, say, the equations

E

G

are not ground confluent,

we may be able to complete them to get a semanticallyequivalent set of equations, say

E

′

which is ground

confluent, sort-decreasing, and terminating. Similarly, if therules

R

are not ground coherent, we may be able to

complete them to get an equivalent set

R

′

of rules that is

ground coherent. In this way we would obtain a rewritetheory

R

′

, E

′

, φ, R

′

semantically equivalent to

R

/G

.

Therefore we would have an isomorphism of a Kripkestructures

K

R

′

, k

Π

K

R

/G, k

Π

, but now with the crucial

propety that

R

′

is

executable

, so we can use

R

′

to verify our

desired

LT L

properties about

R

.

19

A Bakery Protocol Example

In the early stages of algebraic specification all formalismswould use a

STACK

data type as an example. In the relatively

early stages of abstraction techniques it is likewise

de

rigueur

to show how the technique in question handles

Lamport’s bakery protocol.This is an infinite-state protocol that achieves mutualexclusion between processes by the usual method commonin bakeries and deli shops: there is a number dispenser, andcustomers are served in sequential order according to thenumber that they hold.A simple Maude specification for the case of two processesis as follows,

20