Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unification We can represent any substitution by a set of ordered pairs: s = { t 1 /v 1, t 2 /v 2, …, t n /v n } where: t i /v i means that the term i.

Similar presentations


Presentation on theme: "Unification We can represent any substitution by a set of ordered pairs: s = { t 1 /v 1, t 2 /v 2, …, t n /v n } where: t i /v i means that the term i."— Presentation transcript:

1 Unification We can represent any substitution by a set of ordered pairs: s = { t 1 /v 1, t 2 /v 2, …, t n /v n } where: t i /v i means that the term i substitutes variable i throughout the expression. e.g. s1 = {b/x, a/y, a/z} Note: - every occurrence of a variable should be substituted by the same term. - no variable can be replaced by a term that contains the same variable. Def. To denote a substitution instance of an expression E, using a substitution s, we write: Es.

2 Def. Finding substitutions of terms for variables to make two or more expressions identical is called unification. e.g. {p(g(x,f(y)),a), p(g(b,f(z)),y)} ==> p(g(b,f(a)),a) Def. A substitution instance of an expression is obtained by substituting terms for variables in that expression. Def. A ground instance of an expression is one in which there are no variables (and consequently, no quantifiers). Def. An instance of an expression which results from changing just the names of the variables in it, is called an alphabetic variant of the original. e.g.  x.p(x,f(x,b)) ==>  z.p(z,f(z,b)) Unification

3 Def. A composition of two substitutions s1 and s2 is written s1s2, and it is accomplished following the steps: - apply s2 to the elements of s1. - add any pairs of s2 having variables not occurring in s1. e.g. s1={g(x,y)/z}, s2={a/x, b/y, c/w, d/z} s1s2 ==> {g(a,b)/z, a/x, b/y, c/w} s2s1 ==> {a/x, b/y, c/w, d/z} = s2 Some properties of composition are: 1.(Es1)s2=E(s1s2) 2. s1(s2s3)=(s1s2)s3 Unification

4 Def. We say that a set {E i } of expressions is unifiable if there exists a substitution s that makes: E 1 s=E 2 s=…=E n s. Def. If a substitution g has the property that if s is a unifier of {E i } yielding {E i } s, then there exists a substitution s’ such that {E i } s={E i } gs’, then g is called the most general unifier mgu. For the unify procedure presented next, it is assumed that its arguments are two lists of expressions. e.g. g(r(x,f(z)),y) ==> [g, [r, x, [f, z ]], y] g(r(a, y), u) ==> [g, [r, a, y], u] Unification

5 Procedure UNIFIY (E1, E2) If either E1 or E2 is an atom { if E1 and E2 are identical, return NIL if E1 is a variable, do: { if E1 occurs in E2, return FAIL return {E2/E1} } if E2 is a variable, return {E1/E2} return FAIL } F1  the first element of E1 T1  the rest of E1 F2  the first element of E2 T2  the rest of E2 Z1  UNIFY(F1, F2) If Z1 = FAIL, return FAIL G1  result of applying Z1 to T1 G2  result of applying Z1 to T2 Z2  UNIFY(G1, G2) If Z2 = FAIL, return FAIL Return the composition of Z1 and Z2 ________________________ Procedure taken from Nilsson N.J. “Principles of Artificial Intelligence”, Tioga Publishing, California 1980. Unification Algorithm


Download ppt "Unification We can represent any substitution by a set of ordered pairs: s = { t 1 /v 1, t 2 /v 2, …, t n /v n } where: t i /v i means that the term i."

Similar presentations


Ads by Google