-
Notifications
You must be signed in to change notification settings - Fork 8
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
proof-general solving holes #22
base: master
Are you sure you want to change the base?
Conversation
This is a good start, thanks! Here are some suggestions for improvement:
Let me know if it would be helpful to modify the output of |
Thanks for the suggestions.
|
It's true that when we successfully solve a hole in proofgeneral mode, we should replace the In particular, what I'm saying is that the replacement of the Hole numbers are assigned sequentially in each session. It would be too much trouble to try to keep track of which holes have been un-done so that their numbers could be re-used, and since the user isn't supposed to ever have to think about the hole numbers, it shouldn't matter. |
Another thing that needs to be dealt with somehow here is notation precedence. For instance, if we have a hole appearing as a function argument like The simplest thing would be to always insert such parentheses, but that would look a bit ugly in cases where they aren't necessary. However, the only other option I can think of is for each hole to store the precedence at which it was parsed (which shouldn't be too hard) and for parsing of a new term to somehow compute the maximum precedence in which it could be parsed without parentheses (which would require some less trivial alterations to the parser), so that they could be compared and parentheses inserted only if necessary. How does Agda deal with this issue? |
I'll check Agda-mode and try to figure out it later. I have other questions before proceed:
You mean after binding the hole metavariable to the value of the supplied term, if we going back and reload, the hole shouldn't be captured? I understand that since there is still
Am I missing something? Second, to do replacement, I should check whether |
No, I mean that in two hypothetical different worlds, in which we do two different things, namely:
Then the future behavior of these two worlds, as far as interaction with Narya goes, should be indistinguishable. This is like Agda's behavior with filling holes too, except that Agda doesn't have a notion of only partially processing the file. When you fill a hole in Agda, it replaces the hole in the Emacs buffer with the new term, but it doesn't reload the entire file: it internally binds that hole to the term you supplied, and other commands that use that hole now behave as if you'd written that term in place of the hole originally. Sometimes something goes wrong and you do have to reload the entire file, but (I would argue) whenever that happens it is a bug in Agda, even if it's one that's been declared unfixable. |
Regarding checking for errors, did you try |
Yes, I tried |
|
I think it's better now. Also in the case we need to get the response after executing solve command, I added
Let me know if you suggest any improvement. |
Thanks! I haven't tested it yet, but according to the documentation of |
Thanks, you're right. I edited it. |
(let ((hole-overlay (car (seq-filter (lambda (ovl) | ||
(eq (get-char-property (point) 'narya-hole) | ||
(overlay-get ovl 'narya-hole))) | ||
narya-hole-overlays)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option here would be to iterate only through the overlays at point with overlays-in
, looking for one that has a narya-hole
property. I don't know which would be better, just thought I would mention it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean the following
(let ((hole-overlay (car (seq-filter (lambda (ovl)
(overlay-get ovl 'narya-hole))
(overlays-in (point) (point))))))
It didn't work because it does not capture a hole overlay. But I might have mistyped it.
However, the following worked
(let ((hole-overlay (car (seq-filter (lambda (ovl)
(overlay-get ovl 'narya-hole))
(overlays-at (point))))))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, that makes sense -- overlays-in
requires at least one character to be contained in both the overlay and the region supplied, whereas the region from point
to point
is always empty. So overlays-at
is correct.
This is good! Two more things to do that I can think of, before we merge this:
|
I'll look at those soon. |
I attempted to handle "solve a hole" in proofgeneral mode.
I think it works, but let me know if you have any suggestions.