@@ -13,25 +13,6 @@ type spec = {
1313 FVars_bs: binding option list
1414};
1515
16- type binder_sugar = {
17- map_simps: thm list,
18- set_simpss: thm list list,
19- permute_simps: thm list,
20- map_permute: thm option,
21- subst_simps: thm list option,
22- IImsupp_permute_commutes: thm list option,
23- IImsupp_Diffs: thm list option,
24- bsetss: term option list list,
25- bset_bounds: thm list,
26- mrbnf: MRBNF_Def.mrbnf,
27- strong_induct: thm option,
28- distinct: thm list,
29- inject: thm list,
30- ctors: (term * thm) list
31- };
32-
33- val morph_binder_sugar: morphism -> binder_sugar -> binder_sugar;
34-
3516type mr_bnf = (MRBNF_Def.mrbnf, (BNF_Def.bnf, MRBNF_FP_Def_Sugar.quotient_result MRBNF_FP_Def_Sugar.fp_result_T) MRBNF_Util.either) MRBNF_Util.either
3617
3718val mr_bnf_of: local_theory -> bool -> string -> mr_bnf option;
@@ -41,7 +22,7 @@ val build_permute_for: Proof.context -> term list -> typ list -> typ -> (string
4122val create_binder_type : MRBNF_Util.fp_kind -> spec -> local_theory
4223 -> (MRBNF_FP_Def_Sugar.fp_result * typ * MRSBNF_Def.mrsbnf * MRBNF_Comp.absT_info) * local_theory
4324
44- val create_binder_datatype : bool -> spec -> local_theory -> binder_sugar * local_theory
25+ val create_binder_datatype : bool -> spec -> local_theory -> Binder_Sugar. binder_sugar * local_theory
4526end
4627
4728structure MRBNF_Sugar : MRBNF_SUGAR =
@@ -66,57 +47,6 @@ type spec = {
6647 FVars_bs: binding option list
6748};
6849
69- type binder_sugar = {
70- map_simps: thm list,
71- set_simpss: thm list list,
72- permute_simps: thm list,
73- map_permute: thm option,
74- subst_simps: thm list option,
75- IImsupp_permute_commutes: thm list option,
76- IImsupp_Diffs: thm list option,
77- bsetss: term option list list,
78- bset_bounds: thm list,
79- mrbnf: MRBNF_Def.mrbnf,
80- strong_induct: thm option,
81- distinct: thm list,
82- inject: thm list,
83- ctors: (term * thm) list
84- };
85-
86- fun morph_binder_sugar phi { map_simps, permute_simps, map_permute, set_simpss, subst_simps, mrbnf,
87- strong_induct, distinct, inject, ctors, bsetss, bset_bounds, IImsupp_permute_commutes, IImsupp_Diffs } = {
88- map_simps = map (Morphism.thm phi) map_simps,
89- permute_simps = map (Morphism.thm phi) permute_simps,
90- map_permute = Option.map (Morphism.thm phi) map_permute,
91- set_simpss = map (map (Morphism.thm phi)) set_simpss,
92- subst_simps = Option.map (map (Morphism.thm phi)) subst_simps,
93- IImsupp_permute_commutes = Option.map (map (Morphism.thm phi)) IImsupp_permute_commutes,
94- IImsupp_Diffs = Option.map (map (Morphism.thm phi)) IImsupp_Diffs,
95- bsetss = map (map (Option.map (Morphism.term phi))) bsetss,
96- bset_bounds = map (Morphism.thm phi) bset_bounds,
97- mrbnf = MRBNF_Def.morph_mrbnf phi mrbnf,
98- strong_induct = Option.map (Morphism.thm phi) strong_induct,
99- distinct = map (Morphism.thm phi) distinct,
100- inject = map (Morphism.thm phi) inject,
101- ctors = map (map_prod (Morphism.term phi) (Morphism.thm phi)) ctors
102- } : binder_sugar;
103-
104- structure Data = Generic_Data (
105- type T = binder_sugar Symtab.table;
106- val empty = Symtab.empty;
107- fun merge data : T = Symtab.merge (K true ) data;
108- );
109-
110- fun register_binder_sugar name sugar =
111- Local_Theory.declaration {syntax = false , pervasive = true , pos = Position.none}
112- (fn phi => Data.map (Symtab.update (name, morph_binder_sugar phi sugar)));
113-
114- fun binder_sugar_of_generic context =
115- Option.map (morph_binder_sugar (Morphism.transfer_morphism (Context.theory_of context)))
116- o Symtab.lookup (Data.get context);
117-
118- val binder_sugar_of = binder_sugar_of_generic o Context.Proof;
119-
12050fun add_nesting_mrbnf_names Us =
12151 let
12252 fun add (Type (s, Ts)) ss =
@@ -963,9 +893,12 @@ fun create_binder_datatype co (spec : spec) lthy =
963893 eta_compl_free = eta_compl_free_tac,
964894 eta_natural = eta_natural_tac
965895 };
966- val eta_models = map (fn a => Option.map (fn { eta, Inj } => { eta = eta, Inj = Inj, tacs = tvsubst_axioms }) (
967- List.find (fn { eta, ...} => domain_type (fastype_of eta) = a) etas
968- )) vars;
896+ val tvsubst_model = {
897+ binding = #tvsubst_b spec,
898+ etas = map (fn a => Option.map (fn { Inj, eta } => { Inj = Inj, eta = eta, tacs = tvsubst_axioms }) (
899+ List.find (fn t => domain_type (fastype_of (#eta t)) = a) etas
900+ )) vars
901+ };
969902
970903 val thms = @{thms prod.set_map sum.set_map prod_set_simps sum_set_simps UN_empty UN_empty2
971904 Un_empty_left Un_empty_right UN_singleton comp_def map_sum.simps map_prod_simp
@@ -1177,7 +1110,7 @@ fun create_binder_datatype co (spec : spec) lthy =
11771110 REPEAT_DETERM o resolve_tac ctxt prems,
11781111 REPEAT_DETERM o EVERY' [
11791112 EqSubst.eqsubst_tac ctxt [0 ] (map (the o #map_permute) nesting_binder_sugars),
1180- REPEAT_DETERM o resolve_tac ctxt prems
1113+ REPEAT_DETERM o resolve_tac ctxt prems
11811114 ],
11821115 K (Local_Defs.unfold0_tac ctxt @{thms id_apply}),
11831116 rtac ctxt refl
@@ -1189,8 +1122,12 @@ fun create_binder_datatype co (spec : spec) lthy =
11891122 val (lthy, tvsubst_opt) = if not (null (map_filter I (#etas tvsubst_model))) andalso not co then
11901123 let
11911124 val recursor_result = #recursor_result (the vvsubst_res_opt);
1125+ val rec_mrbnf = #rec_mrbnf (the vvsubst_res_opt);
1126+ val vvsubst_res = #vvsubst_res (the vvsubst_res_opt);
1127+
11921128 val (tvsubst_res, lthy) = TVSubst.create_tvsubst_of_mrsbnf (Binding.prefix_name " tv" ) res mrsbnf
1193- rec_mrbnf (#vvsubst_ctor vvsubst_res) (#vvsubst_permute vvsubst_res) (#tvsubst_b spec) eta_models (#QREC_fixed recursor_result) lthy;
1129+ rec_mrbnf (#vvsubst_ctor vvsubst_res) (#vvsubst_permute vvsubst_res) (#tvsubst_b spec)
1130+ (#etas tvsubst_model) (#QREC_fixed recursor_result) lthy;
11941131
11951132 val lthy = BMV_Monad_Def.register_pbmv_monad (fst (dest_Type qT))
11961133 (MRSBNF_Def.bmv_monad_of_mrsbnf (#mrsbnf tvsubst_res)) lthy;
@@ -1240,7 +1177,7 @@ fun create_binder_datatype co (spec : spec) lthy =
12401177
12411178 val bmv_unfolds = maps BMV_Monad_Def.unfolds_of_bmv_monad bmvs;
12421179 fun tac ctxt prems = EVERY1 [
1243- K (Local_Defs.unfold0_tac ctxt (map (Thm.symmetric o snd) (map_filter (Option.map #Inj) eta_models ))),
1180+ K (Local_Defs.unfold0_tac ctxt (map (Thm.symmetric o snd) (map_filter (Option.map #Inj) (#etas tvsubst_model) ))),
12441181 EVERY' [
12451182 resolve_tac ctxt (#tvsubst_Injs tvsubst_res),
12461183 REPEAT_DETERM o resolve_tac ctxt prems
@@ -1297,18 +1234,17 @@ fun create_binder_datatype co (spec : spec) lthy =
12971234 val induct_attrib = Attrib.internal Position.none (K (Induct.induct_type (fst (dest_Type qT))))
12981235 val equiv = @{attributes [simp, equiv]}
12991236
1300- (* fun unfold_tvsubst res = map_filter (Option. map (
1237+ val unfold_tvsubst = map (
13011238 Local_Defs.unfold lthy (
13021239 @{thms SSupp_def[symmetric, THEN meta_eq_to_obj_eq, THEN fun_cong]}
13031240 @ map (Thm.symmetric o snd) ctors
13041241 @ [@{lemma " \< Union>((Vrs \< circ> \< rho>) ` SSupp Inj \< rho>) = IImsupp Inj Vrs \< rho>"
13051242 by (auto simp: IImsupp_def)}]
13061243 )
1307- ));*)
1308- <<<<<<< HEAD
1244+ );
13091245
1310- val IImsupp_permute_commutes = Option.map (fn (res, _) => unfold_tvsubst res (#IImsupp_permute_commutes res)) tvsubst_opt;
1311- val IImsupp_Diffs = Option.map (fn (res, _) => unfold_tvsubst res (#IImsupp_Diffs res)) tvsubst_opt;
1246+ val IImsupp_permute_commutes = Option.map (fn (res, _) => unfold_tvsubst (#IImsupp_permute_commutes res)) tvsubst_opt;
1247+ val IImsupp_Diffs = Option.map (fn (res, _) => unfold_tvsubst (#IImsupp_Diffs res)) tvsubst_opt;
13121248
13131249 val (sugar, lthy) = if co then
13141250 let
@@ -1329,7 +1265,7 @@ fun create_binder_datatype co (spec : spec) lthy =
13291265 distinct = [],
13301266 inject = [],
13311267 ctors = []
1332- } : binder_sugar;
1268+ } : Binder_Sugar. binder_sugar;
13331269 in (sugar, lthy) end
13341270 else
13351271 let
@@ -1349,7 +1285,7 @@ fun create_binder_datatype co (spec : spec) lthy =
13491285 distinct = distinct,
13501286 inject = injects,
13511287 ctors = ctors
1352- } : binder_sugar;
1288+ } : Binder_Sugar. binder_sugar;
13531289 in (sugar, lthy) end
13541290
13551291 val lthy = Binder_Sugar.register_binder_sugar (fst (dest_Type qT)) sugar lthy;
0 commit comments