src/HOL/Tools/BNF/bnf_fp_def_sugar.ML
changeset 58116 1a9ac371e5a0
parent 58115 bfde04fc5190
child 58117 9608028d8f43
equal deleted inserted replaced
58115:bfde04fc5190 58116:1a9ac371e5a0
     7 *)
     7 *)
     8 
     8 
     9 signature BNF_FP_DEF_SUGAR =
     9 signature BNF_FP_DEF_SUGAR =
    10 sig
    10 sig
    11   val fp_sugar_of: Proof.context -> string -> BNF_FP_Util.fp_sugar option
    11   val fp_sugar_of: Proof.context -> string -> BNF_FP_Util.fp_sugar option
       
    12   val fp_sugar_of_global: theory -> string -> BNF_FP_Util.fp_sugar option
    12   val fp_sugars_of: Proof.context -> BNF_FP_Util.fp_sugar list
    13   val fp_sugars_of: Proof.context -> BNF_FP_Util.fp_sugar list
       
    14   val fp_sugars_of_global: theory -> BNF_FP_Util.fp_sugar list
    13   val fp_sugar_interpretation: (BNF_FP_Util.fp_sugar list -> theory -> theory) -> theory -> theory
    15   val fp_sugar_interpretation: (BNF_FP_Util.fp_sugar list -> theory -> theory) -> theory -> theory
    14   val register_fp_sugars: BNF_FP_Util.fp_sugar list -> local_theory -> local_theory
    16   val register_fp_sugars: BNF_FP_Util.fp_sugar list -> local_theory -> local_theory
    15 
    17 
    16   val co_induct_of: 'a list -> 'a
    18   val co_induct_of: 'a list -> 'a
    17   val strong_co_induct_of: 'a list -> 'a
    19   val strong_co_induct_of: 'a list -> 'a
   139     HOLogic.mk_Trueprop (prem $ t $ u)
   141     HOLogic.mk_Trueprop (prem $ t $ u)
   140   end;
   142   end;
   141 
   143 
   142 val name_of_set = name_of_const "set";
   144 val name_of_set = name_of_const "set";
   143 
   145 
   144 fun fp_sugar_of ctxt =
   146 fun fp_sugar_of_generic context =
   145   Symtab.lookup (Data.get (Context.Proof ctxt))
   147   Option.map (transfer_fp_sugar (Context.theory_of context)) o Symtab.lookup (Data.get context)
   146   #> Option.map (transfer_fp_sugar (Proof_Context.theory_of ctxt));
   148 
   147 
   149 fun fp_sugars_of_generic context =
   148 fun fp_sugars_of ctxt =
   150   Symtab.fold (cons o transfer_fp_sugar (Context.theory_of context) o snd) (Data.get context) [];
   149   Symtab.fold (cons o transfer_fp_sugar (Proof_Context.theory_of ctxt) o snd)
   151 
   150     (Data.get (Context.Proof ctxt)) [];
   152 val fp_sugar_of = fp_sugar_of_generic o Context.Proof;
       
   153 val fp_sugar_of_global = fp_sugar_of_generic o Context.Theory;
       
   154 
       
   155 val fp_sugars_of = fp_sugars_of_generic o Context.Proof;
       
   156 val fp_sugars_of_global = fp_sugars_of_generic o Context.Theory;
   151 
   157 
   152 fun co_induct_of (i :: _) = i;
   158 fun co_induct_of (i :: _) = i;
   153 fun strong_co_induct_of [_, s] = s;
   159 fun strong_co_induct_of [_, s] = s;
   154 
   160 
   155 structure FP_Sugar_Interpretation = Interpretation
   161 structure FP_Sugar_Interpretation = Interpretation