78 Maude 1 Maude [1] UIUC J. Meseguer ( 1 ) ( ) Maude Maude SRI 90 UIUC SRI Maude SRI S. Eker C++ Maude 2 Maude Meseguer OBJ 1983-84 OBJ2[3] OBJ Maude OBJ 1 CafeOBJ 3 Maude 4 Maude CafeOBJ Maude: A Computer Language based on Rewriting Logic and its Implementation. Kazuhiro Ogata, Masaki Nakamura, Kokichi Futatsugi,, School of Information Science, JAIST., Vol.25, No.2 (2008), pp.78 84. [ ] 2007 12 27. 1 Real-Time Maude 2 http://maude.cs.uiuc.edu/ 3 http://www.ldl.jaist.ac.jp/cafeobj/ 4 Meseguer Maude [1] [4] Eker Maude SRI (1993-97) [1] [2] ( ) ( ) Maude [1] 800 AC (Associative-Commutative) (LTL search ) LTL SPIN (on-the-fly explicit state) SMV BDD SPIN SPIN Maude 5 Maude 6 5 SRI SAL infbmc 6 CafeOBJ search LTL SAL
Vol. 25 No. 2 Apr. 2008 79 ( ) [5] search ( ) ( ) Maude 2 Maude 7 2 8 (fmod M is endfm) (sort S.) (subsort S 1 < S 2.) (op f : S 1... S n -> S [ ].) ([c]eq LHS = RHS [if C].) ([c]mb T : S [if C].) S 1 < S 2 S 1 S 2 f (assoc) (comm) LHS RHS C C RHS LHS C T S C C C C 1 /\... /\ C n C 7 (LTL ) 8 C 1,..., C n C i (1) (T = T ) (2) (T := T ) (3) Bool T (3) (1)(T = true) (1) (2) T LHS C 1,...,C i 1 (2) T T 9 (1) T T 10 (2) T LHS T T 11 (mod M is ) ([c]rl [[L] :] LHS => RHS [if C].) L LHS RHS C C ( ) RHS LHS C t 0 1 t 0 t 0 t 1 1 t 0 t 1 12 C C 1 /\... /\ C n C i (1) (3) (4) (T => T ) (4) T LHS C 1,...,C i 1 T T (4) T 9 T ( ) 10 == true false (3) T == T (1) 11 12 LHS
80 0 T M ( ) 3 (pr) (ex) (inc) pr M M (no junk) (no confusion) M ex M M inc M M 3 (Critical Section) (Remainder Section) i Loop Remainder Section rs: tmp i := enq(queue,i); es: queue := tmp i ; ws: repeat until top(queue) =i; Critical Section cs: tmp i := deq(queue); ds: queue := tmp i ; queue tmp i 13 enq deq top rs es ws cs ds ws ( ) 1 rs tmp i queue (empty ) 4 Maude S 0 S 0 Maude S 0 V 0 I 0 T 0 13 tmp i queue ( ) 2 V 0 {pc i :Label i P} {tmp i : Queue i P} {queue : Queue} Label Queue P ( Pid ) pc i i ( ) tmp i i tmp i queue queue S 0 V 0 S 0 I 0 i P pc i =rs tmp i =empty queue =empty ( 1 ) T 0 {eq 1 i i P} {eq 2 i i P} {wt i i P} {dq1 i i P} {dq2 i i P} wt i i ws 1 eq1 i eq2 i dq1 i dq2 i i rs es cs ds (1) eq1 i (2) wt i (1) eq1 i pc i =rs pc i es tmp i queue i (2) wt i pc i =ws queue i pc i cs S 0 QLOCK QLOCK mod QLOCK is pr LABEL. pr PID. pr QUEUE. sorts Var Sys. subsort Var < Sys. op : Sys Sys -> Sys [assoc comm]. op pc[_]:_ : Pid Label -> Var. op queue:_ : Queue -> Var. op tmp[_]:_ : Pid Queue -> Var. vars Q R : Queue. var I : Pid. rl [eq1] : (pc[i]: rs) (queue: Q) (tmp[i]: R) => (pc[i]: es) (queue: Q) (tmp[i]: enq(q,i)). rl [eq2] : (pc[i]: es) (queue: Q) (tmp[i]: R) => (pc[i]: ws) (queue: R) (tmp[i]: R). crl [wt] : (pc[i]: ws) (queue: Q) => (pc[i]: cs) (queue: Q) if top(q) == I.
Vol. 25 No. 2 Apr. 2008 81 rl [dq1] : (pc[i]: cs) (queue: Q) (tmp[i]: R) => (pc[i]: ds) (queue: Q) (tmp[i]: deq(q)). rl [dq2] : (pc[i]: ds) (queue: Q) (tmp[i]: R) => (pc[i]: rs) (queue: R) (tmp[i]: R). LABEL PID QUEUE fmod LABEL is sort Label. ops rs es ws cs ds : -> Label. endfm fmod PID is sort Pid. ops p1 p2 : -> Pid. endfm fmod QUEUE is pr PID. sort Queue. op empty : -> Queue. op : Pid Queue -> Queue. op enq : Queue Pid -> Queue. op deq : Queue -> Queue. op top : Queue -> Pid. var Q : Queue. vars X Y : Pid. eq enq(empty,x) = X empty. eq enq((y Q),X) = Y enq(q,x). eq deq(empty) = empty. eq deq((x Q)) = Q. eq top((x Q)) = X. endfm PID 2 ( ) p1 p2 Sys S 0 Var ( ) pc[_]:_ queue:_ tmp[_]:_ pc i queue tmp i pc[_]:_ tmp[_]:_ 1 i 2 pc i tmp i queue:_ queue pc i cs pc[i]: cs S 0 14 S 0 14 SPIN Maude ( ) Z ( ) S 0 Maude (pc[p1]: rs) (pc[p2]: rs) (queue: empty) (tmp[p1]: empty) (tmp[p2]: empty) eq 1 i eq2 i wt i dq1 i dq2 i eq1 eq2 wt dq1 dq2 LHS wt i pc i =ws top(queue) =i LHS (pc[i]: ws) pc[p1]: rs pc[p2]: rs trans by eq1 queue: empty with I = p1 tmp[p1]: empty tmp[p2]: empty trans by eq2 with I = p1 pc[p1]: ws pc[p2]: rs queue: p1 empty trans by wt with I = p1 tmp[p1]: p1 empty tmp[p2]: empty pc[p1]: es pc[p2]: rs queue: empty tmp[p1]: p1 empty tmp[p2]: empty pc[p1]: cs pc[p2]: rs queue: p1 empty tmp[p1]: p1 empty tmp[p2]: empty ( ) eq1 LHS (pc[p1]: rs) (queue: empty) (tmp[p1]: empty) RHS (pc[p1]: es) (queue: empty) (tmp[p1]: p1 empty) S 0 QLOCK-INIT 15 mod QLOCK-INIT is pr QLOCK. op init : -> Sys. eq init = (pc[p1]: rs) (pc[p2]: rs) (queue: empty) (tmp[p1]: empty) (tmp[p2]: empty). 5 search search t t 15 init( ) ( ) ( )
82 pc i =cs i 1 S 0 search [1] in QLOCK-INIT : init =>* (pc[p1]: cs) (pc[p2]: cs) (S:Sys). init (pc[p1]: cs) (pc[p2]: cs) (S:Sys) ( ) [1] 1 S Sys Maude Solution 1 (state 33) states: 34 rewrites: 82 in 1ms cpu (0ms real) (82000 rewrites/second) S:Sys --> queue: (p2 empty) (tmp[p1]: p1 empty) tmp[p2]: p2 empty search 33 (init 0 ) 33 ( 33) 33 ( ) show path (show path 33.) state 0, Sys: queue: empty (pc[p1]: rs) (pc[p2]: rs) (tmp[p1]: empty) tmp[p2]: empty ===[... [label eq1]. ]===> state 1, Sys: queue: empty (pc[p1]: es) (pc[p2]: rs) (tmp[p1]: p1 empty) tmp[p2]: empty ===[... [label eq1]. ]===> state 3, Sys: queue: empty (pc[p1]: es) (pc[p2]: es) ===[... [label eq2]. ]===> state 6, Sys: queue: (p1 empty) (pc[p1]: ws) (pc[p2]: es) ===[... [label wt]. ]===> state 13, Sys: queue: (p1 empty) (pc[p1]: cs) (pc[p2]: es) ===[... [label eq2]. ]===> state 23, Sys: queue: (p2 empty) (pc[p1]: cs) (pc[p2]: ws) ===[... [label wt]. ]===> state 33, Sys: queue: (p2 empty) (pc[p1]: cs) (pc[p2]: cs) eq2 13 23 queue (p1 empty) (p2 empty) wt 23 33 p1 p2 queue rs es 2 1 (rs: queue := enq(queue,i);) i S 0 2 eq1 i eq 2 i 1 eq i S 1 S 0 Maude 2 eq1 eq2 1 S 1 Maude 16 rl [eq] : (pc[i]: rs) (queue: Q) => (pc[i]: ws) (queue: enq(q,i)). search 2 S 1 6 LTL LTL Maude model-checker.maude in (in model-checker) 2 LTL S 1 2 LTL 2 LTL 2 wait crit mod QLOCK-PREDS is pr QLOCK-INIT. inc SATISFACTION. subsort Sys < State. ops wait crit : Pid -> Prop. var P : Pid. var S : Sys. eq (pc[p] : ws) S = wait(p) = true. eq (pc[p] : cs) S = crit(p) = true. 16
Vol. 25 No. 2 Apr. 2008 83 SATISFACTION model-checker.maude ( ) _ =_ LTL mod QLOCK-CHECK is inc QLOCK-PREDS. inc MODEL-CHECKER. inc LTL-SIMPLIFIER. ops mutex lofree : -> Formula. eq mutex = ([] ~(crit(p1) /\ crit(p2))). eq lofree = (wait(p1) -> crit(p1)) /\ (wait(p2) -> crit(p2)). MODEL-CHECKER model-checker.maude modelcheck LTL-SIMPLIFIER LTL ~_ _/\_ ( ) ( ) []_ _ ->_ LTL Henceforth(Λ) Leads-to(ψ) f g LTL Λ f ( )f f ψ g f g mutex lofree LTL S 1 2 LTL ( ) red in QLOCK-CHECK : modelcheck(init,mutex). red in QLOCK-CHECK : modelcheck(init,lofree). 2 S 1 mutex ( ) 2 S 1 lofree ( ) {queue: empty (pc[p1]: rs) (pc[p2]: rs) (tmp[p1]: empty) tmp[p2]: empty, eq}... {queue: (p2 empty) (pc[p1]: rs) (pc[p2]: cs) (tmp[p1]: p2 empty) tmp[p2]: p1 empty, dq1} {queue: (p2 empty) (pc[p1]: rs) (pc[p2]: ds) (tmp[p1]: p2 empty) tmp[p2]: empty, eq} {queue: (p2 p1 empty) (pc[p1]: ws) (pc[p2]: ds) (tmp[p1]: p2 empty) tmp[p2]: empty, dq2}, {queue: empty (pc[p1]: ws) (pc[p2]: rs) (tmp[p1]: p2 empty) tmp[p2]: empty, eq} {queue: (p2 empty) (pc[p1]: ws) (pc[p2]: ws) (tmp[p1]: p2 empty) tmp[p2]: empty, wt} {queue: (p2 empty) (pc[p1]: ws) (pc[p2]: cs) (tmp[p1]: p2 empty) tmp[p2]: empty, dq1} {queue: (p2 empty) (pc[p1]: ws) (pc[p2]: ds) (tmp[p1]: p2 empty) tmp[p2]: empty, dq2}) p1 queue dq2 queue (p2 p1 empty) empty p1 ws queue cs ds 2 1 (cs: queue := deq(queue);) i S 1 2 dq1 i dq2 i 1 dq i S 2 S 1 Maude 2 dq1 dq2 1 S 2 Maude rl [dq] : (pc[i]: cs) (queue: Q) => (pc[i]: rs) (queue: deq(q)). 2 red 2 S 2 mutex lofree 17 17 lofree LTL LTL S 2 lofree queue (rl [xr] : (pc[i]: rs) (queue: Q) => (pc[i]: rs) (queue: Q).) lofree
84 7 Maude [5] [1] Clavel, M., et al.: All About Maude A High- Performance Logical Framework: How to Specify, Program and Verify Systems in Rewriting Logic, LNCS, Vol. 4350, Springer, 2007. [2] Futatsugi, K.: Verifying Specifications with Proof Scores in CafeOBJ, in 21st ASE, 2006, pp. 3 10. [3] Futatsugi, K., Goguen, J. A., Jouannaud, J. -P. and Meseguer, J.: Principles of OBJ2, in 12th POPL, 1985, pp. 52 66. [4] Meseguer, J.: From OBJ to Maude and Beyond, in Algebra, Meaning, and Computation: A Festschrift Symposium in Honor of Joseph Goguen, LNCS, Vol. 4060, Springer, 2006, pp. 252 280. [5] Ogata, K. and Futatsugi, K.: Comparison of Maude and SAL by Conducting Case Studies Model Checking a Distributed Algorithm, IEICE Trans. Fundamentals, Vol. E90-A(2007), pp. 1690 1703.