I am trying to do simple two number multiplication in Prolog. When I initially launch Prolog without loading any file, I am able to type in:
X is 2 * 2.
And I get 4 as the answer. But when I launch Prolog by opening my file with my code, the above statement does not work anymore. It says:
ERROR: toplevel: Undefined procedure: (*)/2 (DWIM could not correct goal)
And when I load my code I get the following:
Warning: The predicates below are not defined. If these are defined
Warning: at runtime using assert/1, use :- dynamic Name/Arity.
Warning:
Warning: */2, which is referenced by
Warning: c:/filepath/project.pl:98:21: 1-st clause of multiply/3
Why does the multiplication work when I don't load my code, but not work when I load my code? This is part of the code I am using for multiplication:
:-dynamic(multiply/3).
multiply(X, Y, Z) :- Z is X * Y.
The two lines above are the only mentions of multiply in my code. I have spent a couple hours searching for answers and failed. Maybe my keywords I use to search are not specific enough, but it's difficult to find Prolog answers as it is. Am I doing something wrong? This issue is the only thing preventing me from finishing my project, which is too long to be of good use if posted.
Part of our project was to modify code given by the Professor. The Prof included the following line that was not being used anywhere:
:-op(150,xfx,is).
When removed, the 'is' in:
X is 2 * 2.
works and displays the correct answer.