Skip to content

[Merged by Bors] - feat: The support of f ^ n#9617

Closed
YaelDillies wants to merge 19 commits intomasterfrom
support_pow
Closed

[Merged by Bors] - feat: The support of f ^ n#9617
YaelDillies wants to merge 19 commits intomasterfrom
support_pow

Conversation

@YaelDillies
Copy link
Copy Markdown
Contributor

This involves moving lemmas from Algebra.GroupPower.Ring to Algebra.GroupWithZero.Basic and changing some 0 < n assumptions to n ≠ 0.

From LeanAPAP


Open in Gitpod

This involves moving lemmas from `Algebra.GroupPower.Ring` to `Algebra.GroupWithZero.Basic` and changing some `0 < n` assumptions to `n ≠ 0`.

From LeanAPAP
@YaelDillies YaelDillies added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. t-algebra Algebra (groups, rings, fields, etc) labels Jan 10, 2024
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jan 11, 2024
@ghost ghost removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jan 13, 2024
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jan 14, 2024
@ghost ghost removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jan 14, 2024
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Jan 16, 2024
Copy link
Copy Markdown
Contributor

@j-loreaux j-loreaux left a comment

Choose a reason for hiding this comment

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

Overall very nice thanks! Only some minor comments.

bors d+


theorem pow_pos_iff (hn : 0 < n) : 0 < a ^ n ↔ 0 < a := by
simp_rw [zero_lt_iff, pow_ne_zero_iff hn]
theorem pow_pos_iff (hn : n ≠ 0) : 0 < a ^ n ↔ 0 < a := by simp_rw [zero_lt_iff, pow_ne_zero_iff hn]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is very minor, and I'm not asking you to change it now, but in the future it would be nice if these kinds of changes were avoided because they needlessly increase the diff, and, as far as style is concerned, the community guidelines are ambivalent on this issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It doesn't increase the diff here given that those lines were already modified.

Comment on lines +262 to +276
rw [eq_div_iff hzero, ← sub_eq_zero] at h
replace hzero : s ≠ 0 := by rintro rfl; simp only [map_zero, not_true_eq_false] at hzero
let f : F[X] := X ^ m * expand F n s - expand F n r
refine ⟨f, ?_, ?_⟩
· have : f.coeff (n * s.natDegree + m) ≠ 0 := by
have hn : 0 < n := by linarith only [hm, hmn]
have hndvd : ¬ n ∣ n * s.natDegree + m := by
rw [← Nat.dvd_add_iff_right (n.dvd_mul_right s.natDegree)]
exact Nat.not_dvd_of_pos_of_lt hm hmn
simp only [coeff_sub, coeff_X_pow_mul, s.coeff_expand_mul' hn, coeff_natDegree,
coeff_expand hn r, hndvd, ite_false, sub_zero]
exact leadingCoeff_ne_zero.2 hzero
intro h
simp only [h, coeff_zero, ne_eq, not_true_eq_false] at this
· simp only [map_sub, map_mul, map_pow, aeval_X, expand_aeval, h]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the same comment applies here, except in this case I think the style guidelines do recommend the · with indentation here (i.e., how it was before the edit), so please revert to shrink the diff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, the style guide says · can (and probably should) be removed when one branch is much longer than the other ones.

apply Finset.sum_congr rfl
refine' fun m _ => mul_eq_mul_left_iff.mpr (Or.inl _)
rw [ite_pow, zero_pow (pow_pos hp.out.pos _)]
rw [ite_pow, zero_pow (pow_ne_zero _ hp.out.ne_zero)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This idiom was repeated a few times in the diff, but I think this is slightly nicer (untested):

Suggested change
rw [ite_pow, zero_pow (pow_ne_zero _ hp.out.ne_zero)]
rw [ite_pow, zero_pow (pow_pos hp.out.pos _).ne']

It's possible I'm missing something though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I understand the idea, but I'm not sure this is better. The "correct" proof of course is

Suggested change
rw [ite_pow, zero_pow (pow_ne_zero _ hp.out.ne_zero)]
rw [ite_pow, zero_pow (by positivity)]

but I haven't made it work yet (nor am I sure I can make it work without a performance penalty, actually). I am happy to wait for this to be figured out before merging this PR if you think that's important.

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jan 19, 2024

✌️ YaelDillies can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ghost ghost added delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). and removed awaiting-review labels Jan 19, 2024
@YaelDillies
Copy link
Copy Markdown
Contributor Author

bors merge

mathlib-bors bot pushed a commit that referenced this pull request Jan 30, 2024
This involves moving lemmas from `Algebra.GroupPower.Ring` to `Algebra.GroupWithZero.Basic` and changing some `0 < n` assumptions to `n ≠ 0`.

From LeanAPAP
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jan 30, 2024

Build failed (retrying...):

mathlib-bors bot pushed a commit that referenced this pull request Jan 30, 2024
This involves moving lemmas from `Algebra.GroupPower.Ring` to `Algebra.GroupWithZero.Basic` and changing some `0 < n` assumptions to `n ≠ 0`.

From LeanAPAP
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jan 30, 2024

Build failed:

@YaelDillies
Copy link
Copy Markdown
Contributor Author

bors merge

mathlib-bors bot pushed a commit that referenced this pull request Jan 31, 2024
This involves moving lemmas from `Algebra.GroupPower.Ring` to `Algebra.GroupWithZero.Basic` and changing some `0 < n` assumptions to `n ≠ 0`.

From LeanAPAP
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jan 31, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: The support of f ^ n [Merged by Bors] - feat: The support of f ^ n Jan 31, 2024
@mathlib-bors mathlib-bors bot closed this Jan 31, 2024
@mathlib-bors mathlib-bors bot deleted the support_pow branch January 31, 2024 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants