src/HOL/TLA/Memory/RPC.thy
author wenzelm
Fri, 26 Jun 2015 15:55:44 +0200
changeset 60591 e0b77517f9a9
parent 60588 750c533459b1
child 60592 c9bd1d902f04
permissions -rw-r--r--
more symbols; eliminated alternative syntax;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41589
bbd861837ebc tuned headers;
wenzelm
parents: 39159
diff changeset
     1
(*  Title:      HOL/TLA/Memory/RPC.thy
bbd861837ebc tuned headers;
wenzelm
parents: 39159
diff changeset
     2
    Author:     Stephan Merz, University of Munich
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
     3
*)
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     4
58889
5b7a9633cfa8 modernized header uniformly as section;
wenzelm
parents: 51717
diff changeset
     5
section {* RPC-Memory example: RPC specification *}
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
     6
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
     7
theory RPC
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
     8
imports RPCParameters ProcedureInterface Memory
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
     9
begin
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    10
42018
878f33040280 modernized specifications;
wenzelm
parents: 41589
diff changeset
    11
type_synonym rpcSndChType = "(rpcOp,Vals) channel"
878f33040280 modernized specifications;
wenzelm
parents: 41589
diff changeset
    12
type_synonym rpcRcvChType = "memChType"
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    13
type_synonym rpcStType = "(PrIds \<Rightarrow> rpcState) stfun"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    14
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    15
consts
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    16
  (* state predicates *)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    17
  RPCInit      :: "rpcRcvChType \<Rightarrow> rpcStType \<Rightarrow> PrIds \<Rightarrow> stpred"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    18
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    19
  (* actions *)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    20
  RPCFwd     :: "rpcSndChType \<Rightarrow> rpcRcvChType \<Rightarrow> rpcStType \<Rightarrow> PrIds \<Rightarrow> action"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    21
  RPCReject  :: "rpcSndChType \<Rightarrow> rpcRcvChType \<Rightarrow> rpcStType \<Rightarrow> PrIds \<Rightarrow> action"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    22
  RPCFail    :: "rpcSndChType \<Rightarrow> rpcRcvChType \<Rightarrow> rpcStType \<Rightarrow> PrIds \<Rightarrow> action"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    23
  RPCReply   :: "rpcSndChType \<Rightarrow> rpcRcvChType \<Rightarrow> rpcStType \<Rightarrow> PrIds \<Rightarrow> action"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    24
  RPCNext    :: "rpcSndChType \<Rightarrow> rpcRcvChType \<Rightarrow> rpcStType \<Rightarrow> PrIds \<Rightarrow> action"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    25
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    26
  (* temporal *)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    27
  RPCIPSpec   :: "rpcSndChType \<Rightarrow> rpcRcvChType \<Rightarrow> rpcStType \<Rightarrow> PrIds \<Rightarrow> temporal"
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    28
  RPCISpec   :: "rpcSndChType \<Rightarrow> rpcRcvChType \<Rightarrow> rpcStType \<Rightarrow> temporal"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    29
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
    30
defs
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    31
  RPCInit_def:       "RPCInit rcv rst p == PRED ((rst!p = #rpcA) \<and> \<not>Calling rcv p)"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    32
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
    33
  RPCFwd_def:        "RPCFwd send rcv rst p == ACT
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    34
                         $(Calling send p)
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    35
                         \<and> $(rst!p) = # rpcA
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    36
                         \<and> IsLegalRcvArg<arg<$(send!p)>>
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    37
                         \<and> Call rcv p RPCRelayArg<arg<send!p>>
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    38
                         \<and> (rst!p)$ = # rpcB
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    39
                         \<and> unchanged (rtrner send!p)"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    40
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
    41
  RPCReject_def:     "RPCReject send rcv rst p == ACT
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    42
                           $(rst!p) = # rpcA
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    43
                         \<and> \<not>IsLegalRcvArg<arg<$(send!p)>>
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    44
                         \<and> Return send p #BadCall
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    45
                         \<and> unchanged ((rst!p), (caller rcv!p))"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    46
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
    47
  RPCFail_def:       "RPCFail send rcv rst p == ACT
60587
0318b43ee95c more symbols;
wenzelm
parents: 58889
diff changeset
    48
                           \<not>$(Calling rcv p)
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    49
                         \<and> Return send p #RPCFailure
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    50
                         \<and> (rst!p)$ = #rpcA
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    51
                         \<and> unchanged (caller rcv!p)"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    52
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
    53
  RPCReply_def:      "RPCReply send rcv rst p == ACT
60587
0318b43ee95c more symbols;
wenzelm
parents: 58889
diff changeset
    54
                           \<not>$(Calling rcv p)
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    55
                         \<and> $(rst!p) = #rpcB
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    56
                         \<and> Return send p res<rcv!p>
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    57
                         \<and> (rst!p)$ = #rpcA
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    58
                         \<and> unchanged (caller rcv!p)"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    59
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
    60
  RPCNext_def:       "RPCNext send rcv rst p == ACT
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    61
                        (  RPCFwd send rcv rst p
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    62
                         \<or> RPCReject send rcv rst p
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    63
                         \<or> RPCFail send rcv rst p
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    64
                         \<or> RPCReply send rcv rst p)"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    65
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
    66
  RPCIPSpec_def:     "RPCIPSpec send rcv rst p == TEMP
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    67
                           Init RPCInit rcv rst p
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    68
                         \<and> \<box>[ RPCNext send rcv rst p ]_(rst!p, rtrner send!p, caller rcv!p)
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    69
                         \<and> WF(RPCNext send rcv rst p)_(rst!p, rtrner send!p, caller rcv!p)"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    70
60587
0318b43ee95c more symbols;
wenzelm
parents: 58889
diff changeset
    71
  RPCISpec_def:      "RPCISpec send rcv rst == TEMP (\<forall>p. RPCIPSpec send rcv rst p)"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 11703
diff changeset
    72
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    73
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    74
lemmas RPC_action_defs =
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    75
  RPCInit_def RPCFwd_def RPCReject_def RPCFail_def RPCReply_def RPCNext_def
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    76
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    77
lemmas RPC_temp_defs = RPCIPSpec_def RPCISpec_def
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    78
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    79
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    80
(* The RPC component engages in an action for process p only if there is an outstanding,
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    81
   unanswered call for that process.
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    82
*)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    83
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    84
lemma RPCidle: "\<turnstile> \<not>$(Calling send p) \<longrightarrow> \<not>RPCNext send rcv rst p"
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    85
  by (auto simp: Return_def RPC_action_defs)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    86
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
    87
lemma RPCbusy: "\<turnstile> $(Calling rcv p) \<and> $(rst!p) = #rpcB \<longrightarrow> \<not>RPCNext send rcv rst p"
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    88
  by (auto simp: RPC_action_defs)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    89
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    90
(* RPC failure actions are visible. *)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    91
lemma RPCFail_vis: "\<turnstile> RPCFail send rcv rst p \<longrightarrow>  
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    92
    <RPCNext send rcv rst p>_(rst!p, rtrner send!p, caller rcv!p)"
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    93
  by (auto dest!: Return_changed [temp_use] simp: angle_def RPCNext_def RPCFail_def)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    94
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
    95
lemma RPCFail_Next_enabled: "\<turnstile> Enabled (RPCFail send rcv rst p) \<longrightarrow>  
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    96
    Enabled (<RPCNext send rcv rst p>_(rst!p, rtrner send!p, caller rcv!p))"
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    97
  by (force elim!: enabled_mono [temp_use] RPCFail_vis [temp_use])
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    98
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    99
(* Enabledness of some actions *)
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   100
lemma RPCFail_enabled: "\<And>p. basevars (rtrner send!p, caller rcv!p, rst!p) \<Longrightarrow>  
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   101
    \<turnstile> \<not>Calling rcv p \<and> Calling send p \<longrightarrow> Enabled (RPCFail send rcv rst p)"
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 42018
diff changeset
   102
  by (tactic {* action_simp_tac (@{context} addsimps [@{thm RPCFail_def},
39159
0dec18004e75 more antiquotations;
wenzelm
parents: 26342
diff changeset
   103
    @{thm Return_def}, @{thm caller_def}, @{thm rtrner_def}]) [exI]
0dec18004e75 more antiquotations;
wenzelm
parents: 26342
diff changeset
   104
    [@{thm base_enabled}, @{thm Pair_inject}] 1 *})
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
   105
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   106
lemma RPCReply_enabled: "\<And>p. basevars (rtrner send!p, caller rcv!p, rst!p) \<Longrightarrow>  
60591
e0b77517f9a9 more symbols;
wenzelm
parents: 60588
diff changeset
   107
      \<turnstile> \<not>Calling rcv p \<and> Calling send p \<and> rst!p = #rpcB  
60588
750c533459b1 more symbols;
wenzelm
parents: 60587
diff changeset
   108
         \<longrightarrow> Enabled (RPCReply send rcv rst p)"
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 42018
diff changeset
   109
  by (tactic {* action_simp_tac (@{context} addsimps [@{thm RPCReply_def},
39159
0dec18004e75 more antiquotations;
wenzelm
parents: 26342
diff changeset
   110
    @{thm Return_def}, @{thm caller_def}, @{thm rtrner_def}]) [exI]
0dec18004e75 more antiquotations;
wenzelm
parents: 26342
diff changeset
   111
    [@{thm base_enabled}, @{thm Pair_inject}] 1 *})
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   112
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
   113
end