What is Unification?
Let Ψ1 = King(x), Ψ2 = King(John), Substitution θ = {John/x} is a unifier for these atoms and applying this substitution, and both expressions will be identical.
E.g. Let's say there are two different expressions, P(x, y), and P(a, f(z)). In this example, we need to make both above statements identical to each other. For this, we will perform the substitution. P(x, y)......... (i)
Conditions for Unification:Following are some basic conditions for unification:
Unification Algorithm:Algorithm: Unify(Ψ1, Ψ2) Step. 1: If Ψ1 or Ψ2 is a variable or constant, then: a) If Ψ1 or Ψ2 are identical, then return NIL. b) Else if Ψ1is a variable, a. then if Ψ1 occurs in Ψ2, then return FAILURE b. Else return { (Ψ2/ Ψ1)}. c) Else if Ψ2 is a variable, a. If Ψ2 occurs in Ψ1 then return FAILURE, b. Else return {( Ψ1/ Ψ2)}. d) Else return FAILURE. Step.2: If the initial Predicate symbol in Ψ1 and Ψ2 are not same, then return FAILURE. Step. 3: IF Ψ1 and Ψ2 have a different number of arguments, then return FAILURE. Step. 4: Set Substitution set(SUBST) to NIL. Step. 5: For i=1 to the number of elements in Ψ1. a) Call Unify function with the ith element of Ψ1 and ith element of Ψ2, and put the result into S. b) If S = failure then returns Failure c) If S ≠ NIL then do, a. Apply S to the remainder of both L1 and L2. b. SUBST= APPEND(S, SUBST). Step.6: Return SUBST. Implementation of the AlgorithmStep.1: Initialize the substitution set to be empty. Step.2: Recursively unify atomic sentences:
For each pair of the following atomic sentences find the most general unifier (If exist). 1. Find the MGU of {p(f(a), g(Y)) and p(X, X)} Sol: S0 => Here, Ψ1 = p(f(a), g(Y)), and Ψ2 = p(X, X) Unification is not possible for these expressions. 2. Find the MGU of {p(b, X, f(g(Z))) and p(Z, f(Y), f(Y))} Here, Ψ1 = p(b, X, f(g(Z))) , and Ψ2 = p(Z, f(Y), f(Y)) S1 => { p(b, X, f(g(b))); p(b, f(Y), f(Y))} S2 => { p(b, f(Y), f(g(b))); p(b, f(Y), f(Y))} S2 => { p(b, f(g(b)), f(g(b)); p(b, f(g(b)), f(g(b))} Unified Successfully. 3. Find the MGU of {p (X, X), and p (Z, f(Z))} Here, Ψ1 = {p (X, X), and Ψ2 = p (Z, f(Z)) Hence, unification is not possible for these expressions. 4. Find the MGU of UNIFY(prime (11), prime(y)) Here, Ψ1 = {prime(11) , and Ψ2 = prime(y)} S1 => {prime(11) , prime(11)} , Successfully unified. 5. Find the MGU of Q(a, g(x, a), f(y)), Q(a, g(f(b), a), x)} Here, Ψ1 = Q(a, g(x, a), f(y)), and Ψ2 = Q(a, g(f(b), a), x) SUBST θ= {b/y} Unifier: [a/a, f(b)/x, b/y]. 6. UNIFY(knows(Richard, x), knows(Richard, John)) Here, Ψ1 = knows(Richard, x), and Ψ2 = knows(Richard, John) Next TopicResolution in FOL |