male(tom).
male(jim).
male(bob).
male(mike).
male(david).

female(jane).
female(betty).
female(mary).
female(alice).

% parent(P,C) means P is a parent of C.
parent(tom,betty).
parent(tom,bob).
parent(jane,betty).
parent(jane,bob).
parent(jim,mike).
parent(jim,david).
parent(betty,mike).
parent(betty,david).
parent(bob,alice).
parent(mary,alice).		

father(F,C) :- male(F), parent(F,C).
mother(F,C) :- female(F), parent(F,C).

grandmother(GM,C) :- female(GM), parent(GM, P), parent(P, C).
