Undefined procedure error in prologue SWI

Running SWI prologue on Windows 8 for the first time.

this is my program file (.pl), very simple, with just 3 facts: (I'm a complete prologue newbie)

hello.
a.
b.

      

When I load it (consult) into prolog-SWI and run 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 this is a simple mistake because it was c

never mentioned in the program as a fact, that's fine, but after looking at examples on the Internet and the ones I found in the Prolog class in these examples, the answers are yes

when the fact is in the program, and no

when it is not this way. Mine responds true

if it does and gives me this long error if it doesn't.

See link example

Where are the answers no

for the hazy.

+3


source to share


1 answer


SWI has a slightly different top-level shell, heavily inspired by the Prolog IV shell . The idea is that you fall back to executing the executable request again. Therefore, true.

instead of yes

and false.

instead of no

. This is especially useful if you want to "paste back" the response in the next request.

?- append(Xs,Ys,[1,4,7]).
Xs = [],
Ys = [1, 4, 7] ;
Xs = [1],
Ys = [4, 7] ;
Xs = [1, 4],
Ys = [7] ;
Xs = [1, 4, 7],
Ys = [] ;
false.

      

This is even more useful when you are working with constraints like library(clpfd)

:



?- use_module(library(clpfd)).
true.

?- X #> 3, X#>=Y,abs(X) #< 100.
X in 4..99,
X#>=Y,
Y in inf..99.

      

Another problem is the usual default behavior on many systems: if there is no sentence and no other mention of a specific predicate, the system assumes that you have mistakenly specified this name and have indicated an error accordingly. If you really insist (don't do it!), You can switch the timing to late 1970s behavior with help set_prolog_flag(unknown, fail).

, but it's better to put it back in right away with set_prolog_flag(unknown, error)

.

+4


source







All Articles