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(data/dfinsupp): Port over the finsupp.lift_add_hom
API
#4821
Conversation
top_unique $ λ x hx, (begin | ||
apply dfinsupp.induction x, | ||
exact add_submonoid.zero_mem _, | ||
exact λ a b f ha hb hf, add_submonoid.add_mem _ | ||
(add_submonoid.subset_closure $ set.mem_Union.2 ⟨a, set.mem_range_self _⟩) hf | ||
end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked in term mode for finsupp
, but the elaborator couldn't fill out the underscores unless I did it in tactic mode.
src/data/dfinsupp.lean
Outdated
/-- | ||
When summing over an `add_monoid_hom`, the decidability assumption is not needed, and the result is | ||
also an `add_monoid_hom` -/ | ||
def sum_add_hom [Π i, add_monoid (β i)] [add_comm_monoid γ] (φ : Π i, β i →+ γ) : ((Π₀ i, β i) →+ γ) := | ||
{ to_fun := (λ f, | ||
quotient.lift_on f (λ x, ∑ i in x.2.to_finset, φ i (x.1 i)) $ λ x y H, | ||
begin | ||
have H1 : x.2.to_finset ∩ y.2.to_finset ⊆ x.2.to_finset, from finset.inter_subset_left _ _, | ||
have H2 : x.2.to_finset ∩ y.2.to_finset ⊆ y.2.to_finset, from finset.inter_subset_right _ _, | ||
refine (finset.sum_subset H1 _).symm.trans ((finset.sum_congr rfl _).trans (finset.sum_subset H2 _)), | ||
{ intros i H1 H2, rw finset.mem_inter at H2, rw H i, | ||
simp only [multiset.mem_to_finset] at H1 H2, | ||
rw [(y.3 i).resolve_left (mt (and.intro H1) H2), add_monoid_hom.map_zero] }, | ||
{ intros i H1, rw H i }, | ||
{ intros i H1 H2, rw finset.mem_inter at H2, rw ← H i, | ||
simp only [multiset.mem_to_finset] at H1 H2, | ||
rw [(x.3 i).resolve_left (mt (λ H3, and.intro H3 H1) H2), add_monoid_hom.map_zero] } | ||
end), | ||
map_add' := assume f g, | ||
begin | ||
refine quotient.induction_on f (λ x, _), | ||
refine quotient.induction_on g (λ y, _), | ||
change ∑ i in _, _ = (∑ i in _, _) + (∑ i in _, _), | ||
simp only, conv { to_lhs, congr, skip, funext, rw add_monoid_hom.map_add }, | ||
simp only [finset.sum_add_distrib], | ||
congr' 1, | ||
{ refine (finset.sum_subset _ _).symm, | ||
{ intro i, simp only [multiset.mem_to_finset, multiset.mem_add], exact or.inl }, | ||
{ intros i H1 H2, simp only [multiset.mem_to_finset, multiset.mem_add] at H2, | ||
rw [(x.3 i).resolve_left H2, add_monoid_hom.map_zero] } }, | ||
{ refine (finset.sum_subset _ _).symm, | ||
{ intro i, simp only [multiset.mem_to_finset, multiset.mem_add], exact or.inr }, | ||
{ intros i H1 H2, simp only [multiset.mem_to_finset, multiset.mem_add] at H2, | ||
rw [(y.3 i).resolve_left H2, add_monoid_hom.map_zero] } } | ||
end, | ||
map_zero' := rfl } | ||
|
||
@[simp] lemma sum_add_hom_single [Π i, add_monoid (β i)] [add_comm_monoid γ] | ||
(φ : Π i, β i →+ γ) (i) (x : β i) : sum_add_hom φ (single i x) = φ i x := | ||
(add_zero _).trans $ congr_arg (φ i) $ show (if H : i ∈ ({i} : finset _) then x else 0) = x, | ||
from dif_pos $ finset.mem_singleton_self i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These proofs are taken verbatim from direct_sum
left_inv := λ x, by { ext, simp }, | ||
right_inv := λ ψ, by { ext, simp }, | ||
map_add' := λ F G, by { ext, simp } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to @urkud's awesome ext lemma, the longer proofs of these from direct_sum
can be discarded.
5de56b2
to
68050b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 🎉
bors merge
These lemmas are mostly copied with minimal translation from `finsupp`. A few proofs are taken from `direct_sum`. The API of `direct_sum` is deliberately unchanged in this PR.
Pull request successfully merged into master. Build succeeded: |
finsupp.lift_add_hom
APIfinsupp.lift_add_hom
API
…over-community#4821) These lemmas are mostly copied with minimal translation from `finsupp`. A few proofs are taken from `direct_sum`. The API of `direct_sum` is deliberately unchanged in this PR.
These lemmas are mostly copied with minimal translation from
finsupp
.A few proofs are taken from
direct_sum
.The API of
direct_sum
is deliberately unchanged in this PR.cc @urkud and @kckennylau, who wrote parts of this moved code.