In order to define new predicates in the top  level you need to furst consult 
the pseudo-file user to specify the terminal. Press ctrl-D when finished.  
http://www.gprolog.org/manual/html_node/gprolog007.html


For example, you can see that I can reproduce your error, but then fix things. 
Note that the ctrl-D entered before the "user compiled..." line is not visible, 
but that is what exits the pseudo-file and causes what has been typed to be 
compiled.

$ gprolog
GNU Prolog 1.4.5 (32 bits)
Compiled Dec  3 2020, 00:37:14 with gcc
By Daniel Diaz
Copyright (C) 1999-2020 Daniel Diaz
| ?- p(a).
uncaught exception: error(existence_error(procedure,p/1),top_level/0)
| ?- [user].
compiling user for byte code...
p(a).

user compiled, 1 lines read - 168 bytes written, 20696 ms

(4 ms) yes
| ?- p(X).

X = a

yes
| ?-

This is great for learning, but more typically you would enter your predicates 
in a file and then consult that file in the top-level, or specify it on the 
gprolog command line, or even just compile it with gplc.


________________________________
From: Users-prolog on behalf of William Clodius via Users list for the GNU 
implementation of Prolog
Sent: Monday, May 3, 2021 6:58 PM
To: users-prolog@gnu.org
Subject: uncaught exception: error(existence_error(procedure, p/1), top_level/0)

I am trying to teach myself prolog starting with the J. R. Fisher tutorial 
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/pt_framer.html. I worked 
through the first few exercises using gprolog with no problems. I exited prolog 
for a break, but now when I restarted it I find myself unable to define 
procedures and am getting an uncaught exception:

gprolog
GNU Prolog 1.4.5 (64 bits)
Compiled Jul 14 2018, 16:25:15 with /usr/bin/clang
By Daniel Diaz
Copyright (C) 1999-2018 Daniel Diaz
| ?- p(a).
uncaught exception: error(existence_error(procedure,p/1),top_level/0)

I suspect I exited prolog improperly and there is an invalid state somewhere in 
a cache. FWIW I am running on a MacBook with OS X Big Sur version 11.3. Are 
there any suggestions about how to fix this?

  • uncaug... William Clodius via Users list for the GNU implementation of Prolog
    • R... Adam Russell

Reply via email to