author | wenzelm |
Sun, 16 Jan 2011 15:53:03 +0100 | |
changeset 41589 | bbd861837ebc |
parent 35068 | 544867142ea4 |
child 42018 | 878f33040280 |
permissions | -rw-r--r-- |
41589 | 1 |
(* Title: HOL/TLA/Memory/ProcedureInterface.thy |
2 |
Author: Stephan Merz, University of Munich |
|
21624 | 3 |
*) |
3807 | 4 |
|
21624 | 5 |
header {* Procedure interface for RPC-Memory components *} |
3807 | 6 |
|
17309 | 7 |
theory ProcedureInterface |
26351 | 8 |
imports "../TLA" RPCMemoryParams |
17309 | 9 |
begin |
3807 | 10 |
|
17309 | 11 |
typedecl |
3807 | 12 |
(* type of channels with argument type 'a and return type 'r. |
17309 | 13 |
we model a channel as an array of variables (of type chan) |
14 |
rather than a single array-valued variable because the |
|
3807 | 15 |
notation gets a little simpler. |
16 |
*) |
|
17 |
('a,'r) chan |
|
17309 | 18 |
types |
19 |
('a,'r) channel =" (PrIds => ('a,'r) chan) stfun" |
|
3807 | 20 |
|
21 |
consts |
|
22 |
(* data-level functions *) |
|
17309 | 23 |
cbit :: "('a,'r) chan => bit" |
24 |
rbit :: "('a,'r) chan => bit" |
|
3807 | 25 |
arg :: "('a,'r) chan => 'a" |
26 |
res :: "('a,'r) chan => 'r" |
|
27 |
||
28 |
(* state functions *) |
|
17309 | 29 |
caller :: "('a,'r) channel => (PrIds => (bit * 'a)) stfun" |
3807 | 30 |
rtrner :: "('a,'r) channel => (PrIds => (bit * 'r)) stfun" |
31 |
||
32 |
(* state predicates *) |
|
33 |
Calling :: "('a,'r) channel => PrIds => stpred" |
|
34 |
||
35 |
(* actions *) |
|
6255 | 36 |
ACall :: "('a,'r) channel => PrIds => 'a stfun => action" |
37 |
AReturn :: "('a,'r) channel => PrIds => 'r stfun => action" |
|
3807 | 38 |
|
39 |
(* temporal formulas *) |
|
40 |
PLegalCaller :: "('a,'r) channel => PrIds => temporal" |
|
41 |
LegalCaller :: "('a,'r) channel => temporal" |
|
42 |
PLegalReturner :: "('a,'r) channel => PrIds => temporal" |
|
43 |
LegalReturner :: "('a,'r) channel => temporal" |
|
44 |
||
6255 | 45 |
(* slice through array-valued state function *) |
46 |
slice :: "('a => 'b) stfun => 'a => 'b stfun" |
|
47 |
||
48 |
syntax |
|
17309 | 49 |
"_slice" :: "[lift, 'a] => lift" ("(_!_)" [70,70] 70) |
6255 | 50 |
|
17309 | 51 |
"_Call" :: "['a, 'b, lift] => lift" ("(Call _ _ _)" [90,90,90] 90) |
52 |
"_Return" :: "['a, 'b, lift] => lift" ("(Return _ _ _)" [90,90,90] 90) |
|
3807 | 53 |
|
6255 | 54 |
translations |
35068 | 55 |
"_slice" == "CONST slice" |
6255 | 56 |
|
35068 | 57 |
"_Call" == "CONST ACall" |
58 |
"_Return" == "CONST AReturn" |
|
6255 | 59 |
|
17309 | 60 |
defs |
61 |
slice_def: "(PRED (x!i)) s == x s i" |
|
3807 | 62 |
|
17309 | 63 |
caller_def: "caller ch == %s p. (cbit (ch s p), arg (ch s p))" |
64 |
rtrner_def: "rtrner ch == %s p. (rbit (ch s p), res (ch s p))" |
|
3807 | 65 |
|
17309 | 66 |
Calling_def: "Calling ch p == PRED cbit< ch!p > ~= rbit< ch!p >" |
67 |
Call_def: "(ACT Call ch p v) == ACT ~ $Calling ch p |
|
9517
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
68 |
& (cbit<ch!p>$ ~= $rbit<ch!p>) |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
69 |
& (arg<ch!p>$ = $v)" |
17309 | 70 |
Return_def: "(ACT Return ch p v) == ACT $Calling ch p |
9517
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
71 |
& (rbit<ch!p>$ = $cbit<ch!p>) |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
72 |
& (res<ch!p>$ = $v)" |
17309 | 73 |
PLegalCaller_def: "PLegalCaller ch p == TEMP |
6255 | 74 |
Init(~ Calling ch p) |
75 |
& [][ ? a. Call ch p a ]_((caller ch)!p)" |
|
17309 | 76 |
LegalCaller_def: "LegalCaller ch == TEMP (! p. PLegalCaller ch p)" |
77 |
PLegalReturner_def: "PLegalReturner ch p == TEMP |
|
6255 | 78 |
[][ ? v. Return ch p v ]_((rtrner ch)!p)" |
17309 | 79 |
LegalReturner_def: "LegalReturner ch == TEMP (! p. PLegalReturner ch p)" |
80 |
||
21624 | 81 |
declare slice_def [simp] |
82 |
||
83 |
lemmas Procedure_defs = caller_def rtrner_def Calling_def Call_def Return_def |
|
84 |
PLegalCaller_def LegalCaller_def PLegalReturner_def LegalReturner_def |
|
85 |
||
86 |
(* Calls and returns change their subchannel *) |
|
87 |
lemma Call_changed: "|- Call ch p v --> <Call ch p v>_((caller ch)!p)" |
|
88 |
by (auto simp: angle_def Call_def caller_def Calling_def) |
|
89 |
||
90 |
lemma Return_changed: "|- Return ch p v --> <Return ch p v>_((rtrner ch)!p)" |
|
91 |
by (auto simp: angle_def Return_def rtrner_def Calling_def) |
|
3807 | 92 |
|
93 |
end |