Using the following example the stack quickly fills due to an infinite recursion...
is_pos_integer(X):- is_pos_integer(Y),X is Y+1.
is_pos_integer(0).
However, the following example when run and requested to backtrack (using ;), hits the same infinite recursion without filling up the stack...
is_pos_integer(0).
is_pos_integer(X):- is_pos_integer(Y),X is Y+1.
I don't believe either function is tail recursive, so why would the second one not cause a ........... StackOverflow? (yaaaaoww....sunglasses)
positive_integer(I) :- I #> 0.- mat