



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




































TOK-RING
TOK-RING
(fth NZNAT* is
protecting NAT .op * : -> NzNat. endfth) (fmod NAT/(N :: NZNAT*) is
sort Nat/(N) .op ‘[_‘] : Nat -> Nat/(N) .op + : Nat/(N) Nat/(N) -> Nat/(N) .op * : Nat/(N) Nat/(N) -> Nat/(N) .vars I J : Nat .ceq [I] = [I rem *] if I >= * .eq [I] + [J] = [I + J] .eq [I] * [J] = [I * J]. endfm)
TOK-RING
TOK-RING
◦
◦
2
×
n
n
TOK-RING
(omod CHECK-TOK-RING(N :: NZNAT*) is
inc TOK-RING(N) .inc MODEL-CHECKER .subsort Configuration < State .op inCrit : Nat/(N) -> Prop .op twoInCrit : -> Prop .var
I : Nat.
vars X Y : Nat/(N) .var
C : Configuration.
var
F : Formula.
eq < X : Proc | mode : critical > C |= inCrit(X) = true .eq < X : Proc | mode : critical > < Y : Proc | mode : critical > C
|= twoInCrit = true.
TOK-RING
n
n
= 5
(view 5 from NZNAT* to NAT is
op * to term 5. endv)
true
TOK-RING
n
= 5
true
L
R
( L
)^
L
T
Reach
(R
(L
))
checking or deductive proof.We can illustrate this general method by definig therewriting logic semantics of a simple parallel language called PARALLEL
PARALLEL
*** A simple parallel language and its rewriting logic semantics.*** Extends an even simpler language presented in ‘‘The Maude LTL*** Model Checker’’ by Eker, Meseguer, and Sridaranarayanan,*** in Proc. WRLA’02, ENTCS Vol. 71, Elsevier, 2002.fmod MEMORY is inc INT.
inc QID.
sorts Memory Bool? Int? .subsorts Bool < Bool?. subsorts Int < Int? .op null : -> Int? .op none : -> Memory .op __ : Memory Memory -> Memory [assoc comm id: none] .op [,] : Qid Int? -> Memory .op in : Qid Memory -> Bool? .var Q : Qid.
var M : Memory.
var N? : Int?.
eq null + N? = null .eq null * N? = null .eq Q in [Q,N?] M = true. endfm
fmod EXPRESSION is
inc MEMORY .sort Expression .subsorts Qid Int? < Expression .op +’ : Expression Expression -> Expression [ctor] .op *’ : Expression Expression -> Expression [ctor] .op eval : Expression Memory -> Int? .var Q : Qid .var M : Memory .vars N N’ : Int .var N? : Int? .vars E E’ : Expression .eq eval(N?, M) = N? .eq eval(Q, [Q, N?] M) = N? .ceq eval(Q,M) = null if Q in M =/= true .eq eval(E +’ E’, M) = eval(E,M) + eval(E’,M) .eq eval(E *’ E’, M) = eval(E,M) * eval(E’,M). endfm
***(Syntax for a trival sequential language.
We allow abstracting
out program fragments as elements of sorts LoopingUserStatement andUserStatement.
Elements of sort LoopingUserStatement abstract out
potentially nonterminating program fragments, whereas elements of sortUserStatement but not of sort LoopingUserStatement abstract out terminatingprogram fragments.)fmod SEQUENTIAL is
inc TESTS .inc EXPRESSION .sorts UserStatement LoopingUserStatement Program .subsort LoopingUserStatement < UserStatement < Program .op skip : -> Program .op ; : Program Program -> Program [prec 61 assoc id: skip] .op := : Qid Expression -> Program .op if_then_fi : Test Program -> Program .op while_do_od : Test Program -> Program .op repeat_forever : Program -> Program. endfm
PARALLEL
mod PARALLEL is
inc SEQUENTIAL .inc TESTS .sorts Pid Process Soup MachineState .subsort Process < Soup .subsort Int < Pid .op [,] : Pid Program -> Process .op empty : -> Soup .op | : Soup Soup -> Soup [prec 61 assoc comm id: empty] .op {,,_} : Soup Memory Pid -> MachineState.
vars P R : Program .var S : Soup .var U : UserStatement .var L : LoopingUserStatement .vars I J : Pid .var M : Memory .var Q : Qid .vars N? X? : Int? .var T : Test .var E : Expression .rl {[I, U ; R] | S, M, J} => {[I, R] | S, M, I} .rl {[I, L ; R] | S, M, J} => {[I, L ; R] | S, M, I} .rl {[I, (Q := E) ; R] | S, [Q, X?] M, J} =>
{[I, R] | S, [Q,eval(E,[Q, X?] M)] M, I}.
crl {[I, (Q := E) ; R] | S, M, J} =>
{[I, R] | S, [Q,eval(E,M)] M, I} if Q in M =/= true.
p
p
c
p
c
turn
{
1
,^ 2
}
PARALLEL
repeat
c1 := 1 ;while c2 = 1 do
if turn = 2 then
c1 := 0 ;while turn = 2 do skip od ;c1 := 1 fi od ;crit ;turn := 2 ;c1 := 0 ;rem forever.