Zulip Chat Archive
Stream: new members
Topic: finsupp sum of single
Lucas Viana Reis (Oct 04 2020 at 13:43):
open finsupp
variables (α β γ : Type)
variables [has_zero β] [add_comm_monoid γ] {a : α} {b : β} (g : α → β → γ)
example : (single a b).sum g = g a b := by library_search
Hi, is this example in the library?
Shing Tak Lam (Oct 04 2020 at 13:52):
import data.finsupp.basic
variables (α β γ : Type)
variables [add_monoid β] [add_comm_monoid γ] {a : α} {b : β} (g : α → β → γ)
open finsupp
example (h : g a 0 = 0) : (single a b).sum g = g a b := finsupp.sum_single_index h
Note: [has_zero β]
=> [add_monoid β]
and you need h : g a 0 = 0
Lucas Viana Reis (Oct 04 2020 at 13:55):
Thanks!
Shing Tak Lam (Oct 04 2020 at 13:57):
mhm... You don't need [add_comm_monoid β]
, here is a proof without (basically the same proof as sum_single_index
)
import data.finsupp.basic
variables (α β γ : Type)
variables [has_zero β] [add_comm_monoid γ] {a : α} {b : β} (g : α → β → γ)
open finsupp
example (h : g a 0 = 0) : (single a b).sum g = g a b :=
begin
by_cases hb : b = 0,
{ simp [h, hb, single_zero], refl },
{ simp [finsupp.sum, finsupp.support_single_ne_zero hb] }
end
Lucas Viana Reis (Oct 04 2020 at 14:03):
If b ≠ 0
, do we still need the hypothesis g a 0 = 0
?
Shing Tak Lam (Oct 04 2020 at 14:04):
no
example (h : b ≠ 0) : (single a b).sum g = g a b :=
begin
simp [finsupp.sum, finsupp.support_single_ne_zero h]
end
Last updated: Dec 20 2023 at 11:08 UTC