Assume we have the following predicates (This is an example from Programming in Prolog):
[F0] isInteger(0).
[F1] isInteger(X):- isInteger(Y), X is Y+1.
The first result for query isInteger(R), the marker is placed at F0, and will return R=0
If user presses ; , the marker is placed at F1, we move to subgoal(isInteger(Y), which is satisfied with F0) and R=1.
I understand the above. Now here are my questions:
- If user presses ; again, where is the marker? How does the search proceed to return R=2? I have tried to understand the images in page 78-79 of the book, but it is not clear to me. The online tutorials that I found, do not handle backtracking in presence of recursion.
I am looking for any tutorials that explain backtracking in presence of recursion, hopefully with images of stack contents that helps me understand.
Thank you in advance Suzanne