src/HOL/UNITY/Comp/Alloc.thy
author wenzelm
Tue, 10 Jul 2007 23:29:43 +0200
changeset 23719 ccd9cb15c062
parent 21710 4e4b7c801142
child 24147 edc90be09ac1
permissions -rw-r--r--
more markup for inner and outer syntax; added enclose;
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
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    33
  
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.
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    62
			INT h. 
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    63
			  {s. h \<le> (ask o sub i o client)s} LeadsTo
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    64
			  {s. h pfixLe (giv o sub i o client) s}"
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 ==
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    84
	 Increasing giv  guarantees
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
    85
	 (INT h. {s. h \<le> giv s & h pfixGe ask s}
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
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 =
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
    96
	    insert Id (UNION (preserves (funPair rel ask)) Acts)}"
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 ==
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   107
	 UNIV  guarantees
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   108
	 (INT i : lessThan Nclients. Increasing (sub i o allocGiv))"
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 ==
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   113
	 (INT i : lessThan Nclients. Increasing (sub i o allocRel))
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   114
         guarantees
15074
277b3a4da341 Modified \<Sum> syntax a little.
nipkow
parents: 11786
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 ==
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   121
	 (INT i : lessThan Nclients. Increasing (sub i o allocAsk) Int
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   122
	                             Increasing (sub i o allocRel))
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.
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
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
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   127
         (INT i : lessThan Nclients. 
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   128
	  INT h. {s. h \<le> (sub i o allocGiv)s & h pfixGe (sub i o allocAsk)s}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   129
		 LeadsTo
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
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
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   132
	     (INT i : lessThan Nclients.
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   133
	      INT h. {s. h \<le> (sub i o allocAsk) s}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   134
	             LeadsTo
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   135
	             {s. h pfixLe (sub i o allocGiv) s})"
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
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   138
	INT h. {s. h i \<le> (sub i o allocGiv)s & h i pfixGe (sub i o allocAsk)s}
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   139
	       LeadsTo
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
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"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
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 =
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   153
	    insert Id (UNION (preserves allocGiv) Acts)}"
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.
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   164
			Increasing (ask o sub i o client)  guarantees
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   165
			((sub i o allocAsk) Fols (ask o sub i o client))"
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.
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   170
			Increasing (sub i o allocGiv)
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   171
			guarantees
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   172
			((giv o sub i o client) Fols (sub i o allocGiv))"
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.
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   177
			Increasing (rel o sub i o client)
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   178
			guarantees
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   179
			((sub i o allocRel) Fols (rel o sub i o client))"
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))"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
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
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   193
	    (UNION (preserves allocRel Int
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   194
		    (INT i: lessThan Nclients. preserves(giv o sub i o client)))
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   195
		  Acts)}"
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,
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   207
			     allocAsk = allocAsk s,
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   208
			     allocRel = allocRel s,
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   209
			     client   = cl,
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   210
			     dummy    = xtr|)"
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,
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   215
			         allocAsk = allocAsk al,
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   216
			         allocRel = allocRel al,
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   217
			         client   = cl,
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   218
			         systemState.dummy = allocState_d.dummy al|)"
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   219
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
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"
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
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
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   235
		  (plam x: lessThan Nclients. rename client_map Client))"
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 =
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   240
  fixes 
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
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
   258
		  (plam x: lessThan Nclients. rename client_map Client))"
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 {*
21669
c68717c16013 removed legacy ML bindings;
wenzelm
parents: 21632
diff changeset
   290
local
c68717c16013 removed legacy ML bindings;
wenzelm
parents: 21632
diff changeset
   291
  val INT_D = thm "INT_D";
c68717c16013 removed legacy ML bindings;
wenzelm
parents: 21632
diff changeset
   292
in
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   293
(*Splits up conjunctions & intersections: like CONJUNCTS in the HOL system*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   294
fun list_of_Int th = 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   295
    (list_of_Int (th RS conjunct1) @ list_of_Int (th RS conjunct2))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   296
    handle THM _ => (list_of_Int (th RS IntD1) @ list_of_Int (th RS IntD2))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   297
    handle THM _ => (list_of_Int (th RS INT_D))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   298
    handle THM _ => (list_of_Int (th RS bspec))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   299
    handle THM _ => [th];
21669
c68717c16013 removed legacy ML bindings;
wenzelm
parents: 21632
diff changeset
   300
end;
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   301
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   302
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   303
lemmas lessThanBspec = lessThan_iff [THEN iffD2, THEN [2] bspec]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   304
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   305
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   306
local
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   307
  val lessThanBspec = thm "lessThanBspec"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   308
in
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   309
fun normalize th = 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   310
     normalize (th RS spec
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   311
		handle THM _ => th RS lessThanBspec
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   312
		handle THM _ => th RS bspec
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   313
		handle THM _ => th RS (guarantees_INT_right_iff RS iffD1))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   314
     handle THM _ => th
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   315
end
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   316
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   317
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   318
(*** bijectivity of sysOfAlloc [MUST BE AUTOMATED] ***)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   319
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   320
val record_auto_tac =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   321
  auto_tac (claset() addIs [ext] addSWrapper record_split_wrapper, 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   322
    simpset() addsimps [thm "sysOfAlloc_def", thm "sysOfClient_def",
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   323
      thm "client_map_def", thm "non_dummy_def", thm "funPair_def", thm "o_apply", thm "Let_def"])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   324
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   325
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)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   330
  apply (tactic record_auto_tac)
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*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   334
lemma inv_sysOfAlloc_eq [simp]: "!!s. inv sysOfAlloc s =  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   335
             (| allocGiv = allocGiv s,    
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   336
                allocAsk = allocAsk s,    
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   337
                allocRel = allocRel s,    
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])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   340
  apply (tactic record_auto_tac)
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)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   345
  apply (tactic record_auto_tac)
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)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   358
  apply (tactic record_auto_tac)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   359
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   360
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   361
lemma inv_sysOfClient_eq [simp]: "!!s. inv sysOfClient s =  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   362
             (client s,  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   363
              (| allocGiv = allocGiv s,  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   364
                 allocAsk = allocAsk s,  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   365
                 allocRel = allocRel s,  
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])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   368
  apply (tactic record_auto_tac)
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)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   373
  apply (tactic record_auto_tac)
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)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   385
  apply (tactic record_auto_tac)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   386
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   387
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   388
lemma inv_client_map_eq [simp]: "!!s. inv client_map s =  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   389
             (%(x,y).(|giv = giv x, ask = ask x, rel = rel x,  
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])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   392
  apply (tactic record_auto_tac)
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)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   397
  apply (tactic record_auto_tac)
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 "
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   427
  apply (tactic record_auto_tac)
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"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   434
  apply (tactic record_auto_tac)
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"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   441
  apply (tactic record_auto_tac)
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"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   448
  apply (tactic record_auto_tac)
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"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   458
  apply (tactic record_auto_tac)
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 "
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   465
  apply (tactic record_auto_tac)
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 "
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   472
  apply (tactic record_auto_tac)
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 "
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   479
  apply (tactic record_auto_tac)
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
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   506
lemma rel_inv_client_map_drop_map: "(rel o inv client_map o drop_map i o inv sysOfClient) =  
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
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   514
lemma ask_inv_client_map_drop_map: "(ask o inv client_map o drop_map i o inv sysOfClient) =  
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
Open_locale "System"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   524
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   525
val Alloc = thm "Alloc";
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   526
val Client = thm "Client";
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   527
val Network = thm "Network";
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   528
val System_def = thm "System_def";
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   529
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   530
CANNOT use bind_thm: it puts the theorem into standard form, in effect
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   531
  exporting it from the locale
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   532
**)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   533
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   534
declare finite_lessThan [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   535
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   536
text{*Client : <unfolded specification> *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   537
lemmas client_spec_simps =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   538
  client_spec_def client_increasing_def client_bounded_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   539
  client_progress_def client_allowed_acts_def client_preserves_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   540
  guarantees_Int_right
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   541
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   542
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   543
val [Client_Increasing_ask, Client_Increasing_rel,
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   544
     Client_Bounded, Client_Progress, Client_AllowedActs, 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   545
     Client_preserves_giv, Client_preserves_dummy] =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   546
        thm "Client" |> simplify (simpset() addsimps (thms "client_spec_simps") )
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   547
               |> list_of_Int;
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   548
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   549
bind_thm ("Client_Increasing_ask", Client_Increasing_ask);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   550
bind_thm ("Client_Increasing_rel", Client_Increasing_rel);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   551
bind_thm ("Client_Bounded", Client_Bounded);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   552
bind_thm ("Client_Progress", Client_Progress);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   553
bind_thm ("Client_AllowedActs", Client_AllowedActs);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   554
bind_thm ("Client_preserves_giv", Client_preserves_giv);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   555
bind_thm ("Client_preserves_dummy", Client_preserves_dummy);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   556
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   557
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   558
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   559
  Client_Increasing_ask [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   560
  Client_Increasing_rel [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   561
  Client_Bounded [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   562
  Client_preserves_giv [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   563
  Client_preserves_dummy [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   564
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   565
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   566
text{*Network : <unfolded specification> *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   567
lemmas network_spec_simps =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   568
  network_spec_def network_ask_def network_giv_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   569
  network_rel_def network_allowed_acts_def network_preserves_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   570
  ball_conj_distrib
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   571
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   572
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   573
val [Network_Ask, Network_Giv, Network_Rel, Network_AllowedActs,
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   574
     Network_preserves_allocGiv, Network_preserves_rel, 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   575
     Network_preserves_ask]  =  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   576
        thm "Network" |> simplify (simpset() addsimps (thms "network_spec_simps"))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   577
                |> list_of_Int;
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   578
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   579
bind_thm ("Network_Ask", Network_Ask);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   580
bind_thm ("Network_Giv", Network_Giv);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   581
bind_thm ("Network_Rel", Network_Rel);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   582
bind_thm ("Network_AllowedActs", Network_AllowedActs);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   583
bind_thm ("Network_preserves_allocGiv", Network_preserves_allocGiv);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   584
bind_thm ("Network_preserves_rel", Network_preserves_rel);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   585
bind_thm ("Network_preserves_ask", Network_preserves_ask);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   586
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   587
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   588
declare Network_preserves_allocGiv [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   589
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   590
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   591
  Network_preserves_rel [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   592
  Network_preserves_ask [simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   593
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   594
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   595
  Network_preserves_rel [simplified o_def, simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   596
  Network_preserves_ask [simplified o_def, simp]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   597
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   598
text{*Alloc : <unfolded specification> *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   599
lemmas alloc_spec_simps =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   600
  alloc_spec_def alloc_increasing_def alloc_safety_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   601
  alloc_progress_def alloc_allowed_acts_def alloc_preserves_def
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   602
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   603
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   604
val [Alloc_Increasing_0, Alloc_Safety, Alloc_Progress, Alloc_AllowedActs,
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   605
     Alloc_preserves_allocRel, Alloc_preserves_allocAsk, 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   606
     Alloc_preserves_dummy] = 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   607
        thm "Alloc" |> simplify (simpset() addsimps (thms "alloc_spec_simps")) 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   608
              |> list_of_Int;
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   609
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   610
bind_thm ("Alloc_Increasing_0", Alloc_Increasing_0);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   611
bind_thm ("Alloc_Safety", Alloc_Safety);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   612
bind_thm ("Alloc_Progress", Alloc_Progress);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   613
bind_thm ("Alloc_AllowedActs", Alloc_AllowedActs);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   614
bind_thm ("Alloc_preserves_allocRel", Alloc_preserves_allocRel);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   615
bind_thm ("Alloc_preserves_allocAsk", Alloc_preserves_allocAsk);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   616
bind_thm ("Alloc_preserves_dummy", Alloc_preserves_dummy);
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   617
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   618
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   619
text{*Strip off the INT in the guarantees postcondition*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   620
ML
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   621
{*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   622
bind_thm ("Alloc_Increasing", normalize Alloc_Increasing_0)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   623
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   624
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   625
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   626
  Alloc_preserves_allocRel [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   627
  Alloc_preserves_allocAsk [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   628
  Alloc_preserves_dummy [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   629
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   630
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   631
subsection{*Components Lemmas [MUST BE AUTOMATED]*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   633
lemma Network_component_System: "Network Join  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   634
      ((rename sysOfClient  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   635
        (plam x: (lessThan Nclients). rename client_map Client)) Join  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   636
       rename sysOfAlloc Alloc)  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   637
      = System"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   638
  by (simp add: System_def Join_ac)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   639
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   640
lemma Client_component_System: "(rename sysOfClient  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   641
       (plam x: (lessThan Nclients). rename client_map Client)) Join  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   642
      (Network Join rename sysOfAlloc Alloc)  =  System"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   643
  by (simp add: System_def Join_ac)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   644
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   645
lemma Alloc_component_System: "rename sysOfAlloc Alloc Join  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   646
       ((rename sysOfClient (plam x: (lessThan Nclients). rename client_map Client)) Join  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   647
        Network)  =  System"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   648
  by (simp add: System_def Join_ac)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   649
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   650
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   651
  Client_component_System [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   652
  Network_component_System [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   653
  Alloc_component_System [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   654
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   655
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   656
text{** These preservation laws should be generated automatically **}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   657
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   658
lemma Client_Allowed [simp]: "Allowed Client = preserves rel Int preserves ask"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   659
  by (auto simp add: Allowed_def Client_AllowedActs safety_prop_Acts_iff)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   660
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   661
lemma Network_Allowed [simp]: "Allowed Network =         
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   662
        preserves allocRel Int  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   663
        (INT i: lessThan Nclients. preserves(giv o sub i o client))"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   664
  by (auto simp add: Allowed_def Network_AllowedActs safety_prop_Acts_iff)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   665
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   666
lemma Alloc_Allowed [simp]: "Allowed Alloc = preserves allocGiv"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   667
  by (auto simp add: Allowed_def Alloc_AllowedActs safety_prop_Acts_iff)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   668
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   669
text{*needed in @{text rename_client_map_tac}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   670
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
   671
  apply (rule OK_lift_I)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   672
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   673
  apply (drule_tac w1 = rel in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   674
  apply (drule_tac [2] w1 = ask in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   675
  apply (auto simp add: o_def split_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   676
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   677
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   678
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
   679
apply (insert fst_o_lift_map [of i])
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   680
apply (drule fun_cong [where x=x])  
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   681
apply (simp add: o_def);
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   682
done
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   683
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   684
lemma fst_o_lift_map' [simp]:
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   685
     "(f \<circ> sub i \<circ> fst \<circ> lift_map i \<circ> g) = f o fst o g"
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   686
apply (subst fst_o_lift_map [symmetric]) 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   687
apply (simp only: o_assoc) 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   688
done
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   689
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   690
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   691
(*The proofs of rename_Client_Increasing, rename_Client_Bounded and
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   692
  rename_Client_Progress are similar.  All require copying out the original
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   693
  Client property.  A forward proof can be constructed as follows:
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   694
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   695
  Client_Increasing_ask RS
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   696
      (bij_client_map RS rename_rename_guarantees_eq RS iffD2)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   697
  RS (lift_lift_guarantees_eq RS iffD2)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   698
  RS guarantees_PLam_I
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   699
  RS (bij_sysOfClient RS rename_rename_guarantees_eq RS iffD2)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   700
  |> simplify (simpset() addsimps [lift_image_eq_rename, o_def, split_def, 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   701
				   surj_rename RS surj_range])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   702
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   703
However, the "preserves" property remains to be discharged, and the unfolding
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   704
of "o" and "sub" complicates subsequent reasoning.
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   705
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   706
The following tactic works for all three proofs, though it certainly looks
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   707
ad-hoc!
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   708
*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   709
ML
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   710
{*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   711
val rename_client_map_tac =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   712
  EVERY [
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   713
    simp_tac (simpset() addsimps [thm "rename_guarantees_eq_rename_inv"]) 1,
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   714
    rtac (thm "guarantees_PLam_I") 1,
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   715
    assume_tac 2,
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   716
	 (*preserves: routine reasoning*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   717
    asm_simp_tac (simpset() addsimps [thm "lift_preserves_sub"]) 2,
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   718
	 (*the guarantee for  "lift i (rename client_map Client)" *)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   719
    asm_simp_tac
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   720
	(simpset() addsimps [thm "lift_guarantees_eq_lift_inv",
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   721
			     thm "rename_guarantees_eq_rename_inv",
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   722
			     thm "bij_imp_bij_inv", thm "surj_rename" RS thm "surj_range",
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   723
			     thm "inv_inv_eq"]) 1,
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   724
    asm_simp_tac
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   725
        (simpset() addsimps [thm "o_def", thm "non_dummy_def", thm "guarantees_Int_right"]) 1]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   726
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   727
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   728
text{*Lifting @{text Client_Increasing} to @{term systemState}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   729
lemma rename_Client_Increasing: "i : I  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   730
      ==> rename sysOfClient (plam x: I. rename client_map Client) :  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   731
            UNIV  guarantees   
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   732
            Increasing (ask o sub i o client) Int  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   733
            Increasing (rel o sub i o client)"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   734
  by (tactic rename_client_map_tac)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   735
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   736
lemma preserves_sub_fst_lift_map: "[| F : preserves w; i ~= j |]  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   737
      ==> F : preserves (sub i o fst o lift_map j o funPair v w)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   738
  apply (auto simp add: lift_map_def split_def linorder_neq_iff o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   739
  apply (drule_tac [!] subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   740
  apply (auto simp add: o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   741
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   742
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   743
lemma client_preserves_giv_oo_client_map: "[| i < Nclients; j < Nclients |]  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   744
      ==> Client : preserves (giv o sub i o fst o lift_map j o client_map)"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   745
  apply (case_tac "i=j") 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   746
  apply (simp, simp add: o_def non_dummy_def)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   747
  apply (drule Client_preserves_dummy [THEN preserves_sub_fst_lift_map])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   748
  apply (drule_tac [!] subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   749
  apply (simp add: o_def client_map_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   750
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   751
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   752
lemma rename_sysOfClient_ok_Network:
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   753
  "rename sysOfClient (plam x: lessThan Nclients. rename client_map Client) 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   754
    ok Network"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   755
  by (auto simp add: ok_iff_Allowed client_preserves_giv_oo_client_map)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   756
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   757
lemma rename_sysOfClient_ok_Alloc:
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   758
  "rename sysOfClient (plam x: lessThan Nclients. rename client_map Client) 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   759
    ok rename sysOfAlloc Alloc"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   760
  by (simp add: ok_iff_Allowed)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   761
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   762
lemma rename_sysOfAlloc_ok_Network: "rename sysOfAlloc Alloc ok Network"
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   763
  by (simp add: ok_iff_Allowed)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   764
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   765
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   766
  rename_sysOfClient_ok_Network [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   767
  rename_sysOfClient_ok_Alloc [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   768
  rename_sysOfAlloc_ok_Network [iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   769
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   770
text{*The "ok" laws, re-oriented. 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   771
  But not sure this works: theorem @{text ok_commute} is needed below*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   772
declare
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   773
  rename_sysOfClient_ok_Network [THEN ok_sym, iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   774
  rename_sysOfClient_ok_Alloc [THEN ok_sym, iff]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   775
  rename_sysOfAlloc_ok_Network [THEN ok_sym]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   776
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   777
lemma System_Increasing: "i < Nclients
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   778
      ==> System : Increasing (ask o sub i o client) Int  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   779
                   Increasing (rel o sub i o client)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   780
  apply (rule component_guaranteesD [OF rename_Client_Increasing Client_component_System])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   781
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   782
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   783
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   784
lemmas rename_guarantees_sysOfAlloc_I =
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   785
  bij_sysOfAlloc [THEN rename_rename_guarantees_eq, THEN iffD2, standard]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   786
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   787
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   788
(*Lifting Alloc_Increasing up to the level of systemState*)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   789
lemmas rename_Alloc_Increasing =
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   790
  Alloc_Increasing
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   791
    [THEN rename_guarantees_sysOfAlloc_I, 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   792
     simplified surj_rename [THEN surj_range] o_def sub_apply 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   793
                rename_image_Increasing bij_sysOfAlloc 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   794
                allocGiv_o_inv_sysOfAlloc_eq'];
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   795
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   796
lemma System_Increasing_allocGiv: 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   797
     "i < Nclients ==> System : Increasing (sub i o allocGiv)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   798
  apply (unfold System_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   799
  apply (simp add: o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   800
  apply (rule rename_Alloc_Increasing [THEN guarantees_Join_I1, THEN guaranteesD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   801
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   802
  done
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   803
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   804
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   805
ML {*
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   806
bind_thms ("System_Increasing'", list_of_Int (thm "System_Increasing"))
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   807
*}
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   808
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   809
declare System_Increasing' [intro!]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   810
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   811
text{* Follows consequences.
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   812
    The "Always (INT ...) formulation expresses the general safety property
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   813
    and allows it to be combined using @{text Always_Int_rule} below. *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   814
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   815
lemma System_Follows_rel: 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   816
  "i < Nclients ==> System : ((sub i o allocRel) Fols (rel o sub i o client))"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   817
  apply (auto intro!: Network_Rel [THEN component_guaranteesD])
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   818
  apply (simp add: ok_commute [of Network]) 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   819
  done
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   820
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   821
lemma System_Follows_ask: 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   822
  "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
   823
  apply (auto intro!: Network_Ask [THEN component_guaranteesD])
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   824
  apply (simp add: ok_commute [of Network]) 
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   825
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   826
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   827
lemma System_Follows_allocGiv: 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   828
  "i < Nclients ==> System : (giv o sub i o client) Fols (sub i o allocGiv)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   829
  apply (auto intro!: Network_Giv [THEN component_guaranteesD]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   830
    rename_Alloc_Increasing [THEN component_guaranteesD])
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   831
  apply (simp_all add: o_def non_dummy_def ok_commute [of Network])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   832
  apply (auto intro!: rename_Alloc_Increasing [THEN component_guaranteesD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   833
  done
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   834
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   835
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   836
lemma Always_giv_le_allocGiv: "System : Always (INT i: lessThan Nclients.  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   837
                       {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
   838
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   839
  apply (erule System_Follows_allocGiv [THEN Follows_Bounded])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   840
  done
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   841
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   842
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   843
lemma Always_allocAsk_le_ask: "System : Always (INT i: lessThan Nclients.  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   844
                       {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
   845
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   846
  apply (erule System_Follows_ask [THEN Follows_Bounded])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   847
  done
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   848
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   849
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   850
lemma Always_allocRel_le_rel: "System : Always (INT i: lessThan Nclients.  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   851
                       {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
   852
  by (auto intro!: Follows_Bounded System_Follows_rel)
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   853
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   854
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   855
subsection{*Proof of the safety property (1)*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   856
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   857
text{*safety (1), step 1 is @{text System_Follows_rel}*}
21632
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 2*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   860
(* i < Nclients ==> System : Increasing (sub i o allocRel) *)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   861
lemmas System_Increasing_allocRel = System_Follows_rel [THEN Follows_Increasing1, standard]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   862
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   863
(*Lifting Alloc_safety up to the level of systemState.
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   864
  Simplifying with o_def gets rid of the translations but it unfortunately
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   865
  gets rid of the other "o"s too.*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   866
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   867
text{*safety (1), step 3*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   868
lemma System_sum_bounded: 
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   869
    "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
   870
            \<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
   871
  apply (simp add: o_apply)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   872
  apply (insert Alloc_Safety [THEN rename_guarantees_sysOfAlloc_I])   
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   873
  apply (simp add: o_def); 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   874
  apply (erule component_guaranteesD) 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   875
  apply (auto simp add: System_Increasing_allocRel [simplified sub_apply o_def])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   876
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   877
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   878
text{* Follows reasoning*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   879
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   880
lemma Always_tokens_giv_le_allocGiv: "System : Always (INT i: lessThan Nclients.  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   881
                          {s. (tokens o giv o sub i o client) s  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   882
                           \<le> (tokens o sub i o allocGiv) s})"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   883
  apply (rule Always_giv_le_allocGiv [THEN Always_weaken])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   884
  apply (auto intro: tokens_mono_prefix simp add: o_apply)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   885
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   886
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   887
lemma Always_tokens_allocRel_le_rel: "System : Always (INT i: lessThan Nclients.  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   888
                          {s. (tokens o sub i o allocRel) s  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   889
                           \<le> (tokens o rel o sub i o client) s})"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   890
  apply (rule Always_allocRel_le_rel [THEN Always_weaken])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   891
  apply (auto intro: tokens_mono_prefix simp add: o_apply)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   892
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   893
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   894
text{*safety (1), step 4 (final result!) *}
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   895
theorem System_safety: "System : system_safety"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   896
  apply (unfold system_safety_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   897
  apply (tactic {* rtac (Always_Int_rule [thm "System_sum_bounded",
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   898
    thm "Always_tokens_giv_le_allocGiv", thm "Always_tokens_allocRel_le_rel"] RS
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   899
    thm "Always_weaken") 1 *})
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   900
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   901
  apply (rule setsum_fun_mono [THEN order_trans])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   902
  apply (drule_tac [2] order_trans)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   903
  apply (rule_tac [2] add_le_mono [OF order_refl setsum_fun_mono])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   904
  prefer 3 apply assumption
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   905
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   906
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   907
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   908
subsection {* Proof of the progress property (2) *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   909
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   910
text{*progress (2), step 1 is @{text System_Follows_ask} and
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   911
      @{text System_Follows_rel}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   912
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   913
text{*progress (2), step 2; see also @{text System_Increasing_allocRel}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   914
(* i < Nclients ==> System : Increasing (sub i o allocAsk) *)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   915
lemmas System_Increasing_allocAsk =  System_Follows_ask [THEN Follows_Increasing1, standard]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   916
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   917
text{*progress (2), step 3: lifting @{text Client_Bounded} to systemState*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   918
lemma rename_Client_Bounded: "i : I  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   919
    ==> rename sysOfClient (plam x: I. rename client_map Client) :  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   920
          UNIV  guarantees   
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   921
          Always {s. ALL elt : set ((ask o sub i o client) s). elt \<le> NbT}"
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   922
  by (tactic rename_client_map_tac)
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   923
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   924
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   925
lemma System_Bounded_ask: "i < Nclients  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   926
      ==> System : Always  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   927
                    {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
   928
  apply (rule component_guaranteesD [OF rename_Client_Bounded Client_component_System])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   929
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   930
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   931
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   932
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
   933
  apply blast
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   934
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   935
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   936
text{*progress (2), step 4*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   937
lemma System_Bounded_allocAsk: "System : Always {s. ALL i<Nclients.  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   938
                          ALL elt : set ((sub i o allocAsk) s). elt \<le> NbT}"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   939
  apply (auto simp add: Collect_all_imp_eq)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   940
  apply (tactic {* rtac (Always_Int_rule [thm "Always_allocAsk_le_ask",
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   941
    thm "System_Bounded_ask"] RS thm "Always_weaken") 1 *})
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   942
  apply (auto dest: set_mono)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   943
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   944
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   945
text{*progress (2), step 5 is @{text System_Increasing_allocGiv}*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   946
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   947
text{*progress (2), step 6*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   948
(* i < Nclients ==> System : Increasing (giv o sub i o client) *)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   949
lemmas System_Increasing_giv =  System_Follows_allocGiv [THEN Follows_Increasing1, standard]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   950
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   951
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   952
lemma rename_Client_Progress: "i: I  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   953
   ==> rename sysOfClient (plam x: I. rename client_map Client)  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   954
        : Increasing (giv o sub i o client)   
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   955
          guarantees  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   956
          (INT h. {s. h \<le> (giv o sub i o client) s &  
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   957
                            h pfixGe (ask o sub i o client) s}   
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   958
                  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
   959
  apply (tactic rename_client_map_tac)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   960
  apply (simp add: Client_Progress [simplified o_def])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   961
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   962
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   963
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   964
text{*progress (2), step 7*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   965
lemma System_Client_Progress: 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   966
  "System : (INT i : (lessThan Nclients).  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   967
            INT h. {s. h \<le> (giv o sub i o client) s &  
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   968
                       h pfixGe (ask o sub i o client) s}   
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   969
                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
   970
  apply (rule INT_I)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   971
(*Couldn't have just used Auto_tac since the "INT h" must be kept*)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   972
  apply (rule component_guaranteesD [OF rename_Client_Progress Client_component_System])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   973
  apply (auto simp add: System_Increasing_giv)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   974
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   975
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   976
(*Concludes
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   977
 System : {s. k \<le> (sub i o allocGiv) s} 
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   978
          LeadsTo
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   979
          {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
   980
          {s. k \<le> (giv o sub i o client) s} *)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   981
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   982
lemmas System_lemma1 =
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   983
  Always_LeadsToD [OF System_Follows_ask [THEN Follows_Bounded]
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   984
                      System_Follows_allocGiv [THEN Follows_LeadsTo]]
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   985
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   986
lemmas System_lemma2 =
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   987
  PSP_Stable [OF System_lemma1
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   988
	      System_Follows_ask [THEN Follows_Increasing1, THEN IncreasingD]]
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   989
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   990
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   991
lemma System_lemma3: "i < Nclients  
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   992
      ==> System : {s. h \<le> (sub i o allocGiv) s &       
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   993
                       h pfixGe (sub i o allocAsk) s}    
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   994
                   LeadsTo   
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   995
                   {s. h \<le> (giv o sub i o client) s &   
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   996
                       h pfixGe (ask o sub i o client) s}"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
   997
  apply (rule single_LeadsTo_I)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   998
  apply (rule_tac k6 = "h" and x2 = " (sub i o allocAsk) s" 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
   999
         in System_lemma2 [THEN LeadsTo_weaken])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1000
  apply auto
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1001
  apply (blast intro: trans_Ge [THEN trans_genPrefix, THEN transD] prefix_imp_pfixGe)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1002
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1003
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1004
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1005
text{*progress (2), step 8: Client i's "release" action is visible system-wide*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1006
lemma System_Alloc_Client_Progress: "i < Nclients   
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1007
      ==> System : {s. h \<le> (sub i o allocGiv) s &  
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1008
                       h pfixGe (sub i o allocAsk) s}   
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1009
                   LeadsTo {s. tokens h \<le> (tokens o sub i o allocRel) s}"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1010
  apply (rule LeadsTo_Trans)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1011
   prefer 2
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1012
   apply (drule System_Follows_rel [THEN
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1013
     mono_tokens [THEN mono_Follows_o, THEN [2] rev_subsetD],
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1014
     THEN Follows_LeadsTo])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1015
   apply (simp add: o_assoc)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1016
  apply (rule LeadsTo_Trans)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1017
   apply (cut_tac [2] System_Client_Progress)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1018
   prefer 2
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1019
   apply (blast intro: LeadsTo_Basis)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1020
  apply (erule System_lemma3)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1021
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1022
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1023
text{*Lifting @{text Alloc_Progress} up to the level of systemState*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1024
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1025
text{*progress (2), step 9*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1026
lemma System_Alloc_Progress: 
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1027
 "System : (INT i : (lessThan Nclients).  
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1028
            INT h. {s. h \<le> (sub i o allocAsk) s}   
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1029
                   LeadsTo {s. h pfixLe (sub i o allocGiv) s})"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1030
  apply (simp only: o_apply sub_def)
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1031
  apply (insert Alloc_Progress [THEN rename_guarantees_sysOfAlloc_I]) 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1032
  apply (simp add: o_def del: Set.INT_iff); 
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1033
  apply (erule component_guaranteesD)
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1034
  apply (auto simp add: 
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1035
    System_Increasing_allocRel [simplified sub_apply o_def]
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1036
    System_Increasing_allocAsk [simplified sub_apply o_def]
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1037
    System_Bounded_allocAsk [simplified sub_apply o_def]
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1038
    System_Alloc_Client_Progress [simplified sub_apply o_def])
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1039
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1040
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1041
text{*progress (2), step 10 (final result!) *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1042
lemma System_Progress: "System : system_progress"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1043
  apply (unfold system_progress_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1044
  apply (cut_tac System_Alloc_Progress)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1045
  apply (blast intro: LeadsTo_Trans
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1046
    System_Follows_allocGiv [THEN Follows_LeadsTo_pfixLe]
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1047
    System_Follows_ask [THEN Follows_LeadsTo])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1048
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1049
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1050
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1051
theorem System_correct: "System : system_spec"
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1052
  apply (unfold system_spec_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1053
  apply (blast intro: System_safety System_Progress)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1054
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1055
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1056
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1057
text{* Some obsolete lemmas *}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1058
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1059
lemma non_dummy_eq_o_funPair: "non_dummy = (% (g,a,r). (| giv = g, ask = a, rel = r |)) o  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1060
                              (funPair giv (funPair ask rel))"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1061
  apply (rule ext)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1062
  apply (auto simp add: o_def non_dummy_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1063
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1064
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1065
lemma preserves_non_dummy_eq: "(preserves non_dummy) =  
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1066
      (preserves rel Int preserves ask Int preserves giv)"
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1067
  apply (simp add: non_dummy_eq_o_funPair)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1068
  apply auto
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1069
    apply (drule_tac w1 = rel in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1070
    apply (drule_tac [2] w1 = ask in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1071
    apply (drule_tac [3] w1 = giv in subset_preserves_o [THEN [2] rev_subsetD])
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1072
    apply (auto simp add: o_def)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1073
  done
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1074
21710
4e4b7c801142 patched up the proofs agsin
paulson
parents: 21669
diff changeset
  1075
text{*Could go to Extend.ML*}
21632
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1076
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
  1077
  apply (rule fst_inv_equalityI)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1078
   apply (rule_tac f = "%z. (f z, ?h z) " in surjI)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1079
   apply (simp add: bij_is_inj inv_f_f)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1080
  apply (simp add: bij_is_surj surj_f_inv_f)
e7c1f1a77d18 converted legacy ML script;
wenzelm
parents: 17310
diff changeset
  1081
  done
11194
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
  1082
ea13ff5a26d1 reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff changeset
  1083
end