0% found this document useful (0 votes)
35 views6 pages

3.4 Unification

Unification is the process of making two logical expressions identical through substitution, crucial for first-order inference algorithms. The UNIFY algorithm determines if two atomic sentences can be unified and returns the Most General Unifier (MGU) if possible. Conditions for successful unification include matching predicate symbols and identical argument counts, while indexing can enhance storage and retrieval efficiency in knowledge bases.

Uploaded by

Raj Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views6 pages

3.4 Unification

Unification is the process of making two logical expressions identical through substitution, crucial for first-order inference algorithms. The UNIFY algorithm determines if two atomic sentences can be unified and returns the Most General Unifier (MGU) if possible. Conditions for successful unification include matching predicate symbols and identical argument counts, while indexing can enhance storage and retrieval efficiency in knowledge bases.

Uploaded by

Raj Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

What is Unification?

o Unification is a process of making two different logical atomic


expressions identical by finding a substitution.
o Unification depends on the substitution process.
o It takes two literals as input and makes them identical using
substitution.
Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such
that, Ψ1𝜎 = Ψ2𝜎, then it can be expressed as UNIFY(Ψ1, Ψ2).
o

Example: Find the MGU (Most General Unifier) for Unify {King(x),
King (John)}

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.

o The UNIFY algorithm is used for unification, which takes two atomic
sentences and returns a unifier for those sentences (If any exist).
o Unification is a key component of all first-order inference algorithms.
o It returns fail if the expressions do not match with each other.
o The substitution variables are called Most General Unifier or
MGU.

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)


P(a, f(z))......... (ii)

o Substitute x with a, and y with f(z) in the first expression,


and it will be represented as a/x and f(z)/y.
o With both the substitutions, the first expression will be
identical to the second expression and the substitution set
will be: [a/x, f(z)/y].

Conditions for Unification:


o Predicate symbol must be same, atoms or expression with different
predicate symbol can never be unified.
o Number of Arguments in both expressions must be identical.
o Unification will fail if there are two similar variables present in the same
expression.

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 Algorithm


Step.1: Initialize the substitution set to be empty.

Step.2: Recursively unify atomic sentences:

a. Check for Identical expression match.


b. If one expression is a variable v i, and the other is a term t i which does not
contain variable vi, then:

a. Substitute ti / vi in the existing substitutions


b. Add ti /vi to the substitution setlist.
c. If both the expressions are functions, then function name must be
similar, and the number of arguments must be the same in both the
expression.

For Example: - The Query is Knows (John, x) whom does John Know?

 Some answers to the above query can be found by finding all sentences in the KB that
unify with knows (John, x)

 The results of unification are as follows,

UNIFY (knows (john, x), knows (John, Jane)) = {x/Jane}


UNIFY (knows (john, x), knows (y, Leo)) = {x/Leo, y/John}
UNIFY (knows (john, x), knows (y, Mother(y)) = {y/John, x/Mother (John)}
UNIFY (knows (john, x), knows (x, Elizabeth)) = fail
 x cannot take both the values John and Elizabeth at the same time.

 Knows (x, Elizabeth) means “Everyone knows Elizabeth” from this we able to infer
that John knows Elizabeth.
This can be avoided by using standardizing apart one of the two sentences being
unified (i.e.) renaming is done to avoid name clashes.
 For Example:-
UNIFY (Knows (john, x), knows (x1, Elizabeth)) = {x/Elizabeth,

Storage and retrieval:-


 Once the data type for sentences and terms are defined, we need to maintain
asset of sentences in a KB (i.e.) to store and fetch a sentence or term,
✔ Store (s) – stores a sentence s.
✔ Fetch (q) – returns all unifiers
 Such that the query q unifies with some sentences in the KB.
 For Example: - The unification for Knows (John, x) is an
Instance of fetching. ∙ The simplest way to store and fetch is
maintain a long list in sequential order.
 For a Query q, call UNIFY (q, s) for every sentences s in the list, requires O(n)
time on
an n-element KB.
 To make the fetch more efficient, indexing the facts in KB is done.
 The different types of indexing are as follows,
✔ Table based Indexing
✔ Tree based Indexing
✔ Predicate based Indexing
 To make the fetch more efficient, indexing the facts in KB is done.
 A simple form of indexing is predicate indexing puts all the knows facts in one
bucket
and all the brother facts in another.
 The buckets are stored in hash table for efficient access, Where hash table
means “a data structure for storing and retrieving information indexed by fixed
keys”
 Given sentence to be stored, it is possible to construct indices for all possible
queries that unify with it,
For Example:- For the fact Employs (SSN, John) the queries are as
follows,
✔ Employs (SSN, John) Does SSN employ John?
✔ Employs (x, John) who employs John?
✔ Employs (SSN, y) whom does SSN employ?
✔ Employs (x, y) who employs whom?

 These queries form a substitution lattice (i.e.) Properties of Lattice:- child of


any node in the lattice is obtained from its parent by a single substitution and
the highest common descendent of any two nodes is the result of applying
their most general unifier.
 For a predicate with n arguments, the lattice contains O(2n) nodes
 The following diagram shows the subsumption lattice,

Advantages and Disadvantages:

Advantages:-
 The scheme works very well whenever the lattice contains a small number of nodes.
 For a predicate with n arguments, the lattice contains O(2n) nodes.
Disadvantages:-
 If function symbols are allowed, the number of nodes is also exponential in the size of
the terms in the sentence to be stored. This can lead to a huge number of indices.

 At some point, the benefits of indexing are outweighed by the costs of storing and
maintaining all the indices.
More Examples:

Unification is not possible for these expressions.


6. UNIFY(knows(Richard, x), knows(Richard, John))

You might also like