You are on page 1of 3

Assignment 9

1) Write a Prolog program to represent a Family tree defining


relation by fact. Family tree is given below where tom and pam is
parent of bob and so on.

Code:
parent(pam,bob).

parent(tom,bob).

parent(tom,liz).

parent(bob,ann).

parent(bob,pat).

parent(pat,jim).

Output:
2)Formulate in prolog the following question about parent relation
given above:
a) Who is Pat’s parent?
b) Does Liz have a child?
c) Who is Pat’s grandparent?
Code:
parent(pam,bob).

parent(tom,bob).

parent(tom,liz).

parent(bob,ann).

parent(bob,pat).

parent(pat,jim).

Output:

You might also like