Hi, I want to use prolog to make One Hundred Years of Solitude 's family tree, and when i try to search result, I find there are the duplicate part? So could you tell me how to fix it? Or could you give me some advice to let it better? Thanks!
My code is here:
% One Hundred Years of Solitude 's family tree in Prolog
% Wiki picture: https://en.wikipedia.org/wiki/One_Hundred_Years_of_Solitude#/media/File:One_Hundred_Years_Of_Solitude_Buendia%27s_Family_Tree.svg
% See here:https://codereview.stackexchange.com/questions/143116/family-tree-in-prolog
% predicate(X,Y) means "X is Y 's XXX ."
% eg. father(X,Y) means "X is Y 's father."
% Generation I
man('JosĂ© Arcadio BuendĂa').
woman('Ărsula IguarĂĄn').
marry('JosĂ© Arcadio BuendĂa','Ărsula IguarĂĄn').
% Generation II
man('José Arcadio').
man('Colonel Aureliano BuendĂa').
woman('Amaranta').
woman('Remedios Moscote').
woman('Rebeca').
woman('Pilar Ternera').
parent('JosĂ© Arcadio BuendĂa','JosĂ© Arcadio').
parent('JosĂ© Arcadio BuendĂa','Colonel Aureliano BuendĂa').
parent('JosĂ© Arcadio BuendĂa','Amaranta').
parent('Ărsula IguarĂĄn','JosĂ© Arcadio').
parent('Ărsula IguarĂĄn','Colonel Aureliano BuendĂa').
parent('Ărsula IguarĂĄn','Amaranta').
marry('Colonel Aureliano BuendĂa','Remedios Moscote').
marry('Rebeca','José Arcadio').
amorousAffairsy('Pilar Ternera','José Arcadio').
amorousAffairsy('Pilar Ternera','Colonel Aureliano BuendĂa').
% Generation III
woman('Aureliano José').
woman('Arcadio').
man('Santa SofĂa de la Piedad').
marry('Santa SofĂa de la Piedad','Arcadio').
illegitimateChild('17 sons by unknown women','Colonel Aureliano BuendĂa').
parent('Pilar Ternera','Arcadio').
parent('JosĂ© Arcadio BuendĂa','Arcadio').
% Generation IV
woman('Remedios the Beauty').
man('José Arcadio II').
man('Aureliano II').
woman('Petra Cotes').
woman('Fernanda del Carpio').
marry('Aureliano II','Fernanda del Carpio').
amorousAffairsy('Petra Cotes','Aureliano II').
parent('Santa SofĂa de la Piedad','Remedios the Beauty').
parent('Santa SofĂa de la Piedad','JosĂ© Arcadio II').
parent('Santa SofĂa de la Piedad','Aureliano II').
parent('Arcadio','Remedios the Beauty').
parent('Arcadio','José Arcadio II').
parent('Arcadio','Aureliano II').
% Generation V
man('GastĂłn').
man('José Arcadio').
man('Mauricio Babilonia').
woman('Amaranta Ărsula').
woman('Renata Remedios').
marry('Amaranta Ărsula','GastĂłn').
amorousAffairsy('Renata Remedios','Mauricio Babilonia').
parent('Aureliano II','Amaranta Ărsula').
parent('Aureliano II','José Arcadio').
parent('Aureliano II','Renata Remedios').
parent('Fernanda del Carpio','Amaranta Ărsula').
parent('Fernanda del Carpio','José Arcadio').
parent('Fernanda del Carpio','Renata Remedios').
% Generation VI
man('Aureliano Babilonia').
parent('Mauricio Babilonia','Aureliano Babilonia').
parent('Renata Remedios','Aureliano Babilonia').
amorousAffairsy('Amaranta Ărsula','Aureliano Babilonia').
% Generation VII
man('Aureliano').
parent('Aureliano Babilonia','Aureliano').
parent('Amaranta Ărsula','Aureliano').
% -------- Start defining the relationships --------
:- discontiguous man/1, woman/1, marry/2,amorousAffairsy/2.
father(X,Y) :- parent(X,Y), man(X), X\=Y.
mother(X,Y) :- parent(X,Y), woman(X), X\=Y.
%parent(X,Y) :- father(X,Y); mother(X,Y).
parents(X,Y,Z) :- (father(X,Z), mother(Y,Z)); (father(Y,Z), mother(X,Z)), X\=Y, X\=Z,Z\=Y.
marry(X,Y) :- marry(X,Y), marry(Y,X), X\=Y.
amorousAffairsy(X,Y) :- amorousAffairsy(X,Y), amorousAffairsy(Y,X), X\=Y.
child(X,Y) :- father(Y,X); mother(Y,X),X\=Y.
illegitimateChild(X,Y) :- illegitimateChild(X,Y), X\=Y.
son(X,Y) :- child(X,Y),man(X),X\=Y.
daughter(X,Y) :- child(X,Y),woman(X),X\=Y.
grandma(X,Y) :- (mother(X,W), mother(W,Y)); (father(X,W), mother(W,Y)),X\=Y.
grandpa(X,Y) :- (father(X,W), father(W,Y)); (mother(X,W), father(W,Y)),X\=Y.
grandparents(X,Y,Z) :- (grandma(X,Z), grandpa(Y,Z)); (grandma(Y,Z), grandpa(X,Z)), X\=Y, X\=Z,Z\=Y.
siblings(A,B) :- father(F,A), father(F,B), mother(M,A), mother(M,B), A\=B.
uncle(U,N) :- man(U), ((siblings(U,M), father(M,N)) ; (siblings(U,F), father(F,N))),U\=N.
aunt(U,N) :- woman(U), ((siblings(U,M), mother(M,N)) ; (siblings(U,F), mother(F,N))),U\=N.
sister(X,Y) :- siblings(X,Y), woman(X), X\=Y.
brother(X,Y) :- siblings(X,Y), man(X), X\=Y.
ancestor(X,Y):-parent(X,Y),X\=Y.
ancestor(X,Y):-parent(X,Z),ancestor(Z,Y).
% -------- End defining the relationships --------