src/HOL/TLA/Memory/ProcedureInterface.thy
author wenzelm
Sat, 07 Apr 2012 16:41:59 +0200
changeset 47389 e8552cba702d
parent 42018 878f33040280
child 58889 5b7a9633cfa8
permissions -rw-r--r--
explicit checks stable_finished_theory/stable_command allow parallel asynchronous command transactions; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41589
bbd861837ebc tuned headers;
wenzelm
parents: 35068
diff changeset
     1
(*  Title:      HOL/TLA/Memory/ProcedureInterface.thy
bbd861837ebc tuned headers;
wenzelm
parents: 35068
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
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
     5
header {* Procedure interface for RPC-Memory components *}
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: 12338
diff changeset
     7
theory ProcedureInterface
26351
d5125a62f839 tuned import
haftmann
parents: 21624
diff changeset
     8
imports "../TLA" RPCMemoryParams
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
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
typedecl ('a,'r) chan
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    12
  (* type of channels with argument type 'a and return type 'r.
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    13
     we model a channel as an array of variables (of type chan)
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    14
     rather than a single array-valued variable because the
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    15
     notation gets a little simpler.
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    16
  *)
42018
878f33040280 modernized specifications;
wenzelm
parents: 41589
diff changeset
    17
type_synonym ('a,'r) channel =" (PrIds => ('a,'r) chan) stfun"
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
consts
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    20
  (* data-level functions *)
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    21
  cbit          :: "('a,'r) chan => bit"
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    22
  rbit          :: "('a,'r) chan => bit"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    23
  arg           :: "('a,'r) chan => 'a"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    24
  res           :: "('a,'r) chan => 'r"
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
  (* state functions *)
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    27
  caller        :: "('a,'r) channel => (PrIds => (bit * 'a)) stfun"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    28
  rtrner        :: "('a,'r) channel => (PrIds => (bit * 'r)) stfun"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    29
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    30
  (* state predicates *)
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    31
  Calling   :: "('a,'r) channel => PrIds => stpred"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    32
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    33
  (* actions *)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    34
  ACall      :: "('a,'r) channel => PrIds => 'a stfun => action"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    35
  AReturn    :: "('a,'r) channel => PrIds => 'r stfun => action"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    36
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    37
  (* temporal formulas *)
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    38
  PLegalCaller      :: "('a,'r) channel => PrIds => temporal"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    39
  LegalCaller       :: "('a,'r) channel => temporal"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    40
  PLegalReturner    :: "('a,'r) channel => PrIds => temporal"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    41
  LegalReturner     :: "('a,'r) channel => temporal"
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    42
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    43
  (* slice through array-valued state function *)
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    44
  slice        :: "('a => 'b) stfun => 'a => 'b stfun"
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    45
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    46
syntax
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    47
  "_slice"    :: "[lift, 'a] => lift"      ("(_!_)" [70,70] 70)
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    48
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    49
  "_Call"     :: "['a, 'b, lift] => lift"    ("(Call _ _ _)" [90,90,90] 90)
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    50
  "_Return"   :: "['a, 'b, lift] => lift"    ("(Return _ _ _)" [90,90,90] 90)
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    51
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    52
translations
35068
544867142ea4 modernized translations;
wenzelm
parents: 26351
diff changeset
    53
  "_slice"  ==  "CONST slice"
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    54
35068
544867142ea4 modernized translations;
wenzelm
parents: 26351
diff changeset
    55
  "_Call"   ==  "CONST ACall"
544867142ea4 modernized translations;
wenzelm
parents: 26351
diff changeset
    56
  "_Return" ==  "CONST AReturn"
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    57
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    58
defs
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    59
  slice_def:     "(PRED (x!i)) s == x s i"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    60
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    61
  caller_def:    "caller ch   == %s p. (cbit (ch s p), arg (ch s p))"
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    62
  rtrner_def:    "rtrner ch   == %s p. (rbit (ch s p), res (ch s p))"
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    63
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    64
  Calling_def:   "Calling ch p  == PRED cbit< ch!p > ~= rbit< ch!p >"
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    65
  Call_def:      "(ACT Call ch p v)   == ACT  ~ $Calling ch p
9517
f58863b1406a tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents: 6255
diff changeset
    66
                                     & (cbit<ch!p>$ ~= $rbit<ch!p>)
f58863b1406a tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents: 6255
diff changeset
    67
                                     & (arg<ch!p>$ = $v)"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    68
  Return_def:    "(ACT Return ch p v) == ACT  $Calling ch p
9517
f58863b1406a tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents: 6255
diff changeset
    69
                                     & (rbit<ch!p>$ = $cbit<ch!p>)
f58863b1406a tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents: 6255
diff changeset
    70
                                     & (res<ch!p>$ = $v)"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    71
  PLegalCaller_def:      "PLegalCaller ch p == TEMP
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    72
                             Init(~ Calling ch p)
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    73
                             & [][ ? a. Call ch p a ]_((caller ch)!p)"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    74
  LegalCaller_def:       "LegalCaller ch == TEMP (! p. PLegalCaller ch p)"
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    75
  PLegalReturner_def:    "PLegalReturner ch p == TEMP
6255
db63752140c7 updated (Stephan Merz);
wenzelm
parents: 3807
diff changeset
    76
                                [][ ? v. Return ch p v ]_((rtrner ch)!p)"
17309
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    77
  LegalReturner_def:     "LegalReturner ch == TEMP (! p. PLegalReturner ch p)"
c43ed29bd197 converted to Isar theory format;
wenzelm
parents: 12338
diff changeset
    78
21624
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    79
declare slice_def [simp]
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    80
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    81
lemmas Procedure_defs = caller_def rtrner_def Calling_def Call_def Return_def
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    82
  PLegalCaller_def LegalCaller_def PLegalReturner_def LegalReturner_def
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    83
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    84
(* Calls and returns change their subchannel *)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    85
lemma Call_changed: "|- Call ch p v --> <Call ch p v>_((caller ch)!p)"
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    86
  by (auto simp: angle_def Call_def caller_def Calling_def)
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    87
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    88
lemma Return_changed: "|- Return ch p v --> <Return ch p v>_((rtrner ch)!p)"
6f79647cf536 TLA: converted legacy ML scripts;
wenzelm
parents: 17309
diff changeset
    89
  by (auto simp: angle_def Return_def rtrner_def Calling_def)
3807
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    90
82a99b090d9d A formalization of TLA in HOL -- by Stephan Merz;
wenzelm
parents:
diff changeset
    91
end