where do I think wrong

Roelof Wobben <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
Hello, 

I have these clauses and rules: 

male(roelof).
male(mans). 
male(ronald).
male(jan).

female(chantal).
female(marie).
female(gerda).
female(dagmar).
female(denise).
female(kimberly).

parent(mans,gerda).
parent(mans,roelof).
parent(marie,gerda).
parent(marie,roelof).
parent(dagmar,denise).
parent(dagmar,kimberly).
parent(ronald,denise).
parent(ronald,kimberly).
parent(chantal,tamara).
parent(roelof,tamara).
parent(jan,chantal).
parent(jan,dagmar).

is_father(F,C) :- 
   parent(F,C), male(F).

is_mother(M,C) :-
   parent(M,C),female(M).

have_children(M,F) :-
   is_mother(M,Z), 
   is_father(F,Z).

display_mother(C):-
   is_mother(M,C), 
   write('De moeder van '), 
   write(C) , 
   write(' is '),
   write(M).

display_father(C) :-
   is_father(F,C), 
   write('De vader van '),
   write(C),
   write(' is '),
   write(F).

list_parents(C) :-
   parent(X,C), 
   tab(5), 
   write(X),
   nl, 
   fail.
   list_parents(_).

display_parents(C) :-
   write('De ouders van '), 
   write(C), 
   write(' zijn :'),
   nl, 
   nl,
   list_parents(C).
   display_parents(_).

have_siblings(C) :-
    is_father(X,C),
    is_father(X,S), 
    is_mother(Y,S), 
    is_mother(Y,C), 
    C \= S,
    write(S).
    

display_siblings(C) :-
   write('De broers/zusters van '), 
   write(C), 
   write(' zijn :'),
   nl, 
   nl,
   have_siblings(C).
   display_siblings(_).


It worked fine if a mother and father are known.
So I want to change it to this :

have_siblings(C) :-
    is_father(X,C),
    is_father(X,S); 
    is_mother(Y,S), 
    is_mother(Y,C), 
    C \= S,
    write(S).

So if a father of a child(C)  is equal to the father of a sibling(S) or the mother of a child is equal to the mother of a sibling.
But nothing gets found then. 

Here is a trace : 

  Call: (6) display_siblings(chantal) ? creep
   Call: (7) write('De broers/zusters van ') ? creep
De broers/zusters van 
   Exit: (7) write('De broers/zusters van ') ? creep
   Call: (7) write(chantal) ? creep
chantal
   Exit: (7) write(chantal) ? creep
   Call: (7) write(' zijn :') ? creep
 zijn :
   Exit: (7) write(' zijn :') ? creep
   Call: (7) nl ? creep

   Exit: (7) nl ? creep
   Call: (7) nl ? creep

   Exit: (7) nl ? creep
   Call: (7) have_siblings(chantal) ? creep
   Call: (8) is_father(_G1969, chantal) ? creep
   Call: (9) parent(_G1969, chantal) ? creep
   Exit: (9) parent(jan, chantal) ? creep
   Call: (9) male(jan) ? creep
   Exit: (9) male(jan) ? creep
   Exit: (8) is_father(jan, chantal) ? creep
   Call: (8) is_father(jan, _G1970) ? creep
   Call: (9) parent(jan, _G1970) ? creep
   Exit: (9) parent(jan, chantal) ? creep
   Call: (9) male(jan) ? creep
   Exit: (9) male(jan) ? creep
   Exit: (8) is_father(jan, chantal) ? creep
   Exit: (7) have_siblings(chantal) ? creep
   Exit: (6) display_siblings(chantal) ? creep
true .

Roelof

 		 	   		  
-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.