gpt4 book ai didi

prolog - 处理 SWI-Prolog 中的未知程序错误

转载 作者:行者123 更新时间:2023-12-04 02:28:04 25 4
gpt4 key购买 nike

我正在尝试使用 Swi-Prolog 创建一个简单的知识库,但在运行查询 animal(X). 时遇到“未知过程”错误。据我所知,它应该根据我在下面写的事实打印“Alligator”。我做错了什么?

species(reptile):-
scales(present),
body_temperature(cold_blooded),
reproduction(lays_eggs).

animal(alligator):-
species(reptile),
color(dark_green),
habitat(water).

species(reptile).
color(dark_green).
habitat(water).

最佳答案

你的程序不包含变量,只有常量,这里以原子的形式(全小写字母字符串)

错误:

ERROR: Unknown procedure: scales/1
ERROR: In:
ERROR: [12] scales(present)
ERROR: [11] species(reptile) at user://1:8
ERROR: [10] animal(alligator) at user://1:13
ERROR: [9] toplevel_call(user:user: ...)

解释器正在寻找谓词 scales/1 以调用参数 present。没有这样的谓词(找不到以这种方式命名的事实或规则)。

也不清楚您的程序应该做什么。

你可能想这样表达:

“输入”关于某些原子的事实(这些通常没有人们想象的那么有用。

animal(alligator).     % alligator is an animal
species(reptile). % reptile is a species
color(dark_green). % dark_green is a color
habitat(water). % water is a habitat

alligator指定的事物的属性:

species(alligator,reptile).   % species of alligator is reptile
color(alligator,dark_green) % color of alligator is dark_green
habitat(alligator,water). % habitat of alligator is water

species指定事物的属性:

surface(reptile,scales).
body_temperature(reptile,cold_blooded),
reproduction(reptile,lays_eggs).

Prolog 正确建模对象的能力有点乏力。缺少基本有用的数据结构“ map ”无济于事。 (Prolog 是“本体组装器”吗?是的!)

关于prolog - 处理 SWI-Prolog 中的未知程序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66006284/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com