Q.5. Attempt to unify the following pairs of expressions. Either show their most general unifiers or explain why they will not unify. a. p(X,Y) and p(a,Z) b. p(X,X) and p(a,b) c. ancestor(X,Y) and ancestor(bill,father(bill)) d. ancestor(X,father(X)) and ancestor(david,george) e. q(X) and ﬧq(a).
What I know about unification is based on some Prolog programming I did and on the Wikipedia page about Unification. Some terminology will make it easier to talk about this. Let's call strings starting with an upper-case letter 'variables', let's call other strings 'atoms' and strings including braces, '(' and ')', terms (this is what they're called in Prolog). So when can two expressions be unified? 1) A variable can be unified with an atom, variable or term 2) Two atoms can be unified if they're identical 3) A term can be unified if the identifiers (the string before the '(' ) are the same, they have the same number of arguments and all arguments can be unified. If you have a look at example a, you want to unify 'p(X,Y)' with 'p(a,Z)'. Since these are terms, we need to look at the third rule. Both these terms have the same identifier (which is 'p') and the same number of arguments (2 arguments). So they can be unified if the arguments can be unified. So you need to check if 'X' can unify with 'a' and if 'Y' can unify with 'Z'. Since 'X' is a variable and 'a' an atom, and according to the first rule, a variable can be unified with an atom. Thus 'X -> a' ('X' will map to 'a': instead of each use of 'X', you can put in an 'a'). 'Y' is again a variable, so again the first rule should be used. Thus 'Y' can be unified with 'Z' ('Y -> Z'). Since 'X' unifies with 'a' and 'Y' unifies with 'Z', the two terms can be unified.
Join our real-time social learning platform and learn together with your friends!