Running prolog SWI on windows 8 for the first time.
this is my program (.pl) file, very basic just with 3 facts: (I'm a complete prolog beginner)
hello.
a.
b.
When I load it (consult) in prolog-SWI, and work with the program, I get this error in my output:
12 ?- b.
true.
13 ?- a.
true.
14 ?- c.
ERROR: toplevel: Undefined procedure: c/0 (DWIM could not correct goal)
Now if that is a simple error because c
was never stated in the program as a fact then that is fine, but after looking at the examples online and the ones I had found in class Prolog in these examples replies yes
when a fact is in the program, and no
when it is not. Mine replies true
if it is, and gives me that long error if it is not.
See this link for example
Where is replies no
for foggy.
SWI has a slightly different top level shell much inspired by Prolog IV's shell. The idea is that you get back as an answer again an executable query. Therefore
true.
instead ofyes
andfalse.
instead ofno
. This is particularly useful if you want to "paste back" an answer into the next query.It is even more useful, when you are working with constraints like
library(clpfd)
:The other problem is common default behavior in many systems: If there is no clause and no other mentioning of a particular predicate, the system assumes that you mistyped the name and gives you an error accordingly. If you really insist (don't!), you can switch behavior time traveling into the late 1970s with
set_prolog_flag(unknown, fail).
but better switch it back immediately withset_prolog_flag(unknown, error)
.