SWI Prolog忽略了不连续的谓词

时间:2014-02-19 20:15:28

标签: prolog

我很难理解如何在(SWI)Prolog中正确使用discontiguous/1谓词。

buumi.pl成为伪事实的小文件:

discontiguous(buumi/1).

buumi(eins).
buri(zwei).
buumi(drei).

然而,运行swipl -s Buumi.pl会发出此警告:

% swipl -s Buumi.prolog
Warning: [...]/Buumi.prolog:5:
        Clauses of buumi/1 are not together in the source-file

文档很模糊,只是说明了

discontiguous :PredicateIndicator, ...

但没有提供有关如何使用它的具体示例。我有 发现一些例子表明我正确使用它;至少, swipl没有抱怨,但是再一次,它也不尊重我的要求。 我在这里做错了什么?

2 个答案:

答案 0 :(得分:8)

discontiguous/1是ISO指令。你必须把它作为

:- discontiguous(pred/2).

在Prolog文本的开头。

答案 1 :(得分:0)

我正在为 x86_64-linux 使用 SWI-Prolog 8.2.4 版。

我的警告说要进入

:- discontiguous pred-name/1.

这最终奏效了,我在加载 prolog 文件后得到如下输出:

?- consult('animals.pl').     (My entry)

  true.                       (SWIPL response)

必须明确输入每个谓词名称,否则 SWIPL 假定未声明谓词的默认规则并输出相同的旧警告。