10 |
10 |
11 Proofs ported from HOL. |
11 Proofs ported from HOL. |
12 *) |
12 *) |
13 |
13 |
14 Goal "OK(cons(i, I), F) <-> \ |
14 Goal "OK(cons(i, I), F) <-> \ |
15 \ (i:I & OK(I, F)) | (i~:I & OK(I, F) & F(i) ok JOIN(I,F))"; |
15 \ (i \\<in> I & OK(I, F)) | (i\\<notin>I & OK(I, F) & F(i) ok JOIN(I,F))"; |
16 by (asm_full_simp_tac (simpset() addsimps [OK_iff_ok]) 1); |
16 by (asm_full_simp_tac (simpset() addsimps [OK_iff_ok]) 1); |
17 (** Auto_tac proves the goal in one-step, but takes more time **) |
17 (** Auto_tac proves the goal in one-step, but takes more time **) |
18 by Safe_tac; |
18 by Safe_tac; |
19 by (ALLGOALS(Clarify_tac)); |
19 by (ALLGOALS(Clarify_tac)); |
20 by (REPEAT(blast_tac (claset() addIs [ok_sym]) 10)); |
20 by (REPEAT(blast_tac (claset() addIs [ok_sym]) 10)); |
21 by (REPEAT(Blast_tac 1)); |
21 by (REPEAT(Blast_tac 1)); |
22 qed "OK_cons_iff"; |
22 qed "OK_cons_iff"; |
23 |
23 |
24 (*** existential properties ***) |
24 (*** existential properties ***) |
25 |
25 |
26 Goalw [ex_prop_def] "ex_prop(X) ==> X<=program"; |
26 Goalw [ex_prop_def] "ex_prop(X) ==> X\\<subseteq>program"; |
27 by (Asm_simp_tac 1); |
27 by (Asm_simp_tac 1); |
28 qed "ex_imp_subset_program"; |
28 qed "ex_imp_subset_program"; |
29 |
29 |
30 Goalw [ex_prop_def] |
30 Goalw [ex_prop_def] |
31 "GG:Fin(program) ==> (ex_prop(X) \ |
31 "GG \\<in> Fin(program) ==> (ex_prop(X) \ |
32 \ --> GG Int X~=0 --> OK(GG, (%G. G)) -->(JN G:GG. G):X)"; |
32 \ --> GG Int X\\<noteq>0 --> OK(GG, (%G. G)) -->(\\<Squnion>G \\<in> GG. G):X)"; |
33 by (etac Fin_induct 1); |
33 by (etac Fin_induct 1); |
34 by (ALLGOALS(asm_full_simp_tac |
34 by (ALLGOALS(asm_full_simp_tac |
35 (simpset() addsimps [OK_cons_iff]))); |
35 (simpset() addsimps [OK_cons_iff]))); |
36 (* Auto_tac proves the goal in one step *) |
36 (* Auto_tac proves the goal in one step *) |
37 by (safe_tac (claset() addSEs [not_emptyE])); |
37 by (safe_tac (claset() addSEs [not_emptyE])); |
38 by (ALLGOALS(Asm_full_simp_tac)); |
38 by (ALLGOALS(Asm_full_simp_tac)); |
39 by (Fast_tac 1); |
39 by (Fast_tac 1); |
40 qed_spec_mp "ex1"; |
40 qed_spec_mp "ex1"; |
41 |
41 |
42 Goalw [ex_prop_def] |
42 Goalw [ex_prop_def] |
43 "X<=program ==> \ |
43 "X\\<subseteq>program ==> \ |
44 \(ALL GG. GG:Fin(program) & GG Int X ~= 0 --> OK(GG,(%G. G))-->(JN G:GG. G):X)\ |
44 \(\\<forall>GG. GG \\<in> Fin(program) & GG Int X \\<noteq> 0 --> OK(GG,(%G. G))-->(\\<Squnion>G \\<in> GG. G):X)\ |
45 \ --> ex_prop(X)"; |
45 \ --> ex_prop(X)"; |
46 by (Clarify_tac 1); |
46 by (Clarify_tac 1); |
47 by (dres_inst_tac [("x", "{F,G}")] spec 1); |
47 by (dres_inst_tac [("x", "{F,G}")] spec 1); |
48 by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [OK_iff_ok]))); |
48 by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [OK_iff_ok]))); |
49 by Safe_tac; |
49 by Safe_tac; |
50 by (auto_tac (claset() addIs [ok_sym], simpset())); |
50 by (auto_tac (claset() addIs [ok_sym], simpset())); |
51 qed "ex2"; |
51 qed "ex2"; |
52 |
52 |
53 (*Chandy & Sanders take this as a definition*) |
53 (*Chandy & Sanders take this as a definition*) |
54 |
54 |
55 Goal "ex_prop(X) <-> (X<=program & \ |
55 Goal "ex_prop(X) <-> (X\\<subseteq>program & \ |
56 \ (ALL GG. GG:Fin(program) & GG Int X ~= 0& OK(GG,( %G. G))-->(JN G:GG. G):X))"; |
56 \ (\\<forall>GG. GG \\<in> Fin(program) & GG Int X \\<noteq> 0& OK(GG,( %G. G))-->(\\<Squnion>G \\<in> GG. G):X))"; |
57 by Auto_tac; |
57 by Auto_tac; |
58 by (ALLGOALS(blast_tac (claset() addIs [ex1, ex2 RS mp] |
58 by (ALLGOALS(blast_tac (claset() addIs [ex1, ex2 RS mp] |
59 addDs [ex_imp_subset_program]))); |
59 addDs [ex_imp_subset_program]))); |
60 qed "ex_prop_finite"; |
60 qed "ex_prop_finite"; |
61 |
61 |
62 (* Equivalent definition of ex_prop given at the end of section 3*) |
62 (* Equivalent definition of ex_prop given at the end of section 3*) |
63 Goalw [ex_prop_def, component_of_def] |
63 Goalw [ex_prop_def, component_of_def] |
64 "ex_prop(X) <-> \ |
64 "ex_prop(X) <-> \ |
65 \ X<=program & (ALL G:program. (G:X <-> (ALL H:program. (G component_of H) --> H:X)))"; |
65 \ X\\<subseteq>program & (\\<forall>G \\<in> program. (G \\<in> X <-> (\\<forall>H \\<in> program. (G component_of H) --> H \\<in> X)))"; |
66 by Safe_tac; |
66 by Safe_tac; |
67 by (stac Join_commute 4); |
67 by (stac Join_commute 4); |
68 by (dtac ok_sym 4); |
68 by (dtac ok_sym 4); |
69 by (dres_inst_tac [("x", "G")] bspec 4); |
69 by (dres_inst_tac [("x", "G")] bspec 4); |
70 by (dres_inst_tac [("x", "F")] bspec 3); |
70 by (dres_inst_tac [("x", "F")] bspec 3); |
72 by (REPEAT(Force_tac 1)); |
72 by (REPEAT(Force_tac 1)); |
73 qed "ex_prop_equiv"; |
73 qed "ex_prop_equiv"; |
74 |
74 |
75 (*** universal properties ***) |
75 (*** universal properties ***) |
76 |
76 |
77 Goalw [uv_prop_def] "uv_prop(X)==> X<=program"; |
77 Goalw [uv_prop_def] "uv_prop(X)==> X\\<subseteq>program"; |
78 by (Asm_simp_tac 1); |
78 by (Asm_simp_tac 1); |
79 qed "uv_imp_subset_program"; |
79 qed "uv_imp_subset_program"; |
80 |
80 |
81 Goalw [uv_prop_def] |
81 Goalw [uv_prop_def] |
82 "GG:Fin(program) ==> \ |
82 "GG \\<in> Fin(program) ==> \ |
83 \ (uv_prop(X)--> GG <= X & OK(GG, (%G. G)) --> (JN G:GG. G):X)"; |
83 \ (uv_prop(X)--> GG \\<subseteq> X & OK(GG, (%G. G)) --> (\\<Squnion>G \\<in> GG. G):X)"; |
84 by (etac Fin_induct 1); |
84 by (etac Fin_induct 1); |
85 by (auto_tac (claset(), simpset() addsimps |
85 by (auto_tac (claset(), simpset() addsimps |
86 [OK_cons_iff])); |
86 [OK_cons_iff])); |
87 qed_spec_mp "uv1"; |
87 qed_spec_mp "uv1"; |
88 |
88 |
89 Goalw [uv_prop_def] |
89 Goalw [uv_prop_def] |
90 "X<=program ==> (ALL GG. GG:Fin(program) & GG <= X & OK(GG,(%G. G)) \ |
90 "X\\<subseteq>program ==> (\\<forall>GG. GG \\<in> Fin(program) & GG \\<subseteq> X & OK(GG,(%G. G)) \ |
91 \ --> (JN G:GG. G):X) --> uv_prop(X)"; |
91 \ --> (\\<Squnion>G \\<in> GG. G):X) --> uv_prop(X)"; |
92 by Auto_tac; |
92 by Auto_tac; |
93 by (Clarify_tac 2); |
93 by (Clarify_tac 2); |
94 by (dres_inst_tac [("x", "{F,G}")] spec 2); |
94 by (dres_inst_tac [("x", "{F,G}")] spec 2); |
95 by (dres_inst_tac [("x", "0")] spec 1); |
95 by (dres_inst_tac [("x", "0")] spec 1); |
96 by (auto_tac (claset() addDs [ok_sym], |
96 by (auto_tac (claset() addDs [ok_sym], |
97 simpset() addsimps [OK_iff_ok])); |
97 simpset() addsimps [OK_iff_ok])); |
98 qed "uv2"; |
98 qed "uv2"; |
99 |
99 |
100 (*Chandy & Sanders take this as a definition*) |
100 (*Chandy & Sanders take this as a definition*) |
101 Goal |
101 Goal |
102 "uv_prop(X) <-> X<=program & \ |
102 "uv_prop(X) <-> X\\<subseteq>program & \ |
103 \ (ALL GG. GG:Fin(program) & GG <= X & OK(GG, %G. G) --> (JN G:GG. G): X)"; |
103 \ (\\<forall>GG. GG \\<in> Fin(program) & GG \\<subseteq> X & OK(GG, %G. G) --> (\\<Squnion>G \\<in> GG. G): X)"; |
104 by Auto_tac; |
104 by Auto_tac; |
105 by (REPEAT(blast_tac (claset() addIs [uv1,uv2 RS mp] |
105 by (REPEAT(blast_tac (claset() addIs [uv1,uv2 RS mp] |
106 addDs [uv_imp_subset_program]) 1)); |
106 addDs [uv_imp_subset_program]) 1)); |
107 qed "uv_prop_finite"; |
107 qed "uv_prop_finite"; |
108 |
108 |
109 (*** guarantees ***) |
109 (*** guarantees ***) |
110 val major::prems = Goal |
110 val major::prems = Goal |
111 "[| (!!G. [| F ok G; F Join G:X; G:program |] ==> F Join G : Y); F:program |] \ |
111 "[| (!!G. [| F ok G; F Join G \\<in> X; G \\<in> program |] ==> F Join G \\<in> Y); F \\<in> program |] \ |
112 \ ==> F : X guarantees Y"; |
112 \ ==> F \\<in> X guarantees Y"; |
113 by (cut_facts_tac prems 1); |
113 by (cut_facts_tac prems 1); |
114 by (simp_tac (simpset() addsimps [guar_def, component_def]) 1); |
114 by (simp_tac (simpset() addsimps [guar_def, component_def]) 1); |
115 by (blast_tac (claset() addIs [major]) 1); |
115 by (blast_tac (claset() addIs [major]) 1); |
116 qed "guaranteesI"; |
116 qed "guaranteesI"; |
117 |
117 |
118 Goalw [guar_def, component_def] |
118 Goalw [guar_def, component_def] |
119 "[| F : X guarantees Y; F ok G; F Join G:X; G:program |] \ |
119 "[| F \\<in> X guarantees Y; F ok G; F Join G \\<in> X; G \\<in> program |] \ |
120 \ ==> F Join G : Y"; |
120 \ ==> F Join G \\<in> Y"; |
121 by (Asm_full_simp_tac 1); |
121 by (Asm_full_simp_tac 1); |
122 qed "guaranteesD"; |
122 qed "guaranteesD"; |
123 |
123 |
124 (*This version of guaranteesD matches more easily in the conclusion |
124 (*This version of guaranteesD matches more easily in the conclusion |
125 The major premise can no longer be F<=H since we need to reason about G*) |
125 The major premise can no longer be F\\<subseteq>H since we need to reason about G*) |
126 |
126 |
127 Goalw [guar_def] |
127 Goalw [guar_def] |
128 "[| F : X guarantees Y; F Join G = H; H : X; F ok G; G:program |] \ |
128 "[| F \\<in> X guarantees Y; F Join G = H; H \\<in> X; F ok G; G \\<in> program |] \ |
129 \ ==> H : Y"; |
129 \ ==> H \\<in> Y"; |
130 by (Blast_tac 1); |
130 by (Blast_tac 1); |
131 qed "component_guaranteesD"; |
131 qed "component_guaranteesD"; |
132 |
132 |
133 Goalw [guar_def] |
133 Goalw [guar_def] |
134 "[| F: X guarantees X'; Y <= X; X' <= Y' |] ==> F: Y guarantees Y'"; |
134 "[| F \\<in> X guarantees X'; Y \\<subseteq> X; X' \\<subseteq> Y' |] ==> F \\<in> Y guarantees Y'"; |
135 by Auto_tac; |
135 by Auto_tac; |
136 qed "guarantees_weaken"; |
136 qed "guarantees_weaken"; |
137 |
137 |
138 Goalw [guar_def] "X <= Y \ |
138 Goalw [guar_def] "X \\<subseteq> Y \ |
139 \ ==> X guarantees Y = program"; |
139 \ ==> X guarantees Y = program"; |
140 by (Blast_tac 1); |
140 by (Blast_tac 1); |
141 qed "subset_imp_guarantees_program"; |
141 qed "subset_imp_guarantees_program"; |
142 |
142 |
143 (*Equivalent to subset_imp_guarantees_UNIV but more intuitive*) |
143 (*Equivalent to subset_imp_guarantees_UNIV but more intuitive*) |
144 Goalw [guar_def] "[| X <= Y; F:program |] \ |
144 Goalw [guar_def] "[| X \\<subseteq> Y; F \\<in> program |] \ |
145 \ ==> F : X guarantees Y"; |
145 \ ==> F \\<in> X guarantees Y"; |
146 by (Blast_tac 1); |
146 by (Blast_tac 1); |
147 qed "subset_imp_guarantees"; |
147 qed "subset_imp_guarantees"; |
148 |
148 |
149 Goalw [component_of_def] |
149 Goalw [component_of_def] |
150 "F ok G ==> F component_of (F Join G)"; |
150 "F ok G ==> F component_of (F Join G)"; |
202 by Safe_tac; |
202 by Safe_tac; |
203 by (REPEAT(Blast_tac 1)); |
203 by (REPEAT(Blast_tac 1)); |
204 qed "guarantees_Un_left"; |
204 qed "guarantees_Un_left"; |
205 |
205 |
206 Goalw [guar_def] |
206 Goalw [guar_def] |
207 "i:I ==> X guarantees (INT i:I. Y(i)) = (INT i:I. X guarantees Y(i))"; |
207 "i \\<in> I ==> X guarantees (\\<Inter>i \\<in> I. Y(i)) = (\\<Inter>i \\<in> I. X guarantees Y(i))"; |
208 by (rtac equalityI 1); |
208 by (rtac equalityI 1); |
209 by Safe_tac; |
209 by Safe_tac; |
210 by (REPEAT(Blast_tac 1)); |
210 by (REPEAT(Blast_tac 1)); |
211 qed "guarantees_INT_right"; |
211 qed "guarantees_INT_right"; |
212 |
212 |
213 Goalw [guar_def] |
213 Goalw [guar_def] |
214 "Z guarantees (X Int Y) = (Z guarantees X) Int (Z guarantees Y)"; |
214 "Z guarantees (X Int Y) = (Z guarantees X) Int (Z guarantees Y)"; |
215 by (Blast_tac 1); |
215 by (Blast_tac 1); |
216 qed "guarantees_Int_right"; |
216 qed "guarantees_Int_right"; |
217 |
217 |
218 Goal "[| F : Z guarantees X; F : Z guarantees Y |] \ |
218 Goal "[| F \\<in> Z guarantees X; F \\<in> Z guarantees Y |] \ |
219 \ ==> F : Z guarantees (X Int Y)"; |
219 \ ==> F \\<in> Z guarantees (X Int Y)"; |
220 by (asm_simp_tac (simpset() addsimps [guarantees_Int_right]) 1); |
220 by (asm_simp_tac (simpset() addsimps [guarantees_Int_right]) 1); |
221 qed "guarantees_Int_right_I"; |
221 qed "guarantees_Int_right_I"; |
222 |
222 |
223 Goal "i:I==> (F : X guarantees (INT i:I. Y(i))) <-> \ |
223 Goal "i \\<in> I==> (F \\<in> X guarantees (\\<Inter>i \\<in> I. Y(i))) <-> \ |
224 \ (ALL i:I. F : X guarantees Y(i))"; |
224 \ (\\<forall>i \\<in> I. F \\<in> X guarantees Y(i))"; |
225 by (asm_simp_tac (simpset() addsimps [guarantees_INT_right, INT_iff]) 1); |
225 by (asm_simp_tac (simpset() addsimps [guarantees_INT_right, INT_iff]) 1); |
226 by (Blast_tac 1); |
226 by (Blast_tac 1); |
227 qed "guarantees_INT_right_iff"; |
227 qed "guarantees_INT_right_iff"; |
228 |
228 |
229 |
229 |
238 (** The following two can be expressed using intersection and subset, which |
238 (** The following two can be expressed using intersection and subset, which |
239 is more faithful to the text but looks cryptic. |
239 is more faithful to the text but looks cryptic. |
240 **) |
240 **) |
241 |
241 |
242 Goalw [guar_def] |
242 Goalw [guar_def] |
243 "[| F : V guarantees X; F : (X Int Y) guarantees Z |]\ |
243 "[| F \\<in> V guarantees X; F \\<in> (X Int Y) guarantees Z |]\ |
244 \ ==> F : (V Int Y) guarantees Z"; |
244 \ ==> F \\<in> (V Int Y) guarantees Z"; |
245 by (Blast_tac 1); |
245 by (Blast_tac 1); |
246 qed "combining1"; |
246 qed "combining1"; |
247 |
247 |
248 Goalw [guar_def] |
248 Goalw [guar_def] |
249 "[| F : V guarantees (X Un Y); F : Y guarantees Z |]\ |
249 "[| F \\<in> V guarantees (X Un Y); F \\<in> Y guarantees Z |]\ |
250 \ ==> F : V guarantees (X Un Z)"; |
250 \ ==> F \\<in> V guarantees (X Un Z)"; |
251 by (Blast_tac 1); |
251 by (Blast_tac 1); |
252 qed "combining2"; |
252 qed "combining2"; |
253 |
253 |
254 |
254 |
255 (** The following two follow Chandy-Sanders, but the use of object-quantifiers |
255 (** The following two follow Chandy-Sanders, but the use of object-quantifiers |
256 does not suit Isabelle... **) |
256 does not suit Isabelle... **) |
257 |
257 |
258 (*Premise should be (!!i. i: I ==> F: X guarantees Y i) *) |
258 (*Premise should be (!!i. i \\<in> I ==> F \\<in> X guarantees Y i) *) |
259 Goalw [guar_def] |
259 Goalw [guar_def] |
260 "[| ALL i:I. F : X guarantees Y(i); i:I |] \ |
260 "[| \\<forall>i \\<in> I. F \\<in> X guarantees Y(i); i \\<in> I |] \ |
261 \ ==> F : X guarantees (INT i:I. Y(i))"; |
261 \ ==> F \\<in> X guarantees (\\<Inter>i \\<in> I. Y(i))"; |
262 by (Blast_tac 1); |
262 by (Blast_tac 1); |
263 qed "all_guarantees"; |
263 qed "all_guarantees"; |
264 |
264 |
265 (*Premises should be [| F: X guarantees Y i; i: I |] *) |
265 (*Premises should be [| F \\<in> X guarantees Y i; i \\<in> I |] *) |
266 Goalw [guar_def] |
266 Goalw [guar_def] |
267 "EX i:I. F : X guarantees Y(i) ==> F : X guarantees (UN i:I. Y(i))"; |
267 "\\<exists>i \\<in> I. F \\<in> X guarantees Y(i) ==> F \\<in> X guarantees (\\<Union>i \\<in> I. Y(i))"; |
268 by (Blast_tac 1); |
268 by (Blast_tac 1); |
269 qed "ex_guarantees"; |
269 qed "ex_guarantees"; |
270 |
270 |
271 |
271 |
272 (*** Additional guarantees laws, by lcp ***) |
272 (*** Additional guarantees laws, by lcp ***) |
273 |
273 |
274 Goalw [guar_def] |
274 Goalw [guar_def] |
275 "[| F: U guarantees V; G: X guarantees Y; F ok G |] \ |
275 "[| F \\<in> U guarantees V; G \\<in> X guarantees Y; F ok G |] \ |
276 \ ==> F Join G: (U Int X) guarantees (V Int Y)"; |
276 \ ==> F Join G: (U Int X) guarantees (V Int Y)"; |
277 by (Simp_tac 1); |
277 by (Simp_tac 1); |
278 by Safe_tac; |
278 by Safe_tac; |
279 by (asm_full_simp_tac (simpset() addsimps [Join_assoc]) 1); |
279 by (asm_full_simp_tac (simpset() addsimps [Join_assoc]) 1); |
280 by (subgoal_tac "F Join G Join Ga = G Join (F Join Ga)" 1); |
280 by (subgoal_tac "F Join G Join Ga = G Join (F Join Ga)" 1); |
281 by (asm_full_simp_tac (simpset() addsimps [ok_commute]) 1); |
281 by (asm_full_simp_tac (simpset() addsimps [ok_commute]) 1); |
282 by (asm_simp_tac (simpset() addsimps Join_ac) 1); |
282 by (asm_simp_tac (simpset() addsimps Join_ac) 1); |
283 qed "guarantees_Join_Int"; |
283 qed "guarantees_Join_Int"; |
284 |
284 |
285 Goalw [guar_def] |
285 Goalw [guar_def] |
286 "[| F: U guarantees V; G: X guarantees Y; F ok G |] \ |
286 "[| F \\<in> U guarantees V; G \\<in> X guarantees Y; F ok G |] \ |
287 \ ==> F Join G: (U Un X) guarantees (V Un Y)"; |
287 \ ==> F Join G: (U Un X) guarantees (V Un Y)"; |
288 by (Simp_tac 1); |
288 by (Simp_tac 1); |
289 by Safe_tac; |
289 by Safe_tac; |
290 by (asm_full_simp_tac (simpset() addsimps [Join_assoc]) 1); |
290 by (asm_full_simp_tac (simpset() addsimps [Join_assoc]) 1); |
291 by (subgoal_tac "F Join G Join Ga = G Join (F Join Ga)" 1); |
291 by (subgoal_tac "F Join G Join Ga = G Join (F Join Ga)" 1); |
295 by (force_tac (claset(), simpset() addsimps [ok_commute]) 1); |
295 by (force_tac (claset(), simpset() addsimps [ok_commute]) 1); |
296 by (asm_simp_tac (simpset() addsimps Join_ac) 1); |
296 by (asm_simp_tac (simpset() addsimps Join_ac) 1); |
297 qed "guarantees_Join_Un"; |
297 qed "guarantees_Join_Un"; |
298 |
298 |
299 Goalw [guar_def] |
299 Goalw [guar_def] |
300 "[| ALL i:I. F(i) : X(i) guarantees Y(i); OK(I,F); i:I |] \ |
300 "[| \\<forall>i \\<in> I. F(i) \\<in> X(i) guarantees Y(i); OK(I,F); i \\<in> I |] \ |
301 \ ==> (JN i:I. F(i)) : (INT i:I. X(i)) guarantees (INT i:I. Y(i))"; |
301 \ ==> (\\<Squnion>i \\<in> I. F(i)) \\<in> (\\<Inter>i \\<in> I. X(i)) guarantees (\\<Inter>i \\<in> I. Y(i))"; |
302 by Safe_tac; |
302 by Safe_tac; |
303 by (Blast_tac 2); |
303 by (Blast_tac 2); |
304 by (dres_inst_tac [("x", "xa")] bspec 1); |
304 by (dres_inst_tac [("x", "xa")] bspec 1); |
305 by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [INT_iff]))); |
305 by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [INT_iff]))); |
306 by Safe_tac; |
306 by Safe_tac; |
307 by (rotate_tac ~1 1); |
307 by (rotate_tac ~1 1); |
308 by (dres_inst_tac [("x", "(JN x:(I-{xa}). F(x)) Join G")] bspec 1); |
308 by (dres_inst_tac [("x", "(\\<Squnion>x \\<in> (I-{xa}). F(x)) Join G")] bspec 1); |
309 by (auto_tac |
309 by (auto_tac |
310 (claset() addIs [OK_imp_ok], |
310 (claset() addIs [OK_imp_ok], |
311 simpset() addsimps [Join_assoc RS sym, JN_Join_diff, JN_absorb])); |
311 simpset() addsimps [Join_assoc RS sym, JN_Join_diff, JN_absorb])); |
312 qed "guarantees_JN_INT"; |
312 qed "guarantees_JN_INT"; |
313 |
313 |
314 Goalw [guar_def] |
314 Goalw [guar_def] |
315 "[| ALL i:I. F(i) : X(i) guarantees Y(i); OK(I,F) |] \ |
315 "[| \\<forall>i \\<in> I. F(i) \\<in> X(i) guarantees Y(i); OK(I,F) |] \ |
316 \ ==> JOIN(I,F) : (UN i:I. X(i)) guarantees (UN i:I. Y(i))"; |
316 \ ==> JOIN(I,F) \\<in> (\\<Union>i \\<in> I. X(i)) guarantees (\\<Union>i \\<in> I. Y(i))"; |
317 by Auto_tac; |
317 by Auto_tac; |
318 by (dres_inst_tac [("x", "y")] bspec 1); |
318 by (dres_inst_tac [("x", "y")] bspec 1); |
319 by (ALLGOALS(Asm_full_simp_tac)); |
319 by (ALLGOALS(Asm_full_simp_tac)); |
320 by Safe_tac; |
320 by Safe_tac; |
321 by (rotate_tac ~1 1); |
321 by (rotate_tac ~1 1); |
327 qed "guarantees_JN_UN"; |
327 qed "guarantees_JN_UN"; |
328 |
328 |
329 (*** guarantees laws for breaking down the program, by lcp ***) |
329 (*** guarantees laws for breaking down the program, by lcp ***) |
330 |
330 |
331 Goalw [guar_def] |
331 Goalw [guar_def] |
332 "[| F: X guarantees Y; F ok G |] ==> F Join G: X guarantees Y"; |
332 "[| F \\<in> X guarantees Y; F ok G |] ==> F Join G \\<in> X guarantees Y"; |
333 by (Simp_tac 1); |
333 by (Simp_tac 1); |
334 by Safe_tac; |
334 by Safe_tac; |
335 by (asm_full_simp_tac (simpset() addsimps [Join_assoc]) 1); |
335 by (asm_full_simp_tac (simpset() addsimps [Join_assoc]) 1); |
336 qed "guarantees_Join_I1"; |
336 qed "guarantees_Join_I1"; |
337 |
337 |
338 Goal "[| G: X guarantees Y; F ok G |] ==> F Join G: X guarantees Y"; |
338 Goal "[| G \\<in> X guarantees Y; F ok G |] ==> F Join G \\<in> X guarantees Y"; |
339 by (asm_full_simp_tac (simpset() addsimps [inst "G" "G" Join_commute, |
339 by (asm_full_simp_tac (simpset() addsimps [inst "G" "G" Join_commute, |
340 inst "G" "G" ok_commute]) 1); |
340 inst "G" "G" ok_commute]) 1); |
341 by (blast_tac (claset() addIs [guarantees_Join_I1]) 1); |
341 by (blast_tac (claset() addIs [guarantees_Join_I1]) 1); |
342 qed "guarantees_Join_I2"; |
342 qed "guarantees_Join_I2"; |
343 |
343 |
344 Goalw [guar_def] |
344 Goalw [guar_def] |
345 "[| i:I; F(i): X guarantees Y; OK(I,F) |] \ |
345 "[| i \\<in> I; F(i): X guarantees Y; OK(I,F) |] \ |
346 \ ==> (JN i:I. F(i)) : X guarantees Y"; |
346 \ ==> (\\<Squnion>i \\<in> I. F(i)) \\<in> X guarantees Y"; |
347 by Safe_tac; |
347 by Safe_tac; |
348 by (dres_inst_tac [("x", "JOIN(I-{i},F) Join G")] bspec 1); |
348 by (dres_inst_tac [("x", "JOIN(I-{i},F) Join G")] bspec 1); |
349 by (Simp_tac 1); |
349 by (Simp_tac 1); |
350 by (auto_tac (claset() addIs [OK_imp_ok], |
350 by (auto_tac (claset() addIs [OK_imp_ok], |
351 simpset() addsimps [JN_Join_diff, Join_assoc RS sym])); |
351 simpset() addsimps [JN_Join_diff, Join_assoc RS sym])); |
352 qed "guarantees_JN_I"; |
352 qed "guarantees_JN_I"; |
353 |
353 |
354 (*** well-definedness ***) |
354 (*** well-definedness ***) |
355 |
355 |
356 Goalw [welldef_def] "F Join G: welldef ==> programify(F): welldef"; |
356 Goalw [welldef_def] "F Join G \\<in> welldef ==> programify(F): welldef"; |
357 by Auto_tac; |
357 by Auto_tac; |
358 qed "Join_welldef_D1"; |
358 qed "Join_welldef_D1"; |
359 |
359 |
360 Goalw [welldef_def] "F Join G: welldef ==> programify(G): welldef"; |
360 Goalw [welldef_def] "F Join G \\<in> welldef ==> programify(G): welldef"; |
361 by Auto_tac; |
361 by Auto_tac; |
362 qed "Join_welldef_D2"; |
362 qed "Join_welldef_D2"; |
363 |
363 |
364 (*** refinement ***) |
364 (*** refinement ***) |
365 |
365 |
367 by (Blast_tac 1); |
367 by (Blast_tac 1); |
368 qed "refines_refl"; |
368 qed "refines_refl"; |
369 |
369 |
370 (* More results on guarantees, added by Sidi Ehmety from Chandy & Sander, section 6 *) |
370 (* More results on guarantees, added by Sidi Ehmety from Chandy & Sander, section 6 *) |
371 |
371 |
372 Goalw [wg_def] "wg(F, X) <= program"; |
372 Goalw [wg_def] "wg(F, X) \\<subseteq> program"; |
373 by Auto_tac; |
373 by Auto_tac; |
374 qed "wg_type"; |
374 qed "wg_type"; |
375 |
375 |
376 Goalw [guar_def] "X guarantees Y <= program"; |
376 Goalw [guar_def] "X guarantees Y \\<subseteq> program"; |
377 by Auto_tac; |
377 by Auto_tac; |
378 qed "guarantees_type"; |
378 qed "guarantees_type"; |
379 |
379 |
380 Goalw [wg_def] "G:wg(F, X) ==> G:program & F:program"; |
380 Goalw [wg_def] "G \\<in> wg(F, X) ==> G \\<in> program & F \\<in> program"; |
381 by Auto_tac; |
381 by Auto_tac; |
382 by (blast_tac (claset() addDs [guarantees_type RS subsetD]) 1); |
382 by (blast_tac (claset() addDs [guarantees_type RS subsetD]) 1); |
383 qed "wgD2"; |
383 qed "wgD2"; |
384 |
384 |
385 Goalw [guar_def, component_of_def] |
385 Goalw [guar_def, component_of_def] |
386 "(F:X guarantees Y) <-> \ |
386 "(F \\<in> X guarantees Y) <-> \ |
387 \ F:program & (ALL H:program. H:X --> (F component_of H --> H:Y))"; |
387 \ F \\<in> program & (\\<forall>H \\<in> program. H \\<in> X --> (F component_of H --> H \\<in> Y))"; |
388 by Safe_tac; |
388 by Safe_tac; |
389 by (REPEAT(Force_tac 1)); |
389 by (REPEAT(Force_tac 1)); |
390 qed "guarantees_equiv"; |
390 qed "guarantees_equiv"; |
391 |
391 |
392 Goalw [wg_def] "!!X. [| F:(X guarantees Y); X <= program |] ==> X <= wg(F,Y)"; |
392 Goalw [wg_def] "!!X. [| F \\<in> (X guarantees Y); X \\<subseteq> program |] ==> X \\<subseteq> wg(F,Y)"; |
393 by Auto_tac; |
393 by Auto_tac; |
394 qed "wg_weakest"; |
394 qed "wg_weakest"; |
395 |
395 |
396 Goalw [wg_def, guar_def] |
396 Goalw [wg_def, guar_def] |
397 "F:program ==> F:wg(F,Y) guarantees Y"; |
397 "F \\<in> program ==> F \\<in> wg(F,Y) guarantees Y"; |
398 by (Blast_tac 1); |
398 by (Blast_tac 1); |
399 qed "wg_guarantees"; |
399 qed "wg_guarantees"; |
400 |
400 |
401 Goalw [wg_def] "(H: wg(F,X)) <-> ((F component_of H --> H:X) & F:program & H:program)"; |
401 Goalw [wg_def] "(H \\<in> wg(F,X)) <-> ((F component_of H --> H \\<in> X) & F \\<in> program & H \\<in> program)"; |
402 by (simp_tac (simpset() addsimps [guarantees_equiv]) 1); |
402 by (simp_tac (simpset() addsimps [guarantees_equiv]) 1); |
403 by (rtac iffI 1); |
403 by (rtac iffI 1); |
404 by Safe_tac; |
404 by Safe_tac; |
405 by (res_inst_tac [("x", "{H}")] bexI 4); |
405 by (res_inst_tac [("x", "{H}")] bexI 4); |
406 by (res_inst_tac [("x", "{H}")] bexI 3); |
406 by (res_inst_tac [("x", "{H}")] bexI 3); |
407 by (REPEAT(Blast_tac 1)); |
407 by (REPEAT(Blast_tac 1)); |
408 qed "wg_equiv"; |
408 qed "wg_equiv"; |
409 |
409 |
410 Goal |
410 Goal |
411 "F component_of H ==> H:wg(F,X) <-> (H:X & F:program & H:program)"; |
411 "F component_of H ==> H \\<in> wg(F,X) <-> (H \\<in> X & F \\<in> program & H \\<in> program)"; |
412 by (asm_simp_tac (simpset() addsimps [wg_equiv]) 1); |
412 by (asm_simp_tac (simpset() addsimps [wg_equiv]) 1); |
413 qed "component_of_wg"; |
413 qed "component_of_wg"; |
414 |
414 |
415 Goal |
415 Goal |
416 "ALL FF:Fin(program). FF Int X ~= 0 --> OK(FF, %F. F) \ |
416 "\\<forall>FF \\<in> Fin(program). FF Int X \\<noteq> 0 --> OK(FF, %F. F) \ |
417 \ --> (ALL F:FF. ((JN F:FF. F): wg(F,X)) <-> ((JN F:FF. F):X))"; |
417 \ --> (\\<forall>F \\<in> FF. ((\\<Squnion>F \\<in> FF. F): wg(F,X)) <-> ((\\<Squnion>F \\<in> FF. F):X))"; |
418 by (Clarify_tac 1); |
418 by (Clarify_tac 1); |
419 by (subgoal_tac "F component_of (JN F:FF. F)" 1); |
419 by (subgoal_tac "F component_of (\\<Squnion>F \\<in> FF. F)" 1); |
420 by (dres_inst_tac [("X", "X")] component_of_wg 1); |
420 by (dres_inst_tac [("X", "X")] component_of_wg 1); |
421 by (force_tac (claset() addSDs [thm"Fin.dom_subset" RS subsetD RS PowD], |
421 by (force_tac (claset() addSDs [thm"Fin.dom_subset" RS subsetD RS PowD], |
422 simpset()) 1); |
422 simpset()) 1); |
423 by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [component_of_def]))); |
423 by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [component_of_def]))); |
424 by (res_inst_tac [("x", "JN F:(FF-{F}). F")] exI 1); |
424 by (res_inst_tac [("x", "\\<Squnion>F \\<in> (FF-{F}). F")] exI 1); |
425 by (auto_tac (claset() addIs [JN_Join_diff] addDs [ok_sym], |
425 by (auto_tac (claset() addIs [JN_Join_diff] addDs [ok_sym], |
426 simpset() addsimps [OK_iff_ok])); |
426 simpset() addsimps [OK_iff_ok])); |
427 qed "wg_finite"; |
427 qed "wg_finite"; |
428 |
428 |
429 |
429 |
430 (* "!!FF. [| FF:Fin(program); FF Int X ~=0; OK(FF, %F. F); G:FF |] |
430 (* "!!FF. [| FF \\<in> Fin(program); FF Int X \\<noteq>0; OK(FF, %F. F); G \\<in> FF |] |
431 ==> JOIN(FF, %F. F):wg(G, X) <-> JOIN(FF, %F. F):X" *) |
431 ==> JOIN(FF, %F. F):wg(G, X) <-> JOIN(FF, %F. F):X" *) |
432 val wg_finite2 = wg_finite RS bspec RS mp RS mp RS bspec; |
432 val wg_finite2 = wg_finite RS bspec RS mp RS mp RS bspec; |
433 |
433 |
434 Goal "ex_prop(X) ==> (F:X) <-> (ALL H:program. H : wg(F,X) & F:program)"; |
434 Goal "ex_prop(X) ==> (F \\<in> X) <-> (\\<forall>H \\<in> program. H \\<in> wg(F,X) & F \\<in> program)"; |
435 by (full_simp_tac (simpset() addsimps [ex_prop_equiv, wg_equiv]) 1); |
435 by (full_simp_tac (simpset() addsimps [ex_prop_equiv, wg_equiv]) 1); |
436 by (Blast_tac 1); |
436 by (Blast_tac 1); |
437 qed "wg_ex_prop"; |
437 qed "wg_ex_prop"; |
438 |
438 |
439 (** From Charpentier and Chandy "Theorems About Composition" **) |
439 (** From Charpentier and Chandy "Theorems About Composition" **) |
440 (* Proposition 2 *) |
440 (* Proposition 2 *) |
441 Goalw [wx_def] "wx(X)<=X"; |
441 Goalw [wx_def] "wx(X)\\<subseteq>X"; |
442 by Auto_tac; |
442 by Auto_tac; |
443 qed "wx_subset"; |
443 qed "wx_subset"; |
444 |
444 |
445 Goal "ex_prop(wx(X))"; |
445 Goal "ex_prop(wx(X))"; |
446 by (full_simp_tac (simpset() addsimps [ex_prop_def, wx_def]) 1); |
446 by (full_simp_tac (simpset() addsimps [ex_prop_def, wx_def]) 1); |
514 *) |
514 *) |
515 |
515 |
516 (* Rules given in section 7 of Chandy and Sander's |
516 (* Rules given in section 7 of Chandy and Sander's |
517 Reasoning About Program composition paper *) |
517 Reasoning About Program composition paper *) |
518 |
518 |
519 Goal "[| Init(F) <= A; F:program |] ==> F:(stable(A)) guarantees (Always(A))"; |
519 Goal "[| Init(F) \\<subseteq> A; F \\<in> program |] ==> F \\<in> stable(A) guarantees Always(A)"; |
520 by (rtac guaranteesI 1); |
520 by (rtac guaranteesI 1); |
521 by (assume_tac 2); |
521 by (assume_tac 2); |
522 by (simp_tac (simpset() addsimps [Join_commute]) 1); |
522 by (simp_tac (simpset() addsimps [Join_commute]) 1); |
523 by (rtac stable_Join_Always1 1); |
523 by (rtac stable_Join_Always1 1); |
524 by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [invariant_def]))); |
524 by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [invariant_def]))); |
525 by (auto_tac (claset(), simpset() addsimps [programify_def, initially_def])); |
525 by (auto_tac (claset(), simpset() addsimps [programify_def, initially_def])); |
526 qed "stable_guarantees_Always"; |
526 qed "stable_guarantees_Always"; |
527 |
527 |
528 (* To be moved to WFair.ML *) |
528 (* To be moved to WFair.ML *) |
529 Goal "[| F:A co A Un B; F:transient(A); st_set(B) |] ==> F:A leadsTo B"; |
529 Goal "[| F \\<in> A co A Un B; F \\<in> transient(A); st_set(B) |] ==> F \\<in> A leadsTo B"; |
530 by (ftac constrainsD2 1); |
530 by (ftac constrainsD2 1); |
531 by (dres_inst_tac [("B", "A-B")] constrains_weaken_L 1); |
531 by (dres_inst_tac [("B", "A-B")] constrains_weaken_L 1); |
532 by (dres_inst_tac [("B", "A-B")] transient_strengthen 2); |
532 by (dres_inst_tac [("B", "A-B")] transient_strengthen 2); |
533 by (rtac (ensuresI RS leadsTo_Basis) 3); |
533 by (rtac (ensuresI RS leadsTo_Basis) 3); |
534 by (ALLGOALS(Blast_tac)); |
534 by (ALLGOALS(Blast_tac)); |
535 qed "leadsTo_Basis'"; |
535 qed "leadsTo_Basis'"; |
536 |
536 |
537 Goal "[| F:transient(A); st_set(B) |] ==> F: (A co A Un B) guarantees (A leadsTo (B-A))"; |
537 Goal "[| F \\<in> transient(A); st_set(B) |] ==> F: (A co A Un B) guarantees (A leadsTo (B-A))"; |
538 by (rtac guaranteesI 1); |
538 by (rtac guaranteesI 1); |
539 by (blast_tac (claset() addDs [transient_type RS subsetD]) 2); |
539 by (blast_tac (claset() addDs [transient_type RS subsetD]) 2); |
540 by (rtac leadsTo_Basis' 1); |
540 by (rtac leadsTo_Basis' 1); |
541 by (Blast_tac 3); |
541 by (Blast_tac 3); |
542 by (dtac constrains_weaken_R 1); |
542 by (dtac constrains_weaken_R 1); |