Unification

CS 421

Unification
Published

September 24, 2026

Denote lowercase letters as unification variables. Denote uppercase letters among (F, P, L, N, S) as term constructors with arity 2, 2, 1, 0, 0 respectively.

We will run Unify { ('b = F(N, S)), (P('a, 'c) = P('c, 'b)) }, i.e. we have two constraints. The first asserts that the type variable 'b must be equal to F(N, S). The second asserts that the aggregate of two type variables P('a, 'c) must be equal to the aggregate P('c, 'b). The solution is obviously that

Now, (one instantiation) of steps could be:

And we get a final answer of: {'a -> F(N, S), 'b -> F(N, S), 'c -> F(N, S)}.

As another example, we will run Unify {(F('a,F('b,'b)) = F(P('c,L('c)), F(P('e,L('d)),P('c,'f)))), (P(P(N,'d),'c) = P('a,'c))}, i.e. now with 2 constraints that are more nested.

And we get a final answer of: {'f -> L(L(N)), 'e -> N, 'c -> N, 'b -> P(N, L(L(N))), 'd -> L(N), 'a -> P(N, L(N)) }