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).
我的问题是,当我运行以下问题时;
isa(pipistrelle, O).
swi-prolog仅显示以下内容;
O = bat.
我希望显示所有可能性:
O = bat;
O = mammal;
O = animal
你能帮助我吗,谢谢。
答案 0 :(得分:1)
您正在调用isa/2
谓词,但您应该调用isa1/2
谓词,该谓词是实现 isa 关系的传递闭包的谓词:
?- isa1(pipistrelle, O).
O = bat ;
O = mammal ;
O = animal ;
false.