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
pattern for rewriting Boolean (in)equalities #869
Conversation
LGTM, but
|
Another issue I have with this PR is that it corrects some spacing problems which are independent from the subject in the title. It is too bad that these corrections will be forgotten if this PR is not incorporated. |
I tried at some point and failed: this was too ambiguous, e.g. for which Like many things in ssr most people will not use it until they really feel the need, and that's when they must be able find them through documentation. Maybe we should rewrite a mathcomp local addentum to https://coq.inria.fr/refman/proof-engine/ssreflect-proof-language.html for that purpose? |
The topic was discussed during the last mathcomp-dev meeting, see https://github.com/math-comp/math-comp/wiki/Minutes-April-06-2022.
with the following comment: "one still needs to put in %pattern scope some notations for the usual infix symbols." Should it come as a replacement or an addition? |
I would vote for "as an addition" |
I guess one needs to make the scope explicit around symb as well. And test it a little, since I did not do it very carefully. |
a pity we can't write |
mathcomp/ssreflect/eqtype.v
Outdated
@@ -38,6 +38,8 @@ From mathcomp Require Import ssreflect ssrfun ssrbool. | |||
(* x != y :> T <=> x and y compare unequal at type T. *) | |||
(* x =P y :: a proof of reflect (x = y) (x == y); x =P y coerces *) | |||
(* to x == y -> x = y. *) | |||
(* eqLHS := (X in (X == _))%pattern (for rewriting) *) |
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.
should it not be eqbLHS
?
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.
for the sake of consistency indeed, but eqLHS
is free and shorter; if we enforce consistency to have eqbLHS
then we could think of using eqLHS
instead of LHS
and that does not seem a good idea given than it is used very often
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.
my poor brain prefers consistency 😉
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.
I would prefer eqLHS
to be a synonymous of LHS
and is there a need for leqLHS
and ltnLHS
or is this captured by leLHS
and ltLHS
?
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 last push force added leqLHS, etc. They seem quite useful. As for adding eqLHS as a synonymous of LHS, it looks like it better be an addition to Coq's ssrmatching.v. Should we PR this to Coq?
I think you can if you add these notations in the pattern scope (not as infix, just as atoms). |
I am pretty bad at notation I tried to add |
I'm not on my pc
|
Then we can maybe merge this one for now and issue for the more general pattern (it might require some testing). |
I have tried Notation "<=" := leq : symb_scope.
Delimit Scope symb_scope with symb.
Notation "'LEFT' f" := (X in f%symb X _)%pattern (at level 10).
Goal 1 <= 2 . and I get a |
I think we need to create a new nonterminal (a.k.a. custom entry) for that otherwise we will screw up the main parser. |
ok this works Declare Custom Entry symb.
Notation "<=" := leq (in custom symb at level 0).
Notation "'LEFT' f" := (X in f X _)%pattern (f in custom symb, at level 10).
Goal 1 <= 2 .
rewrite -[LEFT <=](addn1). |
Motivation for this change
These patterns were introduced by @CohenCyril in mathcomp-analysis and proved useful @thery .
They do not seem to be that useful in mathcomp itself but they could benefit to other users.
Things done/to do
CHANGELOG_UNRELEASED.md
(do not edit former entries)Automatic note to reviewers
Read this Checklist and make sure there is a milestone.