| author | wenzelm |
| Tue, 12 Jan 2016 20:05:53 +0100 | |
| changeset 62155 | ec2f0dad8b98 |
| parent 62125 | 438f5986d11c |
| child 62335 | e85c42f4f30a |
| permissions | -rw-r--r-- |
| 55061 | 1 |
(* Title: HOL/Tools/BNF/bnf_fp_util.ML |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2 |
Author: Dmitriy Traytel, TU Muenchen |
|
51823
38996458bc5c
create data structure for storing (co)datatype information
blanchet
parents:
51819
diff
changeset
|
3 |
Author: Jasmin Blanchette, TU Muenchen |
| 57668 | 4 |
Author: Martin Desharnais, TU Muenchen |
|
58256
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
5 |
Author: Stefan Berghofer, TU Muenchen |
| 57668 | 6 |
Copyright 2012, 2013, 2014 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
7 |
|
| 49389 | 8 |
Shared library for the datatype and codatatype constructions. |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
9 |
*) |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
10 |
|
|
51850
106afdf5806c
renamed a few FP-related files, to make it clear that these are not the sum of LFP + GFP but rather shared basic libraries
blanchet
parents:
51839
diff
changeset
|
11 |
signature BNF_FP_UTIL = |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
12 |
sig |
|
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49589
diff
changeset
|
13 |
type fp_result = |
| 51859 | 14 |
{Ts: typ list,
|
15 |
bnfs: BNF_Def.bnf list, |
|
| 51839 | 16 |
ctors: term list, |
| 51819 | 17 |
dtors: term list, |
| 59819 | 18 |
xtor_un_folds: term list, |
| 55868 | 19 |
xtor_co_recs: term list, |
| 53106 | 20 |
xtor_co_induct: thm, |
| 51819 | 21 |
dtor_ctors: thm list, |
22 |
ctor_dtors: thm list, |
|
23 |
ctor_injects: thm list, |
|
|
53203
222ea6acbdd6
moved derivation of ctor_dtor_unfold to sugar (streamlines fp_result interface)
traytel
parents:
53202
diff
changeset
|
24 |
dtor_injects: thm list, |
| 58583 | 25 |
xtor_maps: thm list, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
26 |
xtor_map_uniques: thm list, |
| 58584 | 27 |
xtor_setss: thm list list, |
| 58585 | 28 |
xtor_rels: thm list, |
| 59819 | 29 |
xtor_un_fold_thms: thm list, |
| 55868 | 30 |
xtor_co_rec_thms: thm list, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
31 |
xtor_un_fold_uniques: thm list, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
32 |
xtor_co_rec_uniques: thm list, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
33 |
xtor_un_fold_o_maps: thm list, |
|
58578
9ff8ca957c02
rename 'xtor_co_rec_o_map_thms' to 'xtor_co_rec_o_maps'
desharna
parents:
58448
diff
changeset
|
34 |
xtor_co_rec_o_maps: thm list, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
35 |
xtor_un_fold_transfers: thm list, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
36 |
xtor_co_rec_transfers: thm list, |
|
58579
b7bc5ba2f3fb
rename 'rel_xtor_co_induct_thm' to 'xtor_rel_co_induct'
desharna
parents:
58578
diff
changeset
|
37 |
xtor_rel_co_induct: thm, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
38 |
dtor_set_inducts: thm list} |
|
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49589
diff
changeset
|
39 |
|
|
51823
38996458bc5c
create data structure for storing (co)datatype information
blanchet
parents:
51819
diff
changeset
|
40 |
val morph_fp_result: morphism -> fp_result -> fp_result |
|
38996458bc5c
create data structure for storing (co)datatype information
blanchet
parents:
51819
diff
changeset
|
41 |
|
|
53143
ba80154a1118
configuration option to control timing output for (co)datatypes
traytel
parents:
53138
diff
changeset
|
42 |
val time: Proof.context -> Timer.real_timer -> string -> Timer.real_timer |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
43 |
|
|
55851
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
44 |
val fixpoint: ('a * 'a -> bool) -> ('a list -> 'a list) -> 'a list -> 'a list
|
|
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
45 |
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
46 |
val IITN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
47 |
val LevN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
48 |
val algN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
49 |
val behN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
50 |
val bisN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
51 |
val carTN: string |
| 49338 | 52 |
val caseN: string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
53 |
val coN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
54 |
val coinductN: string |
|
57983
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
55 |
val coinduct_strongN: string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
56 |
val corecN: string |
|
57983
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
57 |
val corec_discN: string |
|
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
58 |
val corec_disc_iffN: string |
| 49501 | 59 |
val ctorN: string |
60 |
val ctor_dtorN: string |
|
61 |
val ctor_exhaustN: string |
|
62 |
val ctor_induct2N: string |
|
63 |
val ctor_inductN: string |
|
64 |
val ctor_injectN: string |
|
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49502
diff
changeset
|
65 |
val ctor_foldN: string |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
66 |
val ctor_fold_o_mapN: string |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
67 |
val ctor_fold_transferN: string |
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49502
diff
changeset
|
68 |
val ctor_fold_uniqueN: string |
| 49541 | 69 |
val ctor_mapN: string |
|
49543
53b3c532a082
renamed low-level "map_unique" to have "ctor" or "dtor" in the name
blanchet
parents:
49542
diff
changeset
|
70 |
val ctor_map_uniqueN: string |
| 49501 | 71 |
val ctor_recN: string |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
72 |
val ctor_rec_o_mapN: string |
| 58444 | 73 |
val ctor_rec_transferN: string |
|
51739
3514b90d0a8b
(co)rec is (just as the (un)fold) the unique morphism;
traytel
parents:
49635
diff
changeset
|
74 |
val ctor_rec_uniqueN: string |
|
49518
b377da40244b
renamed LFP low-level rel property to have ctor not dtor in its name
blanchet
parents:
49516
diff
changeset
|
75 |
val ctor_relN: string |
|
55901
8c6d49dd8ae1
renamed a pair of low-level theorems to have c/dtor in their names (like the others)
blanchet
parents:
55899
diff
changeset
|
76 |
val ctor_rel_inductN: string |
|
49544
24094fa47e0d
renamed "set_incl" etc. to have "ctor" or "dtor" in the name
blanchet
parents:
49543
diff
changeset
|
77 |
val ctor_set_inclN: string |
|
24094fa47e0d
renamed "set_incl" etc. to have "ctor" or "dtor" in the name
blanchet
parents:
49543
diff
changeset
|
78 |
val ctor_set_set_inclN: string |
| 49501 | 79 |
val dtorN: string |
|
49582
557302525778
renamed "dtor_rel_coinduct" etc. to "dtor_coinduct"
blanchet
parents:
49581
diff
changeset
|
80 |
val dtor_coinductN: string |
| 49501 | 81 |
val dtor_corecN: string |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
82 |
val dtor_corec_o_mapN: string |
| 58445 | 83 |
val dtor_corec_transferN: string |
|
51739
3514b90d0a8b
(co)rec is (just as the (un)fold) the unique morphism;
traytel
parents:
49635
diff
changeset
|
84 |
val dtor_corec_uniqueN: string |
|
49518
b377da40244b
renamed LFP low-level rel property to have ctor not dtor in its name
blanchet
parents:
49516
diff
changeset
|
85 |
val dtor_ctorN: string |
| 49501 | 86 |
val dtor_exhaustN: string |
87 |
val dtor_injectN: string |
|
|
49545
8bb6e2d7346b
renamed coinduction principles to have "dtor" in the name
blanchet
parents:
49544
diff
changeset
|
88 |
val dtor_mapN: string |
|
49581
4e5bd3883429
renamed "dtor_coinduct" etc. to "dtor_map_coinduct"
blanchet
parents:
49545
diff
changeset
|
89 |
val dtor_map_coinductN: string |
|
57983
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
90 |
val dtor_map_coinduct_strongN: string |
|
49543
53b3c532a082
renamed low-level "map_unique" to have "ctor" or "dtor" in the name
blanchet
parents:
49542
diff
changeset
|
91 |
val dtor_map_uniqueN: string |
|
49545
8bb6e2d7346b
renamed coinduction principles to have "dtor" in the name
blanchet
parents:
49544
diff
changeset
|
92 |
val dtor_relN: string |
|
55901
8c6d49dd8ae1
renamed a pair of low-level theorems to have c/dtor in their names (like the others)
blanchet
parents:
55899
diff
changeset
|
93 |
val dtor_rel_coinductN: string |
|
49544
24094fa47e0d
renamed "set_incl" etc. to have "ctor" or "dtor" in the name
blanchet
parents:
49543
diff
changeset
|
94 |
val dtor_set_inclN: string |
|
24094fa47e0d
renamed "set_incl" etc. to have "ctor" or "dtor" in the name
blanchet
parents:
49543
diff
changeset
|
95 |
val dtor_set_set_inclN: string |
|
57983
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
96 |
val dtor_coinduct_strongN: string |
|
49516
d4859efc1096
renamed "rel_simp" to "dtor_rel" and similarly for "srel"
blanchet
parents:
49510
diff
changeset
|
97 |
val dtor_unfoldN: string |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
98 |
val dtor_unfold_o_mapN: string |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
99 |
val dtor_unfold_transferN: string |
|
49516
d4859efc1096
renamed "rel_simp" to "dtor_rel" and similarly for "srel"
blanchet
parents:
49510
diff
changeset
|
100 |
val dtor_unfold_uniqueN: string |
|
49020
f379cf5d71bd
more work on BNF sugar -- up to derivation of nchotomy
blanchet
parents:
49019
diff
changeset
|
101 |
val exhaustN: string |
| 56113 | 102 |
val colN: string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
103 |
val inductN: string |
| 49019 | 104 |
val injectN: string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
105 |
val isNodeN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
106 |
val lsbisN: string |
|
49594
55e798614c45
tweaked theorem names (in particular, dropped s's)
blanchet
parents:
49592
diff
changeset
|
107 |
val mapN: string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
108 |
val map_uniqueN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
109 |
val min_algN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
110 |
val morN: string |
|
49020
f379cf5d71bd
more work on BNF sugar -- up to derivation of nchotomy
blanchet
parents:
49019
diff
changeset
|
111 |
val nchotomyN: string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
112 |
val recN: string |
| 57525 | 113 |
val rel_casesN: string |
| 51918 | 114 |
val rel_coinductN: string |
115 |
val rel_inductN: string |
|
|
49592
b859a02c1150
fixed "rels" + split them into injectivity and distinctness
blanchet
parents:
49591
diff
changeset
|
116 |
val rel_injectN: string |
| 57493 | 117 |
val rel_introsN: string |
|
49592
b859a02c1150
fixed "rels" + split them into injectivity and distinctness
blanchet
parents:
49591
diff
changeset
|
118 |
val rel_distinctN: string |
| 57563 | 119 |
val rel_selN: string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
120 |
val rvN: string |
|
57983
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
121 |
val corec_selN: string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
122 |
val set_inclN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
123 |
val set_set_inclN: string |
| 53694 | 124 |
val setN: string |
| 49438 | 125 |
val simpsN: string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
126 |
val strTN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
127 |
val str_initN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
128 |
val sum_bdN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
129 |
val sum_bdTN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
130 |
val uniqueN: string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
131 |
|
|
49585
5c4a12550491
generate high-level "maps", "sets", and "rels" properties
blanchet
parents:
49584
diff
changeset
|
132 |
(* TODO: Don't index set facts. Isabelle packages traditionally generate uniform names. *) |
|
49584
4339aa335355
use singular since there is always only one theorem
blanchet
parents:
49582
diff
changeset
|
133 |
val mk_ctor_setN: int -> string |
|
4339aa335355
use singular since there is always only one theorem
blanchet
parents:
49582
diff
changeset
|
134 |
val mk_dtor_setN: int -> string |
|
49542
b39354db8629
renamed low-level "set_simps" and "set_induct" to have "ctor" or "dtor" in the name
blanchet
parents:
49541
diff
changeset
|
135 |
val mk_dtor_set_inductN: int -> string |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
136 |
val mk_set_inductN: int -> string |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
137 |
|
|
55575
a5e33e18fb5c
moved 'primrec' up (for real this time) and removed temporary 'old_primrec'
blanchet
parents:
55570
diff
changeset
|
138 |
val co_prefix: BNF_Util.fp_kind -> string |
| 51863 | 139 |
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
140 |
val split_conj_thm: thm -> thm list |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
141 |
val split_conj_prems: int -> thm -> thm |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
142 |
|
|
49255
2ecc533d6697
use balanced sums for constructors (to gracefully handle 100 constructors or more)
blanchet
parents:
49240
diff
changeset
|
143 |
val mk_sumTN: typ list -> typ |
| 58159 | 144 |
val mk_sumTN_balanced: typ list -> typ |
| 55969 | 145 |
val mk_tupleT_balanced: typ list -> typ |
| 55966 | 146 |
val mk_sumprodT_balanced: typ list list -> typ |
|
49255
2ecc533d6697
use balanced sums for constructors (to gracefully handle 100 constructors or more)
blanchet
parents:
49240
diff
changeset
|
147 |
|
|
54923
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54171
diff
changeset
|
148 |
val mk_proj: typ -> int -> int -> term |
|
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54171
diff
changeset
|
149 |
|
| 53032 | 150 |
val mk_convol: term * term -> term |
| 58443 | 151 |
val mk_rel_prod: term -> term -> term |
152 |
val mk_rel_sum: term -> term -> term |
|
| 49368 | 153 |
|
| 49121 | 154 |
val Inl_const: typ -> typ -> term |
155 |
val Inr_const: typ -> typ -> term |
|
| 55969 | 156 |
val mk_tuple_balanced: term list -> term |
157 |
val mk_tuple1_balanced: typ list -> term list -> term |
|
| 59873 | 158 |
val abs_curried_balanced: typ list -> term -> term |
| 62124 | 159 |
val mk_tupled_fun: term -> term -> term list -> term |
| 49121 | 160 |
|
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
161 |
val mk_case_sum: term * term -> term |
|
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
162 |
val mk_case_sumN: term list -> term |
| 55968 | 163 |
val mk_case_absumprod: typ -> term -> term list -> term list list -> term list list -> term |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
164 |
|
|
49255
2ecc533d6697
use balanced sums for constructors (to gracefully handle 100 constructors or more)
blanchet
parents:
49240
diff
changeset
|
165 |
val mk_Inl: typ -> term -> term |
|
2ecc533d6697
use balanced sums for constructors (to gracefully handle 100 constructors or more)
blanchet
parents:
49240
diff
changeset
|
166 |
val mk_Inr: typ -> term -> term |
| 59673 | 167 |
val mk_sumprod_balanced: typ -> int -> int -> term list -> term |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
168 |
val mk_absumprod: typ -> term -> int -> int -> term list -> term |
| 49121 | 169 |
|
|
49255
2ecc533d6697
use balanced sums for constructors (to gracefully handle 100 constructors or more)
blanchet
parents:
49240
diff
changeset
|
170 |
val dest_sumT: typ -> typ * typ |
| 58159 | 171 |
val dest_sumTN_balanced: int -> typ -> typ list |
172 |
val dest_tupleT_balanced: int -> typ -> typ list |
|
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
173 |
val dest_absumprodT: typ -> typ -> int -> int list -> typ -> typ list list |
| 49176 | 174 |
|
|
53202
2333fae25719
export one more ML function, needed for primcorec
blanchet
parents:
53143
diff
changeset
|
175 |
val If_const: typ -> term |
|
2333fae25719
export one more ML function, needed for primcorec
blanchet
parents:
53143
diff
changeset
|
176 |
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
177 |
val mk_Field: term -> term |
| 49275 | 178 |
val mk_If: term -> term -> term -> term |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
179 |
val mk_union: term * term -> term |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
180 |
|
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
181 |
val mk_absumprodE: thm -> int list -> thm |
|
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
182 |
|
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
183 |
val mk_sum_caseN: int -> int -> thm |
|
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
184 |
val mk_sum_caseN_balanced: int -> int -> thm |
| 49125 | 185 |
|
|
55851
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
186 |
val mk_sum_Cinfinite: thm list -> thm |
|
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
187 |
val mk_sum_card_order: thm list -> thm |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
188 |
|
|
58579
b7bc5ba2f3fb
rename 'rel_xtor_co_induct_thm' to 'xtor_rel_co_induct'
desharna
parents:
58578
diff
changeset
|
189 |
val mk_xtor_rel_co_induct_thm: BNF_Util.fp_kind -> term list -> term list -> term list -> |
|
55575
a5e33e18fb5c
moved 'primrec' up (for real this time) and removed temporary 'old_primrec'
blanchet
parents:
55570
diff
changeset
|
190 |
term list -> term list -> term list -> term list -> term list -> |
|
52505
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
191 |
({prems: thm list, context: Proof.context} -> tactic) -> Proof.context -> thm
|
| 58443 | 192 |
val mk_co_iter_transfer_thms: BNF_Util.fp_kind -> term list -> term list -> term list -> |
193 |
term list -> term list -> term list -> term list -> |
|
194 |
({prems: thm list, context: Proof.context} -> tactic) -> Proof.context -> thm list
|
|
|
55575
a5e33e18fb5c
moved 'primrec' up (for real this time) and removed temporary 'old_primrec'
blanchet
parents:
55570
diff
changeset
|
195 |
val mk_xtor_un_fold_o_map_thms: BNF_Util.fp_kind -> bool -> int -> thm -> thm list -> thm list -> |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
196 |
thm list -> thm list -> thm list |
|
52505
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
197 |
|
| 51867 | 198 |
val fp_bnf: (binding list -> (string * sort) list -> typ list * typ list list -> |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
199 |
BNF_Def.bnf list -> BNF_Comp.absT_info list -> local_theory -> 'a) -> |
| 55701 | 200 |
binding list -> (string * sort) list -> (string * sort) list -> ((string * sort) * typ) list -> |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
201 |
local_theory -> (BNF_Def.bnf list * BNF_Comp.absT_info list) * 'a |
|
58256
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
202 |
val fp_antiquote_setup: binding -> theory -> theory |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
203 |
end; |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
204 |
|
|
51850
106afdf5806c
renamed a few FP-related files, to make it clear that these are not the sum of LFP + GFP but rather shared basic libraries
blanchet
parents:
51839
diff
changeset
|
205 |
structure BNF_FP_Util : BNF_FP_UTIL = |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
206 |
struct |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
207 |
|
|
56650
1f9ab71d43a5
no need to make 'size' generation an interpretation -- overkill
blanchet
parents:
56113
diff
changeset
|
208 |
open Ctr_Sugar |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
209 |
open BNF_Comp |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
210 |
open BNF_Def |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
211 |
open BNF_Util |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
212 |
|
|
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49589
diff
changeset
|
213 |
type fp_result = |
| 51859 | 214 |
{Ts: typ list,
|
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
215 |
bnfs: bnf list, |
| 51839 | 216 |
ctors: term list, |
| 51819 | 217 |
dtors: term list, |
| 59819 | 218 |
xtor_un_folds: term list, |
| 55868 | 219 |
xtor_co_recs: term list, |
| 53106 | 220 |
xtor_co_induct: thm, |
| 51819 | 221 |
dtor_ctors: thm list, |
222 |
ctor_dtors: thm list, |
|
223 |
ctor_injects: thm list, |
|
|
53203
222ea6acbdd6
moved derivation of ctor_dtor_unfold to sugar (streamlines fp_result interface)
traytel
parents:
53202
diff
changeset
|
224 |
dtor_injects: thm list, |
| 58583 | 225 |
xtor_maps: thm list, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
226 |
xtor_map_uniques: thm list, |
| 58584 | 227 |
xtor_setss: thm list list, |
| 58585 | 228 |
xtor_rels: thm list, |
| 59819 | 229 |
xtor_un_fold_thms: thm list, |
| 55868 | 230 |
xtor_co_rec_thms: thm list, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
231 |
xtor_un_fold_uniques: thm list, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
232 |
xtor_co_rec_uniques: thm list, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
233 |
xtor_un_fold_o_maps: thm list, |
|
58578
9ff8ca957c02
rename 'xtor_co_rec_o_map_thms' to 'xtor_co_rec_o_maps'
desharna
parents:
58448
diff
changeset
|
234 |
xtor_co_rec_o_maps: thm list, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
235 |
xtor_un_fold_transfers: thm list, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
236 |
xtor_co_rec_transfers: thm list, |
|
58579
b7bc5ba2f3fb
rename 'rel_xtor_co_induct_thm' to 'xtor_rel_co_induct'
desharna
parents:
58578
diff
changeset
|
237 |
xtor_rel_co_induct: thm, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
238 |
dtor_set_inducts: thm list}; |
|
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49589
diff
changeset
|
239 |
|
| 59819 | 240 |
fun morph_fp_result phi {Ts, bnfs, ctors, dtors, xtor_un_folds, xtor_co_recs, xtor_co_induct,
|
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
241 |
dtor_ctors, ctor_dtors, ctor_injects, dtor_injects, xtor_maps, xtor_map_uniques, xtor_setss, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
242 |
xtor_rels, xtor_un_fold_thms, xtor_co_rec_thms, xtor_un_fold_uniques, xtor_co_rec_uniques, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
243 |
xtor_un_fold_o_maps, xtor_co_rec_o_maps, xtor_un_fold_transfers, xtor_co_rec_transfers, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
244 |
xtor_rel_co_induct, dtor_set_inducts} = |
| 51859 | 245 |
{Ts = map (Morphism.typ phi) Ts,
|
246 |
bnfs = map (morph_bnf phi) bnfs, |
|
| 51839 | 247 |
ctors = map (Morphism.term phi) ctors, |
|
51823
38996458bc5c
create data structure for storing (co)datatype information
blanchet
parents:
51819
diff
changeset
|
248 |
dtors = map (Morphism.term phi) dtors, |
| 59819 | 249 |
xtor_un_folds = map (Morphism.term phi) xtor_un_folds, |
| 55868 | 250 |
xtor_co_recs = map (Morphism.term phi) xtor_co_recs, |
| 53106 | 251 |
xtor_co_induct = Morphism.thm phi xtor_co_induct, |
|
51823
38996458bc5c
create data structure for storing (co)datatype information
blanchet
parents:
51819
diff
changeset
|
252 |
dtor_ctors = map (Morphism.thm phi) dtor_ctors, |
|
38996458bc5c
create data structure for storing (co)datatype information
blanchet
parents:
51819
diff
changeset
|
253 |
ctor_dtors = map (Morphism.thm phi) ctor_dtors, |
|
38996458bc5c
create data structure for storing (co)datatype information
blanchet
parents:
51819
diff
changeset
|
254 |
ctor_injects = map (Morphism.thm phi) ctor_injects, |
|
53203
222ea6acbdd6
moved derivation of ctor_dtor_unfold to sugar (streamlines fp_result interface)
traytel
parents:
53202
diff
changeset
|
255 |
dtor_injects = map (Morphism.thm phi) dtor_injects, |
| 58583 | 256 |
xtor_maps = map (Morphism.thm phi) xtor_maps, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
257 |
xtor_map_uniques = map (Morphism.thm phi) xtor_map_uniques, |
| 58584 | 258 |
xtor_setss = map (map (Morphism.thm phi)) xtor_setss, |
| 58585 | 259 |
xtor_rels = map (Morphism.thm phi) xtor_rels, |
| 59819 | 260 |
xtor_un_fold_thms = map (Morphism.thm phi) xtor_un_fold_thms, |
| 55868 | 261 |
xtor_co_rec_thms = map (Morphism.thm phi) xtor_co_rec_thms, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
262 |
xtor_un_fold_uniques = map (Morphism.thm phi) xtor_un_fold_uniques, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
263 |
xtor_co_rec_uniques = map (Morphism.thm phi) xtor_co_rec_uniques, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
264 |
xtor_un_fold_o_maps = map (Morphism.thm phi) xtor_un_fold_o_maps, |
|
58578
9ff8ca957c02
rename 'xtor_co_rec_o_map_thms' to 'xtor_co_rec_o_maps'
desharna
parents:
58448
diff
changeset
|
265 |
xtor_co_rec_o_maps = map (Morphism.thm phi) xtor_co_rec_o_maps, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
266 |
xtor_un_fold_transfers = map (Morphism.thm phi) xtor_un_fold_transfers, |
|
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
267 |
xtor_co_rec_transfers = map (Morphism.thm phi) xtor_co_rec_transfers, |
|
58579
b7bc5ba2f3fb
rename 'rel_xtor_co_induct_thm' to 'xtor_rel_co_induct'
desharna
parents:
58578
diff
changeset
|
268 |
xtor_rel_co_induct = Morphism.thm phi xtor_rel_co_induct, |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
269 |
dtor_set_inducts = map (Morphism.thm phi) dtor_set_inducts}; |
|
51823
38996458bc5c
create data structure for storing (co)datatype information
blanchet
parents:
51819
diff
changeset
|
270 |
|
|
53143
ba80154a1118
configuration option to control timing output for (co)datatypes
traytel
parents:
53138
diff
changeset
|
271 |
fun time ctxt timer msg = (if Config.get ctxt bnf_timing |
| 55811 | 272 |
then warning (msg ^ ": " ^ string_of_int (Time.toMilliseconds (Timer.checkRealTimer timer)) ^ |
273 |
"ms") |
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
274 |
else (); Timer.startRealTimer ()); |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
275 |
|
| 49223 | 276 |
val preN = "pre_" |
277 |
val rawN = "raw_" |
|
| 49218 | 278 |
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
279 |
val coN = "co" |
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49502
diff
changeset
|
280 |
val unN = "un" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
281 |
val algN = "alg" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
282 |
val IITN = "IITN" |
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49502
diff
changeset
|
283 |
val foldN = "fold" |
|
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49502
diff
changeset
|
284 |
val unfoldN = unN ^ foldN |
| 62125 | 285 |
val uniqueN = "unique" |
286 |
val transferN = "transfer" |
|
| 49438 | 287 |
val simpsN = "simps" |
| 49501 | 288 |
val ctorN = "ctor" |
289 |
val dtorN = "dtor" |
|
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49502
diff
changeset
|
290 |
val ctor_foldN = ctorN ^ "_" ^ foldN |
|
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49502
diff
changeset
|
291 |
val dtor_unfoldN = dtorN ^ "_" ^ unfoldN |
| 62125 | 292 |
val ctor_fold_uniqueN = ctor_foldN ^ "_" ^ uniqueN |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
293 |
val ctor_fold_o_mapN = ctor_foldN ^ "_o_" ^ mapN |
| 62125 | 294 |
val dtor_unfold_uniqueN = dtor_unfoldN ^ "_" ^ uniqueN |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
295 |
val dtor_unfold_o_mapN = dtor_unfoldN ^ "_o_" ^ mapN |
| 62125 | 296 |
val ctor_fold_transferN = ctor_foldN ^ "_" ^ transferN |
297 |
val dtor_unfold_transferN = dtor_unfoldN ^ "_" ^ transferN |
|
| 49541 | 298 |
val ctor_mapN = ctorN ^ "_" ^ mapN |
299 |
val dtor_mapN = dtorN ^ "_" ^ mapN |
|
| 62125 | 300 |
val map_uniqueN = mapN ^ "_" ^ uniqueN |
|
49543
53b3c532a082
renamed low-level "map_unique" to have "ctor" or "dtor" in the name
blanchet
parents:
49542
diff
changeset
|
301 |
val ctor_map_uniqueN = ctorN ^ "_" ^ map_uniqueN |
|
53b3c532a082
renamed low-level "map_unique" to have "ctor" or "dtor" in the name
blanchet
parents:
49542
diff
changeset
|
302 |
val dtor_map_uniqueN = dtorN ^ "_" ^ map_uniqueN |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
303 |
val min_algN = "min_alg" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
304 |
val morN = "mor" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
305 |
val bisN = "bis" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
306 |
val lsbisN = "lsbis" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
307 |
val sum_bdTN = "sbdT" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
308 |
val sum_bdN = "sbd" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
309 |
val carTN = "carT" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
310 |
val strTN = "strT" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
311 |
val isNodeN = "isNode" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
312 |
val LevN = "Lev" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
313 |
val rvN = "recover" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
314 |
val behN = "beh" |
| 53694 | 315 |
val setN = "set" |
|
49584
4339aa335355
use singular since there is always only one theorem
blanchet
parents:
49582
diff
changeset
|
316 |
val mk_ctor_setN = prefix (ctorN ^ "_") o mk_setN |
|
4339aa335355
use singular since there is always only one theorem
blanchet
parents:
49582
diff
changeset
|
317 |
val mk_dtor_setN = prefix (dtorN ^ "_") o mk_setN |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
318 |
fun mk_set_inductN i = mk_setN i ^ "_induct" |
|
49542
b39354db8629
renamed low-level "set_simps" and "set_induct" to have "ctor" or "dtor" in the name
blanchet
parents:
49541
diff
changeset
|
319 |
val mk_dtor_set_inductN = prefix (dtorN ^ "_") o mk_set_inductN |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
320 |
|
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
321 |
val str_initN = "str_init" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
322 |
val recN = "rec" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
323 |
val corecN = coN ^ recN |
| 49501 | 324 |
val ctor_recN = ctorN ^ "_" ^ recN |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
325 |
val ctor_rec_o_mapN = ctor_recN ^ "_o_" ^ mapN |
| 62125 | 326 |
val ctor_rec_transferN = ctor_recN ^ "_" ^ transferN |
327 |
val ctor_rec_uniqueN = ctor_recN ^ "_" ^ uniqueN |
|
| 49501 | 328 |
val dtor_corecN = dtorN ^ "_" ^ corecN |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
329 |
val dtor_corec_o_mapN = dtor_corecN ^ "_o_" ^ mapN |
| 62125 | 330 |
val dtor_corec_transferN = dtor_corecN ^ "_" ^ transferN |
331 |
val dtor_corec_uniqueN = dtor_corecN ^ "_" ^ uniqueN |
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
332 |
|
| 49501 | 333 |
val ctor_dtorN = ctorN ^ "_" ^ dtorN |
334 |
val dtor_ctorN = dtorN ^ "_" ^ ctorN |
|
|
49020
f379cf5d71bd
more work on BNF sugar -- up to derivation of nchotomy
blanchet
parents:
49019
diff
changeset
|
335 |
val nchotomyN = "nchotomy" |
| 49019 | 336 |
val injectN = "inject" |
|
49020
f379cf5d71bd
more work on BNF sugar -- up to derivation of nchotomy
blanchet
parents:
49019
diff
changeset
|
337 |
val exhaustN = "exhaust" |
|
49585
5c4a12550491
generate high-level "maps", "sets", and "rels" properties
blanchet
parents:
49584
diff
changeset
|
338 |
val ctor_injectN = ctorN ^ "_" ^ injectN |
|
5c4a12550491
generate high-level "maps", "sets", and "rels" properties
blanchet
parents:
49584
diff
changeset
|
339 |
val ctor_exhaustN = ctorN ^ "_" ^ exhaustN |
|
5c4a12550491
generate high-level "maps", "sets", and "rels" properties
blanchet
parents:
49584
diff
changeset
|
340 |
val dtor_injectN = dtorN ^ "_" ^ injectN |
|
5c4a12550491
generate high-level "maps", "sets", and "rels" properties
blanchet
parents:
49584
diff
changeset
|
341 |
val dtor_exhaustN = dtorN ^ "_" ^ exhaustN |
|
49545
8bb6e2d7346b
renamed coinduction principles to have "dtor" in the name
blanchet
parents:
49544
diff
changeset
|
342 |
val ctor_relN = ctorN ^ "_" ^ relN |
|
8bb6e2d7346b
renamed coinduction principles to have "dtor" in the name
blanchet
parents:
49544
diff
changeset
|
343 |
val dtor_relN = dtorN ^ "_" ^ relN |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
344 |
val inductN = "induct" |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
345 |
val coinductN = coN ^ inductN |
| 49501 | 346 |
val ctor_inductN = ctorN ^ "_" ^ inductN |
347 |
val ctor_induct2N = ctor_inductN ^ "2" |
|
|
49581
4e5bd3883429
renamed "dtor_coinduct" etc. to "dtor_map_coinduct"
blanchet
parents:
49545
diff
changeset
|
348 |
val dtor_map_coinductN = dtor_mapN ^ "_" ^ coinductN |
|
49582
557302525778
renamed "dtor_rel_coinduct" etc. to "dtor_coinduct"
blanchet
parents:
49581
diff
changeset
|
349 |
val dtor_coinductN = dtorN ^ "_" ^ coinductN |
|
57983
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
350 |
val coinduct_strongN = coinductN ^ "_strong" |
|
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
351 |
val dtor_map_coinduct_strongN = dtor_mapN ^ "_" ^ coinduct_strongN |
|
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
352 |
val dtor_coinduct_strongN = dtorN ^ "_" ^ coinduct_strongN |
| 56113 | 353 |
val colN = "col" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
354 |
val set_inclN = "set_incl" |
|
49544
24094fa47e0d
renamed "set_incl" etc. to have "ctor" or "dtor" in the name
blanchet
parents:
49543
diff
changeset
|
355 |
val ctor_set_inclN = ctorN ^ "_" ^ set_inclN |
|
24094fa47e0d
renamed "set_incl" etc. to have "ctor" or "dtor" in the name
blanchet
parents:
49543
diff
changeset
|
356 |
val dtor_set_inclN = dtorN ^ "_" ^ set_inclN |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
357 |
val set_set_inclN = "set_set_incl" |
|
49544
24094fa47e0d
renamed "set_incl" etc. to have "ctor" or "dtor" in the name
blanchet
parents:
49543
diff
changeset
|
358 |
val ctor_set_set_inclN = ctorN ^ "_" ^ set_set_inclN |
|
24094fa47e0d
renamed "set_incl" etc. to have "ctor" or "dtor" in the name
blanchet
parents:
49543
diff
changeset
|
359 |
val dtor_set_set_inclN = dtorN ^ "_" ^ set_set_inclN |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
360 |
|
| 49338 | 361 |
val caseN = "case" |
| 49342 | 362 |
val discN = "disc" |
|
57983
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
363 |
val corec_discN = corecN ^ "_" ^ discN |
|
49594
55e798614c45
tweaked theorem names (in particular, dropped s's)
blanchet
parents:
49592
diff
changeset
|
364 |
val iffN = "_iff" |
|
57983
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
365 |
val corec_disc_iffN = corec_discN ^ iffN |
|
49592
b859a02c1150
fixed "rels" + split them into injectivity and distinctness
blanchet
parents:
49591
diff
changeset
|
366 |
val distinctN = "distinct" |
|
b859a02c1150
fixed "rels" + split them into injectivity and distinctness
blanchet
parents:
49591
diff
changeset
|
367 |
val rel_distinctN = relN ^ "_" ^ distinctN |
|
b859a02c1150
fixed "rels" + split them into injectivity and distinctness
blanchet
parents:
49591
diff
changeset
|
368 |
val injectN = "inject" |
| 57525 | 369 |
val rel_casesN = relN ^ "_cases" |
|
49592
b859a02c1150
fixed "rels" + split them into injectivity and distinctness
blanchet
parents:
49591
diff
changeset
|
370 |
val rel_injectN = relN ^ "_" ^ injectN |
| 57493 | 371 |
val rel_introsN = relN ^ "_intros" |
| 51918 | 372 |
val rel_coinductN = relN ^ "_" ^ coinductN |
| 57563 | 373 |
val rel_selN = relN ^ "_sel" |
|
55901
8c6d49dd8ae1
renamed a pair of low-level theorems to have c/dtor in their names (like the others)
blanchet
parents:
55899
diff
changeset
|
374 |
val dtor_rel_coinductN = dtorN ^ "_" ^ rel_coinductN |
| 51918 | 375 |
val rel_inductN = relN ^ "_" ^ inductN |
|
55901
8c6d49dd8ae1
renamed a pair of low-level theorems to have c/dtor in their names (like the others)
blanchet
parents:
55899
diff
changeset
|
376 |
val ctor_rel_inductN = ctorN ^ "_" ^ rel_inductN |
| 49342 | 377 |
val selN = "sel" |
|
57983
6edc3529bb4e
reordered some (co)datatype property names for more consistency
blanchet
parents:
57700
diff
changeset
|
378 |
val corec_selN = corecN ^ "_" ^ selN |
| 49338 | 379 |
|
| 55966 | 380 |
fun co_prefix fp = case_fp fp "" "co"; |
| 51863 | 381 |
|
| 49264 | 382 |
fun dest_sumT (Type (@{type_name sum}, [T, T'])) = (T, T');
|
383 |
||
384 |
val dest_sumTN_balanced = Balanced_Tree.dest dest_sumT; |
|
385 |
||
| 55966 | 386 |
fun dest_tupleT_balanced 0 @{typ unit} = []
|
387 |
| dest_tupleT_balanced n T = Balanced_Tree.dest HOLogic.dest_prodT n T; |
|
| 49264 | 388 |
|
| 55966 | 389 |
fun dest_absumprodT absT repT n ms = |
390 |
map2 dest_tupleT_balanced ms o dest_sumTN_balanced n o mk_repT absT repT; |
|
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
391 |
|
| 49264 | 392 |
val mk_sumTN = Library.foldr1 mk_sumT; |
393 |
val mk_sumTN_balanced = Balanced_Tree.make mk_sumT; |
|
|
49255
2ecc533d6697
use balanced sums for constructors (to gracefully handle 100 constructors or more)
blanchet
parents:
49240
diff
changeset
|
394 |
|
| 55966 | 395 |
fun mk_tupleT_balanced [] = HOLogic.unitT |
396 |
| mk_tupleT_balanced Ts = Balanced_Tree.make HOLogic.mk_prodT Ts; |
|
397 |
||
398 |
val mk_sumprodT_balanced = mk_sumTN_balanced o map mk_tupleT_balanced; |
|
399 |
||
|
54923
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54171
diff
changeset
|
400 |
fun mk_proj T n k = |
|
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54171
diff
changeset
|
401 |
let val (binders, _) = strip_typeN n T in |
|
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54171
diff
changeset
|
402 |
fold_rev (fn T => fn t => Abs (Name.uu, T, t)) binders (Bound (n - k - 1)) |
|
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54171
diff
changeset
|
403 |
end; |
|
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54171
diff
changeset
|
404 |
|
| 53032 | 405 |
fun mk_convol (f, g) = |
406 |
let |
|
407 |
val (fU, fTU) = `range_type (fastype_of f); |
|
408 |
val ((gT, gU), gTU) = `dest_funT (fastype_of g); |
|
409 |
val convolT = fTU --> gTU --> gT --> HOLogic.mk_prodT (fU, gU); |
|
410 |
in Const (@{const_name convol}, convolT) $ f $ g end;
|
|
| 49368 | 411 |
|
| 58443 | 412 |
fun mk_rel_prod R S = |
413 |
let |
|
414 |
val ((A1, A2), RT) = `dest_pred2T (fastype_of R); |
|
415 |
val ((B1, B2), ST) = `dest_pred2T (fastype_of S); |
|
416 |
val rel_prodT = RT --> ST --> mk_pred2T (HOLogic.mk_prodT (A1, B1)) (HOLogic.mk_prodT (A2, B2)); |
|
417 |
in Const (@{const_name rel_prod}, rel_prodT) $ R $ S end;
|
|
418 |
||
419 |
fun mk_rel_sum R S = |
|
420 |
let |
|
421 |
val ((A1, A2), RT) = `dest_pred2T (fastype_of R); |
|
422 |
val ((B1, B2), ST) = `dest_pred2T (fastype_of S); |
|
423 |
val rel_sumT = RT --> ST --> mk_pred2T (mk_sumT (A1, B1)) (mk_sumT (A2, B2)); |
|
424 |
in Const (@{const_name rel_sum}, rel_sumT) $ R $ S end;
|
|
425 |
||
| 49121 | 426 |
fun Inl_const LT RT = Const (@{const_name Inl}, LT --> mk_sumT (LT, RT));
|
|
49255
2ecc533d6697
use balanced sums for constructors (to gracefully handle 100 constructors or more)
blanchet
parents:
49240
diff
changeset
|
427 |
fun mk_Inl RT t = Inl_const (fastype_of t) RT $ t; |
| 49121 | 428 |
|
429 |
fun Inr_const LT RT = Const (@{const_name Inr}, RT --> mk_sumT (LT, RT));
|
|
|
49255
2ecc533d6697
use balanced sums for constructors (to gracefully handle 100 constructors or more)
blanchet
parents:
49240
diff
changeset
|
430 |
fun mk_Inr LT t = Inr_const LT (fastype_of t) $ t; |
| 49121 | 431 |
|
| 55969 | 432 |
fun mk_prod1 bound_Ts (t, u) = |
433 |
HOLogic.pair_const (fastype_of1 (bound_Ts, t)) (fastype_of1 (bound_Ts, u)) $ t $ u; |
|
434 |
||
435 |
fun mk_tuple1_balanced _ [] = HOLogic.unit |
|
436 |
| mk_tuple1_balanced bound_Ts ts = Balanced_Tree.make (mk_prod1 bound_Ts) ts; |
|
437 |
||
438 |
val mk_tuple_balanced = mk_tuple1_balanced []; |
|
| 55966 | 439 |
|
| 59873 | 440 |
fun abs_curried_balanced Ts t = |
441 |
t $ mk_tuple1_balanced (List.rev Ts) (map Bound (length Ts - 1 downto 0)) |
|
442 |
|> fold_rev (Term.abs o pair Name.uu) Ts; |
|
443 |
||
| 59673 | 444 |
fun mk_sumprod_balanced T n k ts = Sum_Tree.mk_inj T n k (mk_tuple_balanced ts); |
445 |
||
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
446 |
fun mk_absumprod absT abs0 n k ts = |
|
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
447 |
let val abs = mk_abs absT abs0; |
| 59673 | 448 |
in abs $ mk_sumprod_balanced (domain_type (fastype_of abs)) n k ts end; |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
449 |
|
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
450 |
fun mk_case_sum (f, g) = |
| 49129 | 451 |
let |
| 55968 | 452 |
val (fT, T') = dest_funT (fastype_of f); |
453 |
val (gT, _) = dest_funT (fastype_of g); |
|
| 49129 | 454 |
in |
| 55968 | 455 |
Sum_Tree.mk_sumcase fT gT T' f g |
| 49129 | 456 |
end; |
457 |
||
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
458 |
val mk_case_sumN = Library.foldr1 mk_case_sum; |
|
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
459 |
val mk_case_sumN_balanced = Balanced_Tree.make mk_case_sum; |
| 49176 | 460 |
|
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
461 |
fun mk_tupled_fun f x xs = |
|
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
462 |
if xs = [x] then f else HOLogic.tupled_lambda x (Term.list_comb (f, xs)); |
|
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
463 |
|
| 55968 | 464 |
fun mk_case_absumprod absT rep fs xss xss' = |
| 62124 | 465 |
HOLogic.mk_comp (mk_case_sumN_balanced |
466 |
(@{map 3} mk_tupled_fun fs (map mk_tuple_balanced xss) xss'), mk_rep absT rep);
|
|
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
467 |
|
|
53202
2333fae25719
export one more ML function, needed for primcorec
blanchet
parents:
53143
diff
changeset
|
468 |
fun If_const T = Const (@{const_name If}, HOLogic.boolT --> T --> T --> T);
|
|
2333fae25719
export one more ML function, needed for primcorec
blanchet
parents:
53143
diff
changeset
|
469 |
fun mk_If p t f = let val T = fastype_of t in If_const T $ p $ t $ f end; |
| 49275 | 470 |
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
471 |
fun mk_Field r = |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
472 |
let val T = fst (dest_relT (fastype_of r)); |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
473 |
in Const (@{const_name Field}, mk_relT (T, T) --> HOLogic.mk_setT T) $ r end;
|
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
474 |
|
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
475 |
val mk_union = HOLogic.mk_binop @{const_name sup};
|
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
476 |
|
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
477 |
(*dangerous; use with monotonic, converging functions only!*) |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
478 |
fun fixpoint eq f X = if subset eq (f X, X) then X else fixpoint eq f (f X); |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
479 |
|
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
480 |
(* stolen from "~~/src/HOL/Tools/Datatype/datatype_aux.ML" *) |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
481 |
fun split_conj_thm th = |
| 49119 | 482 |
((th RS conjunct1) :: split_conj_thm (th RS conjunct2)) handle THM _ => [th]; |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
483 |
|
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
484 |
fun split_conj_prems limit th = |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
485 |
let |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
486 |
fun split n i th = |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
487 |
if i = n then th else split n (i + 1) (conjI RSN (i, th)) handle THM _ => th; |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
488 |
in split limit 1 th end; |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
489 |
|
| 49335 | 490 |
fun mk_obj_sumEN_balanced n = |
491 |
Balanced_Tree.make (fn (thm1, thm2) => thm1 RSN (1, thm2 RSN (2, @{thm obj_sumE_f})))
|
|
492 |
(replicate n asm_rl); |
|
493 |
||
| 55966 | 494 |
fun mk_tupled_allIN_balanced 0 = @{thm unit_all_impI}
|
495 |
| mk_tupled_allIN_balanced n = |
|
496 |
let |
|
497 |
val (tfrees, _) = BNF_Util.mk_TFrees n @{context};
|
|
498 |
val T = mk_tupleT_balanced tfrees; |
|
499 |
in |
|
500 |
@{thm asm_rl[of "ALL x. P x --> Q x" for P Q]}
|
|
| 60801 | 501 |
|> Thm.instantiate' [SOME (Thm.ctyp_of @{context} T)] []
|
| 55966 | 502 |
|> Raw_Simplifier.rewrite_goals_rule @{context} @{thms split_paired_All[THEN eq_reflection]}
|
503 |
|> (fn thm => impI RS funpow n (fn th => allI RS th) thm) |
|
504 |
|> Thm.varifyT_global |
|
505 |
end; |
|
| 49335 | 506 |
|
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
507 |
fun mk_absumprodE type_definition ms = |
| 49335 | 508 |
let val n = length ms in |
| 55966 | 509 |
mk_obj_sumEN_balanced n OF map mk_tupled_allIN_balanced ms RS |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
510 |
(type_definition RS @{thm type_copy_obj_one_point_absE})
|
| 49335 | 511 |
end; |
| 49264 | 512 |
|
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
513 |
fun mk_sum_caseN 1 1 = refl |
|
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
514 |
| mk_sum_caseN _ 1 = @{thm sum.case(1)}
|
|
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
515 |
| mk_sum_caseN 2 2 = @{thm sum.case(2)}
|
|
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
516 |
| mk_sum_caseN n k = trans OF [@{thm case_sum_step(2)}, mk_sum_caseN (n - 1) (k - 1)];
|
| 49264 | 517 |
|
518 |
fun mk_sum_step base step thm = |
|
519 |
if Thm.eq_thm_prop (thm, refl) then base else trans OF [step, thm]; |
|
520 |
||
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
521 |
fun mk_sum_caseN_balanced 1 1 = refl |
|
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55394
diff
changeset
|
522 |
| mk_sum_caseN_balanced n k = |
|
55642
63beb38e9258
adapted to renaming of datatype 'cases' and 'recs' to 'case' and 'rec'
blanchet
parents:
55575
diff
changeset
|
523 |
Balanced_Tree.access {left = mk_sum_step @{thm sum.case(1)} @{thm case_sum_step(1)},
|
|
63beb38e9258
adapted to renaming of datatype 'cases' and 'recs' to 'case' and 'rec'
blanchet
parents:
55575
diff
changeset
|
524 |
right = mk_sum_step @{thm sum.case(2)} @{thm case_sum_step(2)}, init = refl} n k;
|
|
49130
3c26e17b2849
implemented "mk_case_tac" -- and got rid of "cheat_tac"
blanchet
parents:
49129
diff
changeset
|
525 |
|
|
55851
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
526 |
fun mk_sum_Cinfinite [thm] = thm |
|
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
527 |
| mk_sum_Cinfinite (thm :: thms) = @{thm Cinfinite_csum_weak} OF [thm, mk_sum_Cinfinite thms];
|
|
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
528 |
|
|
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
529 |
fun mk_sum_card_order [thm] = thm |
|
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
530 |
| mk_sum_card_order (thm :: thms) = @{thm card_order_csum} OF [thm, mk_sum_card_order thms];
|
|
3d40cf74726c
optimize cardinal bounds involving natLeq (omega)
blanchet
parents:
55811
diff
changeset
|
531 |
|
|
58579
b7bc5ba2f3fb
rename 'rel_xtor_co_induct_thm' to 'xtor_rel_co_induct'
desharna
parents:
58578
diff
changeset
|
532 |
fun mk_xtor_rel_co_induct_thm fp pre_rels pre_phis rels phis xs ys xtors xtor's tac lthy = |
|
52505
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
533 |
let |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
534 |
val pre_relphis = map (fn rel => Term.list_comb (rel, phis @ pre_phis)) pre_rels; |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
535 |
val relphis = map (fn rel => Term.list_comb (rel, phis)) rels; |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
536 |
fun mk_xtor fp' xtor x = if fp = fp' then xtor $ x else x; |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
537 |
val dtor = mk_xtor Greatest_FP; |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
538 |
val ctor = mk_xtor Least_FP; |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
539 |
fun flip f x y = if fp = Greatest_FP then f y x else f x y; |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
540 |
|
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
541 |
fun mk_prem pre_relphi phi x y xtor xtor' = |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
542 |
HOLogic.mk_Trueprop (list_all_free [x, y] (flip (curry HOLogic.mk_imp) |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
543 |
(pre_relphi $ (dtor xtor x) $ (dtor xtor' y)) (phi $ (ctor xtor x) $ (ctor xtor' y)))); |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
544 |
val prems = @{map 6} mk_prem pre_relphis pre_phis xs ys xtors xtor's;
|
|
52505
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
545 |
|
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
546 |
val concl = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
547 |
(map2 (flip mk_leq) relphis pre_phis)); |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
548 |
in |
| 52506 | 549 |
Goal.prove_sorry lthy (map (fst o dest_Free) (phis @ pre_phis)) prems concl tac |
|
52505
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
550 |
|> Thm.close_derivation |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
551 |
|> (fn thm => thm OF (replicate (length pre_rels) @{thm allI[OF allI[OF impI]]}))
|
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
552 |
end; |
|
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
553 |
|
| 58443 | 554 |
fun mk_co_iter_transfer_thms fp pre_rels pre_iphis pre_ophis rels phis un_folds un_folds' tac lthy = |
| 52731 | 555 |
let |
| 58443 | 556 |
val pre_relphis = map (fn rel => Term.list_comb (rel, phis @ pre_iphis)) pre_rels; |
| 52731 | 557 |
val relphis = map (fn rel => Term.list_comb (rel, phis)) rels; |
558 |
fun flip f x y = if fp = Greatest_FP then f y x else f x y; |
|
559 |
||
| 58443 | 560 |
val arg_rels = map2 (flip mk_rel_fun) pre_relphis pre_ophis; |
| 52731 | 561 |
fun mk_transfer relphi pre_phi un_fold un_fold' = |
| 55945 | 562 |
fold_rev mk_rel_fun arg_rels (flip mk_rel_fun relphi pre_phi) $ un_fold $ un_fold'; |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
563 |
val transfers = @{map 4} mk_transfer relphis pre_ophis un_folds un_folds';
|
| 52731 | 564 |
|
| 58443 | 565 |
val goal = fold_rev Logic.all (phis @ pre_ophis) |
| 52731 | 566 |
(HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj transfers)); |
567 |
in |
|
568 |
Goal.prove_sorry lthy [] [] goal tac |
|
569 |
|> Thm.close_derivation |
|
570 |
|> split_conj_thm |
|
571 |
end; |
|
572 |
||
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
573 |
fun mk_xtor_un_fold_o_map_thms fp is_rec m un_fold_unique xtor_maps xtor_un_folds sym_map_comps |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
574 |
map_cong0s = |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
575 |
let |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
576 |
val n = length sym_map_comps; |
| 55966 | 577 |
val rewrite_comp_comp2 = case_fp fp @{thm rewriteR_comp_comp2} @{thm rewriteL_comp_comp2};
|
578 |
val rewrite_comp_comp = case_fp fp @{thm rewriteR_comp_comp} @{thm rewriteL_comp_comp};
|
|
579 |
val map_cong_passive_args1 = replicate m (case_fp fp @{thm id_comp} @{thm comp_id} RS fun_cong);
|
|
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
580 |
val map_cong_active_args1 = replicate n (if is_rec |
| 55966 | 581 |
then case_fp fp @{thm convol_o} @{thm o_case_sum} RS fun_cong
|
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
582 |
else refl); |
| 55966 | 583 |
val map_cong_passive_args2 = replicate m (case_fp fp @{thm comp_id} @{thm id_comp} RS fun_cong);
|
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
584 |
val map_cong_active_args2 = replicate n (if is_rec |
| 55966 | 585 |
then case_fp fp @{thm map_prod_o_convol_id} @{thm case_sum_o_map_sum_id}
|
586 |
else case_fp fp @{thm id_comp} @{thm comp_id} RS fun_cong);
|
|
| 55990 | 587 |
fun mk_map_congs passive active = |
588 |
map (fn thm => thm OF (passive @ active) RS @{thm ext}) map_cong0s;
|
|
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
589 |
val map_cong1s = mk_map_congs map_cong_passive_args1 map_cong_active_args1; |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
590 |
val map_cong2s = mk_map_congs map_cong_passive_args2 map_cong_active_args2; |
| 57489 | 591 |
|
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
592 |
fun mk_rewrites map_congs = map2 (fn sym_map_comp => fn map_cong => |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
593 |
mk_trans sym_map_comp map_cong RS rewrite_comp_comp) sym_map_comps map_congs; |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
594 |
val rewrite1s = mk_rewrites map_cong1s; |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
595 |
val rewrite2s = mk_rewrites map_cong2s; |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
596 |
val unique_prems = |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
597 |
@{map 4} (fn xtor_map => fn un_fold => fn rewrite1 => fn rewrite2 =>
|
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
598 |
mk_trans (rewrite_comp_comp2 OF [xtor_map, un_fold]) |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
599 |
(mk_trans rewrite1 (mk_sym rewrite2))) |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
600 |
xtor_maps xtor_un_folds rewrite1s rewrite2s; |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
601 |
in |
| 55966 | 602 |
split_conj_thm (un_fold_unique OF map (case_fp fp I mk_sym) unique_prems) |
|
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
603 |
end; |
|
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52899
diff
changeset
|
604 |
|
| 55701 | 605 |
fun fp_bnf construct_fp bs resBs Ds0 fp_eqs lthy = |
| 51868 | 606 |
let |
|
53143
ba80154a1118
configuration option to control timing output for (co)datatypes
traytel
parents:
53138
diff
changeset
|
607 |
val time = time lthy; |
| 51868 | 608 |
val timer = time (Timer.startRealTimer ()); |
| 58332 | 609 |
|
610 |
val nn = length fp_eqs; |
|
| 53222 | 611 |
val (Xs, rhsXs) = split_list fp_eqs; |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
612 |
|
| 58332 | 613 |
fun flatten_tyargs Ass = |
| 53222 | 614 |
subtract (op =) Xs (filter (fn T => exists (fn Ts => member (op =) Ts T) Ass) resBs) @ Xs; |
| 51868 | 615 |
|
| 53263 | 616 |
fun raw_qualify base_b = |
| 59858 | 617 |
let |
618 |
val qs = Binding.path_of base_b; |
|
619 |
val n = Binding.name_of base_b; |
|
| 53264 | 620 |
in |
621 |
Binding.prefix_name rawN |
|
622 |
#> fold_rev (fn (s, mand) => Binding.qualify mand s) (qs @ [(n, true)]) |
|
| 59859 | 623 |
#> Binding.concealed |
| 53264 | 624 |
end; |
| 51868 | 625 |
|
| 55904 | 626 |
val ((bnfs, (deadss, livess)), accum) = |
| 55706 | 627 |
apfst (apsnd split_list o split_list) |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
628 |
(@{fold_map 2}
|
|
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
629 |
(fn b => bnf_of_typ Smart_Inline (raw_qualify b) flatten_tyargs Xs Ds0) bs rhsXs |
| 55706 | 630 |
((empty_comp_cache, empty_unfolds), lthy)); |
| 51868 | 631 |
|
| 53566 | 632 |
fun norm_qualify i = Binding.qualify true (Binding.name_of (nth bs (Int.max (0, i - 1)))) |
| 59859 | 633 |
#> Binding.concealed; |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
634 |
|
| 49132 | 635 |
val Ass = map (map dest_TFree) livess; |
| 58332 | 636 |
val Ds' = fold (fold Term.add_tfreesT) deadss []; |
637 |
val Ds = union (op =) Ds' Ds0; |
|
638 |
val missing = resBs |> fold (subtract (op =)) (Ds' :: Ass); |
|
639 |
val (dead_phantoms, live_phantoms) = List.partition (member (op =) Ds0) missing; |
|
640 |
val resBs' = resBs |> fold (subtract (op =)) [dead_phantoms, Ds]; |
|
| 49132 | 641 |
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
642 |
val timer = time (timer "Construction of BNFs"); |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
643 |
|
| 55904 | 644 |
val ((kill_poss, _), (bnfs', ((_, unfold_set'), lthy'))) = |
| 58332 | 645 |
normalize_bnfs norm_qualify Ass Ds (K (resBs' @ Xs)) bnfs accum; |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
646 |
|
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
647 |
val Dss = @{map 3} (uncurry append oo curry swap oo map o nth) livess kill_poss deadss;
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
648 |
|
| 53566 | 649 |
fun pre_qualify b = Binding.qualify false (Binding.name_of b) |
| 62093 | 650 |
#> not (Config.get lthy' bnf_internals) ? Binding.concealed; |
| 53264 | 651 |
|
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
652 |
val ((pre_bnfs, (deadss, absT_infos)), lthy'') = |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
653 |
@{fold_map 4} (fn b => seal_bnf (pre_qualify b) unfold_set' (Binding.prefix_name preN b))
|
| 58332 | 654 |
bs (not (null live_phantoms) :: replicate (nn - 1) false) Dss bnfs' lthy' |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
655 |
|>> split_list |
|
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
656 |
|>> apsnd split_list; |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
657 |
|
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
658 |
val timer = time (timer "Normalization & sealing of BNFs"); |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
659 |
|
| 58332 | 660 |
val res = construct_fp bs resBs (map TFree dead_phantoms, deadss) pre_bnfs absT_infos lthy''; |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
661 |
|
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
662 |
val timer = time (timer "FP construction in total"); |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
663 |
in |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55706
diff
changeset
|
664 |
timer; ((pre_bnfs, absT_infos), res) |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
665 |
end; |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
666 |
|
|
58256
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
667 |
fun fp_antiquote_setup binding = |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
668 |
Thy_Output.antiquotation binding (Args.type_name {proper = true, strict = true})
|
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
669 |
(fn {source = src, context = ctxt, ...} => fn fcT_name =>
|
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
670 |
(case Ctr_Sugar.ctr_sugar_of ctxt fcT_name of |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
671 |
NONE => error ("Not a known freely generated type name: " ^ quote fcT_name)
|
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
672 |
| SOME {T = T0, ctrs = ctrs0, ...} =>
|
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
673 |
let |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
674 |
val freezeT = Term.map_atyps (fn TVar ((s, _), S) => TFree (s, S) | T => T); |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
675 |
|
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
676 |
val T = freezeT T0; |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
677 |
val ctrs = map (Term.map_types freezeT) ctrs0; |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
678 |
|
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
679 |
val pretty_typ_bracket = Syntax.pretty_typ (Config.put pretty_priority 1001 ctxt); |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
680 |
fun pretty_ctr ctr = |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
681 |
Pretty.block (Pretty.breaks (Syntax.pretty_term ctxt ctr :: |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
682 |
map pretty_typ_bracket (binder_types (fastype_of ctr)))); |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
683 |
val pretty_co_datatype = |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
684 |
Pretty.block (Pretty.keyword1 (Binding.name_of binding) :: Pretty.brk 1 :: |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
685 |
Syntax.pretty_typ ctxt T :: Pretty.str " =" :: Pretty.brk 1 :: |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
686 |
flat (separate [Pretty.brk 1, Pretty.str "| "] (map (single o pretty_ctr) ctrs))); |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
687 |
in |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
688 |
Thy_Output.output ctxt |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
689 |
(Thy_Output.maybe_pretty_source (K (K pretty_co_datatype)) ctxt src [()]) |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
690 |
end)); |
|
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58208
diff
changeset
|
691 |
|
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
692 |
end; |