2101 val rels = map2 (fn Ds => mk_rel_of_bnf Ds (passiveAs @ Ts) (passiveBs @ Ts')) Dss bnfs; |
2101 val rels = map2 (fn Ds => mk_rel_of_bnf Ds (passiveAs @ Ts) (passiveBs @ Ts')) Dss bnfs; |
2102 val in_rels = map in_rel_of_bnf bnfs; |
2102 val in_rels = map in_rel_of_bnf bnfs; |
2103 |
2103 |
2104 (*register new codatatypes as BNFs*) |
2104 (*register new codatatypes as BNFs*) |
2105 val (timer, Jbnfs, (folded_dtor_map_o_thms, folded_dtor_map_thms), folded_dtor_set_thmss', |
2105 val (timer, Jbnfs, (folded_dtor_map_o_thms, folded_dtor_map_thms), folded_dtor_set_thmss', |
2106 dtor_set_induct_thms, dtor_Jrel_thms, lthy) = |
2106 dtor_set_induct_thms, dtor_Jrel_thms, Jbnf_notes, lthy) = |
2107 if m = 0 then |
2107 if m = 0 then |
2108 (timer, replicate n DEADID_bnf, |
2108 (timer, replicate n DEADID_bnf, |
2109 map_split (`(mk_pointfree lthy)) (map2 mk_dtor_map_DEADID_thm dtor_inject_thms map_ids), |
2109 map_split (`(mk_pointfree lthy)) (map2 mk_dtor_map_DEADID_thm dtor_inject_thms map_ids), |
2110 replicate n [], [], map2 mk_dtor_Jrel_DEADID_thm dtor_inject_thms bnfs, lthy) |
2110 replicate n [], [], map2 mk_dtor_Jrel_DEADID_thm dtor_inject_thms bnfs, [], lthy) |
2111 else let |
2111 else let |
2112 val fTs = map2 (curry op -->) passiveAs passiveBs; |
2112 val fTs = map2 (curry op -->) passiveAs passiveBs; |
2113 val gTs = map2 (curry op -->) passiveBs passiveCs; |
2113 val gTs = map2 (curry op -->) passiveBs passiveCs; |
2114 val f1Ts = map2 (curry op -->) passiveAs passiveYs; |
2114 val f1Ts = map2 (curry op -->) passiveAs passiveYs; |
2115 val f2Ts = map2 (curry op -->) passiveBs passiveYs; |
2115 val f2Ts = map2 (curry op -->) passiveBs passiveYs; |
2739 map2 (fn b => fn thms => |
2739 map2 (fn b => fn thms => |
2740 ((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])])) |
2740 ((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])])) |
2741 bs thmss) |
2741 bs thmss) |
2742 in |
2742 in |
2743 (timer, Jbnfs, (folded_dtor_map_o_thms, folded_dtor_map_thms), folded_dtor_set_thmss', |
2743 (timer, Jbnfs, (folded_dtor_map_o_thms, folded_dtor_map_thms), folded_dtor_set_thmss', |
2744 dtor_set_induct_thms, dtor_Jrel_thms, |
2744 dtor_set_induct_thms, dtor_Jrel_thms, Jbnf_common_notes @ Jbnf_notes, lthy) |
2745 lthy |> Local_Theory.notes (Jbnf_common_notes @ Jbnf_notes) |> snd) |
|
2746 end; |
2745 end; |
2747 |
2746 |
2748 val dtor_unfold_o_map_thms = mk_xtor_un_fold_o_map_thms Greatest_FP false m |
2747 val dtor_unfold_o_map_thms = mk_xtor_un_fold_o_map_thms Greatest_FP false m |
2749 dtor_unfold_unique_thm folded_dtor_map_o_thms (map (mk_pointfree lthy) dtor_unfold_thms) |
2748 dtor_unfold_unique_thm folded_dtor_map_o_thms (map (mk_pointfree lthy) dtor_unfold_thms) |
2750 sym_map_comps map_cong0s; |
2749 sym_map_comps map_cong0s; |
2901 xtor_map_thms = folded_dtor_map_thms, xtor_set_thmss = folded_dtor_set_thmss', |
2900 xtor_map_thms = folded_dtor_map_thms, xtor_set_thmss = folded_dtor_set_thmss', |
2902 xtor_rel_thms = dtor_Jrel_thms, |
2901 xtor_rel_thms = dtor_Jrel_thms, |
2903 xtor_co_iter_thmss = transpose [dtor_unfold_thms, dtor_corec_thms], |
2902 xtor_co_iter_thmss = transpose [dtor_unfold_thms, dtor_corec_thms], |
2904 xtor_co_iter_o_map_thmss = transpose [dtor_unfold_o_map_thms, dtor_corec_o_map_thms], |
2903 xtor_co_iter_o_map_thmss = transpose [dtor_unfold_o_map_thms, dtor_corec_o_map_thms], |
2905 rel_xtor_co_induct_thm = Jrel_coinduct_thm}, |
2904 rel_xtor_co_induct_thm = Jrel_coinduct_thm}, |
2906 lthy |> Local_Theory.notes (common_notes @ notes) |> snd) |
2905 lthy |> Local_Theory.notes (common_notes @ notes @ Jbnf_notes) |> snd) |
2907 end; |
2906 end; |
2908 |
2907 |
2909 val _ = |
2908 val _ = |
2910 Outer_Syntax.local_theory @{command_spec "codatatype"} "define BNF-based coinductive datatypes" |
2909 Outer_Syntax.local_theory @{command_spec "codatatype"} "define BNF-based coinductive datatypes" |
2911 (parse_co_datatype_cmd Greatest_FP construct_gfp); |
2910 (parse_co_datatype_cmd Greatest_FP construct_gfp); |