41589
|
1 |
(* Title: HOL/TLA/Memory/ProcedureInterface.thy
|
|
2 |
Author: Stephan Merz, University of Munich
|
21624
|
3 |
*)
|
3807
|
4 |
|
60592
|
5 |
section \<open>Procedure interface for RPC-Memory components\<close>
|
3807
|
6 |
|
17309
|
7 |
theory ProcedureInterface
|
26351
|
8 |
imports "../TLA" RPCMemoryParams
|
17309
|
9 |
begin
|
3807
|
10 |
|
42018
|
11 |
typedecl ('a,'r) chan
|
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 |
*)
|
60588
|
17 |
type_synonym ('a,'r) channel =" (PrIds \<Rightarrow> ('a,'r) chan) stfun"
|
3807
|
18 |
|
|
19 |
consts
|
|
20 |
(* data-level functions *)
|
60588
|
21 |
cbit :: "('a,'r) chan \<Rightarrow> bit"
|
|
22 |
rbit :: "('a,'r) chan \<Rightarrow> bit"
|
|
23 |
arg :: "('a,'r) chan \<Rightarrow> 'a"
|
|
24 |
res :: "('a,'r) chan \<Rightarrow> 'r"
|
3807
|
25 |
|
|
26 |
(* state functions *)
|
60588
|
27 |
caller :: "('a,'r) channel \<Rightarrow> (PrIds \<Rightarrow> (bit * 'a)) stfun"
|
|
28 |
rtrner :: "('a,'r) channel \<Rightarrow> (PrIds \<Rightarrow> (bit * 'r)) stfun"
|
3807
|
29 |
|
|
30 |
(* state predicates *)
|
60588
|
31 |
Calling :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> stpred"
|
3807
|
32 |
|
|
33 |
(* actions *)
|
60588
|
34 |
ACall :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> 'a stfun \<Rightarrow> action"
|
|
35 |
AReturn :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> 'r stfun \<Rightarrow> action"
|
3807
|
36 |
|
|
37 |
(* temporal formulas *)
|
60588
|
38 |
PLegalCaller :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> temporal"
|
|
39 |
LegalCaller :: "('a,'r) channel \<Rightarrow> temporal"
|
|
40 |
PLegalReturner :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> temporal"
|
|
41 |
LegalReturner :: "('a,'r) channel \<Rightarrow> temporal"
|
3807
|
42 |
|
6255
|
43 |
(* slice through array-valued state function *)
|
60588
|
44 |
slice :: "('a \<Rightarrow> 'b) stfun \<Rightarrow> 'a \<Rightarrow> 'b stfun"
|
6255
|
45 |
|
|
46 |
syntax
|
60588
|
47 |
"_slice" :: "[lift, 'a] \<Rightarrow> lift" ("(_!_)" [70,70] 70)
|
6255
|
48 |
|
60588
|
49 |
"_Call" :: "['a, 'b, lift] \<Rightarrow> lift" ("(Call _ _ _)" [90,90,90] 90)
|
|
50 |
"_Return" :: "['a, 'b, lift] \<Rightarrow> lift" ("(Return _ _ _)" [90,90,90] 90)
|
3807
|
51 |
|
6255
|
52 |
translations
|
35068
|
53 |
"_slice" == "CONST slice"
|
6255
|
54 |
|
35068
|
55 |
"_Call" == "CONST ACall"
|
|
56 |
"_Return" == "CONST AReturn"
|
6255
|
57 |
|
17309
|
58 |
defs
|
|
59 |
slice_def: "(PRED (x!i)) s == x s i"
|
3807
|
60 |
|
60587
|
61 |
caller_def: "caller ch == \<lambda>s p. (cbit (ch s p), arg (ch s p))"
|
|
62 |
rtrner_def: "rtrner ch == \<lambda>s p. (rbit (ch s p), res (ch s p))"
|
3807
|
63 |
|
60587
|
64 |
Calling_def: "Calling ch p == PRED cbit< ch!p > \<noteq> rbit< ch!p >"
|
|
65 |
Call_def: "(ACT Call ch p v) == ACT \<not> $Calling ch p
|
60591
|
66 |
\<and> (cbit<ch!p>$ \<noteq> $rbit<ch!p>)
|
|
67 |
\<and> (arg<ch!p>$ = $v)"
|
17309
|
68 |
Return_def: "(ACT Return ch p v) == ACT $Calling ch p
|
60591
|
69 |
\<and> (rbit<ch!p>$ = $cbit<ch!p>)
|
|
70 |
\<and> (res<ch!p>$ = $v)"
|
17309
|
71 |
PLegalCaller_def: "PLegalCaller ch p == TEMP
|
60587
|
72 |
Init(\<not> Calling ch p)
|
60591
|
73 |
\<and> \<box>[\<exists>a. Call ch p a ]_((caller ch)!p)"
|
60587
|
74 |
LegalCaller_def: "LegalCaller ch == TEMP (\<forall>p. PLegalCaller ch p)"
|
17309
|
75 |
PLegalReturner_def: "PLegalReturner ch p == TEMP
|
60587
|
76 |
\<box>[\<exists>v. Return ch p v ]_((rtrner ch)!p)"
|
|
77 |
LegalReturner_def: "LegalReturner ch == TEMP (\<forall>p. PLegalReturner ch p)"
|
17309
|
78 |
|
21624
|
79 |
declare slice_def [simp]
|
|
80 |
|
|
81 |
lemmas Procedure_defs = caller_def rtrner_def Calling_def Call_def Return_def
|
|
82 |
PLegalCaller_def LegalCaller_def PLegalReturner_def LegalReturner_def
|
|
83 |
|
|
84 |
(* Calls and returns change their subchannel *)
|
60588
|
85 |
lemma Call_changed: "\<turnstile> Call ch p v \<longrightarrow> <Call ch p v>_((caller ch)!p)"
|
21624
|
86 |
by (auto simp: angle_def Call_def caller_def Calling_def)
|
|
87 |
|
60588
|
88 |
lemma Return_changed: "\<turnstile> Return ch p v \<longrightarrow> <Return ch p v>_((rtrner ch)!p)"
|
21624
|
89 |
by (auto simp: angle_def Return_def rtrner_def Calling_def)
|
3807
|
90 |
|
|
91 |
end
|