src/HOL/UNITY/Alloc.ML
author paulson
Mon, 06 Sep 1999 10:52:26 +0200
changeset 7482 7badd511844d
parent 7399 cf780c2bcccf
child 7537 875754b599df
permissions -rw-r--r--
working snapshot
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
     1
(*  Title:      HOL/UNITY/Alloc
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
     2
    ID:         $Id$
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
     4
    Copyright   1998  University of Cambridge
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
     5
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
     6
Specification of Chandy and Charpentier's Allocator
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
     7
*)
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
     8
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
     9
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    10
Goal "~ f #2 ==> ~ (!t::nat. (#0 <= t & t <= #10) --> f t)";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    11
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    12
(*Useful examples:  singletonI RS subst_elem,  subst_elem RSN (2,IntI) *)
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    13
Goal "[| b:A;  a=b |] ==> a:A";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    14
by (etac ssubst 1);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    15
by (assume_tac 1);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    16
qed "subst_elem";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    17
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    18
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    19
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    20
6840
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    21
(*Generalized version allowing different clients*)
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    22
Goal "[| Alloc : alloc_spec;  \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    23
\        Client : (lessThan Nclients) funcset client_spec;  \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    24
\        Network : network_spec |] \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    25
\     ==> (extend sysOfAlloc Alloc) \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    26
\         Join (extend sysOfClient (PLam (lessThan Nclients) Client)) \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    27
\         Join Network : system_spec";
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    28
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    29
Goal "System : system_spec";
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    30
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    31
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    32
Goalw [sysOfAlloc_def] "inj sysOfAlloc";
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    33
by (rtac injI 1);
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    34
by (auto_tac (claset() addSWrapper record_split_wrapper, simpset()));
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    35
qed "inj_sysOfAlloc";
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    36
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    37
Goalw [sysOfAlloc_def] "surj sysOfAlloc";
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    38
by (res_inst_tac [("f", "%s. ((| allocGiv = allocGiv s,    \
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    39
\                                allocAsk = allocAsk s,    \
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    40
\                                allocRel = allocRel s |), \
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    41
\                             client s)")] surjI 1);
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    42
by (auto_tac (claset() addSWrapper record_split_wrapper, simpset()));
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    43
qed "surj_sysOfAlloc";
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    44
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    45
AddIffs [inj_sysOfAlloc, surj_sysOfAlloc];
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    46
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    47
Goalw [good_map_def] "good_map sysOfAlloc";
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    48
by Auto_tac;
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    49
qed "good_map_sysOfAlloc";
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    50
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    51
(*MUST BE AUTOMATED: even the statement of such results*)
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    52
Goal "!!s. inv sysOfAlloc s = \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    53
\            ((| allocGiv = allocGiv s,   \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    54
\                allocAsk = allocAsk s,   \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    55
\                allocRel = allocRel s|), \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    56
\             client s)";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    57
by (rtac (inj_sysOfAlloc RS inv_f_eq) 1);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    58
by (auto_tac (claset() addSWrapper record_split_wrapper, 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    59
	      simpset() addsimps [sysOfAlloc_def]));
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    60
qed "inv_sysOfAlloc_eq";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    61
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    62
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
    63
(**SHOULD NOT BE NECESSARY: The various injections into the system
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
    64
   state need to be treated symmetrically or done automatically*)
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    65
Goalw [sysOfClient_def] "inj sysOfClient";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    66
by (rtac injI 1);
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    67
by (auto_tac (claset() addSDs [inj_sysOfAlloc RS injD]
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    68
		       addSWrapper record_split_wrapper, simpset()));
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    69
qed "inj_sysOfClient";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    70
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    71
Goalw [sysOfClient_def] "surj sysOfClient";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    72
by (cut_facts_tac [surj_sysOfAlloc] 1);
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    73
by (rewtac surj_def);
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    74
by Auto_tac;
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    75
by (Blast_tac 1);
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    76
qed "surj_sysOfClient";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    77
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    78
AddIffs [inj_sysOfClient, surj_sysOfClient];
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    79
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    80
Goalw [good_map_def] "good_map sysOfClient";
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    81
by Auto_tac;
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    82
qed "good_map_sysOfClient";
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    83
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    84
(*MUST BE AUTOMATED: even the statement of such results*)
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    85
Goal "!!s. inv sysOfClient s = \
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    86
\            (client s, \
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    87
\             (| allocGiv = allocGiv s, \
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    88
\                allocAsk = allocAsk s, \
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    89
\                allocRel = allocRel s|) )";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    90
by (rtac (inj_sysOfClient RS inv_f_eq) 1);
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    91
by (auto_tac (claset() addSWrapper record_split_wrapper, 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    92
	      simpset() addsimps [sysOfAlloc_def, sysOfClient_def]));
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
    93
qed "inv_sysOfClient_eq";
6837
1bd850260747 another snapshot, still not working
paulson
parents: 6828
diff changeset
    94
1bd850260747 another snapshot, still not working
paulson
parents: 6828
diff changeset
    95
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
    96
Open_locale "System";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
    97
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
    98
val Alloc = thm "Alloc";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
    99
val Client = thm "Client";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   100
val Network = thm "Network";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   101
val System_def = thm "System_def";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   102
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   103
AddIffs [finite_lessThan];
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   104
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   105
(*Client : <unfolded specification> *)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   106
val Client_Spec =
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   107
    rewrite_rule [client_spec_def, client_increasing_def,
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   108
		  client_bounded_def, client_progress_def] Client;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   109
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   110
Goal "Client : UNIV guarantees Increasing ask";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   111
by (cut_facts_tac [Client_Spec] 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   112
by (asm_full_simp_tac (simpset() addsimps [guarantees_Int_right]) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   113
qed "Client_Increasing_ask";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   114
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   115
Goal "Client : UNIV guarantees Increasing rel";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   116
by (cut_facts_tac [Client_Spec] 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   117
by (asm_full_simp_tac (simpset() addsimps [guarantees_Int_right]) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   118
qed "Client_Increasing_rel";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   119
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   120
AddIffs [Client_Increasing_ask, Client_Increasing_rel];
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   121
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   122
Goal "Client : UNIV guarantees Always {s. ALL elt : set (ask s). elt <= NbT}";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   123
by (cut_facts_tac [Client_Spec] 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   124
by Auto_tac;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   125
qed "Client_Bounded";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   126
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   127
(*Client_Progress is cumbersome to state*)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   128
val Client_Progress = Client_Spec RS IntD2;
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   129
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   130
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   131
(*Network : <unfolded specification> *)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   132
val Network_Spec =
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   133
    rewrite_rule [network_spec_def, network_ask_def,
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   134
		  network_giv_def, network_rel_def] Network;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   135
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   136
(*CANNOT use bind_thm: it puts the theorem into standard form, in effect
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   137
  exporting it from the locale*)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   138
val Network_Ask = Network_Spec RS IntD1 RS IntD1;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   139
val Network_Giv = Network_Spec RS IntD1 RS IntD2;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   140
val Network_Rel = Network_Spec RS IntD2 RS INT_D;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   141
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   142
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   143
(*Alloc : <unfolded specification> *)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   144
val Alloc_Spec =
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   145
    rewrite_rule [alloc_spec_def, alloc_increasing_def,
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   146
		  alloc_safety_def, alloc_progress_def] Alloc;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   147
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   148
Goal "i < Nclients ==> Alloc : UNIV guarantees Increasing (sub i o allocAsk)";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   149
by (cut_facts_tac [Alloc_Spec] 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   150
by (asm_full_simp_tac (simpset() addsimps [guarantees_INT_right]) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   151
qed "Alloc_Increasing";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   152
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   153
val Alloc_Safety = Alloc_Spec RS IntD1 RS IntD2;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   154
val Alloc_Progress = (Alloc_Spec RS IntD2
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   155
                      |> simplify (simpset() addsimps [guarantees_INT_right]))
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   156
                     RS bspec RS spec;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   157
		     
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   158
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   159
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   160
(*Not sure what to say about the other components because they involve
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   161
  extend*)
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   162
Goalw [System_def] "Network <= System";
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   163
by (blast_tac (claset() addIs [componentI]) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   164
qed "Network_component_System";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   165
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   166
Goalw [System_def] "(extend sysOfAlloc Alloc) <= System";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   167
by (blast_tac (claset() addIs [componentI]) 1);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   168
qed "Alloc_component_System";
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   169
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   170
AddIffs [Network_component_System, Alloc_component_System];
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   171
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   172
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   173
(* F : UNIV guarantees Increasing func
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   174
   ==> extend sysOfClient F : UNIV guarantees Increasing (func o client) *)
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   175
val extend_Client_guar_Increasing =
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   176
  good_map_sysOfClient RS export extend_guar_Increasing
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   177
  |> simplify (simpset() addsimps [inv_sysOfClient_eq]);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   178
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   179
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   180
(** Proof of property (1) **)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   181
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   182
(*step 1*)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   183
Goalw [System_def]
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   184
     "i < Nclients ==> System : Increasing (rel o sub i o client)";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   185
by (rtac ([guaranteesI RS disjI2 RS guarantees_Join_I, UNIV_I] 
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   186
	  MRS guaranteesD) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   187
by (asm_simp_tac 
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   188
    (simpset() addsimps [guarantees_PLam_I, 
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   189
			 extend_Client_guar_Increasing RS guaranteesD,
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   190
			 lift_prog_guar_Increasing]) 1);
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   191
qed "System_Increasing_rel";
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   192
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   193
(*Note: the first step above performs simple quantifier reasoning.  It could
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   194
  be replaced by a proof mentioning no guarantees primitives*)
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   195
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   196
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   197
(*step 2*)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   198
Goal "i < Nclients ==> System : Increasing (sub i o allocRel)";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   199
by (rtac Follows_Increasing1 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   200
by (blast_tac (claset() addIs [Network_Rel RS component_guaranteesD,
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   201
			       System_Increasing_rel, Network]) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   202
qed "System_Increasing_allocRel";
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   203
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   204
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   205
(*NEED TO PROVE something like this (maybe without premise)*)
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   206
Goal "i < Nclients ==> System : (sub i o allocRel) localTo Network";
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   207
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   208
fun alloc_export th = good_map_sysOfAlloc RS export th;
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   209
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   210
val extend_Alloc_guar_Increasing =
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   211
  alloc_export extend_guar_Increasing
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   212
  |> simplify (simpset() addsimps [inv_sysOfAlloc_eq]);
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   213
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   214
Goal "System : Always {s. sum (%i. (tokens o sub i o allocGiv) s) Nclients \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   215
\                  <= NbT + sum (%i. (tokens o sub i o allocRel) s) Nclients}";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   216
by (res_inst_tac 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   217
    [("X", "(INT i : lessThan Nclients. (sub i o allocRel) localTo Network \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   218
\                                       Int Increasing (sub i o allocRel))")] 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   219
    component_guaranteesD 1);;
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   220
by (rtac Alloc_component_System 3);
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   221
by (rtac project_guarantees 1);
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   222
by (rtac Alloc_Safety 1);
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   223
by (dtac (alloc_export (project_extend_Join RSN (2, subst_elem RS project_Always_D))) 2 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   224
     THEN
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   225
     full_simp_tac
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   226
     (simpset() addsimps [inv_sysOfAlloc_eq,
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   227
			  alloc_export Collect_eq_extend_set RS sym]) 2);
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   228
by Auto_tac;
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   229
by (force_tac (claset(), simpset() addsimps [System_Increasing_allocRel]) 3);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   230
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   231
by (dtac bspec 1);
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   232
by (Blast_tac 1);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   233
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   234
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   235
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   236
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   237
       [| i < Nclients;
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   238
          extend sysOfAlloc Alloc Join G
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   239
          : (sub i o allocRel) localTo Network &
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   240
          extend sysOfAlloc Alloc Join G : Increasing (sub i o allocRel) |]
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   241
       ==> Alloc Join project sysOfAlloc G : Increasing (sub i o allocRel)
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   242
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   243
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   244
       [| i < Nclients;
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   245
          H : (sub i o allocRel) localTo Network &
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   246
          H : Increasing (sub i o allocRel) |]
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   247
       ==> project sysOfAlloc H : Increasing (sub i o allocRel)
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   248
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   249
Open_locale"Extend";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   250
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   251
Goal "(H : (func o f) localTo G) ==> (project h H : func localTo (project h G))";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   252
by (asm_full_simp_tac 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   253
    (simpset() addsimps [localTo_def, 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   254
			 project_extend_Join RS sym,
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   255
			 Diff_project_stable,
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   256
			 Collect_eq_extend_set RS sym]) 1);
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   257
by Auto_tac;
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   258
by (rtac Diff_project_stable 1);
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   259
PROBABLY FALSE;
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   260
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   261
by (Clarify_tac 1);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   262
by (dres_inst_tac [("x","z")] spec 1);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   263
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   264
by (rtac (alloc_export project_Always_D) 2);
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   265
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   266
by (rtac (alloc_export extend_Always RS iffD2) 2);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   267
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   268
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   269
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   270
by (rtac guaranteesI 1);
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   271
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   272
by (res_inst_tac 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   273
    [("X", "(INT i : lessThan Nclients. Increasing (sub i o allocRel))")] 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   274
    component_guaranteesD 1);;
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   275
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   276
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   277
by (rtac (Alloc_Safety RS component_guaranteesD) 1);
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   278
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   279
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   280
by (rtac (alloc_export guarantees_imp_extend_guarantees RS guarantees_weaken) 1);
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   281
by (rtac Alloc_Safety 1);