src/HOL/Tools/BNF/bnf_fp_rec_sugar_util.ML
changeset 59275 77cd4992edcd
parent 58337 568fb4e382c9
child 59281 1b4dc8a9f7d9
equal deleted inserted replaced
59274:67afe7e6a516 59275:77cd4992edcd
     6 Library for recursor and corecursor sugar.
     6 Library for recursor and corecursor sugar.
     7 *)
     7 *)
     8 
     8 
     9 signature BNF_FP_REC_SUGAR_UTIL =
     9 signature BNF_FP_REC_SUGAR_UTIL =
    10 sig
    10 sig
       
    11 
    11   datatype fp_kind = Least_FP | Greatest_FP
    12   datatype fp_kind = Least_FP | Greatest_FP
    12 
    13 
    13   val case_fp: fp_kind -> 'a -> 'a -> 'a
    14   val case_fp: fp_kind -> 'a -> 'a -> 'a
       
    15 
       
    16   type fp_rec_sugar =
       
    17     {transfers: bool list,
       
    18      fun_names: string list,
       
    19      funs: term list,
       
    20      fun_defs: thm list,
       
    21      fpTs: typ list}
       
    22 
       
    23   val morph_fp_rec_sugar: morphism -> fp_rec_sugar -> fp_rec_sugar
    14 
    24 
    15   val flat_rec_arg_args: 'a list list -> 'a list
    25   val flat_rec_arg_args: 'a list list -> 'a list
    16 
    26 
    17   val indexed: 'a list -> int -> int list * int
    27   val indexed: 'a list -> int -> int list * int
    18   val indexedd: 'a list list -> int -> int list list * int
    28   val indexedd: 'a list list -> int -> int list list * int
    48 
    58 
    49 datatype fp_kind = Least_FP | Greatest_FP;
    59 datatype fp_kind = Least_FP | Greatest_FP;
    50 
    60 
    51 fun case_fp Least_FP l _ = l
    61 fun case_fp Least_FP l _ = l
    52   | case_fp Greatest_FP _ g = g;
    62   | case_fp Greatest_FP _ g = g;
       
    63 
       
    64 type fp_rec_sugar =
       
    65   {transfers: bool list,
       
    66    fun_names: string list,
       
    67    funs: term list,
       
    68    fun_defs: thm list,
       
    69    fpTs: typ list}
       
    70 
       
    71 fun morph_fp_rec_sugar phi {transfers, fun_names, funs, fun_defs, fpTs} =
       
    72   {transfers = transfers,
       
    73    fun_names = fun_names,
       
    74    funs = map (Morphism.term phi) funs,
       
    75    fun_defs = map (Morphism.thm phi) fun_defs,
       
    76    fpTs = map (Morphism.typ phi) fpTs};
    53 
    77 
    54 fun flat_rec_arg_args xss =
    78 fun flat_rec_arg_args xss =
    55   (* FIXME (once the old datatype package is phased out): The first line below gives the preferred
    79   (* FIXME (once the old datatype package is phased out): The first line below gives the preferred
    56      order. The second line is for compatibility with the old datatype package. *)
    80      order. The second line is for compatibility with the old datatype package. *)
    57   (* flat xss *)
    81   (* flat xss *)