- Any value can be unified with itself. (This is normally
useful only as a test.)
mother(john) = mother(john).
- A variable can be unified with another variable. The two variable
names thereafter reference the same variable.
X = Y, X = 2, write(Y). /* Writes the value 2. */
- A variable can be unified with any Prolog value; this is called
instantiating the variable. A variable is fully
instantiated if it is unified with a value that does not itself
X = foo(bar, [1, 2, 3]). /* X is fully instantiated. */
Pa = husband(Ma). /* Pa is partially instantiated. */
- Two different values can be unified if there are unifications for
the constituent variables which make the values the same.
mother(mary, X) = mother(Y, father(Z)).
[Also results in the unifications
- It is legal to unify a variable with an expression containing
itself; however, the resultant value cannot be printed, and must
otherwise be handled with extreme care.
X = foo(X, Y).