| author | paulson | 
| Mon, 04 Feb 2002 13:16:54 +0100 | |
| changeset 12867 | 5c900a821a7c | 
| parent 12437 | 6d4e02b6dd43 | 
| child 12920 | 32292d83367b | 
| permissions | -rw-r--r-- | 
| 7700 | 1  | 
(* Title: HOL/Inductive.thy  | 
2  | 
ID: $Id$  | 
|
| 10402 | 3  | 
Author: Markus Wenzel, TU Muenchen  | 
| 10727 | 4  | 
License: GPL (GNU GENERAL PUBLIC LICENSE)  | 
| 11688 | 5  | 
*)  | 
| 10727 | 6  | 
|
| 11688 | 7  | 
header {* Support for inductive sets and types *}
 | 
| 1187 | 8  | 
|
| 
11325
 
a5e0289dd56c
Inductive definitions are now introduced earlier in the theory hierarchy.
 
berghofe 
parents: 
11003 
diff
changeset
 | 
9  | 
theory Inductive = Gfp + Sum_Type + Relation  | 
| 7700 | 10  | 
files  | 
| 10402 | 11  | 
  ("Tools/inductive_package.ML")
 | 
| 
12437
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
12  | 
  ("Tools/inductive_codegen.ML")
 | 
| 10402 | 13  | 
  ("Tools/datatype_aux.ML")
 | 
14  | 
  ("Tools/datatype_prop.ML")
 | 
|
15  | 
  ("Tools/datatype_rep_proofs.ML")
 | 
|
16  | 
  ("Tools/datatype_abs_proofs.ML")
 | 
|
17  | 
  ("Tools/datatype_package.ML")
 | 
|
| 
12437
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
18  | 
  ("Tools/datatype_codegen.ML")
 | 
| 
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
19  | 
  ("Tools/recfun_codegen.ML")
 | 
| 10402 | 20  | 
  ("Tools/primrec_package.ML"):
 | 
21  | 
||
| 10727 | 22  | 
|
| 11688 | 23  | 
subsection {* Inductive sets *}
 | 
24  | 
||
25  | 
text {* Inversion of injective functions. *}
 | 
|
| 11436 | 26  | 
|
27  | 
constdefs  | 
|
28  | 
  myinv :: "('a => 'b) => ('b => 'a)"
 | 
|
29  | 
"myinv (f :: 'a => 'b) == \<lambda>y. THE x. f x = y"  | 
|
30  | 
||
31  | 
lemma myinv_f_f: "inj f ==> myinv f (f x) = x"  | 
|
32  | 
proof -  | 
|
33  | 
assume "inj f"  | 
|
34  | 
hence "(THE x'. f x' = f x) = (THE x'. x' = x)"  | 
|
35  | 
by (simp only: inj_eq)  | 
|
36  | 
also have "... = x" by (rule the_eq_trivial)  | 
|
| 11439 | 37  | 
finally show ?thesis by (unfold myinv_def)  | 
| 11436 | 38  | 
qed  | 
39  | 
||
40  | 
lemma f_myinv_f: "inj f ==> y \<in> range f ==> f (myinv f y) = y"  | 
|
41  | 
proof (unfold myinv_def)  | 
|
42  | 
assume inj: "inj f"  | 
|
43  | 
assume "y \<in> range f"  | 
|
44  | 
then obtain x where "y = f x" ..  | 
|
45  | 
hence x: "f x = y" ..  | 
|
46  | 
thus "f (THE x. f x = y) = y"  | 
|
47  | 
proof (rule theI)  | 
|
48  | 
fix x' assume "f x' = y"  | 
|
49  | 
with x have "f x' = f x" by simp  | 
|
50  | 
with inj show "x' = x" by (rule injD)  | 
|
51  | 
qed  | 
|
52  | 
qed  | 
|
53  | 
||
54  | 
hide const myinv  | 
|
55  | 
||
56  | 
||
| 11688 | 57  | 
text {* Package setup. *}
 | 
| 10402 | 58  | 
|
59  | 
use "Tools/inductive_package.ML"  | 
|
| 6437 | 60  | 
setup InductivePackage.setup  | 
| 10402 | 61  | 
|
| 11688 | 62  | 
theorems basic_monos [mono] =  | 
63  | 
subset_refl imp_refl disj_mono conj_mono ex_mono all_mono if_def2  | 
|
64  | 
Collect_mono in_mono vimage_mono  | 
|
65  | 
imp_conv_disj not_not de_Morgan_disj de_Morgan_conj  | 
|
66  | 
not_all not_ex  | 
|
67  | 
Ball_def Bex_def  | 
|
| 11990 | 68  | 
induct_rulify2  | 
| 11688 | 69  | 
|
70  | 
||
| 12023 | 71  | 
subsection {* Inductive datatypes and primitive recursion *}
 | 
| 11688 | 72  | 
|
| 11825 | 73  | 
text {* Package setup. *}
 | 
74  | 
||
| 
12437
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
75  | 
use "Tools/recfun_codegen.ML"  | 
| 
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
76  | 
setup RecfunCodegen.setup  | 
| 
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
77  | 
|
| 10402 | 78  | 
use "Tools/datatype_aux.ML"  | 
79  | 
use "Tools/datatype_prop.ML"  | 
|
80  | 
use "Tools/datatype_rep_proofs.ML"  | 
|
81  | 
use "Tools/datatype_abs_proofs.ML"  | 
|
82  | 
use "Tools/datatype_package.ML"  | 
|
| 7700 | 83  | 
setup DatatypePackage.setup  | 
| 10402 | 84  | 
|
| 
12437
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
85  | 
use "Tools/datatype_codegen.ML"  | 
| 
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
86  | 
setup DatatypeCodegen.setup  | 
| 
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
87  | 
|
| 
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
88  | 
use "Tools/inductive_codegen.ML"  | 
| 
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
89  | 
setup InductiveCodegen.setup  | 
| 
 
6d4e02b6dd43
Moved code generator setup from Recdef to Inductive.
 
berghofe 
parents: 
12023 
diff
changeset
 | 
90  | 
|
| 10402 | 91  | 
use "Tools/primrec_package.ML"  | 
| 7700 | 92  | 
|
| 6437 | 93  | 
end  |