author | wenzelm |
Sun, 26 Nov 2017 21:08:32 +0100 | |
changeset 67091 | 1393c2340eec |
parent 64413 | c0d5e78eb647 |
child 67399 | eab6ce8368fa |
permissions | -rw-r--r-- |
55061 | 1 |
(* Title: HOL/Tools/BNF/bnf_gfp.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 |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
3 |
Author: Andrei Popescu, TU Muenchen |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
4 |
Author: Jasmin Blanchette, TU Muenchen |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
5 |
Copyright 2012 |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
6 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
7 |
Codatatype construction. |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
8 |
*) |
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 |
signature BNF_GFP = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
11 |
sig |
62324 | 12 |
val construct_gfp: mixfix list -> binding list -> binding list -> binding list -> |
13 |
binding list list -> binding list -> (string * sort) list -> typ list * typ list list -> |
|
14 |
BNF_Def.bnf list -> BNF_Comp.absT_info list -> local_theory -> |
|
15 |
BNF_FP_Util.fp_result * local_theory |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
16 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
17 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
18 |
structure BNF_GFP : BNF_GFP = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
19 |
struct |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
20 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
21 |
open BNF_Def |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
22 |
open BNF_Util |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
23 |
open BNF_Tactics |
49585
5c4a12550491
generate high-level "maps", "sets", and "rels" properties
blanchet
parents:
49584
diff
changeset
|
24 |
open BNF_Comp |
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
|
25 |
open BNF_FP_Util |
49636 | 26 |
open BNF_FP_Def_Sugar |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
27 |
open BNF_GFP_Util |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
28 |
open BNF_GFP_Tactics |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
29 |
|
49460
4dd451a075ce
fixed infinite loop with trivial rel_O_Gr + tuning
blanchet
parents:
49459
diff
changeset
|
30 |
datatype wit_tree = Wit_Leaf of int | Wit_Node of (int * int * int list) * wit_tree list; |
49104 | 31 |
|
32 |
fun mk_tree_args (I, T) (I', Ts) = (sort_distinct int_ord (I @ I'), T :: Ts); |
|
33 |
||
34 |
fun finish Iss m seen i (nwit, I) = |
|
35 |
let |
|
36 |
val treess = map (fn j => |
|
49460
4dd451a075ce
fixed infinite loop with trivial rel_O_Gr + tuning
blanchet
parents:
49459
diff
changeset
|
37 |
if j < m orelse member (op =) seen j then [([j], Wit_Leaf j)] |
49104 | 38 |
else |
39 |
map_index (finish Iss m (insert (op =) j seen) j) (nth Iss (j - m)) |
|
40 |
|> flat |
|
41 |
|> minimize_wits) |
|
42 |
I; |
|
43 |
in |
|
49460
4dd451a075ce
fixed infinite loop with trivial rel_O_Gr + tuning
blanchet
parents:
49459
diff
changeset
|
44 |
map (fn (I, t) => (I, Wit_Node ((i - m, nwit, filter (fn i => i < m) I), t))) |
49104 | 45 |
(fold_rev (map_product mk_tree_args) treess [([], [])]) |
46 |
|> minimize_wits |
|
47 |
end; |
|
48 |
||
49501 | 49 |
fun tree_to_ctor_wit vars _ _ (Wit_Leaf j) = ([j], nth vars j) |
50 |
| tree_to_ctor_wit vars ctors witss (Wit_Node ((i, nwit, I), subtrees)) = |
|
51 |
(I, nth ctors i $ (Term.list_comb (snd (nth (nth witss i) nwit), |
|
52 |
map (snd o tree_to_ctor_wit vars ctors witss) subtrees))); |
|
49104 | 53 |
|
49460
4dd451a075ce
fixed infinite loop with trivial rel_O_Gr + tuning
blanchet
parents:
49459
diff
changeset
|
54 |
fun tree_to_coind_wits _ (Wit_Leaf _) = [] |
4dd451a075ce
fixed infinite loop with trivial rel_O_Gr + tuning
blanchet
parents:
49459
diff
changeset
|
55 |
| tree_to_coind_wits lwitss (Wit_Node ((i, nwit, I), subtrees)) = |
49104 | 56 |
((i, I), nth (nth lwitss i) nwit) :: maps (tree_to_coind_wits lwitss) subtrees; |
57 |
||
49460
4dd451a075ce
fixed infinite loop with trivial rel_O_Gr + tuning
blanchet
parents:
49459
diff
changeset
|
58 |
(*all BNFs have the same lives*) |
62684
cb20e8828196
document that n2m does not depend on most things in fp_sugar in its type
traytel
parents:
62324
diff
changeset
|
59 |
fun construct_gfp mixfixes map_bs rel_bs pred_bs set_bss0 bs resBs (resDs, Dss) bnfs absT_infos |
cb20e8828196
document that n2m does not depend on most things in fp_sugar in its type
traytel
parents:
62324
diff
changeset
|
60 |
lthy = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
61 |
let |
53143
ba80154a1118
configuration option to control timing output for (co)datatypes
traytel
parents:
53138
diff
changeset
|
62 |
val time = time lthy; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
63 |
val timer = time (Timer.startRealTimer ()); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
64 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
65 |
val live = live_of_bnf (hd bnfs); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
66 |
val n = length bnfs; (*active*) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
67 |
val ks = 1 upto n; |
52956 | 68 |
val m = live - n; (*passive, if 0 don't generate a new BNF*) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
69 |
val ls = 1 upto m; |
53566 | 70 |
|
62093 | 71 |
val internals = Config.get lthy bnf_internals; |
52956 | 72 |
val b_names = map Binding.name_of bs; |
53566 | 73 |
val b_name = mk_common_name b_names; |
74 |
val b = Binding.name b_name; |
|
58241
ff8059e3e803
generate better internal names, with name of the target type in it
blanchet
parents:
58208
diff
changeset
|
75 |
|
ff8059e3e803
generate better internal names, with name of the target type in it
blanchet
parents:
58208
diff
changeset
|
76 |
fun mk_internal_of_b name = |
59859 | 77 |
Binding.prefix_name (name ^ "_") #> Binding.prefix true b_name #> Binding.concealed; |
58241
ff8059e3e803
generate better internal names, with name of the target type in it
blanchet
parents:
58208
diff
changeset
|
78 |
fun mk_internal_b name = mk_internal_of_b name b; |
ff8059e3e803
generate better internal names, with name of the target type in it
blanchet
parents:
58208
diff
changeset
|
79 |
fun mk_internal_bs name = map (mk_internal_of_b name) bs; |
53566 | 80 |
val external_bs = map2 (Binding.prefix false) b_names bs |
62093 | 81 |
|> not internals ? map Binding.concealed; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
82 |
|
49185
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49176
diff
changeset
|
83 |
val deads = fold (union (op =)) Dss resDs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
84 |
val names_lthy = fold Variable.declare_typ deads lthy; |
52956 | 85 |
val passives = map fst (subtract (op = o apsnd TFree) deads resBs); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
86 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
87 |
(* tvars *) |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
88 |
val ((((((passiveAs, activeAs), passiveBs), activeBs), passiveCs), activeCs), idxT) = names_lthy |
52956 | 89 |
|> variant_tfrees passives |
52938
3b3e52d5e66b
tuned name generation code (to make it easier to adapt later)
blanchet
parents:
52923
diff
changeset
|
90 |
||>> mk_TFrees n |
52956 | 91 |
||>> variant_tfrees passives |
52938
3b3e52d5e66b
tuned name generation code (to make it easier to adapt later)
blanchet
parents:
52923
diff
changeset
|
92 |
||>> mk_TFrees n |
3b3e52d5e66b
tuned name generation code (to make it easier to adapt later)
blanchet
parents:
52923
diff
changeset
|
93 |
||>> mk_TFrees m |
3b3e52d5e66b
tuned name generation code (to make it easier to adapt later)
blanchet
parents:
52923
diff
changeset
|
94 |
||>> mk_TFrees n |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
95 |
||> fst o mk_TFrees 1 |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
96 |
||> the_single; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
97 |
|
52938
3b3e52d5e66b
tuned name generation code (to make it easier to adapt later)
blanchet
parents:
52923
diff
changeset
|
98 |
val allAs = passiveAs @ activeAs; |
3b3e52d5e66b
tuned name generation code (to make it easier to adapt later)
blanchet
parents:
52923
diff
changeset
|
99 |
val allBs' = passiveBs @ activeBs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
100 |
val Ass = replicate n allAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
101 |
val allBs = passiveAs @ activeBs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
102 |
val Bss = replicate n allBs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
103 |
val allCs = passiveAs @ activeCs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
104 |
val allCs' = passiveBs @ activeCs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
105 |
val Css' = replicate n allCs'; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
106 |
|
51866 | 107 |
(* types *) |
49185
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49176
diff
changeset
|
108 |
val dead_poss = |
52956 | 109 |
map (fn x => if member (op =) deads (TFree x) then SOME (TFree x) else NONE) resBs; |
49185
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49176
diff
changeset
|
110 |
fun mk_param NONE passive = (hd passive, tl passive) |
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49176
diff
changeset
|
111 |
| mk_param (SOME a) passive = (a, passive); |
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49176
diff
changeset
|
112 |
val mk_params = fold_map mk_param dead_poss #> fst; |
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49176
diff
changeset
|
113 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
114 |
fun mk_FTs Ts = map2 (fn Ds => mk_T_of_bnf Ds Ts) Dss bnfs; |
49185
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49176
diff
changeset
|
115 |
val (params, params') = `(map Term.dest_TFree) (mk_params passiveAs); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
116 |
val FTsAs = mk_FTs allAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
117 |
val FTsBs = mk_FTs allBs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
118 |
val FTsCs = mk_FTs allCs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
119 |
val ATs = map HOLogic.mk_setT passiveAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
120 |
val BTs = map HOLogic.mk_setT activeAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
121 |
val B'Ts = map HOLogic.mk_setT activeBs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
122 |
val B''Ts = map HOLogic.mk_setT activeCs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
123 |
val sTs = map2 (fn T => fn U => T --> U) activeAs FTsAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
124 |
val s'Ts = map2 (fn T => fn U => T --> U) activeBs FTsBs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
125 |
val s''Ts = map2 (fn T => fn U => T --> U) activeCs FTsCs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
126 |
val fTs = map2 (fn T => fn U => T --> U) activeAs activeBs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
127 |
val self_fTs = map (fn T => T --> T) activeAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
128 |
val gTs = map2 (fn T => fn U => T --> U) activeBs activeCs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
129 |
val all_gTs = map2 (fn T => fn U => T --> U) allBs allCs'; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
130 |
val RTs = map2 (fn T => fn U => HOLogic.mk_prodT (T, U)) activeAs activeBs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
131 |
val sRTs = map2 (fn T => fn U => HOLogic.mk_prodT (T, U)) activeAs activeAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
132 |
val R'Ts = map2 (fn T => fn U => HOLogic.mk_prodT (T, U)) activeBs activeCs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
133 |
val setsRTs = map HOLogic.mk_setT sRTs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
134 |
val setRTs = map HOLogic.mk_setT RTs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
135 |
val all_sbisT = HOLogic.mk_tupleT setsRTs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
136 |
val setR'Ts = map HOLogic.mk_setT R'Ts; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
137 |
val FRTs = mk_FTs (passiveAs @ RTs); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
138 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
139 |
(* terms *) |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
140 |
val mapsAsAs = @{map 4} mk_map_of_bnf Dss Ass Ass bnfs; |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
141 |
val mapsAsBs = @{map 4} mk_map_of_bnf Dss Ass Bss bnfs; |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
142 |
val mapsBsCs' = @{map 4} mk_map_of_bnf Dss Bss Css' bnfs; |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
143 |
val mapsAsCs' = @{map 4} mk_map_of_bnf Dss Ass Css' bnfs; |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
144 |
val map_fsts = @{map 4} mk_map_of_bnf Dss (replicate n (passiveAs @ RTs)) Ass bnfs; |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
145 |
val map_snds = @{map 4} mk_map_of_bnf Dss (replicate n (passiveAs @ RTs)) Bss bnfs; |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
146 |
fun mk_setss Ts = @{map 3} mk_sets_of_bnf (map (replicate live) Dss) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
147 |
(map (replicate live) (replicate n Ts)) bnfs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
148 |
val setssAs = mk_setss allAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
149 |
val setssAs' = transpose setssAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
150 |
val bis_setss = mk_setss (passiveAs @ RTs); |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
151 |
val relsAsBs = @{map 4} mk_rel_of_bnf Dss Ass Bss bnfs; |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
152 |
val bds = @{map 3} mk_bd_of_bnf Dss Ass bnfs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
153 |
val sum_bd = Library.foldr1 (uncurry mk_csum) bds; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
154 |
val sum_bdT = fst (dest_relT (fastype_of sum_bd)); |
56516
a13c2ccc160b
more accurate type arguments for intermeadiate typedefs
traytel
parents:
56348
diff
changeset
|
155 |
val (sum_bdT_params, sum_bdT_params') = `(map TFree) (Term.add_tfreesT sum_bdT []); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
156 |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
157 |
val ((((((((((zs, zs'), Bs), ss), fs), self_fs), all_gs), xFs), yFs), yFs_copy), _) = |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
158 |
lthy |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
159 |
|> mk_Frees' "b" activeAs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
160 |
||>> mk_Frees "B" BTs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
161 |
||>> mk_Frees "s" sTs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
162 |
||>> mk_Frees "f" fTs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
163 |
||>> mk_Frees "f" self_fTs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
164 |
||>> mk_Frees "g" all_gTs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
165 |
||>> mk_Frees "x" FTsAs |
51925 | 166 |
||>> mk_Frees "y" FTsBs |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
167 |
||>> mk_Frees "y" FTsBs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
168 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
169 |
val passive_UNIVs = map HOLogic.mk_UNIV passiveAs; |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
170 |
val passive_eqs = map HOLogic.eq_const passiveAs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
171 |
val active_UNIVs = map HOLogic.mk_UNIV activeAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
172 |
val passive_ids = map HOLogic.id_const passiveAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
173 |
val active_ids = map HOLogic.id_const activeAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
174 |
val fsts = map fst_const RTs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
175 |
val snds = map snd_const RTs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
176 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
177 |
(* thms *) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
178 |
val bd_card_orders = map bd_card_order_of_bnf bnfs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
179 |
val bd_card_order = hd bd_card_orders |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
180 |
val bd_Card_orders = map bd_Card_order_of_bnf bnfs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
181 |
val bd_Card_order = hd bd_Card_orders; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
182 |
val bd_Cinfinites = map bd_Cinfinite_of_bnf bnfs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
183 |
val bd_Cinfinite = hd bd_Cinfinites; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
184 |
val in_monos = map in_mono_of_bnf bnfs; |
53287 | 185 |
val map_comp0s = map map_comp0_of_bnf bnfs; |
186 |
val sym_map_comps = map mk_sym map_comp0s; |
|
53288 | 187 |
val map_comps = map map_comp_of_bnf bnfs; |
51761
4c9f08836d87
renamed "map_cong" axiom to "map_cong0" in preparation for real "map_cong"
blanchet
parents:
51758
diff
changeset
|
188 |
val map_cong0s = map map_cong0_of_bnf bnfs; |
53270 | 189 |
val map_id0s = map map_id0_of_bnf bnfs; |
53285 | 190 |
val map_ids = map map_id_of_bnf bnfs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
191 |
val set_bdss = map set_bd_of_bnf bnfs; |
53290 | 192 |
val set_mapss = map set_map_of_bnf bnfs; |
61242 | 193 |
val rel_congs = map rel_cong0_of_bnf bnfs; |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
194 |
val rel_converseps = map rel_conversep_of_bnf bnfs; |
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
195 |
val rel_Grps = map rel_Grp_of_bnf bnfs; |
57726 | 196 |
val le_rel_OOs = map le_rel_OO_of_bnf bnfs; |
56017 | 197 |
val in_rels = map in_rel_of_bnf bnfs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
198 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
199 |
val timer = time (timer "Extracted terms & thms"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
200 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
201 |
(* derived thms *) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
202 |
|
52956 | 203 |
(*map g1 ... gm g(m+1) ... g(m+n) (map id ... id f(m+1) ... f(m+n) x) = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
204 |
map g1 ... gm (g(m+1) o f(m+1)) ... (g(m+n) o f(m+n)) x*) |
53287 | 205 |
fun mk_map_comp_id x mapAsBs mapBsCs mapAsCs map_comp0 = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
206 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
207 |
val lhs = Term.list_comb (mapBsCs, all_gs) $ |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
208 |
(Term.list_comb (mapAsBs, passive_ids @ fs) $ x); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
209 |
val rhs = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
210 |
Term.list_comb (mapAsCs, take m all_gs @ map HOLogic.mk_comp (drop m all_gs ~~ fs)) $ x; |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
211 |
val goal = mk_Trueprop_eq (lhs, rhs); |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
212 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
213 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
214 |
Goal.prove_sorry lthy vars [] goal |
55756 | 215 |
(fn {context = ctxt, prems = _} => mk_map_comp_id_tac ctxt map_comp0) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
216 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
217 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
218 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
219 |
val map_comp_id_thms = @{map 5} mk_map_comp_id xFs mapsAsBs mapsBsCs' mapsAsCs' map_comps; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
220 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
221 |
(*forall a : set(m+1) x. f(m+1) a = a; ...; forall a : set(m+n) x. f(m+n) a = a ==> |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
222 |
map id ... id f(m+1) ... f(m+n) x = x*) |
53285 | 223 |
fun mk_map_cong0L x mapAsAs sets map_cong0 map_id = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
224 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
225 |
fun mk_prem set f z z' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
226 |
HOLogic.mk_Trueprop |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
227 |
(mk_Ball (set $ x) (Term.absfree z' (HOLogic.mk_eq (f $ z, z)))); |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
228 |
val prems = @{map 4} mk_prem (drop m sets) self_fs zs zs'; |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
49121
diff
changeset
|
229 |
val goal = mk_Trueprop_eq (Term.list_comb (mapAsAs, passive_ids @ self_fs) $ x, x); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
230 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
231 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
232 |
Goal.prove_sorry lthy vars [] (Logic.list_implies (prems, goal)) |
60728 | 233 |
(fn {context = ctxt, prems = _} => mk_map_cong0L_tac ctxt m map_cong0 map_id) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
234 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
235 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
236 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
237 |
val map_cong0L_thms = @{map 5} mk_map_cong0L xFs mapsAsAs setssAs map_cong0s map_ids; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
238 |
val in_mono'_thms = map (fn thm => |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
239 |
(thm OF (replicate m subset_refl)) RS @{thm set_mp}) in_monos; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
240 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
241 |
val map_arg_cong_thms = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
242 |
let |
51925 | 243 |
val prems = map2 (curry mk_Trueprop_eq) yFs yFs_copy; |
244 |
val maps = map (fn mapx => Term.list_comb (mapx, all_gs)) mapsBsCs'; |
|
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
49121
diff
changeset
|
245 |
val concls = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
246 |
@{map 3} (fn x => fn y => fn mapx => mk_Trueprop_eq (mapx $ x, mapx $ y)) |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
247 |
yFs yFs_copy maps; |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
248 |
val goals = map2 (fn prem => fn concl => Logic.mk_implies (prem, concl)) prems concls; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
249 |
in |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
250 |
map (fn goal => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
251 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
252 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal (fn {context = ctxt, prems = _} => |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
253 |
(hyp_subst_tac ctxt THEN' rtac ctxt refl) 1)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
254 |
|> Thm.close_derivation) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
255 |
goals |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
256 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
257 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
258 |
val timer = time (timer "Derived simple theorems"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
259 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
260 |
(* coalgebra *) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
261 |
|
53566 | 262 |
val coalg_bind = mk_internal_b (coN ^ algN) ; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
263 |
val coalg_def_bind = (Thm.def_binding coalg_bind, []); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
264 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
265 |
(*forall i = 1 ... n: (\<forall>x \<in> Bi. si \<in> Fi_in UNIV .. UNIV B1 ... Bn)*) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
266 |
val coalg_spec = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
267 |
let |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
268 |
val ins = @{map 3} mk_in (replicate n (passive_UNIVs @ Bs)) setssAs FTsAs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
269 |
fun mk_coalg_conjunct B s X z z' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
270 |
mk_Ball B (Term.absfree z' (HOLogic.mk_mem (s $ z, X))); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
271 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
272 |
val rhs = Library.foldr1 HOLogic.mk_conj (@{map 5} mk_coalg_conjunct Bs ss ins zs zs') |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
273 |
in |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
274 |
fold_rev (Term.absfree o Term.dest_Free) (Bs @ ss) rhs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
275 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
276 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
277 |
val ((coalg_free, (_, coalg_def_free)), (lthy, lthy_old)) = |
49311 | 278 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
279 |
|> Local_Theory.open_target |> snd |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
280 |
|> Local_Theory.define ((coalg_bind, NoSyn), (coalg_def_bind, coalg_spec)) |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
281 |
||> `Local_Theory.close_target; |
49311 | 282 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
283 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
284 |
val coalg = fst (Term.dest_Const (Morphism.term phi coalg_free)); |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
285 |
val coalg_def = mk_unabs_def (2 * n) (Morphism.thm phi coalg_def_free RS meta_eq_to_obj_eq); |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
286 |
|
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
287 |
fun mk_coalg Bs ss = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
288 |
let |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
289 |
val args = Bs @ ss; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
290 |
val Ts = map fastype_of args; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
291 |
val coalgT = Library.foldr (op -->) (Ts, HOLogic.boolT); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
292 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
293 |
Term.list_comb (Const (coalg, coalgT), args) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
294 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
295 |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
296 |
val((((((zs, zs'), Bs), B's), ss), s's), _) = |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
297 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
298 |
|> mk_Frees' "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
299 |
||>> mk_Frees "B" BTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
300 |
||>> mk_Frees "B'" B'Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
301 |
||>> mk_Frees "s" sTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
302 |
||>> mk_Frees "s'" s'Ts; |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
303 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
304 |
val coalg_prem = HOLogic.mk_Trueprop (mk_coalg Bs ss); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
305 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
306 |
val coalg_in_thms = map (fn i => |
52904 | 307 |
coalg_def RS iffD1 RS mk_conjunctN n i RS bspec) ks |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
308 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
309 |
val coalg_set_thmss = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
310 |
let |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
311 |
val coalg_prem = HOLogic.mk_Trueprop (mk_coalg Bs ss); |
57567 | 312 |
fun mk_prem x B = mk_Trueprop_mem (x, B); |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
313 |
fun mk_concl s x B set = HOLogic.mk_Trueprop (mk_leq (set $ (s $ x)) B); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
314 |
val prems = map2 mk_prem zs Bs; |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
315 |
val conclss = @{map 3} (fn s => fn x => fn sets => map2 (mk_concl s x) Bs (drop m sets)) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
316 |
ss zs setssAs; |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
317 |
val goalss = map2 (fn prem => fn concls => map (fn concl => |
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
318 |
Logic.list_implies (coalg_prem :: [prem], concl)) concls) prems conclss; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
319 |
in |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
320 |
map (fn goals => map (fn goal => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
321 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
322 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal (fn {context = ctxt, prems = _} => |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
323 |
mk_coalg_set_tac ctxt coalg_def)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
324 |
|> Thm.close_derivation) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
325 |
goals) goalss |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
326 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
327 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
328 |
fun mk_tcoalg BTs = mk_coalg (map HOLogic.mk_UNIV BTs); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
329 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
330 |
val tcoalg_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
331 |
let |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
332 |
val goal = HOLogic.mk_Trueprop (mk_tcoalg activeAs ss); |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
333 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
334 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
335 |
Goal.prove_sorry lthy vars [] goal |
60728 | 336 |
(fn {context = ctxt, prems = _} => (rtac ctxt (coalg_def RS iffD2) 1 THEN CONJ_WRAP |
337 |
(K (EVERY' [rtac ctxt ballI, rtac ctxt CollectI, |
|
338 |
CONJ_WRAP' (K (EVERY' [rtac ctxt @{thm subset_UNIV}])) allAs] 1)) ss)) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
339 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
340 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
341 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
342 |
val timer = time (timer "Coalgebra definition & thms"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
343 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
344 |
(* morphism *) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
345 |
|
53566 | 346 |
val mor_bind = mk_internal_b morN; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
347 |
val mor_def_bind = (Thm.def_binding mor_bind, []); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
348 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
349 |
(*fbetw) forall i = 1 ... n: (\<forall>x \<in> Bi. fi x \<in> B'i)*) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
350 |
(*mor) forall i = 1 ... n: (\<forall>x \<in> Bi. |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
351 |
Fi_map id ... id f1 ... fn (si x) = si' (fi x)*) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
352 |
val mor_spec = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
353 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
354 |
fun mk_fbetw f B1 B2 z z' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
355 |
mk_Ball B1 (Term.absfree z' (HOLogic.mk_mem (f $ z, B2))); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
356 |
fun mk_mor B mapAsBs f s s' z z' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
357 |
mk_Ball B (Term.absfree z' (HOLogic.mk_eq |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
358 |
(Term.list_comb (mapAsBs, passive_ids @ fs @ [s $ z]), s' $ (f $ z)))); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
359 |
val rhs = HOLogic.mk_conj |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
360 |
(Library.foldr1 HOLogic.mk_conj (@{map 5} mk_fbetw fs Bs B's zs zs'), |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
361 |
Library.foldr1 HOLogic.mk_conj (@{map 7} mk_mor Bs mapsAsBs fs ss s's zs zs')) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
362 |
in |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
363 |
fold_rev (Term.absfree o Term.dest_Free) (Bs @ ss @ B's @ s's @ fs) rhs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
364 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
365 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
366 |
val ((mor_free, (_, mor_def_free)), (lthy, lthy_old)) = |
49311 | 367 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
368 |
|> Local_Theory.open_target |> snd |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
369 |
|> Local_Theory.define ((mor_bind, NoSyn), (mor_def_bind, mor_spec)) |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
370 |
||> `Local_Theory.close_target; |
49311 | 371 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
372 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
373 |
val mor = fst (Term.dest_Const (Morphism.term phi mor_free)); |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
374 |
val mor_def = mk_unabs_def (5 * n) (Morphism.thm phi mor_def_free RS meta_eq_to_obj_eq); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
375 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
376 |
fun mk_mor Bs1 ss1 Bs2 ss2 fs = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
377 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
378 |
val args = Bs1 @ ss1 @ Bs2 @ ss2 @ fs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
379 |
val Ts = map fastype_of (Bs1 @ ss1 @ Bs2 @ ss2 @ fs); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
380 |
val morT = Library.foldr (op -->) (Ts, HOLogic.boolT); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
381 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
382 |
Term.list_comb (Const (mor, morT), args) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
383 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
384 |
|
63314 | 385 |
val ((((((((((((((zs, z's), Bs), Bs_copy), B's), B''s), ss), s's), s''s), fs), fs_copy), gs), |
386 |
RFs), Rs), _) = |
|
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
387 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
388 |
|> mk_Frees "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
389 |
||>> mk_Frees "b" activeBs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
390 |
||>> mk_Frees "B" BTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
391 |
||>> mk_Frees "B" BTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
392 |
||>> mk_Frees "B'" B'Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
393 |
||>> mk_Frees "B''" B''Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
394 |
||>> mk_Frees "s" sTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
395 |
||>> mk_Frees "s'" s'Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
396 |
||>> mk_Frees "s''" s''Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
397 |
||>> mk_Frees "f" fTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
398 |
||>> mk_Frees "f" fTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
399 |
||>> mk_Frees "g" gTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
400 |
||>> mk_Frees "x" FRTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
401 |
||>> mk_Frees "R" setRTs; |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
402 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
403 |
val mor_prem = HOLogic.mk_Trueprop (mk_mor Bs ss B's s's fs); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
404 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
405 |
val (mor_image_thms, morE_thms) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
406 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
407 |
val prem = HOLogic.mk_Trueprop (mk_mor Bs ss B's s's fs); |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
408 |
fun mk_image_goal f B1 B2 = |
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
409 |
Logic.mk_implies (prem, HOLogic.mk_Trueprop (mk_leq (mk_image f $ B1) B2)); |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
410 |
val image_goals = @{map 3} mk_image_goal fs Bs B's; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
411 |
fun mk_elim_goal B mapAsBs f s s' x = |
57567 | 412 |
Logic.list_implies ([prem, mk_Trueprop_mem (x, B)], |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
413 |
mk_Trueprop_eq (Term.list_comb (mapAsBs, passive_ids @ fs @ [s $ x]), s' $ (f $ x))); |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
414 |
val elim_goals = @{map 6} mk_elim_goal Bs mapsAsBs fs ss s's zs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
415 |
fun prove goal = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
416 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
417 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal (fn {context = ctxt, prems = _} => |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
418 |
mk_mor_elim_tac ctxt mor_def)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
419 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
420 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
421 |
(map prove image_goals, map prove elim_goals) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
422 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
423 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
424 |
val mor_image'_thms = map (fn thm => @{thm set_mp} OF [thm, imageI]) mor_image_thms; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
425 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
426 |
val mor_incl_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
427 |
let |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
428 |
val prems = map2 (HOLogic.mk_Trueprop oo mk_leq) Bs Bs_copy; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
429 |
val concl = HOLogic.mk_Trueprop (mk_mor Bs ss Bs_copy ss active_ids); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
430 |
val vars = fold (Variable.add_free_names lthy) (concl :: prems) []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
431 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
432 |
Goal.prove_sorry lthy vars [] (Logic.list_implies (prems, concl)) |
60728 | 433 |
(fn {context = ctxt, prems = _} => mk_mor_incl_tac ctxt mor_def map_ids) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
434 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
435 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
436 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
437 |
val mor_id_thm = mor_incl_thm OF (replicate n subset_refl); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
438 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
439 |
val mor_comp_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
440 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
441 |
val prems = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
442 |
[HOLogic.mk_Trueprop (mk_mor Bs ss B's s's fs), |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
443 |
HOLogic.mk_Trueprop (mk_mor B's s's B''s s''s gs)]; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
444 |
val concl = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
445 |
HOLogic.mk_Trueprop (mk_mor Bs ss B''s s''s (map2 (curry HOLogic.mk_comp) gs fs)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
446 |
val vars = fold (Variable.add_free_names lthy) (concl :: prems) []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
447 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
448 |
Goal.prove_sorry lthy vars [] (Logic.list_implies (prems, concl)) |
61271 | 449 |
(fn {context = ctxt, prems = _} => |
450 |
mk_mor_comp_tac ctxt mor_def mor_image'_thms morE_thms map_comp_id_thms) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
451 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
452 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
453 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
454 |
val mor_cong_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
455 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
456 |
val prems = map HOLogic.mk_Trueprop |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
457 |
(map2 (curry HOLogic.mk_eq) fs_copy fs @ [mk_mor Bs ss B's s's fs]) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
458 |
val concl = HOLogic.mk_Trueprop (mk_mor Bs ss B's s's fs_copy); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
459 |
val vars = fold (Variable.add_free_names lthy) (concl :: prems) []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
460 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
461 |
Goal.prove_sorry lthy vars [] (Logic.list_implies (prems, concl)) |
61271 | 462 |
(fn {context = ctxt, prems = _} => (hyp_subst_tac ctxt THEN' assume_tac ctxt) 1) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
463 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
464 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
465 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
466 |
val mor_UNIV_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
467 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
468 |
fun mk_conjunct mapAsBs f s s' = HOLogic.mk_eq |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
469 |
(HOLogic.mk_comp (Term.list_comb (mapAsBs, passive_ids @ fs), s), |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
470 |
HOLogic.mk_comp (s', f)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
471 |
val lhs = mk_mor active_UNIVs ss (map HOLogic.mk_UNIV activeBs) s's fs; |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
472 |
val rhs = Library.foldr1 HOLogic.mk_conj (@{map 4} mk_conjunct mapsAsBs fs ss s's); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
473 |
val vars = fold (Variable.add_free_names lthy) [lhs, rhs] []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
474 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
475 |
Goal.prove_sorry lthy vars [] (mk_Trueprop_eq (lhs, rhs)) |
60728 | 476 |
(fn {context = ctxt, prems = _} => mk_mor_UNIV_tac ctxt morE_thms mor_def) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
477 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
478 |
end; |
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 |
val mor_str_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
481 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
482 |
val maps = map2 (fn Ds => fn bnf => Term.list_comb |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
483 |
(mk_map_of_bnf Ds allAs (passiveAs @ FTsAs) bnf, passive_ids @ ss)) Dss bnfs; |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
484 |
val goal = HOLogic.mk_Trueprop (mk_mor active_UNIVs ss (map HOLogic.mk_UNIV FTsAs) maps ss); |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
485 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
486 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
487 |
Goal.prove_sorry lthy vars [] goal |
60728 | 488 |
(fn {context = ctxt, prems = _} => mk_mor_str_tac ctxt ks mor_UNIV_thm) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
489 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
490 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
491 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
492 |
val timer = time (timer "Morphism definition & thms"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
493 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
494 |
(* bisimulation *) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
495 |
|
53566 | 496 |
val bis_bind = mk_internal_b bisN; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
497 |
val bis_def_bind = (Thm.def_binding bis_bind, []); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
498 |
|
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
499 |
fun mk_bis_le_conjunct R B1 B2 = mk_leq R (mk_Times (B1, B2)); |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
500 |
val bis_le = Library.foldr1 HOLogic.mk_conj (@{map 3} mk_bis_le_conjunct Rs Bs B's) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
501 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
502 |
val bis_spec = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
503 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
504 |
val fst_args = passive_ids @ fsts; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
505 |
val snd_args = passive_ids @ snds; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
506 |
fun mk_bis R s s' b1 b2 RF map1 map2 sets = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
507 |
list_all_free [b1, b2] (HOLogic.mk_imp |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
508 |
(HOLogic.mk_mem (HOLogic.mk_prod (b1, b2), R), |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
509 |
mk_Bex (mk_in (passive_UNIVs @ Rs) sets (snd (dest_Free RF))) |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
510 |
(Term.absfree (dest_Free RF) (HOLogic.mk_conj |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
511 |
(HOLogic.mk_eq (Term.list_comb (map1, fst_args) $ RF, s $ b1), |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
512 |
HOLogic.mk_eq (Term.list_comb (map2, snd_args) $ RF, s' $ b2)))))); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
513 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
514 |
val rhs = HOLogic.mk_conj |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
515 |
(bis_le, Library.foldr1 HOLogic.mk_conj |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
516 |
(@{map 9} mk_bis Rs ss s's zs z's RFs map_fsts map_snds bis_setss)) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
517 |
in |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
518 |
fold_rev (Term.absfree o Term.dest_Free) (Bs @ ss @ B's @ s's @ Rs) rhs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
519 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
520 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
521 |
val ((bis_free, (_, bis_def_free)), (lthy, lthy_old)) = |
49311 | 522 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
523 |
|> Local_Theory.open_target |> snd |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
524 |
|> Local_Theory.define ((bis_bind, NoSyn), (bis_def_bind, bis_spec)) |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
525 |
||> `Local_Theory.close_target; |
49311 | 526 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
527 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
528 |
val bis = fst (Term.dest_Const (Morphism.term phi bis_free)); |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
529 |
val bis_def = mk_unabs_def (5 * n) (Morphism.thm phi bis_def_free RS meta_eq_to_obj_eq); |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
530 |
|
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
531 |
fun mk_bis Bs1 ss1 Bs2 ss2 Rs = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
532 |
let |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
533 |
val args = Bs1 @ ss1 @ Bs2 @ ss2 @ Rs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
534 |
val Ts = map fastype_of args; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
535 |
val bisT = Library.foldr (op -->) (Ts, HOLogic.boolT); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
536 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
537 |
Term.list_comb (Const (bis, bisT), args) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
538 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
539 |
|
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
540 |
val (((((((((((((((((zs, z's), Bs), B's), B''s), ss), s's), s''s), fs), (Rtuple, Rtuple')), Rs), |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
541 |
Rs_copy), R's), sRs), (idx, idx')), Idx), Ris), _) = |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
542 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
543 |
|> mk_Frees "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
544 |
||>> mk_Frees "b" activeBs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
545 |
||>> mk_Frees "B" BTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
546 |
||>> mk_Frees "B'" B'Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
547 |
||>> mk_Frees "B''" B''Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
548 |
||>> mk_Frees "s" sTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
549 |
||>> mk_Frees "s'" s'Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
550 |
||>> mk_Frees "s''" s''Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
551 |
||>> mk_Frees "f" fTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
552 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "Rtuple") all_sbisT |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
553 |
||>> mk_Frees "R" setRTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
554 |
||>> mk_Frees "R" setRTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
555 |
||>> mk_Frees "R'" setR'Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
556 |
||>> mk_Frees "R" setsRTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
557 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "i") idxT |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
558 |
||>> yield_singleton (mk_Frees "I") (HOLogic.mk_setT idxT) |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
559 |
||>> mk_Frees "Ri" (map (fn T => idxT --> T) setRTs); |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
560 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
561 |
val bis_cong_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
562 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
563 |
val prems = map HOLogic.mk_Trueprop |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
564 |
(mk_bis Bs ss B's s's Rs :: map2 (curry HOLogic.mk_eq) Rs_copy Rs) |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
565 |
val concl = HOLogic.mk_Trueprop (mk_bis Bs ss B's s's Rs_copy); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
566 |
val vars = fold (Variable.add_free_names lthy) (concl :: prems) []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
567 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
568 |
Goal.prove_sorry lthy vars [] (Logic.list_implies (prems, concl)) |
58963
26bf09b95dda
proper context for assume_tac (atac remains as fall-back without context);
wenzelm
parents:
58959
diff
changeset
|
569 |
(fn {context = ctxt, prems = _} => (hyp_subst_tac ctxt THEN' assume_tac ctxt) 1) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
570 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
571 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
572 |
|
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
573 |
val bis_rel_thm = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
574 |
let |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
575 |
fun mk_conjunct R s s' b1 b2 rel = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
576 |
list_all_free [b1, b2] (HOLogic.mk_imp |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
577 |
(HOLogic.mk_mem (HOLogic.mk_prod (b1, b2), R), |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
578 |
Term.list_comb (rel, passive_eqs @ map mk_in_rel Rs) $ (s $ b1) $ (s' $ b2))); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
579 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
580 |
val rhs = HOLogic.mk_conj |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
581 |
(bis_le, Library.foldr1 HOLogic.mk_conj |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
582 |
(@{map 6} mk_conjunct Rs ss s's zs z's relsAsBs)) |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
583 |
val goal = mk_Trueprop_eq (mk_bis Bs ss B's s's Rs, rhs); |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
584 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
585 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
586 |
Goal.prove_sorry lthy vars [] goal |
60728 | 587 |
(fn {context = ctxt, prems = _} => mk_bis_rel_tac ctxt m bis_def in_rels map_comps |
588 |
map_cong0s set_mapss) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
589 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
590 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
591 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
592 |
val bis_converse_thm = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
593 |
let |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
594 |
val goal = Logic.mk_implies (HOLogic.mk_Trueprop (mk_bis Bs ss B's s's Rs), |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
595 |
HOLogic.mk_Trueprop (mk_bis B's s's Bs ss (map mk_converse Rs))); |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
596 |
val vars = Variable.add_free_names lthy goal []; |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
597 |
in |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
598 |
Goal.prove_sorry lthy vars [] goal |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
599 |
(fn {context = ctxt, prems = _} => mk_bis_converse_tac ctxt m bis_rel_thm rel_congs |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
600 |
rel_converseps) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
601 |
|> Thm.close_derivation |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
602 |
end; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
603 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
604 |
val bis_O_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
605 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
606 |
val prems = |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
607 |
[HOLogic.mk_Trueprop (mk_bis Bs ss B's s's Rs), |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
608 |
HOLogic.mk_Trueprop (mk_bis B's s's B''s s''s R's)]; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
609 |
val concl = |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
610 |
HOLogic.mk_Trueprop (mk_bis Bs ss B''s s''s (map2 (curry mk_rel_comp) Rs R's)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
611 |
val vars = fold (Variable.add_free_names lthy) (concl :: prems) []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
612 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
613 |
Goal.prove_sorry lthy vars [] (Logic.list_implies (prems, concl)) |
61271 | 614 |
(fn {context = ctxt, prems = _} => mk_bis_O_tac ctxt m bis_rel_thm rel_congs le_rel_OOs) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
615 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
616 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
617 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
618 |
val bis_Gr_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
619 |
let |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
620 |
val concl = HOLogic.mk_Trueprop (mk_bis Bs ss B's s's (map2 mk_Gr Bs fs)); |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
621 |
val vars = fold (Variable.add_free_names lthy) ([coalg_prem, mor_prem, concl]) []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
622 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
623 |
Goal.prove_sorry lthy vars [] (Logic.list_implies ([coalg_prem, mor_prem], concl)) |
55197 | 624 |
(fn {context = ctxt, prems = _} => mk_bis_Gr_tac ctxt bis_rel_thm rel_Grps mor_image_thms |
625 |
morE_thms coalg_in_thms) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
626 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
627 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
628 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
629 |
val bis_image2_thm = bis_cong_thm OF |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
630 |
((bis_O_thm OF [bis_Gr_thm RS bis_converse_thm, bis_Gr_thm]) :: |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
631 |
replicate n @{thm image2_Gr}); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
632 |
|
51447 | 633 |
val bis_Id_on_thm = bis_cong_thm OF ((mor_id_thm RSN (2, bis_Gr_thm)) :: |
634 |
replicate n @{thm Id_on_Gr}); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
635 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
636 |
val bis_Union_thm = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
637 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
638 |
val prem = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
639 |
HOLogic.mk_Trueprop (mk_Ball Idx |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
640 |
(Term.absfree idx' (mk_bis Bs ss B's s's (map (fn R => R $ idx) Ris)))); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
641 |
val concl = |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
642 |
HOLogic.mk_Trueprop (mk_bis Bs ss B's s's (map (mk_UNION Idx) Ris)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
643 |
val vars = fold (Variable.add_free_names lthy) [prem, concl] []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
644 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
645 |
Goal.prove_sorry lthy vars [] (Logic.mk_implies (prem, concl)) |
55197 | 646 |
(fn {context = ctxt, prems = _} => mk_bis_Union_tac ctxt bis_def in_mono'_thms) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
647 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
648 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
649 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
650 |
(* self-bisimulation *) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
651 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
652 |
fun mk_sbis Bs ss Rs = mk_bis Bs ss Bs ss Rs; |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
653 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
654 |
(* largest self-bisimulation *) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
655 |
|
53566 | 656 |
val lsbis_binds = mk_internal_bs lsbisN; |
657 |
fun lsbis_bind i = nth lsbis_binds (i - 1); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
658 |
val lsbis_def_bind = rpair [] o Thm.def_binding o lsbis_bind; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
659 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
660 |
val all_sbis = HOLogic.mk_Collect (fst Rtuple', snd Rtuple', list_exists_free sRs |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
661 |
(HOLogic.mk_conj (HOLogic.mk_eq (Rtuple, HOLogic.mk_tuple sRs), mk_sbis Bs ss sRs))); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
662 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
663 |
fun lsbis_spec i = |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
664 |
fold_rev (Term.absfree o Term.dest_Free) (Bs @ ss) |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
665 |
(mk_UNION all_sbis (Term.absfree Rtuple' (mk_nthN n Rtuple i))); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
666 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
667 |
val ((lsbis_frees, (_, lsbis_def_frees)), (lthy, lthy_old)) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
668 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
669 |
|> Local_Theory.open_target |> snd |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
670 |
|> fold_map (fn i => Local_Theory.define |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
671 |
((lsbis_bind i, NoSyn), (lsbis_def_bind i, lsbis_spec i))) ks |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
672 |
|>> apsnd split_list o split_list |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
673 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
674 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
675 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
676 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
677 |
val lsbis_defs = map (fn def => |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
678 |
mk_unabs_def (2 * n) (Morphism.thm phi def RS meta_eq_to_obj_eq)) lsbis_def_frees; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
679 |
val lsbiss = map (fst o Term.dest_Const o Morphism.term phi) lsbis_frees; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
680 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
681 |
fun mk_lsbis Bs ss i = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
682 |
let |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
683 |
val args = Bs @ ss; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
684 |
val Ts = map fastype_of args; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
685 |
val RT = mk_relT (`I (HOLogic.dest_setT (fastype_of (nth Bs (i - 1))))); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
686 |
val lsbisT = Library.foldr (op -->) (Ts, RT); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
687 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
688 |
Term.list_comb (Const (nth lsbiss (i - 1), lsbisT), args) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
689 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
690 |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
691 |
val (((((zs, zs'), Bs), ss), sRs), _) = |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
692 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
693 |
|> mk_Frees' "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
694 |
||>> mk_Frees "B" BTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
695 |
||>> mk_Frees "s" sTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
696 |
||>> mk_Frees "R" setsRTs; |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
697 |
|
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
698 |
val sbis_prem = HOLogic.mk_Trueprop (mk_sbis Bs ss sRs); |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
699 |
val coalg_prem = HOLogic.mk_Trueprop (mk_coalg Bs ss); |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
700 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
701 |
val sbis_lsbis_thm = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
702 |
let |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
703 |
val goal = HOLogic.mk_Trueprop (mk_sbis Bs ss (map (mk_lsbis Bs ss) ks)); |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
704 |
val vars = Variable.add_free_names lthy goal []; |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
705 |
in |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
706 |
Goal.prove_sorry lthy vars [] goal |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
707 |
(fn {context = ctxt, prems = _} => |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
708 |
mk_sbis_lsbis_tac ctxt lsbis_defs bis_Union_thm bis_cong_thm) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
709 |
|> Thm.close_derivation |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
710 |
end; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
711 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
712 |
val lsbis_incl_thms = map (fn i => sbis_lsbis_thm RS |
52904 | 713 |
(bis_def RS iffD1 RS conjunct1 RS mk_conjunctN n i)) ks; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
714 |
val lsbisE_thms = map (fn i => (mk_specN 2 (sbis_lsbis_thm RS |
52904 | 715 |
(bis_def RS iffD1 RS conjunct2 RS mk_conjunctN n i))) RS mp) ks; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
716 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
717 |
val incl_lsbis_thms = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
718 |
let |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
719 |
fun mk_concl i R = HOLogic.mk_Trueprop (mk_leq R (mk_lsbis Bs ss i)); |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
720 |
val goals = map2 (fn i => fn R => Logic.mk_implies (sbis_prem, mk_concl i R)) ks sRs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
721 |
in |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
722 |
@{map 3} (fn goal => fn i => fn def => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
723 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
724 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal (fn {context = ctxt, prems = _} => |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
725 |
mk_incl_lsbis_tac ctxt n i def)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
726 |
|> Thm.close_derivation) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
727 |
goals ks lsbis_defs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
728 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
729 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
730 |
val equiv_lsbis_thms = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
731 |
let |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
732 |
fun mk_concl i B = HOLogic.mk_Trueprop (mk_equiv B (mk_lsbis Bs ss i)); |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
733 |
val goals = map2 (fn i => fn B => Logic.mk_implies (coalg_prem, mk_concl i B)) ks Bs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
734 |
in |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
735 |
@{map 3} (fn goal => fn l_incl => fn incl_l => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
736 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
737 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
60728 | 738 |
(fn {context = ctxt, prems = _} => mk_equiv_lsbis_tac ctxt sbis_lsbis_thm l_incl incl_l |
739 |
bis_Id_on_thm bis_converse_thm bis_O_thm) |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
740 |
|> Thm.close_derivation)) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
741 |
goals lsbis_incl_thms incl_lsbis_thms |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
742 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
743 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
744 |
val timer = time (timer "Bisimulations"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
745 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
746 |
(* bounds *) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
747 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
748 |
val (lthy, sbd, sbdT, |
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
52634
diff
changeset
|
749 |
sbd_card_order, sbd_Cinfinite, sbd_Card_order, set_sbdss) = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
750 |
if n = 1 |
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
52634
diff
changeset
|
751 |
then (lthy, sum_bd, sum_bdT, bd_card_order, bd_Cinfinite, bd_Card_order, set_bdss) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
752 |
else |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
753 |
let |
53566 | 754 |
val sbdT_bind = mk_internal_b sum_bdTN; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
755 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
756 |
val ((sbdT_name, (sbdT_glob_info, sbdT_loc_info)), lthy) = |
56516
a13c2ccc160b
more accurate type arguments for intermeadiate typedefs
traytel
parents:
56348
diff
changeset
|
757 |
typedef (sbdT_bind, sum_bdT_params', NoSyn) |
60728 | 758 |
(HOLogic.mk_UNIV sum_bdT) NONE (fn ctxt => |
759 |
EVERY' [rtac ctxt exI, rtac ctxt UNIV_I] 1) lthy; |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
760 |
|
56516
a13c2ccc160b
more accurate type arguments for intermeadiate typedefs
traytel
parents:
56348
diff
changeset
|
761 |
val sbdT = Type (sbdT_name, sum_bdT_params); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
762 |
val Abs_sbdT = Const (#Abs_name sbdT_glob_info, sum_bdT --> sbdT); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
763 |
|
53566 | 764 |
val sbd_bind = mk_internal_b sum_bdN; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
765 |
val sbd_def_bind = (Thm.def_binding sbd_bind, []); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
766 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
767 |
val sbd_spec = mk_dir_image sum_bd Abs_sbdT; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
768 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
769 |
val ((sbd_free, (_, sbd_def_free)), (lthy, lthy_old)) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
770 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
771 |
|> Local_Theory.open_target |> snd |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
772 |
|> Local_Theory.define ((sbd_bind, NoSyn), (sbd_def_bind, sbd_spec)) |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
773 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
774 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
775 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
776 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
777 |
val sbd_def = Morphism.thm phi sbd_def_free RS meta_eq_to_obj_eq; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
778 |
val sbd = Const (fst (Term.dest_Const (Morphism.term phi sbd_free)), mk_relT (`I sbdT)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
779 |
|
49228 | 780 |
val Abs_sbdT_inj = mk_Abs_inj_thm (#Abs_inject sbdT_loc_info); |
781 |
val Abs_sbdT_bij = mk_Abs_bij_thm lthy Abs_sbdT_inj (#Abs_cases sbdT_loc_info); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
782 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
783 |
val sum_Cinfinite = mk_sum_Cinfinite bd_Cinfinites; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
784 |
val sum_Card_order = sum_Cinfinite RS conjunct2; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
785 |
val sum_card_order = mk_sum_card_order bd_card_orders; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
786 |
|
55770
f2cf7f92c9ac
intermediate typedef for the type of the bound (local to lfp)
traytel
parents:
55756
diff
changeset
|
787 |
val sbd_ordIso = @{thm ssubst_Pair_rhs} OF |
f2cf7f92c9ac
intermediate typedef for the type of the bound (local to lfp)
traytel
parents:
55756
diff
changeset
|
788 |
[@{thm dir_image} OF [Abs_sbdT_inj, sum_Card_order], sbd_def]; |
f2cf7f92c9ac
intermediate typedef for the type of the bound (local to lfp)
traytel
parents:
55756
diff
changeset
|
789 |
val sbd_card_order = @{thm iffD2[OF arg_cong[of _ _ card_order]]} OF |
f2cf7f92c9ac
intermediate typedef for the type of the bound (local to lfp)
traytel
parents:
55756
diff
changeset
|
790 |
[sbd_def, @{thm card_order_dir_image} OF [Abs_sbdT_bij, sum_card_order]]; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
791 |
val sbd_Cinfinite = @{thm Cinfinite_cong} OF [sbd_ordIso, sum_Cinfinite]; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
792 |
val sbd_Card_order = sbd_Cinfinite RS conjunct2; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
793 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
794 |
fun mk_set_sbd i bd_Card_order bds = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
795 |
map (fn thm => @{thm ordLeq_ordIso_trans} OF |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
796 |
[bd_Card_order RS mk_ordLeq_csum n i thm, sbd_ordIso]) bds; |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
797 |
val set_sbdss = @{map 3} mk_set_sbd ks bd_Card_orders set_bdss; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
798 |
in |
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
52634
diff
changeset
|
799 |
(lthy, sbd, sbdT, sbd_card_order, sbd_Cinfinite, sbd_Card_order, set_sbdss) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
800 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
801 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
802 |
val sbdTs = replicate n sbdT; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
803 |
val sum_sbdT = mk_sumTN sbdTs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
804 |
val sum_sbd_listT = HOLogic.listT sum_sbdT; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
805 |
val sum_sbd_list_setT = HOLogic.mk_setT sum_sbd_listT; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
806 |
val bdTs = passiveAs @ replicate n sbdT; |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
807 |
val to_sbd_maps = @{map 4} mk_map_of_bnf Dss Ass (replicate n bdTs) bnfs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
808 |
val bdFTs = mk_FTs bdTs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
809 |
val sbdFT = mk_sumTN bdFTs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
810 |
val treeT = HOLogic.mk_prodT (sum_sbd_list_setT, sum_sbd_listT --> sbdFT); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
811 |
val treeQT = HOLogic.mk_setT treeT; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
812 |
val treeTs = passiveAs @ replicate n treeT; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
813 |
val treeQTs = passiveAs @ replicate n treeQT; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
814 |
val treeFTs = mk_FTs treeTs; |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
815 |
val tree_maps = @{map 4} mk_map_of_bnf Dss (replicate n bdTs) (replicate n treeTs) bnfs; |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
816 |
val final_maps = @{map 4} mk_map_of_bnf Dss (replicate n treeTs) (replicate n treeQTs) bnfs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
817 |
val isNode_setss = mk_setss (passiveAs @ replicate n sbdT); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
818 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
819 |
val root = HOLogic.mk_set sum_sbd_listT [HOLogic.mk_list sum_sbdT []]; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
820 |
val Zero = HOLogic.mk_tuple (map (fn U => absdummy U root) activeAs); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
821 |
val Lev_recT = fastype_of Zero; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
822 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
823 |
val Nil = HOLogic.mk_tuple (@{map 3} (fn i => fn z => fn z'=> |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
824 |
Term.absfree z' (mk_InN activeAs z i)) ks zs zs'); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
825 |
val rv_recT = fastype_of Nil; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
826 |
|
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
827 |
val (((((((((((((((zs, zs'), zs_copy), ss), (nat, nat')), |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
828 |
(sumx, sumx')), (kks, kks')), (kl, kl')), (kl_copy, kl'_copy)), (Kl, Kl')), (lab, lab')), |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
829 |
(Kl_lab, Kl_lab')), xs), (Lev_rec, Lev_rec')), (rv_rec, rv_rec')), _) = |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
830 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
831 |
|> mk_Frees' "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
832 |
||>> mk_Frees "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
833 |
||>> mk_Frees "s" sTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
834 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "n") HOLogic.natT |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
835 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "sumx") sum_sbdT |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
836 |
||>> mk_Frees' "k" sbdTs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
837 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "kl") sum_sbd_listT |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
838 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "kl") sum_sbd_listT |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
839 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "Kl") sum_sbd_list_setT |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
840 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "lab") (sum_sbd_listT --> sbdFT) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
841 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "Kl_lab") treeT |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
842 |
||>> mk_Frees "x" bdFTs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
843 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "rec") Lev_recT |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
844 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "rec") rv_recT; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
845 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
846 |
val (k, k') = (hd kks, hd kks') |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
847 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
848 |
val timer = time (timer "Bounds"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
849 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
850 |
(* tree coalgebra *) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
851 |
|
53566 | 852 |
val isNode_binds = mk_internal_bs isNodeN; |
853 |
fun isNode_bind i = nth isNode_binds (i - 1); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
854 |
val isNode_def_bind = rpair [] o Thm.def_binding o isNode_bind; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
855 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
856 |
val isNodeT = |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
857 |
Library.foldr (op -->) (map fastype_of [Kl, lab, kl], HOLogic.boolT); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
858 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
859 |
val Succs = @{map 3} (fn i => fn k => fn k' => |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
860 |
HOLogic.mk_Collect (fst k', snd k', HOLogic.mk_mem (mk_InN sbdTs k i, mk_Succ Kl kl))) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
861 |
ks kks kks'; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
862 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
863 |
fun isNode_spec sets x i = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
864 |
let |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
865 |
val active_sets = drop m (map (fn set => set $ x) sets); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
866 |
val rhs = list_exists_free [x] |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
867 |
(Library.foldr1 HOLogic.mk_conj (HOLogic.mk_eq (lab $ kl, mk_InN bdFTs x i) :: |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
868 |
map2 (curry HOLogic.mk_eq) active_sets Succs)); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
869 |
in |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
870 |
fold_rev (Term.absfree o Term.dest_Free) [Kl, lab, kl] rhs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
871 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
872 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
873 |
val ((isNode_frees, (_, isNode_def_frees)), (lthy, lthy_old)) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
874 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
875 |
|> Local_Theory.open_target |> snd |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
876 |
|> @{fold_map 3} (fn i => fn x => fn sets => Local_Theory.define |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
877 |
((isNode_bind i, NoSyn), (isNode_def_bind i, isNode_spec sets x i))) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
878 |
ks xs isNode_setss |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
879 |
|>> apsnd split_list o split_list |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
880 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
881 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
882 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
883 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
884 |
val isNode_defs = map (fn def => |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
885 |
mk_unabs_def 3 (Morphism.thm phi def RS meta_eq_to_obj_eq)) isNode_def_frees; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
886 |
val isNodes = map (fst o Term.dest_Const o Morphism.term phi) isNode_frees; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
887 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
888 |
fun mk_isNode kl i = |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
889 |
Term.list_comb (Const (nth isNodes (i - 1), isNodeT), [Kl, lab, kl]); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
890 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
891 |
val isTree = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
892 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
893 |
val empty = HOLogic.mk_mem (HOLogic.mk_list sum_sbdT [], Kl); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
894 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
895 |
val tree = mk_Ball Kl (Term.absfree kl' |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
896 |
(Library.foldr1 HOLogic.mk_conj (@{map 4} (fn Succ => fn i => fn k => fn k' => |
55581
d1c228753d76
another simplification of internal codatatype construction
traytel
parents:
55577
diff
changeset
|
897 |
mk_Ball Succ (Term.absfree k' (mk_isNode |
d1c228753d76
another simplification of internal codatatype construction
traytel
parents:
55577
diff
changeset
|
898 |
(mk_append (kl, HOLogic.mk_list sum_sbdT [mk_InN sbdTs k i])) i))) |
d1c228753d76
another simplification of internal codatatype construction
traytel
parents:
55577
diff
changeset
|
899 |
Succs ks kks kks'))); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
900 |
in |
55577
a6c2379078c8
simplifications of internal codatatype construction
traytel
parents:
55541
diff
changeset
|
901 |
HOLogic.mk_conj (empty, tree) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
902 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
903 |
|
53566 | 904 |
val carT_binds = mk_internal_bs carTN; |
905 |
fun carT_bind i = nth carT_binds (i - 1); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
906 |
val carT_def_bind = rpair [] o Thm.def_binding o carT_bind; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
907 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
908 |
fun carT_spec i = |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
909 |
HOLogic.mk_Collect (fst Kl_lab', snd Kl_lab', list_exists_free [Kl, lab] |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
910 |
(HOLogic.mk_conj (HOLogic.mk_eq (Kl_lab, HOLogic.mk_prod (Kl, lab)), |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
911 |
HOLogic.mk_conj (isTree, mk_isNode (HOLogic.mk_list sum_sbdT []) i)))); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
912 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
913 |
val ((carT_frees, (_, carT_def_frees)), (lthy, lthy_old)) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
914 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
915 |
|> Local_Theory.open_target |> snd |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
916 |
|> fold_map (fn i => |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
917 |
Local_Theory.define ((carT_bind i, NoSyn), (carT_def_bind i, carT_spec i))) ks |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
918 |
|>> apsnd split_list o split_list |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
919 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
920 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
921 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
922 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
923 |
val carT_defs = map (fn def => Morphism.thm phi def RS meta_eq_to_obj_eq) carT_def_frees; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
924 |
val carTs = map (fst o Term.dest_Const o Morphism.term phi) carT_frees; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
925 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
926 |
fun mk_carT i = Const (nth carTs (i - 1), HOLogic.mk_setT treeT); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
927 |
|
53566 | 928 |
val strT_binds = mk_internal_bs strTN; |
929 |
fun strT_bind i = nth strT_binds (i - 1); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
930 |
val strT_def_bind = rpair [] o Thm.def_binding o strT_bind; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
931 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
932 |
fun strT_spec mapFT FT i = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
933 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
934 |
fun mk_f i k k' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
935 |
let val in_k = mk_InN sbdTs k i; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
936 |
in Term.absfree k' (HOLogic.mk_prod (mk_Shift Kl in_k, mk_shift lab in_k)) end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
937 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
938 |
val f = Term.list_comb (mapFT, passive_ids @ @{map 3} mk_f ks kks kks'); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
939 |
val (fTs1, fTs2) = apsnd tl (chop (i - 1) (map (fn T => T --> FT) bdFTs)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
940 |
val fs = map mk_undefined fTs1 @ (f :: map mk_undefined fTs2); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
941 |
in |
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
61334
diff
changeset
|
942 |
HOLogic.mk_case_prod (Term.absfree Kl' (Term.absfree lab' |
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55413
diff
changeset
|
943 |
(mk_case_sumN fs $ (lab $ HOLogic.mk_list sum_sbdT [])))) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
944 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
945 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
946 |
val ((strT_frees, (_, strT_def_frees)), (lthy, lthy_old)) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
947 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
948 |
|> Local_Theory.open_target |> snd |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
949 |
|> @{fold_map 3} (fn i => fn mapFT => fn FT => Local_Theory.define |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
950 |
((strT_bind i, NoSyn), (strT_def_bind i, strT_spec mapFT FT i))) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
951 |
ks tree_maps treeFTs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
952 |
|>> apsnd split_list o split_list |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
953 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
954 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
955 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
956 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
957 |
val strT_defs = map (fn def => |
55642
63beb38e9258
adapted to renaming of datatype 'cases' and 'recs' to 'case' and 'rec'
blanchet
parents:
55602
diff
changeset
|
958 |
trans OF [Morphism.thm phi def RS meta_eq_to_obj_eq RS fun_cong, @{thm prod.case}]) |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
959 |
strT_def_frees; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
960 |
val strTs = map (fst o Term.dest_Const o Morphism.term phi) strT_frees; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
961 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
962 |
fun mk_strT FT i = Const (nth strTs (i - 1), treeT --> FT); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
963 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
964 |
val carTAs = map mk_carT ks; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
965 |
val strTAs = map2 mk_strT treeFTs ks; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
966 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
967 |
val coalgT_thm = |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
968 |
Goal.prove_sorry lthy [] [] (HOLogic.mk_Trueprop (mk_coalg carTAs strTAs)) |
55197 | 969 |
(fn {context = ctxt, prems = _} => mk_coalgT_tac ctxt m |
970 |
(coalg_def :: isNode_defs @ carT_defs) strT_defs set_mapss) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
971 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
972 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
973 |
val timer = time (timer "Tree coalgebra"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
974 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
975 |
fun mk_to_sbd s x i i' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
976 |
mk_toCard (nth (nth setssAs (i - 1)) (m + i' - 1) $ (s $ x)) sbd; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
977 |
fun mk_from_sbd s x i i' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
978 |
mk_fromCard (nth (nth setssAs (i - 1)) (m + i' - 1) $ (s $ x)) sbd; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
979 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
980 |
fun mk_to_sbd_thmss thm = map (map (fn set_sbd => |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
981 |
thm OF [set_sbd, sbd_Card_order]) o drop m) set_sbdss; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
982 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
983 |
val to_sbd_inj_thmss = mk_to_sbd_thmss @{thm toCard_inj}; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
984 |
val from_to_sbd_thmss = mk_to_sbd_thmss @{thm fromCard_toCard}; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
985 |
|
53566 | 986 |
val Lev_bind = mk_internal_b LevN; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
987 |
val Lev_def_bind = rpair [] (Thm.def_binding Lev_bind); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
988 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
989 |
val Lev_spec = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
990 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
991 |
fun mk_Suc i s setsAs a a' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
992 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
993 |
val sets = drop m setsAs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
994 |
fun mk_set i' set b = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
995 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
996 |
val Cons = HOLogic.mk_eq (kl_copy, |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
997 |
mk_Cons (mk_InN sbdTs (mk_to_sbd s a i i' $ b) i') kl) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
998 |
val b_set = HOLogic.mk_mem (b, set $ (s $ a)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
999 |
val kl_rec = HOLogic.mk_mem (kl, mk_nthN n Lev_rec i' $ b); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1000 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1001 |
HOLogic.mk_Collect (fst kl'_copy, snd kl'_copy, list_exists_free [b, kl] |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1002 |
(HOLogic.mk_conj (Cons, HOLogic.mk_conj (b_set, kl_rec)))) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1003 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1004 |
in |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1005 |
Term.absfree a' (Library.foldl1 mk_union (@{map 3} mk_set ks sets zs_copy)) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1006 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1007 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1008 |
val Suc = Term.absdummy HOLogic.natT (Term.absfree Lev_rec' |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1009 |
(HOLogic.mk_tuple (@{map 5} mk_Suc ks ss setssAs zs zs'))); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1010 |
|
55415 | 1011 |
val rhs = mk_rec_nat Zero Suc; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1012 |
in |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1013 |
fold_rev (Term.absfree o Term.dest_Free) ss rhs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1014 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1015 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1016 |
val ((Lev_free, (_, Lev_def_free)), (lthy, lthy_old)) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1017 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1018 |
|> Local_Theory.open_target |> snd |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1019 |
|> Local_Theory.define ((Lev_bind, NoSyn), (Lev_def_bind, Lev_spec)) |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1020 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1021 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1022 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1023 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1024 |
val Lev_def = mk_unabs_def n (Morphism.thm phi Lev_def_free RS meta_eq_to_obj_eq); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1025 |
val Lev = fst (Term.dest_Const (Morphism.term phi Lev_free)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1026 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1027 |
fun mk_Lev ss nat i = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1028 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1029 |
val Ts = map fastype_of ss; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1030 |
val LevT = Library.foldr (op -->) (Ts, HOLogic.natT --> |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1031 |
HOLogic.mk_tupleT (map (fn U => domain_type U --> sum_sbd_list_setT) Ts)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1032 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1033 |
mk_nthN n (Term.list_comb (Const (Lev, LevT), ss) $ nat) i |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1034 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1035 |
|
55416 | 1036 |
val Lev_0s = flat (mk_rec_simps n @{thm rec_nat_0_imp} [Lev_def]); |
1037 |
val Lev_Sucs = flat (mk_rec_simps n @{thm rec_nat_Suc_imp} [Lev_def]); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1038 |
|
53566 | 1039 |
val rv_bind = mk_internal_b rvN; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1040 |
val rv_def_bind = rpair [] (Thm.def_binding rv_bind); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1041 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1042 |
val rv_spec = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1043 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1044 |
fun mk_Cons i s b b' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1045 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1046 |
fun mk_case i' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1047 |
Term.absfree k' (mk_nthN n rv_rec i' $ (mk_from_sbd s b i i' $ k)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1048 |
in |
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55413
diff
changeset
|
1049 |
Term.absfree b' (mk_case_sumN (map mk_case ks) $ sumx) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1050 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1051 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1052 |
val Cons = Term.absfree sumx' (Term.absdummy sum_sbd_listT (Term.absfree rv_rec' |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1053 |
(HOLogic.mk_tuple (@{map 4} mk_Cons ks ss zs zs')))); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1054 |
|
55413
a8e96847523c
adapted theories to '{case,rec}_{list,option}' names
blanchet
parents:
55393
diff
changeset
|
1055 |
val rhs = mk_rec_list Nil Cons; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1056 |
in |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1057 |
fold_rev (Term.absfree o Term.dest_Free) ss rhs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1058 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1059 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1060 |
val ((rv_free, (_, rv_def_free)), (lthy, lthy_old)) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1061 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1062 |
|> Local_Theory.open_target |> snd |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1063 |
|> Local_Theory.define ((rv_bind, NoSyn), (rv_def_bind, rv_spec)) |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1064 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1065 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1066 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1067 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1068 |
val rv_def = mk_unabs_def n (Morphism.thm phi rv_def_free RS meta_eq_to_obj_eq); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1069 |
val rv = fst (Term.dest_Const (Morphism.term phi rv_free)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1070 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1071 |
fun mk_rv ss kl i = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1072 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1073 |
val Ts = map fastype_of ss; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1074 |
val As = map domain_type Ts; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1075 |
val rvT = Library.foldr (op -->) (Ts, fastype_of kl --> |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1076 |
HOLogic.mk_tupleT (map (fn U => U --> mk_sumTN As) As)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1077 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1078 |
mk_nthN n (Term.list_comb (Const (rv, rvT), ss) $ kl) i |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1079 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1080 |
|
55413
a8e96847523c
adapted theories to '{case,rec}_{list,option}' names
blanchet
parents:
55393
diff
changeset
|
1081 |
val rv_Nils = flat (mk_rec_simps n @{thm rec_list_Nil_imp} [rv_def]); |
a8e96847523c
adapted theories to '{case,rec}_{list,option}' names
blanchet
parents:
55393
diff
changeset
|
1082 |
val rv_Conss = flat (mk_rec_simps n @{thm rec_list_Cons_imp} [rv_def]); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1083 |
|
53566 | 1084 |
val beh_binds = mk_internal_bs behN; |
1085 |
fun beh_bind i = nth beh_binds (i - 1); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1086 |
val beh_def_bind = rpair [] o Thm.def_binding o beh_bind; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1087 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1088 |
fun beh_spec i z = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1089 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1090 |
fun mk_case i to_sbd_map s k k' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1091 |
Term.absfree k' (mk_InN bdFTs |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1092 |
(Term.list_comb (to_sbd_map, passive_ids @ map (mk_to_sbd s k i) ks) $ (s $ k)) i); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1093 |
|
55577
a6c2379078c8
simplifications of internal codatatype construction
traytel
parents:
55541
diff
changeset
|
1094 |
val Lab = Term.absfree kl' |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1095 |
(mk_case_sumN (@{map 5} mk_case ks to_sbd_maps ss zs zs') $ (mk_rv ss kl i $ z)); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1096 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1097 |
val rhs = HOLogic.mk_prod (mk_UNION (HOLogic.mk_UNIV HOLogic.natT) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1098 |
(Term.absfree nat' (mk_Lev ss nat i $ z)), Lab); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1099 |
in |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1100 |
fold_rev (Term.absfree o Term.dest_Free) (ss @ [z]) rhs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1101 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1102 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1103 |
val ((beh_frees, (_, beh_def_frees)), (lthy, lthy_old)) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1104 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1105 |
|> Local_Theory.open_target |> snd |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1106 |
|> @{fold_map 2} (fn i => fn z => |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1107 |
Local_Theory.define ((beh_bind i, NoSyn), (beh_def_bind i, beh_spec i z))) ks zs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1108 |
|>> apsnd split_list o split_list |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1109 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1110 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1111 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1112 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1113 |
val beh_defs = map (fn def => |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1114 |
mk_unabs_def (n + 1) (Morphism.thm phi def RS meta_eq_to_obj_eq)) beh_def_frees; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1115 |
val behs = map (fst o Term.dest_Const o Morphism.term phi) beh_frees; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1116 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1117 |
fun mk_beh ss i = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1118 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1119 |
val Ts = map fastype_of ss; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1120 |
val behT = Library.foldr (op -->) (Ts, nth activeAs (i - 1) --> treeT); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1121 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1122 |
Term.list_comb (Const (nth behs (i - 1), behT), ss) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1123 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1124 |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1125 |
val ((((((zs, zs_copy), zs_copy2), ss), (nat, nat')), (kl, kl')), _) = |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1126 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1127 |
|> mk_Frees "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1128 |
||>> mk_Frees "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1129 |
||>> mk_Frees "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1130 |
||>> mk_Frees "s" sTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1131 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "n") HOLogic.natT |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1132 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "kl") sum_sbd_listT; |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1133 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1134 |
val (length_Lev_thms, length_Lev'_thms) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1135 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1136 |
fun mk_conjunct i z = HOLogic.mk_imp (HOLogic.mk_mem (kl, mk_Lev ss nat i $ z), |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1137 |
HOLogic.mk_eq (mk_size kl, nat)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1138 |
val goal = list_all_free (kl :: zs) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1139 |
(Library.foldr1 HOLogic.mk_conj (map2 mk_conjunct ks zs)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1140 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1141 |
|
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
1142 |
val cts = map (SOME o Thm.cterm_of lthy) [Term.absfree nat' goal, nat]; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1143 |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1144 |
val length_Lev = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1145 |
Goal.prove_sorry lthy vars [] (HOLogic.mk_Trueprop goal) |
61271 | 1146 |
(fn {context = ctxt, prems = _} => mk_length_Lev_tac ctxt cts Lev_0s Lev_Sucs) |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1147 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1148 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1149 |
val length_Lev' = mk_specN (n + 1) length_Lev; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1150 |
val length_Levs = map (fn i => length_Lev' RS mk_conjunctN n i RS mp) ks; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1151 |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1152 |
fun mk_goal i z = Logic.mk_implies |
57567 | 1153 |
(mk_Trueprop_mem (kl, mk_Lev ss nat i $ z), |
1154 |
mk_Trueprop_mem (kl, mk_Lev ss (mk_size kl) i $ z)); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1155 |
val goals = map2 mk_goal ks zs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1156 |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1157 |
val length_Levs' = |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1158 |
map2 (fn goal => fn length_Lev => |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1159 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1160 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal (fn {context = ctxt, prems = _} => |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1161 |
mk_length_Lev'_tac ctxt length_Lev)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1162 |
|> Thm.close_derivation) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1163 |
goals length_Levs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1164 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1165 |
(length_Levs, length_Levs') |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1166 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1167 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1168 |
val rv_last_thmss = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1169 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1170 |
fun mk_conjunct i z i' z_copy = list_exists_free [z_copy] |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1171 |
(HOLogic.mk_eq |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1172 |
(mk_rv ss (mk_append (kl, HOLogic.mk_list sum_sbdT [mk_InN sbdTs k i'])) i $ z, |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1173 |
mk_InN activeAs z_copy i')); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1174 |
val goal = list_all_free (k :: zs) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1175 |
(Library.foldr1 HOLogic.mk_conj (map2 (fn i => fn z => |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1176 |
Library.foldr1 HOLogic.mk_conj |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1177 |
(map2 (mk_conjunct i z) ks zs_copy)) ks zs)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1178 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1179 |
|
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
1180 |
val cTs = [SOME (Thm.ctyp_of lthy sum_sbdT)]; |
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
1181 |
val cts = map (SOME o Thm.cterm_of lthy) [Term.absfree kl' goal, kl]; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1182 |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1183 |
val rv_last = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1184 |
Goal.prove_sorry lthy vars [] (HOLogic.mk_Trueprop goal) |
60728 | 1185 |
(fn {context = ctxt, prems = _} => mk_rv_last_tac ctxt cTs cts rv_Nils rv_Conss) |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1186 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1187 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1188 |
val rv_last' = mk_specN (n + 1) rv_last; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1189 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1190 |
map (fn i => map (fn i' => rv_last' RS mk_conjunctN n i RS mk_conjunctN n i') ks) ks |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1191 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1192 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1193 |
val set_Lev_thmsss = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1194 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1195 |
fun mk_conjunct i z = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1196 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1197 |
fun mk_conjunct' i' sets s z' = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1198 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1199 |
fun mk_conjunct'' i'' set z'' = HOLogic.mk_imp |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1200 |
(HOLogic.mk_mem (z'', set $ (s $ z')), |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1201 |
HOLogic.mk_mem (mk_append (kl, |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1202 |
HOLogic.mk_list sum_sbdT [mk_InN sbdTs (mk_to_sbd s z' i' i'' $ z'') i'']), |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1203 |
mk_Lev ss (HOLogic.mk_Suc nat) i $ z)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1204 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1205 |
HOLogic.mk_imp (HOLogic.mk_eq (mk_rv ss kl i $ z, mk_InN activeAs z' i'), |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1206 |
(Library.foldr1 HOLogic.mk_conj |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1207 |
(@{map 3} mk_conjunct'' ks (drop m sets) zs_copy2))) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1208 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1209 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1210 |
HOLogic.mk_imp (HOLogic.mk_mem (kl, mk_Lev ss nat i $ z), |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1211 |
Library.foldr1 HOLogic.mk_conj (@{map 4} mk_conjunct' ks setssAs ss zs_copy)) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1212 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1213 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1214 |
val goal = list_all_free (kl :: zs @ zs_copy @ zs_copy2) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1215 |
(Library.foldr1 HOLogic.mk_conj (map2 mk_conjunct ks zs)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1216 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1217 |
|
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
1218 |
val cts = map (SOME o Thm.cterm_of lthy) [Term.absfree nat' goal, nat]; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1219 |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1220 |
val set_Lev = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1221 |
Goal.prove_sorry lthy vars [] (HOLogic.mk_Trueprop goal) |
61271 | 1222 |
(fn {context = ctxt, prems = _} => |
1223 |
mk_set_Lev_tac ctxt cts Lev_0s Lev_Sucs rv_Nils rv_Conss from_to_sbd_thmss) |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1224 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1225 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1226 |
val set_Lev' = mk_specN (3 * n + 1) set_Lev; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1227 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1228 |
map (fn i => map (fn i' => map (fn i'' => set_Lev' RS |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1229 |
mk_conjunctN n i RS mp RS |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1230 |
mk_conjunctN n i' RS mp RS |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1231 |
mk_conjunctN n i'' RS mp) ks) ks) ks |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1232 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1233 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1234 |
val set_image_Lev_thmsss = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1235 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1236 |
fun mk_conjunct i z = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1237 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1238 |
fun mk_conjunct' i' sets = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1239 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1240 |
fun mk_conjunct'' i'' set s z'' = HOLogic.mk_imp |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1241 |
(HOLogic.mk_eq (mk_rv ss kl i $ z, mk_InN activeAs z'' i''), |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1242 |
HOLogic.mk_mem (k, mk_image (mk_to_sbd s z'' i'' i') $ (set $ (s $ z'')))); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1243 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1244 |
HOLogic.mk_imp (HOLogic.mk_mem |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1245 |
(mk_append (kl, HOLogic.mk_list sum_sbdT [mk_InN sbdTs k i']), |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1246 |
mk_Lev ss (HOLogic.mk_Suc nat) i $ z), |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1247 |
(Library.foldr1 HOLogic.mk_conj (@{map 4} mk_conjunct'' ks sets ss zs_copy))) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1248 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1249 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1250 |
HOLogic.mk_imp (HOLogic.mk_mem (kl, mk_Lev ss nat i $ z), |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1251 |
Library.foldr1 HOLogic.mk_conj (map2 mk_conjunct' ks (drop m setssAs'))) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1252 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1253 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1254 |
val goal = list_all_free (kl :: k :: zs @ zs_copy) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1255 |
(Library.foldr1 HOLogic.mk_conj (map2 mk_conjunct ks zs)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1256 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1257 |
|
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
1258 |
val cts = map (SOME o Thm.cterm_of lthy) [Term.absfree nat' goal, nat]; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1259 |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1260 |
val set_image_Lev = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1261 |
Goal.prove_sorry lthy vars [] (HOLogic.mk_Trueprop goal) |
61271 | 1262 |
(fn {context = ctxt, prems = _} => |
1263 |
mk_set_image_Lev_tac ctxt cts Lev_0s Lev_Sucs rv_Nils rv_Conss |
|
1264 |
from_to_sbd_thmss to_sbd_inj_thmss) |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1265 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1266 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1267 |
val set_image_Lev' = mk_specN (2 * n + 2) set_image_Lev; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1268 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1269 |
map (fn i => map (fn i' => map (fn i'' => set_image_Lev' RS |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1270 |
mk_conjunctN n i RS mp RS |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1271 |
mk_conjunctN n i'' RS mp RS |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1272 |
mk_conjunctN n i' RS mp) ks) ks) ks |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1273 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1274 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1275 |
val mor_beh_thm = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1276 |
let |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1277 |
val goal = HOLogic.mk_Trueprop (mk_mor active_UNIVs ss carTAs strTAs (map (mk_beh ss) ks)); |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1278 |
val vars = Variable.add_free_names lthy goal []; |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1279 |
in |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1280 |
Goal.prove_sorry lthy vars [] goal |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1281 |
(fn {context = ctxt, prems = _} => mk_mor_beh_tac ctxt m mor_def mor_cong_thm |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1282 |
beh_defs carT_defs strT_defs isNode_defs |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1283 |
to_sbd_inj_thmss from_to_sbd_thmss Lev_0s Lev_Sucs rv_Nils rv_Conss |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1284 |
length_Lev_thms length_Lev'_thms rv_last_thmss set_Lev_thmsss |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1285 |
set_image_Lev_thmsss set_mapss map_comp_id_thms map_cong0s) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1286 |
|> Thm.close_derivation |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1287 |
end; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1288 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1289 |
val timer = time (timer "Behavioral morphism"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1290 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1291 |
val lsbisAs = map (mk_lsbis carTAs strTAs) ks; |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1292 |
|
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1293 |
fun mk_str_final i = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1294 |
mk_univ (HOLogic.mk_comp (Term.list_comb (nth final_maps (i - 1), |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1295 |
passive_ids @ map mk_proj lsbisAs), nth strTAs (i - 1))); |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1296 |
|
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1297 |
val car_finals = map2 mk_quotient carTAs lsbisAs; |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1298 |
val str_finals = map mk_str_final ks; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1299 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1300 |
val coalgT_set_thmss = map (map (fn thm => coalgT_thm RS thm)) coalg_set_thmss; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1301 |
val equiv_LSBIS_thms = map (fn thm => coalgT_thm RS thm) equiv_lsbis_thms; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1302 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1303 |
val congruent_str_final_thms = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1304 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1305 |
fun mk_goal R final_map strT = |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1306 |
HOLogic.mk_Trueprop (mk_congruent R (HOLogic.mk_comp |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1307 |
(Term.list_comb (final_map, passive_ids @ map mk_proj lsbisAs), strT))); |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1308 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1309 |
val goals = @{map 3} mk_goal lsbisAs final_maps strTAs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1310 |
in |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1311 |
@{map 4} (fn goal => fn lsbisE => fn map_comp_id => fn map_cong0 => |
51551 | 1312 |
Goal.prove_sorry lthy [] [] goal |
60728 | 1313 |
(fn {context = ctxt, prems = _} => mk_congruent_str_final_tac ctxt m lsbisE map_comp_id |
1314 |
map_cong0 equiv_LSBIS_thms) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
1315 |
|> Thm.close_derivation) |
51761
4c9f08836d87
renamed "map_cong" axiom to "map_cong0" in preparation for real "map_cong"
blanchet
parents:
51758
diff
changeset
|
1316 |
goals lsbisE_thms map_comp_id_thms map_cong0s |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1317 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1318 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1319 |
val coalg_final_thm = Goal.prove_sorry lthy [] [] |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1320 |
(HOLogic.mk_Trueprop (mk_coalg car_finals str_finals)) |
60728 | 1321 |
(fn {context = ctxt, prems = _} => mk_coalg_final_tac ctxt m coalg_def |
1322 |
congruent_str_final_thms equiv_LSBIS_thms set_mapss coalgT_set_thmss) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
1323 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1324 |
|
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1325 |
val mor_T_final_thm = Goal.prove_sorry lthy [] [] |
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1326 |
(HOLogic.mk_Trueprop (mk_mor carTAs strTAs car_finals str_finals (map mk_proj lsbisAs))) |
60728 | 1327 |
(fn {context = ctxt, prems = _} => mk_mor_T_final_tac ctxt mor_def congruent_str_final_thms |
1328 |
equiv_LSBIS_thms) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
1329 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1330 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1331 |
val mor_final_thm = mor_comp_thm OF [mor_beh_thm, mor_T_final_thm]; |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1332 |
val in_car_final_thms = map (fn thm => thm OF [mor_final_thm, UNIV_I]) mor_image'_thms; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1333 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1334 |
val timer = time (timer "Final coalgebra"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1335 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1336 |
val ((T_names, (T_glob_infos, T_loc_infos)), lthy) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1337 |
lthy |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1338 |
|> @{fold_map 4} (fn b => fn mx => fn car_final => fn in_car_final => |
60728 | 1339 |
typedef (b, params, mx) car_final NONE |
1340 |
(fn ctxt => EVERY' [rtac ctxt exI, rtac ctxt in_car_final] 1)) |
|
1341 |
bs mixfixes car_finals in_car_final_thms |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1342 |
|>> apsnd split_list o split_list; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1343 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1344 |
val Ts = map (fn name => Type (name, params')) T_names; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1345 |
fun mk_Ts passive = map (Term.typ_subst_atomic (passiveAs ~~ passive)) Ts; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1346 |
val Ts' = mk_Ts passiveBs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1347 |
val Rep_Ts = map2 (fn info => fn T => Const (#Rep_name info, T --> treeQT)) T_glob_infos Ts; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1348 |
val Abs_Ts = map2 (fn info => fn T => Const (#Abs_name info, treeQT --> T)) T_glob_infos Ts; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1349 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1350 |
val Reps = map #Rep T_loc_infos; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1351 |
val Rep_injects = map #Rep_inject T_loc_infos; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1352 |
val Abs_inverses = map #Abs_inverse T_loc_infos; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1353 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1354 |
val timer = time (timer "THE TYPEDEFs & Rep/Abs thms"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1355 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1356 |
val UNIVs = map HOLogic.mk_UNIV Ts; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1357 |
val FTs = mk_FTs (passiveAs @ Ts); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1358 |
val FTs_setss = mk_setss (passiveAs @ Ts); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1359 |
val map_FTs = map2 (fn Ds => mk_map_of_bnf Ds treeQTs (passiveAs @ Ts)) Dss bnfs; |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1360 |
val unfold_fTs = map2 (curry op -->) activeAs Ts; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1361 |
|
56113 | 1362 |
val emptys = map (fn T => HOLogic.mk_set T []) passiveAs; |
1363 |
val Zeros = map (fn empty => |
|
1364 |
HOLogic.mk_tuple (map (fn U => absdummy U empty) Ts)) emptys; |
|
1365 |
val hrecTs = map fastype_of Zeros; |
|
1366 |
||
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1367 |
val (((zs, ss), (Jzs, Jzs')), _) = |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1368 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1369 |
|> mk_Frees "b" activeAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1370 |
||>> mk_Frees "s" sTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1371 |
||>> mk_Frees' "z" Ts; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1372 |
|
54492 | 1373 |
fun dtor_bind i = nth external_bs (i - 1) |> Binding.prefix_name (dtorN ^ "_"); |
59859 | 1374 |
val dtor_def_bind = rpair [] o Binding.concealed o Thm.def_binding o dtor_bind; |
49501 | 1375 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1376 |
fun dtor_spec rep str map_FT Jz Jz' = |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1377 |
Term.absfree Jz' |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1378 |
(Term.list_comb (map_FT, map HOLogic.id_const passiveAs @ Abs_Ts) $ (str $ (rep $ Jz))); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1379 |
|
49501 | 1380 |
val ((dtor_frees, (_, dtor_def_frees)), (lthy, lthy_old)) = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1381 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1382 |
|> Local_Theory.open_target |> snd |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1383 |
|> @{fold_map 6} (fn i => fn rep => fn str => fn mapx => fn Jz => fn Jz' => |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1384 |
Local_Theory.define ((dtor_bind i, NoSyn), |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1385 |
(dtor_def_bind i, dtor_spec rep str mapx Jz Jz'))) |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1386 |
ks Rep_Ts str_finals map_FTs Jzs Jzs' |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1387 |
|>> apsnd split_list o split_list |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1388 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1389 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1390 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
49501 | 1391 |
fun mk_dtors passive = |
49185
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49176
diff
changeset
|
1392 |
map (Term.subst_atomic_types (map (Morphism.typ phi) params' ~~ (mk_params passive)) o |
49501 | 1393 |
Morphism.term phi) dtor_frees; |
1394 |
val dtors = mk_dtors passiveAs; |
|
1395 |
val dtor's = mk_dtors passiveBs; |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1396 |
val dtor_defs = map (fn def => |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1397 |
Morphism.thm phi def RS meta_eq_to_obj_eq RS fun_cong) dtor_def_frees; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1398 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1399 |
val coalg_final_set_thmss = map (map (fn thm => coalg_final_thm RS thm)) coalg_set_thmss; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1400 |
val (mor_Rep_thm, mor_Abs_thm) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1401 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1402 |
val mor_Rep = |
51551 | 1403 |
Goal.prove_sorry lthy [] [] |
49501 | 1404 |
(HOLogic.mk_Trueprop (mk_mor UNIVs dtors car_finals str_finals Rep_Ts)) |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1405 |
(fn {context = ctxt, prems = _} => mk_mor_Rep_tac ctxt (mor_def :: dtor_defs) Reps |
55197 | 1406 |
Abs_inverses coalg_final_set_thmss map_comp_id_thms map_cong0L_thms) |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
1407 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1408 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1409 |
val mor_Abs = |
51551 | 1410 |
Goal.prove_sorry lthy [] [] |
49501 | 1411 |
(HOLogic.mk_Trueprop (mk_mor car_finals str_finals UNIVs dtors Abs_Ts)) |
55197 | 1412 |
(fn {context = ctxt, prems = _} => mk_mor_Abs_tac ctxt (mor_def :: dtor_defs) |
1413 |
Abs_inverses) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
1414 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1415 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1416 |
(mor_Rep, mor_Abs) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1417 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1418 |
|
49501 | 1419 |
val timer = time (timer "dtor definitions & thms"); |
1420 |
||
54492 | 1421 |
fun unfold_bind i = nth external_bs (i - 1) |> Binding.prefix_name (dtor_unfoldN ^ "_"); |
59859 | 1422 |
val unfold_def_bind = rpair [] o Binding.concealed o Thm.def_binding o unfold_bind; |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1423 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1424 |
fun unfold_spec abs f z = fold_rev (Term.absfree o Term.dest_Free) (ss @ [z]) (abs $ (f $ z)); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1425 |
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1426 |
val ((unfold_frees, (_, unfold_def_frees)), (lthy, lthy_old)) = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1427 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1428 |
|> Local_Theory.open_target |> snd |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1429 |
|> @{fold_map 4} (fn i => fn abs => fn f => fn z => |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1430 |
Local_Theory.define ((unfold_bind i, NoSyn), (unfold_def_bind i, unfold_spec abs f z))) |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1431 |
ks Abs_Ts (map (fn i => HOLogic.mk_comp |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1432 |
(mk_proj (nth lsbisAs (i - 1)), mk_beh ss i)) ks) zs |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1433 |
|>> apsnd split_list o split_list |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1434 |
||> `Local_Theory.close_target; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1435 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1436 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1437 |
val unfolds = map (Morphism.term phi) unfold_frees; |
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1438 |
val unfold_names = map (fst o dest_Const) unfolds; |
52731 | 1439 |
fun mk_unfolds passives actives = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1440 |
@{map 3} (fn name => fn T => fn active => |
52731 | 1441 |
Const (name, Library.foldr (op -->) |
52923 | 1442 |
(map2 (curry op -->) actives (mk_FTs (passives @ actives)), active --> T))) |
52731 | 1443 |
unfold_names (mk_Ts passives) actives; |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1444 |
fun mk_unfold Ts ss i = Term.list_comb (Const (nth unfold_names (i - 1), Library.foldr (op -->) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1445 |
(map fastype_of ss, domain_type (fastype_of (nth ss (i - 1))) --> nth Ts (i - 1))), ss); |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1446 |
val unfold_defs = map (fn def => |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1447 |
mk_unabs_def (n + 1) (Morphism.thm phi def RS meta_eq_to_obj_eq)) unfold_def_frees; |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1448 |
|
63314 | 1449 |
val (((ss, TRs), unfold_fs), _) = |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1450 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1451 |
|> mk_Frees "s" sTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1452 |
||>> mk_Frees "r" (map (mk_relT o `I) Ts) |
63314 | 1453 |
||>> mk_Frees "f" unfold_fTs; |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1454 |
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1455 |
val mor_unfold_thm = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1456 |
let |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1457 |
val Abs_inverses' = map2 (curry op RS) in_car_final_thms Abs_inverses; |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1458 |
val morEs' = map (fn thm => (thm OF [mor_final_thm, UNIV_I]) RS sym) morE_thms; |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1459 |
val goal = HOLogic.mk_Trueprop (mk_mor active_UNIVs ss UNIVs dtors (map (mk_unfold Ts ss) ks)); |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1460 |
val vars = Variable.add_free_names lthy goal []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1461 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1462 |
Goal.prove_sorry lthy vars [] goal |
60728 | 1463 |
(fn {context = ctxt, prems = _} => mk_mor_unfold_tac ctxt m mor_UNIV_thm dtor_defs |
1464 |
unfold_defs Abs_inverses' morEs' map_comp_id_thms map_cong0s) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
1465 |
|> Thm.close_derivation |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1466 |
end; |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1467 |
val dtor_unfold_thms = map (fn thm => (thm OF [mor_unfold_thm, UNIV_I]) RS sym) morE_thms; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1468 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1469 |
val (raw_coind_thms, raw_coind_thm) = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1470 |
let |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1471 |
val prem = HOLogic.mk_Trueprop (mk_sbis UNIVs dtors TRs); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1472 |
val concl = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
1473 |
(map2 (fn R => fn T => mk_leq R (Id_const T)) TRs Ts)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1474 |
val vars = fold (Variable.add_free_names lthy) [prem, concl] []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1475 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1476 |
`split_conj_thm (Goal.prove_sorry lthy vars [] (Logic.mk_implies (prem, concl)) |
60728 | 1477 |
(fn {context = ctxt, prems = _} => mk_raw_coind_tac ctxt bis_def bis_cong_thm bis_O_thm |
1478 |
bis_converse_thm bis_Gr_thm tcoalg_thm coalgT_thm mor_T_final_thm sbis_lsbis_thm |
|
1479 |
lsbis_incl_thms incl_lsbis_thms equiv_LSBIS_thms mor_Rep_thm Rep_injects) |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1480 |
|> Thm.close_derivation) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1481 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1482 |
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1483 |
val (unfold_unique_mor_thms, unfold_unique_mor_thm) = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1484 |
let |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1485 |
val prem = HOLogic.mk_Trueprop (mk_mor active_UNIVs ss UNIVs dtors unfold_fs); |
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1486 |
fun mk_fun_eq f i = HOLogic.mk_eq (f, mk_unfold Ts ss i); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1487 |
val unique = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1488 |
(map2 mk_fun_eq unfold_fs ks)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1489 |
val vars = fold (Variable.add_free_names lthy) [prem, unique] []; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1490 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1491 |
val bis_thm = tcoalg_thm RSN (2, tcoalg_thm RS bis_image2_thm); |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1492 |
val mor_thm = mor_comp_thm OF [mor_final_thm, mor_Abs_thm]; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1493 |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1494 |
val unique_mor = Goal.prove_sorry lthy vars [] (Logic.mk_implies (prem, unique)) |
60728 | 1495 |
(fn {context = ctxt, prems = _} => mk_unfold_unique_mor_tac ctxt raw_coind_thms |
1496 |
bis_thm mor_thm unfold_defs) |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1497 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1498 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1499 |
`split_conj_thm unique_mor |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1500 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1501 |
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1502 |
val (dtor_unfold_unique_thms, dtor_unfold_unique_thm) = `split_conj_thm (split_conj_prems n |
52904 | 1503 |
(mor_UNIV_thm RS iffD2 RS unfold_unique_mor_thm)); |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1504 |
|
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1505 |
val unfold_dtor_thms = map (fn thm => mor_id_thm RS thm RS sym) unfold_unique_mor_thms; |
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1506 |
|
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1507 |
val unfold_o_dtor_thms = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1508 |
let |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1509 |
val mor = mor_comp_thm OF [mor_str_thm, mor_unfold_thm]; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1510 |
in |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1511 |
map2 (fn unique => fn unfold_ctor => |
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1512 |
trans OF [mor RS unique, unfold_ctor]) unfold_unique_mor_thms unfold_dtor_thms |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1513 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1514 |
|
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1515 |
val timer = time (timer "unfold definitions & thms"); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1516 |
|
49501 | 1517 |
val map_dtors = map2 (fn Ds => fn bnf => |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1518 |
Term.list_comb (mk_map_of_bnf Ds (passiveAs @ Ts) (passiveAs @ FTs) bnf, |
49501 | 1519 |
map HOLogic.id_const passiveAs @ dtors)) Dss bnfs; |
1520 |
||
54492 | 1521 |
fun ctor_bind i = nth external_bs (i - 1) |> Binding.prefix_name (ctorN ^ "_"); |
59859 | 1522 |
val ctor_def_bind = rpair [] o Binding.concealed o Thm.def_binding o ctor_bind; |
49501 | 1523 |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1524 |
fun ctor_spec i = mk_unfold Ts map_dtors i; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1525 |
|
49501 | 1526 |
val ((ctor_frees, (_, ctor_def_frees)), (lthy, lthy_old)) = |
49311 | 1527 |
lthy |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1528 |
|> Local_Theory.open_target |> snd |
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1529 |
|> fold_map (fn i => |
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1530 |
Local_Theory.define ((ctor_bind i, NoSyn), (ctor_def_bind i, ctor_spec i))) ks |
49311 | 1531 |
|>> apsnd split_list o split_list |
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1532 |
||> `Local_Theory.close_target; |
49311 | 1533 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1534 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
49501 | 1535 |
fun mk_ctors params = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1536 |
map (Term.subst_atomic_types (map (Morphism.typ phi) params' ~~ params) o Morphism.term phi) |
49501 | 1537 |
ctor_frees; |
1538 |
val ctors = mk_ctors params'; |
|
55204
345ee77213b5
use Local_Theory.define instead of Specification.definition for internal constants
traytel
parents:
55197
diff
changeset
|
1539 |
val ctor_defs = map (fn def => Morphism.thm phi def RS meta_eq_to_obj_eq) ctor_def_frees; |
49501 | 1540 |
|
63222
fe92356ade42
eliminated pointless alias (no warning for duplicates);
wenzelm
parents:
63045
diff
changeset
|
1541 |
val ctor_o_dtor_thms = map2 (Local_Defs.fold lthy o single) ctor_defs unfold_o_dtor_thms; |
49501 | 1542 |
|
1543 |
val dtor_o_ctor_thms = |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1544 |
let |
49501 | 1545 |
fun mk_goal dtor ctor FT = |
1546 |
mk_Trueprop_eq (HOLogic.mk_comp (dtor, ctor), HOLogic.id_const FT); |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1547 |
val goals = @{map 3} mk_goal dtors ctors FTs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1548 |
in |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1549 |
@{map 5} (fn goal => fn ctor_def => fn unfold => fn map_comp_id => fn map_cong0L => |
51551 | 1550 |
Goal.prove_sorry lthy [] [] goal |
55197 | 1551 |
(fn {context = ctxt, prems = _} => mk_dtor_o_ctor_tac ctxt ctor_def unfold map_comp_id |
1552 |
map_cong0L unfold_o_dtor_thms) |
|
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
1553 |
|> Thm.close_derivation) |
51761
4c9f08836d87
renamed "map_cong" axiom to "map_cong0" in preparation for real "map_cong"
blanchet
parents:
51758
diff
changeset
|
1554 |
goals ctor_defs dtor_unfold_thms map_comp_id_thms map_cong0L_thms |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1555 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1556 |
|
49501 | 1557 |
val dtor_ctor_thms = map (fn thm => thm RS @{thm pointfree_idE}) dtor_o_ctor_thms; |
1558 |
val ctor_dtor_thms = map (fn thm => thm RS @{thm pointfree_idE}) ctor_o_dtor_thms; |
|
1559 |
||
1560 |
val bij_dtor_thms = |
|
1561 |
map2 (fn thm1 => fn thm2 => @{thm o_bij} OF [thm1, thm2]) ctor_o_dtor_thms dtor_o_ctor_thms; |
|
1562 |
val inj_dtor_thms = map (fn thm => thm RS @{thm bij_is_inj}) bij_dtor_thms; |
|
1563 |
val surj_dtor_thms = map (fn thm => thm RS @{thm bij_is_surj}) bij_dtor_thms; |
|
1564 |
val dtor_nchotomy_thms = map (fn thm => thm RS @{thm surjD}) surj_dtor_thms; |
|
1565 |
val dtor_inject_thms = map (fn thm => thm RS @{thm inj_eq}) inj_dtor_thms; |
|
1566 |
val dtor_exhaust_thms = map (fn thm => thm RS exE) dtor_nchotomy_thms; |
|
1567 |
||
1568 |
val bij_ctor_thms = |
|
1569 |
map2 (fn thm1 => fn thm2 => @{thm o_bij} OF [thm1, thm2]) dtor_o_ctor_thms ctor_o_dtor_thms; |
|
1570 |
val inj_ctor_thms = map (fn thm => thm RS @{thm bij_is_inj}) bij_ctor_thms; |
|
1571 |
val surj_ctor_thms = map (fn thm => thm RS @{thm bij_is_surj}) bij_ctor_thms; |
|
1572 |
val ctor_nchotomy_thms = map (fn thm => thm RS @{thm surjD}) surj_ctor_thms; |
|
1573 |
val ctor_inject_thms = map (fn thm => thm RS @{thm inj_eq}) inj_ctor_thms; |
|
1574 |
val ctor_exhaust_thms = map (fn thm => thm RS exE) ctor_nchotomy_thms; |
|
1575 |
||
1576 |
val timer = time (timer "ctor definitions & thms"); |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1577 |
|
63314 | 1578 |
val (((((Jzs, Jzs_copy), Jzs1), Jzs2), phis), _) = |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1579 |
lthy |
63314 | 1580 |
|> mk_Frees "z" Ts |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1581 |
||>> mk_Frees "z'" Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1582 |
||>> mk_Frees "z1" Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1583 |
||>> mk_Frees "z2" Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1584 |
||>> mk_Frees "P" (map2 mk_pred2T Ts Ts); |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1585 |
|
55644 | 1586 |
val (coinduct_params, dtor_coinduct_thm) = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1587 |
let |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
1588 |
val rels = map (Term.subst_atomic_types ((activeAs ~~ Ts) @ (activeBs ~~ Ts))) relsAsBs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1589 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1590 |
fun mk_concl phi z1 z2 = HOLogic.mk_imp (phi $ z1 $ z2, HOLogic.mk_eq (z1, z2)); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1591 |
val concl = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1592 |
(@{map 3} mk_concl phis Jzs1 Jzs2)); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1593 |
|
53105
ec38e9f4352f
simpler (forward) derivation of strong (up-to equality) coinduction properties
traytel
parents:
53104
diff
changeset
|
1594 |
fun mk_rel_prem phi dtor rel Jz Jz_copy = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1595 |
let |
55541
fd9ea8ae28f6
syntactic simplifications of internal (co)datatype constructions
traytel
parents:
55538
diff
changeset
|
1596 |
val concl = Term.list_comb (rel, passive_eqs @ phis) $ |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
1597 |
(dtor $ Jz) $ (dtor $ Jz_copy); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1598 |
in |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1599 |
HOLogic.mk_Trueprop |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1600 |
(list_all_free [Jz, Jz_copy] (HOLogic.mk_imp (phi $ Jz $ Jz_copy, concl))) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1601 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1602 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1603 |
val rel_prems = @{map 5} mk_rel_prem phis dtors rels Jzs Jzs_copy; |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1604 |
val dtor_coinduct_goal = Logic.list_implies (rel_prems, concl); |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
1605 |
|
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
1606 |
val dtor_coinduct = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1607 |
Variable.add_free_names lthy dtor_coinduct_goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1608 |
|> (fn vars => Goal.prove_sorry lthy vars [] dtor_coinduct_goal |
60728 | 1609 |
(fn {context = ctxt, prems = _} => mk_dtor_coinduct_tac ctxt m raw_coind_thm bis_rel_thm |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1610 |
rel_congs)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1611 |
|> Thm.close_derivation; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1612 |
in |
55644 | 1613 |
(rev (Term.add_tfrees dtor_coinduct_goal []), dtor_coinduct) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1614 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1615 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1616 |
val timer = time (timer "coinduction"); |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1617 |
|
53270 | 1618 |
fun mk_dtor_map_DEADID_thm dtor_inject map_id0 = |
1619 |
trans OF [iffD2 OF [dtor_inject, id_apply], map_id0 RS sym]; |
|
51925 | 1620 |
|
62863
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1621 |
fun mk_dtor_map_unique_DEADID_thm () = |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1622 |
let |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1623 |
val (funs, algs) = |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1624 |
HOLogic.conjuncts (HOLogic.dest_Trueprop (Thm.concl_of dtor_unfold_unique_thm)) |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1625 |
|> map_split HOLogic.dest_eq |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1626 |
||> snd o strip_comb o hd |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1627 |
|> @{apply 2} (map (fst o dest_Var)); |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1628 |
fun mk_fun_insts T ix = Thm.cterm_of lthy (Var (ix, T --> T)); |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1629 |
val theta = |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1630 |
(funs ~~ @{map 2} mk_fun_insts Ts funs) @ (algs ~~ map (Thm.cterm_of lthy) dtors); |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1631 |
val dtor_unfold_dtors = (dtor_unfold_unique_thm OF |
67091 | 1632 |
map (fn thm => mk_trans (thm RS @{thm arg_cong2[of _ _ _ _ "op \<circ>", OF _ refl]}) |
62863
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1633 |
@{thm trans[OF id_o o_id[symmetric]]}) map_id0s) |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1634 |
|> split_conj_thm |> map mk_sym; |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1635 |
in |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1636 |
infer_instantiate lthy theta dtor_unfold_unique_thm |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1637 |
|> Morphism.thm (Local_Theory.target_morphism lthy) |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1638 |
|> unfold_thms lthy dtor_unfold_dtors |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1639 |
|> (fn thm => thm OF replicate n sym) |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1640 |
end; |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1641 |
(* |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1642 |
thm trans[OF x.dtor_unfold_unique x.dtor_unfold_unique[symmetric, |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1643 |
OF trans[OF arg_cong2[of _ _ _ _ "op o", OF pre_x.map_id0 refl] trans[OF id_o o_id[symmetric]]]], |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1644 |
OF sym] |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1645 |
*) |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1646 |
|
51925 | 1647 |
fun mk_dtor_Jrel_DEADID_thm dtor_inject bnf = |
51917
f964a9887713
store proper theorems even for fixed points that have no passive live variables
traytel
parents:
51894
diff
changeset
|
1648 |
trans OF [rel_eq_of_bnf bnf RS @{thm predicate2_eqD}, dtor_inject] RS sym; |
f964a9887713
store proper theorems even for fixed points that have no passive live variables
traytel
parents:
51894
diff
changeset
|
1649 |
|
51925 | 1650 |
val JphiTs = map2 mk_pred2T passiveAs passiveBs; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1651 |
val Jpsi1Ts = map2 mk_pred2T passiveAs passiveCs; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1652 |
val Jpsi2Ts = map2 mk_pred2T passiveCs passiveBs; |
51925 | 1653 |
val prodTsTs' = map2 (curry HOLogic.mk_prodT) Ts Ts'; |
1654 |
val fstsTsTs' = map fst_const prodTsTs'; |
|
1655 |
val sndsTsTs' = map snd_const prodTsTs'; |
|
52731 | 1656 |
val activephiTs = map2 mk_pred2T activeAs activeBs; |
51925 | 1657 |
val activeJphiTs = map2 mk_pred2T Ts Ts'; |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1658 |
|
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1659 |
val rels = map2 (fn Ds => mk_rel_of_bnf Ds (passiveAs @ Ts) (passiveBs @ Ts')) Dss bnfs; |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1660 |
|
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1661 |
val ((((Jzs, Jz's), Jphis), activeJphis), _) = |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1662 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1663 |
|> mk_Frees "z" Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1664 |
||>> mk_Frees "y" Ts' |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1665 |
||>> mk_Frees "R" JphiTs |
51925 | 1666 |
||>> mk_Frees "JR" activeJphiTs; |
1667 |
||
57567 | 1668 |
fun mk_Jrel_DEADID_coinduct_thm () = |
58579
b7bc5ba2f3fb
rename 'rel_xtor_co_induct_thm' to 'xtor_rel_co_induct'
desharna
parents:
58578
diff
changeset
|
1669 |
mk_xtor_rel_co_induct_thm Greatest_FP rels activeJphis (map HOLogic.eq_const Ts) Jphis |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1670 |
Jzs Jz's dtors dtor's (fn {context = ctxt, prems} => |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1671 |
(unfold_thms_tac ctxt @{thms le_fun_def le_bool_def all_simps(1,2)[symmetric]} THEN |
60728 | 1672 |
REPEAT_DETERM (rtac ctxt allI 1) THEN rtac ctxt (dtor_coinduct_thm OF prems) 1)) lthy; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1673 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1674 |
(*register new codatatypes as BNFs*) |
62863
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1675 |
val (timer, Jbnfs, (dtor_Jmap_o_thms, dtor_Jmap_thms), dtor_Jmap_unique_thm, dtor_Jset_thmss', |
57700 | 1676 |
dtor_Jrel_thms, Jrel_coinduct_thm, Jbnf_notes, dtor_Jset_induct_thms, lthy) = |
49585
5c4a12550491
generate high-level "maps", "sets", and "rels" properties
blanchet
parents:
49584
diff
changeset
|
1677 |
if m = 0 then |
52913
2d2d9d1de1a9
theorems relating {c,d}tor_(un)fold/(co)rec and {c,d}tor_map
traytel
parents:
52912
diff
changeset
|
1678 |
(timer, replicate n DEADID_bnf, |
64413 | 1679 |
map_split (`(mk_pointfree2 lthy)) (map2 mk_dtor_map_DEADID_thm dtor_inject_thms map_ids), |
62863
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1680 |
mk_dtor_map_unique_DEADID_thm (), |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1681 |
replicate n [], |
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
1682 |
map2 mk_dtor_Jrel_DEADID_thm dtor_inject_thms bnfs, |
57700 | 1683 |
mk_Jrel_DEADID_coinduct_thm (), [], [], lthy) |
49585
5c4a12550491
generate high-level "maps", "sets", and "rels" properties
blanchet
parents:
49584
diff
changeset
|
1684 |
else let |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1685 |
val fTs = map2 (curry op -->) passiveAs passiveBs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1686 |
val gTs = map2 (curry op -->) passiveBs passiveCs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1687 |
val uTs = map2 (curry op -->) Ts Ts'; |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1688 |
val (((((nat, nat'), (Jzs, Jzs')), (hrecs, hrecs')), (fs, fs')), _) = |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1689 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1690 |
|> yield_singleton (apfst (op ~~) oo mk_Frees' "n") HOLogic.natT |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1691 |
||>> mk_Frees' "z" Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1692 |
||>> mk_Frees' "rec" hrecTs |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1693 |
||>> mk_Frees' "f" fTs; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1694 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1695 |
val map_FTFT's = map2 (fn Ds => |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1696 |
mk_map_of_bnf Ds (passiveAs @ Ts) (passiveBs @ Ts')) Dss bnfs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1697 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1698 |
fun mk_maps ATs BTs Ts mk_T = |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1699 |
map2 (fn Ds => mk_map_of_bnf Ds (ATs @ Ts) (BTs @ map mk_T Ts)) Dss bnfs; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1700 |
fun mk_Fmap mk_const fs Ts Fmap = Term.list_comb (Fmap, fs @ map mk_const Ts); |
49501 | 1701 |
fun mk_map mk_const mk_T Ts fs Ts' dtors mk_maps = |
49504
df9b897fb254
renamed "iter"/"coiter" to "fold"/"unfold" (cf. Wadler)
blanchet
parents:
49501
diff
changeset
|
1702 |
mk_unfold Ts' (map2 (fn dtor => fn Fmap => |
49501 | 1703 |
HOLogic.mk_comp (mk_Fmap mk_const fs Ts Fmap, dtor)) dtors (mk_maps Ts mk_T)); |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1704 |
val mk_map_id = mk_map HOLogic.id_const I; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1705 |
val mk_mapsAB = mk_maps passiveAs passiveBs; |
49501 | 1706 |
val fs_maps = map (mk_map_id Ts fs Ts' dtors mk_mapsAB) ks; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1707 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1708 |
val set_bss = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1709 |
map (flat o map2 (fn B => fn b => |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1710 |
if member (op =) resDs (TFree B) then [] else [b]) resBs) set_bss0; |
57567 | 1711 |
|
56113 | 1712 |
fun col_bind j = mk_internal_b (colN ^ (if m = 1 then "" else string_of_int j)); |
1713 |
val col_def_bind = rpair [] o Thm.def_binding o col_bind; |
|
57567 | 1714 |
|
56113 | 1715 |
fun col_spec j Zero hrec hrec' = |
1716 |
let |
|
56179 | 1717 |
fun mk_Suc dtor sets z z' = |
56113 | 1718 |
let |
56179 | 1719 |
val (set, sets) = apfst (fn xs => nth xs (j - 1)) (chop m sets); |
56113 | 1720 |
fun mk_UN set k = mk_UNION (set $ (dtor $ z)) (mk_nthN n hrec k); |
1721 |
in |
|
1722 |
Term.absfree z' |
|
1723 |
(mk_union (set $ (dtor $ z), Library.foldl1 mk_union (map2 mk_UN sets ks))) |
|
1724 |
end; |
|
57567 | 1725 |
|
56113 | 1726 |
val Suc = Term.absdummy HOLogic.natT (Term.absfree hrec' |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1727 |
(HOLogic.mk_tuple (@{map 4} mk_Suc dtors FTs_setss Jzs Jzs'))); |
56113 | 1728 |
in |
1729 |
mk_rec_nat Zero Suc |
|
1730 |
end; |
|
57567 | 1731 |
|
56113 | 1732 |
val ((col_frees, (_, col_def_frees)), (lthy, lthy_old)) = |
1733 |
lthy |
|
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1734 |
|> Local_Theory.open_target |> snd |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1735 |
|> @{fold_map 4} (fn j => fn Zero => fn hrec => fn hrec' => Local_Theory.define |
56113 | 1736 |
((col_bind j, NoSyn), (col_def_bind j, col_spec j Zero hrec hrec'))) |
1737 |
ls Zeros hrecs hrecs' |
|
1738 |
|>> apsnd split_list o split_list |
|
61101
7b915ca69af1
use open/close_target rather than Local_Theory.restore to get polymorphic definitions;
traytel
parents:
60801
diff
changeset
|
1739 |
||> `Local_Theory.close_target; |
57567 | 1740 |
|
56113 | 1741 |
val phi = Proof_Context.export_morphism lthy_old lthy; |
57567 | 1742 |
|
56113 | 1743 |
val col_defs = map (fn def => Morphism.thm phi def RS meta_eq_to_obj_eq) col_def_frees; |
1744 |
val cols = map (fst o Term.dest_Const o Morphism.term phi) col_frees; |
|
57567 | 1745 |
|
56113 | 1746 |
fun mk_col Ts nat i j T = |
1747 |
let |
|
1748 |
val hrecT = HOLogic.mk_tupleT (map (fn U => U --> HOLogic.mk_setT T) Ts) |
|
1749 |
val colT = HOLogic.natT --> hrecT; |
|
1750 |
in |
|
1751 |
mk_nthN n (Term.list_comb (Const (nth cols (j - 1), colT), [nat])) i |
|
1752 |
end; |
|
57567 | 1753 |
|
56113 | 1754 |
val col_0ss = mk_rec_simps n @{thm rec_nat_0_imp} col_defs; |
1755 |
val col_Sucss = mk_rec_simps n @{thm rec_nat_Suc_imp} col_defs; |
|
1756 |
val col_0ss' = transpose col_0ss; |
|
1757 |
val col_Sucss' = transpose col_Sucss; |
|
57567 | 1758 |
|
56179 | 1759 |
fun mk_set Ts i j T = |
56113 | 1760 |
Abs (Name.uu, nth Ts (i - 1), mk_UNION (HOLogic.mk_UNIV HOLogic.natT) |
1761 |
(Term.absfree nat' (mk_col Ts nat i j T $ Bound 1))); |
|
1762 |
||
56179 | 1763 |
val setss = map (fn i => map2 (mk_set Ts i) ls passiveAs) ks; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1764 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1765 |
val (Jbnf_consts, lthy) = |
62324 | 1766 |
@{fold_map 8} (fn b => fn map_b => fn rel_b => fn pred_b => fn set_bs => fn mapx => |
1767 |
fn sets => fn T => fn lthy => |
|
56179 | 1768 |
define_bnf_consts Hardly_Inline (user_policy Note_Some lthy) false (SOME deads) |
62324 | 1769 |
map_b rel_b pred_b set_bs |
1770 |
(((((((b, T), fold_rev Term.absfree fs' mapx), sets), sbd), |
|
1771 |
[Const (@{const_name undefined}, T)]), NONE), NONE) lthy) |
|
1772 |
bs map_bs rel_bs pred_bs set_bss fs_maps setss Ts lthy; |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1773 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1774 |
val (_, Jconsts, Jconst_defs, mk_Jconsts) = @{split_list 4} Jbnf_consts; |
62324 | 1775 |
val (_, Jsetss, Jbds_Ds, _, _, _) = @{split_list 6} Jconsts; |
1776 |
val (Jmap_defs, Jset_defss, Jbd_defs, _, Jrel_defs, Jpred_defs) = |
|
1777 |
@{split_list 6} Jconst_defs; |
|
1778 |
val (mk_Jmaps_Ds, mk_Jt_Ds, _, mk_Jrels_Ds, mk_Jpreds_Ds, _, _) = |
|
1779 |
@{split_list 7} mk_Jconsts; |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1780 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1781 |
val Jrel_unabs_defs = map (fn def => mk_unabs_def m (def RS meta_eq_to_obj_eq)) Jrel_defs; |
62324 | 1782 |
val Jpred_unabs_defs = map (fn def => mk_unabs_def m (def RS meta_eq_to_obj_eq)) Jpred_defs; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1783 |
val Jset_defs = flat Jset_defss; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1784 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1785 |
fun mk_Jmaps As Bs = map (fn mk => mk deads As Bs) mk_Jmaps_Ds; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1786 |
fun mk_Jsetss As = map2 (fn mk => fn Jsets => map (mk deads As) Jsets) mk_Jt_Ds Jsetss; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1787 |
val Jbds = map2 (fn mk => mk deads passiveAs) mk_Jt_Ds Jbds_Ds; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1788 |
fun mk_Jrels As Bs = map (fn mk => mk deads As Bs) mk_Jrels_Ds; |
62324 | 1789 |
fun mk_Jpreds As = map (fn mk => mk deads As) mk_Jpreds_Ds; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1790 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1791 |
val Jmaps = mk_Jmaps passiveAs passiveBs; |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1792 |
val (Jsetss_by_range, Jsetss_by_bnf) = `transpose (mk_Jsetss passiveAs); |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1793 |
|
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1794 |
val timer = time (timer "bnf constants for the new datatypes"); |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1795 |
|
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1796 |
val ((((((((((((((((((((ys, ys'), (nat, nat')), (Jzs, Jzs')), Jz's), Jzs_copy), Jz's_copy), |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1797 |
dtor_set_induct_phiss), Jphis), Jpsi1s), Jpsi2s), activeJphis), fs), fs_copy), gs), us), |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1798 |
(Jys, Jys')), (Jys_copy, Jys'_copy)), (ys_copy, ys'_copy)), Kss), names_lthy) = |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1799 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1800 |
|> mk_Frees' "y" passiveAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1801 |
||>> yield_singleton (apfst (op ~~) oo mk_Frees' "n") HOLogic.natT |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1802 |
||>> mk_Frees' "z" Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1803 |
||>> mk_Frees "y" Ts' |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1804 |
||>> mk_Frees "z'" Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1805 |
||>> mk_Frees "y'" Ts' |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1806 |
||>> mk_Freess "P" (map (fn A => map (mk_pred2T A) Ts) passiveAs) |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1807 |
||>> mk_Frees "R" JphiTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1808 |
||>> mk_Frees "R" Jpsi1Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1809 |
||>> mk_Frees "Q" Jpsi2Ts |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1810 |
||>> mk_Frees "JR" activeJphiTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1811 |
||>> mk_Frees "f" fTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1812 |
||>> mk_Frees "f" fTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1813 |
||>> mk_Frees "g" gTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1814 |
||>> mk_Frees "u" uTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1815 |
||>> mk_Frees' "b" Ts' |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1816 |
||>> mk_Frees' "b" Ts' |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1817 |
||>> mk_Frees' "y" passiveAs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1818 |
||>> mk_Freess "K" (map (fn AT => map (fn T => T --> AT) Ts) ATs); |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
1819 |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1820 |
val fs_Jmaps = map (fn m => Term.list_comb (m, fs)) Jmaps; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1821 |
val fs_copy_Jmaps = map (fn m => Term.list_comb (m, fs_copy)) Jmaps; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1822 |
val gs_Jmaps = map (fn m => Term.list_comb (m, gs)) (mk_Jmaps passiveBs passiveCs); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1823 |
val fgs_Jmaps = map (fn m => Term.list_comb (m, map2 (curry HOLogic.mk_comp) gs fs)) |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1824 |
(mk_Jmaps passiveAs passiveCs); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1825 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1826 |
val (dtor_Jmap_thms, Jmap_thms) = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1827 |
let |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1828 |
fun mk_goal fs_Jmap map dtor dtor' = mk_Trueprop_eq (HOLogic.mk_comp (dtor', fs_Jmap), |
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1829 |
HOLogic.mk_comp (Term.list_comb (map, fs @ fs_Jmaps), dtor)); |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1830 |
val goals = @{map 4} mk_goal fs_Jmaps map_FTFT's dtors dtor's; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1831 |
val maps = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1832 |
@{map 5} (fn goal => fn unfold => fn map_comp => fn map_cong0 => fn map_arg_cong => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1833 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1834 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1835 |
(fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jmap_defs THEN |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1836 |
mk_map_tac ctxt m n map_arg_cong unfold map_comp map_cong0)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1837 |
|> Thm.close_derivation) |
55602 | 1838 |
goals dtor_unfold_thms map_comps map_cong0s map_arg_cong_thms; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1839 |
in |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1840 |
map_split (fn thm => (thm RS @{thm comp_eq_dest}, thm)) maps |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1841 |
end; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1842 |
|
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
1843 |
val (dtor_Jmap_unique_thms, dtor_Jmap_unique_thm) = |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1844 |
let |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1845 |
fun mk_prem u map dtor dtor' = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1846 |
mk_Trueprop_eq (HOLogic.mk_comp (dtor', u), |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1847 |
HOLogic.mk_comp (Term.list_comb (map, fs @ us), dtor)); |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1848 |
val prems = @{map 4} mk_prem us map_FTFT's dtors dtor's; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1849 |
val goal = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1850 |
HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1851 |
(map2 (curry HOLogic.mk_eq) us fs_Jmaps)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1852 |
val vars = fold (Variable.add_free_names lthy) (goal :: prems) []; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1853 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1854 |
`split_conj_thm (Goal.prove_sorry lthy vars [] (Logic.list_implies (prems, goal)) |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1855 |
(fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jmap_defs THEN |
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1856 |
mk_dtor_map_unique_tac ctxt dtor_unfold_unique_thm sym_map_comps) |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1857 |
|> Thm.close_derivation) |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1858 |
end; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1859 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1860 |
val Jmap_comp0_thms = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1861 |
let |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1862 |
val goal = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1863 |
(@{map 3} (fn fmap => fn gmap => fn fgmap => |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1864 |
HOLogic.mk_eq (HOLogic.mk_comp (gmap, fmap), fgmap)) |
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1865 |
fs_Jmaps gs_Jmaps fgs_Jmaps)) |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1866 |
val vars = Variable.add_free_names lthy goal []; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1867 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1868 |
split_conj_thm (Goal.prove_sorry lthy vars [] goal |
60728 | 1869 |
(fn {context = ctxt, prems = _} => |
1870 |
mk_map_comp0_tac ctxt Jmap_thms map_comp0s dtor_Jmap_unique_thm) |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1871 |
|> Thm.close_derivation) |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1872 |
end; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1873 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1874 |
val timer = time (timer "map functions for the new codatatypes"); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
1875 |
|
56179 | 1876 |
val Jset_minimal_thms = |
1877 |
let |
|
1878 |
fun mk_passive_prem set dtor x K = |
|
1879 |
Logic.all x (HOLogic.mk_Trueprop (mk_leq (set $ (dtor $ x)) (K $ x))); |
|
57567 | 1880 |
|
56179 | 1881 |
fun mk_active_prem dtor x1 K1 set x2 K2 = |
1882 |
fold_rev Logic.all [x1, x2] |
|
57567 | 1883 |
(Logic.mk_implies (mk_Trueprop_mem (x2, set $ (dtor $ x1)), |
56179 | 1884 |
HOLogic.mk_Trueprop (mk_leq (K2 $ x2) (K1 $ x1)))); |
57567 | 1885 |
|
56179 | 1886 |
val premss = map2 (fn j => fn Ks => |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1887 |
@{map 4} mk_passive_prem (map (fn xs => nth xs (j - 1)) FTs_setss) dtors Jzs Ks @ |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1888 |
flat (@{map 4} (fn sets => fn s => fn x1 => fn K1 => |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1889 |
@{map 3} (mk_active_prem s x1 K1) (drop m sets) Jzs_copy Ks) FTs_setss dtors Jzs Ks)) |
56179 | 1890 |
ls Kss; |
57567 | 1891 |
|
56179 | 1892 |
val col_minimal_thms = |
1893 |
let |
|
1894 |
fun mk_conjunct j T i K x = mk_leq (mk_col Ts nat i j T $ x) (K $ x); |
|
1895 |
fun mk_concl j T Ks = list_all_free Jzs |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1896 |
(Library.foldr1 HOLogic.mk_conj (@{map 3} (mk_conjunct j T) ks Ks Jzs)); |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1897 |
val concls = @{map 3} mk_concl ls passiveAs Kss; |
57567 | 1898 |
|
56179 | 1899 |
val goals = map2 (fn prems => fn concl => |
1900 |
Logic.list_implies (prems, HOLogic.mk_Trueprop concl)) premss concls |
|
57567 | 1901 |
|
56179 | 1902 |
val ctss = |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
1903 |
map (fn phi => map (SOME o Thm.cterm_of lthy) [Term.absfree nat' phi, nat]) concls; |
56179 | 1904 |
in |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1905 |
@{map 4} (fn goal => fn cts => fn col_0s => fn col_Sucs => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1906 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1907 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1908 |
(fn {context = ctxt, prems = _} => mk_col_minimal_tac ctxt m cts col_0s |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1909 |
col_Sucs)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1910 |
|> Thm.close_derivation) |
56179 | 1911 |
goals ctss col_0ss' col_Sucss' |
1912 |
end; |
|
57567 | 1913 |
|
56179 | 1914 |
fun mk_conjunct set K x = mk_leq (set $ x) (K $ x); |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1915 |
fun mk_concl sets Ks = Library.foldr1 HOLogic.mk_conj (@{map 3} mk_conjunct sets Ks Jzs); |
56179 | 1916 |
val concls = map2 mk_concl Jsetss_by_range Kss; |
57567 | 1917 |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1918 |
val goals = map2 (fn prems => fn concl => |
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1919 |
Logic.list_implies (prems, HOLogic.mk_Trueprop concl)) premss concls; |
56179 | 1920 |
in |
1921 |
map2 (fn goal => fn col_minimal => |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1922 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1923 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
56179 | 1924 |
(fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jset_defs THEN |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1925 |
mk_Jset_minimal_tac ctxt n col_minimal)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1926 |
|> Thm.close_derivation) |
56179 | 1927 |
goals col_minimal_thms |
1928 |
end; |
|
1929 |
||
1930 |
val (dtor_Jset_incl_thmss, dtor_set_Jset_incl_thmsss) = |
|
1931 |
let |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1932 |
fun mk_set_incl_Jset dtor x set Jset = |
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1933 |
HOLogic.mk_Trueprop (mk_leq (set $ (dtor $ x)) (Jset $ x)); |
57567 | 1934 |
|
56179 | 1935 |
fun mk_set_Jset_incl_Jset dtor x y set Jset1 Jset2 = |
57567 | 1936 |
Logic.mk_implies (mk_Trueprop_mem (x, set $ (dtor $ y)), |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
1937 |
HOLogic.mk_Trueprop (mk_leq (Jset1 $ x) (Jset2 $ y))); |
57567 | 1938 |
|
56179 | 1939 |
val set_incl_Jset_goalss = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1940 |
@{map 4} (fn dtor => fn x => fn sets => fn Jsets => |
56179 | 1941 |
map2 (mk_set_incl_Jset dtor x) (take m sets) Jsets) |
1942 |
dtors Jzs FTs_setss Jsetss_by_bnf; |
|
57567 | 1943 |
|
56179 | 1944 |
(*x(k) : F(i)set(m+k) (dtor(i) y(i)) ==> J(k)set(j) x(k) <= J(i)set(j) y(i)*) |
1945 |
val set_Jset_incl_Jset_goalsss = |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1946 |
@{map 4} (fn dtori => fn yi => fn sets => fn Jsetsi => |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1947 |
@{map 3} (fn xk => fn set => fn Jsetsk => |
56179 | 1948 |
map2 (mk_set_Jset_incl_Jset dtori xk yi set) Jsetsk Jsetsi) |
1949 |
Jzs_copy (drop m sets) Jsetss_by_bnf) |
|
1950 |
dtors Jzs FTs_setss Jsetss_by_bnf; |
|
1951 |
in |
|
1952 |
(map2 (fn goals => fn rec_Sucs => |
|
1953 |
map2 (fn goal => fn rec_Suc => |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1954 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1955 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
56179 | 1956 |
(fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jset_defs THEN |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1957 |
mk_set_incl_Jset_tac ctxt rec_Suc)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1958 |
|> Thm.close_derivation) |
56179 | 1959 |
goals rec_Sucs) |
1960 |
set_incl_Jset_goalss col_Sucss, |
|
1961 |
map2 (fn goalss => fn rec_Sucs => |
|
1962 |
map2 (fn k => fn goals => |
|
1963 |
map2 (fn goal => fn rec_Suc => |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1964 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1965 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
56179 | 1966 |
(fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jset_defs THEN |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1967 |
mk_set_Jset_incl_Jset_tac ctxt n rec_Suc k)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
1968 |
|> Thm.close_derivation) |
56179 | 1969 |
goals rec_Sucs) |
1970 |
ks goalss) |
|
1971 |
set_Jset_incl_Jset_goalsss col_Sucss) |
|
1972 |
end; |
|
57567 | 1973 |
|
56179 | 1974 |
val set_incl_Jset_thmss' = transpose dtor_Jset_incl_thmss; |
1975 |
val set_Jset_incl_Jset_thmsss' = transpose (map transpose dtor_set_Jset_incl_thmsss); |
|
1976 |
val set_Jset_thmss = map (map (fn thm => thm RS @{thm set_mp})) dtor_Jset_incl_thmss; |
|
1977 |
val set_Jset_Jset_thmsss = map (map (map (fn thm => thm RS @{thm set_mp}))) |
|
1978 |
dtor_set_Jset_incl_thmsss; |
|
1979 |
val set_Jset_thmss' = transpose set_Jset_thmss; |
|
1980 |
val set_Jset_Jset_thmsss' = transpose (map transpose set_Jset_Jset_thmsss); |
|
57567 | 1981 |
|
56179 | 1982 |
val dtor_Jset_induct_thms = |
1983 |
let |
|
1984 |
val incls = |
|
1985 |
maps (map (fn thm => thm RS @{thm subset_Collect_iff})) dtor_Jset_incl_thmss @ |
|
1986 |
@{thms subset_Collect_iff[OF subset_refl]}; |
|
1987 |
||
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
1988 |
val cTs = map (SOME o Thm.ctyp_of lthy) params'; |
56179 | 1989 |
fun mk_induct_tinst phis jsets y y' = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1990 |
@{map 4} (fn phi => fn jset => fn Jz => fn Jz' => |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
1991 |
SOME (Thm.cterm_of lthy (Term.absfree Jz' (HOLogic.mk_Collect (fst y', snd y', |
56179 | 1992 |
HOLogic.mk_conj (HOLogic.mk_mem (y, jset $ Jz), phi $ y $ Jz)))))) |
1993 |
phis jsets Jzs Jzs'; |
|
1994 |
in |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
1995 |
@{map 6} (fn set_minimal => fn set_set_inclss => fn jsets => fn y => fn y' => fn phis => |
56179 | 1996 |
((set_minimal |
60801 | 1997 |
|> Thm.instantiate' cTs (mk_induct_tinst phis jsets y y') |
56179 | 1998 |
|> unfold_thms lthy incls) OF |
1999 |
(replicate n ballI @ |
|
2000 |
maps (map (fn thm => thm RS @{thm subset_CollectI})) set_set_inclss)) |
|
2001 |
|> singleton (Proof_Context.export names_lthy lthy) |
|
60728 | 2002 |
|> rule_by_tactic lthy (ALLGOALS (TRY o etac lthy asm_rl))) |
56179 | 2003 |
Jset_minimal_thms set_Jset_incl_Jset_thmsss' Jsetss_by_range ys ys' dtor_set_induct_phiss |
2004 |
end; |
|
2005 |
||
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2006 |
val (dtor_Jset_thmss', dtor_Jset_thmss) = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2007 |
let |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2008 |
fun mk_simp_goal relate pas_set act_sets sets dtor z set = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2009 |
relate (set $ z, mk_union (pas_set $ (dtor $ z), |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2010 |
Library.foldl1 mk_union |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2011 |
(map2 (fn X => mk_UNION (X $ (dtor $ z))) act_sets sets))); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2012 |
fun mk_goals eq = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2013 |
map2 (fn i => fn sets => |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2014 |
@{map 4} (fn Fsets => |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2015 |
mk_simp_goal eq (nth Fsets (i - 1)) (drop m Fsets) sets) |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2016 |
FTs_setss dtors Jzs sets) |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2017 |
ls Jsetss_by_range; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2018 |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
2019 |
val le_goals = map (HOLogic.mk_Trueprop o Library.foldr1 HOLogic.mk_conj) |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2020 |
(mk_goals (uncurry mk_leq)); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2021 |
val set_le_thmss = map split_conj_thm |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2022 |
(@{map 4} (fn goal => fn Jset_minimal => fn set_Jsets => fn set_Jset_Jsetss => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2023 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2024 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
60728 | 2025 |
(fn {context = ctxt, prems = _} => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2026 |
mk_set_le_tac ctxt n Jset_minimal set_Jsets set_Jset_Jsetss)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2027 |
|> Thm.close_derivation) |
56179 | 2028 |
le_goals Jset_minimal_thms set_Jset_thmss' set_Jset_Jset_thmsss'); |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2029 |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
2030 |
val ge_goalss = map (map HOLogic.mk_Trueprop) (mk_goals (uncurry mk_leq o swap)); |
57567 | 2031 |
val set_ge_thmss = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2032 |
@{map 3} (@{map 3} (fn goal => fn set_incl_Jset => fn set_Jset_incl_Jsets => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2033 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2034 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
60728 | 2035 |
(fn {context = ctxt, prems = _} => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2036 |
mk_set_ge_tac ctxt n set_incl_Jset set_Jset_incl_Jsets)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2037 |
|> Thm.close_derivation)) |
56179 | 2038 |
ge_goalss set_incl_Jset_thmss' set_Jset_incl_Jset_thmsss' |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2039 |
in |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2040 |
map2 (map2 (fn le => fn ge => equalityI OF [le, ge])) set_le_thmss set_ge_thmss |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2041 |
|> `transpose |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2042 |
end; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2043 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2044 |
val timer = time (timer "set functions for the new codatatypes"); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2045 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2046 |
val colss = map2 (fn j => fn T => |
56113 | 2047 |
map (fn i => mk_col Ts nat i j T) ks) ls passiveAs; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2048 |
val colss' = map2 (fn j => fn T => |
56113 | 2049 |
map (fn i => mk_col Ts' nat i j T) ks) ls passiveBs; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2050 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2051 |
val col_natural_thmss = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2052 |
let |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2053 |
fun mk_col_natural f map z col col' = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2054 |
HOLogic.mk_eq (mk_image f $ (col $ z), col' $ (map $ z)); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2055 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2056 |
fun mk_goal f cols cols' = list_all_free Jzs (Library.foldr1 HOLogic.mk_conj |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2057 |
(@{map 4} (mk_col_natural f) fs_Jmaps Jzs cols cols')); |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2058 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2059 |
val goals = @{map 3} mk_goal fs colss colss'; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2060 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2061 |
val ctss = |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
2062 |
map (fn phi => map (SOME o Thm.cterm_of lthy) [Term.absfree nat' phi, nat]) goals; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2063 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2064 |
val thms = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2065 |
@{map 4} (fn goal => fn cts => fn rec_0s => fn rec_Sucs => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2066 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2067 |
|> (fn vars => Goal.prove_sorry lthy vars [] (HOLogic.mk_Trueprop goal) |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
2068 |
(fn {context = ctxt, prems = _} => mk_col_natural_tac ctxt cts rec_0s rec_Sucs |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2069 |
dtor_Jmap_thms set_mapss)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2070 |
|> Thm.close_derivation) |
56113 | 2071 |
goals ctss col_0ss' col_Sucss'; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2072 |
in |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2073 |
map (split_conj_thm o mk_specN n) thms |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2074 |
end; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2075 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2076 |
val col_bd_thmss = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2077 |
let |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2078 |
fun mk_col_bd z col bd = mk_ordLeq (mk_card_of (col $ z)) bd; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2079 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2080 |
fun mk_goal bds cols = list_all_free Jzs (Library.foldr1 HOLogic.mk_conj |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2081 |
(@{map 3} mk_col_bd Jzs cols bds)); |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2082 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2083 |
val goals = map (mk_goal Jbds) colss; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2084 |
|
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
2085 |
val ctss = map (fn phi => map (SOME o Thm.cterm_of lthy) [Term.absfree nat' phi, nat]) |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2086 |
(map (mk_goal (replicate n sbd)) colss); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2087 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2088 |
val thms = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2089 |
@{map 5} (fn j => fn goal => fn cts => fn rec_0s => fn rec_Sucs => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2090 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2091 |
|> (fn vars => Goal.prove_sorry lthy vars [] (HOLogic.mk_Trueprop goal) |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
2092 |
(fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jbd_defs THEN |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2093 |
mk_col_bd_tac ctxt m j cts rec_0s rec_Sucs sbd_Card_order sbd_Cinfinite set_sbdss)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2094 |
|> Thm.close_derivation) |
56113 | 2095 |
ls goals ctss col_0ss' col_Sucss'; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2096 |
in |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2097 |
map (split_conj_thm o mk_specN n) thms |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2098 |
end; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2099 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2100 |
val map_cong0_thms = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2101 |
let |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
2102 |
val cTs = map (SOME o Thm.ctyp_of lthy o |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2103 |
Term.typ_subst_atomic (passiveAs ~~ passiveBs) o TFree) coinduct_params; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2104 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2105 |
fun mk_prem z set f g y y' = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2106 |
mk_Ball (set $ z) (Term.absfree y' (HOLogic.mk_eq (f $ y, g $ y))); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2107 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2108 |
fun mk_prems sets z = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2109 |
Library.foldr1 HOLogic.mk_conj (@{map 5} (mk_prem z) sets fs fs_copy ys ys') |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2110 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2111 |
fun mk_map_cong0 sets z fmap gmap = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2112 |
HOLogic.mk_imp (mk_prems sets z, HOLogic.mk_eq (fmap $ z, gmap $ z)); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2113 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2114 |
fun mk_coind_body sets (x, T) z fmap gmap y y_copy = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2115 |
HOLogic.mk_conj |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2116 |
(HOLogic.mk_mem (z, HOLogic.mk_Collect (x, T, mk_prems sets z)), |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2117 |
HOLogic.mk_conj (HOLogic.mk_eq (y, fmap $ z), |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2118 |
HOLogic.mk_eq (y_copy, gmap $ z))) |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2119 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2120 |
fun mk_cphi sets (z' as (x, T)) z fmap gmap y' y y'_copy y_copy = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2121 |
HOLogic.mk_exists (x, T, mk_coind_body sets z' z fmap gmap y y_copy) |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2122 |
|> Term.absfree y'_copy |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2123 |
|> Term.absfree y' |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
2124 |
|> Thm.cterm_of lthy; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2125 |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2126 |
val cphis = @{map 9} mk_cphi |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2127 |
Jsetss_by_bnf Jzs' Jzs fs_Jmaps fs_copy_Jmaps Jys' Jys Jys'_copy Jys_copy; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2128 |
|
60801 | 2129 |
val coinduct = Thm.instantiate' cTs (map SOME cphis) dtor_coinduct_thm; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2130 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2131 |
val goal = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2132 |
HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2133 |
(@{map 4} mk_map_cong0 Jsetss_by_bnf Jzs fs_Jmaps fs_copy_Jmaps)); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2134 |
val vars = Variable.add_free_names lthy goal []; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2135 |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
2136 |
val thm = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2137 |
Goal.prove_sorry lthy vars [] goal |
60728 | 2138 |
(fn {context = ctxt, prems = _} => mk_mcong_tac ctxt m (rtac ctxt coinduct) map_comps |
2139 |
dtor_Jmap_thms map_cong0s |
|
2140 |
set_mapss set_Jset_thmss set_Jset_Jset_thmsss in_rels) |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2141 |
|> Thm.close_derivation; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2142 |
in |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2143 |
split_conj_thm thm |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2144 |
end; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2145 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2146 |
val in_Jrels = map (fn def => trans OF [def, @{thm OO_Grp_alt}] RS @{thm predicate2_eqD}) |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2147 |
Jrel_unabs_defs; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2148 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2149 |
val Jrels = mk_Jrels passiveAs passiveBs; |
62324 | 2150 |
val Jpreds = mk_Jpreds passiveAs; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2151 |
val Jrelphis = map (fn rel => Term.list_comb (rel, Jphis)) Jrels; |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
2152 |
val relphis = map (fn rel => Term.list_comb (rel, Jphis @ Jrelphis)) rels; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2153 |
val Jrelpsi1s = map (fn rel => Term.list_comb (rel, Jpsi1s)) (mk_Jrels passiveAs passiveCs); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2154 |
val Jrelpsi2s = map (fn rel => Term.list_comb (rel, Jpsi2s)) (mk_Jrels passiveCs passiveBs); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2155 |
val Jrelpsi12s = map (fn rel => |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2156 |
Term.list_comb (rel, map2 (curry mk_rel_compp) Jpsi1s Jpsi2s)) Jrels; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2157 |
|
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51869
diff
changeset
|
2158 |
val dtor_Jrel_thms = |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2159 |
let |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
2160 |
fun mk_goal Jz Jz' dtor dtor' Jrelphi relphi = |
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
2161 |
mk_Trueprop_eq (Jrelphi $ Jz $ Jz', relphi $ (dtor $ Jz) $ (dtor' $ Jz')); |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2162 |
val goals = @{map 6} mk_goal Jzs Jz's dtors dtor's Jrelphis relphis; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2163 |
in |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2164 |
@{map 12} (fn i => fn goal => fn in_rel => fn map_comp0 => fn map_cong0 => |
49542
b39354db8629
renamed low-level "set_simps" and "set_induct" to have "ctor" or "dtor" in the name
blanchet
parents:
49541
diff
changeset
|
2165 |
fn dtor_map => fn dtor_sets => fn dtor_inject => fn dtor_ctor => |
53289 | 2166 |
fn set_map0s => fn dtor_set_incls => fn dtor_set_set_inclss => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2167 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2168 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
61271 | 2169 |
(fn {context = ctxt, prems = _} => |
2170 |
mk_dtor_rel_tac ctxt in_Jrels i in_rel map_comp0 map_cong0 dtor_map dtor_sets |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2171 |
dtor_inject dtor_ctor set_map0s dtor_set_incls dtor_set_set_inclss)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2172 |
|> Thm.close_derivation) |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2173 |
ks goals in_rels map_comps map_cong0s dtor_Jmap_thms dtor_Jset_thmss' |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2174 |
dtor_inject_thms dtor_ctor_thms set_mapss dtor_Jset_incl_thmss |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2175 |
dtor_set_Jset_incl_thmsss |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2176 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2177 |
|
51925 | 2178 |
val passiveABs = map2 (curry HOLogic.mk_prodT) passiveAs passiveBs; |
2179 |
val zip_ranTs = passiveABs @ prodTsTs'; |
|
2180 |
val allJphis = Jphis @ activeJphis; |
|
2181 |
val zipFTs = mk_FTs zip_ranTs; |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2182 |
val zipTs = @{map 3} (fn T => fn T' => fn FT => T --> T' --> FT) Ts Ts' zipFTs; |
51925 | 2183 |
val zip_zTs = mk_Ts passiveABs; |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2184 |
val (((zips, (abs, abs')), (zip_zs, zip_zs')), _) = |
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
2185 |
names_lthy |
51925 | 2186 |
|> mk_Frees "zip" zipTs |
2187 |
||>> mk_Frees' "ab" passiveABs |
|
55602 | 2188 |
||>> mk_Frees' "z" zip_zTs; |
51925 | 2189 |
|
2190 |
val Iphi_sets = |
|
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
61334
diff
changeset
|
2191 |
map2 (fn phi => fn T => HOLogic.Collect_const T $ HOLogic.mk_case_prod phi) allJphis zip_ranTs; |
51925 | 2192 |
val in_phis = map2 (mk_in Iphi_sets) (mk_setss zip_ranTs) zipFTs; |
2193 |
val fstABs = map fst_const passiveABs; |
|
2194 |
val all_fsts = fstABs @ fstsTsTs'; |
|
2195 |
val map_all_fsts = map2 (fn Ds => fn bnf => |
|
2196 |
Term.list_comb (mk_map_of_bnf Ds zip_ranTs (passiveAs @ Ts) bnf, all_fsts)) Dss bnfs; |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2197 |
val Jmap_fsts = map2 (fn map => fn T => if m = 0 then HOLogic.id_const T |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2198 |
else Term.list_comb (map, fstABs)) (mk_Jmaps passiveABs passiveAs) Ts; |
51925 | 2199 |
|
2200 |
val sndABs = map snd_const passiveABs; |
|
2201 |
val all_snds = sndABs @ sndsTsTs'; |
|
2202 |
val map_all_snds = map2 (fn Ds => fn bnf => |
|
2203 |
Term.list_comb (mk_map_of_bnf Ds zip_ranTs (passiveBs @ Ts') bnf, all_snds)) Dss bnfs; |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2204 |
val Jmap_snds = map2 (fn map => fn T => if m = 0 then HOLogic.id_const T |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2205 |
else Term.list_comb (map, sndABs)) (mk_Jmaps passiveABs passiveBs) Ts; |
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
61334
diff
changeset
|
2206 |
val zip_unfolds = map (mk_unfold zip_zTs (map HOLogic.mk_case_prod zips)) ks; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2207 |
val zip_setss = mk_Jsetss passiveABs |> transpose; |
51925 | 2208 |
|
55197 | 2209 |
fun Jrel_coinduct_tac {context = ctxt, prems = CIHs} = |
51925 | 2210 |
let |
2211 |
fun mk_helper_prem phi in_phi zip x y map map' dtor dtor' = |
|
2212 |
let |
|
2213 |
val zipxy = zip $ x $ y; |
|
2214 |
in |
|
2215 |
HOLogic.mk_Trueprop (list_all_free [x, y] |
|
2216 |
(HOLogic.mk_imp (phi $ x $ y, HOLogic.mk_conj (HOLogic.mk_mem (zipxy, in_phi), |
|
2217 |
HOLogic.mk_conj (HOLogic.mk_eq (map $ zipxy, dtor $ x), |
|
2218 |
HOLogic.mk_eq (map' $ zipxy, dtor' $ y)))))) |
|
2219 |
end; |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2220 |
val helper_prems = @{map 9} mk_helper_prem |
51925 | 2221 |
activeJphis in_phis zips Jzs Jz's map_all_fsts map_all_snds dtors dtor's; |
55602 | 2222 |
fun mk_helper_coind_phi fst phi x alt y map zip_unfold = |
2223 |
list_exists_free [if fst then y else x] (HOLogic.mk_conj (phi $ x $ y, |
|
2224 |
HOLogic.mk_eq (alt, map $ (zip_unfold $ HOLogic.mk_prod (x, y))))) |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2225 |
val coind1_phis = @{map 6} (mk_helper_coind_phi true) |
55602 | 2226 |
activeJphis Jzs Jzs_copy Jz's Jmap_fsts zip_unfolds; |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2227 |
val coind2_phis = @{map 6} (mk_helper_coind_phi false) |
55602 | 2228 |
activeJphis Jzs Jz's_copy Jz's Jmap_snds zip_unfolds; |
2229 |
fun mk_cts zs z's phis = |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2230 |
@{map 3} (fn z => fn z' => fn phi => |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
2231 |
SOME (Thm.cterm_of lthy (fold_rev (Term.absfree o Term.dest_Free) [z', z] phi))) |
55602 | 2232 |
zs z's phis @ |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
2233 |
map (SOME o Thm.cterm_of lthy) (splice z's zs); |
55602 | 2234 |
val cts1 = mk_cts Jzs Jzs_copy coind1_phis; |
2235 |
val cts2 = mk_cts Jz's Jz's_copy coind2_phis; |
|
2236 |
||
2237 |
fun mk_helper_coind_concl z alt coind_phi = |
|
2238 |
HOLogic.mk_imp (coind_phi, HOLogic.mk_eq (alt, z)); |
|
51925 | 2239 |
val helper_coind1_concl = |
2240 |
HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2241 |
(@{map 3} mk_helper_coind_concl Jzs Jzs_copy coind1_phis)); |
51925 | 2242 |
val helper_coind2_concl = |
2243 |
HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2244 |
(@{map 3} mk_helper_coind_concl Jz's Jz's_copy coind2_phis)); |
55602 | 2245 |
|
55644 | 2246 |
fun mk_helper_coind_thms fst concl cts = |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2247 |
let |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2248 |
val vars = fold (Variable.add_free_names lthy) (concl :: helper_prems) []; |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2249 |
in |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2250 |
Goal.prove_sorry lthy vars [] (Logic.list_implies (helper_prems, concl)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2251 |
(fn {context = ctxt, prems = _} => |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2252 |
mk_rel_coinduct_coind_tac ctxt fst m |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2253 |
(infer_instantiate' ctxt cts dtor_coinduct_thm) ks map_comps map_cong0s |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2254 |
map_arg_cong_thms set_mapss dtor_unfold_thms dtor_Jmap_thms in_rels) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2255 |
|> Thm.close_derivation |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2256 |
|> split_conj_thm |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2257 |
end; |
55602 | 2258 |
|
55644 | 2259 |
val helper_coind1_thms = mk_helper_coind_thms true helper_coind1_concl cts1; |
2260 |
val helper_coind2_thms = mk_helper_coind_thms false helper_coind2_concl cts2; |
|
55602 | 2261 |
|
2262 |
fun mk_helper_ind_phi phi ab fst snd z active_phi x y zip_unfold = |
|
2263 |
list_all_free [x, y] (HOLogic.mk_imp |
|
51925 | 2264 |
(HOLogic.mk_conj (active_phi $ x $ y, |
2265 |
HOLogic.mk_eq (z, zip_unfold $ HOLogic.mk_prod (x, y))), |
|
55602 | 2266 |
phi $ (fst $ ab) $ (snd $ ab))); |
2267 |
val helper_ind_phiss = |
|
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2268 |
@{map 4} (fn Jphi => fn ab => fn fst => fn snd => |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2269 |
@{map 5} (mk_helper_ind_phi Jphi ab fst snd) |
55602 | 2270 |
zip_zs activeJphis Jzs Jz's zip_unfolds) |
2271 |
Jphis abs fstABs sndABs; |
|
2272 |
val ctss = map2 (fn ab' => fn phis => |
|
2273 |
map2 (fn z' => fn phi => |
|
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
2274 |
SOME (Thm.cterm_of lthy (Term.absfree ab' (Term.absfree z' phi)))) |
55602 | 2275 |
zip_zs' phis @ |
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
2276 |
map (SOME o Thm.cterm_of lthy) zip_zs) |
55602 | 2277 |
abs' helper_ind_phiss; |
2278 |
fun mk_helper_ind_concl ab' z ind_phi set = |
|
2279 |
mk_Ball (set $ z) (Term.absfree ab' ind_phi); |
|
57567 | 2280 |
|
51925 | 2281 |
val mk_helper_ind_concls = |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2282 |
@{map 3} (fn ab' => fn ind_phis => fn zip_sets => |
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2283 |
@{map 3} (mk_helper_ind_concl ab') zip_zs ind_phis zip_sets) |
55602 | 2284 |
abs' helper_ind_phiss zip_setss |
51925 | 2285 |
|> map (HOLogic.mk_Trueprop o Library.foldr1 HOLogic.mk_conj); |
55602 | 2286 |
|
51925 | 2287 |
val helper_ind_thmss = if m = 0 then replicate n [] else |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2288 |
@{map 4} (fn concl => fn j => fn set_induct => fn cts => |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2289 |
fold (Variable.add_free_names lthy) (concl :: helper_prems) [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2290 |
|> (fn vars => Goal.prove_sorry lthy vars [] (Logic.list_implies (helper_prems, concl)) |
60784 | 2291 |
(fn {context = ctxt, prems = _} => |
2292 |
mk_rel_coinduct_ind_tac ctxt m ks |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2293 |
dtor_unfold_thms set_mapss j (infer_instantiate' ctxt cts set_induct))) |
51925 | 2294 |
|> Thm.close_derivation |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2295 |
|> split_conj_thm) |
55602 | 2296 |
mk_helper_ind_concls ls dtor_Jset_induct_thms ctss |
51925 | 2297 |
|> transpose; |
2298 |
in |
|
55197 | 2299 |
mk_rel_coinduct_tac ctxt CIHs in_rels in_Jrels |
52505
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
2300 |
helper_ind_thmss helper_coind1_thms helper_coind2_thms |
51925 | 2301 |
end; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2302 |
|
52505
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
2303 |
val Jrel_coinduct_thm = |
58579
b7bc5ba2f3fb
rename 'rel_xtor_co_induct_thm' to 'xtor_rel_co_induct'
desharna
parents:
58578
diff
changeset
|
2304 |
mk_xtor_rel_co_induct_thm Greatest_FP rels activeJphis Jrels Jphis Jzs Jz's dtors dtor's |
52505
e62f3fd2035e
share some code between codatatypes, datatypes and eventually prim(co)rec
traytel
parents:
52344
diff
changeset
|
2305 |
Jrel_coinduct_tac lthy; |
51925 | 2306 |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2307 |
val le_Jrel_OO_thm = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2308 |
let |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2309 |
fun mk_le_Jrel_OO Jrelpsi1 Jrelpsi2 Jrelpsi12 = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2310 |
mk_leq (mk_rel_compp (Jrelpsi1, Jrelpsi2)) Jrelpsi12; |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2311 |
val goals = @{map 3} mk_le_Jrel_OO Jrelpsi1s Jrelpsi2s Jrelpsi12s; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2312 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2313 |
val goal = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj goals); |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2314 |
val vars = Variable.add_free_names lthy goal []; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2315 |
in |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2316 |
Goal.prove_sorry lthy vars [] goal (fn {context = ctxt, prems = _} => |
60728 | 2317 |
mk_le_rel_OO_tac ctxt Jrel_coinduct_thm dtor_Jrel_thms le_rel_OOs) |
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
2318 |
|> Thm.close_derivation |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2319 |
end; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2320 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2321 |
val timer = time (timer "helpers for BNF properties"); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2322 |
|
56179 | 2323 |
fun close_wit I wit = (I, fold_rev Term.absfree (map (nth ys') I) wit); |
2324 |
||
2325 |
val all_unitTs = replicate live HOLogic.unitT; |
|
2326 |
val unitTs = replicate n HOLogic.unitT; |
|
2327 |
val unit_funs = replicate n (Term.absdummy HOLogic.unitT HOLogic.unit); |
|
2328 |
fun mk_map_args I = |
|
2329 |
map (fn i => |
|
2330 |
if member (op =) I i then Term.absdummy HOLogic.unitT (nth ys i) |
|
2331 |
else mk_undefined (HOLogic.unitT --> nth passiveAs i)) |
|
2332 |
(0 upto (m - 1)); |
|
2333 |
||
2334 |
fun mk_nat_wit Ds bnf (I, wit) () = |
|
2335 |
let |
|
2336 |
val passiveI = filter (fn i => i < m) I; |
|
2337 |
val map_args = mk_map_args passiveI; |
|
2338 |
in |
|
2339 |
Term.absdummy HOLogic.unitT (Term.list_comb |
|
2340 |
(mk_map_of_bnf Ds all_unitTs (passiveAs @ unitTs) bnf, map_args @ unit_funs) $ wit) |
|
2341 |
end; |
|
2342 |
||
2343 |
fun mk_dummy_wit Ds bnf I = |
|
2344 |
let |
|
2345 |
val map_args = mk_map_args I; |
|
2346 |
in |
|
2347 |
Term.absdummy HOLogic.unitT (Term.list_comb |
|
2348 |
(mk_map_of_bnf Ds all_unitTs (passiveAs @ unitTs) bnf, map_args @ unit_funs) $ |
|
2349 |
mk_undefined (mk_T_of_bnf Ds all_unitTs bnf)) |
|
2350 |
end; |
|
2351 |
||
2352 |
val nat_witss = |
|
2353 |
map2 (fn Ds => fn bnf => mk_wits_of_bnf (replicate (nwits_of_bnf bnf) Ds) |
|
2354 |
(replicate (nwits_of_bnf bnf) (replicate live HOLogic.unitT)) bnf |
|
2355 |
|> map (fn (I, wit) => |
|
2356 |
(I, Lazy.lazy (mk_nat_wit Ds bnf (I, Term.list_comb (wit, map (K HOLogic.unit) I)))))) |
|
2357 |
Dss bnfs; |
|
2358 |
||
2359 |
val nat_wit_thmss = map2 (curry op ~~) nat_witss (map wit_thmss_of_bnf bnfs) |
|
2360 |
||
2361 |
val Iss = map (map fst) nat_witss; |
|
2362 |
||
2363 |
fun filter_wits (I, wit) = |
|
2364 |
let val J = filter (fn i => i < m) I; |
|
2365 |
in (J, (length J < length I, wit)) end; |
|
2366 |
||
2367 |
val wit_treess = map_index (fn (i, Is) => |
|
2368 |
map_index (finish Iss m [i+m] (i+m)) Is) Iss |
|
2369 |
|> map (minimize_wits o map filter_wits o minimize_wits o flat); |
|
2370 |
||
2371 |
val coind_wit_argsss = |
|
2372 |
map (map (tree_to_coind_wits nat_wit_thmss o snd o snd) o filter (fst o snd)) wit_treess; |
|
2373 |
||
2374 |
val nonredundant_coind_wit_argsss = |
|
2375 |
fold (fn i => fn argsss => |
|
2376 |
nth_map (i - 1) (filter_out (fn xs => |
|
2377 |
exists (fn ys => |
|
2378 |
let |
|
2379 |
val xs' = (map (fst o fst) xs, snd (fst (hd xs))); |
|
2380 |
val ys' = (map (fst o fst) ys, snd (fst (hd ys))); |
|
2381 |
in |
|
2382 |
eq_pair (subset (op =)) (eq_set (op =)) (xs', ys') andalso not (fst xs' = fst ys') |
|
2383 |
end) |
|
2384 |
(flat argsss))) |
|
2385 |
argsss) |
|
2386 |
ks coind_wit_argsss; |
|
2387 |
||
2388 |
fun prepare_args args = |
|
2389 |
let |
|
2390 |
val I = snd (fst (hd args)); |
|
2391 |
val (dummys, args') = |
|
2392 |
map_split (fn i => |
|
2393 |
(case find_first (fn arg => fst (fst arg) = i - 1) args of |
|
2394 |
SOME (_, ((_, wit), thms)) => (NONE, (Lazy.force wit, thms)) |
|
2395 |
| NONE => |
|
2396 |
(SOME (i - 1), (mk_dummy_wit (nth Dss (i - 1)) (nth bnfs (i - 1)) I, [])))) |
|
2397 |
ks; |
|
2398 |
in |
|
2399 |
((I, dummys), apsnd flat (split_list args')) |
|
2400 |
end; |
|
2401 |
||
2402 |
fun mk_coind_wits ((I, dummys), (args, thms)) = |
|
2403 |
((I, dummys), (map (fn i => mk_unfold Ts args i $ HOLogic.unit) ks, thms)); |
|
2404 |
||
2405 |
val coind_witss = |
|
2406 |
maps (map (mk_coind_wits o prepare_args)) nonredundant_coind_wit_argsss; |
|
2407 |
||
2408 |
val witss = map2 (fn Ds => fn bnf => mk_wits_of_bnf |
|
2409 |
(replicate (nwits_of_bnf bnf) Ds) |
|
2410 |
(replicate (nwits_of_bnf bnf) (passiveAs @ Ts)) bnf) Dss bnfs; |
|
2411 |
||
2412 |
val ctor_witss = |
|
2413 |
map (map (uncurry close_wit o tree_to_ctor_wit ys ctors witss o snd o snd) o |
|
2414 |
filter_out (fst o snd)) wit_treess; |
|
2415 |
||
2416 |
fun mk_coind_wit_thms ((I, dummys), (wits, wit_thms)) = |
|
2417 |
let |
|
2418 |
fun mk_goal sets y y_copy y'_copy j = |
|
2419 |
let |
|
2420 |
fun mk_conjunct set z dummy wit = |
|
2421 |
mk_Ball (set $ z) (Term.absfree y'_copy |
|
2422 |
(if dummy = NONE orelse member (op =) I (j - 1) then |
|
2423 |
HOLogic.mk_imp (HOLogic.mk_eq (z, wit), |
|
2424 |
if member (op =) I (j - 1) then HOLogic.mk_eq (y_copy, y) |
|
2425 |
else @{term False}) |
|
2426 |
else @{term True})); |
|
2427 |
in |
|
56272
159c07ceb18c
prove theorems with fixed variables (export afterwards)
traytel
parents:
56179
diff
changeset
|
2428 |
HOLogic.mk_Trueprop |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2429 |
(Library.foldr1 HOLogic.mk_conj (@{map 4} mk_conjunct sets Jzs dummys wits)) |
56179 | 2430 |
end; |
58634
9f10d82e8188
added parameterized ML antiquotations @{map N}, @{fold N}, @{fold_map N}, @{split_list N};
wenzelm
parents:
58585
diff
changeset
|
2431 |
val goals = @{map 5} mk_goal Jsetss_by_range ys ys_copy ys'_copy ls; |
56179 | 2432 |
in |
2433 |
map2 (fn goal => fn induct => |
|
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2434 |
Variable.add_free_names lthy goal [] |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2435 |
|> (fn vars => Goal.prove_sorry lthy vars [] goal |
56179 | 2436 |
(fn {context = ctxt, prems = _} => mk_coind_wit_tac ctxt induct dtor_unfold_thms |
61334
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2437 |
(flat set_mapss) wit_thms)) |
8d40ddaa427f
collect the names from goals in favor of fragile exports
traytel
parents:
61272
diff
changeset
|
2438 |
|> Thm.close_derivation) |
56179 | 2439 |
goals dtor_Jset_induct_thms |
2440 |
|> map split_conj_thm |
|
2441 |
|> transpose |
|
2442 |
|> map (map_filter (try (fn thm => thm RS bspec RS mp))) |
|
2443 |
|> curry op ~~ (map_index Library.I (map (close_wit I) wits)) |
|
2444 |
|> filter (fn (_, thms) => length thms = m) |
|
2445 |
end; |
|
2446 |
||
2447 |
val coind_wit_thms = maps mk_coind_wit_thms coind_witss; |
|
2448 |
||
2449 |
val (wit_thmss, all_witss) = |
|
2450 |
fold (fn ((i, wit), thms) => fn witss => |
|
2451 |
nth_map i (fn (thms', wits) => (thms @ thms', wit :: wits)) witss) |
|
2452 |
coind_wit_thms (map (pair []) ctor_witss) |
|
2453 |
|> map (apsnd (map snd o minimize_wits)) |
|
2454 |
|> split_list; |
|
2455 |
||
2456 |
val timer = time (timer "witnesses"); |
|
2457 |
||
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2458 |
val map_id0_tacs = |
60728 | 2459 |
map2 (fn thm => fn thm' => fn ctxt => |
2460 |
mk_map_id0_tac ctxt Jmap_thms thm thm') |
|
2461 |
dtor_unfold_unique_thms unfold_dtor_thms; |
|
2462 |
val map_comp0_tacs = map (fn thm => fn ctxt => rtac ctxt (thm RS sym) 1) Jmap_comp0_thms; |
|
55197 | 2463 |
val map_cong0_tacs = map (fn thm => fn ctxt => mk_map_cong0_tac ctxt m thm) map_cong0_thms; |
2464 |
val set_map0_tacss = |
|
60728 | 2465 |
map (map (fn col => fn ctxt => |
2466 |
unfold_thms_tac ctxt Jset_defs THEN mk_set_map0_tac ctxt col)) |
|
2467 |
(transpose col_natural_thmss); |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2468 |
|
63222
fe92356ade42
eliminated pointless alias (no warning for duplicates);
wenzelm
parents:
63045
diff
changeset
|
2469 |
val Jbd_card_orders = map (fn def => Local_Defs.fold lthy [def] sbd_card_order) Jbd_defs; |
fe92356ade42
eliminated pointless alias (no warning for duplicates);
wenzelm
parents:
63045
diff
changeset
|
2470 |
val Jbd_Cinfinites = map (fn def => Local_Defs.fold lthy [def] sbd_Cinfinite) Jbd_defs; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2471 |
|
60728 | 2472 |
val bd_co_tacs = map (fn thm => fn ctxt => rtac ctxt thm 1) Jbd_card_orders; |
2473 |
val bd_cinf_tacs = map (fn thm => fn ctxt => rtac ctxt (thm RS conjunct1) 1) Jbd_Cinfinites; |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2474 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2475 |
val set_bd_tacss = |
56113 | 2476 |
map2 (fn Cinf => map (fn col => fn ctxt => |
60728 | 2477 |
unfold_thms_tac ctxt Jset_defs THEN mk_set_bd_tac ctxt Cinf col)) |
56113 | 2478 |
Jbd_Cinfinites (transpose col_bd_thmss); |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2479 |
|
60728 | 2480 |
val le_rel_OO_tacs = map (fn i => fn ctxt => |
2481 |
rtac ctxt (le_Jrel_OO_thm RS mk_conjunctN n i) 1) ks; |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2482 |
|
60728 | 2483 |
val rel_OO_Grp_tacs = map (fn def => fn ctxt => rtac ctxt def 1) Jrel_unabs_defs; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2484 |
|
62324 | 2485 |
val pred_set_tacs = map (fn def => fn ctxt => rtac ctxt def 1) Jpred_unabs_defs; |
2486 |
||
2487 |
val tacss = @{map 10} zip_axioms map_id0_tacs map_comp0_tacs map_cong0_tacs set_map0_tacss |
|
2488 |
bd_co_tacs bd_cinf_tacs set_bd_tacss le_rel_OO_tacs rel_OO_Grp_tacs pred_set_tacs; |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2489 |
|
56179 | 2490 |
fun wit_tac thms ctxt = |
55197 | 2491 |
mk_wit_tac ctxt n dtor_ctor_thms (flat dtor_Jset_thmss) (maps wit_thms_of_bnf bnfs) thms; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2492 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2493 |
val (Jbnfs, lthy) = |
62324 | 2494 |
@{fold_map 7} (fn tacs => fn map_b => fn rel_b => fn pred_b => fn set_bs => fn wit_thms => |
56348 | 2495 |
fn consts => |
56179 | 2496 |
bnf_def Hardly_Inline (user_policy Note_Some) false I tacs (wit_tac wit_thms) |
62324 | 2497 |
(SOME deads) map_b rel_b pred_b set_bs consts) |
2498 |
tacss map_bs rel_bs pred_bs set_bss wit_thmss |
|
2499 |
(((((((replicate n Binding.empty ~~ Ts) ~~ Jmaps) ~~ Jsetss_by_bnf) ~~ Jbds) ~~ |
|
2500 |
all_witss) ~~ map SOME Jrels) ~~ map SOME Jpreds) |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2501 |
lthy; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2502 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2503 |
val timer = time (timer "registered new codatatypes as BNFs"); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2504 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2505 |
val ls' = if m = 1 then [0] else ls; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2506 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2507 |
val Jbnf_common_notes = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2508 |
map2 (fn i => fn thm => (mk_dtor_set_inductN i, [thm])) ls' dtor_Jset_induct_thms |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2509 |
|> map (fn (thmN, thms) => |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2510 |
((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])])); |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2511 |
|
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2512 |
val Jbnf_notes = |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2513 |
[(dtor_mapN, map single dtor_Jmap_thms), |
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
2514 |
(dtor_map_uniqueN, map single dtor_Jmap_unique_thms), |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2515 |
(dtor_relN, map single dtor_Jrel_thms), |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2516 |
(dtor_set_inclN, dtor_Jset_incl_thmss), |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2517 |
(dtor_set_set_inclN, map flat dtor_set_Jset_incl_thmsss)] @ |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2518 |
map2 (fn i => fn thms => (mk_dtor_setN i, map single thms)) ls' dtor_Jset_thmss |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2519 |
|> maps (fn (thmN, thmss) => |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2520 |
map2 (fn b => fn thms => |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2521 |
((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])])) |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2522 |
bs thmss) |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2523 |
in |
62863
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
2524 |
(timer, Jbnfs, (Jmap_thms, dtor_Jmap_thms), dtor_Jmap_unique_thm, dtor_Jset_thmss', |
57700 | 2525 |
dtor_Jrel_thms, Jrel_coinduct_thm, Jbnf_common_notes @ Jbnf_notes, dtor_Jset_induct_thms, |
2526 |
lthy) |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2527 |
end; |
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2528 |
|
61272
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
2529 |
val ((Jphis, activephis), _) = |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
2530 |
lthy |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
2531 |
|> mk_Frees "R" JphiTs |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
2532 |
||>> mk_Frees "S" activephiTs; |
f49644098959
restructure fresh variable generation to make exports more wellformed
traytel
parents:
61271
diff
changeset
|
2533 |
|
62827 | 2534 |
val dtor_unfold_o_Jmap_thms = mk_xtor_co_iter_o_map_thms Greatest_FP false m |
64413 | 2535 |
dtor_unfold_unique_thm dtor_Jmap_o_thms (map (mk_pointfree2 lthy) dtor_unfold_thms) |
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2536 |
sym_map_comps map_cong0s; |
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2537 |
|
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2538 |
val rels = map2 (fn Ds => mk_rel_of_bnf Ds allAs allBs') Dss bnfs; |
58443 | 2539 |
val Jrels = if m = 0 then map HOLogic.eq_const Ts |
2540 |
else map (mk_rel_of_bnf deads passiveAs passiveBs) Jbnfs; |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54793
diff
changeset
|
2541 |
|
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2542 |
val dtor_unfold_transfer_thms = |
62827 | 2543 |
mk_xtor_co_iter_transfer_thms Greatest_FP rels activephis activephis Jrels Jphis |
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2544 |
(mk_unfolds passiveAs activeAs) (mk_unfolds passiveBs activeBs) |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2545 |
(fn {context = ctxt, prems = _} => mk_unfold_transfer_tac ctxt m Jrel_coinduct_thm |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2546 |
(map map_transfer_of_bnf bnfs) dtor_unfold_thms) |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2547 |
lthy; |
52731 | 2548 |
|
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2549 |
val timer = time (timer "relator coinduction"); |
51925 | 2550 |
|
62905 | 2551 |
fun mk_Ts As = map (typ_subst_atomic (passiveAs ~~ As)) Ts; |
2552 |
val export = map (Morphism.term (Local_Theory.target_morphism lthy)) |
|
2553 |
val ((corecs, (dtor_corec_thms, dtor_corec_unique_thm, dtor_corec_o_Jmap_thms, |
|
2554 |
dtor_corec_transfer_thms)), lthy) = lthy |
|
2555 |
|> derive_xtor_co_recs Greatest_FP external_bs mk_Ts (Dss, resDs) bnfs |
|
2556 |
(export dtors) (export unfolds) |
|
2557 |
dtor_unfold_unique_thm dtor_unfold_thms dtor_unfold_transfer_thms |
|
63045 | 2558 |
dtor_Jmap_thms dtor_Jrel_thms (replicate n NONE); |
62905 | 2559 |
|
2560 |
val timer = time (timer "recursor"); |
|
2561 |
||
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2562 |
val common_notes = |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2563 |
[(dtor_coinductN, [dtor_coinduct_thm]), |
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
2564 |
(dtor_rel_coinductN, [Jrel_coinduct_thm])] |
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2565 |
|> map (fn (thmN, thms) => |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2566 |
((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])])); |
49109
0e5b859e1c91
no more aliases for Local_Theory.note; use Thm.close_derivation in internal theorems;
traytel
parents:
49105
diff
changeset
|
2567 |
|
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2568 |
val notes = |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2569 |
[(ctor_dtorN, ctor_dtor_thms), |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2570 |
(ctor_exhaustN, ctor_exhaust_thms), |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2571 |
(ctor_injectN, ctor_inject_thms), |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2572 |
(dtor_ctorN, dtor_ctor_thms), |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2573 |
(dtor_exhaustN, dtor_exhaust_thms), |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2574 |
(dtor_injectN, dtor_inject_thms), |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2575 |
(dtor_unfoldN, dtor_unfold_thms), |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2576 |
(dtor_unfold_o_mapN, dtor_unfold_o_Jmap_thms), |
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
2577 |
(dtor_unfold_transferN, dtor_unfold_transfer_thms), |
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
2578 |
(dtor_unfold_uniqueN, dtor_unfold_unique_thms)] |
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2579 |
|> map (apsnd (map single)) |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2580 |
|> maps (fn (thmN, thmss) => |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2581 |
map2 (fn b => fn thms => |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2582 |
((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])])) |
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2583 |
bs thmss); |
53568
f9456284048f
conceal low-level noted facts (+ FIXME to get rid of the notes altogether eventually)
traytel
parents:
53567
diff
changeset
|
2584 |
|
62093 | 2585 |
val lthy' = lthy |> internals ? snd o Local_Theory.notes (common_notes @ notes @ Jbnf_notes); |
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2586 |
|
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2587 |
val fp_res = |
62684
cb20e8828196
document that n2m does not depend on most things in fp_sugar in its type
traytel
parents:
62324
diff
changeset
|
2588 |
{Ts = Ts, bnfs = Jbnfs, pre_bnfs = bnfs, absT_infos = absT_infos, |
62907 | 2589 |
ctors = ctors, dtors = dtors, xtor_un_folds = unfolds, xtor_co_recs = export corecs, |
62684
cb20e8828196
document that n2m does not depend on most things in fp_sugar in its type
traytel
parents:
62324
diff
changeset
|
2590 |
xtor_co_induct = dtor_coinduct_thm, dtor_ctors = dtor_ctor_thms, ctor_dtors = ctor_dtor_thms, |
cb20e8828196
document that n2m does not depend on most things in fp_sugar in its type
traytel
parents:
62324
diff
changeset
|
2591 |
ctor_injects = ctor_inject_thms, dtor_injects = dtor_inject_thms, xtor_maps = dtor_Jmap_thms, |
62863
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
2592 |
xtor_map_unique = dtor_Jmap_unique_thm, xtor_setss = dtor_Jset_thmss', |
62907 | 2593 |
xtor_rels = dtor_Jrel_thms, xtor_un_fold_thms = dtor_unfold_thms, |
2594 |
xtor_co_rec_thms = dtor_corec_thms, xtor_un_fold_unique = dtor_unfold_unique_thm, |
|
62863
e0b894bba6ff
single uniqueness theorems for map, (un)fold, (co)rec for mutual (co)datatypes
traytel
parents:
62827
diff
changeset
|
2595 |
xtor_co_rec_unique = dtor_corec_unique_thm, |
62907 | 2596 |
xtor_un_fold_o_maps = dtor_unfold_o_Jmap_thms, |
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
2597 |
xtor_co_rec_o_maps = dtor_corec_o_Jmap_thms, |
62907 | 2598 |
xtor_un_fold_transfers = dtor_unfold_transfer_thms, |
59856
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
2599 |
xtor_co_rec_transfers = dtor_corec_transfer_thms, xtor_rel_co_induct = Jrel_coinduct_thm, |
ed0ca9029021
export more low-level theorems in data structure (partly for 'corec')
blanchet
parents:
59819
diff
changeset
|
2600 |
dtor_set_inducts = dtor_Jset_induct_thms}; |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2601 |
in |
57631
959caab43a3d
use the noted theorem whenever possible, also in 'BNF_Def'
blanchet
parents:
57567
diff
changeset
|
2602 |
timer; (fp_res, lthy') |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2603 |
end; |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2604 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2605 |
val _ = |
59936
b8ffc3dc9e24
@{command_spec} is superseded by @{command_keyword};
wenzelm
parents:
59860
diff
changeset
|
2606 |
Outer_Syntax.local_theory @{command_keyword codatatype} "define coinductive datatypes" |
52207
21026c312cc3
tuning -- avoided unreadable true/false all over the place for LFP/GFP
blanchet
parents:
52090
diff
changeset
|
2607 |
(parse_co_datatype_cmd Greatest_FP construct_gfp); |
49308
6190b701e4f4
reorganized dependencies so that the sugar does not depend on GFP -- this will be essential for bootstrapping
blanchet
parents:
49277
diff
changeset
|
2608 |
|
58256
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58241
diff
changeset
|
2609 |
val _ = Theory.setup (fp_antiquote_setup @{binding codatatype}); |
08c0f0d4b9f4
generalized 'datatype' LaTeX antiquotation and added 'codatatype'
blanchet
parents:
58241
diff
changeset
|
2610 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2611 |
end; |