29262
|
1 |
(* Title: Pure/old_term.ML
|
|
2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
3 |
|
|
4 |
Some old-style term operations.
|
|
5 |
*)
|
|
6 |
|
|
7 |
signature OLD_TERM =
|
|
8 |
sig
|
|
9 |
val add_term_vars: term * term list -> term list
|
|
10 |
val term_vars: term -> term list
|
|
11 |
val add_term_frees: term * term list -> term list
|
|
12 |
val term_frees: term -> term list
|
|
13 |
end;
|
|
14 |
|
|
15 |
structure OldTerm: OLD_TERM =
|
|
16 |
struct
|
|
17 |
|
|
18 |
(*Accumulates the Vars in the term, suppressing duplicates*)
|
|
19 |
fun add_term_vars (t, vars: term list) = case t of
|
|
20 |
Var _ => OrdList.insert Term.term_ord t vars
|
|
21 |
| Abs (_,_,body) => add_term_vars(body,vars)
|
|
22 |
| f$t => add_term_vars (f, add_term_vars(t, vars))
|
|
23 |
| _ => vars;
|
|
24 |
|
|
25 |
fun term_vars t = add_term_vars(t,[]);
|
|
26 |
|
|
27 |
(*Accumulates the Frees in the term, suppressing duplicates*)
|
|
28 |
fun add_term_frees (t, frees: term list) = case t of
|
|
29 |
Free _ => OrdList.insert Term.term_ord t frees
|
|
30 |
| Abs (_,_,body) => add_term_frees(body,frees)
|
|
31 |
| f$t => add_term_frees (f, add_term_frees(t, frees))
|
|
32 |
| _ => frees;
|
|
33 |
|
|
34 |
fun term_frees t = add_term_frees(t,[]);
|
|
35 |
|
|
36 |
end;
|