A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Most General Unifier (MGU)

College Depth 75 in the knowledge graph I know this Set as goal
2topics build on this
340prerequisites beneath it
See this on the map →
Substitution and UnificationGround Instances and Variable Instantiation
first-order-logic unification automated-reasoning

Core Idea

A substitution θ is a unifier of two terms if θ(s) = θ(t); a most general unifier (MGU) is a unifier such that any other unifier is an instance of it. The MGU, when it exists, is unique up to variable renaming and is the key operation enabling the resolution rule in first-order logic to work effectively.

Explainer

You already know what a substitution is — a mapping from variables to terms — and you know that unification is the process of finding a substitution that makes two terms syntactically identical. For example, the terms f(x, b) and f(a, y) can be unified by the substitution {x ↦ a, y ↦ b}, because applying it gives f(a, b) and f(a, b). But there may be many unifiers: {x ↦ a, y ↦ b, z ↦ c} also works if z doesn't appear in either term. The most general unifier is the one that commits the least — the one that makes the minimum number of additional assignments.

Formally, θ is a most general unifier (MGU) of s and t if (1) θ(s) = θ(t) (it is a unifier), and (2) every other unifier σ factors through θ: there exists a substitution λ such that σ = λ ∘ θ. In other words, any unifier is an "instance" of the MGU obtained by further specializing it. The MGU preserves the most freedom — it unifies just enough and no more. For f(x, b) and f(a, y), the MGU is {x ↦ a, y ↦ b} exactly. A substitution like {x ↦ a, y ↦ b, x ↦ a} with redundant bindings is the same MGU up to trivialities; what you *cannot* have in an MGU is {x ↦ a, y ↦ b, z ↦ c} when z is unconstrained — that adds information not required for unification.

Martelli and Montanari's algorithm (and the earlier Robinson unification algorithm) compute the MGU systematically: decompose the unification problem into a set of equations, repeatedly applying rules like "both terms are the same constant — remove the equation" or "variable x appears on one side — substitute x throughout." The occurs check is the critical safety test: before substituting x ↦ t, verify that x does not appear in t. Without this check, you could create a circular binding like x ↦ f(x), which has no finite solution. With the occurs check, the algorithm terminates and either produces an MGU or reports failure (no unifier exists).

The MGU is the engine of resolution-based theorem proving. The resolution rule takes two clauses, finds a literal in one that is the negation of a literal in the other, and cancels them — but for first-order logic, the two literals may not match syntactically. The MGU bridges this gap: it is the substitution that makes the two literals match, and applying it to the full clauses gives the resolvent. For example, resolving P(x) and ¬P(f(a)) requires unifying x with f(a) via {x ↦ f(a)}, giving the MGU that makes resolution possible. Using the MGU (rather than any specific unifier) ensures the resolvent is as general as possible — no unnecessary commitments about the values of other variables.

The uniqueness property (up to variable renaming) is what makes the MGU well-defined as an algorithm output. There isn't an arbitrary choice being made — the MGU is a canonical object. This is why unification-based inference systems are deterministic in their inference steps, even though they may explore many branches in proof search. Every step in the resolution refutation has a unique MGU, and the proof's correctness doesn't depend on which renaming you use.

Practice Questions 5 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraIntroduction to Propositional LogicIntroduction to Predicate Logic (First-Order Logic)First-Order Logic SyntaxTerms and Atomic Formulas in FOLVariable Binding and ScopeSubstitution and UnificationMost General Unifier (MGU)

Longest path: 76 steps · 340 total prerequisite topics

Prerequisites (1)

Leads To (1)