Comparing terms

Author(s): Daniel Cabeza, Manuel Hermenegildo.

These built-in predicates are extra-logical. They treat uninstantiated variables as objects with values which may be compared, and they never instantiate those variables. They should not be used when what you really want is arithmetic comparison or unification.

The predicates make reference to a standard total ordering of terms, which is as follows:

  • Variables, by age (roughly, 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 the arguments in left-to-right order. Recall that lists are equivalent to compound terms with principal functor '.'/2.

For example, here is a list of terms in standard order:

[ X, -1.0, -9, 1, bar, foo, [1], X = Y, foo(0,2), bar(1,1,1) ]

Usage and interface

Documentation on exports

PROPERTY==/2

Usage:Term1==Term2

The terms Term1 and Term2 are strictly identical.

    Other properties:
    Term1==Term2

    Term1==Term2

    • If the following properties hold at call time:
      (term_typing:ground/1)Term1 is currently ground (it contains no variables).
      (term_typing:ground/1)Term2 is currently ground (it contains no variables).
      then the following properties hold globally:
      (basic_props:eval/1)Term1==Term2 is evaluable at compile-time.
    Term1==Term2

    • The following properties hold globally:
      (native_props:is_det/1)All calls of the form Term1==Term2 are deterministic.
      (native_props:test_type/2)Indicates the type of test that a predicate performs. Required by the nonfailure analyisis.

    PREDICATE\==/2

    Usage:Term1\==Term2

    The terms Term1 and Term2 are not strictly identical.

    Other properties:
    Term1\==Term2

    • If the following properties hold at call time:
      (term_typing:ground/1)Term1 is currently ground (it contains no variables).
      (term_typing:ground/1)Term2 is currently ground (it contains no variables).
      then the following properties hold globally:
      (basic_props:eval/1)Term1\==Term2 is evaluable at compile-time.
    Term1\==Term2

    • The following properties hold globally:
      (native_props:is_det/1)All calls of the form Term1\==Term2 are deterministic.
      (native_props:test_type/2)Indicates the type of test that a predicate performs. Required by the nonfailure analyisis.

    PREDICATE@</2

    Usage:Term1@<Term2

    The term Term1 precedes the term Term2 in the standard order.

    Other properties:
    Term1@<Term2

    • If the following properties hold at call time:
      (term_typing:ground/1)Term1 is currently ground (it contains no variables).
      (term_typing:ground/1)Term2 is currently ground (it contains no variables).
      then the following properties hold globally:
      (basic_props:eval/1)Term1@<Term2 is evaluable at compile-time.

    PREDICATE@=</2

    Usage:Term1@=<Term2

    The term Term1 precedes or is identical to the term Term2 in the standard order.

    Other properties:
    Term1@=<Term2

    • If the following properties hold at call time:
      (term_typing:ground/1)Term1 is currently ground (it contains no variables).
      (term_typing:ground/1)Term2 is currently ground (it contains no variables).
      then the following properties hold globally:
      (basic_props:eval/1)Term1@=<Term2 is evaluable at compile-time.

    PREDICATE@>/2

    Usage:Term1@>Term2

    The term Term1 follows the term Term2 in the standard order.

    Other properties:
    Term1@>Term2

    • If the following properties hold at call time:
      (term_typing:ground/1)Term1 is currently ground (it contains no variables).
      (term_typing:ground/1)Term2 is currently ground (it contains no variables).
      then the following properties hold globally:
      (basic_props:eval/1)Term1@>Term2 is evaluable at compile-time.

    PREDICATE@>=/2

    Usage:Term1@>=Term2

    The term Term1 follows or is identical to the term Term2 in the standard order.

    Other properties:
    Term1@>=Term2

    • If the following properties hold at call time:
      (term_typing:ground/1)Term1 is currently ground (it contains no variables).
      (term_typing:ground/1)Term2 is currently ground (it contains no variables).
      then the following properties hold globally:
      (basic_props:eval/1)Term1@>=Term2 is evaluable at compile-time.

    PREDICATEcompare/3
    compare(Op,Term1,Term2)

    Op is the result of comparing the terms Term1 and Term2.

    Usage:

    Other properties:
    compare(Op,Term1,Term2)

    • If the following properties hold at call time:
      (term_typing:ground/1)Term1 is currently ground (it contains no variables).
      (term_typing:ground/1)Term2 is currently ground (it contains no variables).
      then the following properties hold globally:
      (basic_props:eval/1)compare(Op,Term1,Term2) is evaluable at compile-time.

    A regular type, defined as follows:
    comparator(=).
    comparator(>).
    comparator(<).
    

    Documentation on imports

    This module has the following direct dependencies: