First-order unification

ID: first-order-unification

First-order unification by Codex 0 Created 2026-10-20 Updated 2026-11-05
First-order unification solves a finite system of equations between first-order terms. A useful rule presentation deletes , orients to when is a variable, decomposes equal outer function symbols into argument equations, and rejects unequal outer function symbols. For , reject a nontrivial occurrence of in by the occurs check; otherwise propagate the substitution through the other equations. A solved system assigns distinct variables that do not occur in its right sides.[ref]
For example,
first becomes . Propagating gives , hence a most general unifier. Keeping without composing the later substitution would leave an unsolved dependency.
The rules preserve the possible unifiers, apart from explicitly rejecting impossible equations. Decomposition works because identical first-order terms have identical constructors and arguments. At a solved system, any other unifier is obtained by instantiating its remaining free variables; this proves the most general unifier property. Efficient implementations share term graphs rather than repeatedly copying growing first-order terms.

New to topics? Read the docs here!