| author | nipkow | 
| Fri, 28 Feb 2014 18:09:37 +0100 | |
| changeset 55807 | fd31d0e70eb8 | 
| parent 55604 | 42e4e8c2e8dc | 
| child 56146 | 8453d35e4684 | 
| permissions | -rw-r--r-- | 
| 7700 | 1 | (* Title: HOL/Inductive.thy | 
| 10402 | 2 | Author: Markus Wenzel, TU Muenchen | 
| 11688 | 3 | *) | 
| 10727 | 4 | |
| 24915 | 5 | header {* Knaster-Tarski Fixpoint Theorem and inductive definitions *}
 | 
| 1187 | 6 | |
| 54398 
100c0eaf63d5
moved 'Ctr_Sugar' further up the theory hierarchy, so that 'Datatype' can use it
 blanchet parents: 
52143diff
changeset | 7 | theory Inductive | 
| 
100c0eaf63d5
moved 'Ctr_Sugar' further up the theory hierarchy, so that 'Datatype' can use it
 blanchet parents: 
52143diff
changeset | 8 | imports Complete_Lattices Ctr_Sugar | 
| 46950 
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
 wenzelm parents: 
46947diff
changeset | 9 | keywords | 
| 
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
 wenzelm parents: 
46947diff
changeset | 10 | "inductive" "coinductive" :: thy_decl and | 
| 
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
 wenzelm parents: 
46947diff
changeset | 11 | "inductive_cases" "inductive_simps" :: thy_script and "monos" and | 
| 54398 
100c0eaf63d5
moved 'Ctr_Sugar' further up the theory hierarchy, so that 'Datatype' can use it
 blanchet parents: 
52143diff
changeset | 12 | "print_inductives" :: diag and | 
| 46950 
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
 wenzelm parents: 
46947diff
changeset | 13 | "rep_datatype" :: thy_goal and | 
| 55575 
a5e33e18fb5c
moved 'primrec' up (for real this time) and removed temporary 'old_primrec'
 blanchet parents: 
55534diff
changeset | 14 | "primrec" :: thy_decl | 
| 15131 | 15 | begin | 
| 10727 | 16 | |
| 24915 | 17 | subsection {* Least and greatest fixed points *}
 | 
| 18 | ||
| 26013 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 19 | context complete_lattice | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 20 | begin | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 21 | |
| 24915 | 22 | definition | 
| 26013 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 23 |   lfp :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a" where
 | 
| 24915 | 24 |   "lfp f = Inf {u. f u \<le> u}"    --{*least fixed point*}
 | 
| 25 | ||
| 26 | definition | |
| 26013 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 27 |   gfp :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a" where
 | 
| 24915 | 28 |   "gfp f = Sup {u. u \<le> f u}"    --{*greatest fixed point*}
 | 
| 29 | ||
| 30 | ||
| 31 | subsection{* Proof of Knaster-Tarski Theorem using @{term lfp} *}
 | |
| 32 | ||
| 54398 
100c0eaf63d5
moved 'Ctr_Sugar' further up the theory hierarchy, so that 'Datatype' can use it
 blanchet parents: 
52143diff
changeset | 33 | text{*@{term "lfp f"} is the least upper bound of
 | 
| 24915 | 34 |       the set @{term "{u. f(u) \<le> u}"} *}
 | 
| 35 | ||
| 36 | lemma lfp_lowerbound: "f A \<le> A ==> lfp f \<le> A" | |
| 37 | by (auto simp add: lfp_def intro: Inf_lower) | |
| 38 | ||
| 39 | lemma lfp_greatest: "(!!u. f u \<le> u ==> A \<le> u) ==> A \<le> lfp f" | |
| 40 | by (auto simp add: lfp_def intro: Inf_greatest) | |
| 41 | ||
| 26013 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 42 | end | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 43 | |
| 24915 | 44 | lemma lfp_lemma2: "mono f ==> f (lfp f) \<le> lfp f" | 
| 45 | by (iprover intro: lfp_greatest order_trans monoD lfp_lowerbound) | |
| 46 | ||
| 47 | lemma lfp_lemma3: "mono f ==> lfp f \<le> f (lfp f)" | |
| 48 | by (iprover intro: lfp_lemma2 monoD lfp_lowerbound) | |
| 49 | ||
| 50 | lemma lfp_unfold: "mono f ==> lfp f = f (lfp f)" | |
| 51 | by (iprover intro: order_antisym lfp_lemma2 lfp_lemma3) | |
| 52 | ||
| 53 | lemma lfp_const: "lfp (\<lambda>x. t) = t" | |
| 54 | by (rule lfp_unfold) (simp add:mono_def) | |
| 55 | ||
| 56 | ||
| 57 | subsection {* General induction rules for least fixed points *}
 | |
| 58 | ||
| 59 | theorem lfp_induct: | |
| 60 | assumes mono: "mono f" and ind: "f (inf (lfp f) P) <= P" | |
| 61 | shows "lfp f <= P" | |
| 62 | proof - | |
| 63 | have "inf (lfp f) P <= lfp f" by (rule inf_le1) | |
| 64 | with mono have "f (inf (lfp f) P) <= f (lfp f)" .. | |
| 65 | also from mono have "f (lfp f) = lfp f" by (rule lfp_unfold [symmetric]) | |
| 66 | finally have "f (inf (lfp f) P) <= lfp f" . | |
| 67 | from this and ind have "f (inf (lfp f) P) <= inf (lfp f) P" by (rule le_infI) | |
| 68 | hence "lfp f <= inf (lfp f) P" by (rule lfp_lowerbound) | |
| 69 | also have "inf (lfp f) P <= P" by (rule inf_le2) | |
| 70 | finally show ?thesis . | |
| 71 | qed | |
| 72 | ||
| 73 | lemma lfp_induct_set: | |
| 74 | assumes lfp: "a: lfp(f)" | |
| 75 | and mono: "mono(f)" | |
| 76 |       and indhyp: "!!x. [| x: f(lfp(f) Int {x. P(x)}) |] ==> P(x)"
 | |
| 77 | shows "P(a)" | |
| 78 | by (rule lfp_induct [THEN subsetD, THEN CollectD, OF mono _ lfp]) | |
| 32683 
7c1fe854ca6a
inter and union are mere abbreviations for inf and sup
 haftmann parents: 
32587diff
changeset | 79 | (auto simp: intro: indhyp) | 
| 24915 | 80 | |
| 26013 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 81 | lemma lfp_ordinal_induct: | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 82 | fixes f :: "'a\<Colon>complete_lattice \<Rightarrow> 'a" | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 83 | assumes mono: "mono f" | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 84 | and P_f: "\<And>S. P S \<Longrightarrow> P (f S)" | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 85 | and P_Union: "\<And>M. \<forall>S\<in>M. P S \<Longrightarrow> P (Sup M)" | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 86 | shows "P (lfp f)" | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 87 | proof - | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 88 |   let ?M = "{S. S \<le> lfp f \<and> P S}"
 | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 89 | have "P (Sup ?M)" using P_Union by simp | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 90 | also have "Sup ?M = lfp f" | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 91 | proof (rule antisym) | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 92 | show "Sup ?M \<le> lfp f" by (blast intro: Sup_least) | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 93 | hence "f (Sup ?M) \<le> f (lfp f)" by (rule mono [THEN monoD]) | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 94 | hence "f (Sup ?M) \<le> lfp f" using mono [THEN lfp_unfold] by simp | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 95 | hence "f (Sup ?M) \<in> ?M" using P_f P_Union by simp | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 96 | hence "f (Sup ?M) \<le> Sup ?M" by (rule Sup_upper) | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 97 | thus "lfp f \<le> Sup ?M" by (rule lfp_lowerbound) | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 98 | qed | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 99 | finally show ?thesis . | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 100 | qed | 
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 101 | |
| 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 haftmann parents: 
25557diff
changeset | 102 | lemma lfp_ordinal_induct_set: | 
| 24915 | 103 | assumes mono: "mono f" | 
| 104 | and P_f: "!!S. P S ==> P(f S)" | |
| 105 | and P_Union: "!!M. !S:M. P S ==> P(Union M)" | |
| 106 | shows "P(lfp f)" | |
| 46008 
c296c75f4cf4
reverted some changes for set->predicate transition, according to "hg log -u berghofe -r Isabelle2007:Isabelle2008";
 wenzelm parents: 
45907diff
changeset | 107 | using assms by (rule lfp_ordinal_induct) | 
| 24915 | 108 | |
| 109 | ||
| 110 | text{*Definition forms of @{text lfp_unfold} and @{text lfp_induct}, 
 | |
| 111 | to control unfolding*} | |
| 112 | ||
| 113 | lemma def_lfp_unfold: "[| h==lfp(f); mono(f) |] ==> h = f(h)" | |
| 45899 | 114 | by (auto intro!: lfp_unfold) | 
| 24915 | 115 | |
| 116 | lemma def_lfp_induct: | |
| 117 | "[| A == lfp(f); mono(f); | |
| 118 | f (inf A P) \<le> P | |
| 119 | |] ==> A \<le> P" | |
| 120 | by (blast intro: lfp_induct) | |
| 121 | ||
| 122 | lemma def_lfp_induct_set: | |
| 123 | "[| A == lfp(f); mono(f); a:A; | |
| 124 |         !!x. [| x: f(A Int {x. P(x)}) |] ==> P(x)         
 | |
| 125 | |] ==> P(a)" | |
| 126 | by (blast intro: lfp_induct_set) | |
| 127 | ||
| 128 | (*Monotonicity of lfp!*) | |
| 129 | lemma lfp_mono: "(!!Z. f Z \<le> g Z) ==> lfp f \<le> lfp g" | |
| 130 | by (rule lfp_lowerbound [THEN lfp_greatest], blast intro: order_trans) | |
| 131 | ||
| 132 | ||
| 133 | subsection {* Proof of Knaster-Tarski Theorem using @{term gfp} *}
 | |
| 134 | ||
| 135 | text{*@{term "gfp f"} is the greatest lower bound of 
 | |
| 136 |       the set @{term "{u. u \<le> f(u)}"} *}
 | |
| 137 | ||
| 138 | lemma gfp_upperbound: "X \<le> f X ==> X \<le> gfp f" | |
| 139 | by (auto simp add: gfp_def intro: Sup_upper) | |
| 140 | ||
| 141 | lemma gfp_least: "(!!u. u \<le> f u ==> u \<le> X) ==> gfp f \<le> X" | |
| 142 | by (auto simp add: gfp_def intro: Sup_least) | |
| 143 | ||
| 144 | lemma gfp_lemma2: "mono f ==> gfp f \<le> f (gfp f)" | |
| 145 | by (iprover intro: gfp_least order_trans monoD gfp_upperbound) | |
| 146 | ||
| 147 | lemma gfp_lemma3: "mono f ==> f (gfp f) \<le> gfp f" | |
| 148 | by (iprover intro: gfp_lemma2 monoD gfp_upperbound) | |
| 149 | ||
| 150 | lemma gfp_unfold: "mono f ==> gfp f = f (gfp f)" | |
| 151 | by (iprover intro: order_antisym gfp_lemma2 gfp_lemma3) | |
| 152 | ||
| 153 | ||
| 154 | subsection {* Coinduction rules for greatest fixed points *}
 | |
| 155 | ||
| 156 | text{*weak version*}
 | |
| 157 | lemma weak_coinduct: "[| a: X; X \<subseteq> f(X) |] ==> a : gfp(f)" | |
| 45899 | 158 | by (rule gfp_upperbound [THEN subsetD]) auto | 
| 24915 | 159 | |
| 160 | lemma weak_coinduct_image: "!!X. [| a : X; g`X \<subseteq> f (g`X) |] ==> g a : gfp f" | |
| 45899 | 161 | apply (erule gfp_upperbound [THEN subsetD]) | 
| 162 | apply (erule imageI) | |
| 163 | done | |
| 24915 | 164 | |
| 165 | lemma coinduct_lemma: | |
| 166 | "[| X \<le> f (sup X (gfp f)); mono f |] ==> sup X (gfp f) \<le> f (sup X (gfp f))" | |
| 167 | apply (frule gfp_lemma2) | |
| 168 | apply (drule mono_sup) | |
| 169 | apply (rule le_supI) | |
| 170 | apply assumption | |
| 171 | apply (rule order_trans) | |
| 172 | apply (rule order_trans) | |
| 173 | apply assumption | |
| 174 | apply (rule sup_ge2) | |
| 175 | apply assumption | |
| 176 | done | |
| 177 | ||
| 178 | text{*strong version, thanks to Coen and Frost*}
 | |
| 179 | lemma coinduct_set: "[| mono(f); a: X; X \<subseteq> f(X Un gfp(f)) |] ==> a : gfp(f)" | |
| 55604 | 180 | by (rule weak_coinduct[rotated], rule coinduct_lemma) blast+ | 
| 24915 | 181 | |
| 182 | lemma coinduct: "[| mono(f); X \<le> f (sup X (gfp f)) |] ==> X \<le> gfp(f)" | |
| 183 | apply (rule order_trans) | |
| 184 | apply (rule sup_ge1) | |
| 55604 | 185 | apply (rule gfp_upperbound) | 
| 186 | apply (erule coinduct_lemma) | |
| 24915 | 187 | apply assumption | 
| 188 | done | |
| 189 | ||
| 190 | lemma gfp_fun_UnI2: "[| mono(f); a: gfp(f) |] ==> a: f(X Un gfp(f))" | |
| 45899 | 191 | by (blast dest: gfp_lemma2 mono_Un) | 
| 24915 | 192 | |
| 193 | ||
| 194 | subsection {* Even Stronger Coinduction Rule, by Martin Coen *}
 | |
| 195 | ||
| 196 | text{* Weakens the condition @{term "X \<subseteq> f(X)"} to one expressed using both
 | |
| 197 |   @{term lfp} and @{term gfp}*}
 | |
| 198 | ||
| 199 | lemma coinduct3_mono_lemma: "mono(f) ==> mono(%x. f(x) Un X Un B)" | |
| 200 | by (iprover intro: subset_refl monoI Un_mono monoD) | |
| 201 | ||
| 202 | lemma coinduct3_lemma: | |
| 203 | "[| X \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f))); mono(f) |] | |
| 204 | ==> lfp(%x. f(x) Un X Un gfp(f)) \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f)))" | |
| 205 | apply (rule subset_trans) | |
| 206 | apply (erule coinduct3_mono_lemma [THEN lfp_lemma3]) | |
| 207 | apply (rule Un_least [THEN Un_least]) | |
| 208 | apply (rule subset_refl, assumption) | |
| 209 | apply (rule gfp_unfold [THEN equalityD1, THEN subset_trans], assumption) | |
| 46008 
c296c75f4cf4
reverted some changes for set->predicate transition, according to "hg log -u berghofe -r Isabelle2007:Isabelle2008";
 wenzelm parents: 
45907diff
changeset | 210 | apply (rule monoD, assumption) | 
| 24915 | 211 | apply (subst coinduct3_mono_lemma [THEN lfp_unfold], auto) | 
| 212 | done | |
| 213 | ||
| 214 | lemma coinduct3: | |
| 215 | "[| mono(f); a:X; X \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f))) |] ==> a : gfp(f)" | |
| 216 | apply (rule coinduct3_lemma [THEN [2] weak_coinduct]) | |
| 41081 | 217 | apply (rule coinduct3_mono_lemma [THEN lfp_unfold, THEN ssubst]) | 
| 218 | apply (simp_all) | |
| 24915 | 219 | done | 
| 220 | ||
| 221 | ||
| 222 | text{*Definition forms of @{text gfp_unfold} and @{text coinduct}, 
 | |
| 223 | to control unfolding*} | |
| 224 | ||
| 225 | lemma def_gfp_unfold: "[| A==gfp(f); mono(f) |] ==> A = f(A)" | |
| 45899 | 226 | by (auto intro!: gfp_unfold) | 
| 24915 | 227 | |
| 228 | lemma def_coinduct: | |
| 229 | "[| A==gfp(f); mono(f); X \<le> f(sup X A) |] ==> X \<le> A" | |
| 45899 | 230 | by (iprover intro!: coinduct) | 
| 24915 | 231 | |
| 232 | lemma def_coinduct_set: | |
| 233 | "[| A==gfp(f); mono(f); a:X; X \<subseteq> f(X Un A) |] ==> a: A" | |
| 45899 | 234 | by (auto intro!: coinduct_set) | 
| 24915 | 235 | |
| 236 | (*The version used in the induction/coinduction package*) | |
| 237 | lemma def_Collect_coinduct: | |
| 238 | "[| A == gfp(%w. Collect(P(w))); mono(%w. Collect(P(w))); | |
| 239 | a: X; !!z. z: X ==> P (X Un A) z |] ==> | |
| 240 | a : A" | |
| 45899 | 241 | by (erule def_coinduct_set) auto | 
| 24915 | 242 | |
| 243 | lemma def_coinduct3: | |
| 244 | "[| A==gfp(f); mono(f); a:X; X \<subseteq> f(lfp(%x. f(x) Un X Un A)) |] ==> a: A" | |
| 45899 | 245 | by (auto intro!: coinduct3) | 
| 24915 | 246 | |
| 247 | text{*Monotonicity of @{term gfp}!*}
 | |
| 248 | lemma gfp_mono: "(!!Z. f Z \<le> g Z) ==> gfp f \<le> gfp g" | |
| 249 | by (rule gfp_upperbound [THEN gfp_least], blast intro: order_trans) | |
| 250 | ||
| 251 | ||
| 23734 | 252 | subsection {* Inductive predicates and sets *}
 | 
| 11688 | 253 | |
| 254 | text {* Package setup. *}
 | |
| 10402 | 255 | |
| 23734 | 256 | theorems basic_monos = | 
| 22218 | 257 | subset_refl imp_refl disj_mono conj_mono ex_mono all_mono if_bool_eq_conj | 
| 11688 | 258 | Collect_mono in_mono vimage_mono | 
| 259 | ||
| 48891 | 260 | ML_file "Tools/inductive.ML" | 
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
31604diff
changeset | 261 | setup Inductive.setup | 
| 21018 
e6b8d6784792
Added new package for inductive definitions, moved old package
 berghofe parents: 
20604diff
changeset | 262 | |
| 23734 | 263 | theorems [mono] = | 
| 22218 | 264 | imp_refl disj_mono conj_mono ex_mono all_mono if_bool_eq_conj | 
| 33934 
25d6a8982e37
Streamlined setup for monotonicity rules (no longer requires classical rules).
 berghofe parents: 
32701diff
changeset | 265 | imp_mono not_mono | 
| 21018 
e6b8d6784792
Added new package for inductive definitions, moved old package
 berghofe parents: 
20604diff
changeset | 266 | Ball_def Bex_def | 
| 
e6b8d6784792
Added new package for inductive definitions, moved old package
 berghofe parents: 
20604diff
changeset | 267 | induct_rulify_fallback | 
| 
e6b8d6784792
Added new package for inductive definitions, moved old package
 berghofe parents: 
20604diff
changeset | 268 | |
| 11688 | 269 | |
| 12023 | 270 | subsection {* Inductive datatypes and primitive recursion *}
 | 
| 11688 | 271 | |
| 11825 | 272 | text {* Package setup. *}
 | 
| 273 | ||
| 48891 | 274 | ML_file "Tools/Datatype/datatype_aux.ML" | 
| 275 | ML_file "Tools/Datatype/datatype_prop.ML" | |
| 276 | ML_file "Tools/Datatype/datatype_data.ML" setup Datatype_Data.setup | |
| 277 | ML_file "Tools/Datatype/rep_datatype.ML" | |
| 54615 
62fb5af93fe2
generalized datatype code generation code so that it works with old-style and new-style (co)datatypes (as long as they are not local)
 blanchet parents: 
54398diff
changeset | 278 | ML_file "Tools/Datatype/datatype_codegen.ML" | 
| 48891 | 279 | ML_file "Tools/Datatype/primrec.ML" | 
| 12437 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 berghofe parents: 
12023diff
changeset | 280 | |
| 55575 
a5e33e18fb5c
moved 'primrec' up (for real this time) and removed temporary 'old_primrec'
 blanchet parents: 
55534diff
changeset | 281 | ML_file "Tools/BNF/bnf_fp_rec_sugar_util.ML" | 
| 
a5e33e18fb5c
moved 'primrec' up (for real this time) and removed temporary 'old_primrec'
 blanchet parents: 
55534diff
changeset | 282 | ML_file "Tools/BNF/bnf_lfp_rec_sugar.ML" | 
| 
a5e33e18fb5c
moved 'primrec' up (for real this time) and removed temporary 'old_primrec'
 blanchet parents: 
55534diff
changeset | 283 | |
| 23526 | 284 | text{* Lambda-abstractions with pattern matching: *}
 | 
| 285 | ||
| 286 | syntax | |
| 23529 | 287 |   "_lam_pats_syntax" :: "cases_syn => 'a => 'b"               ("(%_)" 10)
 | 
| 23526 | 288 | syntax (xsymbols) | 
| 23529 | 289 |   "_lam_pats_syntax" :: "cases_syn => 'a => 'b"               ("(\<lambda>_)" 10)
 | 
| 23526 | 290 | |
| 52143 | 291 | parse_translation {*
 | 
| 292 | let | |
| 293 | fun fun_tr ctxt [cs] = | |
| 294 | let | |
| 295 | val x = Syntax.free (fst (Name.variant "x" (Term.declare_term_frees cs Name.context))); | |
| 296 | val ft = Case_Translation.case_tr true ctxt [x, cs]; | |
| 297 | in lambda x ft end | |
| 298 |   in [(@{syntax_const "_lam_pats_syntax"}, fun_tr)] end
 | |
| 23526 | 299 | *} | 
| 300 | ||
| 301 | end |