Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Prolog 当前_谓词/1不适用于:-动态?_Prolog_Swi Prolog_Prolog Directive Dynamic - Fatal编程技术网

Prolog 当前_谓词/1不适用于:-动态?

Prolog 当前_谓词/1不适用于:-动态?,prolog,swi-prolog,prolog-directive-dynamic,Prolog,Swi Prolog,Prolog Directive Dynamic,我在Prolog中使用断言定义了一些谓词 我正在使用current\u predicate/1,以了解断言是否已运行(只需断言一个值) 然而,swipl不断抱怨: Warning: The predicates below are not defined. If these are defined Warning: at runtime using assert/1, use :- dynamic Name/Arity. Warning: Warning: amountOfStudentsIn

我在Prolog中使用断言定义了一些谓词

我正在使用
current\u predicate/1
,以了解断言是否已运行(只需断言一个值)

然而,
swipl
不断抱怨:

Warning: The predicates below are not defined. If these are defined
Warning: at runtime using assert/1, use :- dynamic Name/Arity.
Warning: 
Warning: amountOfStudentsInCourseAsserted/2, which is referenced by
因此,我添加了
:-dynamicamountofstudentsinCourseAsserted/2
,但不幸的是,这将谓词添加到了当前的_谓词(谓词)。。因此,如果使用此动态命名,我将无法再使用当前谓词/1


是否还有另一个谓词,如
current\u predicate/1
,对于动态名称不正确?

您可以使用
predicate\u属性/2
内置谓词和
number\u of_子句/1
属性。

:-dynamic
声明是合适的,因为这将使符号在数据库中为人所知。然后在断言之前尝试匹配(使用适当的参数,在以下示例中忽略):

...
(  amountOfStudentsInCourseAsserted(_,_)
-> true
;  assert(amountOfStudentsInCourseAsserted(X,Y))
),
...

你确定这样行吗?在手册中:
对于外部谓词失败。
并且它会:
子句\u属性(ExamListAsserted,子句的数量)。错误
请重新阅读我的答案。您的注释引用了不同的内置谓词和不同的属性。我首先尝试使用谓词属性,然后测试子句属性。我复制粘贴了错误的项目。但不幸的是,它仍然是相同的结果:
predicate\u属性(ExamListAsserted,多个\u子句)。false。
总是false属性是
子句的数量/1
,而不是
子句的数量/0
。也就是说,属性有一个参数,正如名称所示,它是谓词s(X)的子句数。稍微安全一点是
(子句(amountofstudentsincourseserted(u,u),u)->…