src/HOL/Tools/BNF/bnf_gfp_rec_sugar.ML
changeset 55871 a28817253b31
parent 55870 2f90476e3e61
child 55966 972f0aa7091b
equal deleted inserted replaced
55870:2f90476e3e61 55871:a28817253b31
   372 
   372 
   373 fun corec_specs_of bs arg_Ts res_Ts callers callssss0 lthy0 =
   373 fun corec_specs_of bs arg_Ts res_Ts callers callssss0 lthy0 =
   374   let
   374   let
   375     val thy = Proof_Context.theory_of lthy0;
   375     val thy = Proof_Context.theory_of lthy0;
   376 
   376 
   377     val ((missing_res_Ts, perm0_kks, fp_sugars as {nested_bnfs, co_rec = corec,
   377     val ((missing_res_Ts, perm0_kks, fp_sugars as {nested_bnfs,
   378             common_co_inducts = common_coinduct_thms, ...} :: _,
   378           common_co_inducts = common_coinduct_thms, ...} :: _, (_, gfp_sugar_thms)), lthy) =
   379           (_, gfp_sugar_thms)), lthy) =
       
   380       nested_to_mutual_fps Greatest_FP bs res_Ts callers callssss0 lthy0;
   379       nested_to_mutual_fps Greatest_FP bs res_Ts callers callssss0 lthy0;
   381 
   380 
   382     val perm_fp_sugars = sort (int_ord o pairself #fp_res_index) fp_sugars;
   381     val perm_fp_sugars = sort (int_ord o pairself #fp_res_index) fp_sugars;
   383 
   382 
   384     val indices = map #fp_res_index fp_sugars;
   383     val indices = map #fp_res_index fp_sugars;
   922     val fun_names = map Binding.name_of bs;
   921     val fun_names = map Binding.name_of bs;
   923     val basic_ctr_specss = map (basic_corec_specs_of lthy) res_Ts;
   922     val basic_ctr_specss = map (basic_corec_specs_of lthy) res_Ts;
   924     val frees = map (fst #>> Binding.name_of #> Free) fixes;
   923     val frees = map (fst #>> Binding.name_of #> Free) fixes;
   925     val has_call = exists_subterm (member (op =) frees);
   924     val has_call = exists_subterm (member (op =) frees);
   926     val eqns_data =
   925     val eqns_data =
   927       fold_map2 (dissect_coeqn lthy has_call fun_names sequentials basic_ctr_specss) (tag_list 0 (map snd specs))
   926       fold_map2 (dissect_coeqn lthy has_call fun_names sequentials basic_ctr_specss)
   928         of_specs_opt []
   927         (tag_list 0 (map snd specs)) of_specs_opt []
   929       |> flat o fst;
   928       |> flat o fst;
   930 
   929 
   931     val callssss =
   930     val callssss =
   932       map_filter (try (fn Sel x => x)) eqns_data
   931       map_filter (try (fn Sel x => x)) eqns_data
   933       |> partition_eq (op = o pairself #fun_name)
   932       |> partition_eq (op = o pairself #fun_name)
  1294 
  1293 
  1295         val disc_iff_thmss = map6 (flat ooo map2 oooo prove_disc_iff) corec_specs exhaust_thmss
  1294         val disc_iff_thmss = map6 (flat ooo map2 oooo prove_disc_iff) corec_specs exhaust_thmss
  1296           disc_thmsss' disc_eqnss disc_thmsss' disc_eqnss
  1295           disc_thmsss' disc_eqnss disc_thmsss' disc_eqnss
  1297           |> map sort_list_duplicates;
  1296           |> map sort_list_duplicates;
  1298 
  1297 
  1299         val ctr_alists = map5 (maps oooo prove_ctr) disc_alists (map (map snd) sel_alists) disc_eqnss
  1298         val ctr_alists = map5 (maps oooo prove_ctr) disc_alists (map (map snd) sel_alists)
  1300           sel_eqnss ctr_specss;
  1299           disc_eqnss sel_eqnss ctr_specss;
  1301         val ctr_thmss' = map (map snd) ctr_alists;
  1300         val ctr_thmss' = map (map snd) ctr_alists;
  1302         val ctr_thmss = map (map snd o order_list) ctr_alists;
  1301         val ctr_thmss = map (map snd o order_list) ctr_alists;
  1303 
  1302 
  1304         val code_thmss = map6 prove_code exhaustives disc_eqnss sel_eqnss nchotomy_thmss ctr_thmss'
  1303         val code_thmss = map6 prove_code exhaustives disc_eqnss sel_eqnss nchotomy_thmss ctr_thmss'
  1305           ctr_specss;
  1304           ctr_specss;