210 (if fp = Least_FP then define_iters [foldN, recN] (the iters_args_types) |
210 (if fp = Least_FP then define_iters [foldN, recN] (the iters_args_types) |
211 else define_coiters [unfoldN, corecN] (the coiters_args_types)) |
211 else define_coiters [unfoldN, corecN] (the coiters_args_types)) |
212 (mk_binding b) fpTs Cs) fp_bs xtor_co_iterss lthy |
212 (mk_binding b) fpTs Cs) fp_bs xtor_co_iterss lthy |
213 |>> split_list; |
213 |>> split_list; |
214 |
214 |
215 val ((co_inducts, un_fold_thmss, co_rec_thmss, disc_unfold_thmss, disc_corec_thmss, |
215 val ((co_inducts, co_inductss, un_fold_thmss, co_rec_thmss, disc_unfold_thmss, |
216 sel_unfold_thmsss, sel_corec_thmsss), fp_sugar_thms) = |
216 disc_corec_thmss, sel_unfold_thmsss, sel_corec_thmsss), fp_sugar_thms) = |
217 if fp = Least_FP then |
217 if fp = Least_FP then |
218 derive_induct_iters_thms_for_types pre_bnfs (the iters_args_types) xtor_co_induct |
218 derive_induct_iters_thms_for_types pre_bnfs (the iters_args_types) xtor_co_induct |
219 xtor_co_iter_thmss nesting_bnfs nested_bnfs fpTs Cs Xs ctrXs_Tsss ctrss ctr_defss |
219 xtor_co_iter_thmss nesting_bnfs nested_bnfs fpTs Cs Xs ctrXs_Tsss ctrss ctr_defss |
220 co_iterss co_iter_defss lthy |
220 co_iterss co_iter_defss lthy |
221 |> `(fn ((_, induct, _), (fold_thmss, rec_thmss, _)) => |
221 |> `(fn ((inducts, induct, _), (fold_thmss, rec_thmss, _)) => |
222 ([induct], fold_thmss, rec_thmss, [], [], [], [])) |
222 ([induct], [inducts], fold_thmss, rec_thmss, [], [], [], [])) |
223 ||> (fn info => (SOME info, NONE)) |
223 ||> (fn info => (SOME info, NONE)) |
224 else |
224 else |
225 derive_coinduct_coiters_thms_for_types pre_bnfs (the coiters_args_types) xtor_co_induct |
225 derive_coinduct_coiters_thms_for_types pre_bnfs (the coiters_args_types) xtor_co_induct |
226 dtor_injects dtor_ctors xtor_co_iter_thmss nesting_bnfs fpTs Cs Xs ctrXs_Tsss kss mss |
226 dtor_injects dtor_ctors xtor_co_iter_thmss nesting_bnfs fpTs Cs Xs ctrXs_Tsss kss mss |
227 ns ctr_defss ctr_sugars co_iterss co_iter_defss |
227 ns ctr_defss ctr_sugars co_iterss co_iter_defss |
228 (Proof_Context.export lthy no_defs_lthy) lthy |
228 (Proof_Context.export lthy no_defs_lthy) lthy |
229 |> `(fn ((coinduct_thms_pairs, _), (unfold_thmss, corec_thmss, _), |
229 |> `(fn ((coinduct_thms_pairs, _), (unfold_thmss, corec_thmss, _), |
230 (disc_unfold_thmss, disc_corec_thmss, _), _, |
230 (disc_unfold_thmss, disc_corec_thmss, _), _, |
231 (sel_unfold_thmsss, sel_corec_thmsss, _)) => |
231 (sel_unfold_thmsss, sel_corec_thmsss, _)) => |
232 (map snd coinduct_thms_pairs, unfold_thmss, corec_thmss, disc_unfold_thmss, |
232 (map snd coinduct_thms_pairs, map fst coinduct_thms_pairs, unfold_thmss, corec_thmss, |
233 disc_corec_thmss, sel_unfold_thmsss, sel_corec_thmsss)) |
233 disc_unfold_thmss, disc_corec_thmss, sel_unfold_thmsss, sel_corec_thmsss)) |
234 ||> (fn info => (NONE, SOME info)); |
234 ||> (fn info => (NONE, SOME info)); |
235 |
235 |
236 val phi = Proof_Context.export_morphism no_defs_lthy no_defs_lthy0; |
236 val phi = Proof_Context.export_morphism no_defs_lthy no_defs_lthy0; |
237 |
237 |
238 fun mk_target_fp_sugar (kk, T) = |
238 fun mk_target_fp_sugar (kk, T) = |
239 {T = T, fp = fp, index = kk, pre_bnfs = pre_bnfs, nested_bnfs = nested_bnfs, |
239 {T = T, fp = fp, index = kk, pre_bnfs = pre_bnfs, nested_bnfs = nested_bnfs, |
240 nesting_bnfs = nesting_bnfs, fp_res = fp_res, ctr_defss = ctr_defss, |
240 nesting_bnfs = nesting_bnfs, fp_res = fp_res, ctr_defss = ctr_defss, |
241 ctr_sugars = ctr_sugars, co_iterss = co_iterss, mapss = mapss, co_inducts = co_inducts, |
241 ctr_sugars = ctr_sugars, co_iterss = co_iterss, mapss = mapss, co_inducts = co_inducts, |
|
242 co_inductss = transpose co_inductss, |
242 co_iter_thmsss = transpose [un_fold_thmss, co_rec_thmss], |
243 co_iter_thmsss = transpose [un_fold_thmss, co_rec_thmss], |
243 disc_co_itersss = transpose [disc_unfold_thmss, disc_corec_thmss], |
244 disc_co_itersss = transpose [disc_unfold_thmss, disc_corec_thmss], |
244 sel_co_iterssss = transpose [sel_unfold_thmsss, sel_corec_thmsss]} |
245 sel_co_iterssss = transpose [sel_unfold_thmsss, sel_corec_thmsss]} |
245 |> morph_fp_sugar phi; |
246 |> morph_fp_sugar phi; |
246 |
247 |