# finding the most general unifier

i am trying to find the most general unifier of the following:

1)Daughter(Uncle(y),y), Daughter(Uncle(x),emily)

2)Loves(cat(x),x), Loves(y,y)

what i think:

1)$$\theta = [emily/y, x/y]$$

2)$$\theta = [cat(x)/y,x/y]$$ - not sure about this one because of $$Loves(cat(x),x), Loves(cat(x),cat(x))$$, (would really appreciate help with this).

## 1 Answer

1. $$s = \text{Daughter}(\text{Uncle}(y),y)$$, $$t = \text{Daughter}(\text{Uncle}(x),\text{emily})$$

1. Start with the empty substitution $$\sigma_0 = \emptyset$$.
2. Scan $$\sigma_0(s)$$ and $$\sigma_0(t)$$ for differences. The first difference is y vs. x, extend your substitution to $$\sigma_1 = \{ y/x \} \circ \sigma_0 = \{y/x\}$$.
3. Scan $$\sigma_1(s)$$ and $$\sigma_1(t)$$, the next difference is $$x$$ vs. $$\text{emily}$$. Extend your substitution to $$\sigma_2 = \{x/\text{emily} \} \circ \sigma_1 = \{ x / \text{emily}, y/\text{emily}\}$$.
4. Exit since $$\sigma_2(s) = \sigma_2(t)$$.
2. $$s = \text{Loves}(\text{cat}(x),x)$$, $$t = \text{Loves}(y,y)$$

1. Start with the empty substitution $$\sigma_0 = \emptyset$$.
2. Scan $$\sigma_0(s)$$ and $$\sigma_0(t)$$ for differences. The first difference is $$\text{cat}(x)$$ vs. $$y$$. Extend your substitution to $$\sigma_1 = \{y / \text{cat}(x)\} \circ \sigma_0 = \{ y / \text{cat}(x)\}$$.
3. Scan $$\sigma_1(s)$$ and $$\sigma_1(t)$$ for differences. The next difference is $$x$$ vs. $$\text{cat}(x)$$. Abort since the variable occurs in the term we want to substitute it with (occur error).

The third kind of exit condition you could hit would be the clash error, when you have a difference between two non-variable terms, for example $$\text{Loves(x,y)}$$ vs. $$\text{Hates(x,y)}$$.