8000 Backport from stablesort by pi8027 · Pull Request #1097 · math-comp/math-comp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Backport from stablesort #1097

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

Merged
merged 1 commit into from
Oct 24, 2023
Merged

Backport from stablesort #1097

merged 1 commit into from
Oct 24, 2023

Conversation

pi8027
Copy link
Member
@pi8027 pi8027 commented Oct 19, 2023
Motivation for this change

Backport from this file: https://github.com/pi8027/stablesort/blob/565499cbef5884e219e8af6048083651ef0f43cf/theories/mathcomp_ext.v

Things done/to do
  • added corresponding entries in CHANGELOG_UNRELEASED.md
  • [ ] added corresponding documentation in the headers
  • tried to abide by the contribution guide
Compatibility with MathComp 1.X
  • I added the label TODO: MC-1 port to make sure someone ports this PR to
    the mathcomp-1 branch or I already opened an issue or PR (please cross reference).
Automatic note to reviewers

Read this Checklist and put a milestone if possible.

Comment on lines 4263 to 4274
Lemma eq_allrel_l {T : eqType} {S} (r : T -> S -> bool) (s1 s1' : seq T) s2 :
s1 =i s1' -> allrel r s1 s2 = allrel r s1' s2.
Proof. by move=> eqs1; apply: eq_all_r. Qed.

Lemma eq_allrel_r {T} {S : eqType} (r : T -> S -> bool) s1 (s2 s2' : seq S) :
s2 =i s2' -> allrel r s1 s2 = allrel r s1 s2'.
Proof. by rewrite ![allrel _ s1 _]allrelC; apply: eq_allrel_l. Qed.

Lemma eq_allrel2 {T S : eqType} (r : T -> S -> bool)
(s1 s1' : seq T) (s2 s2' : seq S) :
s1 =i s1' -> s2 =i s2' -> allrel r s1 s2 = allrel r s1' s2'.
Proof. by move=> /eq_allrel_l -> /eq_allrel_r ->. Qed.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure if these names are coherent with the following lemma:

Lemma eq_allrel {T S : Type} (r r' : T -> S -> bool) :
  r =2 r' -> allrel r =2 allrel r'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been using the suffix 2 for operations that apply to the both sides of a relation, like:

Lemma lteN2 x y : (- x < - y) = (y < x).

I am wondering whether eq_allrel should be eq2_allrel and
eq_allrel2 be eq_allrel because in that case eq_allrel_r/l
would seem more natural to me.
allrel_rev2 seems ok to me (somehow, a shortcut for allrel_revrev).
I would have found allrelrev2 ok but one may find it a bit disgracious.
I also have the following proposal:
allrel_revr could be allrelsrev
and allrel_revl could be allrelrevs (positional notations with "s" to mark the position of a string, I have a tendency to prefer that over l/r suffixes but like the above I wouldn't argue too long with somebody thinking it is ugly).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names like allrelsrev and allrelrevs work only when rev is replaced with one capital character IMO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering whether eq_allrel should be eq2_allrel

A grep on "eq2_" returns nothing but an old thing that was renamed in the changelog, so likely not a consensual choice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have a suffix _mem (because the hypothesis is using =i) but I think it's good enough as it is.
We'd like to release a 2.1 tomorrow and it would be nice that this lands in it, so I'm ratherfor merging as it is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering whether eq_allrel should be eq2_allrel and
eq_allrel2 be eq_allrel because in that case eq_allrel_r/l
would seem more natural to me.

By the way, it looks like _r and _l are often used in the Coq standard library
but much less in MathComp. Don't you want to remove the _?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(We are planning to release today by the way ^_^.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about eq_allrel2 -> eq_allrel_mem2 (we "apply" mem on the left and on the right of the rel)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(which then calls for the renaming eq_allrel_l -> eq_allrel_meml)

@pi8027 pi8027 requested a review from affeldt-aist October 21, 2023 14:45
@proux01 proux01 added this to the 2.1.0 milestone Oct 24, 2023
@proux01 proux01 force-pushed the backport-stablesort branch from 6061c29 to b9430c4 Compare October 24, 2023 08:27
@proux01 proux01 merged commit 290a24d into master Oct 24, 2023
@pi8027 pi8027 deleted the backport-stablesort branch October 25, 2023 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0