-
Notifications
You must be signed in to change notification settings - Fork 57
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
Created rewrite tactic #746
Conversation
Some comments Enrico made on the Zulip:
I will address these. |
Okay, comments fixed. |
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.
Thanks for your contribution, please take a look at my comments
apps/eltac/theories/rewrite.v
Outdated
% Eq is a direct Gallina term or a gref and we will infer its type | ||
% from context | ||
coq.typecheck Eq Ty ok; | ||
% Eq is a reference to a declared variable in the context | ||
std.mem Ctx (decl Eq _ Ty)), |
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.
The LHS of ;
should suffice since Ctx is loaded hence you are really running Ctx => coq.typecheck ...
and that knows the type of proof variables.
apps/eltac/theories/rewrite.v
Outdated
% First, introduce a rule that causes "copy" to act as a function | ||
% sending a type T to the same type, but with all | ||
% subterms of T unifiable with Q to be replaced with a fresh constant x. | ||
pi x\ (pi J\ copy J x :- coq.unify-leq Q J ok) => |
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.
This looks like a good introduction to the power of copy etc, thanks for providing it.
But this implementation of rewrite is known to be a "bad rewrite" since it is too smart, eg lets you rewrite with commutativity of addition on a goal like 2 * x = ..
that has no addition in it. I recommend at least writing a comment about this, or write a more complex line that compares the key verbatim, see for
example
coq-elpi/elpi/elpi_elaborator.elpi
Lines 173 to 177 in c40e913
bind-list [app [C| AS] |VS] T R :- key C, !, | |
pi x\ | |
(pi L X\ bind (app[C|L]) X :- get-option "unif:greedy" tt, unify-list-eq L AS, X = x, !) => | |
(pi L X\ bind (app[C|L]) X :- not (get-option "unif:greedy" tt),unify-list-eq L AS, X = x) => | |
bind-list VS T (R x). |
apps/eltac/theories/rewrite.v
Outdated
(fun _ S (a\ | ||
fun _ {{ @eq lp:S lp:P lp:Q }} (_\ A a ) | ||
)) |
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.
(fun _ S (a\ | |
fun _ {{ @eq lp:S lp:P lp:Q }} (_\ A a ) | |
)) | |
{{ fun a (e : @eq lp:S lp:P lp:Q) => lp:(A a) }} |
Also shouldn't Q be a ?
I have created a simple rewriting tactic that Enrico suggested on the Zulip would be a good fit for the eltac repo.