I am trying to get a simple family tree to work with Prolog using a maximum of 3 facts being allowed, however I can't seem to be able to define my sister as the child of my parents. Here is what I've wrote:
father(dad,me).
mother(mom,me).
siblings(me,sis).
parents(X,Z):-father(X,Z).
parents(Y,Z):-mother(Y,Z).
child(Z,X):-siblings(Z,Z2),parents(X,Z).
child(Z,Y):-siblings(Z,Z2),parents(Y,Z).
child(Z2,X):-siblings(Z,Z2),parents(X,Z).
child(Z2,Y):-siblings(Z,Z2),parents(Y,Z).
son(Z,X):-siblings(Z,Z2),parents(X,Z).
daughter(Z2,X):-siblings(Z,Z2),parents(X,Z).
brother(Z,Z2):-siblings(Z,Z2).
sister(Z2,Z):-siblings(Z,Z2).
and when I type in father(ZFather,ZChild)
in Prolog, it only shows me
as the child and not my sis
. I know I haven't defined it in facts, but I tried to do so in rules with child(Z2,X)
and child(Z2,Y)
meaning that Z2
is my sis
.
Helps will be appreciated.