Unable to define predicate in Prolog
prolog
Solution
As false said, If you want to define a predicate or function during the execution of the interpreter, you must enter the "user" mode of the interpreter, by typing:
['user'].
After typing your predicates, you'll just need to leave this "zone", as a confirmation to the interpreter that you're finished with the coding, and it can start to compile your predicates to bytecodes -- which you'll be, then, allowed to access through your function names.
To leave the "user" mode simply press `ctrl + d`.
Tested in both swipl and gprolog:
SWI-Prolog version 5.10.4
(GNU Prolog) 1.3.0
Regards!
Problem
I have just started learning `Prolog` and so pardon me if this is a bit naive, or rather a lot naive. I am trying to define this predicate ``` | ?- times(M,N,Product) :- Product is M*N. ``` which gives me this error ``` uncaught exception: error(existence_error(procedure,(:-)/2),top_level/0) ``` I am using GNU Prolog. What is the fault here ?