1

I'm really new to prolog and I'm trying out some examples. I'm getting the error

ERROR: Undefined procedure: eats/2 (DWIM could not correct goal) when I run the rule.

Why is it showing if my rule is true? Please see rule below from my .pl file. This is taken from an example.

eats(fred,oranges).                           /* "Fred eats oranges" */

Prolog command consult: eats(fred,oranges).

Any explanation for this error would be very helpful.

cala
  • 767
  • 4
  • 11
  • 28
  • Carried out some more troubleshooting, might have been .pl file not loaded correctly? – cala Aug 12 '18 at 18:36
  • 1
    There's nothing wrong with your code, so probably it didn't get consulted properly. – Daniel Lyons Aug 12 '18 at 21:53
  • Were you able to figure out your problem? – Daniel Lyons Aug 13 '18 at 19:02
  • @DanielLyons yes I'm just back on it now. Moving onto recursion and lists. I had to click 'File' > 'Reload modified files'. It also works by re-consulting the .pl program. Thanks for your help it's great! – cala Aug 13 '18 at 19:35

2 Answers2

0

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.

https://stackoverflow.com/a/5404259/1599699

Andrew
  • 5,839
  • 1
  • 51
  • 72
0

There is nothing wrong with the command you can resolve the issue by a simple command go to compile< compile buffer or use shortcut key control-c control-b. This will surely make your code run