author | paulson |
Fri, 21 Jul 2000 18:01:36 +0200 | |
changeset 9403 | aad13b59b8d9 |
parent 8948 | b797cfa3548d |
child 10064 | 1a77667b21ef |
permissions | -rw-r--r-- |
5636 | 1 |
(* Title: HOL/UNITY/Client |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1998 University of Cambridge |
|
5 |
||
6 |
Distributed Resource Management System: the Client |
|
7 |
*) |
|
8 |
||
8216 | 9 |
Addsimps [Client_def RS def_prg_Init]; |
10 |
program_defs_ref := [Client_def]; |
|
5636 | 11 |
|
12 |
Addsimps (map simp_of_act [rel_act_def, tok_act_def, ask_act_def]); |
|
13 |
||
14 |
||
8216 | 15 |
(*Safety property 1: ask, rel are increasing*) |
16 |
Goal "Client: UNIV guarantees[funPair rel ask] \ |
|
17 |
\ Increasing ask Int Increasing rel"; |
|
18 |
by (auto_tac |
|
9403
aad13b59b8d9
much tidying in connection with the 2nd UNITY paper
paulson
parents:
8948
diff
changeset
|
19 |
(claset() addSIs [increasing_imp_Increasing], |
aad13b59b8d9
much tidying in connection with the 2nd UNITY paper
paulson
parents:
8948
diff
changeset
|
20 |
simpset() addsimps [guar_def, impOfSubs preserves_subset_increasing])); |
8216 | 21 |
by (auto_tac (claset(), simpset() addsimps [increasing_def])); |
22 |
by (ALLGOALS constrains_tac); |
|
5636 | 23 |
by Auto_tac; |
8216 | 24 |
qed "increasing_ask_rel"; |
25 |
||
5636 | 26 |
|
27 |
Addsimps [nth_append, append_one_prefix]; |
|
28 |
||
29 |
||
8216 | 30 |
(*Safety property 2: the client never requests too many tokens. |
5636 | 31 |
With no Substitution Axiom, we must prove the two invariants |
8216 | 32 |
simultaneously. |
5636 | 33 |
*) |
8216 | 34 |
Goal "G : preserves (funPair ask tok) \ |
35 |
\ ==> Client Join G : \ |
|
36 |
\ Always ({s. tok s <= NbT} Int \ |
|
37 |
\ {s. ALL elt : set (ask s). elt <= NbT})"; |
|
38 |
by (rtac (invariantI RS stable_Join_Always2) 1); |
|
39 |
by (fast_tac (claset() addSEs [impOfSubs preserves_subset_stable] |
|
40 |
addSIs [stable_Int]) 3); |
|
41 |
by (constrains_tac 2); |
|
8251
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents:
8216
diff
changeset
|
42 |
by (cut_inst_tac [("m", "tok s")] (NbT_pos RS mod_less_divisor) 2); |
8216 | 43 |
by Auto_tac; |
44 |
qed "ask_bounded_lemma"; |
|
45 |
||
8251
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents:
8216
diff
changeset
|
46 |
(*export version, with no mention of tok in the postcondition, but |
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents:
8216
diff
changeset
|
47 |
unfortunately tok must be declared local.*) |
8216 | 48 |
Goal "Client: UNIV guarantees[funPair ask tok] \ |
49 |
\ Always {s. ALL elt : set (ask s). elt <= NbT}"; |
|
50 |
by (rtac guaranteesI 1); |
|
51 |
by (etac (ask_bounded_lemma RS Always_weaken) 1); |
|
52 |
by (rtac Int_lower2 1); |
|
5636 | 53 |
qed "ask_bounded"; |
54 |
||
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
55 |
|
8216 | 56 |
(*** Towards proving the liveness property ***) |
57 |
||
58 |
Goal "Client: stable {s. rel s <= giv s}"; |
|
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
59 |
by (constrains_tac 1); |
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
60 |
by Auto_tac; |
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
61 |
qed "stable_rel_le_giv"; |
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
62 |
|
8216 | 63 |
Goal "[| Client Join G : Increasing giv; G : preserves rel |] \ |
64 |
\ ==> Client Join G : Stable {s. rel s <= giv s}"; |
|
65 |
by (rtac (stable_rel_le_giv RS Increasing_preserves_Stable) 1); |
|
66 |
by Auto_tac; |
|
67 |
qed "Join_Stable_rel_le_giv"; |
|
68 |
||
69 |
Goal "[| Client Join G : Increasing giv; G : preserves rel |] \ |
|
70 |
\ ==> Client Join G : Always {s. rel s <= giv s}"; |
|
9403
aad13b59b8d9
much tidying in connection with the 2nd UNITY paper
paulson
parents:
8948
diff
changeset
|
71 |
by (force_tac (claset() addIs [AlwaysI, Join_Stable_rel_le_giv], simpset()) 1); |
8216 | 72 |
qed "Join_Always_rel_le_giv"; |
73 |
||
74 |
Goal "Client : transient {s. rel s = k & k<h & h <= giv s & h pfixGe ask s}"; |
|
75 |
by (res_inst_tac [("act", "rel_act")] transientI 1); |
|
76 |
by (auto_tac (claset(), |
|
77 |
simpset() addsimps [Domain_def, Client_def])); |
|
78 |
by (blast_tac (claset() addIs [less_le_trans, prefix_length_le, |
|
79 |
strict_prefix_length_less]) 1); |
|
80 |
by (auto_tac (claset(), |
|
81 |
simpset() addsimps [prefix_def, genPrefix_iff_nth, Ge_def])); |
|
82 |
by (blast_tac (claset() addIs [strict_prefix_length_less]) 1); |
|
83 |
qed "transient_lemma"; |
|
84 |
||
85 |
||
86 |
Goal "[| Client Join G : Increasing giv; G : preserves (funPair rel ask) |] \ |
|
87 |
\ ==> Client Join G : {s. rel s = k & k<h & h <= giv s & h pfixGe ask s} \ |
|
88 |
\ LeadsTo {s. k < rel s & rel s <= giv s & \ |
|
89 |
\ h <= giv s & h pfixGe ask s}"; |
|
90 |
by (rtac single_LeadsTo_I 1); |
|
91 |
by (ftac (increasing_ask_rel RS guaranteesD) 1); |
|
92 |
by Auto_tac; |
|
93 |
by (rtac (transient_lemma RS Join_transient_I1 RS transient_imp_leadsTo RS |
|
94 |
leadsTo_imp_LeadsTo RS PSP_Stable RS LeadsTo_weaken) 1); |
|
95 |
by (rtac (Stable_Int RS Stable_Int RS Stable_Int) 1); |
|
96 |
by (eres_inst_tac [("f", "giv"), ("x", "giv s")] IncreasingD 1); |
|
97 |
by (eres_inst_tac [("f", "ask"), ("x", "ask s")] IncreasingD 1); |
|
98 |
by (eres_inst_tac [("f", "rel"), ("x", "rel s")] IncreasingD 1); |
|
99 |
by (etac Join_Stable_rel_le_giv 1); |
|
100 |
by (Blast_tac 1); |
|
101 |
by (blast_tac (claset() addIs [sym, order_less_le RS iffD2, |
|
102 |
order_trans, prefix_imp_pfixGe, |
|
103 |
pfixGe_trans]) 2); |
|
104 |
by (blast_tac (claset() addIs [order_less_imp_le, order_trans]) 1); |
|
105 |
qed "induct_lemma"; |
|
106 |
||
107 |
||
108 |
Goal "[| Client Join G : Increasing giv; G : preserves (funPair rel ask) |] \ |
|
109 |
\ ==> Client Join G : {s. rel s < h & h <= giv s & h pfixGe ask s} \ |
|
110 |
\ LeadsTo {s. h <= rel s}"; |
|
111 |
by (res_inst_tac [("f", "%s. size h - size (rel s)")] LessThan_induct 1); |
|
112 |
by (auto_tac (claset(), simpset() addsimps [vimage_def])); |
|
113 |
by (rtac single_LeadsTo_I 1); |
|
114 |
by (rtac (induct_lemma RS LeadsTo_weaken) 1); |
|
115 |
by Auto_tac; |
|
116 |
by (blast_tac (claset() addIs [order_less_le RS iffD2] |
|
117 |
addDs [common_prefix_linear]) 1); |
|
118 |
by (REPEAT (dtac strict_prefix_length_less 1)); |
|
119 |
by (arith_tac 1); |
|
120 |
qed "rel_progress_lemma"; |
|
121 |
||
122 |
||
123 |
Goal "[| Client Join G : Increasing giv; G : preserves (funPair rel ask) |] \ |
|
124 |
\ ==> Client Join G : {s. h <= giv s & h pfixGe ask s} \ |
|
125 |
\ LeadsTo {s. h <= rel s}"; |
|
126 |
by (rtac (Join_Always_rel_le_giv RS Always_LeadsToI) 1); |
|
127 |
by (rtac ([rel_progress_lemma, subset_refl RS subset_imp_LeadsTo] MRS |
|
128 |
LeadsTo_Un RS LeadsTo_weaken_L) 3); |
|
129 |
by Auto_tac; |
|
130 |
by (blast_tac (claset() addIs [order_less_le RS iffD2] |
|
131 |
addDs [common_prefix_linear]) 1); |
|
132 |
qed "client_progress_lemma"; |
|
133 |
||
8251
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents:
8216
diff
changeset
|
134 |
(*Progress property: all tokens that are given will be released*) |
8216 | 135 |
Goal "Client : \ |
136 |
\ Increasing giv guarantees[funPair rel ask] \ |
|
137 |
\ (INT h. {s. h <= giv s & h pfixGe ask s} LeadsTo {s. h <= rel s})"; |
|
138 |
by (rtac guaranteesI 1); |
|
139 |
by (Clarify_tac 1); |
|
140 |
by (blast_tac (claset() addIs [client_progress_lemma]) 1); |
|
141 |
qed "client_progress"; |
|
142 |
||
8311
6218522253e7
new mostly working version; Alloc nearly converted to "Rename"
paulson
parents:
8251
diff
changeset
|
143 |
(*This shows that the Client won't alter other variables in any state |
6218522253e7
new mostly working version; Alloc nearly converted to "Rename"
paulson
parents:
8251
diff
changeset
|
144 |
that it is combined with*) |
9403
aad13b59b8d9
much tidying in connection with the 2nd UNITY paper
paulson
parents:
8948
diff
changeset
|
145 |
Goal "Client : preserves dummy"; |
8251
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents:
8216
diff
changeset
|
146 |
by (rewtac preserves_def); |
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents:
8216
diff
changeset
|
147 |
by Auto_tac; |
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents:
8216
diff
changeset
|
148 |
by (constrains_tac 1); |
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents:
8216
diff
changeset
|
149 |
by Auto_tac; |
9403
aad13b59b8d9
much tidying in connection with the 2nd UNITY paper
paulson
parents:
8948
diff
changeset
|
150 |
qed "client_preserves_dummy"; |
8251
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents:
8216
diff
changeset
|
151 |
|
8216 | 152 |
|
153 |
(** Obsolete lemmas from first version of the Client **) |
|
154 |
||
155 |
Goal "Client: stable {s. size (rel s) <= size (giv s)}"; |
|
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
156 |
by (constrains_tac 1); |
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
157 |
by Auto_tac; |
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
158 |
qed "stable_size_rel_le_giv"; |
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
159 |
|
8216 | 160 |
(*clients return the right number of tokens*) |
161 |
Goal "Client : Increasing giv guarantees[rel] Always {s. rel s <= giv s}"; |
|
5636 | 162 |
by (rtac guaranteesI 1); |
6570 | 163 |
by (rtac AlwaysI 1); |
5648 | 164 |
by (Force_tac 1); |
8055
bb15396278fb
abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents:
8041
diff
changeset
|
165 |
by (blast_tac (claset() addIs [Increasing_preserves_Stable, |
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5758
diff
changeset
|
166 |
stable_rel_le_giv]) 1); |
5636 | 167 |
qed "ok_guar_rel_prefix_giv"; |