src/HOL/UNITY/Comp/Alloc.thy
author wenzelm
Fri, 13 Mar 2009 19:58:26 +0100
changeset 30510 4120fc59dd85
parent 25995 21b51f748daf
child 30528 7173bf123335
permissions -rw-r--r--
unified type Proof.method and pervasive METHOD combinators;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
     1
(*  ID:         $Id$
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
     3
    Copyright   1998  University of Cambridge
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
     4
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
     5
Specification of Chandy and Charpentier's Allocator
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
     6
*)
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
     7
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
     8
theory Alloc
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
     9
imports AllocBase "../PPROD"
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    10
begin
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    11
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    12
subsection{*State definitions.  OUTPUT variables are locals*}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    13
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    14
record clientState =
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    15
  giv :: "nat list"   --{*client's INPUT history:  tokens GRANTED*}
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    16
  ask :: "nat list"   --{*client's OUTPUT history: tokens REQUESTED*}
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    17
  rel :: "nat list"   --{*client's OUTPUT history: tokens RELEASED*}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    18
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    19
record 'a clientState_d =
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    20
  clientState +
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    21
  dummy :: 'a       --{*dummy field for new variables*}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    22
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    23
constdefs
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    24
  --{*DUPLICATED FROM Client.thy, but with "tok" removed*}
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    25
  --{*Maybe want a special theory section to declare such maps*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    26
  non_dummy :: "'a clientState_d => clientState"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    27
    "non_dummy s == (|giv = giv s, ask = ask s, rel = rel s|)"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    28
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    29
  --{*Renaming map to put a Client into the standard form*}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    30
  client_map :: "'a clientState_d => clientState*'a"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    31
    "client_map == funPair non_dummy dummy"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    32
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
    33
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    34
record allocState =
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    35
  allocGiv :: "nat => nat list"   --{*OUTPUT history: source of "giv" for i*}
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    36
  allocAsk :: "nat => nat list"   --{*INPUT: allocator's copy of "ask" for i*}
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    37
  allocRel :: "nat => nat list"   --{*INPUT: allocator's copy of "rel" for i*}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    38
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    39
record 'a allocState_d =
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    40
  allocState +
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    41
  dummy    :: 'a                --{*dummy field for new variables*}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    42
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    43
record 'a systemState =
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    44
  allocState +
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    45
  client :: "nat => clientState"  --{*states of all clients*}
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    46
  dummy  :: 'a                    --{*dummy field for new variables*}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    47
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    48
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    49
constdefs
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    50
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    51
--{** Resource allocation system specification **}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    52
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    53
  --{*spec (1)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    54
  system_safety :: "'a systemState program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    55
    "system_safety ==
15074
277b3a4da341 Modified \<Sum> syntax a little.
nipkow
parents: 11786
diff changeset
    56
     Always {s. (SUM i: lessThan Nclients. (tokens o giv o sub i o client)s)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    57
     \<le> NbT + (SUM i: lessThan Nclients. (tokens o rel o sub i o client)s)}"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    58
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    59
  --{*spec (2)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    60
  system_progress :: "'a systemState program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    61
    "system_progress == INT i : lessThan Nclients.
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
    62
                        INT h.
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
    63
                          {s. h \<le> (ask o sub i o client)s} LeadsTo
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
    64
                          {s. h pfixLe (giv o sub i o client) s}"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    65
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    66
  system_spec :: "'a systemState program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    67
    "system_spec == system_safety Int system_progress"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    68
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    69
--{** Client specification (required) ***}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    70
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    71
  --{*spec (3)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    72
  client_increasing :: "'a clientState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    73
    "client_increasing ==
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    74
         UNIV guarantees  Increasing ask Int Increasing rel"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    75
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    76
  --{*spec (4)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    77
  client_bounded :: "'a clientState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    78
    "client_bounded ==
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    79
         UNIV guarantees  Always {s. ALL elt : set (ask s). elt \<le> NbT}"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    80
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    81
  --{*spec (5)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    82
  client_progress :: "'a clientState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    83
    "client_progress ==
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
    84
         Increasing giv  guarantees
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
    85
         (INT h. {s. h \<le> giv s & h pfixGe ask s}
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
    86
                 LeadsTo {s. tokens h \<le> (tokens o rel) s})"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    87
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    88
  --{*spec: preserves part*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    89
  client_preserves :: "'a clientState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    90
    "client_preserves == preserves giv Int preserves clientState_d.dummy"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    91
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    92
  --{*environmental constraints*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    93
  client_allowed_acts :: "'a clientState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    94
    "client_allowed_acts ==
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    95
       {F. AllowedActs F =
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
    96
            insert Id (UNION (preserves (funPair rel ask)) Acts)}"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    97
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
    98
  client_spec :: "'a clientState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    99
    "client_spec == client_increasing Int client_bounded Int client_progress
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   100
                    Int client_allowed_acts Int client_preserves"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   101
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   102
--{** Allocator specification (required) **}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   103
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   104
  --{*spec (6)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   105
  alloc_increasing :: "'a allocState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   106
    "alloc_increasing ==
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   107
         UNIV  guarantees
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   108
         (INT i : lessThan Nclients. Increasing (sub i o allocGiv))"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   109
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   110
  --{*spec (7)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   111
  alloc_safety :: "'a allocState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   112
    "alloc_safety ==
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   113
         (INT i : lessThan Nclients. Increasing (sub i o allocRel))
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   114
         guarantees
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   115
         Always {s. (SUM i: lessThan Nclients. (tokens o sub i o allocGiv)s)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   116
         \<le> NbT + (SUM i: lessThan Nclients. (tokens o sub i o allocRel)s)}"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   117
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   118
  --{*spec (8)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   119
  alloc_progress :: "'a allocState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   120
    "alloc_progress ==
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   121
         (INT i : lessThan Nclients. Increasing (sub i o allocAsk) Int
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   122
                                     Increasing (sub i o allocRel))
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   123
         Int
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   124
         Always {s. ALL i<Nclients.
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   125
                     ALL elt : set ((sub i o allocAsk) s). elt \<le> NbT}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   126
         Int
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   127
         (INT i : lessThan Nclients.
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   128
          INT h. {s. h \<le> (sub i o allocGiv)s & h pfixGe (sub i o allocAsk)s}
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   129
                 LeadsTo
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   130
                 {s. tokens h \<le> (tokens o sub i o allocRel)s})
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   131
         guarantees
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   132
             (INT i : lessThan Nclients.
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   133
              INT h. {s. h \<le> (sub i o allocAsk) s}
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   134
                     LeadsTo
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   135
                     {s. h pfixLe (sub i o allocGiv) s})"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   136
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   137
  (*NOTE: to follow the original paper, the formula above should have had
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   138
        INT h. {s. h i \<le> (sub i o allocGiv)s & h i pfixGe (sub i o allocAsk)s}
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   139
               LeadsTo
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   140
               {s. tokens h i \<le> (tokens o sub i o allocRel)s})
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   141
    thus h should have been a function variable.  However, only h i is ever
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   142
    looked at.*)
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   143
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   144
  --{*spec: preserves part*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   145
  alloc_preserves :: "'a allocState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   146
    "alloc_preserves == preserves allocRel Int preserves allocAsk Int
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   147
                        preserves allocState_d.dummy"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   148
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   149
  --{*environmental constraints*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   150
  alloc_allowed_acts :: "'a allocState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   151
    "alloc_allowed_acts ==
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   152
       {F. AllowedActs F =
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   153
            insert Id (UNION (preserves allocGiv) Acts)}"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   154
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   155
  alloc_spec :: "'a allocState_d program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   156
    "alloc_spec == alloc_increasing Int alloc_safety Int alloc_progress Int
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   157
                   alloc_allowed_acts Int alloc_preserves"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   158
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   159
--{** Network specification **}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   160
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   161
  --{*spec (9.1)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   162
  network_ask :: "'a systemState program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   163
    "network_ask == INT i : lessThan Nclients.
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   164
                        Increasing (ask o sub i o client)  guarantees
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   165
                        ((sub i o allocAsk) Fols (ask o sub i o client))"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   166
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   167
  --{*spec (9.2)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   168
  network_giv :: "'a systemState program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   169
    "network_giv == INT i : lessThan Nclients.
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   170
                        Increasing (sub i o allocGiv)
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   171
                        guarantees
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   172
                        ((giv o sub i o client) Fols (sub i o allocGiv))"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   173
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   174
  --{*spec (9.3)*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   175
  network_rel :: "'a systemState program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   176
    "network_rel == INT i : lessThan Nclients.
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   177
                        Increasing (rel o sub i o client)
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   178
                        guarantees
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   179
                        ((sub i o allocRel) Fols (rel o sub i o client))"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   180
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   181
  --{*spec: preserves part*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   182
  network_preserves :: "'a systemState program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   183
    "network_preserves ==
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   184
       preserves allocGiv  Int
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   185
       (INT i : lessThan Nclients. preserves (rel o sub i o client)  Int
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   186
                                   preserves (ask o sub i o client))"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   187
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   188
  --{*environmental constraints*}
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   189
  network_allowed_acts :: "'a systemState program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   190
    "network_allowed_acts ==
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   191
       {F. AllowedActs F =
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   192
           insert Id
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   193
            (UNION (preserves allocRel Int
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   194
                    (INT i: lessThan Nclients. preserves(giv o sub i o client)))
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   195
                  Acts)}"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   196
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   197
  network_spec :: "'a systemState program set"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   198
    "network_spec == network_ask Int network_giv Int
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   199
                     network_rel Int network_allowed_acts Int
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   200
                     network_preserves"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   201
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   202
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   203
--{** State mappings **}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   204
  sysOfAlloc :: "((nat => clientState) * 'a) allocState_d => 'a systemState"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   205
    "sysOfAlloc == %s. let (cl,xtr) = allocState_d.dummy s
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   206
                       in (| allocGiv = allocGiv s,
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   207
                             allocAsk = allocAsk s,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   208
                             allocRel = allocRel s,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   209
                             client   = cl,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   210
                             dummy    = xtr|)"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   211
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   212
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   213
  sysOfClient :: "(nat => clientState) * 'a allocState_d => 'a systemState"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   214
    "sysOfClient == %(cl,al). (| allocGiv = allocGiv al,
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   215
                                 allocAsk = allocAsk al,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   216
                                 allocRel = allocRel al,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   217
                                 client   = cl,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   218
                                 systemState.dummy = allocState_d.dummy al|)"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   219
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   220
consts
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   221
    Alloc   :: "'a allocState_d program"
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   222
    Client  :: "'a clientState_d program"
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   223
    Network :: "'a systemState program"
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   224
    System  :: "'a systemState program"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   225
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   226
axioms
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   227
    Alloc:   "Alloc   : alloc_spec"
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   228
    Client:  "Client  : client_spec"
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   229
    Network: "Network : network_spec"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   230
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   231
defs
17310
1322ed8e0ee4 converted to Isar theory format;
wenzelm
parents: 15074
diff changeset
   232
    System_def:
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   233
      "System == rename sysOfAlloc Alloc Join Network Join
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   234
                 (rename sysOfClient
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   235
                  (plam x: lessThan Nclients. rename client_map Client))"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   236
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   237
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   238
(**
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   239
locale System =
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   240
  fixes
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   241
    Alloc   :: 'a allocState_d program
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   242
    Client  :: 'a clientState_d program
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   243
    Network :: 'a systemState program
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   244
    System  :: 'a systemState program
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   245
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   246
  assumes
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   247
    Alloc   "Alloc   : alloc_spec"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   248
    Client  "Client  : client_spec"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   249
    Network "Network : network_spec"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   250
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   251
  defines
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   252
    System_def
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   253
      "System == rename sysOfAlloc Alloc
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   254
                 Join
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   255
                 Network
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   256
                 Join
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   257
                 (rename sysOfClient
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   258
                  (plam x: lessThan Nclients. rename client_map Client))"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   259
**)
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   260
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   261
(*Perhaps equalities.ML shouldn't add this in the first place!*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   262
declare image_Collect [simp del]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   263
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   264
declare subset_preserves_o [THEN [2] rev_subsetD, intro]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   265
declare subset_preserves_o [THEN [2] rev_subsetD, simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   266
declare funPair_o_distrib [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   267
declare Always_INT_distrib [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   268
declare o_apply [simp del]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   269
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   270
(*For rewriting of specifications related by "guarantees"*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   271
lemmas [simp] =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   272
  rename_image_constrains
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   273
  rename_image_stable
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   274
  rename_image_increasing
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   275
  rename_image_invariant
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   276
  rename_image_Constrains
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   277
  rename_image_Stable
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   278
  rename_image_Increasing
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   279
  rename_image_Always
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   280
  rename_image_leadsTo
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   281
  rename_image_LeadsTo
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   282
  rename_preserves
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   283
  rename_image_preserves
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   284
  lift_image_preserves
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   285
  bij_image_INT
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   286
  bij_is_inj [THEN image_Int]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   287
  bij_image_Collect_eq
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   288
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   289
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   290
(*Splits up conjunctions & intersections: like CONJUNCTS in the HOL system*)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   291
fun list_of_Int th =
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   292
    (list_of_Int (th RS conjunct1) @ list_of_Int (th RS conjunct2))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   293
    handle THM _ => (list_of_Int (th RS IntD1) @ list_of_Int (th RS IntD2))
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   294
    handle THM _ => (list_of_Int (th RS @{thm INT_D}))
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   295
    handle THM _ => (list_of_Int (th RS bspec))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   296
    handle THM _ => [th];
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   297
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   298
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   299
lemmas lessThanBspec = lessThan_iff [THEN iffD2, THEN [2] bspec]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   300
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   301
setup {*
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   302
let
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   303
  fun normalized th =
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   304
    normalized (th RS spec
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   305
      handle THM _ => th RS @{thm lessThanBspec}
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   306
      handle THM _ => th RS bspec
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   307
      handle THM _ => th RS (@{thm guarantees_INT_right_iff} RS iffD1))
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   308
    handle THM _ => th;
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   309
in
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   310
  Attrib.add_attributes [("normalized", Attrib.no_args (Thm.rule_attribute (K normalized)), "")]
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   311
end
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   312
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   313
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   314
(*** bijectivity of sysOfAlloc [MUST BE AUTOMATED] ***)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   315
ML {*
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   316
fun record_auto_tac (cs, ss) =
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   317
  auto_tac (cs addIs [ext] addSWrapper record_split_wrapper,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   318
    ss addsimps [@{thm sysOfAlloc_def}, @{thm sysOfClient_def},
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   319
      @{thm client_map_def}, @{thm non_dummy_def}, @{thm funPair_def},
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   320
      @{thm o_apply}, @{thm Let_def}])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   321
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   322
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   323
method_setup record_auto = {*
30510
4120fc59dd85 unified type Proof.method and pervasive METHOD combinators;
wenzelm
parents: 25995
diff changeset
   324
  Method.ctxt_args (fn ctxt => SIMPLE_METHOD (record_auto_tac (local_clasimpset_of ctxt)))
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   325
*} ""
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   326
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   327
lemma inj_sysOfAlloc [iff]: "inj sysOfAlloc"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   328
  apply (unfold sysOfAlloc_def Let_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   329
  apply (rule inj_onI)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   330
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   331
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   332
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   333
text{*We need the inverse; also having it simplifies the proof of surjectivity*}
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   334
lemma inv_sysOfAlloc_eq [simp]: "!!s. inv sysOfAlloc s =
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   335
             (| allocGiv = allocGiv s,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   336
                allocAsk = allocAsk s,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   337
                allocRel = allocRel s,
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   338
                allocState_d.dummy = (client s, dummy s) |)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   339
  apply (rule inj_sysOfAlloc [THEN inv_f_eq])
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   340
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   341
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   342
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   343
lemma surj_sysOfAlloc [iff]: "surj sysOfAlloc"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   344
  apply (simp add: surj_iff expand_fun_eq o_apply)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   345
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   346
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   347
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   348
lemma bij_sysOfAlloc [iff]: "bij sysOfAlloc"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   349
  apply (blast intro: bijI)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   350
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   351
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   352
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   353
subsubsection{*bijectivity of @{term sysOfClient}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   354
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   355
lemma inj_sysOfClient [iff]: "inj sysOfClient"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   356
  apply (unfold sysOfClient_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   357
  apply (rule inj_onI)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   358
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   359
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   360
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   361
lemma inv_sysOfClient_eq [simp]: "!!s. inv sysOfClient s =
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   362
             (client s,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   363
              (| allocGiv = allocGiv s,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   364
                 allocAsk = allocAsk s,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   365
                 allocRel = allocRel s,
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   366
                 allocState_d.dummy = systemState.dummy s|) )"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   367
  apply (rule inj_sysOfClient [THEN inv_f_eq])
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   368
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   369
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   370
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   371
lemma surj_sysOfClient [iff]: "surj sysOfClient"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   372
  apply (simp add: surj_iff expand_fun_eq o_apply)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   373
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   374
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   375
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   376
lemma bij_sysOfClient [iff]: "bij sysOfClient"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   377
  apply (blast intro: bijI)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   378
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   379
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   380
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   381
subsubsection{*bijectivity of @{term client_map}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   382
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   383
lemma inj_client_map [iff]: "inj client_map"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   384
  apply (unfold inj_on_def)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   385
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   386
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   387
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   388
lemma inv_client_map_eq [simp]: "!!s. inv client_map s =
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   389
             (%(x,y).(|giv = giv x, ask = ask x, rel = rel x,
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   390
                       clientState_d.dummy = y|)) s"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   391
  apply (rule inj_client_map [THEN inv_f_eq])
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   392
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   393
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   394
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   395
lemma surj_client_map [iff]: "surj client_map"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   396
  apply (simp add: surj_iff expand_fun_eq o_apply)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   397
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   398
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   399
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   400
lemma bij_client_map [iff]: "bij client_map"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   401
  apply (blast intro: bijI)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   402
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   403
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   404
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   405
text{*o-simprules for @{term client_map}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   406
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   407
lemma fst_o_client_map: "fst o client_map = non_dummy"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   408
  apply (unfold client_map_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   409
  apply (rule fst_o_funPair)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   410
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   411
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   412
ML {* bind_thms ("fst_o_client_map'", make_o_equivs (thm "fst_o_client_map")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   413
declare fst_o_client_map' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   414
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   415
lemma snd_o_client_map: "snd o client_map = clientState_d.dummy"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   416
  apply (unfold client_map_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   417
  apply (rule snd_o_funPair)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   418
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   419
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   420
ML {* bind_thms ("snd_o_client_map'", make_o_equivs (thm "snd_o_client_map")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   421
declare snd_o_client_map' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   422
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   423
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   424
subsection{*o-simprules for @{term sysOfAlloc} [MUST BE AUTOMATED]*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   425
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   426
lemma client_o_sysOfAlloc: "client o sysOfAlloc = fst o allocState_d.dummy "
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   427
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   428
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   429
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   430
ML {* bind_thms ("client_o_sysOfAlloc'", make_o_equivs (thm "client_o_sysOfAlloc")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   431
declare client_o_sysOfAlloc' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   432
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   433
lemma allocGiv_o_sysOfAlloc_eq: "allocGiv o sysOfAlloc = allocGiv"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   434
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   435
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   436
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   437
ML {* bind_thms ("allocGiv_o_sysOfAlloc_eq'", make_o_equivs (thm "allocGiv_o_sysOfAlloc_eq")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   438
declare allocGiv_o_sysOfAlloc_eq' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   439
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   440
lemma allocAsk_o_sysOfAlloc_eq: "allocAsk o sysOfAlloc = allocAsk"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   441
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   442
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   443
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   444
ML {* bind_thms ("allocAsk_o_sysOfAlloc_eq'", make_o_equivs (thm "allocAsk_o_sysOfAlloc_eq")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   445
declare allocAsk_o_sysOfAlloc_eq' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   446
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   447
lemma allocRel_o_sysOfAlloc_eq: "allocRel o sysOfAlloc = allocRel"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   448
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   449
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   450
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   451
ML {* bind_thms ("allocRel_o_sysOfAlloc_eq'", make_o_equivs (thm "allocRel_o_sysOfAlloc_eq")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   452
declare allocRel_o_sysOfAlloc_eq' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   453
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   454
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   455
subsection{* o-simprules for @{term sysOfClient} [MUST BE AUTOMATED]*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   456
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   457
lemma client_o_sysOfClient: "client o sysOfClient = fst"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   458
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   459
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   460
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   461
ML {* bind_thms ("client_o_sysOfClient'", make_o_equivs (thm "client_o_sysOfClient")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   462
declare client_o_sysOfClient' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   463
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   464
lemma allocGiv_o_sysOfClient_eq: "allocGiv o sysOfClient = allocGiv o snd "
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   465
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   466
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   467
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   468
ML {* bind_thms ("allocGiv_o_sysOfClient_eq'", make_o_equivs (thm "allocGiv_o_sysOfClient_eq")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   469
declare allocGiv_o_sysOfClient_eq' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   470
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   471
lemma allocAsk_o_sysOfClient_eq: "allocAsk o sysOfClient = allocAsk o snd "
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   472
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   473
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   474
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   475
ML {* bind_thms ("allocAsk_o_sysOfClient_eq'", make_o_equivs (thm "allocAsk_o_sysOfClient_eq")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   476
declare allocAsk_o_sysOfClient_eq' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   477
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   478
lemma allocRel_o_sysOfClient_eq: "allocRel o sysOfClient = allocRel o snd "
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   479
  apply record_auto
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   480
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   481
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   482
ML {* bind_thms ("allocRel_o_sysOfClient_eq'", make_o_equivs (thm "allocRel_o_sysOfClient_eq")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   483
declare allocRel_o_sysOfClient_eq' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   484
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   485
lemma allocGiv_o_inv_sysOfAlloc_eq: "allocGiv o inv sysOfAlloc = allocGiv"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   486
  apply (simp add: o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   487
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   488
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   489
ML {* bind_thms ("allocGiv_o_inv_sysOfAlloc_eq'", make_o_equivs (thm "allocGiv_o_inv_sysOfAlloc_eq")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   490
declare allocGiv_o_inv_sysOfAlloc_eq' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   491
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   492
lemma allocAsk_o_inv_sysOfAlloc_eq: "allocAsk o inv sysOfAlloc = allocAsk"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   493
  apply (simp add: o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   494
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   495
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   496
ML {* bind_thms ("allocAsk_o_inv_sysOfAlloc_eq'", make_o_equivs (thm "allocAsk_o_inv_sysOfAlloc_eq")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   497
declare allocAsk_o_inv_sysOfAlloc_eq' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   498
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   499
lemma allocRel_o_inv_sysOfAlloc_eq: "allocRel o inv sysOfAlloc = allocRel"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   500
  apply (simp add: o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   501
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   502
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   503
ML {* bind_thms ("allocRel_o_inv_sysOfAlloc_eq'", make_o_equivs (thm "allocRel_o_inv_sysOfAlloc_eq")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   504
declare allocRel_o_inv_sysOfAlloc_eq' [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   505
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   506
lemma rel_inv_client_map_drop_map: "(rel o inv client_map o drop_map i o inv sysOfClient) =
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   507
      rel o sub i o client"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   508
  apply (simp add: o_def drop_map_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   509
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   510
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   511
ML {* bind_thms ("rel_inv_client_map_drop_map'", make_o_equivs (thm "rel_inv_client_map_drop_map")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   512
declare rel_inv_client_map_drop_map [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   513
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   514
lemma ask_inv_client_map_drop_map: "(ask o inv client_map o drop_map i o inv sysOfClient) =
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   515
      ask o sub i o client"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   516
  apply (simp add: o_def drop_map_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   517
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   518
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   519
ML {* bind_thms ("ask_inv_client_map_drop_map'", make_o_equivs (thm "ask_inv_client_map_drop_map")) *}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   520
declare ask_inv_client_map_drop_map [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   521
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   522
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   523
declare finite_lessThan [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   524
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   525
text{*Client : <unfolded specification> *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   526
lemmas client_spec_simps =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   527
  client_spec_def client_increasing_def client_bounded_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   528
  client_progress_def client_allowed_acts_def client_preserves_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   529
  guarantees_Int_right
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   530
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   531
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   532
val [Client_Increasing_ask, Client_Increasing_rel,
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   533
     Client_Bounded, Client_Progress, Client_AllowedActs,
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   534
     Client_preserves_giv, Client_preserves_dummy] =
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   535
        @{thm Client} |> simplify (@{simpset} addsimps @{thms client_spec_simps})
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   536
               |> list_of_Int;
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   537
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   538
bind_thm ("Client_Increasing_ask", Client_Increasing_ask);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   539
bind_thm ("Client_Increasing_rel", Client_Increasing_rel);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   540
bind_thm ("Client_Bounded", Client_Bounded);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   541
bind_thm ("Client_Progress", Client_Progress);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   542
bind_thm ("Client_AllowedActs", Client_AllowedActs);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   543
bind_thm ("Client_preserves_giv", Client_preserves_giv);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   544
bind_thm ("Client_preserves_dummy", Client_preserves_dummy);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   545
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   546
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   547
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   548
  Client_Increasing_ask [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   549
  Client_Increasing_rel [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   550
  Client_Bounded [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   551
  Client_preserves_giv [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   552
  Client_preserves_dummy [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   553
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   554
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   555
text{*Network : <unfolded specification> *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   556
lemmas network_spec_simps =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   557
  network_spec_def network_ask_def network_giv_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   558
  network_rel_def network_allowed_acts_def network_preserves_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   559
  ball_conj_distrib
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   560
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   561
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   562
val [Network_Ask, Network_Giv, Network_Rel, Network_AllowedActs,
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   563
     Network_preserves_allocGiv, Network_preserves_rel,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   564
     Network_preserves_ask]  =
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   565
        @{thm Network} |> simplify (@{simpset} addsimps @{thms network_spec_simps})
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   566
                |> list_of_Int;
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   567
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   568
bind_thm ("Network_Ask", Network_Ask);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   569
bind_thm ("Network_Giv", Network_Giv);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   570
bind_thm ("Network_Rel", Network_Rel);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   571
bind_thm ("Network_AllowedActs", Network_AllowedActs);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   572
bind_thm ("Network_preserves_allocGiv", Network_preserves_allocGiv);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   573
bind_thm ("Network_preserves_rel", Network_preserves_rel);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   574
bind_thm ("Network_preserves_ask", Network_preserves_ask);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   575
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   576
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   577
declare Network_preserves_allocGiv [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   578
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   579
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   580
  Network_preserves_rel [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   581
  Network_preserves_ask [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   582
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   583
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   584
  Network_preserves_rel [simplified o_def, simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   585
  Network_preserves_ask [simplified o_def, simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   586
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   587
text{*Alloc : <unfolded specification> *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   588
lemmas alloc_spec_simps =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   589
  alloc_spec_def alloc_increasing_def alloc_safety_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   590
  alloc_progress_def alloc_allowed_acts_def alloc_preserves_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   591
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   592
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   593
val [Alloc_Increasing_0, Alloc_Safety, Alloc_Progress, Alloc_AllowedActs,
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   594
     Alloc_preserves_allocRel, Alloc_preserves_allocAsk,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   595
     Alloc_preserves_dummy] =
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   596
        @{thm Alloc} |> simplify (@{simpset} addsimps @{thms alloc_spec_simps})
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   597
              |> list_of_Int;
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   598
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   599
bind_thm ("Alloc_Increasing_0", Alloc_Increasing_0);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   600
bind_thm ("Alloc_Safety", Alloc_Safety);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   601
bind_thm ("Alloc_Progress", Alloc_Progress);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   602
bind_thm ("Alloc_AllowedActs", Alloc_AllowedActs);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   603
bind_thm ("Alloc_preserves_allocRel", Alloc_preserves_allocRel);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   604
bind_thm ("Alloc_preserves_allocAsk", Alloc_preserves_allocAsk);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   605
bind_thm ("Alloc_preserves_dummy", Alloc_preserves_dummy);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   606
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   607
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   608
text{*Strip off the INT in the guarantees postcondition*}
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   609
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   610
lemmas Alloc_Increasing = Alloc_Increasing_0 [normalized]
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   611
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   612
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   613
  Alloc_preserves_allocRel [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   614
  Alloc_preserves_allocAsk [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   615
  Alloc_preserves_dummy [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   616
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   617
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   618
subsection{*Components Lemmas [MUST BE AUTOMATED]*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   619
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   620
lemma Network_component_System: "Network Join
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   621
      ((rename sysOfClient
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   622
        (plam x: (lessThan Nclients). rename client_map Client)) Join
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   623
       rename sysOfAlloc Alloc)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   624
      = System"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   625
  by (simp add: System_def Join_ac)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   626
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   627
lemma Client_component_System: "(rename sysOfClient
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   628
       (plam x: (lessThan Nclients). rename client_map Client)) Join
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   629
      (Network Join rename sysOfAlloc Alloc)  =  System"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   630
  by (simp add: System_def Join_ac)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   631
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   632
lemma Alloc_component_System: "rename sysOfAlloc Alloc Join
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   633
       ((rename sysOfClient (plam x: (lessThan Nclients). rename client_map Client)) Join
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   634
        Network)  =  System"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   635
  by (simp add: System_def Join_ac)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   636
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   637
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   638
  Client_component_System [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   639
  Network_component_System [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   640
  Alloc_component_System [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   641
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   642
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   643
text{** These preservation laws should be generated automatically **}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   644
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   645
lemma Client_Allowed [simp]: "Allowed Client = preserves rel Int preserves ask"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   646
  by (auto simp add: Allowed_def Client_AllowedActs safety_prop_Acts_iff)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   647
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   648
lemma Network_Allowed [simp]: "Allowed Network =
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   649
        preserves allocRel Int
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   650
        (INT i: lessThan Nclients. preserves(giv o sub i o client))"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   651
  by (auto simp add: Allowed_def Network_AllowedActs safety_prop_Acts_iff)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   652
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   653
lemma Alloc_Allowed [simp]: "Allowed Alloc = preserves allocGiv"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   654
  by (auto simp add: Allowed_def Alloc_AllowedActs safety_prop_Acts_iff)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   655
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   656
text{*needed in @{text rename_client_map_tac}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   657
lemma OK_lift_rename_Client [simp]: "OK I (%i. lift i (rename client_map Client))"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   658
  apply (rule OK_lift_I)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   659
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   660
  apply (drule_tac w1 = rel in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   661
  apply (drule_tac [2] w1 = ask in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   662
  apply (auto simp add: o_def split_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   663
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   664
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   665
lemma fst_lift_map_eq_fst [simp]: "fst (lift_map i x) i = fst x"
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   666
apply (insert fst_o_lift_map [of i])
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   667
apply (drule fun_cong [where x=x])
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   668
apply (simp add: o_def);
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   669
done
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   670
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   671
lemma fst_o_lift_map' [simp]:
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   672
     "(f \<circ> sub i \<circ> fst \<circ> lift_map i \<circ> g) = f o fst o g"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   673
apply (subst fst_o_lift_map [symmetric])
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   674
apply (simp only: o_assoc)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   675
done
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   676
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   677
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   678
(*The proofs of rename_Client_Increasing, rename_Client_Bounded and
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   679
  rename_Client_Progress are similar.  All require copying out the original
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   680
  Client property.  A forward proof can be constructed as follows:
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   681
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   682
  Client_Increasing_ask RS
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   683
      (bij_client_map RS rename_rename_guarantees_eq RS iffD2)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   684
  RS (lift_lift_guarantees_eq RS iffD2)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   685
  RS guarantees_PLam_I
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   686
  RS (bij_sysOfClient RS rename_rename_guarantees_eq RS iffD2)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   687
  |> simplify (simpset() addsimps [lift_image_eq_rename, o_def, split_def,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   688
                                   surj_rename RS surj_range])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   689
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   690
However, the "preserves" property remains to be discharged, and the unfolding
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   691
of "o" and "sub" complicates subsequent reasoning.
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   692
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   693
The following tactic works for all three proofs, though it certainly looks
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   694
ad-hoc!
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   695
*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   696
ML
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   697
{*
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   698
fun rename_client_map_tac ss =
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   699
  EVERY [
25995
21b51f748daf rename_client_map_tac: avoid ill-defined thm reference;
wenzelm
parents: 24147
diff changeset
   700
    simp_tac (ss addsimps [@{thm rename_guarantees_eq_rename_inv}]) 1,
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   701
    rtac @{thm guarantees_PLam_I} 1,
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   702
    assume_tac 2,
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   703
         (*preserves: routine reasoning*)
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   704
    asm_simp_tac (ss addsimps [@{thm lift_preserves_sub}]) 2,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   705
         (*the guarantee for  "lift i (rename client_map Client)" *)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   706
    asm_simp_tac
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   707
        (ss addsimps [@{thm lift_guarantees_eq_lift_inv},
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   708
                      @{thm rename_guarantees_eq_rename_inv},
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   709
                      @{thm bij_imp_bij_inv}, @{thm surj_rename} RS @{thm surj_range},
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   710
                      @{thm inv_inv_eq}]) 1,
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   711
    asm_simp_tac
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   712
        (@{simpset} addsimps [@{thm o_def}, @{thm non_dummy_def}, @{thm guarantees_Int_right}]) 1]
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   713
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   714
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   715
method_setup rename_client_map = {*
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   716
  Method.ctxt_args (fn ctxt =>
30510
4120fc59dd85 unified type Proof.method and pervasive METHOD combinators;
wenzelm
parents: 25995
diff changeset
   717
    SIMPLE_METHOD (rename_client_map_tac (local_simpset_of ctxt)))
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   718
*} ""
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   719
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   720
text{*Lifting @{text Client_Increasing} to @{term systemState}*}
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   721
lemma rename_Client_Increasing: "i : I
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   722
      ==> rename sysOfClient (plam x: I. rename client_map Client) :
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   723
            UNIV  guarantees
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   724
            Increasing (ask o sub i o client) Int
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   725
            Increasing (rel o sub i o client)"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   726
  by rename_client_map
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   727
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   728
lemma preserves_sub_fst_lift_map: "[| F : preserves w; i ~= j |]
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   729
      ==> F : preserves (sub i o fst o lift_map j o funPair v w)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   730
  apply (auto simp add: lift_map_def split_def linorder_neq_iff o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   731
  apply (drule_tac [!] subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   732
  apply (auto simp add: o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   733
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   734
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   735
lemma client_preserves_giv_oo_client_map: "[| i < Nclients; j < Nclients |]
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   736
      ==> Client : preserves (giv o sub i o fst o lift_map j o client_map)"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   737
  apply (case_tac "i=j")
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   738
  apply (simp, simp add: o_def non_dummy_def)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   739
  apply (drule Client_preserves_dummy [THEN preserves_sub_fst_lift_map])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   740
  apply (drule_tac [!] subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   741
  apply (simp add: o_def client_map_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   742
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   743
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   744
lemma rename_sysOfClient_ok_Network:
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   745
  "rename sysOfClient (plam x: lessThan Nclients. rename client_map Client)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   746
    ok Network"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   747
  by (auto simp add: ok_iff_Allowed client_preserves_giv_oo_client_map)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   748
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   749
lemma rename_sysOfClient_ok_Alloc:
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   750
  "rename sysOfClient (plam x: lessThan Nclients. rename client_map Client)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   751
    ok rename sysOfAlloc Alloc"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   752
  by (simp add: ok_iff_Allowed)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   753
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   754
lemma rename_sysOfAlloc_ok_Network: "rename sysOfAlloc Alloc ok Network"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   755
  by (simp add: ok_iff_Allowed)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   756
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   757
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   758
  rename_sysOfClient_ok_Network [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   759
  rename_sysOfClient_ok_Alloc [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   760
  rename_sysOfAlloc_ok_Network [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   761
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   762
text{*The "ok" laws, re-oriented.
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   763
  But not sure this works: theorem @{text ok_commute} is needed below*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   764
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   765
  rename_sysOfClient_ok_Network [THEN ok_sym, iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   766
  rename_sysOfClient_ok_Alloc [THEN ok_sym, iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   767
  rename_sysOfAlloc_ok_Network [THEN ok_sym]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   768
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   769
lemma System_Increasing: "i < Nclients
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   770
      ==> System : Increasing (ask o sub i o client) Int
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   771
                   Increasing (rel o sub i o client)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   772
  apply (rule component_guaranteesD [OF rename_Client_Increasing Client_component_System])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   773
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   774
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   775
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   776
lemmas rename_guarantees_sysOfAlloc_I =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   777
  bij_sysOfAlloc [THEN rename_rename_guarantees_eq, THEN iffD2, standard]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   778
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   779
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   780
(*Lifting Alloc_Increasing up to the level of systemState*)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   781
lemmas rename_Alloc_Increasing =
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   782
  Alloc_Increasing
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   783
    [THEN rename_guarantees_sysOfAlloc_I,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   784
     simplified surj_rename [THEN surj_range] o_def sub_apply
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   785
                rename_image_Increasing bij_sysOfAlloc
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   786
                allocGiv_o_inv_sysOfAlloc_eq'];
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   787
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   788
lemma System_Increasing_allocGiv:
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   789
     "i < Nclients ==> System : Increasing (sub i o allocGiv)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   790
  apply (unfold System_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   791
  apply (simp add: o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   792
  apply (rule rename_Alloc_Increasing [THEN guarantees_Join_I1, THEN guaranteesD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   793
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   794
  done
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   795
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   796
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   797
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   798
bind_thms ("System_Increasing'", list_of_Int (thm "System_Increasing"))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   799
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   800
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   801
declare System_Increasing' [intro!]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   802
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   803
text{* Follows consequences.
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   804
    The "Always (INT ...) formulation expresses the general safety property
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   805
    and allows it to be combined using @{text Always_Int_rule} below. *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   806
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   807
lemma System_Follows_rel:
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   808
  "i < Nclients ==> System : ((sub i o allocRel) Fols (rel o sub i o client))"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   809
  apply (auto intro!: Network_Rel [THEN component_guaranteesD])
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   810
  apply (simp add: ok_commute [of Network])
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   811
  done
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   812
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   813
lemma System_Follows_ask:
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   814
  "i < Nclients ==> System : ((sub i o allocAsk) Fols (ask o sub i o client))"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   815
  apply (auto intro!: Network_Ask [THEN component_guaranteesD])
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   816
  apply (simp add: ok_commute [of Network])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   817
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   818
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   819
lemma System_Follows_allocGiv:
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   820
  "i < Nclients ==> System : (giv o sub i o client) Fols (sub i o allocGiv)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   821
  apply (auto intro!: Network_Giv [THEN component_guaranteesD]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   822
    rename_Alloc_Increasing [THEN component_guaranteesD])
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   823
  apply (simp_all add: o_def non_dummy_def ok_commute [of Network])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   824
  apply (auto intro!: rename_Alloc_Increasing [THEN component_guaranteesD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   825
  done
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   826
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   827
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   828
lemma Always_giv_le_allocGiv: "System : Always (INT i: lessThan Nclients.
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   829
                       {s. (giv o sub i o client) s \<le> (sub i o allocGiv) s})"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   830
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   831
  apply (erule System_Follows_allocGiv [THEN Follows_Bounded])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   832
  done
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   833
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   834
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   835
lemma Always_allocAsk_le_ask: "System : Always (INT i: lessThan Nclients.
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   836
                       {s. (sub i o allocAsk) s \<le> (ask o sub i o client) s})"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   837
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   838
  apply (erule System_Follows_ask [THEN Follows_Bounded])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   839
  done
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   840
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   841
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   842
lemma Always_allocRel_le_rel: "System : Always (INT i: lessThan Nclients.
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   843
                       {s. (sub i o allocRel) s \<le> (rel o sub i o client) s})"
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   844
  by (auto intro!: Follows_Bounded System_Follows_rel)
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   845
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   846
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   847
subsection{*Proof of the safety property (1)*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   848
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   849
text{*safety (1), step 1 is @{text System_Follows_rel}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   850
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   851
text{*safety (1), step 2*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   852
(* i < Nclients ==> System : Increasing (sub i o allocRel) *)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   853
lemmas System_Increasing_allocRel = System_Follows_rel [THEN Follows_Increasing1, standard]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   854
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   855
(*Lifting Alloc_safety up to the level of systemState.
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   856
  Simplifying with o_def gets rid of the translations but it unfortunately
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   857
  gets rid of the other "o"s too.*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   858
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   859
text{*safety (1), step 3*}
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   860
lemma System_sum_bounded:
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   861
    "System : Always {s. (\<Sum>i \<in> lessThan Nclients. (tokens o sub i o allocGiv) s)
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   862
            \<le> NbT + (\<Sum>i \<in> lessThan Nclients. (tokens o sub i o allocRel) s)}"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   863
  apply (simp add: o_apply)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   864
  apply (insert Alloc_Safety [THEN rename_guarantees_sysOfAlloc_I])
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   865
  apply (simp add: o_def);
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   866
  apply (erule component_guaranteesD)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   867
  apply (auto simp add: System_Increasing_allocRel [simplified sub_apply o_def])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   868
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   869
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   870
text{* Follows reasoning*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   871
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   872
lemma Always_tokens_giv_le_allocGiv: "System : Always (INT i: lessThan Nclients.
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   873
                          {s. (tokens o giv o sub i o client) s
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   874
                           \<le> (tokens o sub i o allocGiv) s})"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   875
  apply (rule Always_giv_le_allocGiv [THEN Always_weaken])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   876
  apply (auto intro: tokens_mono_prefix simp add: o_apply)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   877
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   878
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   879
lemma Always_tokens_allocRel_le_rel: "System : Always (INT i: lessThan Nclients.
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   880
                          {s. (tokens o sub i o allocRel) s
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   881
                           \<le> (tokens o rel o sub i o client) s})"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   882
  apply (rule Always_allocRel_le_rel [THEN Always_weaken])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   883
  apply (auto intro: tokens_mono_prefix simp add: o_apply)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   884
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   885
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   886
text{*safety (1), step 4 (final result!) *}
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   887
theorem System_safety: "System : system_safety"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   888
  apply (unfold system_safety_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   889
  apply (tactic {* rtac (Always_Int_rule [thm "System_sum_bounded",
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   890
    thm "Always_tokens_giv_le_allocGiv", thm "Always_tokens_allocRel_le_rel"] RS
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   891
    thm "Always_weaken") 1 *})
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   892
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   893
  apply (rule setsum_fun_mono [THEN order_trans])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   894
  apply (drule_tac [2] order_trans)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   895
  apply (rule_tac [2] add_le_mono [OF order_refl setsum_fun_mono])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   896
  prefer 3 apply assumption
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   897
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   898
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   899
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   900
subsection {* Proof of the progress property (2) *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   901
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   902
text{*progress (2), step 1 is @{text System_Follows_ask} and
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   903
      @{text System_Follows_rel}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   904
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   905
text{*progress (2), step 2; see also @{text System_Increasing_allocRel}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   906
(* i < Nclients ==> System : Increasing (sub i o allocAsk) *)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   907
lemmas System_Increasing_allocAsk =  System_Follows_ask [THEN Follows_Increasing1, standard]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   908
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   909
text{*progress (2), step 3: lifting @{text Client_Bounded} to systemState*}
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   910
lemma rename_Client_Bounded: "i : I
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   911
    ==> rename sysOfClient (plam x: I. rename client_map Client) :
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   912
          UNIV  guarantees
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   913
          Always {s. ALL elt : set ((ask o sub i o client) s). elt \<le> NbT}"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   914
  by rename_client_map
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   915
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   916
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   917
lemma System_Bounded_ask: "i < Nclients
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   918
      ==> System : Always
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   919
                    {s. ALL elt : set ((ask o sub i o client) s). elt \<le> NbT}"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   920
  apply (rule component_guaranteesD [OF rename_Client_Bounded Client_component_System])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   921
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   922
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   923
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   924
lemma Collect_all_imp_eq: "{x. ALL y. P y --> Q x y} = (INT y: {y. P y}. {x. Q x y})"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   925
  apply blast
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   926
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   927
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   928
text{*progress (2), step 4*}
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   929
lemma System_Bounded_allocAsk: "System : Always {s. ALL i<Nclients.
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   930
                          ALL elt : set ((sub i o allocAsk) s). elt \<le> NbT}"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   931
  apply (auto simp add: Collect_all_imp_eq)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   932
  apply (tactic {* rtac (Always_Int_rule [thm "Always_allocAsk_le_ask",
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   933
    thm "System_Bounded_ask"] RS thm "Always_weaken") 1 *})
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   934
  apply (auto dest: set_mono)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   935
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   936
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   937
text{*progress (2), step 5 is @{text System_Increasing_allocGiv}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   938
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   939
text{*progress (2), step 6*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   940
(* i < Nclients ==> System : Increasing (giv o sub i o client) *)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   941
lemmas System_Increasing_giv =  System_Follows_allocGiv [THEN Follows_Increasing1, standard]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   942
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   943
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   944
lemma rename_Client_Progress: "i: I
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   945
   ==> rename sysOfClient (plam x: I. rename client_map Client)
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   946
        : Increasing (giv o sub i o client)
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   947
          guarantees
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   948
          (INT h. {s. h \<le> (giv o sub i o client) s &
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   949
                            h pfixGe (ask o sub i o client) s}
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   950
                  LeadsTo {s. tokens h \<le> (tokens o rel o sub i o client) s})"
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   951
  apply rename_client_map
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   952
  apply (simp add: Client_Progress [simplified o_def])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   953
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   954
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   955
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   956
text{*progress (2), step 7*}
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   957
lemma System_Client_Progress:
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   958
  "System : (INT i : (lessThan Nclients).
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   959
            INT h. {s. h \<le> (giv o sub i o client) s &
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   960
                       h pfixGe (ask o sub i o client) s}
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   961
                LeadsTo {s. tokens h \<le> (tokens o rel o sub i o client) s})"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   962
  apply (rule INT_I)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   963
(*Couldn't have just used Auto_tac since the "INT h" must be kept*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   964
  apply (rule component_guaranteesD [OF rename_Client_Progress Client_component_System])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   965
  apply (auto simp add: System_Increasing_giv)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   966
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   967
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   968
(*Concludes
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   969
 System : {s. k \<le> (sub i o allocGiv) s}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   970
          LeadsTo
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   971
          {s. (sub i o allocAsk) s \<le> (ask o sub i o client) s} Int
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   972
          {s. k \<le> (giv o sub i o client) s} *)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   973
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   974
lemmas System_lemma1 =
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   975
  Always_LeadsToD [OF System_Follows_ask [THEN Follows_Bounded]
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   976
                      System_Follows_allocGiv [THEN Follows_LeadsTo]]
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   977
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   978
lemmas System_lemma2 =
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   979
  PSP_Stable [OF System_lemma1
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   980
              System_Follows_ask [THEN Follows_Increasing1, THEN IncreasingD]]
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   981
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   982
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   983
lemma System_lemma3: "i < Nclients
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   984
      ==> System : {s. h \<le> (sub i o allocGiv) s &
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   985
                       h pfixGe (sub i o allocAsk) s}
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   986
                   LeadsTo
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   987
                   {s. h \<le> (giv o sub i o client) s &
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   988
                       h pfixGe (ask o sub i o client) s}"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   989
  apply (rule single_LeadsTo_I)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   990
  apply (rule_tac k6 = "h" and x2 = " (sub i o allocAsk) s"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   991
         in System_lemma2 [THEN LeadsTo_weaken])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   992
  apply auto
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   993
  apply (blast intro: trans_Ge [THEN trans_genPrefix, THEN transD] prefix_imp_pfixGe)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   994
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   995
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   996
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   997
text{*progress (2), step 8: Client i's "release" action is visible system-wide*}
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   998
lemma System_Alloc_Client_Progress: "i < Nclients
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
   999
      ==> System : {s. h \<le> (sub i o allocGiv) s &
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
  1000
                       h pfixGe (sub i o allocAsk) s}
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1001
                   LeadsTo {s. tokens h \<le> (tokens o sub i o allocRel) s}"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1002
  apply (rule LeadsTo_Trans)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1003
   prefer 2
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1004
   apply (drule System_Follows_rel [THEN
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1005
     mono_tokens [THEN mono_Follows_o, THEN [2] rev_subsetD],
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1006
     THEN Follows_LeadsTo])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1007
   apply (simp add: o_assoc)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1008
  apply (rule LeadsTo_Trans)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1009
   apply (cut_tac [2] System_Client_Progress)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1010
   prefer 2
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1011
   apply (blast intro: LeadsTo_Basis)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1012
  apply (erule System_lemma3)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1013
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1014
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1015
text{*Lifting @{text Alloc_Progress} up to the level of systemState*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1016
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1017
text{*progress (2), step 9*}
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
  1018
lemma System_Alloc_Progress:
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
  1019
 "System : (INT i : (lessThan Nclients).
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
  1020
            INT h. {s. h \<le> (sub i o allocAsk) s}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1021
                   LeadsTo {s. h pfixLe (sub i o allocGiv) s})"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1022
  apply (simp only: o_apply sub_def)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
  1023
  apply (insert Alloc_Progress [THEN rename_guarantees_sysOfAlloc_I])
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
  1024
  apply (simp add: o_def del: Set.INT_iff);
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1025
  apply (erule component_guaranteesD)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
  1026
  apply (auto simp add:
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1027
    System_Increasing_allocRel [simplified sub_apply o_def]
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1028
    System_Increasing_allocAsk [simplified sub_apply o_def]
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1029
    System_Bounded_allocAsk [simplified sub_apply o_def]
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1030
    System_Alloc_Client_Progress [simplified sub_apply o_def])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1031
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1032
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1033
text{*progress (2), step 10 (final result!) *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1034
lemma System_Progress: "System : system_progress"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1035
  apply (unfold system_progress_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1036
  apply (cut_tac System_Alloc_Progress)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1037
  apply (blast intro: LeadsTo_Trans
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1038
    System_Follows_allocGiv [THEN Follows_LeadsTo_pfixLe]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1039
    System_Follows_ask [THEN Follows_LeadsTo])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1040
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1041
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1042
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1043
theorem System_correct: "System : system_spec"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1044
  apply (unfold system_spec_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1045
  apply (blast intro: System_safety System_Progress)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1046
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1047
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1048
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1049
text{* Some obsolete lemmas *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1050
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
  1051
lemma non_dummy_eq_o_funPair: "non_dummy = (% (g,a,r). (| giv = g, ask = a, rel = r |)) o
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1052
                              (funPair giv (funPair ask rel))"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1053
  apply (rule ext)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1054
  apply (auto simp add: o_def non_dummy_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1055
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1056
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21710
diff changeset
  1057
lemma preserves_non_dummy_eq: "(preserves non_dummy) =
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1058
      (preserves rel Int preserves ask Int preserves giv)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1059
  apply (simp add: non_dummy_eq_o_funPair)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1060
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1061
    apply (drule_tac w1 = rel in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1062
    apply (drule_tac [2] w1 = ask in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1063
    apply (drule_tac [3] w1 = giv in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1064
    apply (auto simp add: o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1065
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1066
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1067
text{*Could go to Extend.ML*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1068
lemma bij_fst_inv_inv_eq: "bij f ==> fst (inv (%(x, u). inv f x) z) = f z"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1069
  apply (rule fst_inv_equalityI)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1070
   apply (rule_tac f = "%z. (f z, ?h z) " in surjI)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1071
   apply (simp add: bij_is_inj inv_f_f)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1072
  apply (simp add: bij_is_surj surj_f_inv_f)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1073
  done
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
  1074
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
  1075
end