Availability::- use_module(library(dif)).
(can be autoloaded)
dif(@A, @B)The dif/2
predicate is a constraint that is true if and only if A
and B are different terms. If A and B
can never unify, dif/2
succeeds deterministically. If A and B are
identical, it fails immediately. Finally, if A and B
can unify, goals are delayed that prevent A and B
to become equal. It is this last property that makes dif/2
a more general and more declarative alternative for \=/2
and related predicates.
This predicate behaves as if defined by
dif(X, Y) :- when(?=(X,Y), X \== Y)
. See also ?=/2.
The implementation can deal with cyclic terms.
The dif/2
predicate is realised using attributed variables associated with the
module dif
. It is an autoloaded predicate that is defined
in the library library(dif)
.