Sale!

Assignment 5 Unification and Prolog Programming

$30.00

Category:
Rate this product

CMPT 340
Assignment 5
Unification and Prolog Programming
Total: 100 Points
1. [10 Points]: For each of the following pairs of terms, say whether they can be unified. If they can be unified,
provide a most general unifier (mgu) that unifies them; if they cannot be unified, briefly state why.
a) pilots(A, london), pilots(london, paris)
b) point(X, Y, Z), point(X1, Y1, Z1)
c) letter(C), word(letter)
d) noun(alpha), alpha
e) ‘student’, student
f) f(X, X), f(a, b)
g) f(X, a(b, c)), f(Z, a(Z, c))
h) f(c, a(b, c)), f(Z, a(Z, c))
i) f(X, a(b, c)), f(d, a(Z, c))
j) g(Z, f(A, 17, B), A+B, 17), g(C, f(D, D, E), C, E)
—–
For Problems 2 through 4, consider that many family relationships can be defined in terms of the following set
of four simple predicates:
married_to(person1, person2) % person1 is/was married to person2
child_of(person1, person2) % person1 is a child of person2
male(person) % person is male
female(person) % person is female
Now, consider this partial family tree of the Canadian/British royal family:
Elizabeth —– Philip
|_________|
|
Diana —– Charles —– Camilla
|________|
____________|______________
| |
William —- Catherine Harry
|__________|
______|______
| |
George Charlotte
2. [10 Points] Represent the relationships in the tree using facts in Prolog, limiting yourself to the four simple
predicates listed above.
3. [5 + 5 + 5 + 5 + 10 + 10 + 10 + 10 Points] Write Prolog rules for the following additional relationships
(Note: You may need to use not, where not(p) says that p cannot be proved):
a) aunt_of(person1, person2)
b) grandchild_of(person1, person2)
c) mother_of(person1, person2)
d) stepmother_of(person1, person2)
e) nephew_of(person1, person2)
f) mother_in_law_of(person1, person2)
g) brother_in_law_of(person1, person2)
h) ancestor_of(person1, person2)
4. [20 Points] Write Prolog queries to ask the following questions. You may use all eleven predicates; assume
that you have correctly solved Problems 1 and 2.
a) Is Camilla the step mother of Harry? [should respond with yes]
b) Who are the children of Charles? [should respond with William and Harry]
c) Who are the step children of Camilla? [should respond with William and Harry]
d) Who are the grandparents of both William and Harry? [should respond with Elizabeth and Philip]
Submission:
Submit your solution to Problems 1 and 4 as a plain text file named 5-1-4.txt. For Problem 1, just provided
your responses in text; for Problem 4, provide a transcript of the program file being queried with your
queries. Submit your solutions to Problems 2 and 3 as a single Prolog file named 5-2-3.pl.
Create a directory with your nsid as its name. Place both files in the directory, and then submit a zipped
version of this directory (i.e., nsid.zip).
You may submit multiple times before the deadline, so you are advised not to wait till the last minute to submit
your assignment to avoid system slowdown. You are encouraged to submit completed parts of
the assignment early. Late submissions will not be accepted.

Open chat
Need help?
Hello
Can we help you?