1. For each of the following pair of literals, give the most general unifier if it exists, or if none exists, explain why. See the definition MGU in the textbook, figure 9.1. We use the convention that variables are Capitalized (X,Y,Z) and constants are lowercase (a,b,c), which is like Prolog but the reverse of the convention in the textbook. Be careful about the scope of variables: variables with the same name that appear in different literals are not the same variable!
| p(a,b,c) | p(X,Y,Z) |
| p(a,b,X) | p(X,b,Y) |
| q(Y,g(a,b)) | q(g(X,X),Y) |
| older(father(Y),Y) | older(father(X),john) |
| knows(father(Y),Y) | knows(X,X) |
2. Write a Prolog program that finds a solution to the following puzzle. Run your program to confrim that it works. You can download a good free version of Prolog from http://www.swi-prolog.org/.
The Mini Zebra Puzzle
Question: Who owns the zebra? More generally, for each house: who lives there, what pet does he have, and what does he drink?
Notes: In Prolog, the atom "X=Y" is true if X and Y unify. The atom "X\=Y" is true if X and Y do not unifiy. One way to solve the puzzle is write a clause that guesses at a solution, and then verifies that it is correct. Think carefully about the predicates you will use. One approach is to use predicates that hold of houses, for example, dog(H) to mean that H is the house with the dog, and next(house1,house2) to mean that house1 is next to house2.
Following is the full version of the Zebra puzzle: