Docsity

Associating Kripke Structures to Rewrite Theories: Model Checking LTL Properties in Maude , Study notes of Computer Science

Partial preview of the text

Download Associating Kripke Structures to Rewrite Theories: Model Checking LTL Properties in Maude and more Study notes Computer Science in PDF only on Docsity!

Program Verification:

Lecture 22

Jos´ e Meseguer Computer Science Department University of Illinois at Urbana-Champaign 1

The

LTL

Module The LTL syntax, in a typewriter approximation of themathematical syntax, is supported in Maude by thefollowing

LTL

functional module (in the file model-checker.maude ). fmod LTL is sorts Prop Formula .subsort Prop < Formula. *** primitive LTL operators ops True False : -> Formula [ctor format (g o)] .op ~_ : Formula -> Formula [ctor prec 53 format (r o d)] .op _/_ : Formula Formula -> Formula [comm ctor gather (E e) prec 55 format (d r o d)]. op / : Formula Formula -> Formula [comm ctor gather (E e) prec 59 format (d r o d)]. 2

eq [] f = False R f .eq f W g = (f U g) / [] f .eq f |-> g = [](f -> (<> g)) .eq f => g = [] (f -> g) .eq f <=> g = [] (f <-> g). *** negative normal form eq ~ True = False .eq ~ False = True .eq ~ ~ f = f .eq ~ (f / g) = ~ f /\ ~ g .eq ~ (f /\ g) = ~ f / ~ g .eq ~ O f = O ~ f .eq ~(f U g) = (~ f) R (~ g) .eq ~(f R g) = (~ f) U (~ g). endfm 4

The

LTL

Module (II) Note the subsort Prop of Formula , corresponding to the set AP of atomic propositions. For the moment this is left unspecified. We will explain in what follows how suchatomic propositions are defined for a given system module

M

. Note that the nonconstructor connectives have been definedin terms of more basic constructor connectives in the firstset of equations. But since there are good reasons to putan LTL formula in negative normal form by pushing the negations next to the atomic propositions (this is specifiedby the second set of equations) we need to consider alsothe duals of the basic connectives

,^

U

, and

as constructors. That is, we need to also have as constructorsthe dual connectives:

R

, and

(note that

is self-dual). 5

Associating Kripke structures to Rewrite Theories (II) This is because the state predicates need not be related tothe operational semantics of

M

: they are just certain predicates about the states of the system specified by

M

that are needed to specify some properties . Therefore, after choosing a given kind, say [Foo] , in

M

as our kind for states we can specify the relevant statepredicates in a module

M-PREDS

protecting

M

according to the following general pattern: mod M-PREDS is protecting M. including SATISFACTION .subsort Foo < State .... endm 7

Associating Kripke structures to Rewrite Theories (III) Where the dots ‘

’ indicate the part in which the syntax and semantics of the relevant state predicates is specified,as further explained in what follows. The module SATISFACTION (which is contained in the file model-checker.maude ) is very simple, and has the following specification: fmod SATISFACTION is protecting LTL .sort State .op |= : State Formula ~> Bool. endfm where the sort State is unspecified. However, by importing SATISFACTION into

M-PREDS

and giving the subsort declaration 8

Associating Kripke structures to Rewrite Theories (V) In Maude we can define parametric state predicates, that is, operators of sort Prop which need not be constants, but may have one or more sorts as parameter arguments. Wethen define the semantics of such state predicates (when the predicate holds) by appropriate equations.We can illustrate all this by means of a simple mutualexclusion example. Suppose that our original systemmodule

M

is the following module

MUTEX

, in which two processes, one named a and another named b , can be either waiting or in their critical section, and take turns accessingtheir critical section by passing each other a different token (either

or

). 10

Associating Kripke structures to Rewrite Theories (VI) mod MUTEX is sorts Name Mode Proc Token Conf .subsorts Token Proc < Conf .op none : -> Conf .op __ : Conf Conf -> Conf [assoc comm id: none] .ops a b : -> Name .ops wait critical : -> Mode .op [,] : Name Mode -> Proc .ops * $ : -> Token .rl [a-enter] : $ [a,wait] => [a,critical] .rl [b-enter] : * [b,wait] => [b,critical] .rl [a-exit] : [a,critical] => [a,wait] * .rl [b-exit] : [b,critical] => [b,wait] $. endm 11

Associating Kripke structures to Rewrite Theories (VIII) Note the two equations, defining when each of the twoparametric state predicates holds in a given state.The above example illustrates a general method by which desired state predicates for a module

M

are defined in a protecting extension, say

M-PREDS

, of

M

which imports SATISFACTION . One specifies the desired states by choosing a sort in

M

and declaring it as a subsort of State

. One then defines the syntax of the desired state predicates as operators of sort Prop , and defines their semantics by means of a set of equations that specify for what states a given statepredicate evaluates to true . 13

Associating Kripke structures to Rewrite Theories (IX) We assume that those equations, when added to those of

M

, are (ground) Church-Rosser and terminating.Note that only the cases when a predicate holds need to be specified: given a state t and a, possibly parametric, state predicate p

u 1 ,... , u n

, when the ground expression t

p

u 1 ,... , u n

cannot be simplified to true , then the predicate does not hold. This means that to specify the semantics of the state predicates it is enough to give(possibly conditional) equations of the general form, t

p

v 1 ,... , v n

true if

C.

There is in principle no need to specify when a statepredicate is false . 14

Associating Kripke structures to Rewrite Theories (XI)

AP

Π

θ

p

|^

p

, θ ground substitution

where, by convention, we use the simplified notation θ

p

to denote the ground term θ

p

x 1 ,... , x n

. This defines a labeling function

L

Π on the set of states T Σ /E,k assigning to each

[

t

]

T

Σ /E,k the set of atomic propositions,

L

Π

([

t

]) =

θ

p

AP

Π

E

D

t

θ

p

true

The Kripke structure we are interested in is then

K

R

, k

Π

T

Σ /E,k

1 R

, L

Π

16

Associating Kripke structures to Rewrite Theories (XII) Where

1 R

  • denotes the total relation extending the one-step

R

-rewriting relation

1 R among states of kind k , that is,

[

t

]^

1 R

[

t ′

]^

holds iff there are u

[

t

]

and u ′^

[

t ′

]

such that u ′^ is the result of applying one of the rules in

R

to u at some position.Under the usual assumptions that

E

is (ground) Church-Rosser and terminating (perhaps modulo someaxioms

A

contained in

E

) and

R

is (ground) coherent relative to

E

, u can always be chosen to be the canonical from of t under the equations

E

. In terms of the initial algebra

T

Reach ( R ) , we have the equivalent characterization, [ t

]

1 R

[

t

′]

[(

t

t

′)]

T

Reach ( R ) ,Arrow 1

17

Decidability of Propositional LTL (II) A decision procedure of this kind is called a model checking algorithm , since it checks whether ϕ holds in the model

A

with initial state a

. Detailed discussion of such algorithms for a variety of temporal logics such as

LT L, CT L

, and

CT L

∗ is beyond the scope of this course; see the excellent text“Model Checking” by Clark, Grumberg, and Peled. Thereare two rough classes of model checking algorithms:

explicit-state model checking algorithms, that explicitly search the state space of

A

to find a counterexample;

symbolic model checking algoritms, that use a symbolic Boolean representation of sets of states (typically BDDs) to compute the fixpoint of the transitionrelation, i.e., the set Reach A

a

. 19

The Maude Model Checker Suppose that, given a system module

M

specifying a rewrite theory

R

, E, φ, R

, we have:

chosen a kind k in

M

as our kind of states;

defined some state predicates

and their semantics in a module, say

M-PREDS

, protecting

M

by the method already explained in this lecture. Then, as explained earlier, this defines a Kripke structure K

R

, k

Π on the set of atomic propositions

AP

Π

. Given an initial state

[

t

]

T

Σ /E,k and an LTL formula ϕ

LT L

AP

Π

we would like to have a procedure to decide the satisfactionrelation, 20