src/HOL/Tools/BNF/bnf_fp_def_sugar.ML
changeset 58188 cc71d2be4f0a
parent 58187 d2ddd401d74d
child 58189 9d714be4f028
equal deleted inserted replaced
58187:d2ddd401d74d 58188:cc71d2be4f0a
    39   val fp_sugar_of_global: theory -> string -> fp_sugar option
    39   val fp_sugar_of_global: theory -> string -> fp_sugar option
    40   val fp_sugars_of: Proof.context -> fp_sugar list
    40   val fp_sugars_of: Proof.context -> fp_sugar list
    41   val fp_sugars_of_global: theory -> fp_sugar list
    41   val fp_sugars_of_global: theory -> fp_sugar list
    42   val fp_sugars_interpretation: string -> (fp_sugar list -> theory -> theory) ->
    42   val fp_sugars_interpretation: string -> (fp_sugar list -> theory -> theory) ->
    43     (fp_sugar list -> local_theory -> local_theory)-> theory -> theory
    43     (fp_sugar list -> local_theory -> local_theory)-> theory -> theory
    44   val interpret_fp_sugars: fp_sugar list -> local_theory -> local_theory
    44   val interpret_fp_sugars: (string -> bool) -> fp_sugar list -> local_theory -> local_theory
    45   val register_fp_sugars_raw: fp_sugar list -> local_theory -> local_theory
    45   val register_fp_sugars_raw: fp_sugar list -> local_theory -> local_theory
    46   val register_fp_sugars: fp_sugar list -> local_theory -> local_theory
    46   val register_fp_sugars: (string -> bool) -> fp_sugar list -> local_theory -> local_theory
    47 
    47 
    48   val co_induct_of: 'a list -> 'a
    48   val co_induct_of: 'a list -> 'a
    49   val strong_co_induct_of: 'a list -> 'a
    49   val strong_co_induct_of: 'a list -> 'a
    50 
    50 
    51   val flat_corec_preds_predsss_gettersss: 'a list -> 'a list list list -> 'a list list list ->
    51   val flat_corec_preds_predsss_gettersss: 'a list -> 'a list list list -> 'a list list list ->
   234   fold (fn fp_sugar as {T = Type (s, _), ...} =>
   234   fold (fn fp_sugar as {T = Type (s, _), ...} =>
   235       Local_Theory.declaration {syntax = false, pervasive = true}
   235       Local_Theory.declaration {syntax = false, pervasive = true}
   236         (fn phi => Data.map (Symtab.update (s, morph_fp_sugar phi fp_sugar))))
   236         (fn phi => Data.map (Symtab.update (s, morph_fp_sugar phi fp_sugar))))
   237     fp_sugars;
   237     fp_sugars;
   238 
   238 
   239 fun register_fp_sugars fp_sugars =
   239 fun register_fp_sugars keep fp_sugars =
   240   register_fp_sugars_raw fp_sugars #> interpret_fp_sugars fp_sugars;
   240   register_fp_sugars_raw fp_sugars #> interpret_fp_sugars keep fp_sugars;
   241 
   241 
   242 fun interpret_bnfs_register_fp_sugars Ts BTs Xs fp pre_bnfs absT_infos fp_nesting_bnfs
   242 fun interpret_bnfs_register_fp_sugars Ts BTs Xs fp pre_bnfs absT_infos fp_nesting_bnfs
   243     live_nesting_bnfs fp_res ctrXs_Tsss ctr_defss ctr_sugars co_recs co_rec_defs mapss
   243     live_nesting_bnfs fp_res ctrXs_Tsss ctr_defss ctr_sugars co_recs co_rec_defs mapss
   244     common_co_inducts co_inductss co_rec_thmss co_rec_discss co_rec_selsss rel_injectss
   244     common_co_inducts co_inductss co_rec_thmss co_rec_discss co_rec_selsss rel_injectss
   245     rel_distinctss noted =
   245     rel_distinctss noted =
   256          co_rec_selss = nth co_rec_selsss kk, rel_injects = nth rel_injectss kk,
   256          co_rec_selss = nth co_rec_selsss kk, rel_injects = nth rel_injectss kk,
   257          rel_distincts = nth rel_distinctss kk}
   257          rel_distincts = nth rel_distinctss kk}
   258         |> morph_fp_sugar (substitute_noted_thm noted)) Ts;
   258         |> morph_fp_sugar (substitute_noted_thm noted)) Ts;
   259   in
   259   in
   260     register_fp_sugars_raw fp_sugars
   260     register_fp_sugars_raw fp_sugars
   261     #> fold interpret_bnf (#bnfs fp_res)
   261     #> fold (interpret_bnf (K true)) (#bnfs fp_res)
   262     #> interpret_fp_sugars fp_sugars
   262     #> interpret_fp_sugars (K true) fp_sugars
   263   end;
   263   end;
   264 
   264 
   265 (* This function could produce (fairly harmless) clashes in contrived examples (e.g., "x.A",
   265 (* This function could produce (fairly harmless) clashes in contrived examples (e.g., "x.A",
   266    "x.x_A", "y.A"). *)
   266    "x.x_A", "y.A"). *)
   267 fun quasi_unambiguous_case_names names =
   267 fun quasi_unambiguous_case_names names =