src/HOL/TLA/Memory/RPCParameters.thy
author blanchet
Thu, 11 Sep 2014 19:32:36 +0200
changeset 58310 91ea607a34d8
parent 58249 180f1b3508ed
child 58889 5b7a9633cfa8
permissions -rw-r--r--
updated news

(*  Title:      HOL/TLA/Memory/RPCParameters.thy
    Author:     Stephan Merz, University of Munich
*)

header {* RPC-Memory example: RPC parameters *}

theory RPCParameters
imports MemoryParameters
begin

(*
  For simplicity, specify the instance of RPC that is used in the
  memory implementation.
*)

datatype rpcOp = memcall memOp | othercall Vals
datatype rpcState = rpcA | rpcB

consts
  (* some particular return values *)
  RPCFailure     :: Vals
  BadCall        :: Vals
  
  (* Translate an rpc call to a memory call and test if the current argument
     is legal for the receiver (i.e., the memory). This can now be a little
     simpler than for the generic RPC component. RelayArg returns an arbitrary
     memory call for illegal arguments. *)
  IsLegalRcvArg  :: "rpcOp => bool"
  RPCRelayArg    :: "rpcOp => memOp"

axiomatization where
  (* RPCFailure is different from MemVals and exceptions *)
  RFNoMemVal:        "RPCFailure ~: MemVal" and
  NotAResultNotRF:   "NotAResult ~= RPCFailure" and
  OKNotRF:           "OK ~= RPCFailure" and
  BANotRF:           "BadArg ~= RPCFailure"

defs
  IsLegalRcvArg_def: "IsLegalRcvArg ra ==
                         case ra of (memcall m) => True
                                  | (othercall v) => False"
  RPCRelayArg_def:   "RPCRelayArg ra ==
                         case ra of (memcall m) => m
                                  | (othercall v) => undefined"

lemmas [simp] = RFNoMemVal NotAResultNotRF OKNotRF BANotRF
  NotAResultNotRF [symmetric] OKNotRF [symmetric] BANotRF [symmetric]

end