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] - refactor(data/polynomial): Move some lemmas to monoid_algebra #4627

Closed
wants to merge 4 commits into from

Conversation

eric-wieser
Copy link
Member

The add_monoid_algebra.mul_apply_antidiagonal lemma is copied verbatim from monoid_algebra.mul_apply_antidiagonal.


The `add_monoid_algebra.mul_apply_antidiagonal` lemma is copied verbatim from `monoid_algebra.mul_apply_antidiagonal`.
The docstring for `coeff_single` says it shouldn't be needed and `coeff_monomial` is the preferred spelling
src/data/polynomial/basic.lean Outdated Show resolved Hide resolved
src/data/polynomial/basic.lean Show resolved Hide resolved
src/data/polynomial/basic.lean Show resolved Hide resolved
src/algebra/monoid_algebra.lean Show resolved Hide resolved
Comment on lines 83 to +85
@[simp] lemma coeff_mul_C (p : polynomial R) (n : ℕ) (a : R) :
coeff (p * C a) n = coeff p n * a :=
begin
conv_rhs { rw [← @finsupp.sum_single _ _ _ p, coeff_sum] },
rw [add_monoid_algebra.mul_def, ←monomial_zero_left], simp_rw [sum_single_index],
{ simp only [coeff_single, finsupp.sum_mul, coeff_sum],
apply sum_congr rfl,
assume i hi, by_cases i = n; simp [h], },
end
add_monoid_algebra.mul_single_zero_apply p a n
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this proof is actually longer in add_monoid_algebra:

lemma mul_single_apply_aux (f : add_monoid_algebra k G) (r : k)
(x y z : G) (H : ∀ a, a + x = z ↔ a = y) :
(f * single x r) z = f y * r :=
have A : ∀ a₁ b₁, (single x r).sum (λ a₂ b₂, ite (a₁ + a₂ = z) (b₁ * b₂) 0) =
ite (a₁ + x = z) (b₁ * r) 0,
from λ a₁ b₁, sum_single_index $ by simp,
calc (f * single x r) z = sum f (λ a b, if (a = y) then (b * r) else 0) :
-- different `decidable` instances make it not trivial
by { simp only [mul_apply, A, H], congr, funext, split_ifs; refl }
... = if y ∈ f.support then f y * r else 0 : f.support.sum_ite_eq' _ _
... = f y * r : by split_ifs with h; simp at h; simp [h]
lemma mul_single_zero_apply (f : add_monoid_algebra k G) (r : k) (x : G) :
(f * single 0 r) x = f x * r :=
f.mul_single_apply_aux r _ _ _ $ λ a, by rw [add_zero]

Should I change the proof there to use this shorter proof, or is the long one more readable?

Copy link
Member

Choose a reason for hiding this comment

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

mul_single_apply_aux is used more than 1 time in monoid_algebra.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

This allows the lemma which "ideally wouldn't be necessary" to not be necessary
@eric-wieser eric-wieser force-pushed the eric-wieser/monoid_algebra-polynomial branch from 0fdb368 to 75646cd Compare October 15, 2020 11:37
@eric-wieser eric-wieser added the awaiting-review The author would like community review of the PR label Oct 15, 2020
@urkud urkud added awaiting-author A reviewer has asked the author a question or requested changes delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Oct 15, 2020
@urkud
Copy link
Member

urkud commented Oct 15, 2020

I left a couple of comments. LGTM otherwise.
bors d+

@bors
Copy link

bors bot commented Oct 15, 2020

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

@eric-wieser
Copy link
Member Author

bors r+

bors bot pushed a commit that referenced this pull request Oct 15, 2020
The `add_monoid_algebra.mul_apply_antidiagonal` lemma is copied verbatim from `monoid_algebra.mul_apply_antidiagonal`.
@bors
Copy link

bors bot commented Oct 15, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title refactor(data/polynomial): Move some lemmas to monoid_algebra [Merged by Bors] - refactor(data/polynomial): Move some lemmas to monoid_algebra Oct 15, 2020
@bors bors bot closed this Oct 15, 2020
@bors bors bot deleted the eric-wieser/monoid_algebra-polynomial branch October 15, 2020 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author A reviewer has asked the author a question or requested changes delegated The PR author may merge after reviewing final suggestions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants