I've copied the code from a text book for a simple UI in Prolog, as below, or on this URL: https://swish.swi-prolog.org/p/QgEReeXy.pl
/* Weather knowledge base*/
weather(good):-
temp(high),
humidity(dry),
sky(sunny).
weather(bad):-
(humidity(wet);
temp(low);
sky(cloudy)).
/* interface */
go:-
write('Is the temperature high or low?'),
read(Temp), nl,
write('Is the sky sunny or cloudy?'),
read(Sky), nl,
write('Is the humidity dry or wet?'),
read(Humidity), nl,
assert(temp(Temp)),
assert(sky(Sky)),
assert(humidity(Humidity)),
weather(Weather),
write('The weather is '), write(Weather),
retractall(temp(_)),
retractall(sky(_)),
retractall(humidity(_)).
When I run go. I get
procedure `temp(A)' does not exist
Reachable from:
weather(A)
go
Is this due to a small typo, or is there a bigger problem with the code please?
:- dynamic humidity/1, temp/1, sky/1.from the top of your file. You need to forewarn Prolog that you're going to be messing around with the dynamic store of these predicates. - Daniel Lyonsrunin the lower right. - Guy Coder