author | wenzelm |
Tue, 14 Mar 2006 22:06:42 +0100 | |
changeset 19271 | 967e6c2578f2 |
parent 17456 | bcf7544875b2 |
permissions | -rw-r--r-- |
17456 | 1 |
(* Title: CCL/Gfp.ML |
0 | 2 |
ID: $Id$ |
3 |
*) |
|
4 |
||
5 |
(*** Proof of Knaster-Tarski Theorem using gfp ***) |
|
6 |
||
7 |
(* gfp(f) is the least upper bound of {u. u <= f(u)} *) |
|
8 |
||
17456 | 9 |
val prems = goalw (the_context ()) [gfp_def] "[| A <= f(A) |] ==> A <= gfp(f)"; |
0 | 10 |
by (rtac (CollectI RS Union_upper) 1); |
11 |
by (resolve_tac prems 1); |
|
757 | 12 |
qed "gfp_upperbound"; |
0 | 13 |
|
17456 | 14 |
val prems = goalw (the_context ()) [gfp_def] |
0 | 15 |
"[| !!u. u <= f(u) ==> u<=A |] ==> gfp(f) <= A"; |
16 |
by (REPEAT (ares_tac ([Union_least]@prems) 1)); |
|
17 |
by (etac CollectD 1); |
|
757 | 18 |
qed "gfp_least"; |
0 | 19 |
|
17456 | 20 |
val [mono] = goal (the_context ()) "mono(f) ==> gfp(f) <= f(gfp(f))"; |
0 | 21 |
by (EVERY1 [rtac gfp_least, rtac subset_trans, atac, |
1459 | 22 |
rtac (mono RS monoD), rtac gfp_upperbound, atac]); |
757 | 23 |
qed "gfp_lemma2"; |
0 | 24 |
|
17456 | 25 |
val [mono] = goal (the_context ()) "mono(f) ==> f(gfp(f)) <= gfp(f)"; |
0 | 26 |
by (EVERY1 [rtac gfp_upperbound, rtac (mono RS monoD), |
1459 | 27 |
rtac gfp_lemma2, rtac mono]); |
757 | 28 |
qed "gfp_lemma3"; |
0 | 29 |
|
17456 | 30 |
val [mono] = goal (the_context ()) "mono(f) ==> gfp(f) = f(gfp(f))"; |
0 | 31 |
by (REPEAT (resolve_tac [equalityI,gfp_lemma2,gfp_lemma3,mono] 1)); |
757 | 32 |
qed "gfp_Tarski"; |
0 | 33 |
|
34 |
(*** Coinduction rules for greatest fixed points ***) |
|
35 |
||
36 |
(*weak version*) |
|
17456 | 37 |
val prems = goal (the_context ()) |
0 | 38 |
"[| a: A; A <= f(A) |] ==> a : gfp(f)"; |
39 |
by (rtac (gfp_upperbound RS subsetD) 1); |
|
40 |
by (REPEAT (ares_tac prems 1)); |
|
757 | 41 |
qed "coinduct"; |
0 | 42 |
|
17456 | 43 |
val [prem,mono] = goal (the_context ()) |
0 | 44 |
"[| A <= f(A) Un gfp(f); mono(f) |] ==> \ |
45 |
\ A Un gfp(f) <= f(A Un gfp(f))"; |
|
46 |
by (rtac subset_trans 1); |
|
47 |
by (rtac (mono RS mono_Un) 2); |
|
48 |
by (rtac (mono RS gfp_Tarski RS subst) 1); |
|
49 |
by (rtac (prem RS Un_least) 1); |
|
50 |
by (rtac Un_upper2 1); |
|
757 | 51 |
qed "coinduct2_lemma"; |
0 | 52 |
|
53 |
(*strong version, thanks to Martin Coen*) |
|
17456 | 54 |
val ainA::prems = goal (the_context ()) |
0 | 55 |
"[| a: A; A <= f(A) Un gfp(f); mono(f) |] ==> a : gfp(f)"; |
642
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
56 |
by (rtac coinduct 1); |
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
57 |
by (rtac (prems MRS coinduct2_lemma) 2); |
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
58 |
by (resolve_tac [ainA RS UnI1] 1); |
757 | 59 |
qed "coinduct2"; |
0 | 60 |
|
61 |
(*** Even Stronger version of coinduct [by Martin Coen] |
|
62 |
- instead of the condition A <= f(A) |
|
63 |
consider A <= (f(A) Un f(f(A)) ...) Un gfp(A) ***) |
|
64 |
||
17456 | 65 |
val [prem] = goal (the_context ()) "mono(f) ==> mono(%x. f(x) Un A Un B)"; |
0 | 66 |
by (REPEAT (ares_tac [subset_refl, monoI, Un_mono, prem RS monoD] 1)); |
757 | 67 |
qed "coinduct3_mono_lemma"; |
0 | 68 |
|
17456 | 69 |
val [prem,mono] = goal (the_context ()) |
3837 | 70 |
"[| A <= f(lfp(%x. f(x) Un A Un gfp(f))); mono(f) |] ==> \ |
71 |
\ lfp(%x. f(x) Un A Un gfp(f)) <= f(lfp(%x. f(x) Un A Un gfp(f)))"; |
|
0 | 72 |
by (rtac subset_trans 1); |
642
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
73 |
by (rtac (mono RS coinduct3_mono_lemma RS lfp_lemma3) 1); |
0 | 74 |
by (rtac (Un_least RS Un_least) 1); |
642
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
75 |
by (rtac subset_refl 1); |
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
76 |
by (rtac prem 1); |
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
77 |
by (rtac (mono RS gfp_Tarski RS equalityD1 RS subset_trans) 1); |
0 | 78 |
by (rtac (mono RS monoD) 1); |
2035 | 79 |
by (stac (mono RS coinduct3_mono_lemma RS lfp_Tarski) 1); |
0 | 80 |
by (rtac Un_upper2 1); |
757 | 81 |
qed "coinduct3_lemma"; |
0 | 82 |
|
17456 | 83 |
val ainA::prems = goal (the_context ()) |
3837 | 84 |
"[| a:A; A <= f(lfp(%x. f(x) Un A Un gfp(f))); mono(f) |] ==> a : gfp(f)"; |
642
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
85 |
by (rtac coinduct 1); |
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
86 |
by (rtac (prems MRS coinduct3_lemma) 2); |
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
87 |
by (resolve_tac (prems RL [coinduct3_mono_lemma RS lfp_Tarski RS ssubst]) 1); |
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
0
diff
changeset
|
88 |
by (rtac (ainA RS UnI2 RS UnI1) 1); |
757 | 89 |
qed "coinduct3"; |
0 | 90 |
|
91 |
||
92 |
(** Definition forms of gfp_Tarski, to control unfolding **) |
|
93 |
||
17456 | 94 |
val [rew,mono] = goal (the_context ()) "[| h==gfp(f); mono(f) |] ==> h = f(h)"; |
0 | 95 |
by (rewtac rew); |
96 |
by (rtac (mono RS gfp_Tarski) 1); |
|
757 | 97 |
qed "def_gfp_Tarski"; |
0 | 98 |
|
17456 | 99 |
val rew::prems = goal (the_context ()) |
0 | 100 |
"[| h==gfp(f); a:A; A <= f(A) |] ==> a: h"; |
101 |
by (rewtac rew); |
|
102 |
by (REPEAT (ares_tac (prems @ [coinduct]) 1)); |
|
757 | 103 |
qed "def_coinduct"; |
0 | 104 |
|
17456 | 105 |
val rew::prems = goal (the_context ()) |
0 | 106 |
"[| h==gfp(f); a:A; A <= f(A) Un h; mono(f) |] ==> a: h"; |
107 |
by (rewtac rew); |
|
108 |
by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems @ [coinduct2]) 1)); |
|
757 | 109 |
qed "def_coinduct2"; |
0 | 110 |
|
17456 | 111 |
val rew::prems = goal (the_context ()) |
3837 | 112 |
"[| h==gfp(f); a:A; A <= f(lfp(%x. f(x) Un A Un h)); mono(f) |] ==> a: h"; |
0 | 113 |
by (rewtac rew); |
114 |
by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems @ [coinduct3]) 1)); |
|
757 | 115 |
qed "def_coinduct3"; |
0 | 116 |
|
117 |
(*Monotonicity of gfp!*) |
|
17456 | 118 |
val prems = goal (the_context ()) |
0 | 119 |
"[| mono(f); !!Z. f(Z)<=g(Z) |] ==> gfp(f) <= gfp(g)"; |
120 |
by (rtac gfp_upperbound 1); |
|
121 |
by (rtac subset_trans 1); |
|
122 |
by (rtac gfp_lemma2 1); |
|
123 |
by (resolve_tac prems 1); |
|
124 |
by (resolve_tac prems 1); |
|
757 | 125 |
qed "gfp_mono"; |