首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在prolog中进行知识表示

如何在prolog中进行知识表示
EN

Stack Overflow用户
提问于 2021-12-07 13:05:23
回答 1查看 102关注 0票数 0

我有一些信息:

如果X是人、动物或植物,则wings.

  • Mammal

  • X是有机体。如果X能呼吸和移动,则

  • X是有机体。

  • 哺乳动物、爬行动物、两栖类、鱼类和鸟类是动物。

  • 鱼类有鳃呼吸,有鳞,有卵生,有鳍。

H19鸟用肺呼吸,产卵,用肺呼吸,用肺呼吸,有鳞片。ovoviviparous.

  • Amphibian用肺呼吸,viviparous.

  • Plant可以产生oxygen.

  • Human,动物不能产生氧气。--

我根据这些信息制定了一个规则:

代码语言:javascript
运行
复制
organism :- human; animal; plant
organism :- can_breathe, can_move.

animal :- mammal.
animal :- fish.
animal :- reptile.
animal :- amphibian.
animal :- bird.

fish :- breathe_with_gills, have_scales, oviparous, have_fin.
bird :- breathe_with_lungs, oviparous, have_wings.
mammal :- breathe_with_lungs, viviparous.
reptile :- breathe_with_lungs, have_scales, ovoviviparous.
amphibian :- breathe_with_lungs, viviparous.

plant :- produce_oxygen.
human :- not(produce_oxygen).
animal :- not(produce_oxygen).

然后,我尝试在prolog中使用它,并使用assert在知识库中添加事实。我要这样的输出:

代码语言:javascript
运行
复制
?- assert(animal).
true.
?- organism.
true.

但我得到了这样的输出:

代码语言:javascript
运行
复制
?- assert(animal).
ERROR: No permission to modify static procedure `animal/0'
ERROR: Defined at c:/users/user/documents/prolog/file.pl:4
ERROR: In:
ERROR:   [10] assert(animal)
ERROR:    [9] <user>

我怎么才能修好它?

EN

回答 1

Stack Overflow用户

发布于 2021-12-07 15:41:44

您不应该在代码中详细说明如何证明(也不需要) assert;您应该通过任何其他方法来证明assert (例如,produce_oxygen)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70260693

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档