integrated FixedPoint into Inductive
authorhaftmann
Mon Oct 08 22:03:25 2007 +0200 (2007-10-08)
changeset 24915fc90277c0dd7
parent 24914 95cda5dd58d5
child 24916 dc56dd1b3cda
integrated FixedPoint into Inductive
src/HOL/FixedPoint.thy
src/HOL/Inductive.thy
src/HOL/IsaMakefile
src/HOL/Relation.thy
src/HOL/Tools/inductive_package.ML
     1.1 --- a/src/HOL/FixedPoint.thy	Mon Oct 08 22:03:21 2007 +0200
     1.2 +++ b/src/HOL/FixedPoint.thy	Mon Oct 08 22:03:25 2007 +0200
     1.3 @@ -1,273 +0,0 @@
     1.4 -(*  Title:      HOL/FixedPoint.thy
     1.5 -    ID:         $Id$
     1.6 -    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     1.7 -    Author:     Stefan Berghofer, TU Muenchen
     1.8 -    Copyright   1992  University of Cambridge
     1.9 -*)
    1.10 -
    1.11 -header {* Fixed Points and the Knaster-Tarski Theorem*}
    1.12 -
    1.13 -theory FixedPoint
    1.14 -imports Lattices
    1.15 -begin
    1.16 -
    1.17 -subsection {* Least and greatest fixed points *}
    1.18 -
    1.19 -definition
    1.20 -  lfp :: "('a\<Colon>complete_lattice \<Rightarrow> 'a) \<Rightarrow> 'a" where
    1.21 -  "lfp f = Inf {u. f u \<le> u}"    --{*least fixed point*}
    1.22 -
    1.23 -definition
    1.24 -  gfp :: "('a\<Colon>complete_lattice \<Rightarrow> 'a) \<Rightarrow> 'a" where
    1.25 -  "gfp f = Sup {u. u \<le> f u}"    --{*greatest fixed point*}
    1.26 -
    1.27 -
    1.28 -subsection{* Proof of Knaster-Tarski Theorem using @{term lfp} *}
    1.29 -
    1.30 -text{*@{term "lfp f"} is the least upper bound of 
    1.31 -      the set @{term "{u. f(u) \<le> u}"} *}
    1.32 -
    1.33 -lemma lfp_lowerbound: "f A \<le> A ==> lfp f \<le> A"
    1.34 -  by (auto simp add: lfp_def intro: Inf_lower)
    1.35 -
    1.36 -lemma lfp_greatest: "(!!u. f u \<le> u ==> A \<le> u) ==> A \<le> lfp f"
    1.37 -  by (auto simp add: lfp_def intro: Inf_greatest)
    1.38 -
    1.39 -lemma lfp_lemma2: "mono f ==> f (lfp f) \<le> lfp f"
    1.40 -  by (iprover intro: lfp_greatest order_trans monoD lfp_lowerbound)
    1.41 -
    1.42 -lemma lfp_lemma3: "mono f ==> lfp f \<le> f (lfp f)"
    1.43 -  by (iprover intro: lfp_lemma2 monoD lfp_lowerbound)
    1.44 -
    1.45 -lemma lfp_unfold: "mono f ==> lfp f = f (lfp f)"
    1.46 -  by (iprover intro: order_antisym lfp_lemma2 lfp_lemma3)
    1.47 -
    1.48 -lemma lfp_const: "lfp (\<lambda>x. t) = t"
    1.49 -  by (rule lfp_unfold) (simp add:mono_def)
    1.50 -
    1.51 -
    1.52 -subsection {* General induction rules for least fixed points *}
    1.53 -
    1.54 -theorem lfp_induct:
    1.55 -  assumes mono: "mono f" and ind: "f (inf (lfp f) P) <= P"
    1.56 -  shows "lfp f <= P"
    1.57 -proof -
    1.58 -  have "inf (lfp f) P <= lfp f" by (rule inf_le1)
    1.59 -  with mono have "f (inf (lfp f) P) <= f (lfp f)" ..
    1.60 -  also from mono have "f (lfp f) = lfp f" by (rule lfp_unfold [symmetric])
    1.61 -  finally have "f (inf (lfp f) P) <= lfp f" .
    1.62 -  from this and ind have "f (inf (lfp f) P) <= inf (lfp f) P" by (rule le_infI)
    1.63 -  hence "lfp f <= inf (lfp f) P" by (rule lfp_lowerbound)
    1.64 -  also have "inf (lfp f) P <= P" by (rule inf_le2)
    1.65 -  finally show ?thesis .
    1.66 -qed
    1.67 -
    1.68 -lemma lfp_induct_set:
    1.69 -  assumes lfp: "a: lfp(f)"
    1.70 -      and mono: "mono(f)"
    1.71 -      and indhyp: "!!x. [| x: f(lfp(f) Int {x. P(x)}) |] ==> P(x)"
    1.72 -  shows "P(a)"
    1.73 -  by (rule lfp_induct [THEN subsetD, THEN CollectD, OF mono _ lfp])
    1.74 -    (auto simp: inf_set_eq intro: indhyp)
    1.75 -
    1.76 -lemma lfp_ordinal_induct: 
    1.77 -  assumes mono: "mono f"
    1.78 -  and P_f: "!!S. P S ==> P(f S)"
    1.79 -  and P_Union: "!!M. !S:M. P S ==> P(Union M)"
    1.80 -  shows "P(lfp f)"
    1.81 -proof -
    1.82 -  let ?M = "{S. S \<subseteq> lfp f & P S}"
    1.83 -  have "P (Union ?M)" using P_Union by simp
    1.84 -  also have "Union ?M = lfp f"
    1.85 -  proof
    1.86 -    show "Union ?M \<subseteq> lfp f" by blast
    1.87 -    hence "f (Union ?M) \<subseteq> f (lfp f)" by (rule mono [THEN monoD])
    1.88 -    hence "f (Union ?M) \<subseteq> lfp f" using mono [THEN lfp_unfold] by simp
    1.89 -    hence "f (Union ?M) \<in> ?M" using P_f P_Union by simp
    1.90 -    hence "f (Union ?M) \<subseteq> Union ?M" by (rule Union_upper)
    1.91 -    thus "lfp f \<subseteq> Union ?M" by (rule lfp_lowerbound)
    1.92 -  qed
    1.93 -  finally show ?thesis .
    1.94 -qed
    1.95 -
    1.96 -
    1.97 -text{*Definition forms of @{text lfp_unfold} and @{text lfp_induct}, 
    1.98 -    to control unfolding*}
    1.99 -
   1.100 -lemma def_lfp_unfold: "[| h==lfp(f);  mono(f) |] ==> h = f(h)"
   1.101 -by (auto intro!: lfp_unfold)
   1.102 -
   1.103 -lemma def_lfp_induct: 
   1.104 -    "[| A == lfp(f); mono(f);
   1.105 -        f (inf A P) \<le> P
   1.106 -     |] ==> A \<le> P"
   1.107 -  by (blast intro: lfp_induct)
   1.108 -
   1.109 -lemma def_lfp_induct_set: 
   1.110 -    "[| A == lfp(f);  mono(f);   a:A;                    
   1.111 -        !!x. [| x: f(A Int {x. P(x)}) |] ==> P(x)         
   1.112 -     |] ==> P(a)"
   1.113 -  by (blast intro: lfp_induct_set)
   1.114 -
   1.115 -(*Monotonicity of lfp!*)
   1.116 -lemma lfp_mono: "(!!Z. f Z \<le> g Z) ==> lfp f \<le> lfp g"
   1.117 -  by (rule lfp_lowerbound [THEN lfp_greatest], blast intro: order_trans)
   1.118 -
   1.119 -
   1.120 -subsection {* Proof of Knaster-Tarski Theorem using @{term gfp} *}
   1.121 -
   1.122 -text{*@{term "gfp f"} is the greatest lower bound of 
   1.123 -      the set @{term "{u. u \<le> f(u)}"} *}
   1.124 -
   1.125 -lemma gfp_upperbound: "X \<le> f X ==> X \<le> gfp f"
   1.126 -  by (auto simp add: gfp_def intro: Sup_upper)
   1.127 -
   1.128 -lemma gfp_least: "(!!u. u \<le> f u ==> u \<le> X) ==> gfp f \<le> X"
   1.129 -  by (auto simp add: gfp_def intro: Sup_least)
   1.130 -
   1.131 -lemma gfp_lemma2: "mono f ==> gfp f \<le> f (gfp f)"
   1.132 -  by (iprover intro: gfp_least order_trans monoD gfp_upperbound)
   1.133 -
   1.134 -lemma gfp_lemma3: "mono f ==> f (gfp f) \<le> gfp f"
   1.135 -  by (iprover intro: gfp_lemma2 monoD gfp_upperbound)
   1.136 -
   1.137 -lemma gfp_unfold: "mono f ==> gfp f = f (gfp f)"
   1.138 -  by (iprover intro: order_antisym gfp_lemma2 gfp_lemma3)
   1.139 -
   1.140 -
   1.141 -subsection {* Coinduction rules for greatest fixed points *}
   1.142 -
   1.143 -text{*weak version*}
   1.144 -lemma weak_coinduct: "[| a: X;  X \<subseteq> f(X) |] ==> a : gfp(f)"
   1.145 -by (rule gfp_upperbound [THEN subsetD], auto)
   1.146 -
   1.147 -lemma weak_coinduct_image: "!!X. [| a : X; g`X \<subseteq> f (g`X) |] ==> g a : gfp f"
   1.148 -apply (erule gfp_upperbound [THEN subsetD])
   1.149 -apply (erule imageI)
   1.150 -done
   1.151 -
   1.152 -lemma coinduct_lemma:
   1.153 -     "[| X \<le> f (sup X (gfp f));  mono f |] ==> sup X (gfp f) \<le> f (sup X (gfp f))"
   1.154 -  apply (frule gfp_lemma2)
   1.155 -  apply (drule mono_sup)
   1.156 -  apply (rule le_supI)
   1.157 -  apply assumption
   1.158 -  apply (rule order_trans)
   1.159 -  apply (rule order_trans)
   1.160 -  apply assumption
   1.161 -  apply (rule sup_ge2)
   1.162 -  apply assumption
   1.163 -  done
   1.164 -
   1.165 -text{*strong version, thanks to Coen and Frost*}
   1.166 -lemma coinduct_set: "[| mono(f);  a: X;  X \<subseteq> f(X Un gfp(f)) |] ==> a : gfp(f)"
   1.167 -by (blast intro: weak_coinduct [OF _ coinduct_lemma, simplified sup_set_eq])
   1.168 -
   1.169 -lemma coinduct: "[| mono(f); X \<le> f (sup X (gfp f)) |] ==> X \<le> gfp(f)"
   1.170 -  apply (rule order_trans)
   1.171 -  apply (rule sup_ge1)
   1.172 -  apply (erule gfp_upperbound [OF coinduct_lemma])
   1.173 -  apply assumption
   1.174 -  done
   1.175 -
   1.176 -lemma gfp_fun_UnI2: "[| mono(f);  a: gfp(f) |] ==> a: f(X Un gfp(f))"
   1.177 -by (blast dest: gfp_lemma2 mono_Un)
   1.178 -
   1.179 -
   1.180 -subsection {* Even Stronger Coinduction Rule, by Martin Coen *}
   1.181 -
   1.182 -text{* Weakens the condition @{term "X \<subseteq> f(X)"} to one expressed using both
   1.183 -  @{term lfp} and @{term gfp}*}
   1.184 -
   1.185 -lemma coinduct3_mono_lemma: "mono(f) ==> mono(%x. f(x) Un X Un B)"
   1.186 -by (iprover intro: subset_refl monoI Un_mono monoD)
   1.187 -
   1.188 -lemma coinduct3_lemma:
   1.189 -     "[| X \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f)));  mono(f) |]
   1.190 -      ==> lfp(%x. f(x) Un X Un gfp(f)) \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f)))"
   1.191 -apply (rule subset_trans)
   1.192 -apply (erule coinduct3_mono_lemma [THEN lfp_lemma3])
   1.193 -apply (rule Un_least [THEN Un_least])
   1.194 -apply (rule subset_refl, assumption)
   1.195 -apply (rule gfp_unfold [THEN equalityD1, THEN subset_trans], assumption)
   1.196 -apply (rule monoD, assumption)
   1.197 -apply (subst coinduct3_mono_lemma [THEN lfp_unfold], auto)
   1.198 -done
   1.199 -
   1.200 -lemma coinduct3: 
   1.201 -  "[| mono(f);  a:X;  X \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f))) |] ==> a : gfp(f)"
   1.202 -apply (rule coinduct3_lemma [THEN [2] weak_coinduct])
   1.203 -apply (rule coinduct3_mono_lemma [THEN lfp_unfold, THEN ssubst], auto)
   1.204 -done
   1.205 -
   1.206 -
   1.207 -text{*Definition forms of @{text gfp_unfold} and @{text coinduct}, 
   1.208 -    to control unfolding*}
   1.209 -
   1.210 -lemma def_gfp_unfold: "[| A==gfp(f);  mono(f) |] ==> A = f(A)"
   1.211 -by (auto intro!: gfp_unfold)
   1.212 -
   1.213 -lemma def_coinduct:
   1.214 -     "[| A==gfp(f);  mono(f);  X \<le> f(sup X A) |] ==> X \<le> A"
   1.215 -by (iprover intro!: coinduct)
   1.216 -
   1.217 -lemma def_coinduct_set:
   1.218 -     "[| A==gfp(f);  mono(f);  a:X;  X \<subseteq> f(X Un A) |] ==> a: A"
   1.219 -by (auto intro!: coinduct_set)
   1.220 -
   1.221 -(*The version used in the induction/coinduction package*)
   1.222 -lemma def_Collect_coinduct:
   1.223 -    "[| A == gfp(%w. Collect(P(w)));  mono(%w. Collect(P(w)));   
   1.224 -        a: X;  !!z. z: X ==> P (X Un A) z |] ==>  
   1.225 -     a : A"
   1.226 -apply (erule def_coinduct_set, auto) 
   1.227 -done
   1.228 -
   1.229 -lemma def_coinduct3:
   1.230 -    "[| A==gfp(f); mono(f);  a:X;  X \<subseteq> f(lfp(%x. f(x) Un X Un A)) |] ==> a: A"
   1.231 -by (auto intro!: coinduct3)
   1.232 -
   1.233 -text{*Monotonicity of @{term gfp}!*}
   1.234 -lemma gfp_mono: "(!!Z. f Z \<le> g Z) ==> gfp f \<le> gfp g"
   1.235 -  by (rule gfp_upperbound [THEN gfp_least], blast intro: order_trans)
   1.236 -
   1.237 -ML
   1.238 -{*
   1.239 -val lfp_def = thm "lfp_def";
   1.240 -val lfp_lowerbound = thm "lfp_lowerbound";
   1.241 -val lfp_greatest = thm "lfp_greatest";
   1.242 -val lfp_unfold = thm "lfp_unfold";
   1.243 -val lfp_induct = thm "lfp_induct";
   1.244 -val lfp_ordinal_induct = thm "lfp_ordinal_induct";
   1.245 -val def_lfp_unfold = thm "def_lfp_unfold";
   1.246 -val def_lfp_induct = thm "def_lfp_induct";
   1.247 -val def_lfp_induct_set = thm "def_lfp_induct_set";
   1.248 -val lfp_mono = thm "lfp_mono";
   1.249 -val gfp_def = thm "gfp_def";
   1.250 -val gfp_upperbound = thm "gfp_upperbound";
   1.251 -val gfp_least = thm "gfp_least";
   1.252 -val gfp_unfold = thm "gfp_unfold";
   1.253 -val weak_coinduct = thm "weak_coinduct";
   1.254 -val weak_coinduct_image = thm "weak_coinduct_image";
   1.255 -val coinduct = thm "coinduct";
   1.256 -val gfp_fun_UnI2 = thm "gfp_fun_UnI2";
   1.257 -val coinduct3 = thm "coinduct3";
   1.258 -val def_gfp_unfold = thm "def_gfp_unfold";
   1.259 -val def_coinduct = thm "def_coinduct";
   1.260 -val def_Collect_coinduct = thm "def_Collect_coinduct";
   1.261 -val def_coinduct3 = thm "def_coinduct3";
   1.262 -val gfp_mono = thm "gfp_mono";
   1.263 -val le_funI = thm "le_funI";
   1.264 -val le_boolI = thm "le_boolI";
   1.265 -val le_boolI' = thm "le_boolI'";
   1.266 -val inf_fun_eq = thm "inf_fun_eq";
   1.267 -val inf_bool_eq = thm "inf_bool_eq";
   1.268 -val le_funE = thm "le_funE";
   1.269 -val le_funD = thm "le_funD";
   1.270 -val le_boolE = thm "le_boolE";
   1.271 -val le_boolD = thm "le_boolD";
   1.272 -val le_bool_def = thm "le_bool_def";
   1.273 -val le_fun_def = thm "le_fun_def";
   1.274 -*}
   1.275 -
   1.276 -end
     2.1 --- a/src/HOL/Inductive.thy	Mon Oct 08 22:03:21 2007 +0200
     2.2 +++ b/src/HOL/Inductive.thy	Mon Oct 08 22:03:25 2007 +0200
     2.3 @@ -3,10 +3,10 @@
     2.4      Author:     Markus Wenzel, TU Muenchen
     2.5  *)
     2.6  
     2.7 -header {* Support for inductive sets and types *}
     2.8 +header {* Knaster-Tarski Fixpoint Theorem and inductive definitions *}
     2.9  
    2.10  theory Inductive 
    2.11 -imports FixedPoint Sum_Type
    2.12 +imports Lattices Sum_Type
    2.13  uses
    2.14    ("Tools/inductive_package.ML")
    2.15    "Tools/dseq.ML"
    2.16 @@ -20,6 +20,227 @@
    2.17    ("Tools/primrec_package.ML")
    2.18  begin
    2.19  
    2.20 +subsection {* Least and greatest fixed points *}
    2.21 +
    2.22 +definition
    2.23 +  lfp :: "('a\<Colon>complete_lattice \<Rightarrow> 'a) \<Rightarrow> 'a" where
    2.24 +  "lfp f = Inf {u. f u \<le> u}"    --{*least fixed point*}
    2.25 +
    2.26 +definition
    2.27 +  gfp :: "('a\<Colon>complete_lattice \<Rightarrow> 'a) \<Rightarrow> 'a" where
    2.28 +  "gfp f = Sup {u. u \<le> f u}"    --{*greatest fixed point*}
    2.29 +
    2.30 +
    2.31 +subsection{* Proof of Knaster-Tarski Theorem using @{term lfp} *}
    2.32 +
    2.33 +text{*@{term "lfp f"} is the least upper bound of 
    2.34 +      the set @{term "{u. f(u) \<le> u}"} *}
    2.35 +
    2.36 +lemma lfp_lowerbound: "f A \<le> A ==> lfp f \<le> A"
    2.37 +  by (auto simp add: lfp_def intro: Inf_lower)
    2.38 +
    2.39 +lemma lfp_greatest: "(!!u. f u \<le> u ==> A \<le> u) ==> A \<le> lfp f"
    2.40 +  by (auto simp add: lfp_def intro: Inf_greatest)
    2.41 +
    2.42 +lemma lfp_lemma2: "mono f ==> f (lfp f) \<le> lfp f"
    2.43 +  by (iprover intro: lfp_greatest order_trans monoD lfp_lowerbound)
    2.44 +
    2.45 +lemma lfp_lemma3: "mono f ==> lfp f \<le> f (lfp f)"
    2.46 +  by (iprover intro: lfp_lemma2 monoD lfp_lowerbound)
    2.47 +
    2.48 +lemma lfp_unfold: "mono f ==> lfp f = f (lfp f)"
    2.49 +  by (iprover intro: order_antisym lfp_lemma2 lfp_lemma3)
    2.50 +
    2.51 +lemma lfp_const: "lfp (\<lambda>x. t) = t"
    2.52 +  by (rule lfp_unfold) (simp add:mono_def)
    2.53 +
    2.54 +
    2.55 +subsection {* General induction rules for least fixed points *}
    2.56 +
    2.57 +theorem lfp_induct:
    2.58 +  assumes mono: "mono f" and ind: "f (inf (lfp f) P) <= P"
    2.59 +  shows "lfp f <= P"
    2.60 +proof -
    2.61 +  have "inf (lfp f) P <= lfp f" by (rule inf_le1)
    2.62 +  with mono have "f (inf (lfp f) P) <= f (lfp f)" ..
    2.63 +  also from mono have "f (lfp f) = lfp f" by (rule lfp_unfold [symmetric])
    2.64 +  finally have "f (inf (lfp f) P) <= lfp f" .
    2.65 +  from this and ind have "f (inf (lfp f) P) <= inf (lfp f) P" by (rule le_infI)
    2.66 +  hence "lfp f <= inf (lfp f) P" by (rule lfp_lowerbound)
    2.67 +  also have "inf (lfp f) P <= P" by (rule inf_le2)
    2.68 +  finally show ?thesis .
    2.69 +qed
    2.70 +
    2.71 +lemma lfp_induct_set:
    2.72 +  assumes lfp: "a: lfp(f)"
    2.73 +      and mono: "mono(f)"
    2.74 +      and indhyp: "!!x. [| x: f(lfp(f) Int {x. P(x)}) |] ==> P(x)"
    2.75 +  shows "P(a)"
    2.76 +  by (rule lfp_induct [THEN subsetD, THEN CollectD, OF mono _ lfp])
    2.77 +    (auto simp: inf_set_eq intro: indhyp)
    2.78 +
    2.79 +lemma lfp_ordinal_induct: 
    2.80 +  assumes mono: "mono f"
    2.81 +  and P_f: "!!S. P S ==> P(f S)"
    2.82 +  and P_Union: "!!M. !S:M. P S ==> P(Union M)"
    2.83 +  shows "P(lfp f)"
    2.84 +proof -
    2.85 +  let ?M = "{S. S \<subseteq> lfp f & P S}"
    2.86 +  have "P (Union ?M)" using P_Union by simp
    2.87 +  also have "Union ?M = lfp f"
    2.88 +  proof
    2.89 +    show "Union ?M \<subseteq> lfp f" by blast
    2.90 +    hence "f (Union ?M) \<subseteq> f (lfp f)" by (rule mono [THEN monoD])
    2.91 +    hence "f (Union ?M) \<subseteq> lfp f" using mono [THEN lfp_unfold] by simp
    2.92 +    hence "f (Union ?M) \<in> ?M" using P_f P_Union by simp
    2.93 +    hence "f (Union ?M) \<subseteq> Union ?M" by (rule Union_upper)
    2.94 +    thus "lfp f \<subseteq> Union ?M" by (rule lfp_lowerbound)
    2.95 +  qed
    2.96 +  finally show ?thesis .
    2.97 +qed
    2.98 +
    2.99 +
   2.100 +text{*Definition forms of @{text lfp_unfold} and @{text lfp_induct}, 
   2.101 +    to control unfolding*}
   2.102 +
   2.103 +lemma def_lfp_unfold: "[| h==lfp(f);  mono(f) |] ==> h = f(h)"
   2.104 +by (auto intro!: lfp_unfold)
   2.105 +
   2.106 +lemma def_lfp_induct: 
   2.107 +    "[| A == lfp(f); mono(f);
   2.108 +        f (inf A P) \<le> P
   2.109 +     |] ==> A \<le> P"
   2.110 +  by (blast intro: lfp_induct)
   2.111 +
   2.112 +lemma def_lfp_induct_set: 
   2.113 +    "[| A == lfp(f);  mono(f);   a:A;                    
   2.114 +        !!x. [| x: f(A Int {x. P(x)}) |] ==> P(x)         
   2.115 +     |] ==> P(a)"
   2.116 +  by (blast intro: lfp_induct_set)
   2.117 +
   2.118 +(*Monotonicity of lfp!*)
   2.119 +lemma lfp_mono: "(!!Z. f Z \<le> g Z) ==> lfp f \<le> lfp g"
   2.120 +  by (rule lfp_lowerbound [THEN lfp_greatest], blast intro: order_trans)
   2.121 +
   2.122 +
   2.123 +subsection {* Proof of Knaster-Tarski Theorem using @{term gfp} *}
   2.124 +
   2.125 +text{*@{term "gfp f"} is the greatest lower bound of 
   2.126 +      the set @{term "{u. u \<le> f(u)}"} *}
   2.127 +
   2.128 +lemma gfp_upperbound: "X \<le> f X ==> X \<le> gfp f"
   2.129 +  by (auto simp add: gfp_def intro: Sup_upper)
   2.130 +
   2.131 +lemma gfp_least: "(!!u. u \<le> f u ==> u \<le> X) ==> gfp f \<le> X"
   2.132 +  by (auto simp add: gfp_def intro: Sup_least)
   2.133 +
   2.134 +lemma gfp_lemma2: "mono f ==> gfp f \<le> f (gfp f)"
   2.135 +  by (iprover intro: gfp_least order_trans monoD gfp_upperbound)
   2.136 +
   2.137 +lemma gfp_lemma3: "mono f ==> f (gfp f) \<le> gfp f"
   2.138 +  by (iprover intro: gfp_lemma2 monoD gfp_upperbound)
   2.139 +
   2.140 +lemma gfp_unfold: "mono f ==> gfp f = f (gfp f)"
   2.141 +  by (iprover intro: order_antisym gfp_lemma2 gfp_lemma3)
   2.142 +
   2.143 +
   2.144 +subsection {* Coinduction rules for greatest fixed points *}
   2.145 +
   2.146 +text{*weak version*}
   2.147 +lemma weak_coinduct: "[| a: X;  X \<subseteq> f(X) |] ==> a : gfp(f)"
   2.148 +by (rule gfp_upperbound [THEN subsetD], auto)
   2.149 +
   2.150 +lemma weak_coinduct_image: "!!X. [| a : X; g`X \<subseteq> f (g`X) |] ==> g a : gfp f"
   2.151 +apply (erule gfp_upperbound [THEN subsetD])
   2.152 +apply (erule imageI)
   2.153 +done
   2.154 +
   2.155 +lemma coinduct_lemma:
   2.156 +     "[| X \<le> f (sup X (gfp f));  mono f |] ==> sup X (gfp f) \<le> f (sup X (gfp f))"
   2.157 +  apply (frule gfp_lemma2)
   2.158 +  apply (drule mono_sup)
   2.159 +  apply (rule le_supI)
   2.160 +  apply assumption
   2.161 +  apply (rule order_trans)
   2.162 +  apply (rule order_trans)
   2.163 +  apply assumption
   2.164 +  apply (rule sup_ge2)
   2.165 +  apply assumption
   2.166 +  done
   2.167 +
   2.168 +text{*strong version, thanks to Coen and Frost*}
   2.169 +lemma coinduct_set: "[| mono(f);  a: X;  X \<subseteq> f(X Un gfp(f)) |] ==> a : gfp(f)"
   2.170 +by (blast intro: weak_coinduct [OF _ coinduct_lemma, simplified sup_set_eq])
   2.171 +
   2.172 +lemma coinduct: "[| mono(f); X \<le> f (sup X (gfp f)) |] ==> X \<le> gfp(f)"
   2.173 +  apply (rule order_trans)
   2.174 +  apply (rule sup_ge1)
   2.175 +  apply (erule gfp_upperbound [OF coinduct_lemma])
   2.176 +  apply assumption
   2.177 +  done
   2.178 +
   2.179 +lemma gfp_fun_UnI2: "[| mono(f);  a: gfp(f) |] ==> a: f(X Un gfp(f))"
   2.180 +by (blast dest: gfp_lemma2 mono_Un)
   2.181 +
   2.182 +
   2.183 +subsection {* Even Stronger Coinduction Rule, by Martin Coen *}
   2.184 +
   2.185 +text{* Weakens the condition @{term "X \<subseteq> f(X)"} to one expressed using both
   2.186 +  @{term lfp} and @{term gfp}*}
   2.187 +
   2.188 +lemma coinduct3_mono_lemma: "mono(f) ==> mono(%x. f(x) Un X Un B)"
   2.189 +by (iprover intro: subset_refl monoI Un_mono monoD)
   2.190 +
   2.191 +lemma coinduct3_lemma:
   2.192 +     "[| X \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f)));  mono(f) |]
   2.193 +      ==> lfp(%x. f(x) Un X Un gfp(f)) \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f)))"
   2.194 +apply (rule subset_trans)
   2.195 +apply (erule coinduct3_mono_lemma [THEN lfp_lemma3])
   2.196 +apply (rule Un_least [THEN Un_least])
   2.197 +apply (rule subset_refl, assumption)
   2.198 +apply (rule gfp_unfold [THEN equalityD1, THEN subset_trans], assumption)
   2.199 +apply (rule monoD, assumption)
   2.200 +apply (subst coinduct3_mono_lemma [THEN lfp_unfold], auto)
   2.201 +done
   2.202 +
   2.203 +lemma coinduct3: 
   2.204 +  "[| mono(f);  a:X;  X \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f))) |] ==> a : gfp(f)"
   2.205 +apply (rule coinduct3_lemma [THEN [2] weak_coinduct])
   2.206 +apply (rule coinduct3_mono_lemma [THEN lfp_unfold, THEN ssubst], auto)
   2.207 +done
   2.208 +
   2.209 +
   2.210 +text{*Definition forms of @{text gfp_unfold} and @{text coinduct}, 
   2.211 +    to control unfolding*}
   2.212 +
   2.213 +lemma def_gfp_unfold: "[| A==gfp(f);  mono(f) |] ==> A = f(A)"
   2.214 +by (auto intro!: gfp_unfold)
   2.215 +
   2.216 +lemma def_coinduct:
   2.217 +     "[| A==gfp(f);  mono(f);  X \<le> f(sup X A) |] ==> X \<le> A"
   2.218 +by (iprover intro!: coinduct)
   2.219 +
   2.220 +lemma def_coinduct_set:
   2.221 +     "[| A==gfp(f);  mono(f);  a:X;  X \<subseteq> f(X Un A) |] ==> a: A"
   2.222 +by (auto intro!: coinduct_set)
   2.223 +
   2.224 +(*The version used in the induction/coinduction package*)
   2.225 +lemma def_Collect_coinduct:
   2.226 +    "[| A == gfp(%w. Collect(P(w)));  mono(%w. Collect(P(w)));   
   2.227 +        a: X;  !!z. z: X ==> P (X Un A) z |] ==>  
   2.228 +     a : A"
   2.229 +apply (erule def_coinduct_set, auto) 
   2.230 +done
   2.231 +
   2.232 +lemma def_coinduct3:
   2.233 +    "[| A==gfp(f); mono(f);  a:X;  X \<subseteq> f(lfp(%x. f(x) Un X Un A)) |] ==> a: A"
   2.234 +by (auto intro!: coinduct3)
   2.235 +
   2.236 +text{*Monotonicity of @{term gfp}!*}
   2.237 +lemma gfp_mono: "(!!Z. f Z \<le> g Z) ==> gfp f \<le> gfp g"
   2.238 +  by (rule gfp_upperbound [THEN gfp_least], blast intro: order_trans)
   2.239 +
   2.240 +
   2.241  subsection {* Inductive predicates and sets *}
   2.242  
   2.243  text {* Inversion of injective functions. *}
   2.244 @@ -64,6 +285,24 @@
   2.245    Ball_def Bex_def
   2.246    induct_rulify_fallback
   2.247  
   2.248 +ML {*
   2.249 +val def_lfp_unfold = @{thm def_lfp_unfold}
   2.250 +val def_gfp_unfold = @{thm def_gfp_unfold}
   2.251 +val def_lfp_induct = @{thm def_lfp_induct}
   2.252 +val def_coinduct = @{thm def_coinduct}
   2.253 +val inf_bool_eq = @{thm inf_bool_eq}
   2.254 +val inf_fun_eq = @{thm inf_fun_eq}
   2.255 +val le_boolI = @{thm le_boolI}
   2.256 +val le_boolI' = @{thm le_boolI'}
   2.257 +val le_funI = @{thm le_funI}
   2.258 +val le_boolE = @{thm le_boolE}
   2.259 +val le_funE = @{thm le_funE}
   2.260 +val le_boolD = @{thm le_boolD}
   2.261 +val le_funD = @{thm le_funD}
   2.262 +val le_bool_def = @{thm le_bool_def}
   2.263 +val le_fun_def = @{thm le_fun_def}
   2.264 +*}
   2.265 +
   2.266  use "Tools/inductive_package.ML"
   2.267  setup InductivePackage.setup
   2.268  
   2.269 @@ -74,26 +313,6 @@
   2.270    Ball_def Bex_def
   2.271    induct_rulify_fallback
   2.272  
   2.273 -lemma False_meta_all:
   2.274 -  "Trueprop False \<equiv> (\<And>P\<Colon>bool. P)"
   2.275 -proof
   2.276 -  fix P
   2.277 -  assume False
   2.278 -  then show P ..
   2.279 -next
   2.280 -  assume "\<And>P\<Colon>bool. P"
   2.281 -  then show False .
   2.282 -qed
   2.283 -
   2.284 -lemma not_eq_False:
   2.285 -  assumes not_eq: "x \<noteq> y"
   2.286 -  and eq: "x \<equiv> y"
   2.287 -  shows False
   2.288 -  using not_eq eq by auto
   2.289 -
   2.290 -lemmas not_eq_quodlibet =
   2.291 -  not_eq_False [simplified False_meta_all]
   2.292 -
   2.293  
   2.294  subsection {* Inductive datatypes and primitive recursion *}
   2.295  
     3.1 --- a/src/HOL/IsaMakefile	Mon Oct 08 22:03:21 2007 +0200
     3.2 +++ b/src/HOL/IsaMakefile	Mon Oct 08 22:03:25 2007 +0200
     3.3 @@ -92,7 +92,7 @@
     3.4    $(SRC)/Tools/nbe.ML $(SRC)/Tools/rat.ML Tools/TFL/casesplit.ML ATP_Linkup.thy	\
     3.5    Accessible_Part.thy Arith_Tools.thy Code_Setup.thy Datatype.thy 			\
     3.6    Dense_Linear_Order.thy Divides.thy Equiv_Relations.thy Extraction.thy	\
     3.7 -  Finite_Set.thy FixedPoint.thy Fun.thy FunDef.thy HOL.thy		\
     3.8 +  Finite_Set.thy Fun.thy FunDef.thy HOL.thy		\
     3.9    Hilbert_Choice.thy Inductive.thy IntArith.thy IntDef.thy IntDiv.thy	\
    3.10    Lattices.thy List.thy Main.thy Map.thy Nat.thy NatBin.thy	\
    3.11    Numeral.thy OrderedGroup.thy Orderings.thy Power.thy PreList.thy	\
     4.1 --- a/src/HOL/Relation.thy	Mon Oct 08 22:03:21 2007 +0200
     4.2 +++ b/src/HOL/Relation.thy	Mon Oct 08 22:03:25 2007 +0200
     4.3 @@ -7,7 +7,7 @@
     4.4  header {* Relations *}
     4.5  
     4.6  theory Relation
     4.7 -imports Product_Type FixedPoint
     4.8 +imports Product_Type
     4.9  begin
    4.10  
    4.11  subsection {* Definitions *}
     5.1 --- a/src/HOL/Tools/inductive_package.ML	Mon Oct 08 22:03:21 2007 +0200
     5.2 +++ b/src/HOL/Tools/inductive_package.ML	Mon Oct 08 22:03:25 2007 +0200
     5.3 @@ -589,7 +589,7 @@
     5.4  fun mk_ind_def alt_name coind cs intr_ts monos
     5.5        params cnames_syn ctxt =
     5.6    let
     5.7 -    val fp_name = if coind then @{const_name FixedPoint.gfp} else @{const_name FixedPoint.lfp};
     5.8 +    val fp_name = if coind then @{const_name Inductive.gfp} else @{const_name Inductive.lfp};
     5.9  
    5.10      val argTs = fold (fn c => fn Ts => Ts @
    5.11        (List.drop (binder_types (fastype_of c), length params) \\ Ts)) cs [];