src/Pure/term.ML
changeset 19014 f70ced571ba8
parent 18995 ff4e4773cc7c
child 19065 82e2d66f995b
equal deleted inserted replaced
19013:19ad0c59fb1f 19014:f70ced571ba8
   188     -> term -> term
   188     -> term -> term
   189   val instantiateT: ((indexname * sort) * typ) list -> typ -> typ
   189   val instantiateT: ((indexname * sort) * typ) list -> typ -> typ
   190   val maxidx_typ: typ -> int -> int
   190   val maxidx_typ: typ -> int -> int
   191   val maxidx_typs: typ list -> int -> int
   191   val maxidx_typs: typ list -> int -> int
   192   val maxidx_term: term -> int -> int
   192   val maxidx_term: term -> int -> int
       
   193   val variant_name: (string -> bool) -> string -> string
   193   val invent_names: string list -> string -> int -> string list
   194   val invent_names: string list -> string -> int -> string list
   194   val dest_abs: string * typ * term -> string * term
   195   val dest_abs: string * typ * term -> string * term
   195   val bound: int -> string
   196   val bound: int -> string
   196   val is_bound: string -> bool
   197   val is_bound: string -> bool
   197   val zero_var_indexesT: typ -> typ
   198   val zero_var_indexesT: typ -> typ
  1056 
  1057 
  1057 (**** Syntax-related declarations ****)
  1058 (**** Syntax-related declarations ****)
  1058 
  1059 
  1059 (*** Printing ***)
  1060 (*** Printing ***)
  1060 
  1061 
  1061 (*Makes a variant of a name distinct from the names in 'used'.
  1062 (*Makes a variant of a name distinct from already used names.  First
  1062   First attaches the suffix and then increments this;
  1063   attaches the suffix and then increments this; preserves a suffix of
  1063   preserves a suffix of underscores "_". *)
  1064   underscores "_". *)
  1064 fun variant used name =
  1065 fun variant_name used name =
  1065   let
  1066   let
  1066     val (c, u) = pairself implode (Library.take_suffix (equal "_") (Symbol.explode name));
  1067     val (c, u) = pairself implode (Library.take_suffix (fn s => s = "_") (Symbol.explode name));
  1067     fun vary2 c = if ((c ^ u) mem_string used) then vary2 (Symbol.bump_string c) else c;
  1068     fun vary2 c = if used (c ^ u) then vary2 (Symbol.bump_string c) else c;
  1068     fun vary1 c = if ((c ^ u) mem_string used) then vary2 (Symbol.bump_init c) else c;
  1069     fun vary1 c = if used (c ^ u) then vary2 (Symbol.bump_init c) else c;
  1069   in vary1 (if c = "" then "u" else c) ^ u end;
  1070   in vary1 (if c = "" then "u" else c) ^ u end;
       
  1071 
       
  1072 fun variant used_names = variant_name (member (op =) used_names);
  1070 
  1073 
  1071 (*Create variants of the list of names, with priority to the first ones*)
  1074 (*Create variants of the list of names, with priority to the first ones*)
  1072 fun variantlist ([], used) = []
  1075 fun variantlist ([], used) = []
  1073   | variantlist(b::bs, used) =
  1076   | variantlist(b::bs, used) =
  1074       let val b' = variant used b
  1077       let val b' = variant used b