src/HOL/Tools/BNF/bnf_fp_def_sugar.ML
changeset 57633 4ff8c090d580
parent 57631 959caab43a3d
child 57665 232954f7df1c
equal deleted inserted replaced
57632:231e90cf2892 57633:4ff8c090d580
   161          co_rec = nth co_recs kk, co_rec_def = nth co_rec_defs kk, maps = nth mapss kk,
   161          co_rec = nth co_recs kk, co_rec_def = nth co_rec_defs kk, maps = nth mapss kk,
   162          common_co_inducts = common_co_inducts, co_inducts = nth co_inductss kk,
   162          common_co_inducts = common_co_inducts, co_inducts = nth co_inductss kk,
   163          co_rec_thms = nth co_rec_thmss kk, disc_co_recs = nth disc_co_recss kk,
   163          co_rec_thms = nth co_rec_thmss kk, disc_co_recs = nth disc_co_recss kk,
   164          sel_co_recss = nth sel_co_recsss kk, rel_injects = nth rel_injectss kk,
   164          sel_co_recss = nth sel_co_recsss kk, rel_injects = nth rel_injectss kk,
   165          rel_distincts = nth rel_distinctss kk}
   165          rel_distincts = nth rel_distinctss kk}
   166         |> morph_fp_sugar (substitute_noted_thm noted)) Ts
   166         |> morph_fp_sugar (substitute_noted_thm noted)) Ts;
   167   in
   167   in
   168     register_fp_sugars fp_sugars
   168     register_fp_sugars fp_sugars
   169   end;
   169   end;
   170 
   170 
   171 (* This function could produce (fairly harmless) clashes in contrived examples (e.g., "x.A",
   171 (* This function could produce (fairly harmless) clashes in contrived examples (e.g., "x.A",
   599 
   599 
   600         val thm =
   600         val thm =
   601           Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, ...} =>
   601           Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, ...} =>
   602             mk_induct_tac ctxt nn ns mss kksss (flat ctr_defss) ctor_induct' fp_abs_inverses
   602             mk_induct_tac ctxt nn ns mss kksss (flat ctr_defss) ctor_induct' fp_abs_inverses
   603               abs_inverses fp_nesting_set_maps pre_set_defss)
   603               abs_inverses fp_nesting_set_maps pre_set_defss)
   604           |> singleton (Proof_Context.export names_lthy lthy)
   604           |> singleton (Proof_Context.export names_lthy lthy);
   605           (* for "datatype_realizer.ML": *)
       
   606           |> Thm.name_derivation (fst (dest_Type (hd fpTs)) ^ Long_Name.separator ^
       
   607             (if nn > 1 then space_implode "_" (tl fp_b_names) ^ Long_Name.separator else "") ^
       
   608             inductN);
       
   609       in
   605       in
   610         `(conj_dests nn) thm
   606         `(conj_dests nn) thm
   611       end;
   607       end;
   612 
   608 
   613     val xctrss = map2 (map2 (curry Term.list_comb)) ctrss xsss;
   609     val xctrss = map2 (map2 (curry Term.list_comb)) ctrss xsss;
  1700 
  1696 
  1701         val common_notes =
  1697         val common_notes =
  1702           (if nn > 1 then
  1698           (if nn > 1 then
  1703              [(inductN, [induct_thm], induct_attrs),
  1699              [(inductN, [induct_thm], induct_attrs),
  1704               (rel_inductN, common_rel_induct_thms, common_rel_induct_attrs)]
  1700               (rel_inductN, common_rel_induct_thms, common_rel_induct_attrs)]
  1705            else [])
  1701            else
       
  1702              [])
  1706           |> massage_simple_notes fp_common_name;
  1703           |> massage_simple_notes fp_common_name;
  1707 
  1704 
  1708         val notes =
  1705         val notes =
  1709           [(inductN, map single induct_thms, fn T_name => induct_attrs @ [induct_type_attr T_name]),
  1706           [(inductN, map single induct_thms, fn T_name => induct_attrs @ [induct_type_attr T_name]),
  1710            (recN, rec_thmss, K rec_attrs),
  1707            (recN, rec_thmss, K rec_attrs),
  1713           |> massage_multi_notes;
  1710           |> massage_multi_notes;
  1714       in
  1711       in
  1715         lthy
  1712         lthy
  1716         |> Spec_Rules.add Spec_Rules.Equational (recs, flat rec_thmss)
  1713         |> Spec_Rules.add Spec_Rules.Equational (recs, flat rec_thmss)
  1717         |> Local_Theory.notes (common_notes @ notes)
  1714         |> Local_Theory.notes (common_notes @ notes)
       
  1715         (* for "datatype_realizer.ML": *)
       
  1716         |>> name_noted_thms
       
  1717           (fst (dest_Type (hd fpTs)) ^ (implode (map (prefix "_") (tl fp_b_names)))) inductN
  1718         |-> register_as_fp_sugars fpTs fpBTs Xs Least_FP pre_bnfs absT_infos fp_nesting_bnfs
  1718         |-> register_as_fp_sugars fpTs fpBTs Xs Least_FP pre_bnfs absT_infos fp_nesting_bnfs
  1719           live_nesting_bnfs fp_res ctrXs_Tsss ctr_defss ctr_sugars recs rec_defs mapss [induct_thm]
  1719           live_nesting_bnfs fp_res ctrXs_Tsss ctr_defss ctr_sugars recs rec_defs mapss [induct_thm]
  1720           (map single induct_thms) rec_thmss (replicate nn []) (replicate nn []) rel_injectss
  1720           (map single induct_thms) rec_thmss (replicate nn []) (replicate nn []) rel_injectss
  1721           rel_distinctss
  1721           rel_distinctss
  1722       end;
  1722       end;