[ Comparing and Sorting | Reference Manual | Alphabetic Index ]

# ?Term1 ~= ?Term2

The sound difference operator. Succeeds if the two terms cannot be unified, fails if they are identical, otherwise it delays.

Term1
  Any term.
Term2
  Any term.

## Description

If Term1 cannot be unified with Term2 it succeeds. If the two terms are unifiable but not identical, the predicate delays since it cannot yet decide whether the terms are different or not.

### Modes and Determinism

- ~=(?, ?) is semidet

### Fail Conditions

Fails if Term1 and Term2 are identical in the sense of ==/2.

## Examples

    Success:
        3 ~= 4.
        3 ~= X,                (delays ...
            X = 4.             ... then succeeds and gives X = 4)

    Note the nonlogical behaviour of negation as failure:
        3 \= X,                (fails ...
            X = 4.             ... and this is not recognized)

    Fail:
        3 ~= 3.
        s(X,Y) ~= s(X,Y).
        s(X,Y) ~= s(X,Z),        (delays ...
             Z = Y.             ... then fails)

## See Also

\= / 2, \== / 2, == / 2, ~ / 1