src/HOL/BNF/Tools/bnf_util.ML
changeset 52958 5a77edcdbe54
parent 52937 cdd1d5049287
child 52963 96754402c851
equal deleted inserted replaced
52957:717a23e14586 52958:5a77edcdbe54
    69     (term list list * (string * typ) list list) * Proof.context
    69     (term list list * (string * typ) list list) * Proof.context
    70   val retype_free: typ -> term -> term
    70   val retype_free: typ -> term -> term
    71   val variant_types: string list -> sort list -> Proof.context ->
    71   val variant_types: string list -> sort list -> Proof.context ->
    72     (string * sort) list * Proof.context
    72     (string * sort) list * Proof.context
    73   val variant_tfrees: string list -> Proof.context -> typ list * Proof.context
    73   val variant_tfrees: string list -> Proof.context -> typ list * Proof.context
       
    74   val base_name_of_typ: typ -> string
       
    75 
    74   val nonzero_string_of_int: int -> string
    76   val nonzero_string_of_int: int -> string
    75 
    77 
    76   val num_binder_types: typ -> int
    78   val num_binder_types: typ -> int
    77   val strip_typeN: int -> typ -> typ list * typ
    79   val strip_typeN: int -> typ -> typ list * typ
    78 
    80 
   397   in (tfrees, ctxt') end;
   399   in (tfrees, ctxt') end;
   398 
   400 
   399 fun variant_tfrees ss =
   401 fun variant_tfrees ss =
   400   apfst (map TFree) o
   402   apfst (map TFree) o
   401     variant_types (map (ensure_prefix "'") ss) (replicate (length ss) HOLogic.typeS);
   403     variant_types (map (ensure_prefix "'") ss) (replicate (length ss) HOLogic.typeS);
       
   404 
       
   405 fun add_components_of_typ (Type (s, Ts)) =
       
   406     fold add_components_of_typ Ts #> cons (Long_Name.base_name s)
       
   407   | add_components_of_typ (TFree (s, _)) = cons s
       
   408   | add_components_of_typ (TVar ((s, _), _)) = cons s
       
   409   | add_components_of_typ _ = I;
       
   410 
       
   411 fun base_name_of_typ T = space_implode "_" (add_components_of_typ T []);
   402 
   412 
   403 
   413 
   404 (** Types **)
   414 (** Types **)
   405 
   415 
   406 (*stolen from ~~/src/HOL/Tools/Nitpick/nitpick_hol.ML*)
   416 (*stolen from ~~/src/HOL/Tools/Nitpick/nitpick_hol.ML*)