Every time a statically typed language accepts your code without complaint, a small miracle has just happened. The compiler looked at something like f(x) = x + 1 and silently figured out that must be a number â not because you said so, but because it solved an equation over symbolic expressions. The engine doing that work is unification.
The question unification answers is deceptively simple: given two terms built from function symbols, constants, and variables, is there a way to substitute values for the variables so that the two terms become syntactically identical? Not equal in some deep semantic sense â just letter-for-letter the same.
J. A. Robinson answered that question in 1965 with a clean, recursive algorithm. Feed it f(X, b) and f(a, Y), and it will tell you: substitute X = a and Y = b. That substitution â the most general unifier (MGU) â is the unique most-flexible answer. It commits to as little as possible, leaving variables unbound wherever freedom remains.
The MGU is unique up to renaming variables, so unification has one right answer or none. When no substitution can reconcile two terms they are simply non-unifiable, and the algorithm reports failure cleanly.
Comments
Loading comments...