src/HOL/UNITY/Alloc.ML
author paulson
Thu, 11 Nov 1999 10:25:17 +0100
changeset 8005 b64d86018785
parent 7965 a00ad4ca6232
child 8041 e3237d8c18d6
permissions -rw-r--r--
new-style infix declaration for "image"
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
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
     7
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
     8
Stop using o (composition)?
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
     9
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
    10
guarantees_PLam_I looks wrong: refers to lift_prog
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    11
*)
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    12
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
    13
(*Eliminating the "o" operator gives associativity for free*)
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
    14
val o_simp = simplify (simpset() addsimps [o_def]);
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    15
7538
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
    16
Goal "(ALL i: lessThan n. f i <= g i) --> sum f n <= sum g n";
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
    17
by (induct_tac "n" 1);
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
    18
by Auto_tac;
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
    19
by (dres_inst_tac [("x","n")] bspec 1);
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
    20
by Auto_tac;
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
    21
by (arith_tac 1);
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
    22
qed_spec_mp "sum_mono";
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
    23
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
    24
Goal "ALL xs. xs <= ys --> tokens xs <= tokens ys";
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
    25
by (induct_tac "ys" 1);
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
    26
by (auto_tac (claset(), simpset() addsimps [prefix_Cons]));
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
    27
qed_spec_mp "tokens_mono_prefix";
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
    28
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
    29
Goalw [mono_def] "mono tokens";
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
    30
by (blast_tac (claset() addIs [tokens_mono_prefix]) 1);
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
    31
qed "mono_tokens";
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    32
6840
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    33
(*Generalized version allowing different clients*)
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    34
Goal "[| Alloc : alloc_spec;  \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    35
\        Client : (lessThan Nclients) funcset client_spec;  \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    36
\        Network : network_spec |] \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    37
\     ==> (extend sysOfAlloc Alloc) \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    38
\         Join (extend sysOfClient (PLam (lessThan Nclients) Client)) \
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    39
\         Join Network : system_spec";
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    40
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    41
Goal "System : system_spec";
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    42
0e5c82abfc71 another non-working snapshot
paulson
parents: 6837
diff changeset
    43
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    44
Goalw [sysOfAlloc_def] "inj sysOfAlloc";
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    45
by (rtac injI 1);
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    46
by (auto_tac (claset() addSWrapper record_split_wrapper, simpset()));
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    47
qed "inj_sysOfAlloc";
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    48
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    49
Goalw [sysOfAlloc_def] "surj sysOfAlloc";
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    50
by (res_inst_tac [("f", "%s. ((| allocGiv = allocGiv s,    \
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    51
\                                allocAsk = allocAsk s,    \
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    52
\                                allocRel = allocRel s |), \
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    53
\                             client s)")] surjI 1);
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    54
by (auto_tac (claset() addSWrapper record_split_wrapper, simpset()));
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    55
qed "surj_sysOfAlloc";
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    56
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    57
AddIffs [inj_sysOfAlloc, surj_sysOfAlloc];
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    58
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    59
Goalw [good_map_def] "good_map sysOfAlloc";
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    60
by Auto_tac;
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    61
qed "good_map_sysOfAlloc";
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
    62
Addsimps [good_map_sysOfAlloc];
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    63
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    64
(*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
    65
Goal "!!s. inv sysOfAlloc s = \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    66
\            ((| allocGiv = allocGiv s,   \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    67
\                allocAsk = allocAsk s,   \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    68
\                allocRel = allocRel s|), \
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    69
\             client s)";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    70
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
    71
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
    72
	      simpset() addsimps [sysOfAlloc_def]));
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    73
qed "inv_sysOfAlloc_eq";
7538
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
    74
Addsimps [inv_sysOfAlloc_eq];
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
    75
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
    76
(**SHOULD NOT BE NECESSARY: The various injections into the system
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
    77
   state need to be treated symmetrically or done automatically*)
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    78
Goalw [sysOfClient_def] "inj sysOfClient";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    79
by (rtac injI 1);
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    80
by (auto_tac (claset() addSDs [inj_sysOfAlloc RS injD]
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
    81
		       addSWrapper record_split_wrapper, 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
    82
	      simpset()));
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    83
qed "inj_sysOfClient";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    84
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    85
Goalw [sysOfClient_def] "surj sysOfClient";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    86
by (cut_facts_tac [surj_sysOfAlloc] 1);
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    87
by (rewtac surj_def);
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    88
by Auto_tac;
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    89
by (Blast_tac 1);
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    90
qed "surj_sysOfClient";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    91
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    92
AddIffs [inj_sysOfClient, surj_sysOfClient];
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    93
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    94
Goalw [good_map_def] "good_map sysOfClient";
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    95
by Auto_tac;
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
    96
qed "good_map_sysOfClient";
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
    97
Addsimps [good_map_sysOfClient];
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
    98
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
    99
(*MUST BE AUTOMATED: even the statement of such results*)
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   100
Goal "!!s. inv sysOfClient s = \
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   101
\            (client s, \
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   102
\             (| allocGiv = allocGiv s, \
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   103
\                allocAsk = allocAsk s, \
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   104
\                allocRel = allocRel s|) )";
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   105
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
   106
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
   107
	      simpset() addsimps [sysOfAlloc_def, sysOfClient_def]));
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   108
qed "inv_sysOfClient_eq";
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   109
Addsimps [inv_sysOfClient_eq];
6837
1bd850260747 another snapshot, still not working
paulson
parents: 6828
diff changeset
   110
1bd850260747 another snapshot, still not working
paulson
parents: 6828
diff changeset
   111
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   112
Open_locale "System";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   113
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   114
val Alloc = thm "Alloc";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   115
val Client = thm "Client";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   116
val Network = thm "Network";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   117
val System_def = thm "System_def";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   118
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   119
AddIffs [finite_lessThan];
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   120
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   121
(*Client : <unfolded specification> *)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   122
val Client_Spec =
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   123
    rewrite_rule [client_spec_def, client_increasing_def,
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   124
		  client_bounded_def, client_progress_def] Client;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   125
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   126
Goal "Client : UNIV guarantees Increasing ask";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   127
by (cut_facts_tac [Client_Spec] 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   128
by (asm_full_simp_tac (simpset() addsimps [guarantees_Int_right]) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   129
qed "Client_Increasing_ask";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   130
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   131
Goal "Client : UNIV guarantees Increasing rel";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   132
by (cut_facts_tac [Client_Spec] 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   133
by (asm_full_simp_tac (simpset() addsimps [guarantees_Int_right]) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   134
qed "Client_Increasing_rel";
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
AddIffs [Client_Increasing_ask, Client_Increasing_rel];
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   137
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   138
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
   139
by (cut_facts_tac [Client_Spec] 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   140
by Auto_tac;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   141
qed "Client_Bounded";
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
(*Client_Progress is cumbersome to state*)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   144
val Client_Progress = Client_Spec RS IntD2;
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   145
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   146
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   147
(*Network : <unfolded specification> *)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   148
val Network_Spec =
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   149
    rewrite_rule [network_spec_def, network_ask_def,
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   150
		  network_giv_def, network_rel_def] Network;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   151
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   152
(*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
   153
  exporting it from the locale*)
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   154
val Network_Ask = Network_Spec RS IntD1 RS IntD1 RS INT_D;
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   155
val Network_Giv = Network_Spec RS IntD1 RS IntD2 RS INT_D;
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   156
val Network_Rel = Network_Spec RS IntD2 RS INT_D;
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
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   159
(*Alloc : <unfolded specification> *)
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   160
val Alloc_Spec =
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   161
    rewrite_rule [alloc_spec_def, alloc_increasing_def,
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   162
		  alloc_safety_def, alloc_progress_def] Alloc;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   163
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   164
Goal "i < Nclients ==> Alloc : UNIV guarantees Increasing (sub i o allocGiv)";
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   165
by (cut_facts_tac [Alloc_Spec] 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   166
by (asm_full_simp_tac (simpset() addsimps [guarantees_INT_right]) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   167
qed "Alloc_Increasing";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   168
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   169
val Alloc_Safety = Alloc_Spec RS IntD1 RS IntD2;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   170
val Alloc_Progress = (Alloc_Spec RS IntD2
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   171
                      |> simplify (simpset() addsimps [guarantees_INT_right]))
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   172
                     RS bspec RS spec;
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   173
		     
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   174
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   175
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   176
(*Not sure what to say about the other components because they involve
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   177
  extend*)
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   178
Goalw [System_def] "Network <= System";
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   179
by (blast_tac (claset() addIs [componentI]) 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   180
qed "Network_component_System";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   181
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   182
Goalw [System_def] "(extend sysOfAlloc Alloc) <= System";
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   183
by (blast_tac (claset() addIs [componentI]) 1);
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   184
qed "Alloc_component_System";
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   185
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   186
AddIffs [Network_component_System, Alloc_component_System];
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   187
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   188
7826
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7689
diff changeset
   189
fun alloc_export th = good_map_sysOfAlloc RS export th |> simplify (simpset());
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   190
7826
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7689
diff changeset
   191
fun client_export th = good_map_sysOfClient RS export th |> simplify (simpset());
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   192
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   193
(*NEED AUTOMATIC PROPAGATION of Alloc_Increasing*)
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   194
Goal "i < Nclients \
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   195
\ ==> extend sysOfAlloc Alloc : UNIV guarantees Increasing (sub i o allocGiv)";
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   196
by (dtac (Alloc_Increasing RS alloc_export extend_guar_Increasing) 1);
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   197
by (auto_tac (claset(), simpset() addsimps [o_def]));
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   198
qed "extend_Alloc_Increasing_allocGiv";
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   199
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   200
Goalw [System_def]
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   201
     "i < Nclients ==> System : Increasing (sub i o allocGiv)";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   202
by (rtac (extend_Alloc_Increasing_allocGiv RS 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   203
	  guarantees_Join_I1 RS guaranteesD) 1);
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   204
by Auto_tac;
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   205
qed "System_Increasing_allocGiv";
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   206
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   207
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   208
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   209
Goalw [System_def]
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   210
     "i < Nclients ==> System : Increasing (ask o sub i o client)";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   211
by (rtac (client_export extend_guar_Increasing RS guarantees_Join_I2 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   212
	  RS guaranteesD) 1);
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   213
by (rtac (lift_prog_guar_Increasing RS guarantees_PLam_I) 1);
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   214
by Auto_tac;
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   215
qed "System_Increasing_ask";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   216
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   217
Goalw [System_def]
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   218
     "i < Nclients ==> System : Increasing (rel o sub i o client)";
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   219
by (rtac (client_export extend_guar_Increasing RS guarantees_Join_I2 
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   220
	  RS guaranteesD) 1);
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   221
by (rtac (lift_prog_guar_Increasing RS guarantees_PLam_I) 1);
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   222
(*gets Client_Increasing_rel from simpset*)
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   223
by Auto_tac;
7347
ad0ce67e4eb6 another snapshot
paulson
parents: 7188
diff changeset
   224
qed "System_Increasing_rel";
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   225
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   226
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   227
(** Follows consequences.
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   228
    The "Always (INT ...) formulation expresses the general safety property
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   229
    and allows it to be combined using Always_Int_rule below. **)
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   230
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   231
Goal "System : Always (INT i: lessThan Nclients. \
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   232
\                      {s. (giv o sub i o client) s <= (sub i o allocGiv) s})";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   233
by (auto_tac (claset(), 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   234
	      simpset() delsimps [o_apply]
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   235
	                addsimps [Always_INT_distrib, Follows_Bounded,
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   236
				  Network_Giv RS component_guaranteesD,
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   237
	     extend_Alloc_Increasing_allocGiv RS component_guaranteesD]));
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   238
qed "Always_giv_le_allocGiv";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   239
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   240
Goal "System : Always (INT i: lessThan Nclients. \
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   241
\                      {s. (sub i o allocAsk) s <= (ask o sub i o client) s})";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   242
by (auto_tac (claset(), 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   243
	      simpset() delsimps [o_apply]
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   244
	      addsimps [Always_INT_distrib, Follows_Bounded,
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   245
	     [Network_Ask, System_Increasing_ask] MRS component_guaranteesD]));
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   246
qed "Always_allocAsk_le_ask";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   247
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   248
Goal "System : Always (INT i: lessThan Nclients. \
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   249
\                      {s. (sub i o allocRel) s <= (rel o sub i o client) s})";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   250
by (auto_tac (claset(), 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   251
	      simpset() delsimps [o_apply]
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   252
	                addsimps [Always_INT_distrib, Follows_Bounded,
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   253
	     [Network_Rel, System_Increasing_rel] MRS component_guaranteesD]));
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   254
qed "Always_allocRel_le_rel";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   255
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   256
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   257
(*** Proof of the safety property (1) ***)
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   258
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   259
(*safety (1), step 1 is System_Increasing_rel*)
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   260
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   261
(*safety (1), step 2*)
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   262
Goal "i < Nclients ==> System : Increasing (sub i o allocRel)";
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   263
by (rtac Follows_Increasing1 1);
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   264
by (blast_tac (claset() addIs [Network_Rel RS component_guaranteesD,
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   265
			       System_Increasing_rel]) 1);
7365
b5bb32e0861c a bit further with property (1)
paulson
parents: 7347
diff changeset
   266
qed "System_Increasing_allocRel";
6828
ea6832d74353 not working but taking shape
paulson
parents: 6815
diff changeset
   267
7826
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7689
diff changeset
   268
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7689
diff changeset
   269
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   270
(*safety (1), step 3*)
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   271
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
   272
\                  <= 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
   273
by (res_inst_tac 
7537
875754b599df working snapshot
paulson
parents: 7482
diff changeset
   274
    [("X", "(INT i : lessThan Nclients. Increasing (sub i o allocRel))")] 
875754b599df working snapshot
paulson
parents: 7482
diff changeset
   275
    component_guaranteesD 1);
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   276
by (rtac Alloc_component_System 3);
7537
875754b599df working snapshot
paulson
parents: 7482
diff changeset
   277
by (force_tac (claset(), simpset() addsimps [System_Increasing_allocRel]) 2);
7538
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
   278
by (rtac (Alloc_Safety RS project_guarantees) 1);
7826
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7689
diff changeset
   279
(*1: Increasing precondition*)
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   280
by (rtac (alloc_export projecting_Increasing RS projecting_weaken RS 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   281
	  projecting_INT) 1);
7537
875754b599df working snapshot
paulson
parents: 7482
diff changeset
   282
by Auto_tac;
7826
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7689
diff changeset
   283
by (asm_full_simp_tac (simpset() addsimps [o_def]) 1);
7538
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
   284
(*2: Always postcondition*)
7826
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7689
diff changeset
   285
by (rtac ((alloc_export extending_Always RS extending_weaken)) 1);
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7689
diff changeset
   286
by Auto_tac;
7538
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
   287
by (asm_full_simp_tac
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
   288
     (simpset() addsimps [alloc_export Collect_eq_extend_set RS sym]) 1);
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
   289
qed "System_sum_bounded";
7537
875754b599df working snapshot
paulson
parents: 7482
diff changeset
   290
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   291
(** Follows reasoning **)
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   292
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   293
Goal "System : Always (INT i: lessThan Nclients. \
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   294
\                         {s. (tokens o giv o sub i o client) s \
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   295
\                          <= (tokens o sub i o allocGiv) s})";
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   296
by (rtac (Always_giv_le_allocGiv RS Always_weaken) 1);
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   297
by (auto_tac (claset() addIs [tokens_mono_prefix], simpset()));
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   298
qed "Always_tokens_giv_le_allocGiv";
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   299
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   300
Goal "System : Always (INT i: lessThan Nclients. \
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   301
\                         {s. (tokens o sub i o allocRel) s \
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   302
\                          <= (tokens o rel o sub i o client) s})";
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   303
by (rtac (Always_allocRel_le_rel RS Always_weaken) 1);
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   304
by (auto_tac (claset() addIs [tokens_mono_prefix], simpset()));
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   305
qed "Always_tokens_allocRel_le_rel";
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   306
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   307
(*safety (1), step 4 (final result!) *)
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   308
Goal "System : Always {s. sum (%i. (tokens o giv o sub i o client)s) Nclients \
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   309
\              <= NbT + sum (%i. (tokens o rel o sub i o client)s) Nclients}";
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   310
by (rtac (Always_Int_rule [System_sum_bounded, Always_tokens_giv_le_allocGiv, 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   311
			   Always_tokens_allocRel_le_rel] RS Always_weaken) 1);
7538
357873391561 new rule PLam_ensures
paulson
parents: 7537
diff changeset
   312
by Auto_tac;
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   313
by (rtac (sum_mono RS order_trans) 1);
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   314
by (dtac order_trans 2);
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   315
by (rtac ([order_refl, sum_mono] MRS add_le_mono) 2);
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   316
by (assume_tac 3);
7482
7badd511844d working snapshot
paulson
parents: 7399
diff changeset
   317
by Auto_tac;
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7538
diff changeset
   318
qed "System_safety";
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7365
diff changeset
   319
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   320
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   321
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   322
(*** Proof of the progress property (2) ***)
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   323
7965
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   324
(** Lemmas about localTo **)
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   325
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   326
Goal "extend sysOfAlloc F : client localTo[C] extend sysOfClient G";
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   327
by (rtac localTo_UNIV_imp_localTo 1);
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   328
by (simp_tac (simpset() addsimps [LOCALTO_def, Diff_def, extend_def, 
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   329
				  stable_def, constrains_def,
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   330
				  image_eq_UN, extend_act_def,
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   331
				  sysOfAlloc_def, sysOfClient_def]) 1);
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   332
by (Force_tac 1);
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   333
qed "sysOfAlloc_in_client_localTo_xl_Client";
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   334
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   335
Goal "extend sysOfClient (plam i:I. F) :  \
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   336
\      (sub i o client) localTo[C] extend sysOfClient (lift_prog i F)";
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   337
by (rtac localTo_UNIV_imp_localTo 1);
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   338
by (rtac (client_export (extend_set_UNIV_eq RS equalityD2 RSN
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   339
			 (2, extend_localTo_extend_I))) 1);
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   340
by (rtac PLam_sub_localTo 1);
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   341
qed "sysOfClient_in_client_localTo_xl_Client";
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   342
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   343
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   344
(*Now there are proofs identical to System_Increasing_rel and
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   345
  System_Increasing_allocRel: tactics needed!*)
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   346
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   347
(*progress (2), step 1 is System_Increasing_ask and System_Increasing_rel*)
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   348
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   349
(*progress (2), step 2; see also System_Increasing_allocRel*)
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   350
Goal "i < Nclients ==> System : Increasing (sub i o allocAsk)";
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   351
by (rtac Follows_Increasing1 1);
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   352
by (blast_tac (claset() addIs [Network_Ask RS component_guaranteesD,
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   353
			       System_Increasing_ask]) 1);
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   354
qed "System_Increasing_allocAsk";
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   355
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   356
val Client_i_Bounded =
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   357
    [Client_Bounded, projecting_UNIV, lift_export extending_Always] 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   358
    MRS drop_prog_guarantees;
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   359
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   360
val UNIV_guar_Always =
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   361
    [asm_rl, projecting_UNIV, extending_Always] 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   362
    MRS project_guarantees;
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   363
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   364
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   365
(*progress (2), step 3*)
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   366
(*All this trouble just to lift "Client_Bounded" through two extend ops*)
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   367
Goalw [System_def]
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   368
     "i < Nclients \
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   369
\   ==> System : Always \
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   370
\                 {s. ALL elt : set ((ask o sub i o client) s). elt <= NbT}";
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   371
by (rtac (guarantees_PLam_I RS client_export UNIV_guar_Always RS
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   372
	  guarantees_Join_I2 RS guaranteesD RS Always_weaken) 1);
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   373
by (rtac Client_i_Bounded 1);
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   374
by (auto_tac(claset(),
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   375
	 simpset() addsimps [lift_export Collect_eq_extend_set RS sym,
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7540
diff changeset
   376
			     client_export Collect_eq_extend_set RS sym]));
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   377
qed "System_Bounded_ask";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   378
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   379
(*progress (2), step 4*)
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   380
Goal "System : Always {s. ALL i : lessThan Nclients. \
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   381
\                          ALL elt : set ((sub i o allocAsk) s). elt <= NbT}";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   382
by (auto_tac (claset(), 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   383
	      simpset() addsimps [Collect_ball_eq, Always_INT_distrib]));
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   384
by (rtac (Always_Int_rule [Always_allocAsk_le_ask, System_Bounded_ask] 
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   385
    RS Always_weaken) 1);
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   386
by (auto_tac(claset() addDs [set_mono], simpset()));
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   387
qed "System_Bounded_allocAsk";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   388
7965
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   389
(*progress (2), step 5 is System_Increasing_allocGiv*)
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   390
7965
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   391
(*progress (2), step 6*)
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   392
Goal "i < Nclients ==> System : Increasing (giv o sub i o client)";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   393
by (rtac Follows_Increasing1 1);
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   394
by (blast_tac (claset() addIs [Network_Giv RS component_guaranteesD,
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   395
			       System_Increasing_allocGiv]) 1);
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   396
qed "System_Increasing_giv";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   397
7965
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   398
(*Lemma (?).  A LOT of work just to lift "Client_Progress" to the array*)
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   399
Goal "lift_prog i Client \
7965
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   400
\  : Increasing (giv o sub i) Int (sub i LocalTo (lift_prog i Client)) \
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   401
\    guarantees \
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   402
\    (INT h. {s. h <=  (giv o sub i) s & \
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   403
\                       h pfixGe (ask o sub i) s}  \
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   404
\            LeadsTo {s. tokens h <= (tokens o rel o sub i) s})";
7878
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7841
diff changeset
   405
by (rtac (Client_Progress RS drop_prog_guarantees) 1);
7965
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   406
by (rtac (lift_export extending_LeadsTo RS extending_weaken RS
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   407
	  extending_INT) 2);
7878
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7841
diff changeset
   408
by (rtac subset_refl 4);
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   409
by (simp_tac (simpset()addsimps [lift_export Collect_eq_extend_set RS sym]) 3);
7965
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   410
by (force_tac (claset(), simpset() addsimps [sub_def, lift_prog_correct]) 2);
7841
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   411
by (rtac (lift_export projecting_Increasing RS projecting_weaken) 1);
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   412
by (auto_tac (claset(), simpset() addsimps [o_def]));
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   413
qed "Client_i_Progress";
65d91d13fc13 working snapshot; more steps in Alloc
paulson
parents: 7826
diff changeset
   414
7965
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   415
(*needed??*)
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   416
Goalw [PLam_def]
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   417
     "(plam x:lessThan Nclients. Client) \
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   418
\  : (INT i : lessThan Nclients. \
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   419
\          Increasing (giv o sub i) Int (sub i LocalTo (lift_prog i Client))) \
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   420
\    guarantees \
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   421
\    (INT i : lessThan Nclients. \
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   422
\         INT h. {s. h <=  (giv o sub i) s & \
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   423
\                       h pfixGe (ask o sub i) s}  \
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   424
\            LeadsTo {s. tokens h <= (tokens o rel o sub i) s})";
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   425
br guarantees_JN_INT 1;
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   426
br Client_i_Progress 1;
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   427
qed "PLam_Client_Progress";
7947
b999c1ab9327 working again; new treatment of LocalTo
paulson
parents: 7915
diff changeset
   428
7965
a00ad4ca6232 expandshort; tidied
paulson
parents: 7947
diff changeset
   429
(*progress (2), step 7*)