Prolog gives error “undefined procedure” when trying to use :-

六眼飞鱼酱① 提交于 2019-12-21 07:16:30

问题


I'm using SWI-Prolog on Windows and am getting the following error:

14 ?- parent(X, Y) :- child(Y, X).
ERROR: toplevel: Undefined procedure: (:-)/2 (DWIM could not correct)

I'm not entirely sure what's going on, as this worked last week and I am just starting to learn Prolog.


回答1:


The FAQ says it all: http://www.swi-prolog.org/FAQ/ToplevelMode.html

You need to create a file and write your program with rules there. The top level command line will only allow you to issue queries.




回答2:


You can try it this way

1 ?- assert(a(A,B):-A=B).
true.

2 ?- a(B,c).
B = c.


来源:https://stackoverflow.com/questions/5404143/prolog-gives-error-undefined-procedure-when-trying-to-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!