Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Unification (computer science)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Examples of syntactic unification of first-order terms=== In the Prolog syntactical convention a symbol starting with an upper case letter is a variable name; a symbol that starts with a lowercase letter is a function symbol; the comma is used as the logical ''and'' operator. For mathematical notation, ''x,y,z'' are used as variables, ''f,g'' as function symbols, and ''a,b'' as constants. {| class="wikitable" |- ! Prolog notation !! Mathematical notation !! Unifying substitution !! Explanation |- | <code> a = a </code> || { ''a'' = ''a'' } || {} || Succeeds. ([[Tautology (logic)|tautology]]) |- | <code> a = b </code> || { ''a'' = ''b'' } || β₯ || ''a'' and ''b'' do not match |- | <code> X = X </code> || { ''x'' = ''x'' } || {} || Succeeds. ([[Tautology (logic)|tautology]]) |- | <code> a = X </code> || { ''a'' = ''x'' } || { ''x'' β¦ ''a'' } || ''x'' is unified with the constant ''a'' |- | <code> X = Y </code> || { ''x'' = ''y'' } || { ''x'' β¦ ''y'' } || ''x'' and ''y'' are aliased |- | <code> f(a,X) = f(a,b) </code> || { ''f''(''a'',''x'') = ''f''(''a'',''b'') } || { ''x'' β¦ ''b'' } || function and constant symbols match, ''x'' is unified with the constant ''b'' |- | <code> f(a) = g(a) </code> || { ''f''(''a'') = ''g''(''a'') } || β₯ || ''f'' and ''g'' do not match |- | <code> f(X) = f(Y) </code> || { ''f''(''x'') = ''f''(''y'') } || { ''x'' β¦ ''y'' } || ''x'' and ''y'' are aliased |- | <code> f(X) = g(Y) </code> || { ''f''(''x'') = ''g''(''y'') } || β₯ || ''f'' and ''g'' do not match |- | <code> f(X) = f(Y,Z) </code> || { ''f''(''x'') = ''f''(''y'',''z'') } || β₯ || Fails. The ''f'' function symbols have different arity |- | <code> f(g(X)) = f(Y) </code> || { ''f''(''g''(''x'')) = ''f''(''y'') } || { ''y'' β¦ ''g''(''x'') } || Unifies ''y'' with the term {{tmath|g(x)}} |- | <code> f(g(X),X) = f(Y,a) </code> || { ''f''(''g''(''x''),''x'') = ''f''(''y'',''a'') } || { ''x'' β¦ ''a'', ''y'' β¦ ''g''(''a'') } || Unifies ''x'' with constant ''a'', and ''y'' with the term {{tmath|g(a)}} |- | <code> X = f(X) </code> || { ''x'' = ''f''(''x'') } || should be β₯ || Returns β₯ in first-order logic and many modern Prolog dialects (enforced by the ''[[occurs check]]''). Succeeds in traditional Prolog and in Prolog II, unifying ''x'' with infinite term <code>x=f(f(f(f(...))))</code>. |- | <code> X = Y, Y = a </code> || { ''x'' = ''y'', ''y'' = ''a'' } || { ''x'' β¦ ''a'', ''y'' β¦ ''a'' } || Both ''x'' and ''y'' are unified with the constant ''a'' |- | <code> a = Y, X = Y </code> || { ''a'' = ''y'', ''x'' = ''y'' } || { ''x'' β¦ ''a'', ''y'' β¦ ''a'' } || As above (order of equations in set doesn't matter) |- | <code> X = a, b = X </code> || { ''x'' = ''a'', ''b'' = ''x'' } || β₯ || Fails. ''a'' and ''b'' do not match, so ''x'' can't be unified with both |} [[File:Unification exponential blow-up svg.svg|thumb|Two terms with an exponentially larger tree for their least common instance. Its [[directed acyclic graph|dag]] representation (rightmost, orange part) is still of linear size.]] The most general unifier of a syntactic first-order unification problem of [[Term (logic)#Operations with terms|size]] {{mvar|n}} may have a size of {{math|2<sup>''n''</sup>}}. For example, the problem {{tmath| (((a*z)*y)*x)*w \doteq w*(x*(y*(z*a))) }} has the most general unifier {{tmath| \{ z \mapsto a, y \mapsto a*a, x \mapsto (a*a)*(a*a), w \mapsto ((a*a)*(a*a))*((a*a)*(a*a)) \} }}, cf. picture. In order to avoid exponential time complexity caused by such blow-up, advanced unification algorithms work on [[directed acyclic graph]]s (dags) rather than trees.{{refn|e.g. {{harvtxt|Paterson|Wegman|1978}} sect.2, p.159}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)