188.8.131.52 Standard Order of Terms
These predicates use a standard total order when comparing terms. The
standard total order is:
- Variables, by age (oldest first—the order is not related
to the names of variables).
- Floats, in numeric order (e.g. -1.0 is put before 1.0).
- Integers, in numeric order (e.g. -1 is put before 1).
- Atoms, in alphabetical (i.e. character code) order.
- Compound terms, ordered first by arity, then by the name of
the principal functor, then by age for mutables and by the
arguments in left-to-right order for other terms. Recall
that lists are equivalent to compound terms with principal
For example, here is a list of terms in standard order:
[ X, -1.0, -9, 1, fie, foe, X = Y, foe(0,2), fie(1,1,1) ]
Please note: the standard order is only well-defined for finite (acyclic)
terms. There are infinite (cyclic) terms for which no order
relation holds. Furthermore, blocking goals
(see ref-sem-sec) on variables or modifying their attributes
(see lib-atts) does not preserve their order.
The predicates for comparison of terms are described below.
- T1 and T2 are
literally identical (in particular, variables in equivalent positions in
the two terms must be identical).
- T1 and T2 are
not literally identical.
- T1 is before term T2 in the standard order.
- T1 is after term T2
- T1 is not after term T2
- T1 is not before term T2
- the result of comparing terms T1 and T2 is Op, where
the possible values for Op are:
- if T1 is identical to T2,
- if T1 is before T2 in the standard order,
- if T1 is after T2 in the standard order.
Send feedback on this subject.