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