8 |
8 |
9 (* ------------------------------------------------------------------------ *) |
9 (* ------------------------------------------------------------------------ *) |
10 (* derive inductive properties of iterate from primitive recursion *) |
10 (* derive inductive properties of iterate from primitive recursion *) |
11 (* ------------------------------------------------------------------------ *) |
11 (* ------------------------------------------------------------------------ *) |
12 |
12 |
13 Goal "iterate (Suc n) F x = iterate n F (F`x)"; |
13 Goal "iterate (Suc n) F x = iterate n F (F$x)"; |
14 by (induct_tac "n" 1); |
14 by (induct_tac "n" 1); |
15 by Auto_tac; |
15 by Auto_tac; |
16 qed "iterate_Suc2"; |
16 qed "iterate_Suc2"; |
17 |
17 |
18 (* ------------------------------------------------------------------------ *) |
18 (* ------------------------------------------------------------------------ *) |
19 (* the sequence of function itertaions is a chain *) |
19 (* the sequence of function itertaions is a chain *) |
20 (* This property is essential since monotonicity of iterate makes no sense *) |
20 (* This property is essential since monotonicity of iterate makes no sense *) |
21 (* ------------------------------------------------------------------------ *) |
21 (* ------------------------------------------------------------------------ *) |
22 |
22 |
23 Goalw [chain] "x << F`x ==> chain (%i. iterate i F x)"; |
23 Goalw [chain] "x << F$x ==> chain (%i. iterate i F x)"; |
24 by (strip_tac 1); |
24 by (strip_tac 1); |
25 by (induct_tac "i" 1); |
25 by (induct_tac "i" 1); |
26 by Auto_tac; |
26 by Auto_tac; |
27 by (etac monofun_cfun_arg 1); |
27 by (etac monofun_cfun_arg 1); |
28 qed "chain_iterate2"; |
28 qed "chain_iterate2"; |
38 (* Kleene's fixed point theorems for continuous functions in pointed *) |
38 (* Kleene's fixed point theorems for continuous functions in pointed *) |
39 (* omega cpo's *) |
39 (* omega cpo's *) |
40 (* ------------------------------------------------------------------------ *) |
40 (* ------------------------------------------------------------------------ *) |
41 |
41 |
42 |
42 |
43 Goalw [Ifix_def] "Ifix F =F`(Ifix F)"; |
43 Goalw [Ifix_def] "Ifix F =F$(Ifix F)"; |
44 by (stac contlub_cfun_arg 1); |
44 by (stac contlub_cfun_arg 1); |
45 by (rtac chain_iterate 1); |
45 by (rtac chain_iterate 1); |
46 by (rtac antisym_less 1); |
46 by (rtac antisym_less 1); |
47 by (rtac lub_mono 1); |
47 by (rtac lub_mono 1); |
48 by (rtac chain_iterate 1); |
48 by (rtac chain_iterate 1); |
59 by (rtac is_ub_thelub 1); |
59 by (rtac is_ub_thelub 1); |
60 by (rtac chain_iterate 1); |
60 by (rtac chain_iterate 1); |
61 qed "Ifix_eq"; |
61 qed "Ifix_eq"; |
62 |
62 |
63 |
63 |
64 Goalw [Ifix_def] "F`x=x ==> Ifix(F) << x"; |
64 Goalw [Ifix_def] "F$x=x ==> Ifix(F) << x"; |
65 by (rtac is_lub_thelub 1); |
65 by (rtac is_lub_thelub 1); |
66 by (rtac chain_iterate 1); |
66 by (rtac chain_iterate 1); |
67 by (rtac ub_rangeI 1); |
67 by (rtac ub_rangeI 1); |
68 by (strip_tac 1); |
68 by (strip_tac 1); |
69 by (induct_tac "i" 1); |
69 by (induct_tac "i" 1); |
248 |
248 |
249 (* ------------------------------------------------------------------------ *) |
249 (* ------------------------------------------------------------------------ *) |
250 (* propagate properties of Ifix to its continuous counterpart *) |
250 (* propagate properties of Ifix to its continuous counterpart *) |
251 (* ------------------------------------------------------------------------ *) |
251 (* ------------------------------------------------------------------------ *) |
252 |
252 |
253 Goalw [fix_def] "fix`F = F`(fix`F)"; |
253 Goalw [fix_def] "fix$F = F$(fix$F)"; |
254 by (asm_simp_tac (simpset() addsimps [cont_Ifix]) 1); |
254 by (asm_simp_tac (simpset() addsimps [cont_Ifix]) 1); |
255 by (rtac Ifix_eq 1); |
255 by (rtac Ifix_eq 1); |
256 qed "fix_eq"; |
256 qed "fix_eq"; |
257 |
257 |
258 Goalw [fix_def] "F`x = x ==> fix`F << x"; |
258 Goalw [fix_def] "F$x = x ==> fix$F << x"; |
259 by (asm_simp_tac (simpset() addsimps [cont_Ifix]) 1); |
259 by (asm_simp_tac (simpset() addsimps [cont_Ifix]) 1); |
260 by (etac Ifix_least 1); |
260 by (etac Ifix_least 1); |
261 qed "fix_least"; |
261 qed "fix_least"; |
262 |
262 |
263 |
263 |
264 Goal |
264 Goal |
265 "[| F`x = x; !z. F`z = z --> x << z |] ==> x = fix`F"; |
265 "[| F$x = x; !z. F$z = z --> x << z |] ==> x = fix$F"; |
266 by (rtac antisym_less 1); |
266 by (rtac antisym_less 1); |
267 by (etac allE 1); |
267 by (etac allE 1); |
268 by (etac mp 1); |
268 by (etac mp 1); |
269 by (rtac (fix_eq RS sym) 1); |
269 by (rtac (fix_eq RS sym) 1); |
270 by (etac fix_least 1); |
270 by (etac fix_least 1); |
271 qed "fix_eqI"; |
271 qed "fix_eqI"; |
272 |
272 |
273 |
273 |
274 Goal "f == fix`F ==> f = F`f"; |
274 Goal "f == fix$F ==> f = F$f"; |
275 by (asm_simp_tac (simpset() addsimps [fix_eq RS sym]) 1); |
275 by (asm_simp_tac (simpset() addsimps [fix_eq RS sym]) 1); |
276 qed "fix_eq2"; |
276 qed "fix_eq2"; |
277 |
277 |
278 Goal "f == fix`F ==> f`x = F`f`x"; |
278 Goal "f == fix$F ==> f$x = F$f$x"; |
279 by (etac (fix_eq2 RS cfun_fun_cong) 1); |
279 by (etac (fix_eq2 RS cfun_fun_cong) 1); |
280 qed "fix_eq3"; |
280 qed "fix_eq3"; |
281 |
281 |
282 fun fix_tac3 thm i = ((rtac trans i) THEN (rtac (thm RS fix_eq3) i)); |
282 fun fix_tac3 thm i = ((rtac trans i) THEN (rtac (thm RS fix_eq3) i)); |
283 |
283 |
284 Goal "f = fix`F ==> f = F`f"; |
284 Goal "f = fix$F ==> f = F$f"; |
285 by (hyp_subst_tac 1); |
285 by (hyp_subst_tac 1); |
286 by (rtac fix_eq 1); |
286 by (rtac fix_eq 1); |
287 qed "fix_eq4"; |
287 qed "fix_eq4"; |
288 |
288 |
289 Goal "f = fix`F ==> f`x = F`f`x"; |
289 Goal "f = fix$F ==> f$x = F$f$x"; |
290 by (rtac trans 1); |
290 by (rtac trans 1); |
291 by (etac (fix_eq4 RS cfun_fun_cong) 1); |
291 by (etac (fix_eq4 RS cfun_fun_cong) 1); |
292 by (rtac refl 1); |
292 by (rtac refl 1); |
293 qed "fix_eq5"; |
293 qed "fix_eq5"; |
294 |
294 |
295 fun fix_tac5 thm i = ((rtac trans i) THEN (rtac (thm RS fix_eq5) i)); |
295 fun fix_tac5 thm i = ((rtac trans i) THEN (rtac (thm RS fix_eq5) i)); |
296 |
296 |
297 (* proves the unfolding theorem for function equations f = fix`... *) |
297 (* proves the unfolding theorem for function equations f = fix$... *) |
298 fun fix_prover thy fixeq s = prove_goal thy s (fn prems => [ |
298 fun fix_prover thy fixeq s = prove_goal thy s (fn prems => [ |
299 (rtac trans 1), |
299 (rtac trans 1), |
300 (rtac (fixeq RS fix_eq4) 1), |
300 (rtac (fixeq RS fix_eq4) 1), |
301 (rtac trans 1), |
301 (rtac trans 1), |
302 (rtac beta_cfun 1), |
302 (rtac beta_cfun 1), |
303 (Simp_tac 1) |
303 (Simp_tac 1) |
304 ]); |
304 ]); |
305 |
305 |
306 (* proves the unfolding theorem for function definitions f == fix`... *) |
306 (* proves the unfolding theorem for function definitions f == fix$... *) |
307 fun fix_prover2 thy fixdef s = prove_goal thy s (fn prems => [ |
307 fun fix_prover2 thy fixdef s = prove_goal thy s (fn prems => [ |
308 (rtac trans 1), |
308 (rtac trans 1), |
309 (rtac (fix_eq2) 1), |
309 (rtac (fix_eq2) 1), |
310 (rtac fixdef 1), |
310 (rtac fixdef 1), |
311 (rtac beta_cfun 1), |
311 (rtac beta_cfun 1), |
333 |
333 |
334 (* ------------------------------------------------------------------------ *) |
334 (* ------------------------------------------------------------------------ *) |
335 (* direct connection between fix and iteration without Ifix *) |
335 (* direct connection between fix and iteration without Ifix *) |
336 (* ------------------------------------------------------------------------ *) |
336 (* ------------------------------------------------------------------------ *) |
337 |
337 |
338 Goalw [fix_def] "fix`F = lub(range(%i. iterate i F UU))"; |
338 Goalw [fix_def] "fix$F = lub(range(%i. iterate i F UU))"; |
339 by (fold_goals_tac [Ifix_def]); |
339 by (fold_goals_tac [Ifix_def]); |
340 by (asm_simp_tac (simpset() addsimps [cont_Ifix]) 1); |
340 by (asm_simp_tac (simpset() addsimps [cont_Ifix]) 1); |
341 qed "fix_def2"; |
341 qed "fix_def2"; |
342 |
342 |
343 |
343 |
377 (* ------------------------------------------------------------------------ *) |
377 (* ------------------------------------------------------------------------ *) |
378 (* fixed point induction *) |
378 (* fixed point induction *) |
379 (* ------------------------------------------------------------------------ *) |
379 (* ------------------------------------------------------------------------ *) |
380 |
380 |
381 val major::prems = Goal |
381 val major::prems = Goal |
382 "[| adm(P); P(UU); !!x. P(x) ==> P(F`x)|] ==> P(fix`F)"; |
382 "[| adm(P); P(UU); !!x. P(x) ==> P(F$x)|] ==> P(fix$F)"; |
383 by (stac fix_def2 1); |
383 by (stac fix_def2 1); |
384 by (rtac (major RS admD) 1); |
384 by (rtac (major RS admD) 1); |
385 by (rtac chain_iterate 1); |
385 by (rtac chain_iterate 1); |
386 by (rtac allI 1); |
386 by (rtac allI 1); |
387 by (induct_tac "i" 1); |
387 by (induct_tac "i" 1); |
388 by (asm_simp_tac (simpset() addsimps (iterate_0::prems)) 1); |
388 by (asm_simp_tac (simpset() addsimps (iterate_0::prems)) 1); |
389 by (asm_simp_tac (simpset() addsimps (iterate_Suc::prems)) 1); |
389 by (asm_simp_tac (simpset() addsimps (iterate_Suc::prems)) 1); |
390 qed "fix_ind"; |
390 qed "fix_ind"; |
391 |
391 |
392 val prems = Goal "[| f == fix`F; adm(P); \ |
392 val prems = Goal "[| f == fix$F; adm(P); \ |
393 \ P(UU); !!x. P(x) ==> P(F`x)|] ==> P f"; |
393 \ P(UU); !!x. P(x) ==> P(F$x)|] ==> P f"; |
394 by (cut_facts_tac prems 1); |
394 by (cut_facts_tac prems 1); |
395 by (asm_simp_tac HOL_ss 1); |
395 by (asm_simp_tac HOL_ss 1); |
396 by (etac fix_ind 1); |
396 by (etac fix_ind 1); |
397 by (atac 1); |
397 by (atac 1); |
398 by (eresolve_tac prems 1); |
398 by (eresolve_tac prems 1); |
400 |
400 |
401 (* ------------------------------------------------------------------------ *) |
401 (* ------------------------------------------------------------------------ *) |
402 (* computational induction for weak admissible formulae *) |
402 (* computational induction for weak admissible formulae *) |
403 (* ------------------------------------------------------------------------ *) |
403 (* ------------------------------------------------------------------------ *) |
404 |
404 |
405 Goal "[| admw(P); !n. P(iterate n F UU)|] ==> P(fix`F)"; |
405 Goal "[| admw(P); !n. P(iterate n F UU)|] ==> P(fix$F)"; |
406 by (stac fix_def2 1); |
406 by (stac fix_def2 1); |
407 by (rtac (admw_def2 RS iffD1 RS spec RS mp) 1); |
407 by (rtac (admw_def2 RS iffD1 RS spec RS mp) 1); |
408 by (atac 1); |
408 by (atac 1); |
409 by (rtac allI 1); |
409 by (rtac allI 1); |
410 by (etac spec 1); |
410 by (etac spec 1); |
411 qed "wfix_ind"; |
411 qed "wfix_ind"; |
412 |
412 |
413 Goal "[| f == fix`F; admw(P); \ |
413 Goal "[| f == fix$F; admw(P); \ |
414 \ !n. P(iterate n F UU) |] ==> P f"; |
414 \ !n. P(iterate n F UU) |] ==> P f"; |
415 by (asm_simp_tac HOL_ss 1); |
415 by (asm_simp_tac HOL_ss 1); |
416 by (etac wfix_ind 1); |
416 by (etac wfix_ind 1); |
417 by (atac 1); |
417 by (atac 1); |
418 qed "def_wfix_ind"; |
418 qed "def_wfix_ind"; |
438 |
438 |
439 (* ------------------------------------------------------------------------ *) |
439 (* ------------------------------------------------------------------------ *) |
440 (* some lemmata for functions with flat/chfin domain/range types *) |
440 (* some lemmata for functions with flat/chfin domain/range types *) |
441 (* ------------------------------------------------------------------------ *) |
441 (* ------------------------------------------------------------------------ *) |
442 |
442 |
443 val _ = goalw thy [adm_def] "adm (%(u::'a::cpo->'b::chfin). P(u`s))"; |
443 val _ = goalw thy [adm_def] "adm (%(u::'a::cpo->'b::chfin). P(u$s))"; |
444 by (strip_tac 1); |
444 by (strip_tac 1); |
445 by (dtac chfin_Rep_CFunR 1); |
445 by (dtac chfin_Rep_CFunR 1); |
446 by (eres_inst_tac [("x","s")] allE 1); |
446 by (eres_inst_tac [("x","s")] allE 1); |
447 by (fast_tac (HOL_cs addss (simpset() addsimps [chfin])) 1); |
447 by (fast_tac (HOL_cs addss (simpset() addsimps [chfin])) 1); |
448 qed "adm_chfindom"; |
448 qed "adm_chfindom"; |