Choice points and Redo's in Prolog

Viewed 1464

After asking a question here about when exactly a Redo is called in Prolog with new variables, or when it is attempted with the same, I thought I figured it out. In the following piece of code, however, I thought that an additional Redo were to be called, but that does not seem to be the case.

My knowledge base is the following:

location(desk,office).
location(apple,kitchen).
location(flashlight,desk).
location('washing machine',cellar).
location(nani,'washing machine').
location(broccoli,kitchen).
location(crackers,kitchen).
location(computer,office).

edible(apple).
edible(crackers).

My query was

?-location(X,kitchen),edible(X).

with the following trace:

   Call: (9) location(_5612, kitchen) ? creep
   Exit: (9) location(apple, kitchen) ? creep
   Call: (9) edible(apple) ? creep
   Exit: (9) edible(apple) ? creep
X = apple ;
   Redo: (9) location(_5612, kitchen) ? creep       <====
   Exit: (9) location(broccoli, kitchen) ? creep
   Call: (9) edible(broccoli) ? creep
   Fail: (9) edible(broccoli) ? creep
   Redo: (9) location(_5612, kitchen) ? creep
   Exit: (9) location(crackers, kitchen) ? creep
   Call: (9) edible(crackers) ? creep
   Exit: (9) edible(crackers) ? creep
X = crackers.

Why is there not an additional Redo after the first solution along the lines of Redo: (9) edible(apple) (which would then fail, before going on to the next Redo) since there is still another fact in the code with the functor edible, which would mean that there was a choice point that created? I found an annotated trace of the same query here. I will post a short snippet from it, because it has the additional Redo that I feel is missing here:

screenshot of webpage

Can someone point me in the right direction as to what is to be expected in this case?

Thanks.

2 Answers
Related