3807
|
1 |
(*
|
|
2 |
File: RPCParameters.thy
|
|
3 |
Author: Stephan Merz
|
|
4 |
Copyright: 1997 University of Munich
|
|
5 |
|
|
6 |
Theory Name: RPCParameters
|
|
7 |
Logic Image: TLA
|
|
8 |
|
|
9 |
RPC-Memory example: RPC parameters
|
|
10 |
For simplicity, specify the instance of RPC that is used in the
|
|
11 |
memory implementation.
|
|
12 |
*)
|
|
13 |
|
|
14 |
RPCParameters = MemoryParameters +
|
|
15 |
|
|
16 |
datatype rpcOps = remoteCall
|
|
17 |
datatype rpcState = rpcA | rpcB
|
|
18 |
|
|
19 |
types
|
|
20 |
(* type of RPC arguments other than memory calls *)
|
|
21 |
noMemArgType
|
|
22 |
(* legal arguments for (our instance of) the RPC component *)
|
|
23 |
rpcArgType = "(rpcOps * memArgType) + (rpcOps * noMemArgType)"
|
|
24 |
|
|
25 |
arities
|
|
26 |
noMemArgType :: term
|
|
27 |
|
|
28 |
consts
|
|
29 |
(* some particular return values *)
|
|
30 |
RPCFailure :: "Vals"
|
|
31 |
BadCall :: "Vals"
|
|
32 |
|
|
33 |
(* Translate an rpc call to a memory call and test if the current argument
|
|
34 |
is legal for the receiver (i.e., the memory). This can now be a little
|
|
35 |
simpler than for the generic RPC component. RelayArg returns an arbitrary
|
|
36 |
memory call for illegal arguments. *)
|
|
37 |
IsLegalRcvArg :: "rpcArgType => bool"
|
|
38 |
RPCRelayArg :: "rpcArgType => memArgType"
|
|
39 |
|
|
40 |
rules
|
|
41 |
(* RPCFailure is different from MemVals and exceptions *)
|
|
42 |
RFNoMemVal "~(MemVal RPCFailure)"
|
|
43 |
NotAResultNotRF "NotAResult ~= RPCFailure"
|
|
44 |
OKNotRF "OK ~= RPCFailure"
|
|
45 |
BANotRF "BadArg ~= RPCFailure"
|
|
46 |
|
|
47 |
IsLegalRcvArg_def "IsLegalRcvArg ra == EX marg. ra = Inl (remoteCall,marg)"
|
|
48 |
RPCRelayArg_def "RPCRelayArg ra ==
|
|
49 |
case ra of Inl (rm) => (snd rm)
|
|
50 |
| Inr (rn) => Inl (read, @ l. True)"
|
|
51 |
|
|
52 |
end
|
|
53 |
|
|
54 |
|