author | paulson |
Thu, 13 Aug 1998 18:06:40 +0200 | |
changeset 5313 | 1861a564d7e2 |
parent 5277 | e4297d03e5d2 |
child 5340 | d75c03cf77b5 |
permissions | -rw-r--r-- |
4776 | 1 |
(* Title: HOL/UNITY/WFair |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1998 University of Cambridge |
|
5 |
||
6 |
Weak Fairness versions of transient, ensures, leadsTo. |
|
7 |
||
8 |
From Misra, "A Logic for Concurrent Programming", 1994 |
|
9 |
*) |
|
10 |
||
11 |
||
12 |
(*** transient ***) |
|
13 |
||
5069 | 14 |
Goalw [stable_def, constrains_def, transient_def] |
5253 | 15 |
"[| stable acts A; transient acts A |] ==> A = {}"; |
4776 | 16 |
by (Blast_tac 1); |
17 |
qed "stable_transient_empty"; |
|
18 |
||
5069 | 19 |
Goalw [transient_def] |
5253 | 20 |
"[| transient acts A; B<=A |] ==> transient acts B"; |
4776 | 21 |
by (Clarify_tac 1); |
22 |
by (rtac bexI 1 THEN assume_tac 2); |
|
23 |
by (Blast_tac 1); |
|
24 |
qed "transient_strengthen"; |
|
25 |
||
5069 | 26 |
Goalw [transient_def] |
5253 | 27 |
"[| act:acts; A <= Domain act; act^^A <= Compl A |] \ |
28 |
\ ==> transient acts A"; |
|
4776 | 29 |
by (Blast_tac 1); |
30 |
qed "transient_mem"; |
|
31 |
||
32 |
||
33 |
(*** ensures ***) |
|
34 |
||
5069 | 35 |
Goalw [ensures_def] |
5253 | 36 |
"[| constrains acts (A-B) (A Un B); transient acts (A-B) |] \ |
37 |
\ ==> ensures acts A B"; |
|
4776 | 38 |
by (Blast_tac 1); |
39 |
qed "ensuresI"; |
|
40 |
||
5069 | 41 |
Goalw [ensures_def] |
5253 | 42 |
"ensures acts A B \ |
43 |
\ ==> constrains acts (A-B) (A Un B) & transient acts (A-B)"; |
|
4776 | 44 |
by (Blast_tac 1); |
45 |
qed "ensuresD"; |
|
46 |
||
47 |
(*The L-version (precondition strengthening) doesn't hold for ENSURES*) |
|
5069 | 48 |
Goalw [ensures_def] |
5253 | 49 |
"[| ensures acts A A'; A'<=B' |] ==> ensures acts A B'"; |
4776 | 50 |
by (blast_tac (claset() addIs [constrains_weaken, transient_strengthen]) 1); |
51 |
qed "ensures_weaken_R"; |
|
52 |
||
5069 | 53 |
Goalw [ensures_def, constrains_def, transient_def] |
5253 | 54 |
"acts ~= {} ==> ensures acts A UNIV"; |
4776 | 55 |
by (Asm_simp_tac 1); (*omitting this causes PROOF FAILED, even with Safe_tac*) |
56 |
by (Blast_tac 1); |
|
57 |
qed "ensures_UNIV"; |
|
58 |
||
5069 | 59 |
Goalw [ensures_def] |
5253 | 60 |
"[| stable acts C; \ |
61 |
\ constrains acts (C Int (A - A')) (A Un A'); \ |
|
62 |
\ transient acts (C Int (A-A')) |] \ |
|
63 |
\ ==> ensures acts (C Int A) (C Int A')"; |
|
4776 | 64 |
by (asm_simp_tac (simpset() addsimps [Int_Un_distrib RS sym, |
65 |
Diff_Int_distrib RS sym, |
|
66 |
stable_constrains_Int]) 1); |
|
67 |
qed "stable_ensures_Int"; |
|
68 |
||
69 |
||
70 |
(*** leadsTo ***) |
|
71 |
||
72 |
(*Synonyms for the theorems produced by the inductive defn package*) |
|
73 |
bind_thm ("leadsTo_Basis", leadsto.Basis); |
|
74 |
bind_thm ("leadsTo_Trans", leadsto.Trans); |
|
75 |
||
5253 | 76 |
Goal "act: acts ==> leadsTo acts A UNIV"; |
4776 | 77 |
by (blast_tac (claset() addIs [ensures_UNIV RS leadsTo_Basis]) 1); |
78 |
qed "leadsTo_UNIV"; |
|
79 |
Addsimps [leadsTo_UNIV]; |
|
80 |
||
81 |
(*Useful with cancellation, disjunction*) |
|
5253 | 82 |
Goal "leadsTo acts A (A' Un A') ==> leadsTo acts A A'"; |
4776 | 83 |
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1); |
84 |
qed "leadsTo_Un_duplicate"; |
|
85 |
||
5253 | 86 |
Goal "leadsTo acts A (A' Un C Un C) ==> leadsTo acts A (A' Un C)"; |
4776 | 87 |
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1); |
88 |
qed "leadsTo_Un_duplicate2"; |
|
89 |
||
90 |
(*The Union introduction rule as we should have liked to state it*) |
|
91 |
val prems = goal thy |
|
5253 | 92 |
"(!!A. A : S ==> leadsTo acts A B) ==> leadsTo acts (Union S) B"; |
4776 | 93 |
by (blast_tac (claset() addIs (leadsto.Union::prems)) 1); |
94 |
qed "leadsTo_Union"; |
|
95 |
||
96 |
val prems = goal thy |
|
5253 | 97 |
"(!!i. i : I ==> leadsTo acts (A i) B) ==> leadsTo acts (UN i:I. A i) B"; |
4776 | 98 |
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1); |
99 |
by (blast_tac (claset() addIs (leadsto.Union::prems)) 1); |
|
100 |
qed "leadsTo_UN"; |
|
101 |
||
102 |
(*Binary union introduction rule*) |
|
5253 | 103 |
Goal "[| leadsTo acts A C; leadsTo acts B C |] ==> leadsTo acts (A Un B) C"; |
4776 | 104 |
by (stac Un_eq_Union 1); |
105 |
by (blast_tac (claset() addIs [leadsTo_Union]) 1); |
|
106 |
qed "leadsTo_Un"; |
|
107 |
||
108 |
||
109 |
(*The INDUCTION rule as we should have liked to state it*) |
|
110 |
val major::prems = goal thy |
|
5253 | 111 |
"[| leadsTo acts za zb; \ |
112 |
\ !!A B. ensures acts A B ==> P A B; \ |
|
113 |
\ !!A B C. [| leadsTo acts A B; P A B; leadsTo acts B C; P B C |] \ |
|
4776 | 114 |
\ ==> P A C; \ |
5253 | 115 |
\ !!B S. ALL A:S. leadsTo acts A B & P A B ==> P (Union S) B \ |
4776 | 116 |
\ |] ==> P za zb"; |
5232 | 117 |
by (rtac (major RS leadsto.induct) 1); |
4776 | 118 |
by (REPEAT (blast_tac (claset() addIs prems) 1)); |
119 |
qed "leadsTo_induct"; |
|
120 |
||
121 |
||
5253 | 122 |
Goal "[| A<=B; id: acts |] ==> leadsTo acts A B"; |
4776 | 123 |
by (rtac leadsTo_Basis 1); |
124 |
by (rewrite_goals_tac [ensures_def, constrains_def, transient_def]); |
|
125 |
by (Blast_tac 1); |
|
126 |
qed "subset_imp_leadsTo"; |
|
127 |
||
128 |
bind_thm ("empty_leadsTo", empty_subsetI RS subset_imp_leadsTo); |
|
129 |
Addsimps [empty_leadsTo]; |
|
130 |
||
131 |
||
132 |
(*There's a direct proof by leadsTo_Trans and subset_imp_leadsTo, but it |
|
5253 | 133 |
needs the extra premise id:acts*) |
134 |
Goal "leadsTo acts A A' ==> A'<=B' --> leadsTo acts A B'"; |
|
4776 | 135 |
by (etac leadsTo_induct 1); |
136 |
by (Clarify_tac 3); |
|
137 |
by (blast_tac (claset() addIs [leadsTo_Union]) 3); |
|
138 |
by (blast_tac (claset() addIs [leadsTo_Trans]) 2); |
|
139 |
by (blast_tac (claset() addIs [leadsTo_Basis, ensures_weaken_R]) 1); |
|
140 |
qed_spec_mp "leadsTo_weaken_R"; |
|
141 |
||
142 |
||
5253 | 143 |
Goal "[| leadsTo acts A A'; B<=A; id: acts |] ==> \ |
144 |
\ leadsTo acts B A'"; |
|
4776 | 145 |
by (blast_tac (claset() addIs [leadsTo_Basis, leadsTo_Trans, |
146 |
subset_imp_leadsTo]) 1); |
|
147 |
qed_spec_mp "leadsTo_weaken_L"; |
|
148 |
||
149 |
(*Distributes over binary unions*) |
|
5253 | 150 |
Goal "id: acts ==> \ |
151 |
\ leadsTo acts (A Un B) C = (leadsTo acts A C & leadsTo acts B C)"; |
|
4776 | 152 |
by (blast_tac (claset() addIs [leadsTo_Un, leadsTo_weaken_L]) 1); |
153 |
qed "leadsTo_Un_distrib"; |
|
154 |
||
5253 | 155 |
Goal "id: acts ==> \ |
156 |
\ leadsTo acts (UN i:I. A i) B = (ALL i : I. leadsTo acts (A i) B)"; |
|
4776 | 157 |
by (blast_tac (claset() addIs [leadsTo_UN, leadsTo_weaken_L]) 1); |
158 |
qed "leadsTo_UN_distrib"; |
|
159 |
||
5253 | 160 |
Goal "id: acts ==> \ |
161 |
\ leadsTo acts (Union S) B = (ALL A : S. leadsTo acts A B)"; |
|
4776 | 162 |
by (blast_tac (claset() addIs [leadsTo_Union, leadsTo_weaken_L]) 1); |
163 |
qed "leadsTo_Union_distrib"; |
|
164 |
||
165 |
||
5253 | 166 |
Goal "[| leadsTo acts A A'; id: acts; B<=A; A'<=B' |] \ |
167 |
\ ==> leadsTo acts B B'"; |
|
4776 | 168 |
(*PROOF FAILED: why?*) |
169 |
by (blast_tac (claset() addIs [leadsTo_Trans, leadsTo_weaken_R, |
|
170 |
leadsTo_weaken_L]) 1); |
|
171 |
qed "leadsTo_weaken"; |
|
172 |
||
173 |
||
174 |
(*Set difference: maybe combine with leadsTo_weaken_L??*) |
|
5253 | 175 |
Goal "[| leadsTo acts (A-B) C; leadsTo acts B C; id: acts |] \ |
176 |
\ ==> leadsTo acts A C"; |
|
4776 | 177 |
by (blast_tac (claset() addIs [leadsTo_Un, leadsTo_weaken]) 1); |
178 |
qed "leadsTo_Diff"; |
|
179 |
||
180 |
||
181 |
(** Meta or object quantifier ??? |
|
182 |
see ball_constrains_UN in UNITY.ML***) |
|
183 |
||
184 |
val prems = goal thy |
|
5253 | 185 |
"(!! i. i:I ==> leadsTo acts (A i) (A' i)) \ |
186 |
\ ==> leadsTo acts (UN i:I. A i) (UN i:I. A' i)"; |
|
4776 | 187 |
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1); |
188 |
by (blast_tac (claset() addIs [leadsTo_Union, leadsTo_weaken_R] |
|
189 |
addIs prems) 1); |
|
190 |
qed "leadsTo_UN_UN"; |
|
191 |
||
192 |
||
193 |
(*Version with no index set*) |
|
194 |
val prems = goal thy |
|
5253 | 195 |
"(!! i. leadsTo acts (A i) (A' i)) \ |
196 |
\ ==> leadsTo acts (UN i. A i) (UN i. A' i)"; |
|
4776 | 197 |
by (blast_tac (claset() addIs [leadsTo_UN_UN] |
198 |
addIs prems) 1); |
|
199 |
qed "leadsTo_UN_UN_noindex"; |
|
200 |
||
201 |
(*Version with no index set*) |
|
5253 | 202 |
Goal "ALL i. leadsTo acts (A i) (A' i) \ |
203 |
\ ==> leadsTo acts (UN i. A i) (UN i. A' i)"; |
|
4776 | 204 |
by (blast_tac (claset() addIs [leadsTo_UN_UN]) 1); |
205 |
qed "all_leadsTo_UN_UN"; |
|
206 |
||
207 |
||
208 |
(*Binary union version*) |
|
5253 | 209 |
Goal "[| leadsTo acts A A'; leadsTo acts B B' |] \ |
210 |
\ ==> leadsTo acts (A Un B) (A' Un B')"; |
|
4776 | 211 |
by (blast_tac (claset() addIs [leadsTo_Un, |
212 |
leadsTo_weaken_R]) 1); |
|
213 |
qed "leadsTo_Un_Un"; |
|
214 |
||
215 |
||
216 |
(** The cancellation law **) |
|
217 |
||
5253 | 218 |
Goal "[| leadsTo acts A (A' Un B); leadsTo acts B B'; id: acts |] \ |
219 |
\ ==> leadsTo acts A (A' Un B')"; |
|
4776 | 220 |
by (blast_tac (claset() addIs [leadsTo_Un_Un, |
221 |
subset_imp_leadsTo, leadsTo_Trans]) 1); |
|
222 |
qed "leadsTo_cancel2"; |
|
223 |
||
5253 | 224 |
Goal "[| leadsTo acts A (A' Un B); leadsTo acts (B-A') B'; id: acts |] \ |
225 |
\ ==> leadsTo acts A (A' Un B')"; |
|
4776 | 226 |
by (rtac leadsTo_cancel2 1); |
227 |
by (assume_tac 2); |
|
228 |
by (ALLGOALS Asm_simp_tac); |
|
229 |
qed "leadsTo_cancel_Diff2"; |
|
230 |
||
5253 | 231 |
Goal "[| leadsTo acts A (B Un A'); leadsTo acts B B'; id: acts |] \ |
232 |
\ ==> leadsTo acts A (B' Un A')"; |
|
4776 | 233 |
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1); |
234 |
by (blast_tac (claset() addSIs [leadsTo_cancel2]) 1); |
|
235 |
qed "leadsTo_cancel1"; |
|
236 |
||
5253 | 237 |
Goal "[| leadsTo acts A (B Un A'); leadsTo acts (B-A') B'; id: acts |] \ |
238 |
\ ==> leadsTo acts A (B' Un A')"; |
|
4776 | 239 |
by (rtac leadsTo_cancel1 1); |
240 |
by (assume_tac 2); |
|
241 |
by (ALLGOALS Asm_simp_tac); |
|
242 |
qed "leadsTo_cancel_Diff1"; |
|
243 |
||
244 |
||
245 |
||
246 |
(** The impossibility law **) |
|
247 |
||
5253 | 248 |
Goal "leadsTo acts A B ==> B={} --> A={}"; |
4776 | 249 |
by (etac leadsTo_induct 1); |
250 |
by (ALLGOALS Asm_simp_tac); |
|
251 |
by (rewrite_goals_tac [ensures_def, constrains_def, transient_def]); |
|
252 |
by (Blast_tac 1); |
|
253 |
val lemma = result() RS mp; |
|
254 |
||
5253 | 255 |
Goal "leadsTo acts A {} ==> A={}"; |
4776 | 256 |
by (blast_tac (claset() addSIs [lemma]) 1); |
257 |
qed "leadsTo_empty"; |
|
258 |
||
259 |
||
260 |
(** PSP: Progress-Safety-Progress **) |
|
261 |
||
5253 | 262 |
(*Special case of PSP: Misra's "stable conjunction". Doesn't need id:acts. *) |
5069 | 263 |
Goalw [stable_def] |
5253 | 264 |
"[| leadsTo acts A A'; stable acts B |] \ |
265 |
\ ==> leadsTo acts (A Int B) (A' Int B)"; |
|
4776 | 266 |
by (etac leadsTo_induct 1); |
267 |
by (simp_tac (simpset() addsimps [Int_Union_Union]) 3); |
|
268 |
by (blast_tac (claset() addIs [leadsTo_Union]) 3); |
|
269 |
by (blast_tac (claset() addIs [leadsTo_Trans]) 2); |
|
270 |
by (rtac leadsTo_Basis 1); |
|
271 |
by (asm_full_simp_tac |
|
272 |
(simpset() addsimps [ensures_def, |
|
273 |
Diff_Int_distrib2 RS sym, Int_Un_distrib2 RS sym]) 1); |
|
274 |
by (blast_tac (claset() addIs [transient_strengthen, constrains_Int]) 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
275 |
qed "psp_stable"; |
4776 | 276 |
|
5253 | 277 |
Goal "[| leadsTo acts A A'; stable acts B |] \ |
278 |
\ ==> leadsTo acts (B Int A) (B Int A')"; |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
279 |
by (asm_simp_tac (simpset() addsimps (psp_stable::Int_ac)) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
280 |
qed "psp_stable2"; |
4776 | 281 |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
282 |
Goalw [ensures_def, constrains_def] |
5253 | 283 |
"[| ensures acts A A'; constrains acts B B' |] \ |
284 |
\ ==> ensures acts (A Int B) ((A' Int B) Un (B' - B))"; |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
285 |
by (blast_tac (claset() addIs [transient_strengthen]) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
286 |
qed "psp_ensures"; |
4776 | 287 |
|
5253 | 288 |
Goal "[| leadsTo acts A A'; constrains acts B B'; id: acts |] \ |
289 |
\ ==> leadsTo acts (A Int B) ((A' Int B) Un (B' - B))"; |
|
4776 | 290 |
by (etac leadsTo_induct 1); |
291 |
by (simp_tac (simpset() addsimps [Int_Union_Union]) 3); |
|
292 |
by (blast_tac (claset() addIs [leadsTo_Union]) 3); |
|
293 |
(*Transitivity case has a delicate argument involving "cancellation"*) |
|
294 |
by (rtac leadsTo_Un_duplicate2 2); |
|
295 |
by (etac leadsTo_cancel_Diff1 2); |
|
296 |
by (assume_tac 3); |
|
297 |
by (asm_full_simp_tac (simpset() addsimps [Int_Diff, Diff_triv]) 2); |
|
298 |
(*Basis case*) |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
299 |
by (blast_tac (claset() addIs [leadsTo_Basis, psp_ensures]) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
300 |
qed "psp"; |
4776 | 301 |
|
5253 | 302 |
Goal "[| leadsTo acts A A'; constrains acts B B'; id: acts |] \ |
303 |
\ ==> leadsTo acts (B Int A) ((B Int A') Un (B' - B))"; |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
304 |
by (asm_simp_tac (simpset() addsimps (psp::Int_ac)) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
305 |
qed "psp2"; |
4776 | 306 |
|
307 |
||
5069 | 308 |
Goalw [unless_def] |
5253 | 309 |
"[| leadsTo acts A A'; unless acts B B'; id: acts |] \ |
310 |
\ ==> leadsTo acts (A Int B) ((A' Int B) Un B')"; |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
311 |
by (dtac psp 1); |
4776 | 312 |
by (assume_tac 1); |
313 |
by (asm_full_simp_tac (simpset() addsimps [Un_Diff_Diff, Int_Diff_Un]) 2); |
|
314 |
by (asm_full_simp_tac (simpset() addsimps [Diff_Int_distrib]) 2); |
|
315 |
by (etac leadsTo_Diff 2); |
|
316 |
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 2); |
|
317 |
by Auto_tac; |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
318 |
qed "psp_unless"; |
4776 | 319 |
|
320 |
||
321 |
(*** Proving the induction rules ***) |
|
322 |
||
5257 | 323 |
(** The most general rule: r is any wf relation; f is any variant function **) |
324 |
||
5239 | 325 |
Goal "[| wf r; \ |
5253 | 326 |
\ ALL m. leadsTo acts (A Int f-``{m}) \ |
5239 | 327 |
\ ((A Int f-``(r^-1 ^^ {m})) Un B); \ |
5253 | 328 |
\ id: acts |] \ |
329 |
\ ==> leadsTo acts (A Int f-``{m}) B"; |
|
4776 | 330 |
by (eres_inst_tac [("a","m")] wf_induct 1); |
5253 | 331 |
by (subgoal_tac "leadsTo acts (A Int (f -`` (r^-1 ^^ {x}))) B" 1); |
4776 | 332 |
by (stac vimage_eq_UN 2); |
333 |
by (asm_simp_tac (HOL_ss addsimps (UN_simps RL [sym])) 2); |
|
334 |
by (blast_tac (claset() addIs [leadsTo_UN]) 2); |
|
335 |
by (blast_tac (claset() addIs [leadsTo_cancel1, leadsTo_Un_duplicate]) 1); |
|
336 |
val lemma = result(); |
|
337 |
||
338 |
||
339 |
(** Meta or object quantifier ????? **) |
|
5239 | 340 |
Goal "[| wf r; \ |
5253 | 341 |
\ ALL m. leadsTo acts (A Int f-``{m}) \ |
5239 | 342 |
\ ((A Int f-``(r^-1 ^^ {m})) Un B); \ |
5253 | 343 |
\ id: acts |] \ |
344 |
\ ==> leadsTo acts A B"; |
|
4776 | 345 |
by (res_inst_tac [("t", "A")] subst 1); |
346 |
by (rtac leadsTo_UN 2); |
|
347 |
by (etac lemma 2); |
|
348 |
by (REPEAT (assume_tac 2)); |
|
349 |
by (Fast_tac 1); (*Blast_tac: Function unknown's argument not a parameter*) |
|
350 |
qed "leadsTo_wf_induct"; |
|
351 |
||
352 |
||
5239 | 353 |
Goal "[| wf r; \ |
5253 | 354 |
\ ALL m:I. leadsTo acts (A Int f-``{m}) \ |
5257 | 355 |
\ ((A Int f-``(r^-1 ^^ {m})) Un B); \ |
5253 | 356 |
\ id: acts |] \ |
357 |
\ ==> leadsTo acts A ((A - (f-``I)) Un B)"; |
|
4776 | 358 |
by (etac leadsTo_wf_induct 1); |
359 |
by Safe_tac; |
|
360 |
by (case_tac "m:I" 1); |
|
361 |
by (blast_tac (claset() addIs [leadsTo_weaken]) 1); |
|
362 |
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1); |
|
363 |
qed "bounded_induct"; |
|
364 |
||
365 |
||
5253 | 366 |
(*Alternative proof is via the lemma leadsTo acts (A Int f-``(lessThan m)) B*) |
367 |
Goal "[| ALL m. leadsTo acts (A Int f-``{m}) \ |
|
5239 | 368 |
\ ((A Int f-``(lessThan m)) Un B); \ |
5253 | 369 |
\ id: acts |] \ |
370 |
\ ==> leadsTo acts A B"; |
|
4776 | 371 |
by (rtac (wf_less_than RS leadsTo_wf_induct) 1); |
372 |
by (assume_tac 2); |
|
373 |
by (Asm_simp_tac 1); |
|
374 |
qed "lessThan_induct"; |
|
375 |
||
5253 | 376 |
Goal "[| ALL m:(greaterThan l). leadsTo acts (A Int f-``{m}) \ |
5239 | 377 |
\ ((A Int f-``(lessThan m)) Un B); \ |
5253 | 378 |
\ id: acts |] \ |
379 |
\ ==> leadsTo acts A ((A Int (f-``(atMost l))) Un B)"; |
|
4776 | 380 |
by (simp_tac (HOL_ss addsimps [Diff_eq RS sym, vimage_Compl, Compl_greaterThan RS sym]) 1); |
381 |
by (rtac (wf_less_than RS bounded_induct) 1); |
|
382 |
by (assume_tac 2); |
|
383 |
by (Asm_simp_tac 1); |
|
384 |
qed "lessThan_bounded_induct"; |
|
385 |
||
5253 | 386 |
Goal "[| ALL m:(lessThan l). leadsTo acts (A Int f-``{m}) \ |
5239 | 387 |
\ ((A Int f-``(greaterThan m)) Un B); \ |
5253 | 388 |
\ id: acts |] \ |
389 |
\ ==> leadsTo acts A ((A Int (f-``(atLeast l))) Un B)"; |
|
4776 | 390 |
by (res_inst_tac [("f","f"),("f1", "%k. l - k")] |
391 |
(wf_less_than RS wf_inv_image RS leadsTo_wf_induct) 1); |
|
392 |
by (assume_tac 2); |
|
393 |
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1); |
|
394 |
by (Clarify_tac 1); |
|
395 |
by (case_tac "m<l" 1); |
|
396 |
by (blast_tac (claset() addIs [not_leE, subset_imp_leadsTo]) 2); |
|
397 |
by (blast_tac (claset() addIs [leadsTo_weaken_R, diff_less_mono2]) 1); |
|
398 |
qed "greaterThan_bounded_induct"; |
|
399 |
||
400 |
||
401 |
||
402 |
(*** wlt ****) |
|
403 |
||
404 |
(*Misra's property W3*) |
|
5253 | 405 |
Goalw [wlt_def] "leadsTo acts (wlt acts B) B"; |
4776 | 406 |
by (blast_tac (claset() addSIs [leadsTo_Union]) 1); |
407 |
qed "wlt_leadsTo"; |
|
408 |
||
5253 | 409 |
Goalw [wlt_def] "leadsTo acts A B ==> A <= wlt acts B"; |
4776 | 410 |
by (blast_tac (claset() addSIs [leadsTo_Union]) 1); |
411 |
qed "leadsTo_subset"; |
|
412 |
||
413 |
(*Misra's property W2*) |
|
5253 | 414 |
Goal "id: acts ==> leadsTo acts A B = (A <= wlt acts B)"; |
4776 | 415 |
by (blast_tac (claset() addSIs [leadsTo_subset, |
416 |
wlt_leadsTo RS leadsTo_weaken_L]) 1); |
|
417 |
qed "leadsTo_eq_subset_wlt"; |
|
418 |
||
419 |
(*Misra's property W4*) |
|
5253 | 420 |
Goal "id: acts ==> B <= wlt acts B"; |
4776 | 421 |
by (asm_simp_tac (simpset() addsimps [leadsTo_eq_subset_wlt RS sym, |
422 |
subset_imp_leadsTo]) 1); |
|
423 |
qed "wlt_increasing"; |
|
424 |
||
425 |
||
426 |
(*Used in the Trans case below*) |
|
5069 | 427 |
Goalw [constrains_def] |
5111 | 428 |
"[| B <= A2; \ |
5253 | 429 |
\ constrains acts (A1 - B) (A1 Un B); \ |
430 |
\ constrains acts (A2 - C) (A2 Un C) |] \ |
|
431 |
\ ==> constrains acts (A1 Un A2 - C) (A1 Un A2 Un C)"; |
|
4776 | 432 |
by (Clarify_tac 1); |
433 |
by (blast_tac (claset() addSDs [bspec]) 1); |
|
434 |
val lemma1 = result(); |
|
435 |
||
436 |
||
437 |
(*Lemma (1,2,3) of Misra's draft book, Chapter 4, "Progress"*) |
|
5253 | 438 |
Goal "[| leadsTo acts A A'; id: acts |] ==> \ |
439 |
\ EX B. A<=B & leadsTo acts B A' & constrains acts (B-A') (B Un A')"; |
|
4776 | 440 |
by (etac leadsTo_induct 1); |
441 |
(*Basis*) |
|
442 |
by (blast_tac (claset() addIs [leadsTo_Basis] |
|
443 |
addDs [ensuresD]) 1); |
|
444 |
(*Trans*) |
|
445 |
by (Clarify_tac 1); |
|
446 |
by (res_inst_tac [("x", "Ba Un Bb")] exI 1); |
|
447 |
by (blast_tac (claset() addIs [lemma1, leadsTo_Un_Un, leadsTo_cancel1, |
|
448 |
leadsTo_Un_duplicate]) 1); |
|
449 |
(*Union*) |
|
450 |
by (clarify_tac (claset() addSDs [ball_conj_distrib RS iffD1, |
|
451 |
bchoice, ball_constrains_UN]) 1);; |
|
452 |
by (res_inst_tac [("x", "UN A:S. f A")] exI 1); |
|
453 |
by (blast_tac (claset() addIs [leadsTo_UN, constrains_weaken]) 1); |
|
454 |
qed "leadsTo_123"; |
|
455 |
||
456 |
||
457 |
(*Misra's property W5*) |
|
5253 | 458 |
Goal "id: acts ==> constrains acts (wlt acts B - B) (wlt acts B)"; |
4776 | 459 |
by (forward_tac [wlt_leadsTo RS leadsTo_123] 1); |
460 |
by (Clarify_tac 1); |
|
5253 | 461 |
by (subgoal_tac "Ba = wlt acts B" 1); |
4776 | 462 |
by (blast_tac (claset() addDs [leadsTo_eq_subset_wlt]) 2); |
463 |
by (Clarify_tac 1); |
|
464 |
by (asm_full_simp_tac (simpset() addsimps [wlt_increasing, Un_absorb2]) 1); |
|
465 |
qed "wlt_constrains_wlt"; |
|
466 |
||
467 |
||
468 |
(*** Completion: Binary and General Finite versions ***) |
|
469 |
||
5253 | 470 |
Goal "[| leadsTo acts A A'; stable acts A'; \ |
471 |
\ leadsTo acts B B'; stable acts B'; id: acts |] \ |
|
472 |
\ ==> leadsTo acts (A Int B) (A' Int B')"; |
|
473 |
by (subgoal_tac "stable acts (wlt acts B')" 1); |
|
4776 | 474 |
by (asm_full_simp_tac (simpset() addsimps [stable_def]) 2); |
475 |
by (EVERY [etac (constrains_Un RS constrains_weaken) 2, |
|
476 |
etac wlt_constrains_wlt 2, |
|
477 |
fast_tac (claset() addEs [wlt_increasing RSN (2,rev_subsetD)]) 3, |
|
478 |
Blast_tac 2]); |
|
5253 | 479 |
by (subgoal_tac "leadsTo acts (A Int wlt acts B') (A' Int wlt acts B')" 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
480 |
by (blast_tac (claset() addIs [psp_stable]) 2); |
5253 | 481 |
by (subgoal_tac "leadsTo acts (A' Int wlt acts B') (A' Int B')" 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
482 |
by (blast_tac (claset() addIs [wlt_leadsTo, psp_stable2]) 2); |
5253 | 483 |
by (subgoal_tac "leadsTo acts (A Int B) (A Int wlt acts B')" 1); |
4776 | 484 |
by (blast_tac (claset() addIs [leadsTo_subset RS subsetD, |
485 |
subset_imp_leadsTo]) 2); |
|
486 |
(*Blast_tac gives PROOF FAILED*) |
|
487 |
by (best_tac (claset() addIs [leadsTo_Trans]) 1); |
|
488 |
qed "stable_completion"; |
|
489 |
||
490 |
||
5253 | 491 |
Goal "[| finite I; id: acts |] \ |
492 |
\ ==> (ALL i:I. leadsTo acts (A i) (A' i)) --> \ |
|
493 |
\ (ALL i:I. stable acts (A' i)) --> \ |
|
494 |
\ leadsTo acts (INT i:I. A i) (INT i:I. A' i)"; |
|
4776 | 495 |
by (etac finite_induct 1); |
496 |
by (Asm_simp_tac 1); |
|
497 |
by (asm_simp_tac |
|
498 |
(simpset() addsimps [stable_completion, stable_def, |
|
499 |
ball_constrains_INT]) 1); |
|
500 |
qed_spec_mp "finite_stable_completion"; |
|
501 |
||
502 |
||
5253 | 503 |
Goal "[| W = wlt acts (B' Un C); \ |
504 |
\ leadsTo acts A (A' Un C); constrains acts A' (A' Un C); \ |
|
505 |
\ leadsTo acts B (B' Un C); constrains acts B' (B' Un C); \ |
|
506 |
\ id: acts |] \ |
|
507 |
\ ==> leadsTo acts (A Int B) ((A' Int B') Un C)"; |
|
508 |
by (subgoal_tac "constrains acts (W-C) (W Un B' Un C)" 1); |
|
4776 | 509 |
by (blast_tac (claset() addIs [[asm_rl, wlt_constrains_wlt] |
510 |
MRS constrains_Un RS constrains_weaken]) 2); |
|
5253 | 511 |
by (subgoal_tac "constrains acts (W-C) W" 1); |
4776 | 512 |
by (asm_full_simp_tac |
513 |
(simpset() addsimps [wlt_increasing, Un_assoc, Un_absorb2]) 2); |
|
5253 | 514 |
by (subgoal_tac "leadsTo acts (A Int W - C) (A' Int W Un C)" 1); |
4776 | 515 |
by (simp_tac (simpset() addsimps [Int_Diff]) 2); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
516 |
by (blast_tac (claset() addIs [wlt_leadsTo, psp RS leadsTo_weaken_R]) 2); |
5253 | 517 |
by (subgoal_tac "leadsTo acts (A' Int W Un C) (A' Int B' Un C)" 1); |
4776 | 518 |
by (blast_tac (claset() addIs [wlt_leadsTo, leadsTo_Un_Un, |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
519 |
psp2 RS leadsTo_weaken_R, |
4776 | 520 |
subset_refl RS subset_imp_leadsTo, |
521 |
leadsTo_Un_duplicate2]) 2); |
|
522 |
by (dtac leadsTo_Diff 1); |
|
523 |
by (assume_tac 2); |
|
524 |
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1); |
|
525 |
by (subgoal_tac "A Int B <= A Int W" 1); |
|
526 |
by (blast_tac (claset() addIs [leadsTo_subset, Int_mono] |
|
527 |
delrules [subsetI]) 2); |
|
528 |
by (blast_tac (claset() addIs [leadsTo_Trans, subset_imp_leadsTo]) 1); |
|
529 |
bind_thm("completion", refl RS result()); |
|
530 |
||
531 |
||
5253 | 532 |
Goal "[| finite I; id: acts |] \ |
533 |
\ ==> (ALL i:I. leadsTo acts (A i) (A' i Un C)) --> \ |
|
534 |
\ (ALL i:I. constrains acts (A' i) (A' i Un C)) --> \ |
|
535 |
\ leadsTo acts (INT i:I. A i) ((INT i:I. A' i) Un C)"; |
|
4776 | 536 |
by (etac finite_induct 1); |
537 |
by (ALLGOALS Asm_simp_tac); |
|
538 |
by (Clarify_tac 1); |
|
539 |
by (dtac ball_constrains_INT 1); |
|
540 |
by (asm_full_simp_tac (simpset() addsimps [completion]) 1); |
|
541 |
qed "finite_completion"; |
|
542 |