src/Pure/old_term.ML
author wenzelm
Wed, 31 Dec 2008 15:30:10 +0100
changeset 29269 5c25a2012975
parent 29262 3ee4656b9e0c
child 29270 0eade173f77e
permissions -rw-r--r--
moved term order operations to structure TermOrd (cf. Pure/term_ord.ML); tuned signature of structure Term;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29262
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/old_term.ML
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
     3
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
     4
Some old-style term operations.
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
     5
*)
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
     6
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
     7
signature OLD_TERM =
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
     8
sig
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
     9
  val add_term_vars: term * term list -> term list
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    10
  val term_vars: term -> term list
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    11
  val add_term_frees: term * term list -> term list
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    12
  val term_frees: term -> term list
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    13
end;
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    14
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    15
structure OldTerm: OLD_TERM =
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    16
struct
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    17
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    18
(*Accumulates the Vars in the term, suppressing duplicates*)
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    19
fun add_term_vars (t, vars: term list) = case t of
29269
5c25a2012975 moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents: 29262
diff changeset
    20
    Var   _ => OrdList.insert TermOrd.term_ord t vars
29262
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    21
  | Abs (_,_,body) => add_term_vars(body,vars)
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    22
  | f$t =>  add_term_vars (f, add_term_vars(t, vars))
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    23
  | _ => vars;
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    24
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    25
fun term_vars t = add_term_vars(t,[]);
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    26
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    27
(*Accumulates the Frees in the term, suppressing duplicates*)
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    28
fun add_term_frees (t, frees: term list) = case t of
29269
5c25a2012975 moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents: 29262
diff changeset
    29
    Free   _ => OrdList.insert TermOrd.term_ord t frees
29262
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    30
  | Abs (_,_,body) => add_term_frees(body,frees)
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    31
  | f$t =>  add_term_frees (f, add_term_frees(t, frees))
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    32
  | _ => frees;
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    33
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    34
fun term_frees t = add_term_frees(t,[]);
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    35
3ee4656b9e0c Some old-style term operations.
wenzelm
parents:
diff changeset
    36
end;