[Merged by Bors] - feat: a + a = 0 ↔ a = 0 in ZMod n for n odd#6086
Closed
[Merged by Bors] - feat: a + a = 0 ↔ a = 0 in ZMod n for n odd#6086
a + a = 0 ↔ a = 0 in ZMod n for n odd#6086Conversation
eric-wieser
reviewed
Jul 24, 2023
eric-wieser
reviewed
Jul 24, 2023
| rw [←mul_two, ←@Nat.cast_two (ZMod n), | ||
| ←ZMod.coe_unitOfCoprime 2 (Nat.prime_two.coprime_iff_not_dvd.mpr hn), Units.mul_left_eq_zero] | ||
|
|
||
| theorem ne_neg_self (n : ℕ) [hn : Fact ((n : ℕ) % 2 = 1)] {a : ZMod n} (ha : a ≠ 0) : a ≠ -a := by |
Member
There was a problem hiding this comment.
This one shouldn't be using Fact (and probably should also be using Odd), but I guess that's out of scope.
Contributor
There was a problem hiding this comment.
I agree with Eric that it would be nice to excise this Fact in a future PR.
ocfnash
approved these changes
Jul 31, 2023
| rw [←mul_two, ←@Nat.cast_two (ZMod n), | ||
| ←ZMod.coe_unitOfCoprime 2 (Nat.prime_two.coprime_iff_not_dvd.mpr hn), Units.mul_left_eq_zero] | ||
|
|
||
| theorem ne_neg_self (n : ℕ) [hn : Fact ((n : ℕ) % 2 = 1)] {a : ZMod n} (ha : a ≠ 0) : a ≠ -a := by |
Contributor
There was a problem hiding this comment.
I agree with Eric that it would be nice to excise this Fact in a future PR.
|
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. If you want to switch to GitHub's built-in merge queue, visit their help page. |
a + a = 0 ↔ a = 0 in ZMod n for n odda + a = 0 ↔ a = 0 in ZMod n for n odd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proves that
a + a = 0 ↔ a = 0, and uses it to golf the proof ofne_neg_self.I removed
le_div_two_iff_lt_negsince it seems to just be a technical auxiliary lemma for the current proof ofne_neg_self, but I can add it back if people think it should be kept around. If we do keep it around, I wonder if it would be better to state it as2 * x.val < n ↔ n < 2 * (-x).val(or something like that) to avoid natural number division.