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