gpt4 book ai didi

prolog - GNU Prolog 断言错误

转载 作者:行者123 更新时间:2023-12-04 11:38:59 26 4
gpt4 key购买 nike

我是 Prolog 的新手,但我坚持使用这个看似简单的命令。我已经加载
一个没有错误的知识库,每当我尝试断言(甚至帮助)我
收到以下消息:

uncaught exception: error(existence_error(procedure,assert/1),top_level/0)
{2}

我到底错过了什么?赞赏。

最佳答案

使用 assertz/1asserta/1反而。 GNU-Prolog 不提供 assert/1因为只有 asserta/1assertz/1标准中定义。

请注意,虽然 asserta/1总是有一个明确的解释含义在开头添加从句,assertz/1的含义更难解决,因为“在最后添加一个子句”并不能完全确定在断言该子句之前调用的目标的语义。

使用 ISO-Prolog,在 assertz/1 之前调用的目标(还有 retract/1 )不受影响。这称为逻辑更新 View 。引用标准(ISO/IEC 13211-1:1995):

7.5.4 A logical database update

Any change in the database that occurs as the result of
executing a goal (for example, when the activator of a
subgoal is a call of assertz/1 or retract/1) shall affect
only an activation whose execution begins afterwards. The
change shall not affect any activation that is currently
being executed.

NOTE — Thus the database is frozen during the execution of
a goal, and the list of clauses defining a predication is fixed at
the moment of its execution (see 7.7.7 e).



请注意,在 DECsystem 10 Prolog 中,手册在 assert/1 之间做了很大的不同。和 assertz/1 .在以下引用自 1978 年的 DECsystem 10 用户指南中,术语 实现定义 只能表示标准中已知的 依赖实现 (意味着基本上未定义)。

5.5 Meta-Logical

...

assert(C)

The current instance of C is interpreted as a clause and is added
to the current interpreted program (with new private variables
replacing any uninstantiated variables). The position of the new
clause within the procedure concerned is implementation-defined.
C must be instantiated to a non-variable.



asserta(C)

Like assert(C), except that the new clause becomes the first
clause for the procedure concerned.



assertz(C)

Like assert(C), except that the new clause becomes the last
clause for the procedure concerned.



今天也有系统,其中 assert/1assertz/1不同。例如, .

关于prolog - GNU Prolog 断言错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20027182/

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