I have seen original question posted on other forum.... for completeness, here is my LAST attempt... which should solve this problem completely.... However, this is just kind of fun, don't take it seriously (ain't I?)
parent_child(X,Y) :- father_child(X,Y).
parent_child(X,Y) :- mother_child(X,Y).
sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y), X\=Y.
mate(X,Y) :- father_child(X,Z), mother_child(Y,Z).
mate(X,Y) :- mother_child(X,Z), father_child(Y,Z).
son(X,Y) :- parent_child(Y,X).
%%
%% Facts
%%
%% 2樓
mother_child(girlmom,girl).
%% 3樓
father_child(boy,girl).
%% 4樓
%%mother_child(girl, xxx).
%%father_child(boy, xxx).
%% 5樓
father_child(girldad,boy).
mother_child(boymom,boy).
%% 6樓
%% mate(boymom,girldad).
%% 7樓
sibling(boydad,girldad).
%% 8樓
%%mother_child(girlmom,boymom).
mother_child(boymom,girlmom).
%% 9樓
father_child(boydad,girlmom).
related(X,Y, 'mate') :- mate(X,Y).
related(X,Y, 'parent') :- parent_child(X,Y).
related(X,Y, 'sibling') :- sibling(X,Y).
related(X,Y, 'son') :- son(X,Y).
path(A,B,Path) :-
travel(A,B,[A],Path).
travel(A,B,P,[B|P]) :-
related(A,B,R),
write(R), nl.
travel(A,B,Visited,Path) :-
related(A,C,R),
C \= B,
\+member(C,Visited),
travel(C,B,[C|Visited],Path),
write(R), nl.
Notes:
(1) Further thro' in relation 'son' (in fact son or daughter)
(2) Revamped relation 'related' again.
(3) Now the 'path' predicate should find ALL possible relation instead of just finding ONE solution as done previously.
Now run it again:
1 ?- path(boymom,girldad,P).
mate
P = [girldad, boymom] ;
sibling
mate
P = [girldad, boydad, boymom] ;
son
mate
parent
mate
P = [girldad, boy, girlmom, boydad, boymom] ;
son
son
parent
parent
mate
P = [girldad, boy, girl, girlmom, boydad, boymom] ;
son
sibling
parent
mate
P = [girldad, boy, girlmom, boydad, boymom] ;
son
parent
P = [girldad, boy, boymom] ;
sibling
son
mate
parent
P = [girldad, boydad, girlmom, boy, boymom] ;
sibling
son
son
parent
parent
P = [girldad, boydad, girlmom, girl, boy, boymom] ;
sibling
son
sibling
parent
P = [girldad, boydad, girlmom, boy, boymom] ;
son
mate
parent
P = [girldad, boy, girlmom, boymom] ;
son
son
parent
parent
P = [girldad, boy, girl, girlmom, boymom] ;
son
sibling
parent
P = [girldad, boy, girlmom, boymom] ;
sibling
son
parent
P = [girldad, boydad, girlmom, boymom] ;
false.
The program shows that there are > 10 relations between them.... To name them.... I will leave to anyone who are interested.