Re: problems with not and unasserted facts

Lindsey Spratt <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
not/1 is not a built-in in gprolog. Instead, use \+ / 1. This means 
"fails to solve", the negation-as-failure predicate.
Many prologs avoid the not/1 built-in because it is not possible to 
implement it in the fully general case and having the built-in would be 
misleading. You could define a not/1 predicate as:

not(Goal) :-
	\+ call(Goal).

The message "uncaught exception: 
error(existence_error(procedure,not/1),action/2)" is gprolog's graceful 
:-) way of telling you that not/1 is an undefined procedure (predicate) 
encountered while solving an action/2 clause.
The behavior you were looking for, a missing predicate definition 
causing a simple failure, can be caused by setting the prolog flag 
'unknown' to 'fail'. Solve the following goal on the command line of 
gprolog:
	set_prolog_flag(unknown, fail).

HTH,
Lindsey Spratt

On Aug 30, 2005, at 7:24 PM, Cliff Bender wrote:

> Hi. I'm new to prolog, but am trying to learn the language to fulfill 
> a prereq for a grad school program. I'm currently using Niel C. Rowe's 
> "Artificial Intelligence Through Prolog" for reference and sample 
> programs. I've typed out the traffic program on pages 61-62:
>
>
> /*--------Rules for arrow lights--------*/
> /*A*/   action(car, stop) :- light(yellow_arrow, Direction), 
> safe_stop_possible.
> /*D,E*/ action(car, yield_and_leftturn)  :- light(yellow_arrow, left), 
> not(safe_stop_possible).
>
[snip program details]
>  given the facts:
>    safe_stop_possible.
>    light(yellow,steady).
>    light(green_arrow,left).
>
>  the query action(car,X) returns:
>
>
> X = yield_and_go ? ;
> uncaught exception: error(existence_error(procedure,not/1),action/2)
>
>
>  if I don't put safe_stop_possible in as a fact, it blows up as well.
>
>  can anyone help? this is leaving me stumped. i thought not was a 
> built-in predicate? and if a fact isn't declared/asserted, that just 
> means that querying it would return false, correct?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.