author | wenzelm |
Wed, 05 Dec 2001 03:13:57 +0100 | |
changeset 12378 | 86c58273f8c0 |
parent 11335 | c150861633da |
child 14169 | 0590de71a016 |
permissions | -rw-r--r-- |
9422 | 1 |
(* Title: HOL/Gfp.ML |
923 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
923 | 4 |
Copyright 1993 University of Cambridge |
5 |
||
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5069
diff
changeset
|
6 |
The Knaster-Tarski Theorem for greatest fixed points. |
923 | 7 |
*) |
8 |
||
9 |
(*** Proof of Knaster-Tarski Theorem using gfp ***) |
|
10 |
||
11 |
(* gfp(f) is the least upper bound of {u. u <= f(u)} *) |
|
12 |
||
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5069
diff
changeset
|
13 |
Goalw [gfp_def] "[| X <= f(X) |] ==> X <= gfp(f)"; |
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5069
diff
changeset
|
14 |
by (etac (CollectI RS Union_upper) 1); |
923 | 15 |
qed "gfp_upperbound"; |
16 |
||
10067 | 17 |
val prems = Goalw [gfp_def] |
923 | 18 |
"[| !!u. u <= f(u) ==> u<=X |] ==> gfp(f) <= X"; |
19 |
by (REPEAT (ares_tac ([Union_least]@prems) 1)); |
|
20 |
by (etac CollectD 1); |
|
21 |
qed "gfp_least"; |
|
22 |
||
5316 | 23 |
Goal "mono(f) ==> gfp(f) <= f(gfp(f))"; |
923 | 24 |
by (EVERY1 [rtac gfp_least, rtac subset_trans, atac, |
5316 | 25 |
etac monoD, rtac gfp_upperbound, atac]); |
923 | 26 |
qed "gfp_lemma2"; |
27 |
||
5316 | 28 |
Goal "mono(f) ==> f(gfp(f)) <= gfp(f)"; |
29 |
by (EVERY1 [rtac gfp_upperbound, rtac monoD, assume_tac, |
|
30 |
etac gfp_lemma2]); |
|
923 | 31 |
qed "gfp_lemma3"; |
32 |
||
5316 | 33 |
Goal "mono(f) ==> gfp(f) = f(gfp(f))"; |
34 |
by (REPEAT (ares_tac [equalityI,gfp_lemma2,gfp_lemma3] 1)); |
|
10186 | 35 |
qed "gfp_unfold"; |
923 | 36 |
|
37 |
(*** Coinduction rules for greatest fixed points ***) |
|
38 |
||
39 |
(*weak version*) |
|
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5069
diff
changeset
|
40 |
Goal "[| a: X; X <= f(X) |] ==> a : gfp(f)"; |
923 | 41 |
by (rtac (gfp_upperbound RS subsetD) 1); |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5069
diff
changeset
|
42 |
by Auto_tac; |
923 | 43 |
qed "weak_coinduct"; |
44 |
||
11335 | 45 |
Goal "!!X. [| a : X; g`X <= f (g`X) |] ==> g a : gfp f"; |
46 |
by (etac (gfp_upperbound RS subsetD) 1); |
|
47 |
by (etac imageI 1); |
|
48 |
qed "weak_coinduct_image"; |
|
49 |
||
10067 | 50 |
Goal "[| X <= f(X Un gfp(f)); mono(f) |] ==> \ |
923 | 51 |
\ X Un gfp(f) <= f(X Un gfp(f))"; |
10067 | 52 |
by (blast_tac (claset() addDs [gfp_lemma2, mono_Un]) 1); |
923 | 53 |
qed "coinduct_lemma"; |
54 |
||
55 |
(*strong version, thanks to Coen & Frost*) |
|
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5069
diff
changeset
|
56 |
Goal "[| mono(f); a: X; X <= f(X Un gfp(f)) |] ==> a : gfp(f)"; |
923 | 57 |
by (rtac (coinduct_lemma RSN (2, weak_coinduct)) 1); |
58 |
by (REPEAT (ares_tac [UnI1, Un_least] 1)); |
|
59 |
qed "coinduct"; |
|
60 |
||
10067 | 61 |
Goal "[| mono(f); a: gfp(f) |] ==> a: f(X Un gfp(f))"; |
62 |
by (blast_tac (claset() addDs [gfp_lemma2, mono_Un]) 1); |
|
923 | 63 |
qed "gfp_fun_UnI2"; |
64 |
||
65 |
(*** Even Stronger version of coinduct [by Martin Coen] |
|
66 |
- instead of the condition X <= f(X) |
|
67 |
consider X <= (f(X) Un f(f(X)) ...) Un gfp(X) ***) |
|
68 |
||
5316 | 69 |
Goal "mono(f) ==> mono(%x. f(x) Un X Un B)"; |
70 |
by (REPEAT (ares_tac [subset_refl, monoI, Un_mono] 1 ORELSE etac monoD 1)); |
|
923 | 71 |
qed "coinduct3_mono_lemma"; |
72 |
||
10067 | 73 |
Goal "[| X <= f(lfp(%x. f(x) Un X Un gfp(f))); mono(f) |] ==> \ |
3842 | 74 |
\ lfp(%x. f(x) Un X Un gfp(f)) <= f(lfp(%x. f(x) Un X Un gfp(f)))"; |
923 | 75 |
by (rtac subset_trans 1); |
10067 | 76 |
by (etac (coinduct3_mono_lemma RS lfp_lemma3) 1); |
923 | 77 |
by (rtac (Un_least RS Un_least) 1); |
78 |
by (rtac subset_refl 1); |
|
10067 | 79 |
by (assume_tac 1); |
10186 | 80 |
by (rtac (gfp_unfold RS equalityD1 RS subset_trans) 1); |
10067 | 81 |
by (assume_tac 1); |
82 |
by (rtac monoD 1 THEN assume_tac 1); |
|
10186 | 83 |
by (stac (coinduct3_mono_lemma RS lfp_unfold) 1); |
10067 | 84 |
by Auto_tac; |
923 | 85 |
qed "coinduct3_lemma"; |
86 |
||
5316 | 87 |
Goal |
88 |
"[| mono(f); a:X; X <= f(lfp(%x. f(x) Un X Un gfp(f))) |] ==> a : gfp(f)"; |
|
923 | 89 |
by (rtac (coinduct3_lemma RSN (2,weak_coinduct)) 1); |
10186 | 90 |
by (resolve_tac [coinduct3_mono_lemma RS lfp_unfold RS ssubst] 1); |
5316 | 91 |
by Auto_tac; |
923 | 92 |
qed "coinduct3"; |
93 |
||
94 |
||
10186 | 95 |
(** Definition forms of gfp_unfold and coinduct, to control unfolding **) |
923 | 96 |
|
10067 | 97 |
Goal "[| A==gfp(f); mono(f) |] ==> A = f(A)"; |
10186 | 98 |
by (auto_tac (claset() addSIs [gfp_unfold], simpset())); |
99 |
qed "def_gfp_unfold"; |
|
923 | 100 |
|
10067 | 101 |
Goal "[| A==gfp(f); mono(f); a:X; X <= f(X Un A) |] ==> a: A"; |
102 |
by (auto_tac (claset() addSIs [coinduct], simpset())); |
|
923 | 103 |
qed "def_coinduct"; |
104 |
||
105 |
(*The version used in the induction/coinduction package*) |
|
5316 | 106 |
val prems = Goal |
923 | 107 |
"[| A == gfp(%w. Collect(P(w))); mono(%w. Collect(P(w))); \ |
108 |
\ a: X; !!z. z: X ==> P (X Un A) z |] ==> \ |
|
109 |
\ a : A"; |
|
110 |
by (rtac def_coinduct 1); |
|
111 |
by (REPEAT (ares_tac (prems @ [subsetI,CollectI]) 1)); |
|
112 |
qed "def_Collect_coinduct"; |
|
113 |
||
10067 | 114 |
Goal "[| A==gfp(f); mono(f); a:X; X <= f(lfp(%x. f(x) Un X Un A)) |] \ |
115 |
\ ==> a: A"; |
|
116 |
by (auto_tac (claset() addSIs [coinduct3], simpset())); |
|
923 | 117 |
qed "def_coinduct3"; |
118 |
||
119 |
(*Monotonicity of gfp!*) |
|
5316 | 120 |
val [prem] = Goal "[| !!Z. f(Z)<=g(Z) |] ==> gfp(f) <= gfp(g)"; |
1465 | 121 |
by (rtac (gfp_upperbound RS gfp_least) 1); |
122 |
by (etac (prem RSN (2,subset_trans)) 1); |
|
923 | 123 |
qed "gfp_mono"; |