Prolog gives error "undefined procedure" when trying to use :-
Asked Answered
M

2

14

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.

Medellin answered 23/3, 2011 at 10:56 Comment(0)
L
21

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.

Legislate answered 23/3, 2011 at 11:5 Comment(1)
Ah I understand now, I assumed it was similar to Python's interactive mode. Thanks!Medellin
D
6

You can try it this way

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

2 ?- a(B,c).
B = c.
Denis answered 23/3, 2011 at 21:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.