views:

2301

answers:

4
+3  Q: 

Prolog Family tree

+3  A: 

It looks like some of your axioms are wrong or missing, if you are trying to replicate the diagram.

missing:

female(jane).

father(john, bob).

wrong:

father(john, sue).

This might cause the sibling rule to conflict. But what do I know about prolog

1800 INFORMATION
+1, I didn't test those
John Rasch
+3  A: 

Your rule of brother already verifies that brother(bob, bob) will fail because it calls sibling(X, Y), which does the check to make sure X \= Y already.

Also, it looks as though everything is working on my machine, but I had to change the dashes on these lines:

aunt(X, Y) :– female(X), sibling(X, Z), parent(Z, Y).
aunt(X, Y) :– female(X), spouse(X, W), sibling(W, Z), parent(Z, Y).

to:

aunt(X, Y) :- female(X), sibling(X, Z), parent(Z, Y).
aunt(X, Y) :- female(X), spouse(X, W), sibling(W, Z), parent(Z, Y).

Yeah, they look identical, but the dashes in the top version are slightly longer... and seemed to cause problems when I "consulted" the file.

I only caught that because I created a Prolog color scheme for Notepad++, if anyone is interested I can post it online.

John Rasch
The longer dashes are probably em or en dashes created by some smart word processor
1800 INFORMATION
John Rasch
A: 

to optimize the rule of the brother for X is not brother to itself.

You should do:

brother(X, Y) :-
      sibling(X, Y),
      male(X),
      male(Y),
      not X=Y.
A: 
Haroldo