#---
# Excerpted from "Good Math: A Geeks Guide to the Beauty of Numbers, Logic, and Computation",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material, 
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose. 
# Visit http://www.pragmaticprogrammer.com/titles/mcmath for more book information.
#---

person(aaron).
person(rebecca).
person(mark).
person(jennifer).
person(irving).
person(gail).
person(yin).
person(paul).
person(deb).
person(jocelyn).


father(mark, aaron).
father(mark, rebecca).
father(irving, mark).
father(irving, deb).
father(paul, jennifer).
mother(jennifer, aaron).
mother(jennifer, rebecca).
mother(gail, mark).
mother(gail, deb).
mother(yin, jennifer).
mother(deb, jocelyn).

parent(X, Y) :- father(X, Y).
parent(X, Y) :- mother(X, Y).

grandparent(X, Y) :- parent(X, Z), parent(Z, Y).

sibling1(X, Y) :-
  parent(P, X),
  parent(P, Y).

sibling(X, Y) :-
  X \= Y,
  parent(P, X),
  parent(P, Y).

cousin(X, Y) :-
  parent(P, X),
  parent(Q, Y),
  sibling(P, Q).

