In the DEC-10 Prolog family, if an object is referred to by a name starting with a capital letter then the object has the status of a logical variable. In the above rule there are two references to X. All this means is that the two references are to the same object ---whatever that object is.
is that two uses of an identical name for a logical variable
only refer to the same object if the uses are within a single clause.
happy(X):-the two references to X in the first clause do not refer to the same object as the references to X in the second clause. By the way, this example is a sort that is discussed in section 2.11.
Do not assume that the word logical is redundant. It is used to distinguish between the nature of the variable as used in predicate calculus and the variable used in imperative languages like BASIC, FORTRAN, ALGOL and so on. In those languages, a variable name indicates a storage location which may `contain' different values at different moments in the execution of the program.
Although this needs some further comments, it is probably better to start with this statement and qualify it later.
For example, in Pascal:X:= 1; X:= 2;results in the assignment of 2 to X. In Prolog, once a logical variable has a value, then it cannot be assigned a different one. The logical statementX=1 X=2cannot be true as X cannot be both `2' and `1' simultaneously. An attempt to make a logical variable take a new value will fail.