| author | wenzelm | 
| Wed, 26 Nov 1997 16:42:19 +0100 | |
| changeset 4291 | 6e13b5427de0 | 
| parent 1737 | 5a4f382455ce | 
| child 4352 | 7ac9f3e8a97d | 
| permissions | -rw-r--r-- | 
| 1461 | 1  | 
(* Title: ZF/Inductive.ML  | 
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
2  | 
ID: $Id$  | 
| 1461 | 3  | 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory  | 
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
4  | 
Copyright 1993 University of Cambridge  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
5  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
6  | 
(Co)Inductive Definitions for Zermelo-Fraenkel Set Theory  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
7  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
8  | 
Inductive definitions use least fixedpoints with standard products and sums  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
9  | 
Coinductive definitions use greatest fixedpoints with Quine products and sums  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
10  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
11  | 
Sums are used only for mutual recursion;  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
12  | 
Products are used only to derive "streamlined" induction rules for relations  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
13  | 
*)  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
14  | 
|
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
15  | 
val iT = Ind_Syntax.iT  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
16  | 
and oT = Ind_Syntax.oT;  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
17  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
18  | 
structure Lfp =  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
19  | 
struct  | 
| 1461 | 20  | 
  val oper      = Const("lfp",      [iT,iT-->iT]--->iT)
 | 
21  | 
  val bnd_mono  = Const("bnd_mono", [iT,iT-->iT]--->oT)
 | 
|
22  | 
val bnd_monoI = bnd_monoI  | 
|
23  | 
val subs = def_lfp_subset  | 
|
24  | 
val Tarski = def_lfp_Tarski  | 
|
25  | 
val induct = def_induct  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
26  | 
end;  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
27  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
28  | 
structure Standard_Prod =  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
29  | 
struct  | 
| 1461 | 30  | 
  val sigma     = Const("Sigma", [iT, iT-->iT]--->iT)
 | 
31  | 
  val pair      = Const("Pair", [iT,iT]--->iT)
 | 
|
| 1737 | 32  | 
val split_name = "split"  | 
| 1461 | 33  | 
val pair_iff = Pair_iff  | 
34  | 
val split_eq = split  | 
|
35  | 
val fsplitI = splitI  | 
|
36  | 
val fsplitD = splitD  | 
|
37  | 
val fsplitE = splitE  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
38  | 
end;  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
39  | 
|
| 1737 | 40  | 
structure Standard_CP = CartProd_Fun (Standard_Prod);  | 
41  | 
||
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
42  | 
structure Standard_Sum =  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
43  | 
struct  | 
| 1461 | 44  | 
  val sum       = Const("op +", [iT,iT]--->iT)
 | 
45  | 
  val inl       = Const("Inl", iT-->iT)
 | 
|
46  | 
  val inr       = Const("Inr", iT-->iT)
 | 
|
47  | 
  val elim      = Const("case", [iT-->iT, iT-->iT, iT]--->iT)
 | 
|
48  | 
val case_inl = case_Inl  | 
|
49  | 
val case_inr = case_Inr  | 
|
50  | 
val inl_iff = Inl_iff  | 
|
51  | 
val inr_iff = Inr_iff  | 
|
52  | 
val distinct = Inl_Inr_iff  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
53  | 
val distinct' = Inr_Inl_iff  | 
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
54  | 
val free_SEs = Ind_Syntax.mk_free_SEs  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
55  | 
[distinct, distinct', inl_iff, inr_iff, Standard_Prod.pair_iff]  | 
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
56  | 
end;  | 
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
57  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
58  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
59  | 
functor Ind_section_Fun (Inductive: sig include INDUCTIVE_ARG INDUCTIVE_I end)  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
60  | 
: sig include INTR_ELIM INDRULE end =  | 
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
61  | 
let  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
62  | 
structure Intr_elim =  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
63  | 
Intr_elim_Fun(structure Inductive=Inductive and Fp=Lfp and  | 
| 1461 | 64  | 
Pr=Standard_Prod and Su=Standard_Sum);  | 
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
65  | 
|
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
66  | 
structure Indrule =  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
67  | 
Indrule_Fun (structure Inductive=Inductive and  | 
| 1737 | 68  | 
Pr=Standard_Prod and CP=Standard_CP and  | 
69  | 
Su=Standard_Sum and  | 
|
70  | 
Intr_elim=Intr_elim)  | 
|
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
71  | 
in  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
72  | 
struct  | 
| 1461 | 73  | 
val thy = Intr_elim.thy  | 
74  | 
val defs = Intr_elim.defs  | 
|
75  | 
val bnd_mono = Intr_elim.bnd_mono  | 
|
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
76  | 
val dom_subset = Intr_elim.dom_subset  | 
| 1461 | 77  | 
val intrs = Intr_elim.intrs  | 
78  | 
val elim = Intr_elim.elim  | 
|
79  | 
val mk_cases = Intr_elim.mk_cases  | 
|
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
80  | 
open Indrule  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
81  | 
end  | 
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
82  | 
end;  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
83  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
84  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
85  | 
structure Ind = Add_inductive_def_Fun  | 
| 1737 | 86  | 
(structure Fp=Lfp and Pr=Standard_Prod and CP=Standard_CP  | 
87  | 
and Su=Standard_Sum);  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
88  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
89  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
90  | 
structure Gfp =  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
91  | 
struct  | 
| 1461 | 92  | 
  val oper      = Const("gfp",      [iT,iT-->iT]--->iT)
 | 
93  | 
  val bnd_mono  = Const("bnd_mono", [iT,iT-->iT]--->oT)
 | 
|
94  | 
val bnd_monoI = bnd_monoI  | 
|
95  | 
val subs = def_gfp_subset  | 
|
96  | 
val Tarski = def_gfp_Tarski  | 
|
97  | 
val induct = def_Collect_coinduct  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
98  | 
end;  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
99  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
100  | 
structure Quine_Prod =  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
101  | 
struct  | 
| 1461 | 102  | 
  val sigma     = Const("QSigma", [iT, iT-->iT]--->iT)
 | 
103  | 
  val pair      = Const("QPair", [iT,iT]--->iT)
 | 
|
| 1737 | 104  | 
val split_name = "qsplit"  | 
| 1461 | 105  | 
val pair_iff = QPair_iff  | 
106  | 
val split_eq = qsplit  | 
|
107  | 
val fsplitI = qsplitI  | 
|
108  | 
val fsplitD = qsplitD  | 
|
109  | 
val fsplitE = qsplitE  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
110  | 
end;  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
111  | 
|
| 1737 | 112  | 
structure Quine_CP = CartProd_Fun (Quine_Prod);  | 
113  | 
||
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
114  | 
structure Quine_Sum =  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
115  | 
struct  | 
| 1461 | 116  | 
  val sum       = Const("op <+>", [iT,iT]--->iT)
 | 
117  | 
  val inl       = Const("QInl", iT-->iT)
 | 
|
118  | 
  val inr       = Const("QInr", iT-->iT)
 | 
|
119  | 
  val elim      = Const("qcase", [iT-->iT, iT-->iT, iT]--->iT)
 | 
|
120  | 
val case_inl = qcase_QInl  | 
|
121  | 
val case_inr = qcase_QInr  | 
|
122  | 
val inl_iff = QInl_iff  | 
|
123  | 
val inr_iff = QInr_iff  | 
|
124  | 
val distinct = QInl_QInr_iff  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
125  | 
val distinct' = QInr_QInl_iff  | 
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
126  | 
val free_SEs = Ind_Syntax.mk_free_SEs  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
127  | 
[distinct, distinct', inl_iff, inr_iff, Quine_Prod.pair_iff]  | 
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
128  | 
end;  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
129  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
130  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
131  | 
signature COINDRULE =  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
132  | 
sig  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
133  | 
val coinduct : thm  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
134  | 
end;  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
135  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
136  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
137  | 
functor CoInd_section_Fun  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
138  | 
(Inductive: sig include INDUCTIVE_ARG INDUCTIVE_I end)  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
139  | 
: sig include INTR_ELIM COINDRULE end =  | 
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
140  | 
let  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
141  | 
structure Intr_elim =  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
142  | 
Intr_elim_Fun(structure Inductive=Inductive and Fp=Gfp and  | 
| 1737 | 143  | 
Pr=Quine_Prod and CP=Standard_CP and  | 
144  | 
Su=Quine_Sum);  | 
|
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
145  | 
in  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
146  | 
struct  | 
| 1461 | 147  | 
val thy = Intr_elim.thy  | 
148  | 
val defs = Intr_elim.defs  | 
|
149  | 
val bnd_mono = Intr_elim.bnd_mono  | 
|
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
150  | 
val dom_subset = Intr_elim.dom_subset  | 
| 1461 | 151  | 
val intrs = Intr_elim.intrs  | 
152  | 
val elim = Intr_elim.elim  | 
|
153  | 
val mk_cases = Intr_elim.mk_cases  | 
|
| 
1418
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
154  | 
val coinduct = Intr_elim.raw_induct  | 
| 
 
f5f97ee67cbb
Improving space efficiency of inductive/datatype definitions.
 
paulson 
parents: 
1093 
diff
changeset
 | 
155  | 
end  | 
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
156  | 
end;  | 
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
157  | 
|
| 
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
158  | 
structure CoInd =  | 
| 1737 | 159  | 
Add_inductive_def_Fun(structure Fp=Gfp and Pr=Quine_Prod and CP=Quine_CP  | 
160  | 
and Su=Quine_Sum);  | 
|
| 
578
 
efc648d29dd0
ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
 
lcp 
parents:  
diff
changeset
 | 
161  |