- Any value can be unified with itself. (This is normally
useful only as a test.)
Example: mother(john) = mother(john).
- A variable can be unified with another variable. The two variable
names thereafter reference the same variable.
Example: 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
contain variables.
Example: X = foo(bar, [1, 2, 3]). /* X is fully instantiated. */
Example: 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.
Example: mother(mary, X) = mother(Y, father(Z)).
[Also results in the unifications mary=Y
and X=father(Z)
].
- 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.
Example: X = foo(X, Y).