Prolog Family Tree Assignment 24BAI10706
Prolog Family Tree Assignment 24BAI10706
Que: Create a family tree in prolog with the rule for following rela ons father,
mother, uncle, aunt, grandfather, grandmother, sibling, ancestor. The facts
should be relevant to your family informa on. Rules should be general.
James Sarah
| |
--------------------------
| |
Robert Catherine
/ \ |
Prolog Code
% Gender
male(james).
male(robert).
male(tom).
female(sarah).
female(catherine).
female(alice).
female(emily).
% Rules
% Sibling: Two people are siblings if they share a parent and are not the same person.
o Robert
o Catherine
o Alice
o Tom
o Emily
Rules Explained
1. Father Rule:
Prolog code
2. Mother Rule:
Prolog code
3. Sibling Rule:
Prolog code
o X and Y are siblings if they share a parent (Z) and are not the same person.
4. Uncle Rule:
Prolog code
5. Aunt Rule:
Prolog code
Prolog code
7. Grandmother Rule:
Prolog code
8. Ancestor Rule:
Prolog code
Prolog code
?- father(X, robert).
Output: X = james.
Prolog code
?- sibling(X, robert).
Output: X = catherine.
Prolog code
?- grandfather(X, alice).
Output: X = james.
Prolog code
?- ancestor(sarah, emily).
Output: true.