word looked up : home / archive

 Unification 

The concept of unification is one of the main ideas behind Prolog. It represents the mechanism of binding the contents of variables and can be viewed as a kind of one-time assignment. In Prolog, this operation is denoted by symbol "=".

  1. An uninstantiated variable X (i.e. no previous unification were performed on it) can be unified with an uninstantiated variable (and effectively becomes its alias), an atom or a term.
  2. An atom can be unified only with the same atom.
  3. A term is unified with another term, if the heads and arities of the terms are identic and the parameters are unified (note that this is a recursive behaviour).

Due to its declarative nature, the order in a sequence of unifications doesn't play (usually) any role.

Examples of unification

A=A
Succeeds (tautology)
A=B, B=abc
Both A and B are unified with the atom abc
xyz=C, C=D
Unification is symmetric
abc=abc
Unification succeeds
abc=xyz
Fails to unify, atoms are different
f(A)=f(B)
A is unified with B
f(A)=g(B)
Fails, the heads of terms are different
f(A)=f(B,C)
Fails to unify, because terms have different arity
f(g(A))=f(B)
Unifies B with the term g(A)
f(g(A), A)=f(B, xyz)
Unifies A with the atom xyz and B with the term g(xyz)
A=f(A)
Infinite unification, A is unified with f(f(f(f(...)))).
A=abc, xyz=X, A=X
Fails to unify; effectively abc=xyz

die of it, the price shall be demanded of thee, and that will be two hands, for thou.html">thou.html">thou.html">thou.html">thou.html">thou hast taken from me the thing that in this world.html">world.html">world captive that I did bring from a strange country. Yea, I bought her her, and made her my daughter in go/go.html">go/go.html">go/go.html">go/god.html">God. And I have cherished her, and bread honourably. With this hast thou naught to make, but do thou deem thee to have gained, hadst thou made her thy leman, and taken for in Hell would thy soul have lain while the world endures, and only to have Nicolete, my sweet lady that I love.html">love so well.html">well. For into these same old priests, and halt old men and maimed, who all day and such folk as wear old amices and old clouted frocks, and naked folk thirst, and of cold, and of little ease. These be they that go into fain go; for into Hell fare the goodly clerks, and goodly knights men noble. With these would I liefly go. And thither pass the lords also thereto. Thither goes the gold, and the silver, and prince of this world. With these I would gladly go, let me but have never shalt thou see her; and if thou hadst word with her, and thy thyself might well be sore adread." "That is even what irketh me," quoth Aucassin. So he went from the Here singeth one: Much in dole and heavy at heart None might bring him any cheer, To the palace doth he fare Passeth to a chamber there, For his lady and love so fair. "Nicolete how fair art thou, Sweet the mirth of thy replies, Sweet thy lips and sweet thy brow, All for thee I sorrow now, Whence I ne'er may go my ways So say they, speak they, tell they the Tale: .

 On wordlookup.net  

All is still licensed under the GNU FDL.
It uses material from the wikipedia.



logo

navig stuff

home
archive