Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit e5a844e

Browse files
feat(data/finsupp/basic): add two versions of finsupp.mul_prod_erase (#10708)
Adding a counterpart for `finsupp` of `finset.mul_prod_erase`
1 parent c9fe6d1 commit e5a844e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/data/finsupp/basic.lean

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,34 @@ lemma on_finset_prod {s : finset α} {f : α → M} {g : α → M → N}
775775
(on_finset s f hf).prod g = ∏ a in s, g a (f a) :=
776776
finset.prod_subset support_on_finset_subset $ by simp [*] { contextual := tt }
777777

778+
/-- Taking a product over `f : α →₀ M` is the same as multiplying the value on a single element
779+
`y ∈ f.support` by the product over `erase y f`. -/
780+
@[to_additive /-" Taking a sum over over `f : α →₀ M` is the same as adding the value on a
781+
single element `y ∈ f.support` to the sum over `erase y f`. "-/]
782+
lemma mul_prod_erase (f : α →₀ M) (y : α) (g : α → M → N) (hyf : y ∈ f.support) :
783+
g y (f y) * (erase y f).prod g = f.prod g :=
784+
begin
785+
rw [finsupp.prod, finsupp.prod, ←finset.mul_prod_erase _ _ hyf, finsupp.support_erase,
786+
finset.prod_congr rfl],
787+
intros h hx,
788+
rw finsupp.erase_ne (ne_of_mem_erase hx),
789+
end
790+
791+
/-- Generalization of `finsupp.mul_prod_erase`: if `g` maps a second argument of 0 to 1,
792+
then its product over `f : α →₀ M` is the same as multiplying the value on any element
793+
`y : α` by the product over `erase y f`. -/
794+
@[to_additive /-" Generalization of `finsupp.add_sum_erase`: if `g` maps a second argument of 0
795+
to 0, then its sum over `f : α →₀ M` is the same as adding the value on any element
796+
`y : α` to the sum over `erase y f`. "-/]
797+
lemma mul_prod_erase' (f : α →₀ M) (y : α) (g : α → M → N) (hg : ∀ (i : α), g i 0 = 1) :
798+
g y (f y) * (erase y f).prod g = f.prod g :=
799+
begin
800+
classical,
801+
by_cases hyf : y ∈ f.support,
802+
{ exact finsupp.mul_prod_erase f y g hyf },
803+
{ rw [not_mem_support_iff.mp hyf, hg y, erase_of_not_mem_support hyf, one_mul] },
804+
end
805+
778806
@[to_additive]
779807
lemma _root_.submonoid.finsupp_prod_mem (S : submonoid N) (f : α →₀ M) (g : α → M → N)
780808
(h : ∀ c, f c ≠ 0 → g c (f c) ∈ S) : f.prod g ∈ S :=

0 commit comments

Comments
 (0)