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