1

我必须在 SWI 中断言这种 CLP(FD) 规则:

    asserta(schedule(A,B) :-  V = [S0,S1,S2],V ins 0..sup).

但我收到此错误:

    ERROR: Syntax error: Operator expected
    ERROR: asserta(schedule(A,B) :-  V = [S0,S1,S2],V 
    ERROR: ** here **
    ERROR: ins 0..sup) . 

为什么?谢谢你!

4

1 回答 1

2

这里有两个错误:

您需要在阅读文本时加载 CLP(FD)。所以需要有use_module(library(clpfd))一个指令,就像一行一样

:- use_module(library(clpfd)).

或作为顶级目标输入。这是必要的,因为您使用(ins)/2的是运算符形式。

另一个问题是缺少括号。它应该改为:

 ..., asserta( ( schedule(A,B) :- V = [_,_,_], V ins 0..sup ) ), ...

顺便说一句,我认为断言这样的规则没有多大意义。动态数据库很少与断言规则一起使用。

于 2013-09-02T18:24:02.313 回答