users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

newbie questions: re-execution, negation


From: Josh
Subject: newbie questions: re-execution, negation
Date: Thu, 25 May 2006 15:33:57 -0700

Hi.  I'm brand new to Prolog and am having trouble understanding some
of the results I get from the gprolog interpreter.  For instance, the
following simple program is meant to yield 'true' for both c(foo) and
c(bar):

a(foo).
a(bar).
b(foo).

c(X) :- a(X) ; b(X).

But in fact I get this:

| ?- c(foo).

true ? ;

yes
| ?- c(bar).

true ? ;

no

Could someone humor me and tell me why I am prompted for another
result after 'true' (and why the 'yes' after the first result and the
'no' after the second).  I get the same behavior if I use:

c(X) :- a(X).
c(X) :- b(X).

Also, I've had to define my own negation operator because if I try to
compile something like:

d(X) :- not a(X).

...I get an error:

/[...]/test.pl:29 error: syntax error: . or operator expected after
expression (char:13)
       1 error(s)
compilation failed

I've read most of TFM as well as a Prolog tutorial, but I don't see
why this shouldn't work.  Btw. this is gprolog 1.2.16 on i386 Linux.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]