Q: detailed meaning of ?- X is X+1 While studying the language Prolog I found the following true or false question:

In Prolog ?- X is X+1 results in the increment of the variable X by one.

A teacher said it's false, however I don't understand why. Won't X be X+1 from now on? Why is it false?

A: Prolog does not work with variables like elements that can change value. A variable is an element that currently has no value, once it has a value, it cannot change that value (except for backtracking in which the unification is undone).
In case X already has a value, X+1 will be calculated, but you cannot unify 3 with 4:
?- X=3, X is X+1.
false.

In case X is ungrounded at that moment, the is predicate will fail:
?- X is X+1.
ERROR: is/2: Arguments are not sufficiently instantiated

The question probably wants to demonstrate one of the fundamental differences between imperative programming and logic programming: in imperative programming a variable can be assigned a (new) value, in logic programming a variable can only grounded once (except for backtracking). Once fully grounded, you cannot ground it a different way.
