Some examples:
Everything must be known at the time of evaluation:
?- 2*2 =:= X. ERROR: Arguments are not sufficiently instantiated ?- X=4.0, 2*2 =:= X. X = 4.0. ?- cos(X) =\= sin(X). ERROR: Arguments are not sufficiently instantiated % Ok, then! ?- X=pi, cos(X) =\= sin(X). X = pi.
Sadly =:= is a bit fussy. It shouldn't even worry about X here:
?- X*0+1 =:= 1.0. ERROR: Arguments are not sufficiently instantiated
However it can deal with subexpressions:
?- X=(1+1), X*2 =:= 4.0. X = 1+1.
"is" can do that too:
?- X=(1+1), Y is X*2. X = 1+1, Y = 4.
Differences in arithmetic type (https://eu.swi-prolog.org/pldoc/man?section=artypes) don't matter.
?- 4 =:= 4. true. ?- 4 =:= 4.0. true.
This works even for rational numbers (https://www.swi-prolog.org/pldoc/man?section=rational):
?- X=1/7, X =:= 2/14. X = 1/7.
Evaluation occurs on both sides:
?- 1*10 =:= 2+3+5. true. ?- sqrt(2.0) =:= sqrt(4.0/2) true.
The constant "epsilon" is the machine epsilon (https://en.wikipedia.org/wiki/Machine_epsilon) and reveals floating point limitations:
?- 1.0 =:= 1.0 + 0.5*epsilon. true.