$=P
Built-in arithmetic
Prolog has several predefined numerical operators and relations.
They include addition, subtraction, multiplication, division and
the modulus giving the remainder of an integer division.
Implementations may disagree on what symbols are used, but generally the operator
is used for addition, etc.
In most Prolog systems, arithmetical expressions are not evaluated.\ftn{
In our implementation of Prolog that is used to implement DLP,
arithmetical expressions are automatically evaluated.
Also, our notation of the arithmetical operators and relations differs somewhat
from the notation encountered in for instance C-Prolog.
}
To evaluate such expressions the system-predicate is is provided.
As an example of its use, consider the goal
\prologindex{{\em is}}
\prologindex{arithmetic}
?- X is 2 * 2 + 3.
Evaluating this goal results in binding X to 7.
For being able to compare numerical values, Prolog provides a number
of relational operators such as the less-than operator .
Also an operator to test the inequality of two terms is provided.
We will write this operator as in
?- X != 7.
This goal tests if the value of X is unequal to 7.
The inequality operator can be used to test the syntactic (equality)
of arbitrary terms.
Recall that the equality operator results in unifying two terms.
So, the goal
?- X = 2 + 3.
results in unifying X with the expression $2 + 3