src/HOL/TLA/Memory/ProcedureInterface.thy
author wenzelm
Mon Jan 11 21:21:02 2016 +0100 (2016-01-11)
changeset 62145 5b946c81dfbf
parent 60592 c9bd1d902f04
child 62146 324bc1ffba12
permissions -rw-r--r--
eliminated old defs;
     1 (*  Title:      HOL/TLA/Memory/ProcedureInterface.thy
     2     Author:     Stephan Merz, University of Munich
     3 *)
     4 
     5 section \<open>Procedure interface for RPC-Memory components\<close>
     6 
     7 theory ProcedureInterface
     8 imports "../TLA" RPCMemoryParams
     9 begin
    10 
    11 typedecl ('a,'r) chan
    12   (* type of channels with argument type 'a and return type 'r.
    13      we model a channel as an array of variables (of type chan)
    14      rather than a single array-valued variable because the
    15      notation gets a little simpler.
    16   *)
    17 type_synonym ('a,'r) channel =" (PrIds \<Rightarrow> ('a,'r) chan) stfun"
    18 
    19 
    20 (* data-level functions *)
    21 
    22 consts
    23   cbit          :: "('a,'r) chan \<Rightarrow> bit"
    24   rbit          :: "('a,'r) chan \<Rightarrow> bit"
    25   arg           :: "('a,'r) chan \<Rightarrow> 'a"
    26   res           :: "('a,'r) chan \<Rightarrow> 'r"
    27 
    28 
    29 (* state functions *)
    30 
    31 definition caller :: "('a,'r) channel \<Rightarrow> (PrIds \<Rightarrow> (bit * 'a)) stfun"
    32   where "caller ch == \<lambda>s p. (cbit (ch s p), arg (ch s p))"
    33 
    34 definition rtrner :: "('a,'r) channel \<Rightarrow> (PrIds \<Rightarrow> (bit * 'r)) stfun"
    35   where "rtrner ch == \<lambda>s p. (rbit (ch s p), res (ch s p))"
    36 
    37 
    38 (* slice through array-valued state function *)
    39 
    40 consts
    41   slice        :: "('a \<Rightarrow> 'b) stfun \<Rightarrow> 'a \<Rightarrow> 'b stfun"
    42 syntax
    43   "_slice"    :: "[lift, 'a] \<Rightarrow> lift"      ("(_!_)" [70,70] 70)
    44 translations
    45   "_slice"  ==  "CONST slice"
    46 defs
    47   slice_def:     "(PRED (x!i)) s == x s i"
    48 
    49 
    50 (* state predicates *)
    51 
    52 definition Calling :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> stpred"
    53   where "Calling ch p == PRED cbit< ch!p > \<noteq> rbit< ch!p >"
    54 
    55 
    56 (* actions *)
    57 
    58 consts
    59   ACall      :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> 'a stfun \<Rightarrow> action"
    60   AReturn    :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> 'r stfun \<Rightarrow> action"
    61 syntax
    62   "_Call"     :: "['a, 'b, lift] \<Rightarrow> lift"    ("(Call _ _ _)" [90,90,90] 90)
    63   "_Return"   :: "['a, 'b, lift] \<Rightarrow> lift"    ("(Return _ _ _)" [90,90,90] 90)
    64 translations
    65   "_Call"   ==  "CONST ACall"
    66   "_Return" ==  "CONST AReturn"
    67 defs
    68   Call_def:      "(ACT Call ch p v)   == ACT  \<not> $Calling ch p
    69                                      \<and> (cbit<ch!p>$ \<noteq> $rbit<ch!p>)
    70                                      \<and> (arg<ch!p>$ = $v)"
    71   Return_def:    "(ACT Return ch p v) == ACT  $Calling ch p
    72                                      \<and> (rbit<ch!p>$ = $cbit<ch!p>)
    73                                      \<and> (res<ch!p>$ = $v)"
    74 
    75 
    76 (* temporal formulas *)
    77 
    78 definition PLegalCaller :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> temporal"
    79   where "PLegalCaller ch p == TEMP
    80      Init(\<not> Calling ch p)
    81      \<and> \<box>[\<exists>a. Call ch p a ]_((caller ch)!p)"
    82 
    83 definition LegalCaller :: "('a,'r) channel \<Rightarrow> temporal"
    84   where "LegalCaller ch == TEMP (\<forall>p. PLegalCaller ch p)"
    85 
    86 definition PLegalReturner :: "('a,'r) channel \<Rightarrow> PrIds \<Rightarrow> temporal"
    87   where "PLegalReturner ch p == TEMP \<box>[\<exists>v. Return ch p v ]_((rtrner ch)!p)"
    88 
    89 definition LegalReturner :: "('a,'r) channel \<Rightarrow> temporal"
    90   where "LegalReturner ch == TEMP (\<forall>p. PLegalReturner ch p)"
    91 
    92 declare slice_def [simp]
    93 
    94 lemmas Procedure_defs = caller_def rtrner_def Calling_def Call_def Return_def
    95   PLegalCaller_def LegalCaller_def PLegalReturner_def LegalReturner_def
    96 
    97 (* Calls and returns change their subchannel *)
    98 lemma Call_changed: "\<turnstile> Call ch p v \<longrightarrow> <Call ch p v>_((caller ch)!p)"
    99   by (auto simp: angle_def Call_def caller_def Calling_def)
   100 
   101 lemma Return_changed: "\<turnstile> Return ch p v \<longrightarrow> <Return ch p v>_((rtrner ch)!p)"
   102   by (auto simp: angle_def Return_def rtrner_def Calling_def)
   103 
   104 end