src/HOL/Tools/BNF/bnf_lfp_compat.ML
changeset 64705 7596b0736ab9
parent 64674 ef0a5fd30f3b
child 66251 cd935b7cb3fb
equal deleted inserted replaced
64704:08c2d80428ff 64705:7596b0736ab9
   206 
   206 
   207 fun mk_infos_of_mutually_recursive_new_datatypes prefs check_names fpT_names0 lthy =
   207 fun mk_infos_of_mutually_recursive_new_datatypes prefs check_names fpT_names0 lthy =
   208   let
   208   let
   209     val thy = Proof_Context.theory_of lthy;
   209     val thy = Proof_Context.theory_of lthy;
   210 
   210 
   211     fun not_datatype s = error (quote s ^ " is not a datatype");
   211     fun not_datatype_name s =
       
   212       error (quote s ^ " is not a datatype");
   212     fun not_mutually_recursive ss =
   213     fun not_mutually_recursive ss =
   213       error ("{" ^ commas ss ^ "} is not a complete set of mutually recursive datatypes");
   214       error ("{" ^ commas ss ^ "} is not a complete set of mutually recursive datatypes");
   214 
   215 
   215     fun checked_fp_sugar_of s =
   216     fun checked_fp_sugar_of s =
   216       (case fp_sugar_of lthy s of
   217       (case fp_sugar_of lthy s of
   217         SOME (fp_sugar as {fp, fp_co_induct_sugar = SOME _, ...}) =>
   218         SOME (fp_sugar as {fp, fp_co_induct_sugar = SOME _, ...}) =>
   218         if member (op =) prefs Include_GFPs orelse fp = Least_FP then fp_sugar else not_datatype s
   219         if member (op =) prefs Include_GFPs orelse fp = Least_FP then fp_sugar
   219       | _ => not_datatype s);
   220         else not_datatype_name s
       
   221       | _ => not_datatype_name s);
   220 
   222 
   221     val fpTs0 as Type (_, var_As) :: _ =
   223     val fpTs0 as Type (_, var_As) :: _ =
   222       map (#T o checked_fp_sugar_of o fst o dest_Type)
   224       map (#T o checked_fp_sugar_of o fst o dest_Type)
   223         (#Ts (#fp_res (checked_fp_sugar_of (hd fpT_names0))));
   225         (#Ts (#fp_res (checked_fp_sugar_of (hd fpT_names0))));
   224     val fpT_names as fpT_name1 :: _ = map (fst o dest_Type) fpTs0;
   226     val fpT_names as fpT_name1 :: _ = map (fst o dest_Type) fpTs0;
   315         define_split_rec_derive_induct_rec_thms Xs' fpTs' ctrXs_Tsss' ctrss' inducts induct recs
   317         define_split_rec_derive_induct_rec_thms Xs' fpTs' ctrXs_Tsss' ctrss' inducts induct recs
   316           rec_thmss lthy'
   318           rec_thmss lthy'
   317         |>> `(fn (inducts', induct', _, rec'_thmss) =>
   319         |>> `(fn (inducts', induct', _, rec'_thmss) =>
   318           SOME ((inducts', induct', mk_induct_attrs ctrss'), (rec'_thmss, [])))
   320           SOME ((inducts', induct', mk_induct_attrs ctrss'), (rec'_thmss, [])))
   319       else
   321       else
   320         not_datatype fpT_name1;
   322         not_datatype_name fpT_name1;
   321 
   323 
   322     val rec'_names = map (fst o dest_Const) recs';
   324     val rec'_names = map (fst o dest_Const) recs';
   323     val rec'_thms = flat rec'_thmss;
   325     val rec'_thms = flat rec'_thmss;
   324 
   326 
   325     fun mk_info (kk, {T = Type (T_name0, _), fp_ctr_sugar = {ctr_sugar = {casex, exhaust, nchotomy,
   327     fun mk_info (kk, {T = Type (T_name0, _), fp_ctr_sugar = {ctr_sugar = {casex, exhaust, nchotomy,