tracing does not show final redo and fail

View: New views
2 Messages — Rating Filter:   Alert me  

tracing does not show final redo and fail

by schemelab :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm reading some data on how the prolog engine works:
http://www.amzi.com/AdventureInProlog/index.htm

and was expecting my trace to show a final redo and fail after finding X = crackers,
but for some reason it did not. Instead SWI Prolog immediately showed 'No'

This is something of a crosspost. But I got no response at comp.lang.prolog:
http://groups.google.com/group/comp.lang.prolog/browse_thread/thread/4c4a1612ba27f132#

Transcript and program follow

/* Transcript */
[debug]  ?- trace.

Yes
[trace]  ?- edible(X).
   Call: (7) edible(_G302) ?
   Exit: (7) edible(apple) ?

X = apple ;
   Redo: (7) edible(_G302) ?
   Exit: (7) edible(crackers) ? creep

X = crackers ;

No
[debug]  ?-

/* Program */

edible(apple).
edible(crackers).

Re: tracing does not show final redo and fail

by Nicolas Pelletier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

On Sat, Oct 24, 2009 at 03:41, metaperl.j <metaperl.j@...> wrote:
>
> I'm reading some data on how the prolog engine works:
> http://www.amzi.com/AdventureInProlog/index.htm
>
> and was expecting my trace to show a final redo and fail after finding X =
> crackers,
> but for some reason it did not. Instead SWI Prolog immediately showed 'No'

From the documentation for current_prolog_flag/2:

> prompt_alternatives_on(atom, changeable)
>     Determines prompting for alternatives in the Prolog toplevel. Default is determinism, which implies the system prompts for alternatives if the goal
> succeeded while leaving choicepoints. Many classical Prolog systems behave as groundness: they prompt for alternatives if and only if the query
> contains variables.

?- [user].
|: edible(apple).
|: edible(crackers).
|: % user://1 compiled 0.00 sec, 744 bytes
true.

?- edible(X).
X = apple ;
X = crackers.

?- set_prolog_flag(prompt_alternatives_on, groundness).
true.

?- edible(X).
X = apple ;
X = crackers ;    % <-- Prompts for user input here
false.

The second time, there is a choicepoint left after X = crackers is
found, as you expect.

Hope this helps,

--
Nicolas
_______________________________________________
SWI-Prolog mailing list
SWI-Prolog@...
https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog