src/Pure/term.ML
changeset 18149 c6899e23b5ff
parent 18131 8c3089df74ba
child 18183 a9f67248996a
equal deleted inserted replaced
18148:7921f41165cf 18149:c6899e23b5ff
    73   val fold_term_types: (term -> typ -> 'a -> 'a) -> term -> 'a -> 'a
    73   val fold_term_types: (term -> typ -> 'a -> 'a) -> term -> 'a -> 'a
    74   val fold_types: (typ -> 'a -> 'a) -> term -> 'a -> 'a
    74   val fold_types: (typ -> 'a -> 'a) -> term -> 'a -> 'a
    75   val add_term_names: term * string list -> string list
    75   val add_term_names: term * string list -> string list
    76   val add_term_varnames: term -> indexname list -> indexname list
    76   val add_term_varnames: term -> indexname list -> indexname list
    77   val term_varnames: term -> indexname list
    77   val term_varnames: term -> indexname list
       
    78   val find_free: term -> string -> term option
    78   val aconv: term * term -> bool
    79   val aconv: term * term -> bool
    79   val aconvs: term list * term list -> bool
    80   val aconvs: term list * term list -> bool
    80   structure Vartab: TABLE
    81   structure Vartab: TABLE
    81   structure Typtab: TABLE
    82   structure Typtab: TABLE
    82   structure Termtab: TABLE
    83   structure Termtab: TABLE
   498 
   499 
   499 (*collect variable names*)
   500 (*collect variable names*)
   500 val add_term_varnames = fold_aterms (fn Var (xi, _) => insert (op =) xi | _ => I);
   501 val add_term_varnames = fold_aterms (fn Var (xi, _) => insert (op =) xi | _ => I);
   501 fun term_varnames t = add_term_varnames t [];
   502 fun term_varnames t = add_term_varnames t [];
   502 
   503 
       
   504 fun find_free t x =
       
   505   let
       
   506     exception Found of term;
       
   507     fun find (t as Free (x', _)) = if x = x' then raise Found t else I
       
   508       | find _ = I;
       
   509   in (fold_aterms find t (); NONE) handle Found v => SOME v end;
       
   510 
       
   511 
   503 
   512 
   504 (** Comparing terms, types, sorts etc. **)
   513 (** Comparing terms, types, sorts etc. **)
   505 
   514 
   506 (* fast syntactic comparison *)
   515 (* fast syntactic comparison *)
   507 
   516