Reputation: 171
i have wroten a very simple prolog. I compiled it in swi-prolog and consult a very simple question. Here is my prolog.
isa(bird, animal).
isa(robin, bird).
isa(fish, animal).
isa(cod, fish).
isa(mammal, animal).
isa(lion, mammal).
isa(horse, mammal).
isa(bat, mammal).
isa(pipistrelle, bat).
isa1(X,Y) :- isa(X,Y).
isa1(X,Z) :- isa(X,Y), isa1(Y,Z).
My question is , when i run the following question;
isa(pipistrelle, O).
swi-prolog shows only the following ;
O = bat.
I want to display all possibilities like :
O = bat;
O = mammal;
O = animal
Could you help me at this point , thanks.
Upvotes: 1
Views: 724
Reputation: 18683
You're calling the isa/2
predicate but you should be calling instead the isa1/2
predicate, which is the one implementing the transitive closure for the isa relation:
?- isa1(pipistrelle, O).
O = bat ;
O = mammal ;
O = animal ;
false.
Upvotes: 1