Skip to content

Instantly share code, notes, and snippets.

@FabienArcellier
Created December 14, 2012 14:26
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 FabienArcellier/4285798 to your computer and use it in GitHub Desktop.
Save FabienArcellier/4285798 to your computer and use it in GitHub Desktop.
Family Link
/* Programme sur les liens familiaux */
pere(paul, jean).
pere(paul, frederic).
pere(emilie, marie).
pere(jean, andre).
pere(jean, cathy).
pere(jean, francis).
pere(frederic, marc).
pere(frederic, lisa).
mere(alice, jean).
mere(alice, frederic).
mere(simone, marie).
mere(marie, andre).
mere(marie, cathy).
mere(marie, francis).
mere(alicia, marc).
mere(alicia, lisa).
masc(paul).
masc(emile).
masc(andre).
masc(francis).
masc(jean).
masc(frederic).
masc(marc).
fem(alicia).
fem(marie).
fem(alice).
fem(lisa).
fem(simone).
fem(cathy).
grand_pere(X, Y) :- pere(X, Z), pere(Z, Y).
grand_pere(X, Y) :- pere(X, Z), mere(Z, Y).
grand_mere(X, Y) :- mere(X, Z), mere(Z, Y).
grand_mere(X, Y) :- mere(X, Z), pere(Z, Y).
fils(X, Y) :- masc(X), mere(Y, X).
fils(X, Y) :- masc(X), pere(Y, X).
fille(X, Y) :- fem(X), mere(Y, X).
fille(X, Y) :- fem(X), pere(Y, X).
pas_moi(X, Y) :- X\==Y.
frere(X, Y) :- pere(Z, X), mere(W, X), fils(Y, Z), fils(Y, W), pas_moi(X, Y).
soeur(X, Y) :- pere(Z, X), mere(W, X), fille(Y, Z), fille(Y, W), pas_moi(X, Y).
petit_fils(X, Y) :- masc(X), grand_pere(Y, X).
petit_fils(X, Y) :- masc(X), grand_mere(Y, X).
petite_fille(X, Y) :- fem(X), grand_pere(Y, X).
petite_fille(X, Y) :- fem(X), grand_mere(Y, X).
oncle(X, Y) :- frere(X, Z), fils(Y, Z).
oncle(X, Y) :- frere(X, Z), fille(Y, Z).
tante(X, Y) :- soeur(X, Z), fils(Z, Y).
tante(X, Y) :- soeur(X, Z), fils(Z, Y).
cousin(X, Y) :- oncle(Z, X), fils(Y, Z).
cousin(X, Y) :- tante(Z, X), fils(Y, Z).
cousine(X, Y) :- oncle(Z, X), fille(Y, Z).
cousine(X, Y) :- tante(Z, X), fille(Y, Z).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment