Predefined operators according to ISO/IEC 13211-1 and 13211-2:
|700||xfx||Arithmetic evaluation and comparison|
|200||xfy||Variable quantification, integer power|
|200||fy||Arithmetic identity, negation ; bitwise complement|
Many systems provide further operators as an implementation specific extension:
In Prolog, custom operators can be defined using
op(+Precedence, +Type, :Operator)
Declares Operator to be an operator of a Type with a Precedence. Operator can also be a list of names in which case all elements of the list are declared to be identical operators.
Precedence is an integer between 0 and 1200, where 0 removes the declaration.
Type is one of:
f indicates the position of the functor and
y indicate the positions of the arguments.
y denotes a term with a precedence lower or equal to the precedence of the functor, whereas
x denotes a strictly lower precedence.
:- op(900, xf, is_true). X_0 is_true :- X_0.
?- dif(X, a) is_true. dif(X, a).
Two terms may be compared via the standard ordering:
variables @< numbers @< atoms @< strings @< structures @< lists
Structures compare alphabetically by functor first, then by arity and lastly by the comparison of each argument.
Lists compare by length first, then by each element.
|Order operator||Succeeds if|
|X @< Y||X is less than Y in the standard order|
|X @> Y||X is greater than Y in the standard order|
|X @=< Y||X is less than or equal to Y in the standard order|
|X @>= Y||X is greater than or equal to Y in the standard order|
?- alpha @< beta. true. ?- alpha(1) @< beta. false. ?- alpha(X) @< alpha(1). true. ?- alpha(X) @=< alpha(Y). true. ?- alpha(X) @> alpha(Y). false. ?- compound(z) @< compound(inner(a)). true.
|Equality operator||Succeeds if|
|X = Y||X can be unified with Y|
|X \= Y||X cannot be unified with Y|
|X == Y||X and Y are identical (i.e. they unify with no variable bindings occurring)|
|X \== Y||X and Y are not identical|
|X =:= Y||X and Y are arithmetically equal|
|X =\= Y||X and Y are not arithmetically equal|