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