06.03.2013 Views

Artificial Intelligence and Soft Computing: Behavioral ... - Arteimi.info

Artificial Intelligence and Soft Computing: Behavioral ... - Arteimi.info

Artificial Intelligence and Soft Computing: Behavioral ... - Arteimi.info

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.9 Unification of Predicates<br />

Two predicates P (t1,t2,..., tn) <strong>and</strong> Q (s1, s2,..., sn) can be unified if terms ti<br />

can be replaced by si or vice-versa.<br />

Loves (mary, Y) <strong>and</strong> Loves (X, Father-of (X)) , for instance, can be unified by<br />

the substitution S ={ mary / X , Father-of ( mary) / Y }.<br />

Conditions of Unification:<br />

i) Both the predicates to be unified should have an equal number of terms.<br />

ii) Neither ti nor si can be a negation operator, or predicate or functions of<br />

different variables, or if ti = term belonging to si or if si = term belonging<br />

to ti then unification is not possible.<br />

The Unification Algorithm<br />

Input: Predicates P(t1, t2,…, tn) <strong>and</strong> Q(s1,s2,…,sm)<br />

Output: Decision whether the predicates P <strong>and</strong> Q are unifiable<br />

<strong>and</strong> a set S that includes the possible substitution.<br />

Procedure Unification (P, Q, S, unify)<br />

Begin<br />

S:= Null;<br />

While P <strong>and</strong> Q contain a Next-symbol do<br />

Begin<br />

Symb1: = Next-symbol (P);<br />

Symb2: = Next-symbol (Q);<br />

If Symb1 ≠ Symb2 Then do<br />

Begin Case of<br />

Symb1 or Symb2 = Predicate: Unify: = fail;<br />

Symb1 = constant <strong>and</strong> symb2 = different-constant: Unify: = fail;<br />

Symb1 or Symb2 = ¬ : Unify: = fail;<br />

Symb1 <strong>and</strong> Symb2 = function: Unify: = fail;<br />

Symb1=variable <strong>and</strong> Symb2 =term <strong>and</strong> variable ∈ term: Unify: = fail;<br />

Symb2=variable <strong>and</strong> Symb1=term <strong>and</strong> variable ∈ term: Unify: = fail;<br />

Else If Symb1 = variable or constant <strong>and</strong> Symb2 =term Then do<br />

Begin<br />

S: = S ∪ {variable or constant / term};<br />

P: = P[variable or constant / term];<br />

End;<br />

Else If Symb2 = variable or constant <strong>and</strong> Symb1 =term Then do<br />

Begin

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!