src/HOL/Tools/BNF/bnf_fp_def_sugar.ML
changeset 59621 291934bac95e
parent 59582 0fbed69ff081
child 59794 39442248a027
equal deleted inserted replaced
59620:92d7d8e4f1bf 59621:291934bac95e
   474 
   474 
   475 fun flip_rels lthy n thm =
   475 fun flip_rels lthy n thm =
   476   let
   476   let
   477     val Rs = Term.add_vars (Thm.prop_of thm) [];
   477     val Rs = Term.add_vars (Thm.prop_of thm) [];
   478     val Rs' = rev (drop (length Rs - n) Rs);
   478     val Rs' = rev (drop (length Rs - n) Rs);
   479     val cRs = map (fn f => (Proof_Context.cterm_of lthy (Var f), Proof_Context.cterm_of lthy (mk_flip f))) Rs';
   479     val cRs = map (fn f => (Thm.cterm_of lthy (Var f), Thm.cterm_of lthy (mk_flip f))) Rs';
   480   in
   480   in
   481     Drule.cterm_instantiate cRs thm
   481     Drule.cterm_instantiate cRs thm
   482   end;
   482   end;
   483 
   483 
   484 fun mk_ctor_or_dtor get_T Ts t =
   484 fun mk_ctor_or_dtor get_T Ts t =
   596       val ctor_cong =
   596       val ctor_cong =
   597         if fp = Least_FP then
   597         if fp = Least_FP then
   598           Drule.dummy_thm
   598           Drule.dummy_thm
   599         else
   599         else
   600           let val ctor' = mk_ctor Bs ctor in
   600           let val ctor' = mk_ctor Bs ctor in
   601             cterm_instantiate_pos [NONE, NONE, SOME (Proof_Context.cterm_of lthy ctor')] arg_cong
   601             cterm_instantiate_pos [NONE, NONE, SOME (Thm.cterm_of lthy ctor')] arg_cong
   602           end;
   602           end;
   603 
   603 
   604       fun mk_cIn ctor k xs =
   604       fun mk_cIn ctor k xs =
   605         let val absT = domain_type (fastype_of ctor) in
   605         let val absT = domain_type (fastype_of ctor) in
   606           mk_absumprod absT abs n k xs
   606           mk_absumprod absT abs n k xs
   607           |> fp = Greatest_FP ? curry (op $) ctor
   607           |> fp = Greatest_FP ? curry (op $) ctor
   608           |> Proof_Context.cterm_of lthy
   608           |> Thm.cterm_of lthy
   609         end;
   609         end;
   610 
   610 
   611       val cxIns = map2 (mk_cIn ctor) ks xss;
   611       val cxIns = map2 (mk_cIn ctor) ks xss;
   612       val cyIns = map2 (mk_cIn (Term.map_types B_ify_T ctor)) ks yss;
   612       val cyIns = map2 (mk_cIn (Term.map_types B_ify_T ctor)) ks yss;
   613 
   613 
   614       fun mk_map_thm ctr_def' cxIn =
   614       fun mk_map_thm ctr_def' cxIn =
   615         fold_thms lthy [ctr_def']
   615         fold_thms lthy [ctr_def']
   616           (unfold_thms lthy (o_apply :: pre_map_def ::
   616           (unfold_thms lthy (o_apply :: pre_map_def ::
   617                (if fp = Least_FP then [] else [dtor_ctor]) @ sumprod_thms_map @ abs_inverses)
   617                (if fp = Least_FP then [] else [dtor_ctor]) @ sumprod_thms_map @ abs_inverses)
   618              (cterm_instantiate_pos (map (SOME o Proof_Context.cterm_of lthy) fs @ [SOME cxIn])
   618              (cterm_instantiate_pos (map (SOME o Thm.cterm_of lthy) fs @ [SOME cxIn])
   619                 (if fp = Least_FP then fp_map_thm
   619                 (if fp = Least_FP then fp_map_thm
   620                  else fp_map_thm RS ctor_cong RS (ctor_dtor RS sym RS trans))))
   620                  else fp_map_thm RS ctor_cong RS (ctor_dtor RS sym RS trans))))
   621         |> singleton (Proof_Context.export names_lthy lthy);
   621         |> singleton (Proof_Context.export names_lthy lthy);
   622 
   622 
   623       fun mk_set0_thm fp_set_thm ctr_def' cxIn =
   623       fun mk_set0_thm fp_set_thm ctr_def' cxIn =
   641       fun mk_rel_thm postproc ctr_defs' cxIn cyIn =
   641       fun mk_rel_thm postproc ctr_defs' cxIn cyIn =
   642         fold_thms lthy ctr_defs'
   642         fold_thms lthy ctr_defs'
   643           (unfold_thms lthy (pre_rel_def :: abs_inverses @
   643           (unfold_thms lthy (pre_rel_def :: abs_inverses @
   644                (if fp = Least_FP then [] else [dtor_ctor]) @ sumprod_thms_rel @
   644                (if fp = Least_FP then [] else [dtor_ctor]) @ sumprod_thms_rel @
   645                @{thms vimage2p_def sum.inject sum.distinct(1)[THEN eq_False[THEN iffD2]]})
   645                @{thms vimage2p_def sum.inject sum.distinct(1)[THEN eq_False[THEN iffD2]]})
   646              (cterm_instantiate_pos (map (SOME o Proof_Context.cterm_of lthy) Rs @ [SOME cxIn, SOME cyIn])
   646              (cterm_instantiate_pos (map (SOME o Thm.cterm_of lthy) Rs @ [SOME cxIn, SOME cyIn])
   647                 fp_rel_thm))
   647                 fp_rel_thm))
   648         |> postproc
   648         |> postproc
   649         |> singleton (Proof_Context.export names_lthy lthy);
   649         |> singleton (Proof_Context.export names_lthy lthy);
   650 
   650 
   651       fun mk_rel_inject_thm ((ctr_def', cxIn), (_, cyIn)) =
   651       fun mk_rel_inject_thm ((ctr_def', cxIn), (_, cyIn)) =
   732                       end) args)
   732                       end) args)
   733                   end) ctrAs;
   733                   end) ctrAs;
   734               val goal = Logic.mk_implies (mk_Trueprop_mem (elem, set $ ta), thesis);
   734               val goal = Logic.mk_implies (mk_Trueprop_mem (elem, set $ ta), thesis);
   735               val thm =
   735               val thm =
   736                 Goal.prove_sorry lthy [] (flat premss) goal (fn {context = ctxt, prems} =>
   736                 Goal.prove_sorry lthy [] (flat premss) goal (fn {context = ctxt, prems} =>
   737                   mk_set_cases_tac ctxt (Proof_Context.cterm_of ctxt ta) prems exhaust set_thms)
   737                   mk_set_cases_tac ctxt (Thm.cterm_of ctxt ta) prems exhaust set_thms)
   738                 |> singleton (Proof_Context.export names_lthy lthy)
   738                 |> singleton (Proof_Context.export names_lthy lthy)
   739                 |> Thm.close_derivation
   739                 |> Thm.close_derivation
   740                 |> rotate_prems ~1;
   740                 |> rotate_prems ~1;
   741 
   741 
   742               val consumes_attr = Attrib.internal (K (Rule_Cases.consumes 1));
   742               val consumes_attr = Attrib.internal (K (Rule_Cases.consumes 1));
   810                    [] => @{term True}
   810                    [] => @{term True}
   811                  | conjuncts => Library.foldr1 HOLogic.mk_conj conjuncts))];
   811                  | conjuncts => Library.foldr1 HOLogic.mk_conj conjuncts))];
   812 
   812 
   813           fun prove goal =
   813           fun prove goal =
   814             Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
   814             Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
   815               mk_rel_sel_tac ctxt (Proof_Context.cterm_of ctxt ta) (Proof_Context.cterm_of ctxt tb) exhaust (flat disc_thmss)
   815               mk_rel_sel_tac ctxt (Thm.cterm_of ctxt ta) (Thm.cterm_of ctxt tb) exhaust (flat disc_thmss)
   816                 (flat sel_thmss) rel_inject_thms distincts rel_distinct_thms live_nesting_rel_eqs)
   816                 (flat sel_thmss) rel_inject_thms distincts rel_distinct_thms live_nesting_rel_eqs)
   817             |> singleton (Proof_Context.export names_lthy lthy)
   817             |> singleton (Proof_Context.export names_lthy lthy)
   818             |> Thm.close_derivation;
   818             |> Thm.close_derivation;
   819         in
   819         in
   820           map prove goals
   820           map prove goals
   844 
   844 
   845           val (assms, names_lthy) = @{fold_map 2} mk_assms ctrAs ctrBs names_lthy;
   845           val (assms, names_lthy) = @{fold_map 2} mk_assms ctrAs ctrBs names_lthy;
   846           val goal = Logic.list_implies (HOLogic.mk_Trueprop rel_Rs_a_b :: assms, thesis);
   846           val goal = Logic.list_implies (HOLogic.mk_Trueprop rel_Rs_a_b :: assms, thesis);
   847           val thm =
   847           val thm =
   848             Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
   848             Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
   849               mk_rel_cases_tac ctxt (Proof_Context.cterm_of ctxt ta) (Proof_Context.cterm_of ctxt tb) exhaust injects
   849               mk_rel_cases_tac ctxt (Thm.cterm_of ctxt ta) (Thm.cterm_of ctxt tb) exhaust injects
   850                 rel_inject_thms distincts rel_distinct_thms live_nesting_rel_eqs)
   850                 rel_inject_thms distincts rel_distinct_thms live_nesting_rel_eqs)
   851             |> singleton (Proof_Context.export names_lthy lthy)
   851             |> singleton (Proof_Context.export names_lthy lthy)
   852             |> Thm.close_derivation;
   852             |> Thm.close_derivation;
   853 
   853 
   854           val ctr_names = quasi_unambiguous_case_names (map name_of_ctr ctrAs);
   854           val ctr_names = quasi_unambiguous_case_names (map name_of_ctr ctrAs);
   918           if null goals then
   918           if null goals then
   919             []
   919             []
   920           else
   920           else
   921             Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
   921             Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
   922               (fn {context = ctxt, prems = _} =>
   922               (fn {context = ctxt, prems = _} =>
   923                  mk_map_disc_iff_tac ctxt (Proof_Context.cterm_of ctxt ta) exhaust (flat disc_thmss) map_thms)
   923                  mk_map_disc_iff_tac ctxt (Thm.cterm_of ctxt ta) exhaust (flat disc_thmss) map_thms)
   924             |> Conjunction.elim_balanced (length goals)
   924             |> Conjunction.elim_balanced (length goals)
   925             |> Proof_Context.export names_lthy lthy
   925             |> Proof_Context.export names_lthy lthy
   926             |> map Thm.close_derivation
   926             |> map Thm.close_derivation
   927         end;
   927         end;
   928 
   928 
   952           `(fst o unflat goalss)
   952           `(fst o unflat goalss)
   953             (if null goals then []
   953             (if null goals then []
   954              else
   954              else
   955                Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
   955                Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
   956                  (fn {context = ctxt, prems = _} =>
   956                  (fn {context = ctxt, prems = _} =>
   957                     mk_map_sel_tac ctxt (Proof_Context.cterm_of ctxt ta) exhaust (flat disc_thmss) map_thms
   957                     mk_map_sel_tac ctxt (Thm.cterm_of ctxt ta) exhaust (flat disc_thmss) map_thms
   958                       (flat sel_thmss) live_nesting_map_id0s)
   958                       (flat sel_thmss) live_nesting_map_id0s)
   959                |> Conjunction.elim_balanced (length goals)
   959                |> Conjunction.elim_balanced (length goals)
   960                |> Proof_Context.export names_lthy lthy
   960                |> Proof_Context.export names_lthy lthy
   961                |> map Thm.close_derivation)
   961                |> map Thm.close_derivation)
   962         end;
   962         end;
  1011           `(fst o unflattt goalssss)
  1011           `(fst o unflattt goalssss)
  1012             (if null goals then []
  1012             (if null goals then []
  1013              else
  1013              else
  1014                Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
  1014                Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
  1015                  (fn {context = ctxt, prems = _} =>
  1015                  (fn {context = ctxt, prems = _} =>
  1016                     mk_set_sel_tac ctxt (Proof_Context.cterm_of ctxt ta) exhaust (flat disc_thmss)
  1016                     mk_set_sel_tac ctxt (Thm.cterm_of ctxt ta) exhaust (flat disc_thmss)
  1017                       (flat sel_thmss) set0_thms)
  1017                       (flat sel_thmss) set0_thms)
  1018                |> Conjunction.elim_balanced (length goals)
  1018                |> Conjunction.elim_balanced (length goals)
  1019                |> Proof_Context.export names_lthy lthy
  1019                |> Proof_Context.export names_lthy lthy
  1020                |> map Thm.close_derivation)
  1020                |> map Thm.close_derivation)
  1021         end;
  1021         end;
  1300     val goal = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj (map2 mk_leq
  1300     val goal = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj (map2 mk_leq
  1301       (map2 (build_the_rel [] lthy (Rs @ IRs) []) fpA_Ts fpB_Ts) IRs));
  1301       (map2 (build_the_rel [] lthy (Rs @ IRs) []) fpA_Ts fpB_Ts) IRs));
  1302 
  1302 
  1303     val rel_induct0_thm =
  1303     val rel_induct0_thm =
  1304       Goal.prove_sorry lthy [] prems goal (fn {context = ctxt, prems} =>
  1304       Goal.prove_sorry lthy [] prems goal (fn {context = ctxt, prems} =>
  1305         mk_rel_induct0_tac ctxt ctor_rel_induct prems (map (Proof_Context.cterm_of ctxt) IRs) exhausts ctor_defss
  1305         mk_rel_induct0_tac ctxt ctor_rel_induct prems (map (Thm.cterm_of ctxt) IRs) exhausts ctor_defss
  1306           ctor_injects pre_rel_defs abs_inverses live_nesting_rel_eqs)
  1306           ctor_injects pre_rel_defs abs_inverses live_nesting_rel_eqs)
  1307       |> singleton (Proof_Context.export names_lthy lthy)
  1307       |> singleton (Proof_Context.export names_lthy lthy)
  1308       |> Thm.close_derivation;
  1308       |> Thm.close_derivation;
  1309   in
  1309   in
  1310     (postproc_co_induct lthy (length fpA_Ts) @{thm predicate2D} @{thm predicate2D_conj}
  1310     (postproc_co_induct lthy (length fpA_Ts) @{thm predicate2D} @{thm predicate2D_conj}
  1558     val goal = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj (map2 mk_leq
  1558     val goal = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj (map2 mk_leq
  1559       IRs (map2 (build_the_rel [] lthy (Rs @ IRs) []) fpA_Ts fpB_Ts)));
  1559       IRs (map2 (build_the_rel [] lthy (Rs @ IRs) []) fpA_Ts fpB_Ts)));
  1560 
  1560 
  1561     val rel_coinduct0_thm =
  1561     val rel_coinduct0_thm =
  1562       Goal.prove_sorry lthy [] prems goal (fn {context = ctxt, prems} =>
  1562       Goal.prove_sorry lthy [] prems goal (fn {context = ctxt, prems} =>
  1563         mk_rel_coinduct0_tac ctxt dtor_rel_coinduct (map (Proof_Context.cterm_of ctxt) IRs) prems
  1563         mk_rel_coinduct0_tac ctxt dtor_rel_coinduct (map (Thm.cterm_of ctxt) IRs) prems
  1564           (map #exhaust ctr_sugars) (map (flat o #disc_thmss) ctr_sugars)
  1564           (map #exhaust ctr_sugars) (map (flat o #disc_thmss) ctr_sugars)
  1565           (map (flat o #sel_thmss) ctr_sugars) ctor_defss dtor_ctors ctor_injects abs_injects
  1565           (map (flat o #sel_thmss) ctr_sugars) ctor_defss dtor_ctors ctor_injects abs_injects
  1566           rel_pre_defs abs_inverses live_nesting_rel_eqs)
  1566           rel_pre_defs abs_inverses live_nesting_rel_eqs)
  1567       |> singleton (Proof_Context.export names_lthy lthy)
  1567       |> singleton (Proof_Context.export names_lthy lthy)
  1568       |> Thm.close_derivation;
  1568       |> Thm.close_derivation;
  1642           |>> apsnd flat;
  1642           |>> apsnd flat;
  1643 
  1643 
  1644         val thm =
  1644         val thm =
  1645           Goal.prove_sorry lthy [] prems (HOLogic.mk_Trueprop concl)
  1645           Goal.prove_sorry lthy [] prems (HOLogic.mk_Trueprop concl)
  1646             (fn {context = ctxt, prems} =>
  1646             (fn {context = ctxt, prems} =>
  1647                mk_set_induct0_tac ctxt (map (Proof_Context.cterm_of ctxt'') Ps) prems dtor_set_inducts exhausts
  1647                mk_set_induct0_tac ctxt (map (Thm.cterm_of ctxt'') Ps) prems dtor_set_inducts exhausts
  1648                  set_pre_defs ctor_defs dtor_ctors Abs_pre_inverses)
  1648                  set_pre_defs ctor_defs dtor_ctors Abs_pre_inverses)
  1649           |> singleton (Proof_Context.export ctxt'' ctxt)
  1649           |> singleton (Proof_Context.export ctxt'' ctxt)
  1650           |> Thm.close_derivation;
  1650           |> Thm.close_derivation;
  1651 
  1651 
  1652         val case_names_attr =
  1652         val case_names_attr =
  1817             if n = 1 then @{const True}
  1817             if n = 1 then @{const True}
  1818             else Library.foldr1 HOLogic.mk_conj (seq_conds mk_maybe_not n k cps));
  1818             else Library.foldr1 HOLogic.mk_conj (seq_conds mk_maybe_not n k cps));
  1819 
  1819 
  1820         val goalss = @{map 6} (map2 oooo mk_goal) cs cpss gcorecs ns kss discss;
  1820         val goalss = @{map 6} (map2 oooo mk_goal) cs cpss gcorecs ns kss discss;
  1821 
  1821 
  1822         fun mk_case_split' cp = Drule.instantiate' [] [SOME (Proof_Context.cterm_of lthy cp)] @{thm case_split};
  1822         fun mk_case_split' cp = Drule.instantiate' [] [SOME (Thm.cterm_of lthy cp)] @{thm case_split};
  1823 
  1823 
  1824         val case_splitss' = map (map mk_case_split') cpss;
  1824         val case_splitss' = map (map mk_case_split') cpss;
  1825 
  1825 
  1826         val tacss = @{map 3} (map oo mk_corec_disc_iff_tac) case_splitss' corec_thmss disc_thmsss;
  1826         val tacss = @{map 3} (map oo mk_corec_disc_iff_tac) case_splitss' corec_thmss disc_thmsss;
  1827 
  1827 
  1843 
  1843 
  1844     fun mk_corec_sel_thm corec_thm sel sel_thm =
  1844     fun mk_corec_sel_thm corec_thm sel sel_thm =
  1845       let
  1845       let
  1846         val (domT, ranT) = dest_funT (fastype_of sel);
  1846         val (domT, ranT) = dest_funT (fastype_of sel);
  1847         val arg_cong' =
  1847         val arg_cong' =
  1848           Drule.instantiate' (map (SOME o Proof_Context.ctyp_of lthy) [domT, ranT])
  1848           Drule.instantiate' (map (SOME o Thm.ctyp_of lthy) [domT, ranT])
  1849             [NONE, NONE, SOME (Proof_Context.cterm_of lthy sel)] arg_cong
  1849             [NONE, NONE, SOME (Thm.cterm_of lthy sel)] arg_cong
  1850           |> Thm.varifyT_global;
  1850           |> Thm.varifyT_global;
  1851         val sel_thm' = sel_thm RSN (2, trans);
  1851         val sel_thm' = sel_thm RSN (2, trans);
  1852       in
  1852       in
  1853         corec_thm RS arg_cong' RS sel_thm'
  1853         corec_thm RS arg_cong' RS sel_thm'
  1854       end;
  1854       end;
  2139                     val goal =
  2139                     val goal =
  2140                       fold_rev Logic.all [w, u]
  2140                       fold_rev Logic.all [w, u]
  2141                         (mk_Trueprop_eq (HOLogic.mk_eq (u, ctor $ w), HOLogic.mk_eq (dtor $ u, w)));
  2141                         (mk_Trueprop_eq (HOLogic.mk_eq (u, ctor $ w), HOLogic.mk_eq (dtor $ u, w)));
  2142                   in
  2142                   in
  2143                     Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, ...} =>
  2143                     Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, ...} =>
  2144                       mk_ctor_iff_dtor_tac ctxt (map (SOME o Proof_Context.ctyp_of lthy) [ctr_absT, fpT])
  2144                       mk_ctor_iff_dtor_tac ctxt (map (SOME o Thm.ctyp_of lthy) [ctr_absT, fpT])
  2145                         (Proof_Context.cterm_of lthy ctor) (Proof_Context.cterm_of lthy dtor) ctor_dtor dtor_ctor)
  2145                         (Thm.cterm_of lthy ctor) (Thm.cterm_of lthy dtor) ctor_dtor dtor_ctor)
  2146                     |> Morphism.thm phi
  2146                     |> Morphism.thm phi
  2147                     |> Thm.close_derivation
  2147                     |> Thm.close_derivation
  2148                   end;
  2148                   end;
  2149 
  2149 
  2150                 val sumEN_thm' =
  2150                 val sumEN_thm' =
  2231 
  2231 
  2232     fun derive_rec_transfer_thms lthy recs rec_defs (SOME (_, _, _, xsssss)) =
  2232     fun derive_rec_transfer_thms lthy recs rec_defs (SOME (_, _, _, xsssss)) =
  2233       let val (Rs, Ss, goals, names_lthy) = mk_co_rec_transfer_goals lthy recs in
  2233       let val (Rs, Ss, goals, names_lthy) = mk_co_rec_transfer_goals lthy recs in
  2234         Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
  2234         Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
  2235           (fn {context = ctxt, prems = _} =>
  2235           (fn {context = ctxt, prems = _} =>
  2236              mk_rec_transfer_tac ctxt nn ns (map (Proof_Context.cterm_of ctxt) Ss) (map (Proof_Context.cterm_of ctxt) Rs) xsssss
  2236              mk_rec_transfer_tac ctxt nn ns (map (Thm.cterm_of ctxt) Ss) (map (Thm.cterm_of ctxt) Rs) xsssss
  2237                rec_defs xtor_co_rec_transfers pre_rel_defs live_nesting_rel_eqs)
  2237                rec_defs xtor_co_rec_transfers pre_rel_defs live_nesting_rel_eqs)
  2238         |> Conjunction.elim_balanced nn
  2238         |> Conjunction.elim_balanced nn
  2239         |> Proof_Context.export names_lthy lthy
  2239         |> Proof_Context.export names_lthy lthy
  2240         |> map Thm.close_derivation
  2240         |> map Thm.close_derivation
  2241       end;
  2241       end;
  2383         val (Rs, Ss, goals, names_lthy) = mk_co_rec_transfer_goals lthy corecs;
  2383         val (Rs, Ss, goals, names_lthy) = mk_co_rec_transfer_goals lthy corecs;
  2384         val (_, _, _, (((pgss, pss, qssss, gssss), _), _)) = the corecs_args_types;
  2384         val (_, _, _, (((pgss, pss, qssss, gssss), _), _)) = the corecs_args_types;
  2385       in
  2385       in
  2386         Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
  2386         Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals)
  2387           (fn {context = ctxt, prems = _} =>
  2387           (fn {context = ctxt, prems = _} =>
  2388              mk_corec_transfer_tac ctxt (map (Proof_Context.cterm_of ctxt) Ss) (map (Proof_Context.cterm_of ctxt) Rs)
  2388              mk_corec_transfer_tac ctxt (map (Thm.cterm_of ctxt) Ss) (map (Thm.cterm_of ctxt) Rs)
  2389                type_definitions corec_defs xtor_co_rec_transfers pre_rel_defs
  2389                type_definitions corec_defs xtor_co_rec_transfers pre_rel_defs
  2390                live_nesting_rel_eqs (flat pgss) pss qssss gssss)
  2390                live_nesting_rel_eqs (flat pgss) pss qssss gssss)
  2391         |> Conjunction.elim_balanced (length goals)
  2391         |> Conjunction.elim_balanced (length goals)
  2392         |> Proof_Context.export names_lthy lthy
  2392         |> Proof_Context.export names_lthy lthy
  2393         |> map Thm.close_derivation
  2393         |> map Thm.close_derivation