Family
Given are some facts in the following form.
male(jack).
male(oliver).
male(ali).
male(james).
male(simon).
male(harry).
female(helen).
female(sophie).
female(jess).
female(lily).
parent(jack, jess).
parent(jack, lily).
parent(helen, jess).
parent(helen, lily).
parent(oliver, james).
parent(sophie, james).
parent(jess, simon).
parent(ali, simon).
parent(lily, harry).
parent(james, harry).
where male/1 and female/1 state the gender of a person, and parent/2 means that the first argument is a parent of the second (in this case Jack is a parent of Jess).
Write the following predicates:
• mother/2
• father/2
• grandmother/2
• grandfather/2
• ancestor/2
Example execution:
?- father(ali, X)
X = simon
?- grandfather(jack, X).
X = simon
X = harry
?- ancestor(X, Y).
X = jack, Y = jess
X = jack, Y = lily
X = helen, Y = jess
…