| author | wenzelm | 
| Sat, 23 Nov 2013 12:59:12 +0100 | |
| changeset 54643 | 57aefb80b639 | 
| parent 52143 | 36ffe23b25f8 | 
| child 54398 | 100c0eaf63d5 | 
| 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  | 
| 
51692
 
ecd34f863242
tuned pretty layout: avoid nested Pretty.string_of, which merely happens to work with Isabelle/jEdit since formatting is delegated to Scala side;
 
wenzelm 
parents: 
51679 
diff
changeset
 | 
12  | 
"print_inductives" "print_case_translations" :: diag and  | 
| 
46950
 
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
 
wenzelm 
parents: 
46947 
diff
changeset
 | 
13  | 
"rep_datatype" :: thy_goal and  | 
| 
 
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
 
wenzelm 
parents: 
46947 
diff
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: 
25557 
diff
changeset
 | 
19  | 
context complete_lattice  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
20  | 
begin  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
21  | 
|
| 24915 | 22  | 
definition  | 
| 
26013
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
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: 
25557 
diff
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  | 
||
33  | 
text{*@{term "lfp f"} is the least upper bound of 
 | 
|
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: 
25557 
diff
changeset
 | 
42  | 
end  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
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: 
32587 
diff
changeset
 | 
79  | 
(auto simp: intro: indhyp)  | 
| 24915 | 80  | 
|
| 
26013
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
81  | 
lemma lfp_ordinal_induct:  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
82  | 
fixes f :: "'a\<Colon>complete_lattice \<Rightarrow> 'a"  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
83  | 
assumes mono: "mono f"  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
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: 
25557 
diff
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: 
25557 
diff
changeset
 | 
86  | 
shows "P (lfp f)"  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
87  | 
proof -  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
88  | 
  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
 | 
89  | 
have "P (Sup ?M)" using P_Union by simp  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
90  | 
also have "Sup ?M = lfp f"  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
91  | 
proof (rule antisym)  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
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: 
25557 
diff
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: 
25557 
diff
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: 
25557 
diff
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: 
25557 
diff
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: 
25557 
diff
changeset
 | 
97  | 
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
 | 
98  | 
qed  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
99  | 
finally show ?thesis .  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
100  | 
qed  | 
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
changeset
 | 
101  | 
|
| 
 
8764a1f1253b
Theorem Inductive.lfp_ordinal_induct generalized to complete lattices
 
haftmann 
parents: 
25557 
diff
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: 
45907 
diff
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)"  | 
|
| 45899 | 180  | 
by (blast intro: weak_coinduct [OF _ coinduct_lemma])  | 
| 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)  | 
|
185  | 
apply (erule gfp_upperbound [OF coinduct_lemma])  | 
|
186  | 
apply assumption  | 
|
187  | 
done  | 
|
188  | 
||
189  | 
lemma gfp_fun_UnI2: "[| mono(f); a: gfp(f) |] ==> a: f(X Un gfp(f))"  | 
|
| 45899 | 190  | 
by (blast dest: gfp_lemma2 mono_Un)  | 
| 24915 | 191  | 
|
192  | 
||
193  | 
subsection {* Even Stronger Coinduction Rule, by Martin Coen *}
 | 
|
194  | 
||
195  | 
text{* Weakens the condition @{term "X \<subseteq> f(X)"} to one expressed using both
 | 
|
196  | 
  @{term lfp} and @{term gfp}*}
 | 
|
197  | 
||
198  | 
lemma coinduct3_mono_lemma: "mono(f) ==> mono(%x. f(x) Un X Un B)"  | 
|
199  | 
by (iprover intro: subset_refl monoI Un_mono monoD)  | 
|
200  | 
||
201  | 
lemma coinduct3_lemma:  | 
|
202  | 
"[| X \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f))); mono(f) |]  | 
|
203  | 
==> lfp(%x. f(x) Un X Un gfp(f)) \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f)))"  | 
|
204  | 
apply (rule subset_trans)  | 
|
205  | 
apply (erule coinduct3_mono_lemma [THEN lfp_lemma3])  | 
|
206  | 
apply (rule Un_least [THEN Un_least])  | 
|
207  | 
apply (rule subset_refl, assumption)  | 
|
208  | 
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
 | 
209  | 
apply (rule monoD, assumption)  | 
| 24915 | 210  | 
apply (subst coinduct3_mono_lemma [THEN lfp_unfold], auto)  | 
211  | 
done  | 
|
212  | 
||
213  | 
lemma coinduct3:  | 
|
214  | 
"[| mono(f); a:X; X \<subseteq> f(lfp(%x. f(x) Un X Un gfp(f))) |] ==> a : gfp(f)"  | 
|
215  | 
apply (rule coinduct3_lemma [THEN [2] weak_coinduct])  | 
|
| 41081 | 216  | 
apply (rule coinduct3_mono_lemma [THEN lfp_unfold, THEN ssubst])  | 
217  | 
apply (simp_all)  | 
|
| 24915 | 218  | 
done  | 
219  | 
||
220  | 
||
221  | 
text{*Definition forms of @{text gfp_unfold} and @{text coinduct}, 
 | 
|
222  | 
to control unfolding*}  | 
|
223  | 
||
224  | 
lemma def_gfp_unfold: "[| A==gfp(f); mono(f) |] ==> A = f(A)"  | 
|
| 45899 | 225  | 
by (auto intro!: gfp_unfold)  | 
| 24915 | 226  | 
|
227  | 
lemma def_coinduct:  | 
|
228  | 
"[| A==gfp(f); mono(f); X \<le> f(sup X A) |] ==> X \<le> A"  | 
|
| 45899 | 229  | 
by (iprover intro!: coinduct)  | 
| 24915 | 230  | 
|
231  | 
lemma def_coinduct_set:  | 
|
232  | 
"[| A==gfp(f); mono(f); a:X; X \<subseteq> f(X Un A) |] ==> a: A"  | 
|
| 45899 | 233  | 
by (auto intro!: coinduct_set)  | 
| 24915 | 234  | 
|
235  | 
(*The version used in the induction/coinduction package*)  | 
|
236  | 
lemma def_Collect_coinduct:  | 
|
237  | 
"[| A == gfp(%w. Collect(P(w))); mono(%w. Collect(P(w)));  | 
|
238  | 
a: X; !!z. z: X ==> P (X Un A) z |] ==>  | 
|
239  | 
a : A"  | 
|
| 45899 | 240  | 
by (erule def_coinduct_set) auto  | 
| 24915 | 241  | 
|
242  | 
lemma def_coinduct3:  | 
|
243  | 
"[| A==gfp(f); mono(f); a:X; X \<subseteq> f(lfp(%x. f(x) Un X Un A)) |] ==> a: A"  | 
|
| 45899 | 244  | 
by (auto intro!: coinduct3)  | 
| 24915 | 245  | 
|
246  | 
text{*Monotonicity of @{term gfp}!*}
 | 
|
247  | 
lemma gfp_mono: "(!!Z. f Z \<le> g Z) ==> gfp f \<le> gfp g"  | 
|
248  | 
by (rule gfp_upperbound [THEN gfp_least], blast intro: order_trans)  | 
|
249  | 
||
250  | 
||
| 23734 | 251  | 
subsection {* Inductive predicates and sets *}
 | 
| 11688 | 252  | 
|
253  | 
text {* Package setup. *}
 | 
|
| 10402 | 254  | 
|
| 23734 | 255  | 
theorems basic_monos =  | 
| 22218 | 256  | 
subset_refl imp_refl disj_mono conj_mono ex_mono all_mono if_bool_eq_conj  | 
| 11688 | 257  | 
Collect_mono in_mono vimage_mono  | 
258  | 
||
| 48891 | 259  | 
ML_file "Tools/inductive.ML"  | 
| 
31723
 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 
haftmann 
parents: 
31604 
diff
changeset
 | 
260  | 
setup Inductive.setup  | 
| 
21018
 
e6b8d6784792
Added new package for inductive definitions, moved old package
 
berghofe 
parents: 
20604 
diff
changeset
 | 
261  | 
|
| 23734 | 262  | 
theorems [mono] =  | 
| 22218 | 263  | 
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
 | 
264  | 
imp_mono not_mono  | 
| 
21018
 
e6b8d6784792
Added new package for inductive definitions, moved old package
 
berghofe 
parents: 
20604 
diff
changeset
 | 
265  | 
Ball_def Bex_def  | 
| 
 
e6b8d6784792
Added new package for inductive definitions, moved old package
 
berghofe 
parents: 
20604 
diff
changeset
 | 
266  | 
induct_rulify_fallback  | 
| 
 
e6b8d6784792
Added new package for inductive definitions, moved old package
 
berghofe 
parents: 
20604 
diff
changeset
 | 
267  | 
|
| 11688 | 268  | 
|
| 12023 | 269  | 
subsection {* Inductive datatypes and primitive recursion *}
 | 
| 11688 | 270  | 
|
| 11825 | 271  | 
text {* Package setup. *}
 | 
272  | 
||
| 48891 | 273  | 
ML_file "Tools/Datatype/datatype_aux.ML"  | 
274  | 
ML_file "Tools/Datatype/datatype_prop.ML"  | 
|
275  | 
ML_file "Tools/Datatype/datatype_data.ML" setup Datatype_Data.setup  | 
|
| 
51672
 
d5c5e088ebdf
case translations performed in a separate check phase (with adjustments by traytel)
 
berghofe 
parents: 
50302 
diff
changeset
 | 
276  | 
|
| 
 
d5c5e088ebdf
case translations performed in a separate check phase (with adjustments by traytel)
 
berghofe 
parents: 
50302 
diff
changeset
 | 
277  | 
consts  | 
| 
51679
 
e7316560928b
disallow coercions to interfere with case translations
 
traytel 
parents: 
51678 
diff
changeset
 | 
278  | 
  case_guard :: "bool \<Rightarrow> 'a \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b"
 | 
| 
51672
 
d5c5e088ebdf
case translations performed in a separate check phase (with adjustments by traytel)
 
berghofe 
parents: 
50302 
diff
changeset
 | 
279  | 
case_nil :: "'a \<Rightarrow> 'b"  | 
| 
 
d5c5e088ebdf
case translations performed in a separate check phase (with adjustments by traytel)
 
berghofe 
parents: 
50302 
diff
changeset
 | 
280  | 
  case_cons :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
 | 
| 
 
d5c5e088ebdf
case translations performed in a separate check phase (with adjustments by traytel)
 
berghofe 
parents: 
50302 
diff
changeset
 | 
281  | 
case_elem :: "'a \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'b"  | 
| 
 
d5c5e088ebdf
case translations performed in a separate check phase (with adjustments by traytel)
 
berghofe 
parents: 
50302 
diff
changeset
 | 
282  | 
  case_abs :: "('c \<Rightarrow> 'b) \<Rightarrow> 'b"
 | 
| 
51679
 
e7316560928b
disallow coercions to interfere with case translations
 
traytel 
parents: 
51678 
diff
changeset
 | 
283  | 
declare [[coercion_args case_guard - + -]]  | 
| 
 
e7316560928b
disallow coercions to interfere with case translations
 
traytel 
parents: 
51678 
diff
changeset
 | 
284  | 
declare [[coercion_args case_cons - -]]  | 
| 
 
e7316560928b
disallow coercions to interfere with case translations
 
traytel 
parents: 
51678 
diff
changeset
 | 
285  | 
declare [[coercion_args case_abs -]]  | 
| 
 
e7316560928b
disallow coercions to interfere with case translations
 
traytel 
parents: 
51678 
diff
changeset
 | 
286  | 
declare [[coercion_args case_elem - +]]  | 
| 
 
e7316560928b
disallow coercions to interfere with case translations
 
traytel 
parents: 
51678 
diff
changeset
 | 
287  | 
|
| 
51673
 
4dfa00e264d8
separate data used for case translation from the datatype package
 
traytel 
parents: 
51672 
diff
changeset
 | 
288  | 
ML_file "Tools/case_translation.ML"  | 
| 
 
4dfa00e264d8
separate data used for case translation from the datatype package
 
traytel 
parents: 
51672 
diff
changeset
 | 
289  | 
setup Case_Translation.setup  | 
| 
51672
 
d5c5e088ebdf
case translations performed in a separate check phase (with adjustments by traytel)
 
berghofe 
parents: 
50302 
diff
changeset
 | 
290  | 
|
| 48891 | 291  | 
ML_file "Tools/Datatype/rep_datatype.ML"  | 
292  | 
ML_file "Tools/Datatype/datatype_codegen.ML" setup Datatype_Codegen.setup  | 
|
293  | 
ML_file "Tools/Datatype/primrec.ML"  | 
|
| 
12437
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
294  | 
|
| 23526 | 295  | 
text{* Lambda-abstractions with pattern matching: *}
 | 
296  | 
||
297  | 
syntax  | 
|
| 23529 | 298  | 
  "_lam_pats_syntax" :: "cases_syn => 'a => 'b"               ("(%_)" 10)
 | 
| 23526 | 299  | 
syntax (xsymbols)  | 
| 23529 | 300  | 
  "_lam_pats_syntax" :: "cases_syn => 'a => 'b"               ("(\<lambda>_)" 10)
 | 
| 23526 | 301  | 
|
| 52143 | 302  | 
parse_translation {*
 | 
303  | 
let  | 
|
304  | 
fun fun_tr ctxt [cs] =  | 
|
305  | 
let  | 
|
306  | 
val x = Syntax.free (fst (Name.variant "x" (Term.declare_term_frees cs Name.context)));  | 
|
307  | 
val ft = Case_Translation.case_tr true ctxt [x, cs];  | 
|
308  | 
in lambda x ft end  | 
|
309  | 
  in [(@{syntax_const "_lam_pats_syntax"}, fun_tr)] end
 | 
|
| 23526 | 310  | 
*}  | 
311  | 
||
312  | 
end  |