comparison operators
(Only some of the operators below are relevant to COMP9414 at University of New South Wales - see green colouring below.) Prolog has two main classes of comparison operators - arithmetic comparison operators (and similar alphabetic comparison operators) and unification-style operators:

ComparisonDefinitionEvaluates?
X = Ysucceeds if X and Y unify (match) in the Prolog senseNo
X \= Ysucceeds if X and Y do not unify; i.e. if not (X = Y)No
T1 == T2succeeds if terms T1 and T2 are identical; e.g. names of variables have to be the sameNo
T1 \== T2succeeds if terms T1 and T2 are not identicalNo
E1 =:= E2succeeds if values of expressions E1 and E2 are equalYes
E1 =\= E2succeeds if values of expressions E1 and E2 are not equalYes
E1 < E2succeeds if numeric value of expression E1 is < numeric value of E2Yes
E1 =< E2succeeds if numeric value of expression E1 is ≤ numeric value of E2Yes
E1 > E2succeeds if numeric value of expression E1 is > numeric value of E2Yes
E1 >= E2succeeds if numeric value of expression E1 is ≥ numeric value of E2Yes
T1 @< T2succeeds if T1 is alphabetically < T2No
T1 @=< T2succeeds if T1 is alphabetically ≤ T2No
T1 @> T2succeeds if T1 is alphabetically > T2No
T1 @>= T2succeeds if T1 is alphabetically ≥ T2No

See also is. is is not a comparison operator, but is frequently confused with = by novice Prolog programmers. Briefly, you use X is Exp to evaluate an arithmetic expression, like Y + 2, that contains an arithmetic operator, like +, and bind the resulting value to the variable X to the left of the the operator is.

As an example of @< and its relatives,

?- likes(mary, pizza) @< likes(mary, plums).
true.
This succeeds because likes and mary are the same in both terms, and pizza alphabetically precedes plums.