GNU Prolog断言错误 [英] GNU Prolog assert error

查看:255
本文介绍了GNU Prolog断言错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Prolog的新手,但我被困在这个简单的命令上.我已经装好了 一个没有错误的知识库,每当我尝试进行 assert (甚至是 help )时, 得到以下消息:

I am new to Prolog, but I am stuck at this supposedly simple command. I have loaded a knowledge base with no errors, and whenever I try do assert (and even help) I get the following message:

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

我到底想念什么?赞赏.

What am I exactly missing? Appreciated.

推荐答案

请改用assertz/1asserta/1. GNU-Prolog不提供assert/1,因为标准中仅定义了asserta/1assertz/1.

Use assertz/1 or asserta/1 instead. GNU-Prolog does not provide assert/1 because only asserta/1 and assertz/1 are defined in the standard.

请注意,尽管asserta/1总是有一个明确的解释,即在子句的开头添加,但assertz/1的含义更难解析,因为在末尾添加子句"确实可以在断言该子句之前尚未完全确定已经调用的目标的语义.

Note that while asserta/1 always had one clear interpretation meaning add the clause at the beginning, the meaning of assertz/1 was more difficult to resolve since "add a clause at the end" does not completely determine the semantics of goals that have been invoked prior to asserting the clause.

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

With ISO-Prolog, goals that have been invoked prior to assertz/1 (but also retract/1) remain unaffected. This is known as the logical update view. To quote the standard (ISO/IEC 13211-1:1995):

7.5.4逻辑数据库更新

由于
而导致的数据库中的任何更改 执行目标(例如,当a
的激活器 subgoal是对assertz/1retract/1的调用),将影响
仅激活之后开始执行.
更改将不会影响当前正在进行的任何激活
被执行.

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.

注意—因此,在执行
时冻结数据库 一个目标,并且定义谓词的子句列表固定在
执行的时刻(请参见7.7.7 e).

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/1assertz/1之间产生了很大的不同.在1978年DECsystem 10用户指南的以下引用中,术语实现定义只能表示标准中称为实现依赖的含义(实质上是未定义的)./p>

Note that in DECsystem 10 Prolog, the manual made a big difference between assert/1 and assertz/1. In the following quote from the DECsystem 10 User guide of 1978, the term implementation defined can only mean what is known in the standard as implementation dependent (meaning essentially undefined).

5.5元逻辑

...

assert(C)

C的当前实例被解释为一个子句并被添加
到当前的解释程序(带有新的私有变量
替换所有未实例化的变量).新
的位置 有关过程中的子句是实现定义的.
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)

类似于assert(C),不同之处在于new子句成为第一个子句
有关程序的条款.

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

assertz(C)

类似于assert(C),不同之处在于new子句成为最后一个子句
有关程序的条款.

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

今天还有assert/1assertz/1不同的系统.例如,.

Also today there are systems where assert/1 and assertz/1 differ. E.g., xsb.

这篇关于GNU Prolog断言错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆