-
Notifications
You must be signed in to change notification settings - Fork 0
/
bioAmbient.maude
297 lines (226 loc) · 9.19 KB
/
bioAmbient.maude
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
***(NOTE :
1-controllare bene i casi particolari delle sostituzioni, cinni non è detto sia esportabile agli ambienti
sull'articolo usano, ad esempio il multiple substitution che permette di andare a fare il lifting all'interno
degli ambienti...?
2- le input e output sequences credevo fossero state aggiunte alla sintassi, invece mi sono reso conto che erano proprie dei MA
il corrispondente dei BA sono le azioni, controllare come puo' funzionare il comportamento .
3- la congruenza "Renaming bound name" non viene specificata .
4- si assume che gli identficatori dei canali di input sia diverso da quello delle new
6- INSERIRE owise per i messaggi.
7- IMPORTANTE i quid dei messaggi in input devono essere anch'essi definiti come name senno' si hanno situazioni particolari tipo
8- chiedere per lo scoping dei messaggi, le variabili esterne fanno parte dello scope?
)***
***(fmod ATYPES is sort AType . endfm)***
fmod ACID is
pr QID .
sort Name .
***subsort Qid < Name .
op _`{_`} : Qid Nat -> Name [prec 1].
endfm
fmod PROCESS is
pr QID .
sorts ProcessConstant Process .
subsort Qid < ProcessConstant < Process .
endfm
***( We don't consider the multiple message behaviour )***
fmod CAPABILITY is
pr ACID .
sort Capability .
****subsorts Name < Capability .
op enter_ : Name -> Capability .
op accept_ : Name -> Capability .
op exit_ : Name -> Capability .
op expel_ : Name -> Capability .
op merge+_ : Name -> Capability .
op merge-_ : Name -> Capability .
endfm
fmod DIRECTION is
sort Direction .
op local : -> Direction .
op s2s : -> Direction .
op p2c : -> Direction .
op c2p : -> Direction .
endfm
fmod ACTIONS is
pr ACID .
pr DIRECTION .
sorts Action Msg .
subsort Name < Msg .
op __!`{_`} : Direction Name Msg -> Action [prec 18] .
op __?`{_`} : Direction Name Qid -> Action [prec 18] .
endfm
fmod CINNI is
inc ACTIONS .
pr PROCESS .
inc CAPABILITY .
sorts Subst Comunication .
subsorts Action Capability < Comunication .
op `[_:=_`] : Qid Msg -> Subst .
op `[shiftup_`] : Qid -> Subst .
op `[lift__`] : Qid Subst -> Subst .
op __ : Subst Name -> Name .
op __ : Subst Comunication -> Comunication .
op __ : Subst Process -> Process .
vars a b : Qid .
var n : Nat .
var M : Msg .
var S : Subst .
var P : Action .
var v v1 : Name .
var d : Direction .
***substitution on Comunications ***
eq [ a := M ] a{0} = M .
eq [ a := M ] a{s n} = a{n} .
ceq [ a := M ] b{n} = b{n} if a =/= b .
***general operations ***
eq [shiftup a ] a{n} = a{s n} .
ceq [shiftup a ] b{n} = b{n} if a =/= b .
eq [lift a S ] a{0} = a{0} .
eq [lift a S ] a{s n} = [ shiftup a ] S a{n} .
ceq [lift a S ] b{n} = [shiftup a] S b{n} if a =/= b .
***application on Capabilities ***
eq S enter v = enter ( S v ).
eq S accept v = accept (S v) .
eq S exit v = exit (S v) .
eq S expel v = expel (S v) .
eq S merge+ v = merge+ (S v) .
eq S merge- v = merge- (S v) .
eq S d v !{ v1 } = d (S v) !{ (S v1) } .
***eq S d v ?{ v1 } = d (S v) ?{ (S v1) } .
endfm
fmod BA-SINTAX is
inc CINNI .
***subsort AProcess < Process .
op 0 : -> Process .
***op aEps : -> Action .
***op cEps : -> Capability .
op _._ : Capability Process -> Process [prec 18 gather(E E) frozen(2) ] .
op _._ : Action Process -> Process [prec 18 gather(E E) frozen(2) ] .
op _|_ : Process Process -> Process [assoc comm prec 30 id: 0] .
op !_ : Process -> Process [prec 20] .
op !__ : Nat Process -> Process [prec 20] . ***bounded bang***
op [_] : Process -> Process [prec 21] .
op _+_ : Process Process -> Process [comm prec 20 id: 0] .
op _+_ : Process Process -> Process [comm prec 20 id: 0 ] .
op new`[_`]_ : Qid Process -> Process [prec 19] .
***application of substitutions on processes ***
var S : Subst .
var a : Qid .
vars CAP CAP1 : Capability .
vars ACT ACT1 : Action .
vars P P1 : Process .
var n : Nat .
vars N N1 : Qid .
var d : Direction .
var v v1 : Name .
eq S 0 = 0 .
eq S ( [P] ) = [ S (P) ] .
ceq S ( P | P1 ) = ( S ( P ) ) | ( S ( P1 ) ) if P =/= 0 and P1 =/= 0 .
***eq S ( A | A1 ) = ( S ( A ) ) | ( S ( A1 ) ) .
eq S ( CAP . P ) = ( S ( CAP ) ) . ( S ( P ) ) .
eq S (! P ) = ! ( S ( P ) ) .
eq S (! n P ) = ! n ( S ( P ) ) .
ceq S ( P + P1 ) = S ( P ) + ( S ( P1 ) ) if P =/= 0 and P1 =/= 0 .
ceq S ( P + P1 ) = S ( P ) + ( S ( P1 ) ) if P1 =/= 0 and P =/= 0 .
eq S ( new[N]P ) = new[N]( [lift N S] P ) .
eq S ( d v ?{ a } . P ) = d (S v) ?{ a } . ([lift a S] P).
eq S ( ACT . P ) = ( S ( ACT ) ) . ( S ( P ) ) [owise] .
eq S P = P [owise] .
******************************************
**** STRUCTURAL EQUIVALENCES ****
******************************************
eq [ 0 ] = 0 .
***eq L [ 0 ] = 0 .
eq new[ N ] 0 = 0 .
ceq new[ N ] new[ N1 ] P = new[ N1 ] new[ N ] P if string( N1 ) < string( N ) .
ceq (( new[ N ] P ) | P1 ) = (new[N] (P | ( [shiftup N ] P1 ) ) ) if P1 =/= 0 and P =/= 0 .
eq ( [ new[N] P] ) = ( new[N] ( [ P ] ) ).
eq ! n 0 = 0 .
eq ! 0 = 0 .
endfm
mod BA-SEMANTICS is
inc BA-SINTAX .
var S : Subst .
vars CAP CAP1 : Process .
vars ACT ACT1 : Process .
vars P Q R U : Process .
****vars A A1 : AProcess .
var i : Nat .
vars N N1 M : Qid .
vars n m : Name .
var p : Qid .
var msg : Msg .
var D : Direction .
rl [BangA] : ! P | P => ! P .
rl [BangC] : ! P => ! P | P .
rl [RedIn] : [ CAP + enter n . P | Q ] | [(CAP1 + accept n . R) | U ] => [ [ P | Q ] | R | U ] .
rl [RedOut] : [ [(CAP + exit n . P ) | Q ] | (CAP1 + expel n . R) | U ] => [ P | Q ] | [ R | U ] .
rl [RedMerge] : [(CAP + merge+ n . P ) | Q ] | [(CAP1 + merge- n . R) | U ] => [ P | Q | R | U ] .
rl [RedPOut] : (ACT + p2c n !{ msg } . P) | [(c2p n ?{ p } . Q + ACT1) | R ] => P | [ ([ p := msg ] Q ) | R ] .
rl [RedPIn] : [R | ACT + c2p n !{ msg } . P ] | (p2c n ?{ p } . Q + ACT1) => [R | P] | ([p := msg ] Q) .
rl [RedSib] : [R | ACT + s2s n !{ msg } . P ] | [ s2s n ?{ p } . Q + ACT1 | U ] => [ R | P ] | [ ([p := msg ] Q) | U ] .
rl [RedLocal] : (ACT + local n !{ msg } . P ) | (local n ?{ p } . Q + ACT1 ) => P | ([ p := msg ] Q ) .
***crl [RedRes] : new[ N ] P => new[ N ] Q if P => Q .
endm
mod BA is
inc BA-SEMANTICS .
inc PROCESS .
pr TRUTH-VALUE .
sort Context .
subsort ProcessConstant < Context .
op null : -> Context .
op context : -> Context .
op not-defined : -> Process .
op _;_ : Context Context -> Context [ assoc comm id: null prec 42] .
op _::=_ : ProcessConstant Process -> Context [prec 40].
op _definedIn_ : Qid Context -> Bool [prec 43] .
op def : ProcessConstant Context -> Process .
vars X X1 : Qid .
var P : Process .
var C : Context .
eq X definedIn ( X ::= P ; C ) = true .
eq X definedIn C = false [owise] .
eq def(X , ( X ::= P ; C ) ) = P .
eq def(X , C) = not-defined [owise] .
crl X => P if ( X definedIn context ) /\ def( X, context) => P .
endm
mod TEST is
inc BA .
eq context = null .
rl [EnterTest] : 'EnterTest => [ enter 'c { 0 } . 'T1 | 'T2 ] | [ accept 'c {0} . 'T3 | 'T4] .
rl [ExitTest] : 'ExitTest => [ [ exit 'c { 0 } . 'T1 | 'T2 ] | expel 'c {0} . 'T3 | 'T4] .
rl [MergeTest] : 'MergeTest => [ merge+ 'c { 0 } . 'T1 | 'T2 ] | [ merge- 'c {0} . 'T3 | 'T4 ] .
rl [V4] : 'V4 => enter 'p {0} . 'P .
rl [s2sTest1] : 's2sTest1 => [ [ s2s 'n{0} !{ 'm{0} } . 'V4 ] | [ s2s 'n{0} ?{ 'p } . 'V4 ] ] .
rl [c2pTest1] : 'c2pTest1 => p2c 'n{0} !{ 'm{0} } . 'V4 | [ c2p 'n{0} ?{ 'p } . 'V4 ] .
rl [p2cTest1] : 'p2cTest1 => p2c 'n{0} ?{ 'p } . 'V4 | [ c2p 'n{0} !{ 'm{0} } . 'V4 ] .
rl [s2sTest2] : 's2sTest2 => [ [ s2s 'n{0} !{ 'm{0} } . 0 ] | [ s2s 'n{0} ?{ 'p } . enter 'p {0} . 'P ] ] .
rl [c2pTest2] : 'c2pTest2 => p2c 'n{0} !{ 'm{0} } . 0 | [ c2p 'n{0} ?{ 'p } . enter 'p {0} . 'P ] .
rl [p2cTest2] : 'p2cTest2 => p2c 'n{0} ?{ 'p } . enter 'p {0} . 'P | [ c2p 'n{0} !{ 'm{0} } . 0 ] .
rl [Porin] : 'Porin => accept 'cell1 {0} . 'Porin + expel 'cell2 {0} . 'Porin .
rl [Mol] : 'Mol => enter 'cell1 {0} . 'Mol + exit 'cell2 {0} . 'Mol .
rl [System] : 'System => [ 'Porin ] | [ 'Mol ] .
endm
***(red 'p definedIn null .
red 'p definedIn 'p ::= 0 .
red 'p definedIn 'false ::= [0] ; 'p ::= 0 .
red 'p definedIn 'false ::= [0] ; 'p ::= 0 ; 'Q ::= enter 'n{0} . 0 .
red 'p definedIn 'false ::= [0] ; 'Q ::= enter 'n{0} . 0 .
red def('p, null) .
red def('p, 'p ::= 0) .
red def('p, 'false ::= [0] ; 'p ::= 0) .
red def('p, 'false ::= [0] ; 'p ::= 0 ; 'Q ::= enter 'n{0} . 0 ) .
red def('p, 'false ::= [0] ; 'Q ::= enter 'n{0} . 0 ) .)***
frew [4] 'EnterTest .
frew [4] 'ExitTest .
frew [4] 'MergeTest .
frew [20] 's2sTest1 .
frew [20] 'c2pTest1 .
frew [20] 'p2cTest1 .
frew [20] 's2sTest2 .
frew [20] 'c2pTest2 .
frew [20] 'p2cTest2 .
frew [50] 'System .
frew [1000] [ accept 'n {0} . 'T3 ] | [ new[ 'n ] enter 'n{0} . P:Process | new[ 'n ] s2s 'z{0} !{ 'n{0} } . s2s 'n{0} ?{ 'p } . enter 'p { 0 } . 'int | new[ 'n ] enter 'n{0} . P2:Process ] | [ new[ 'm ] s2s 'z{0} ?{ 'p } . s2s 'p{0} !{ 'm{0} } . accept 'm{0} . 'entered ] .
frew [1] [ new[ 'p ] s2s 'm{0} ?{ 'p } . enter 'p{0} . 'P | new[ 'p ] s2s 'm{0} ?{ 'p } . enter 'p{0} . 'P ] .
***red [ 'a := 'p{5} ] s2s 'a{0} ?{ 'a } . ( enter 'a { 1 } . ( 'a ) ) .