367 val nesting_map_ids'' = map (unfold_thms lthy @{thms id_def} o map_id_of_bnf) nesting_bnfs; |
367 val nesting_map_ids'' = map (unfold_thms lthy @{thms id_def} o map_id_of_bnf) nesting_bnfs; |
368 val nesting_rel_eqs = map rel_eq_of_bnf nesting_bnfs; |
368 val nesting_rel_eqs = map rel_eq_of_bnf nesting_bnfs; |
369 |
369 |
370 val fp_b_names = map base_name_of_typ fpTs; |
370 val fp_b_names = map base_name_of_typ fpTs; |
371 |
371 |
372 val discss = map (map (mk_disc_or_sel As) o #1) ctr_wrap_ress; |
372 val discss = map (map (mk_disc_or_sel As) o #discs) ctr_wrap_ress; |
373 val selsss = map (map (map (mk_disc_or_sel As)) o #2) ctr_wrap_ress; |
373 val selsss = map (map (map (mk_disc_or_sel As)) o #selss) ctr_wrap_ress; |
374 val exhaust_thms = map #3 ctr_wrap_ress; |
374 val exhausts = map #exhaust ctr_wrap_ress; |
375 val disc_thmsss = map #7 ctr_wrap_ress; |
375 val disc_thmsss = map #disc_thmss ctr_wrap_ress; |
376 val discIss = map #8 ctr_wrap_ress; |
376 val discIss = map #discIs ctr_wrap_ress; |
377 val sel_thmsss = map #9 ctr_wrap_ress; |
377 val sel_thmsss = map #sel_thmss ctr_wrap_ress; |
378 |
378 |
379 val (((rs, us'), vs'), names_lthy) = |
379 val (((rs, us'), vs'), names_lthy) = |
380 lthy |
380 lthy |
381 |> mk_Frees "R" (map (fn T => mk_pred2T T T) fpTs) |
381 |> mk_Frees "R" (map (fn T => mk_pred2T T T) fpTs) |
382 ||>> Variable.variant_fixes fp_b_names |
382 ||>> Variable.variant_fixes fp_b_names |
438 val strong_goal = mk_goal strong_rs; |
438 val strong_goal = mk_goal strong_rs; |
439 |
439 |
440 fun prove dtor_coinduct' goal = |
440 fun prove dtor_coinduct' goal = |
441 Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, ...} => |
441 Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, ...} => |
442 mk_coinduct_tac ctxt nesting_rel_eqs nn ns dtor_coinduct' pre_rel_defs dtor_ctors |
442 mk_coinduct_tac ctxt nesting_rel_eqs nn ns dtor_coinduct' pre_rel_defs dtor_ctors |
443 exhaust_thms ctr_defss disc_thmsss sel_thmsss) |
443 exhausts ctr_defss disc_thmsss sel_thmsss) |
444 |> singleton (Proof_Context.export names_lthy lthy) |
444 |> singleton (Proof_Context.export names_lthy lthy) |
445 |> Thm.close_derivation; |
445 |> Thm.close_derivation; |
446 |
446 |
447 fun postproc nn thm = |
447 fun postproc nn thm = |
448 Thm.permute_prems 0 nn |
448 Thm.permute_prems 0 nn |
1200 fold_map I wrap_types_and_mores lthy |
1200 fold_map I wrap_types_and_mores lthy |
1201 |>> apsnd split_list4 o apfst split_list4 o split_list; |
1201 |>> apsnd split_list4 o apfst split_list4 o split_list; |
1202 |
1202 |
1203 (* TODO: Add map, sets, rel simps *) |
1203 (* TODO: Add map, sets, rel simps *) |
1204 val mk_simp_thmss = |
1204 val mk_simp_thmss = |
1205 map3 (fn (_, _, _, injects, distincts, cases, _, _, _) => fn rec_likes => fn fold_likes => |
1205 map3 (fn {injects, distincts, case_thms, ...} => fn rec_likes => fn fold_likes => |
1206 injects @ distincts @ cases @ rec_likes @ fold_likes); |
1206 injects @ distincts @ case_thms @ rec_likes @ fold_likes); |
1207 |
1207 |
1208 fun derive_and_note_induct_fold_rec_thms_for_types |
1208 fun derive_and_note_induct_fold_rec_thms_for_types |
1209 (((ctrss, xsss, ctr_defss, ctr_wrap_ress), (folds, recs, fold_defs, rec_defs)), lthy) = |
1209 (((ctrss, xsss, ctr_defss, ctr_wrap_ress), (folds, recs, fold_defs, rec_defs)), lthy) = |
1210 let |
1210 let |
1211 val ((induct_thm, induct_thms, induct_attrs), |
1211 val ((induct_thm, induct_thms, induct_attrs), |