These built-in predicates are meta-logical. They treat uninstantiated variables as objects with values that may be compared, and they never instantiate those variables. They should not be used when what you really want is arithmetic comparison (see Arithmetic) or unification.
The predicates make reference to a standard total ordering of terms, which is as follows:
./2.
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 Procedural) on variables or modifying their attributes (see Attributes) does not preserve their order.
These are the basic predicates for comparison of arbitrary terms:
== Term2 ISO | ?- X == Y.
fails (answers `no') because X and Y are distinct uninstantiated variables. However, the query
| ?- X = Y, X == Y.
succeeds because the first goal unifies the two
variables (see Misc Pred).
\== Term2 ISOThe terms currently instantiating Term1 and
Term2 are not literally identical.
@< Term2 ISO @> Term2 ISO @=< Term2 ISO @>= Term2 ISOSome further predicates involving comparison of terms are:
?=(?X,?Y)compare(?Op,?Term1,?Term2)=<>Thus compare(=,Term1,Term2) is equivalent to
Term1 == Term2.
sort(+List1,?List2)keysort(+List1,?List2)K-A occurs before K-B in the input, then K-A will
occur before K-B in the output. (The time and space complexity
of this operation is at worst O(N lg N) where N is the
length of List1.)