(Upon the suggestion of @repeat) Consider a query of a pure program1 ?- G_0. What use if any would the query ?- G_0, G_0. have?
Footnotes
1 No tabling (to be safe), constraints are OK.
Previous post on the subject.
(Upon the suggestion of @repeat) Consider a query of a pure program1 ?- G_0. What use if any would the query ?- G_0, G_0. have?
Footnotes
1 No tabling (to be safe), constraints are OK.
Previous post on the subject.
On
Consider a query of a pure program1 ?- G_0. What use if any would the query ?- G_0, G_0. have?
I see no usefulness of the second goal, especially when tail recursion optimization (last call optimization) is ON.
I could realize an GC issue (stack/heap overflow) when the query is resources-greedy and above options are OFF (e.g. when debugging).
I think the second call is redundant (for pure program) and should be eliminated by the compiler.
The query
?- G_0, G_0.helps to identify redundant answers of?- G_0.To do so it suffices to compare the number of answers of
?- G_0.with the number of answers of?- G_0, G_0.. No need to store those answers (which is a frequent source of errors anyway). Just two integers suffice! If they are equal, then there is no redundancy. But if?- G_0, G_0.has more answers, then there is some redundancy. Here is an example:... and now let's fix this:
No need to manually inspect the constraints involved.
This can be further extended when we are explicitly searching for redundant answers only using
call_nth/2.