equal
deleted
inserted
replaced
40 val b_names = map Binding.name_of bs; |
40 val b_names = map Binding.name_of bs; |
41 val b_name = mk_common_name b_names; |
41 val b_name = mk_common_name b_names; |
42 val b = Binding.name b_name; |
42 val b = Binding.name b_name; |
43 |
43 |
44 fun mk_internal_of_b name = |
44 fun mk_internal_of_b name = |
45 Binding.prefix_name (name ^ "_") #> Binding.prefix true b_name #> Binding.conceal; |
45 Binding.prefix_name (name ^ "_") #> Binding.prefix true b_name #> Binding.concealed; |
46 fun mk_internal_b name = mk_internal_of_b name b; |
46 fun mk_internal_b name = mk_internal_of_b name b; |
47 fun mk_internal_bs name = map (mk_internal_of_b name) bs; |
47 fun mk_internal_bs name = map (mk_internal_of_b name) bs; |
48 val external_bs = map2 (Binding.prefix false) b_names bs |
48 val external_bs = map2 (Binding.prefix false) b_names bs |
49 |> not note_all ? map Binding.conceal; |
49 |> not note_all ? map Binding.concealed; |
50 |
50 |
51 val deads = fold (union (op =)) Dss resDs; |
51 val deads = fold (union (op =)) Dss resDs; |
52 val names_lthy = fold Variable.declare_typ deads lthy; |
52 val names_lthy = fold Variable.declare_typ deads lthy; |
53 val passives = map fst (subtract (op = o apsnd TFree) deads resBs); |
53 val passives = map fst (subtract (op = o apsnd TFree) deads resBs); |
54 |
54 |
909 val Izs = map2 retype_const_or_free Ts zs; |
909 val Izs = map2 retype_const_or_free Ts zs; |
910 val phis = map2 retype_const_or_free (map mk_pred1T Ts) init_phis; |
910 val phis = map2 retype_const_or_free (map mk_pred1T Ts) init_phis; |
911 val phi2s = map2 retype_const_or_free (map2 mk_pred2T Ts Ts') init_phis; |
911 val phi2s = map2 retype_const_or_free (map2 mk_pred2T Ts Ts') init_phis; |
912 |
912 |
913 fun ctor_bind i = nth external_bs (i - 1) |> Binding.prefix_name (ctorN ^ "_"); |
913 fun ctor_bind i = nth external_bs (i - 1) |> Binding.prefix_name (ctorN ^ "_"); |
914 val ctor_def_bind = rpair [] o Binding.conceal o Thm.def_binding o ctor_bind; |
914 val ctor_def_bind = rpair [] o Binding.concealed o Thm.def_binding o ctor_bind; |
915 |
915 |
916 fun ctor_spec abs str map_FT_init = |
916 fun ctor_spec abs str map_FT_init = |
917 Library.foldl1 HOLogic.mk_comp [abs, str, |
917 Library.foldl1 HOLogic.mk_comp [abs, str, |
918 Term.list_comb (map_FT_init, map HOLogic.id_const passiveAs @ Rep_Ts)]; |
918 Term.list_comb (map_FT_init, map HOLogic.id_const passiveAs @ Rep_Ts)]; |
919 |
919 |
963 val fold_fun = Term.absfree fold_f' |
963 val fold_fun = Term.absfree fold_f' |
964 (mk_mor UNIVs ctors active_UNIVs ss (map (mk_nthN n fold_f) ks)); |
964 (mk_mor UNIVs ctors active_UNIVs ss (map (mk_nthN n fold_f) ks)); |
965 val foldx = HOLogic.choice_const foldT $ fold_fun; |
965 val foldx = HOLogic.choice_const foldT $ fold_fun; |
966 |
966 |
967 fun fold_bind i = nth external_bs (i - 1) |> Binding.prefix_name (ctor_foldN ^ "_"); |
967 fun fold_bind i = nth external_bs (i - 1) |> Binding.prefix_name (ctor_foldN ^ "_"); |
968 val fold_def_bind = rpair [] o Binding.conceal o Thm.def_binding o fold_bind; |
968 val fold_def_bind = rpair [] o Binding.concealed o Thm.def_binding o fold_bind; |
969 |
969 |
970 fun fold_spec i = fold_rev (Term.absfree o Term.dest_Free) ss (mk_nthN n foldx i); |
970 fun fold_spec i = fold_rev (Term.absfree o Term.dest_Free) ss (mk_nthN n foldx i); |
971 |
971 |
972 val ((fold_frees, (_, fold_def_frees)), (lthy, lthy_old)) = |
972 val ((fold_frees, (_, fold_def_frees)), (lthy, lthy_old)) = |
973 lthy |
973 lthy |
1070 val map_ctors = map2 (fn Ds => fn bnf => |
1070 val map_ctors = map2 (fn Ds => fn bnf => |
1071 Term.list_comb (mk_map_of_bnf Ds (passiveAs @ FTs) (passiveAs @ Ts) bnf, |
1071 Term.list_comb (mk_map_of_bnf Ds (passiveAs @ FTs) (passiveAs @ Ts) bnf, |
1072 map HOLogic.id_const passiveAs @ ctors)) Dss bnfs; |
1072 map HOLogic.id_const passiveAs @ ctors)) Dss bnfs; |
1073 |
1073 |
1074 fun dtor_bind i = nth external_bs (i - 1) |> Binding.prefix_name (dtorN ^ "_"); |
1074 fun dtor_bind i = nth external_bs (i - 1) |> Binding.prefix_name (dtorN ^ "_"); |
1075 val dtor_def_bind = rpair [] o Binding.conceal o Thm.def_binding o dtor_bind; |
1075 val dtor_def_bind = rpair [] o Binding.concealed o Thm.def_binding o dtor_bind; |
1076 |
1076 |
1077 fun dtor_spec i = mk_fold Ts map_ctors i; |
1077 fun dtor_spec i = mk_fold Ts map_ctors i; |
1078 |
1078 |
1079 val ((dtor_frees, (_, dtor_def_frees)), (lthy, lthy_old)) = |
1079 val ((dtor_frees, (_, dtor_def_frees)), (lthy, lthy_old)) = |
1080 lthy |
1080 lthy |
1133 map2 (fn unique => fn fold_ctor => |
1133 map2 (fn unique => fn fold_ctor => |
1134 trans OF [mor RS unique, fold_ctor]) fold_unique_mor_thms fold_ctor_thms |
1134 trans OF [mor RS unique, fold_ctor]) fold_unique_mor_thms fold_ctor_thms |
1135 end; |
1135 end; |
1136 |
1136 |
1137 fun rec_bind i = nth external_bs (i - 1) |> Binding.prefix_name (ctor_recN ^ "_"); |
1137 fun rec_bind i = nth external_bs (i - 1) |> Binding.prefix_name (ctor_recN ^ "_"); |
1138 val rec_def_bind = rpair [] o Binding.conceal o Thm.def_binding o rec_bind; |
1138 val rec_def_bind = rpair [] o Binding.concealed o Thm.def_binding o rec_bind; |
1139 |
1139 |
1140 val rec_strs = |
1140 val rec_strs = |
1141 @{map 3} (fn ctor => fn prod_s => fn mapx => |
1141 @{map 3} (fn ctor => fn prod_s => fn mapx => |
1142 mk_convol (HOLogic.mk_comp (ctor, Term.list_comb (mapx, passive_ids @ rec_fsts)), prod_s)) |
1142 mk_convol (HOLogic.mk_comp (ctor, Term.list_comb (mapx, passive_ids @ rec_fsts)), prod_s)) |
1143 ctors rec_ss rec_maps; |
1143 ctors rec_ss rec_maps; |