244
|
1 |
(* Title: HOLCF/ex/hoare.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Franz Regensburger
|
|
4 |
Copyright 1993 Technische Universitaet Muenchen
|
|
5 |
*)
|
|
6 |
|
|
7 |
open Hoare;
|
|
8 |
|
|
9 |
(* --------- pure HOLCF logic, some little lemmas ------ *)
|
|
10 |
|
|
11 |
val hoare_lemma2 = prove_goal HOLCF.thy "~b=TT ==> b=FF | b=UU"
|
|
12 |
(fn prems =>
|
|
13 |
[
|
|
14 |
(cut_facts_tac prems 1),
|
|
15 |
(rtac (Exh_tr RS disjE) 1),
|
|
16 |
(fast_tac HOL_cs 1),
|
|
17 |
(etac disjE 1),
|
|
18 |
(contr_tac 1),
|
|
19 |
(fast_tac HOL_cs 1)
|
|
20 |
]);
|
|
21 |
|
|
22 |
val hoare_lemma3 = prove_goal HOLCF.thy
|
|
23 |
" (!k.b1[iterate(k,g,x)]=TT) | (? k.~ b1[iterate(k,g,x)]=TT)"
|
|
24 |
(fn prems =>
|
|
25 |
[
|
|
26 |
(fast_tac HOL_cs 1)
|
|
27 |
]);
|
|
28 |
|
|
29 |
val hoare_lemma4 = prove_goal HOLCF.thy
|
|
30 |
"(? k.~ b1[iterate(k,g,x)]=TT) ==> \
|
|
31 |
\ ? k.b1[iterate(k,g,x)]=FF | b1[iterate(k,g,x)]=UU"
|
|
32 |
(fn prems =>
|
|
33 |
[
|
|
34 |
(cut_facts_tac prems 1),
|
|
35 |
(etac exE 1),
|
|
36 |
(rtac exI 1),
|
|
37 |
(rtac hoare_lemma2 1),
|
|
38 |
(atac 1)
|
|
39 |
]);
|
|
40 |
|
|
41 |
val hoare_lemma5 = prove_goal HOLCF.thy
|
|
42 |
"[|(? k.~ b1[iterate(k,g,x)]=TT);\
|
|
43 |
\ k=theleast(%n.~ b1[iterate(n,g,x)]=TT)|] ==> \
|
|
44 |
\ b1[iterate(k,g,x)]=FF | b1[iterate(k,g,x)]=UU"
|
|
45 |
(fn prems =>
|
|
46 |
[
|
|
47 |
(cut_facts_tac prems 1),
|
|
48 |
(hyp_subst_tac 1),
|
|
49 |
(rtac hoare_lemma2 1),
|
|
50 |
(etac exE 1),
|
|
51 |
(etac theleast1 1)
|
|
52 |
]);
|
|
53 |
|
|
54 |
val hoare_lemma6 = prove_goal HOLCF.thy "b=UU ==> ~b=TT"
|
|
55 |
(fn prems =>
|
|
56 |
[
|
|
57 |
(cut_facts_tac prems 1),
|
|
58 |
(hyp_subst_tac 1),
|
|
59 |
(resolve_tac dist_eq_tr 1)
|
|
60 |
]);
|
|
61 |
|
|
62 |
val hoare_lemma7 = prove_goal HOLCF.thy "b=FF ==> ~b=TT"
|
|
63 |
(fn prems =>
|
|
64 |
[
|
|
65 |
(cut_facts_tac prems 1),
|
|
66 |
(hyp_subst_tac 1),
|
|
67 |
(resolve_tac dist_eq_tr 1)
|
|
68 |
]);
|
|
69 |
|
|
70 |
val hoare_lemma8 = prove_goal HOLCF.thy
|
|
71 |
"[|(? k.~ b1[iterate(k,g,x)]=TT);\
|
|
72 |
\ k=theleast(%n.~ b1[iterate(n,g,x)]=TT)|] ==> \
|
|
73 |
\ !m. m<k --> b1[iterate(m,g,x)]=TT"
|
|
74 |
(fn prems =>
|
|
75 |
[
|
|
76 |
(cut_facts_tac prems 1),
|
|
77 |
(hyp_subst_tac 1),
|
|
78 |
(etac exE 1),
|
|
79 |
(strip_tac 1),
|
|
80 |
(res_inst_tac [("p","b1[iterate(m,g,x)]")] trE 1),
|
|
81 |
(atac 2),
|
|
82 |
(rtac (le_less_trans RS less_anti_refl) 1),
|
|
83 |
(atac 2),
|
|
84 |
(rtac theleast2 1),
|
|
85 |
(etac hoare_lemma6 1),
|
|
86 |
(rtac (le_less_trans RS less_anti_refl) 1),
|
|
87 |
(atac 2),
|
|
88 |
(rtac theleast2 1),
|
|
89 |
(etac hoare_lemma7 1)
|
|
90 |
]);
|
|
91 |
|
|
92 |
val hoare_lemma28 = prove_goal HOLCF.thy
|
|
93 |
"b1[y::'a]=UU::tr ==> b1[UU] = UU"
|
|
94 |
(fn prems =>
|
|
95 |
[
|
|
96 |
(cut_facts_tac prems 1),
|
|
97 |
(etac (flat_tr RS flat_codom RS disjE) 1),
|
|
98 |
(atac 1),
|
|
99 |
(etac spec 1)
|
|
100 |
]);
|
|
101 |
|
|
102 |
|
|
103 |
(* ----- access to definitions ----- *)
|
|
104 |
|
|
105 |
val p_def2 = prove_goalw Hoare.thy [p_def]
|
|
106 |
"p = fix[LAM f x. If b1[x] then f[g[x]] else x fi]"
|
|
107 |
(fn prems =>
|
|
108 |
[
|
|
109 |
(rtac refl 1)
|
|
110 |
]);
|
|
111 |
|
|
112 |
val q_def2 = prove_goalw Hoare.thy [q_def]
|
|
113 |
"q = fix[LAM f x. If b1[x] orelse b2[x] then \
|
|
114 |
\ f[g[x]] else x fi]"
|
|
115 |
(fn prems =>
|
|
116 |
[
|
|
117 |
(rtac refl 1)
|
|
118 |
]);
|
|
119 |
|
|
120 |
|
|
121 |
val p_def3 = prove_goal Hoare.thy
|
|
122 |
"p[x] = If b1[x] then p[g[x]] else x fi"
|
|
123 |
(fn prems =>
|
|
124 |
[
|
|
125 |
(fix_tac3 p_def 1),
|
|
126 |
(simp_tac HOLCF_ss 1)
|
|
127 |
]);
|
|
128 |
|
|
129 |
val q_def3 = prove_goal Hoare.thy
|
|
130 |
"q[x] = If b1[x] orelse b2[x] then q[g[x]] else x fi"
|
|
131 |
(fn prems =>
|
|
132 |
[
|
|
133 |
(fix_tac3 q_def 1),
|
|
134 |
(simp_tac HOLCF_ss 1)
|
|
135 |
]);
|
|
136 |
|
|
137 |
(** --------- proves about iterations of p and q ---------- **)
|
|
138 |
|
|
139 |
val hoare_lemma9 = prove_goal Hoare.thy
|
|
140 |
"(! m. m<Suc(k) --> b1[iterate(m,g,x)]=TT) -->\
|
|
141 |
\ p[iterate(k,g,x)]=p[x]"
|
|
142 |
(fn prems =>
|
|
143 |
[
|
|
144 |
(nat_ind_tac "k" 1),
|
|
145 |
(simp_tac iterate_ss 1),
|
|
146 |
(simp_tac iterate_ss 1),
|
|
147 |
(strip_tac 1),
|
|
148 |
(res_inst_tac [("s","p[iterate(k1,g,x)]")] trans 1),
|
|
149 |
(rtac trans 1),
|
|
150 |
(rtac (p_def3 RS sym) 2),
|
|
151 |
(res_inst_tac [("s","TT"),("t","b1[iterate(k1,g,x)]")] ssubst 1),
|
|
152 |
(rtac mp 1),
|
|
153 |
(etac spec 1),
|
|
154 |
(simp_tac nat_ss 1),
|
|
155 |
(simp_tac HOLCF_ss 1),
|
|
156 |
(etac mp 1),
|
|
157 |
(strip_tac 1),
|
|
158 |
(rtac mp 1),
|
|
159 |
(etac spec 1),
|
|
160 |
(etac less_trans 1),
|
|
161 |
(simp_tac nat_ss 1)
|
|
162 |
]);
|
|
163 |
|
|
164 |
val hoare_lemma24 = prove_goal Hoare.thy
|
|
165 |
"(! m. m<Suc(k) --> b1[iterate(m,g,x)]=TT) --> \
|
|
166 |
\ q[iterate(k,g,x)]=q[x]"
|
|
167 |
(fn prems =>
|
|
168 |
[
|
|
169 |
(nat_ind_tac "k" 1),
|
|
170 |
(simp_tac iterate_ss 1),
|
|
171 |
(simp_tac iterate_ss 1),
|
|
172 |
(strip_tac 1),
|
|
173 |
(res_inst_tac [("s","q[iterate(k1,g,x)]")] trans 1),
|
|
174 |
(rtac trans 1),
|
|
175 |
(rtac (q_def3 RS sym) 2),
|
|
176 |
(res_inst_tac [("s","TT"),("t","b1[iterate(k1,g,x)]")] ssubst 1),
|
|
177 |
(rtac mp 1),
|
|
178 |
(etac spec 1),
|
|
179 |
(simp_tac nat_ss 1),
|
|
180 |
(simp_tac HOLCF_ss 1),
|
|
181 |
(etac mp 1),
|
|
182 |
(strip_tac 1),
|
|
183 |
(rtac mp 1),
|
|
184 |
(etac spec 1),
|
|
185 |
(etac less_trans 1),
|
|
186 |
(simp_tac nat_ss 1)
|
|
187 |
]);
|
|
188 |
|
|
189 |
(* -------- results about p for case (? k.~ b1[iterate(k,g,x)]=TT) ------- *)
|
|
190 |
|
|
191 |
|
|
192 |
val hoare_lemma10 = (hoare_lemma8 RS (hoare_lemma9 RS mp));
|
|
193 |
(*
|
|
194 |
[| ? k. ~ b1[iterate(k,g,?x1)] = TT;
|
|
195 |
Suc(?k3) = theleast(%n. ~ b1[iterate(n,g,?x1)] = TT) |] ==>
|
|
196 |
p[iterate(?k3,g,?x1)] = p[?x1]
|
|
197 |
*)
|
|
198 |
|
|
199 |
val hoare_lemma11 = prove_goal Hoare.thy
|
|
200 |
"(? n.b1[iterate(n,g,x)]~=TT) ==>\
|
|
201 |
\ k=theleast(%n.b1[iterate(n,g,x)]~=TT) & b1[iterate(k,g,x)]=FF \
|
|
202 |
\ --> p[x] = iterate(k,g,x)"
|
|
203 |
(fn prems =>
|
|
204 |
[
|
|
205 |
(cut_facts_tac prems 1),
|
|
206 |
(res_inst_tac [("n","k")] natE 1),
|
|
207 |
(hyp_subst_tac 1),
|
|
208 |
(simp_tac iterate_ss 1),
|
|
209 |
(strip_tac 1),
|
|
210 |
(etac conjE 1),
|
|
211 |
(rtac trans 1),
|
|
212 |
(rtac p_def3 1),
|
|
213 |
(asm_simp_tac HOLCF_ss 1),
|
|
214 |
(eres_inst_tac [("s","0"),("t","theleast(%n. b1[iterate(n, g, x)] ~= TT)")]
|
|
215 |
subst 1),
|
|
216 |
(simp_tac iterate_ss 1),
|
|
217 |
(hyp_subst_tac 1),
|
|
218 |
(strip_tac 1),
|
|
219 |
(etac conjE 1),
|
|
220 |
(rtac trans 1),
|
|
221 |
(etac (hoare_lemma10 RS sym) 1),
|
|
222 |
(atac 1),
|
|
223 |
(rtac trans 1),
|
|
224 |
(rtac p_def3 1),
|
|
225 |
(res_inst_tac [("s","TT"),("t","b1[iterate(xa,g,x)]")] ssubst 1),
|
|
226 |
(rtac (hoare_lemma8 RS spec RS mp) 1),
|
|
227 |
(atac 1),
|
|
228 |
(atac 1),
|
|
229 |
(simp_tac nat_ss 1),
|
|
230 |
(simp_tac HOLCF_ss 1),
|
|
231 |
(rtac trans 1),
|
|
232 |
(rtac p_def3 1),
|
|
233 |
(simp_tac (HOLCF_ss addsimps [iterate_Suc RS sym]) 1),
|
|
234 |
(eres_inst_tac [("s","FF")] ssubst 1),
|
|
235 |
(simp_tac HOLCF_ss 1)
|
|
236 |
]);
|
|
237 |
|
|
238 |
val hoare_lemma12 = prove_goal Hoare.thy
|
|
239 |
"(? n.~ b1[iterate(n,g,x)]=TT) ==>\
|
|
240 |
\ k=theleast(%n.~ b1[iterate(n,g,x)]=TT) & b1[iterate(k,g,x)]=UU \
|
|
241 |
\ --> p[x] = UU"
|
|
242 |
(fn prems =>
|
|
243 |
[
|
|
244 |
(cut_facts_tac prems 1),
|
|
245 |
(res_inst_tac [("n","k")] natE 1),
|
|
246 |
(hyp_subst_tac 1),
|
|
247 |
(simp_tac iterate_ss 1),
|
|
248 |
(strip_tac 1),
|
|
249 |
(etac conjE 1),
|
|
250 |
(rtac trans 1),
|
|
251 |
(rtac p_def3 1),
|
|
252 |
(asm_simp_tac HOLCF_ss 1),
|
|
253 |
(hyp_subst_tac 1),
|
|
254 |
(simp_tac iterate_ss 1),
|
|
255 |
(strip_tac 1),
|
|
256 |
(etac conjE 1),
|
|
257 |
(rtac trans 1),
|
|
258 |
(rtac (hoare_lemma10 RS sym) 1),
|
|
259 |
(atac 1),
|
|
260 |
(atac 1),
|
|
261 |
(rtac trans 1),
|
|
262 |
(rtac p_def3 1),
|
|
263 |
(res_inst_tac [("s","TT"),("t","b1[iterate(xa,g,x)]")] ssubst 1),
|
|
264 |
(rtac (hoare_lemma8 RS spec RS mp) 1),
|
|
265 |
(atac 1),
|
|
266 |
(atac 1),
|
|
267 |
(simp_tac nat_ss 1),
|
|
268 |
(asm_simp_tac HOLCF_ss 1),
|
|
269 |
(rtac trans 1),
|
|
270 |
(rtac p_def3 1),
|
|
271 |
(asm_simp_tac HOLCF_ss 1)
|
|
272 |
]);
|
|
273 |
|
|
274 |
(* -------- results about p for case (! k. b1[iterate(k,g,x)]=TT) ------- *)
|
|
275 |
|
|
276 |
val fernpass_lemma = prove_goal Hoare.thy
|
|
277 |
"(! k. b1[iterate(k,g,x)]=TT) ==> !k.p[iterate(k,g,x)] = UU"
|
|
278 |
(fn prems =>
|
|
279 |
[
|
|
280 |
(cut_facts_tac prems 1),
|
|
281 |
(rtac (p_def2 RS ssubst) 1),
|
|
282 |
(rtac fix_ind 1),
|
|
283 |
(rtac adm_all 1),
|
|
284 |
(rtac allI 1),
|
|
285 |
(rtac adm_eq 1),
|
|
286 |
(contX_tacR 1),
|
|
287 |
(rtac allI 1),
|
|
288 |
(rtac (strict_fapp1 RS ssubst) 1),
|
|
289 |
(rtac refl 1),
|
|
290 |
(simp_tac iterate_ss 1),
|
|
291 |
(rtac allI 1),
|
|
292 |
(res_inst_tac [("s","TT"),("t","b1[iterate(k,g,x)]")] ssubst 1),
|
|
293 |
(etac spec 1),
|
|
294 |
(asm_simp_tac HOLCF_ss 1),
|
|
295 |
(rtac (iterate_Suc RS subst) 1),
|
|
296 |
(etac spec 1)
|
|
297 |
]);
|
|
298 |
|
|
299 |
val hoare_lemma16 = prove_goal Hoare.thy
|
|
300 |
"(! k. b1[iterate(k,g,x)]=TT) ==> p[x] = UU"
|
|
301 |
(fn prems =>
|
|
302 |
[
|
|
303 |
(cut_facts_tac prems 1),
|
|
304 |
(res_inst_tac [("F1","g"),("t","x")] (iterate_0 RS subst) 1),
|
|
305 |
(etac (fernpass_lemma RS spec) 1)
|
|
306 |
]);
|
|
307 |
|
|
308 |
(* -------- results about q for case (! k. b1[iterate(k,g,x)]=TT) ------- *)
|
|
309 |
|
|
310 |
val hoare_lemma17 = prove_goal Hoare.thy
|
|
311 |
"(! k. b1[iterate(k,g,x)]=TT) ==> !k.q[iterate(k,g,x)] = UU"
|
|
312 |
(fn prems =>
|
|
313 |
[
|
|
314 |
(cut_facts_tac prems 1),
|
|
315 |
(rtac (q_def2 RS ssubst) 1),
|
|
316 |
(rtac fix_ind 1),
|
|
317 |
(rtac adm_all 1),
|
|
318 |
(rtac allI 1),
|
|
319 |
(rtac adm_eq 1),
|
|
320 |
(contX_tacR 1),
|
|
321 |
(rtac allI 1),
|
|
322 |
(rtac (strict_fapp1 RS ssubst) 1),
|
|
323 |
(rtac refl 1),
|
|
324 |
(rtac allI 1),
|
|
325 |
(simp_tac iterate_ss 1),
|
|
326 |
(res_inst_tac [("s","TT"),("t","b1[iterate(k,g,x)]")] ssubst 1),
|
|
327 |
(etac spec 1),
|
|
328 |
(asm_simp_tac HOLCF_ss 1),
|
|
329 |
(rtac (iterate_Suc RS subst) 1),
|
|
330 |
(etac spec 1)
|
|
331 |
]);
|
|
332 |
|
|
333 |
val hoare_lemma18 = prove_goal Hoare.thy
|
|
334 |
"(! k. b1[iterate(k,g,x)]=TT) ==> q[x] = UU"
|
|
335 |
(fn prems =>
|
|
336 |
[
|
|
337 |
(cut_facts_tac prems 1),
|
|
338 |
(res_inst_tac [("F1","g"),("t","x")] (iterate_0 RS subst) 1),
|
|
339 |
(etac (hoare_lemma17 RS spec) 1)
|
|
340 |
]);
|
|
341 |
|
|
342 |
val hoare_lemma19 = prove_goal Hoare.thy
|
|
343 |
"(!k. (b1::'a->tr)[iterate(k,g,x)]=TT) ==> b1[UU::'a] = UU | (!y.b1[y::'a]=TT)"
|
|
344 |
(fn prems =>
|
|
345 |
[
|
|
346 |
(cut_facts_tac prems 1),
|
|
347 |
(rtac (flat_tr RS flat_codom) 1),
|
|
348 |
(res_inst_tac [("t","x1")] (iterate_0 RS subst) 1),
|
|
349 |
(etac spec 1)
|
|
350 |
]);
|
|
351 |
|
|
352 |
val hoare_lemma20 = prove_goal Hoare.thy
|
|
353 |
"(! y. b1[y::'a]=TT) ==> !k.q[iterate(k,g,x::'a)] = UU"
|
|
354 |
(fn prems =>
|
|
355 |
[
|
|
356 |
(cut_facts_tac prems 1),
|
|
357 |
(rtac (q_def2 RS ssubst) 1),
|
|
358 |
(rtac fix_ind 1),
|
|
359 |
(rtac adm_all 1),
|
|
360 |
(rtac allI 1),
|
|
361 |
(rtac adm_eq 1),
|
|
362 |
(contX_tacR 1),
|
|
363 |
(rtac allI 1),
|
|
364 |
(rtac (strict_fapp1 RS ssubst) 1),
|
|
365 |
(rtac refl 1),
|
|
366 |
(rtac allI 1),
|
|
367 |
(simp_tac iterate_ss 1),
|
|
368 |
(res_inst_tac [("s","TT"),("t","b1[iterate(k,g,x::'a)]")] ssubst 1),
|
|
369 |
(etac spec 1),
|
|
370 |
(asm_simp_tac HOLCF_ss 1),
|
|
371 |
(rtac (iterate_Suc RS subst) 1),
|
|
372 |
(etac spec 1)
|
|
373 |
]);
|
|
374 |
|
|
375 |
val hoare_lemma21 = prove_goal Hoare.thy
|
|
376 |
"(! y. b1[y::'a]=TT) ==> q[x::'a] = UU"
|
|
377 |
(fn prems =>
|
|
378 |
[
|
|
379 |
(cut_facts_tac prems 1),
|
|
380 |
(res_inst_tac [("F1","g"),("t","x")] (iterate_0 RS subst) 1),
|
|
381 |
(etac (hoare_lemma20 RS spec) 1)
|
|
382 |
]);
|
|
383 |
|
|
384 |
val hoare_lemma22 = prove_goal Hoare.thy
|
|
385 |
"b1[UU::'a]=UU ==> q[UU::'a] = UU"
|
|
386 |
(fn prems =>
|
|
387 |
[
|
|
388 |
(cut_facts_tac prems 1),
|
|
389 |
(rtac (q_def3 RS ssubst) 1),
|
|
390 |
(asm_simp_tac HOLCF_ss 1)
|
|
391 |
]);
|
|
392 |
|
|
393 |
(* -------- results about q for case (? k.~ b1[iterate(k,g,x)]=TT) ------- *)
|
|
394 |
|
|
395 |
val hoare_lemma25 = (hoare_lemma8 RS (hoare_lemma24 RS mp) );
|
|
396 |
(*
|
|
397 |
[| ? k. ~ ?b1.1[iterate(k,?g1,?x1)] = TT;
|
|
398 |
Suc(?k3) = theleast(%n. ~ ?b1.1[iterate(n,?g1,?x1)] = TT) |] ==>
|
|
399 |
q[iterate(?k3,?g1,?x1)] = q[?x1]
|
|
400 |
*)
|
|
401 |
|
|
402 |
val hoare_lemma26 = prove_goal Hoare.thy
|
|
403 |
"(? n.~ b1[iterate(n,g,x)]=TT) ==>\
|
|
404 |
\ k=theleast(%n.~ b1[iterate(n,g,x)]=TT) & b1[iterate(k,g,x)]=FF \
|
|
405 |
\ --> q[x] = q[iterate(k,g,x)]"
|
|
406 |
(fn prems =>
|
|
407 |
[
|
|
408 |
(cut_facts_tac prems 1),
|
|
409 |
(res_inst_tac [("n","k")] natE 1),
|
|
410 |
(hyp_subst_tac 1),
|
|
411 |
(strip_tac 1),
|
|
412 |
(simp_tac iterate_ss 1),
|
|
413 |
(hyp_subst_tac 1),
|
|
414 |
(strip_tac 1),
|
|
415 |
(etac conjE 1),
|
|
416 |
(rtac trans 1),
|
|
417 |
(rtac (hoare_lemma25 RS sym) 1),
|
|
418 |
(atac 1),
|
|
419 |
(atac 1),
|
|
420 |
(rtac trans 1),
|
|
421 |
(rtac q_def3 1),
|
|
422 |
(res_inst_tac [("s","TT"),("t","b1[iterate(xa,g,x)]")] ssubst 1),
|
|
423 |
(rtac (hoare_lemma8 RS spec RS mp) 1),
|
|
424 |
(atac 1),
|
|
425 |
(atac 1),
|
|
426 |
(simp_tac nat_ss 1),
|
|
427 |
(simp_tac (HOLCF_ss addsimps [iterate_Suc]) 1)
|
|
428 |
]);
|
|
429 |
|
|
430 |
|
|
431 |
val hoare_lemma27 = prove_goal Hoare.thy
|
|
432 |
"(? n.~ b1[iterate(n,g,x)]=TT) ==>\
|
|
433 |
\ k=theleast(%n.~ b1[iterate(n,g,x)]=TT) & b1[iterate(k,g,x)]=UU \
|
|
434 |
\ --> q[x] = UU"
|
|
435 |
(fn prems =>
|
|
436 |
[
|
|
437 |
(cut_facts_tac prems 1),
|
|
438 |
(res_inst_tac [("n","k")] natE 1),
|
|
439 |
(hyp_subst_tac 1),
|
|
440 |
(simp_tac iterate_ss 1),
|
|
441 |
(strip_tac 1),
|
|
442 |
(etac conjE 1),
|
|
443 |
(rtac (q_def3 RS ssubst) 1),
|
|
444 |
(asm_simp_tac HOLCF_ss 1),
|
|
445 |
(hyp_subst_tac 1),
|
|
446 |
(simp_tac iterate_ss 1),
|
|
447 |
(strip_tac 1),
|
|
448 |
(etac conjE 1),
|
|
449 |
(rtac trans 1),
|
|
450 |
(rtac (hoare_lemma25 RS sym) 1),
|
|
451 |
(atac 1),
|
|
452 |
(atac 1),
|
|
453 |
(rtac trans 1),
|
|
454 |
(rtac q_def3 1),
|
|
455 |
(res_inst_tac [("s","TT"),("t","b1[iterate(xa,g,x)]")] ssubst 1),
|
|
456 |
(rtac (hoare_lemma8 RS spec RS mp) 1),
|
|
457 |
(atac 1),
|
|
458 |
(atac 1),
|
|
459 |
(simp_tac nat_ss 1),
|
|
460 |
(asm_simp_tac HOLCF_ss 1),
|
|
461 |
(rtac trans 1),
|
|
462 |
(rtac q_def3 1),
|
|
463 |
(asm_simp_tac HOLCF_ss 1)
|
|
464 |
]);
|
|
465 |
|
|
466 |
(* ------- (! k. b1[iterate(k,g,x)]=TT) ==> q o p = q ----- *)
|
|
467 |
|
|
468 |
val hoare_lemma23 = prove_goal Hoare.thy
|
|
469 |
"(! k. b1[iterate(k,g,x)]=TT) ==> q[p[x]] = q[x]"
|
|
470 |
(fn prems =>
|
|
471 |
[
|
|
472 |
(cut_facts_tac prems 1),
|
|
473 |
(rtac (hoare_lemma16 RS ssubst) 1),
|
|
474 |
(atac 1),
|
|
475 |
(rtac (hoare_lemma19 RS disjE) 1),
|
|
476 |
(atac 1),
|
|
477 |
(rtac (hoare_lemma18 RS ssubst) 1),
|
|
478 |
(atac 1),
|
|
479 |
(rtac (hoare_lemma22 RS ssubst) 1),
|
|
480 |
(atac 1),
|
|
481 |
(rtac refl 1),
|
|
482 |
(rtac (hoare_lemma21 RS ssubst) 1),
|
|
483 |
(atac 1),
|
|
484 |
(rtac (hoare_lemma21 RS ssubst) 1),
|
|
485 |
(atac 1),
|
|
486 |
(rtac refl 1)
|
|
487 |
]);
|
|
488 |
|
|
489 |
(* ------------ ? k. ~ b1[iterate(k,g,x)] = TT ==> q o p = q ----- *)
|
|
490 |
|
|
491 |
val hoare_lemma29 = prove_goal Hoare.thy
|
|
492 |
"? k. ~ b1[iterate(k,g,x)] = TT ==> q[p[x]] = q[x]"
|
|
493 |
(fn prems =>
|
|
494 |
[
|
|
495 |
(cut_facts_tac prems 1),
|
|
496 |
(rtac (hoare_lemma5 RS disjE) 1),
|
|
497 |
(atac 1),
|
|
498 |
(rtac refl 1),
|
|
499 |
(rtac (hoare_lemma11 RS mp RS ssubst) 1),
|
|
500 |
(atac 1),
|
|
501 |
(rtac conjI 1),
|
|
502 |
(rtac refl 1),
|
|
503 |
(atac 1),
|
|
504 |
(rtac (hoare_lemma26 RS mp RS subst) 1),
|
|
505 |
(atac 1),
|
|
506 |
(rtac conjI 1),
|
|
507 |
(rtac refl 1),
|
|
508 |
(atac 1),
|
|
509 |
(rtac refl 1),
|
|
510 |
(rtac (hoare_lemma12 RS mp RS ssubst) 1),
|
|
511 |
(atac 1),
|
|
512 |
(rtac conjI 1),
|
|
513 |
(rtac refl 1),
|
|
514 |
(atac 1),
|
|
515 |
(rtac (hoare_lemma22 RS ssubst) 1),
|
|
516 |
(rtac (hoare_lemma28 RS ssubst) 1),
|
|
517 |
(atac 1),
|
|
518 |
(rtac refl 1),
|
|
519 |
(rtac sym 1),
|
|
520 |
(rtac (hoare_lemma27 RS mp RS ssubst) 1),
|
|
521 |
(atac 1),
|
|
522 |
(rtac conjI 1),
|
|
523 |
(rtac refl 1),
|
|
524 |
(atac 1),
|
|
525 |
(rtac refl 1)
|
|
526 |
]);
|
|
527 |
|
|
528 |
(* ------ the main prove q o p = q ------ *)
|
|
529 |
|
|
530 |
val hoare_main = prove_goal Hoare.thy "q oo p = q"
|
|
531 |
(fn prems =>
|
|
532 |
[
|
|
533 |
(rtac ext_cfun 1),
|
|
534 |
(rtac (cfcomp2 RS ssubst) 1),
|
|
535 |
(rtac (hoare_lemma3 RS disjE) 1),
|
|
536 |
(etac hoare_lemma23 1),
|
|
537 |
(etac hoare_lemma29 1)
|
|
538 |
]);
|
|
539 |
|
|
540 |
|