Skip to content

Instantly share code, notes, and snippets.

@karsai5
Created March 18, 2016 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karsai5/b4213e2f73625d5eec62 to your computer and use it in GitHub Desktop.
Save karsai5/b4213e2f73625d5eec62 to your computer and use it in GitHub Desktop.
father(james, patrick).
father(patrick,pjk).
father(pjk, joseph).
father(joseph, jfk).
father(joseph, bobby).
father(joseph, eunice).
father(jfk, caroline).
father(jfk, jfk_jr).
mother(maria, patrick).
mother(bridget, pjk).
mother(mary_augusta, joseph).
mother(rose, jfk).
mother(rose, bobby).
mother(rose, eunice).
mother(jacqueline, caroline).
mother(jacqueline, jfk_jr).
parent(X,Y) :- father(X,Y).
parent(X,Y) :- mother(X,Y).
sibling(A,B) :- parent(P,A), parent(P,B), not(A=B).
cousin(X,Y) :- parent(Xp,X), parent(Yp,Y), sibling(Xp,Yp).
cousin(X,Y) :- parent(Xp,X), parent(Yp,Y), cousin(Xp,Yp).
ancestor(A, B) :- parent(A, B).
ancestor(A, B) :- parent(A, C), ancestor(C, B).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment