-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reversal
query from DCG chapter loops
#36
Comments
There's a slight error in the transcription of the first call of the second clause. After correcting, we get:
|
Adding to this, we can use failure slicing to produce explanations for non-termination. For example, I can insert reversal([]) --> { false }, []. reversal([L|Ls]) --> reversal([Ls]), { false }, [L]. This means that we are effectively considering now the following fragment: reversal([L|Ls]) --> reversal([Ls]). With which we still get (universal) non-termination: ?- phrase(reversal("abcd"), Ls), false. loops. As long as this fragment does not terminate, the original program also does not terminate. Hence, if you want to improve termination properties of your grammar, you must change this specific fragment in the original program. The ability to selectively remove portions of the code and still be able to make interesting statements about the original program by reasoning about only the remainder is one of the greatest attractions of logic programming. |
Ah. Quite so. Thank you. |
When I try to follow the
reversal
example from the DCG chapter, the example query loops on my system. More generally, the queryphrase(reversal([a], Ls)
loops under either scryer or swipl using the following file.Can you verify that your system actually produces the below answer from the book's sample query? If so, can you imagine what I might be doing wrong?
I am currently using the following versions:
The text was updated successfully, but these errors were encountered: