Skip to content
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 by Bors] - feat: gcd and coprime sub #7051

Closed
wants to merge 7 commits into from

Conversation

mo271
Copy link
Collaborator

@mo271 mo271 commented Sep 9, 2023


Open in Gitpod

@mo271
Copy link
Collaborator Author

mo271 commented Sep 9, 2023

I'm not super sure about the naming.
I also considered if this was a good addition to std, but I think this is the better place for it.

@mo271 mo271 added awaiting-review The author would like community review of the PR awaiting-CI labels Sep 9, 2023
mo271 and others added 2 commits September 9, 2023 15:03
Co-authored-by: Alex J Best <alex.j.best@gmail.com>
Co-authored-by: Alex J Best <alex.j.best@gmail.com>
@adomani
Copy link
Collaborator

adomani commented Sep 10, 2023

What is the reason to introduce the lemmas that deal with subtraction and then switch the inputs to gcd? I would have thought that there should be the simp lemma that removes the subtraction, but I am not sure about also swapping the arguments.

@mo271
Copy link
Collaborator Author

mo271 commented Sep 10, 2023

What is the reason to introduce the lemmas that deal with subtraction and then switch the inputs to gcd? I would have thought that there should be the simp lemma that removes the subtraction, but I am not sure about also swapping the arguments.

The reason I added both versions was to try to be in sync with what is done for the add lemmas above. Let's see:

1: gcd m (n + m) = gcd m n
2: gcd (m + n) n = gcd m n
3: gcd (m + n) m = gcd n m
4: gcd m (m + n) = gcd m n

exchanging m and n on the righthand side to always be gcd m n, we then have

1: gcd m (n + m) 
2: gcd (m + n) n
3: gcd (n + m) n
4: gcd m (m + n) 

by analogy we replace the + by the -

1: gcd m (n - m) 
2: gcd (m - n) n
3: gcd (n - m) n
4: gcd m (m - n) 

I suppose you are right, there are only 4 lemmas needed. That's what I did now...

@adomani
Copy link
Collaborator

adomani commented Sep 10, 2023

Yes, my reasoning was: the argument that does not have add/sub stays what it is and does not swap places with the other. The simp lemma just undoes one operation in one coordinate, but does not also swap coordinates.

Of course, e.g. in the Euclidean algorithm, you alternate subtracting and swapping, but I think that the simp lemma should not be trying to do that.

Copy link
Collaborator

@adomani adomani left a comment

Choose a reason for hiding this comment

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

I personally find the naming strange, but it seems to be consistent with the add versions. LGTM!

Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

Thanks 🎉

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review The author would like community review of the PR labels Sep 12, 2023
bors bot pushed a commit that referenced this pull request Sep 12, 2023
Co-authored-by: Moritz Firsching <firsching@google.com>
@bors
Copy link

bors bot commented Sep 12, 2023

Build failed (retrying...):

@ADedecker
Copy link
Member

bors retry

bors bot pushed a commit that referenced this pull request Sep 12, 2023
Co-authored-by: Moritz Firsching <firsching@google.com>
@bors
Copy link

bors bot commented Sep 12, 2023

Pull request successfully merged into master.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title feat: gcd and coprime sub [Merged by Bors] - feat: gcd and coprime sub Sep 12, 2023
@bors bors bot closed this Sep 12, 2023
@bors bors bot deleted the mo271/gcd_coprime_sub branch September 12, 2023 23:50
kodyvajjha pushed a commit that referenced this pull request Sep 22, 2023
Co-authored-by: Moritz Firsching <firsching@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has been sent to bors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants