5899
|
1 |
(* Title: HOL/UNITY/PPROD.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1998 University of Cambridge
|
|
5 |
*)
|
|
6 |
|
|
7 |
val rinst = read_instantiate_sg (sign_of thy);
|
|
8 |
|
|
9 |
(*** General lemmas ***)
|
|
10 |
|
|
11 |
Goal "x:C ==> (A Times C <= B Times C) = (A <= B)";
|
|
12 |
by (Blast_tac 1);
|
|
13 |
qed "Times_subset_cancel2";
|
|
14 |
|
|
15 |
Goal "x:C ==> (A Times C = B Times C) = (A = B)";
|
|
16 |
by (blast_tac (claset() addEs [equalityE]) 1);
|
|
17 |
qed "Times_eq_cancel2";
|
|
18 |
|
|
19 |
Goal "Union(B) Times A = (UN C:B. C Times A)";
|
|
20 |
by (Blast_tac 1);
|
|
21 |
qed "Times_Union2";
|
|
22 |
|
|
23 |
Goal "Domain (Union S) = (UN A:S. Domain A)";
|
|
24 |
by (Blast_tac 1);
|
|
25 |
qed "Domain_Union";
|
|
26 |
|
|
27 |
(** RTimes: the product of two relations **)
|
|
28 |
|
|
29 |
Goal "(((a,b), (a',b')) : A RTimes B) = ((a,a'):A & (b,b'):B)";
|
|
30 |
by (simp_tac (simpset() addsimps [RTimes_def]) 1);
|
|
31 |
qed "mem_RTimes_iff";
|
|
32 |
AddIffs [mem_RTimes_iff];
|
|
33 |
|
|
34 |
Goalw [RTimes_def] "[| A<=C; B<=D |] ==> A RTimes B <= C RTimes D";
|
|
35 |
by Auto_tac;
|
|
36 |
qed "RTimes_mono";
|
|
37 |
|
|
38 |
Goal "{} RTimes B = {}";
|
|
39 |
by Auto_tac;
|
|
40 |
qed "RTimes_empty1";
|
|
41 |
|
|
42 |
Goal "A RTimes {} = {}";
|
|
43 |
by Auto_tac;
|
|
44 |
qed "RTimes_empty2";
|
|
45 |
|
|
46 |
Goal "Id RTimes Id = Id";
|
|
47 |
by Auto_tac;
|
|
48 |
qed "RTimes_Id";
|
|
49 |
|
|
50 |
Addsimps [RTimes_empty1, RTimes_empty2, RTimes_Id];
|
|
51 |
|
|
52 |
Goal "Domain (r RTimes s) = Domain r Times Domain s";
|
|
53 |
by (auto_tac (claset(), simpset() addsimps [Domain_iff]));
|
|
54 |
qed "Domain_RTimes";
|
|
55 |
|
|
56 |
Goal "Range (r RTimes s) = Range r Times Range s";
|
|
57 |
by (auto_tac (claset(), simpset() addsimps [Range_iff]));
|
|
58 |
qed "Range_RTimes";
|
|
59 |
|
|
60 |
Goal "(r RTimes s) ^^ (A Times B) = r^^A Times s^^B";
|
|
61 |
by (auto_tac (claset(), simpset() addsimps [Image_iff]));
|
|
62 |
qed "Image_RTimes";
|
|
63 |
|
|
64 |
|
|
65 |
Goal "- (UNIV Times A) = UNIV Times (-A)";
|
|
66 |
by Auto_tac;
|
|
67 |
qed "Compl_Times_UNIV1";
|
|
68 |
|
|
69 |
Goal "- (A Times UNIV) = (-A) Times UNIV";
|
|
70 |
by Auto_tac;
|
|
71 |
qed "Compl_Times_UNIV2";
|
|
72 |
|
|
73 |
Addsimps [Compl_Times_UNIV1, Compl_Times_UNIV2];
|
|
74 |
|
|
75 |
|
|
76 |
(**** Lcopy ****)
|
|
77 |
|
|
78 |
(*** Basic properties ***)
|
|
79 |
|
|
80 |
Goal "Init (Lcopy F) = Init F Times UNIV";
|
|
81 |
by (simp_tac (simpset() addsimps [Lcopy_def]) 1);
|
|
82 |
qed "Init_Lcopy";
|
|
83 |
|
|
84 |
Goal "Id : (%act. act RTimes Id) `` Acts F";
|
|
85 |
by (rtac image_eqI 1);
|
|
86 |
by (rtac Id_in_Acts 2);
|
|
87 |
by Auto_tac;
|
|
88 |
val lemma = result();
|
|
89 |
|
|
90 |
Goal "Acts (Lcopy F) = (%act. act RTimes Id) `` Acts F";
|
|
91 |
by (auto_tac (claset() addSIs [lemma],
|
|
92 |
simpset() addsimps [Lcopy_def]));
|
|
93 |
qed "Acts_Lcopy";
|
|
94 |
|
|
95 |
Addsimps [Init_Lcopy];
|
|
96 |
|
|
97 |
Goalw [Lcopy_def, SKIP_def] "Lcopy SKIP = SKIP";
|
|
98 |
by (rtac program_equalityI 1);
|
|
99 |
by Auto_tac;
|
|
100 |
qed "Lcopy_SKIP";
|
|
101 |
|
|
102 |
Addsimps [Lcopy_SKIP];
|
|
103 |
|
|
104 |
|
|
105 |
(*** Safety: constrains, stable ***)
|
|
106 |
|
|
107 |
(** In most cases, C = UNIV. The generalization isn't of obvious value. **)
|
|
108 |
|
|
109 |
Goal "x: C ==> \
|
|
110 |
\ (Lcopy F : constrains (A Times C) (B Times C)) = (F : constrains A B)";
|
|
111 |
by (auto_tac (claset(), simpset() addsimps [constrains_def, Lcopy_def]));
|
|
112 |
by (Blast_tac 1);
|
|
113 |
qed "Lcopy_constrains";
|
|
114 |
|
|
115 |
Goal "Lcopy F : constrains A B ==> F : constrains (Domain A) (Domain B)";
|
|
116 |
by (auto_tac (claset(), simpset() addsimps [constrains_def, Lcopy_def]));
|
|
117 |
by (Blast_tac 1);
|
|
118 |
qed "Lcopy_constrains_Domain";
|
|
119 |
|
|
120 |
Goal "x: C ==> (Lcopy F : stable (A Times C)) = (F : stable A)";
|
|
121 |
by (asm_simp_tac (simpset() addsimps [stable_def, Lcopy_constrains]) 1);
|
|
122 |
qed "Lcopy_stable";
|
|
123 |
|
|
124 |
Goal "(Lcopy F : invariant (A Times UNIV)) = (F : invariant A)";
|
|
125 |
by (asm_simp_tac (simpset() addsimps [Times_subset_cancel2,
|
|
126 |
invariant_def, Lcopy_stable]) 1);
|
|
127 |
qed "Lcopy_invariant";
|
|
128 |
|
|
129 |
(** Substitution Axiom versions: Constrains, Stable **)
|
|
130 |
|
|
131 |
Goal "p : reachable (Lcopy F) ==> fst p : reachable F";
|
|
132 |
by (etac reachable.induct 1);
|
|
133 |
by (auto_tac
|
|
134 |
(claset() addIs reachable.intrs,
|
|
135 |
simpset() addsimps [Acts_Lcopy]));
|
|
136 |
qed "reachable_Lcopy_fst";
|
|
137 |
|
|
138 |
Goal "(a,b) : reachable (Lcopy F) ==> a : reachable F";
|
|
139 |
by (force_tac (claset() addSDs [reachable_Lcopy_fst], simpset()) 1);
|
|
140 |
qed "reachable_LcopyD";
|
|
141 |
|
|
142 |
Goal "reachable (Lcopy F) = reachable F Times UNIV";
|
|
143 |
by (rtac equalityI 1);
|
|
144 |
by (force_tac (claset() addSDs [reachable_LcopyD], simpset()) 1);
|
|
145 |
by (Clarify_tac 1);
|
|
146 |
by (etac reachable.induct 1);
|
|
147 |
by (ALLGOALS (force_tac (claset() addIs reachable.intrs,
|
|
148 |
simpset() addsimps [Acts_Lcopy])));
|
|
149 |
qed "reachable_Lcopy_eq";
|
|
150 |
|
|
151 |
Goal "(Lcopy F : Constrains (A Times UNIV) (B Times UNIV)) = \
|
|
152 |
\ (F : Constrains A B)";
|
|
153 |
by (simp_tac
|
|
154 |
(simpset() addsimps [Constrains_def, reachable_Lcopy_eq,
|
|
155 |
Lcopy_constrains, Sigma_Int_distrib1 RS sym]) 1);
|
|
156 |
qed "Lcopy_Constrains";
|
|
157 |
|
|
158 |
Goal "(Lcopy F : Stable (A Times UNIV)) = (F : Stable A)";
|
|
159 |
by (simp_tac (simpset() addsimps [Stable_def, Lcopy_Constrains]) 1);
|
|
160 |
qed "Lcopy_Stable";
|
|
161 |
|
|
162 |
|
|
163 |
(*** Progress: transient, ensures ***)
|
|
164 |
|
|
165 |
Goal "(Lcopy F : transient (A Times UNIV)) = (F : transient A)";
|
|
166 |
by (auto_tac (claset(),
|
|
167 |
simpset() addsimps [transient_def, Times_subset_cancel2,
|
|
168 |
Domain_RTimes, Image_RTimes, Lcopy_def]));
|
|
169 |
qed "Lcopy_transient";
|
|
170 |
|
|
171 |
Goal "(Lcopy F : ensures (A Times UNIV) (B Times UNIV)) = \
|
|
172 |
\ (F : ensures A B)";
|
|
173 |
by (simp_tac
|
|
174 |
(simpset() addsimps [ensures_def, Lcopy_constrains, Lcopy_transient,
|
|
175 |
Sigma_Un_distrib1 RS sym,
|
|
176 |
Sigma_Diff_distrib1 RS sym]) 1);
|
|
177 |
qed "Lcopy_ensures";
|
|
178 |
|
|
179 |
Goal "F : leadsTo A B ==> Lcopy F : leadsTo (A Times UNIV) (B Times UNIV)";
|
|
180 |
by (etac leadsTo_induct 1);
|
|
181 |
by (asm_simp_tac (simpset() addsimps [leadsTo_UN, Times_Union2]) 3);
|
|
182 |
by (blast_tac (claset() addIs [leadsTo_Trans]) 2);
|
|
183 |
by (asm_simp_tac (simpset() addsimps [leadsTo_Basis, Lcopy_ensures]) 1);
|
|
184 |
qed "leadsTo_imp_Lcopy_leadsTo";
|
|
185 |
|
|
186 |
Goal "Lcopy F : ensures A B ==> F : ensures (Domain A) (Domain B)";
|
|
187 |
by (full_simp_tac
|
|
188 |
(simpset() addsimps [ensures_def, Lcopy_constrains, Lcopy_transient,
|
|
189 |
Domain_Un_eq RS sym,
|
|
190 |
Sigma_Un_distrib1 RS sym,
|
|
191 |
Sigma_Diff_distrib1 RS sym]) 1);
|
|
192 |
by (safe_tac (claset() addSDs [Lcopy_constrains_Domain]));
|
|
193 |
by (etac constrains_weaken_L 1);
|
|
194 |
by (Blast_tac 1);
|
|
195 |
(*NOT able to prove this:
|
|
196 |
Lcopy F : ensures A B ==> F : ensures (Domain A) (Domain B)
|
|
197 |
1. [| Lcopy F : transient (A - B);
|
|
198 |
F : constrains (Domain (A - B)) (Domain (A Un B)) |]
|
|
199 |
==> F : transient (Domain A - Domain B)
|
|
200 |
**)
|
|
201 |
|
|
202 |
|
|
203 |
Goal "Lcopy F : leadsTo AU BU ==> F : leadsTo (Domain AU) (Domain BU)";
|
|
204 |
by (etac leadsTo_induct 1);
|
|
205 |
by (full_simp_tac (simpset() addsimps [Domain_Union]) 3);
|
|
206 |
by (blast_tac (claset() addIs [leadsTo_UN]) 3);
|
|
207 |
by (blast_tac (claset() addIs [leadsTo_Trans]) 2);
|
|
208 |
by (rtac leadsTo_Basis 1);
|
|
209 |
(*...and so CANNOT PROVE THIS*)
|
|
210 |
|
|
211 |
|
|
212 |
(*This also seems impossible to prove??*)
|
|
213 |
Goal "(Lcopy F : leadsTo (A Times UNIV) (B Times UNIV)) = \
|
|
214 |
\ (F : leadsTo A B)";
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
(**** PPROD ****)
|
|
219 |
|
|
220 |
(*** Basic properties ***)
|
|
221 |
|
|
222 |
Goalw [PPROD_def, lift_prog_def]
|
|
223 |
"Init (PPROD I F) = {f. ALL i:I. f i : Init F}";
|
|
224 |
by Auto_tac;
|
|
225 |
qed "Init_PPROD";
|
|
226 |
|
|
227 |
Goalw [lift_act_def] "lift_act i Id = Id";
|
|
228 |
by Auto_tac;
|
|
229 |
qed "lift_act_Id";
|
|
230 |
Addsimps [lift_act_Id];
|
|
231 |
|
|
232 |
Goalw [lift_act_def]
|
|
233 |
"((f,f') : lift_act i act) = (EX s'. f' = f(i := s') & (f i, s') : act)";
|
|
234 |
by (Blast_tac 1);
|
|
235 |
qed "lift_act_eq";
|
|
236 |
AddIffs [lift_act_eq];
|
|
237 |
|
|
238 |
Goal "Acts (PPROD I F) = insert Id (UN i:I. lift_act i `` Acts F)";
|
|
239 |
by (auto_tac (claset(),
|
|
240 |
simpset() addsimps [PPROD_def, lift_prog_def, Acts_JN]));
|
|
241 |
qed "Acts_PPROD";
|
|
242 |
|
|
243 |
Addsimps [Init_PPROD];
|
|
244 |
|
|
245 |
Goal "PPROD I SKIP = SKIP";
|
|
246 |
by (rtac program_equalityI 1);
|
|
247 |
by (auto_tac (claset(),
|
|
248 |
simpset() addsimps [PPROD_def, lift_prog_def,
|
|
249 |
SKIP_def, Acts_JN]));
|
|
250 |
qed "PPROD_SKIP";
|
|
251 |
|
|
252 |
Goal "PPROD {} F = SKIP";
|
|
253 |
by (simp_tac (simpset() addsimps [PPROD_def]) 1);
|
|
254 |
qed "PPROD_empty";
|
|
255 |
|
|
256 |
Addsimps [PPROD_SKIP, PPROD_empty];
|
|
257 |
|
|
258 |
Goalw [PPROD_def] "PPROD (insert i I) F = (lift_prog i F) Join (PPROD I F)";
|
|
259 |
by Auto_tac;
|
|
260 |
qed "PPROD_insert";
|
|
261 |
|
|
262 |
|
|
263 |
(*** Safety: constrains, stable ***)
|
|
264 |
|
|
265 |
val subsetCE' = rinst
|
|
266 |
[("c", "(%u. ?s)(i:=?s')")] subsetCE;
|
|
267 |
|
|
268 |
Goal "i : I ==> \
|
|
269 |
\ (PPROD I F : constrains {f. f i : A} {f. f i : B}) = \
|
|
270 |
\ (F : constrains A B)";
|
|
271 |
by (auto_tac (claset(),
|
|
272 |
simpset() addsimps [constrains_def, lift_prog_def, PPROD_def,
|
|
273 |
Acts_JN]));
|
|
274 |
by (REPEAT (Blast_tac 2));
|
|
275 |
by (force_tac (claset() addSEs [subsetCE', allE, ballE], simpset()) 1);
|
|
276 |
qed "PPROD_constrains";
|
|
277 |
|
|
278 |
Goal "[| PPROD I F : constrains AA BB; i: I |] \
|
|
279 |
\ ==> F : constrains (Applyall AA i) (Applyall BB i)";
|
|
280 |
by (auto_tac (claset(),
|
|
281 |
simpset() addsimps [Applyall_def, constrains_def,
|
|
282 |
lift_prog_def, PPROD_def, Acts_JN]));
|
|
283 |
by (force_tac (claset() addSIs [rinst [("x", "?ff(i := ?u)")] image_eqI]
|
|
284 |
addSEs [rinst [("c", "?ff(i := ?u)")] subsetCE, ballE],
|
|
285 |
simpset()) 1);
|
|
286 |
qed "PPROD_constrains_projection";
|
|
287 |
|
|
288 |
|
|
289 |
Goal "i : I ==> (PPROD I F : stable {f. f i : A}) = (F : stable A)";
|
|
290 |
by (asm_simp_tac (simpset() addsimps [stable_def, PPROD_constrains]) 1);
|
|
291 |
qed "PPROD_stable";
|
|
292 |
|
|
293 |
Goal "i : I ==> (PPROD I F : invariant {f. f i : A}) = (F : invariant A)";
|
|
294 |
by (auto_tac (claset(),
|
|
295 |
simpset() addsimps [invariant_def, PPROD_stable]));
|
|
296 |
qed "PPROD_invariant";
|
|
297 |
|
|
298 |
|
|
299 |
(** Substitution Axiom versions: Constrains, Stable **)
|
|
300 |
|
|
301 |
Goal "[| f : reachable (PPROD I F); i : I |] ==> f i : reachable F";
|
|
302 |
by (etac reachable.induct 1);
|
|
303 |
by (auto_tac
|
|
304 |
(claset() addIs reachable.intrs,
|
|
305 |
simpset() addsimps [Acts_PPROD]));
|
|
306 |
qed "reachable_PPROD";
|
|
307 |
|
|
308 |
Goal "reachable (PPROD I F) <= {f. ALL i:I. f i : reachable F}";
|
|
309 |
by (force_tac (claset() addSDs [reachable_PPROD], simpset()) 1);
|
|
310 |
qed "reachable_PPROD_subset1";
|
|
311 |
|
|
312 |
Goal "[| i ~: I; A : reachable F |] \
|
|
313 |
\ ==> ALL f. f : reachable (PPROD I F) \
|
|
314 |
\ --> f(i:=A) : reachable (lift_prog i F Join PPROD I F)";
|
|
315 |
by (etac reachable.induct 1);
|
|
316 |
by (ALLGOALS Clarify_tac);
|
|
317 |
by (etac reachable.induct 1);
|
|
318 |
(*Init, Init case*)
|
|
319 |
by (force_tac (claset() addIs reachable.intrs,
|
|
320 |
simpset() addsimps [lift_prog_def]) 1);
|
|
321 |
(*Init of F, action of PPROD F case*)
|
|
322 |
br reachable.Acts 1;
|
|
323 |
by (force_tac (claset(), simpset() addsimps [Acts_Join]) 1);
|
|
324 |
ba 1;
|
|
325 |
by (force_tac (claset() addIs [ext], simpset() addsimps [Acts_PPROD]) 1);
|
|
326 |
(*induction over the 2nd "reachable" assumption*)
|
|
327 |
by (eres_inst_tac [("xa","f")] reachable.induct 1);
|
|
328 |
(*Init of PPROD F, action of F case*)
|
|
329 |
by (res_inst_tac [("act","lift_act i act")] reachable.Acts 1);
|
|
330 |
by (force_tac (claset(), simpset() addsimps [lift_prog_def, Acts_Join]) 1);
|
|
331 |
by (force_tac (claset() addIs [reachable.Init], simpset()) 1);
|
|
332 |
by (force_tac (claset() addIs [ext], simpset() addsimps [lift_act_def]) 1);
|
|
333 |
(*last case: an action of PPROD I F*)
|
|
334 |
br reachable.Acts 1;
|
|
335 |
by (force_tac (claset(), simpset() addsimps [Acts_Join]) 1);
|
|
336 |
ba 1;
|
|
337 |
by (force_tac (claset() addIs [ext], simpset() addsimps [Acts_PPROD]) 1);
|
|
338 |
qed_spec_mp "reachable_lift_Join_PPROD";
|
|
339 |
|
|
340 |
|
|
341 |
(*The index set must be finite: otherwise infinitely many copies of F can
|
|
342 |
perform actions, and PPROD can never catch up in finite time.*)
|
|
343 |
Goal "finite I ==> {f. ALL i:I. f i : reachable F} <= reachable (PPROD I F)";
|
|
344 |
by (etac finite_induct 1);
|
|
345 |
by (Simp_tac 1);
|
|
346 |
by (force_tac (claset() addDs [reachable_lift_Join_PPROD],
|
|
347 |
simpset() addsimps [PPROD_insert]) 1);
|
|
348 |
qed "reachable_PPROD_subset2";
|
|
349 |
|
|
350 |
Goal "finite I ==> reachable (PPROD I F) = {f. ALL i:I. f i : reachable F}";
|
|
351 |
by (REPEAT_FIRST (ares_tac [equalityI,
|
|
352 |
reachable_PPROD_subset1,
|
|
353 |
reachable_PPROD_subset2]));
|
|
354 |
qed "reachable_PPROD_eq";
|
|
355 |
|
|
356 |
|
|
357 |
Goal "i: I ==> Applyall {f. (ALL i:I. f i : R) & f i : A} i = R Int A";
|
|
358 |
by (force_tac (claset(), simpset() addsimps [Applyall_def]) 1);
|
|
359 |
qed "Applyall_Int";
|
|
360 |
|
|
361 |
|
|
362 |
Goal "[| i: I; finite I |] \
|
|
363 |
\ ==> (PPROD I F : Constrains {f. f i : A} {f. f i : B}) = \
|
|
364 |
\ (F : Constrains A B)";
|
|
365 |
by (auto_tac
|
|
366 |
(claset(),
|
|
367 |
simpset() addsimps [Constrains_def, Collect_conj_eq RS sym,
|
|
368 |
reachable_PPROD_eq]));
|
|
369 |
bd PPROD_constrains_projection 1;
|
|
370 |
ba 1;
|
|
371 |
by (asm_full_simp_tac (simpset() addsimps [Applyall_Int]) 1);
|
|
372 |
by (auto_tac (claset(),
|
|
373 |
simpset() addsimps [constrains_def, lift_prog_def, PPROD_def,
|
|
374 |
Acts_JN]));
|
|
375 |
by (REPEAT (blast_tac (claset() addIs reachable.intrs) 1));
|
|
376 |
qed "PPROD_Constrains";
|
|
377 |
|
|
378 |
|
|
379 |
Goal "[| i: I; finite I |] \
|
|
380 |
\ ==> (PPROD I F : Stable {f. f i : A}) = (F : Stable A)";
|
|
381 |
by (asm_simp_tac (simpset() addsimps [Stable_def, PPROD_Constrains]) 1);
|
|
382 |
qed "PPROD_Stable";
|
|
383 |
|
|
384 |
|
|
385 |
|