Unification in First-Order Logic (FOL) is a key process that makes two logical atomic expressions identical through substitution. The UNIFY algorithm matches two atomic sentences by finding a suitable substitution, or it fails if they don't match. Essential conditions for unification in First-Order Logic (FOL) include identical predicate symbols and the same number of arguments in both expressions. The Most General Unifier (MGU) is the simplest substitution that achieves this match. For example, UNIFY{King(x), King(John)} results in {x/John}, successfully unifying the expressions. Understanding unification in First-Order Logic (FOL) and mastering the UNIFY algorithm are crucial for effective logical inference in FOL.
Unification in First-Order Logic (FOL) is a crucial process that makes two different logical atomic expressions identical by finding a suitable substitution. This process relies on substitution, where variables in the expressions are replaced to achieve uniformity.
Unification takes two literals as input and attempts to make them identical through substitution. Formally, let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such that Ψ1𝜎 = Ψ2𝜎. This can be expressed as UNIFY(Ψ1, Ψ2).
Let's find the Most General Unifier (MGU) for the following expressions:
UNIFY{King(x), King(John)}
Given:
The goal is to find a substitution 𝜎 that makes Ψ1 and Ψ2 identical.
To unify Ψ1 and Ψ2, we can substitute the variable x with the constant John. Therefore, the substitution 𝜎 is {x/John}.
Applying this substitution:
Ψ1𝜎 = King(x){x/John} = King(John)
Ψ2𝜎 = King(John){x/John} = King(John)
Since Ψ1𝜎 = Ψ2𝜎, the unification is successful, and {x/John} is the Most General Unifier (MGU).
Let Ψ1 = King(x), Ψ2 = King(John),
Substitution θ = {John/x} is a unifier for these atoms, and applying this substitution, both expressions will be identical.
The UNIFY algorithm is used for unification. It takes two atomic sentences and returns a unifier for those sentences (if any exist). Unification is a key component of all first-order inference algorithms. It returns fail if the expressions do not match. The substitution variables are called the Most General Unifier or MGU.
Consider two different expressions, P(x, y)
and P(a, f(z))
.
To make both statements identical, we will perform the necessary substitution.
In summary, unification in FOL is the process of making two atomic expressions identical by finding appropriate substitutions, ensuring that the expressions can be matched or unified.
Here are some basic conditions that must be met for unification:
Algorithm: Unify(Ψ1, Ψ2)
vi
and the other is a term ti
that does not contain the variable vi
, then:ti / vi
in the existing substitutions.ti / vi
to the substitution set.Here, Ψ1 = p(f(a), g(Y))
and Ψ2 = p(X, X)
Step 1: Substitute X
with f(a)
SUBST θ = {f(a) / X
}
Step 2: Now Ψ1 = p(f(a), g(Y))
and Ψ2 = p(f(a), f(a))
Unification fails because g(Y)
cannot be unified with f(a)
.
Result: Unification is not possible for these expressions.
Here, Ψ1 = p(b, X, f(g(Z)))
and Ψ2 = p(Z, f(Y), f(Y))
Step 1: Substitute Z
with b
SUBST θ = {b / Z
}
Step 2: Now Ψ1 = p(b, X, f(g(b)))
and Ψ2 = p(b, f(Y), f(Y))
Substitute X
with f(Y)
SUBST θ = {f(Y) / X
}
Step 3: Now Ψ1 = p(b, f(Y), f(g(b)))
and Ψ2 = p(b, f(Y), f(Y))
Substitute Y
with g(b)
SUBST θ = {g(b) / Y
}
Result: Successfully unified. Unifier = {b / Z, f(Y) / X, g(b) / Y
}.
Here, Ψ1 = p(X, X)
and Ψ2 = p(Z, f(Z))
Step 1: Substitute X
with Z
SUBST θ = {X / Z
}
Step 2: Now Ψ1 = p(Z, Z)
and Ψ2 = p(Z, f(Z))
Unification fails because Z
cannot be unified with f(Z)
.
Result: Unification is not possible for these expressions.
Here, Ψ1 = prime(11)
and Ψ2 = prime(y)
Step 1: Substitute y
with 11
SUBST θ = {11 / y
}
Result: Successfully unified. Unifier = {11 / y
}.
Here, Ψ1 = Q(a, g(x, a), f(y))
and Ψ2 = Q(a, g(f(b), a), x)
Step 1: Substitute x
with f(b)
SUBST θ = {f(b) / x
}
Step 2: Now Ψ1 = Q(a, g(f(b), a), f(y))
and Ψ2 = Q(a, g(f(b), a), f(b))
Substitute y
with b
SUBST θ = {b / y
}
Result: Successfully unified. Unifier = {f(b) / x, b / y
}.
Here, Ψ1 = knows(Richard, x)
and Ψ2 = knows(Richard, John)
Step 1: Substitute x
with John
SUBST θ = {John / x
}
Result: Successfully unified. Unifier = {John / x
}.