无法推导出可以调用哪个谓词
Could not derive which predicate may be called
我正在备考,但在其中一个准备题上卡住了:
问题:
The following Prolog-program is a meta-program. Explain why this
program is a meta-program and give the output to the three questions
to the program:
?- prove(moving_method(bird,M),N).
?- prove(moving_method(ross,M),N).
?- prove(moving_method(kim,M),N).
我正在尝试 运行 代码(在 swish.swi-prolog.org 上),但它只给我这个错误消息:
Sandbox restriction!
Could not derive which predicate may be called from
call(C)
prove(A,B)
prove(moving_method(bird,A),B)
我们给出的代码:
:- dynamic moving_method/2, is_a/2.
is_a(bird,animal).
is_a(ross,albatross).
is_a(kim,kiwi).
is_a(albatross,bird).
moving_method(bird,fly).
moving_method(kiwi,walk).
prove(Fact,l):-
Fact,!.
prove(Fact,X):-
Fact=..[Rel,A1,A2],
is_a(A1,SA),
NewFact=..[Rel,SA,A2],
prove(NewFact,X1),
X is X1 + 1.
错误消息可能相当简单,但我该如何解决?为什么这是一个元程序?
谢谢!
why is this a meta-program?
参见:SWI-Prolog Meta-Call Predicates
Meta-call predicates are used to call terms constructed at run time.
在这种情况下,传递要调用的谓词,Fact
,然后 运行 它作为目标。
我正在备考,但在其中一个准备题上卡住了:
问题:
The following Prolog-program is a meta-program. Explain why this program is a meta-program and give the output to the three questions to the program:
?- prove(moving_method(bird,M),N).
?- prove(moving_method(ross,M),N).
?- prove(moving_method(kim,M),N).
我正在尝试 运行 代码(在 swish.swi-prolog.org 上),但它只给我这个错误消息:
Sandbox restriction!
Could not derive which predicate may be called from
call(C)
prove(A,B)
prove(moving_method(bird,A),B)
我们给出的代码:
:- dynamic moving_method/2, is_a/2.
is_a(bird,animal).
is_a(ross,albatross).
is_a(kim,kiwi).
is_a(albatross,bird).
moving_method(bird,fly).
moving_method(kiwi,walk).
prove(Fact,l):-
Fact,!.
prove(Fact,X):-
Fact=..[Rel,A1,A2],
is_a(A1,SA),
NewFact=..[Rel,SA,A2],
prove(NewFact,X1),
X is X1 + 1.
错误消息可能相当简单,但我该如何解决?为什么这是一个元程序?
谢谢!
why is this a meta-program?
参见:SWI-Prolog Meta-Call Predicates
Meta-call predicates are used to call terms constructed at run time.
在这种情况下,传递要调用的谓词,Fact
,然后 运行 它作为目标。