src/HOL/BNF/Tools/bnf_util.ML
changeset 54435 4a655e62ad34
parent 54008 b15cfc2864de
child 54540 5d7006e9205e
equal deleted inserted replaced
54434:e275d520f49d 54435:4a655e62ad34
    52     term list list list * Proof.context
    52     term list list list * Proof.context
    53   val mk_Freessss: string -> typ list list list list -> Proof.context ->
    53   val mk_Freessss: string -> typ list list list list -> Proof.context ->
    54     term list list list list * Proof.context
    54     term list list list list * Proof.context
    55   val nonzero_string_of_int: int -> string
    55   val nonzero_string_of_int: int -> string
    56   val retype_free: typ -> term -> term
    56   val retype_free: typ -> term -> term
    57   val typ_subst_nonatomic: (typ * typ) list -> typ -> typ
       
    58 
    57 
    59   val binder_fun_types: typ -> typ list
    58   val binder_fun_types: typ -> typ list
    60   val body_fun_type: typ -> typ
    59   val body_fun_type: typ -> typ
    61   val num_binder_types: typ -> int
    60   val num_binder_types: typ -> int
    62   val strip_fun_type: typ -> typ list * typ
    61   val strip_fun_type: typ -> typ list * typ
   305 fun nonzero_string_of_int 0 = ""
   304 fun nonzero_string_of_int 0 = ""
   306   | nonzero_string_of_int n = string_of_int n;
   305   | nonzero_string_of_int n = string_of_int n;
   307 
   306 
   308 val mk_TFreess = fold_map mk_TFrees;
   307 val mk_TFreess = fold_map mk_TFrees;
   309 
   308 
   310 (*Replace each Ti by Ui (starting from the leaves); inst = [(T1, U1), ..., (Tn, Un)].*)
       
   311 fun typ_subst_nonatomic [] = I
       
   312   | typ_subst_nonatomic inst =
       
   313     let
       
   314       fun subst (Type (s, Ts)) = perhaps (AList.lookup (op =) inst) (Type (s, map subst Ts))
       
   315         | subst T = perhaps (AList.lookup (op =) inst) T;
       
   316     in subst end;
       
   317 
       
   318 fun mk_Freesss x Tsss = fold_map2 mk_Freess (mk_names (length Tsss) x) Tsss;
   309 fun mk_Freesss x Tsss = fold_map2 mk_Freess (mk_names (length Tsss) x) Tsss;
   319 fun mk_Freessss x Tssss = fold_map2 mk_Freesss (mk_names (length Tssss) x) Tssss;
   310 fun mk_Freessss x Tssss = fold_map2 mk_Freesss (mk_names (length Tssss) x) Tssss;
   320 
   311 
   321 fun retype_free T (Free (s, _)) = Free (s, T)
   312 fun retype_free T (Free (s, _)) = Free (s, T)
   322   | retype_free _ t = raise TERM ("retype_free", [t]);
   313   | retype_free _ t = raise TERM ("retype_free", [t]);