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