Skip to content

Commit f7b5ce7

Browse files
committed
feat: generalize *Finsupp* files (#23140)
This is one of a series of PRs that generalizes type classes across Mathlib. These are generated using a new linter that tries to re-elaborate theorem definitions with more general type classes to see if it succeeds. It will accept the generalization if deleting the entire type class causes the theorem to fail to compile, and the old type class can not simply be re-synthesized with the new declaration. Otherwise, the generalization is rejected as the type class is not being generalized, but can simply be replaced by implicit type class synthesis or an implicit type class in a variable block being pulled in. The linter currently output debug statements indicating source file positions where type classes should be generalized, and a script then makes those edits. This file contains a subset of those generalizations. The linter and the script performing re-writes is available in commit 5e2b704. Also see discussion on Zulip here: https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Elab.20to.20generalize.20type.20classes.20for.20theorems/near/498862988 https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Elab.20to.20generalize.20type.20classes.20for.20theorems/near/501288855
1 parent bcaf02f commit f7b5ce7

File tree

7 files changed

+46
-43
lines changed

7 files changed

+46
-43
lines changed

Mathlib/Algebra/BigOperators/Finsupp/Basic.lean

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ theorem sum_ite_self_eq [DecidableEq α] {N : Type*} [AddCommMonoid N] (f : α
9797
The left hand side of `sum_ite_self_eq` simplifies; this is the variant that is useful for `simp`.
9898
-/
9999
@[simp]
100-
theorem if_mem_support [DecidableEq α] {N : Type*} [AddCommMonoid N] (f : α →₀ N) (a : α) :
100+
theorem if_mem_support [DecidableEq α] {N : Type*} [Zero N] (f : α →₀ N) (a : α) :
101101
(if a ∈ f.support then f a else 0) = f a := by
102102
simp only [mem_support_iff, ne_eq, ite_eq_left_iff, not_not]
103103
exact fun h ↦ h.symm
@@ -122,7 +122,7 @@ theorem prod_pow [Fintype α] (f : α →₀ ℕ) (g : α → N) :
122122
f.prod_fintype _ fun _ ↦ pow_zero _
123123

124124
@[to_additive (attr := simp)]
125-
theorem prod_zpow {N} [CommGroup N] [Fintype α] (f : α →₀ ℤ) (g : α → N) :
125+
theorem prod_zpow {N} [DivisionCommMonoid N] [Fintype α] (f : α →₀ ℤ) (g : α → N) :
126126
(f.prod fun a b => g a ^ b) = ∏ a, g a ^ f a :=
127127
f.prod_fintype _ fun _ ↦ zpow_zero _
128128

@@ -202,12 +202,12 @@ theorem map_finsupp_prod [Zero M] [CommMonoid N] [CommMonoid P] {H : Type*}
202202
map_prod h _ _
203203

204204
@[to_additive]
205-
theorem MonoidHom.coe_finsupp_prod [Zero β] [Monoid N] [CommMonoid P] (f : α →₀ β)
205+
theorem MonoidHom.coe_finsupp_prod [Zero β] [MulOneClass N] [CommMonoid P] (f : α →₀ β)
206206
(g : α → β → N →* P) : ⇑(f.prod g) = f.prod fun i fi => ⇑(g i fi) :=
207207
MonoidHom.coe_finset_prod _ _
208208

209209
@[to_additive (attr := simp)]
210-
theorem MonoidHom.finsupp_prod_apply [Zero β] [Monoid N] [CommMonoid P] (f : α →₀ β)
210+
theorem MonoidHom.finsupp_prod_apply [Zero β] [MulOneClass N] [CommMonoid P] (f : α →₀ β)
211211
(g : α → β → N →* P) (x : N) : f.prod g x = f.prod fun i fi => g i fi x :=
212212
MonoidHom.finset_prod_apply _ _ _
213213

@@ -230,7 +230,7 @@ theorem single_sum [Zero M] [AddCommMonoid N] (s : ι →₀ M) (f : ι → M
230230
single_finset_sum _ _ _
231231

232232
@[to_additive]
233-
theorem prod_neg_index [AddGroup G] [CommMonoid M] {g : α →₀ G} {h : α → G → M}
233+
theorem prod_neg_index [SubtractionMonoid G] [CommMonoid M] {g : α →₀ G} {h : α → G → M}
234234
(h0 : ∀ a, h a 0 = 1) : (-g).prod h = g.prod fun a b => h a (-b) :=
235235
prod_mapRange_index h0
236236

@@ -286,7 +286,7 @@ theorem prod_inv [Zero M] [CommGroup G] {f : α →₀ M} {h : α → M → G} :
286286
(map_prod (MonoidHom.id G)⁻¹ _ _).symm
287287

288288
@[simp]
289-
theorem sum_sub [Zero M] [AddCommGroup G] {f : α →₀ M} {h₁ h₂ : α → M → G} :
289+
theorem sum_sub [Zero M] [SubtractionCommMonoid G] {f : α →₀ M} {h₁ h₂ : α → M → G} :
290290
(f.sum fun a b => h₁ a b - h₂ a b) = f.sum h₁ - f.sum h₂ :=
291291
Finset.sum_sub_distrib
292292

@@ -350,16 +350,16 @@ def liftAddHom [AddZeroClass M] [AddCommMonoid N] : (α → M →+ N) ≃+ ((α
350350
exact sum_add
351351

352352
@[simp]
353-
theorem liftAddHom_apply [AddCommMonoid M] [AddCommMonoid N] (F : α → M →+ N) (f : α →₀ M) :
353+
theorem liftAddHom_apply [AddZeroClass M] [AddCommMonoid N] (F : α → M →+ N) (f : α →₀ M) :
354354
(liftAddHom (α := α) (M := M) (N := N)) F f = f.sum fun x => F x :=
355355
rfl
356356

357357
@[simp]
358-
theorem liftAddHom_symm_apply [AddCommMonoid M] [AddCommMonoid N] (F : (α →₀ M) →+ N) (x : α) :
358+
theorem liftAddHom_symm_apply [AddZeroClass M] [AddCommMonoid N] (F : (α →₀ M) →+ N) (x : α) :
359359
(liftAddHom (α := α) (M := M) (N := N)).symm F x = F.comp (singleAddHom x) :=
360360
rfl
361361

362-
theorem liftAddHom_symm_apply_apply [AddCommMonoid M] [AddCommMonoid N] (F : (α →₀ M) →+ N) (x : α)
362+
theorem liftAddHom_symm_apply_apply [AddZeroClass M] [AddCommMonoid N] (F : (α →₀ M) →+ N) (x : α)
363363
(y : M) : (liftAddHom (α := α) (M := M) (N := N)).symm F x y = F (single x y) :=
364364
rfl
365365

@@ -401,24 +401,24 @@ theorem equivFunOnFinite_symm_eq_sum [Fintype α] [AddCommMonoid M] (f : α →
401401
ext
402402
simp
403403

404-
theorem liftAddHom_apply_single [AddCommMonoid M] [AddCommMonoid N] (f : α → M →+ N) (a : α)
404+
theorem liftAddHom_apply_single [AddZeroClass M] [AddCommMonoid N] (f : α → M →+ N) (a : α)
405405
(b : M) : (liftAddHom (α := α) (M := M) (N := N)) f (single a b) = f a b :=
406406
sum_single_index (f a).map_zero
407407

408408
@[simp]
409-
theorem liftAddHom_comp_single [AddCommMonoid M] [AddCommMonoid N] (f : α → M →+ N) (a : α) :
409+
theorem liftAddHom_comp_single [AddZeroClass M] [AddCommMonoid N] (f : α → M →+ N) (a : α) :
410410
((liftAddHom (α := α) (M := M) (N := N)) f).comp (singleAddHom a) = f a :=
411411
AddMonoidHom.ext fun b => liftAddHom_apply_single f a b
412412

413-
theorem comp_liftAddHom [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] (g : N →+ P)
413+
theorem comp_liftAddHom [AddZeroClass M] [AddCommMonoid N] [AddCommMonoid P] (g : N →+ P)
414414
(f : α → M →+ N) :
415415
g.comp ((liftAddHom (α := α) (M := M) (N := N)) f) =
416416
(liftAddHom (α := α) (M := M) (N := P)) fun a => g.comp (f a) :=
417417
liftAddHom.symm_apply_eq.1 <|
418418
funext fun a => by
419419
rw [liftAddHom_symm_apply, AddMonoidHom.comp_assoc, liftAddHom_comp_single]
420420

421-
theorem sum_sub_index [AddCommGroup β] [AddCommGroup γ] {f g : α →₀ β} {h : α → β → γ}
421+
theorem sum_sub_index [AddGroup β] [AddCommGroup γ] {f g : α →₀ β} {h : α → β → γ}
422422
(h_sub : ∀ a b₁ b₂, h a (b₁ - b₂) = h a b₁ - h a b₂) : (f - g).sum h = f.sum h - g.sum h :=
423423
((liftAddHom (α := α) (M := β) (N := γ)) fun a =>
424424
AddMonoidHom.ofMapSub (h a) (h_sub a)).map_sub f g
@@ -437,7 +437,7 @@ theorem prod_finset_sum_index [AddCommMonoid M] [CommMonoid N] {s : Finset ι} {
437437
rw [prod_cons, ih, sum_cons, prod_add_index' h_zero h_add]
438438

439439
@[to_additive]
440-
theorem prod_sum_index [AddCommMonoid M] [AddCommMonoid N] [CommMonoid P] {f : α →₀ M}
440+
theorem prod_sum_index [Zero M] [AddCommMonoid N] [CommMonoid P] {f : α →₀ M}
441441
{g : α → M → β →₀ N} {h : β → N → P} (h_zero : ∀ a, h a 0 = 1)
442442
(h_add : ∀ a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂) :
443443
(f.sum g).prod h = f.prod fun a b => (g a b).prod h :=
@@ -490,7 +490,7 @@ theorem prod_add_index_of_disjoint [AddCommMonoid M] {f1 f2 : α →₀ M}
490490
classical simp_rw [← this hd, ← this hd.symm, add_comm (f2 _), Finsupp.prod, support_add_eq hd,
491491
prod_union hd, add_apply]
492492

493-
theorem prod_dvd_prod_of_subset_of_dvd [AddCommMonoid M] [CommMonoid N] {f1 f2 : α →₀ M}
493+
theorem prod_dvd_prod_of_subset_of_dvd [Zero M] [CommMonoid N] {f1 f2 : α →₀ M}
494494
{g1 g2 : α → M → N} (h1 : f1.support ⊆ f2.support)
495495
(h2 : ∀ a : α, a ∈ f1.support → g1 a (f1 a) ∣ g2 a (f2 a)) : f1.prod g1 ∣ f2.prod g2 := by
496496
classical

Mathlib/Algebra/BigOperators/Finsupp/Fin.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ lemma sum_cons [AddCommMonoid M] (n : ℕ) (σ : Fin n →₀ M) (i : M) :
2222
rw [sum_fintype _ _ (fun _ => rfl), sum_fintype _ _ (fun _ => rfl)]
2323
exact Fin.sum_cons i σ
2424

25-
lemma sum_cons' [AddCommMonoid M] [AddCommMonoid N] (n : ℕ) (σ : Fin n →₀ M) (i : M)
25+
lemma sum_cons' [Zero M] [AddCommMonoid N] (n : ℕ) (σ : Fin n →₀ M) (i : M)
2626
(f : Fin (n+1) → M → N) (h : ∀ x, f x 0 = 0) :
2727
(sum (Finsupp.cons i σ) f) = f 0 i + sum σ (Fin.tail f) := by
2828
rw [sum_fintype _ _ (fun _ => by apply h), sum_fintype _ _ (fun _ => by apply h)]

Mathlib/Data/DFinsupp/BigOperators.lean

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,18 @@ theorem prod_mul [∀ i, AddCommMonoid (β i)] [∀ (i) (x : β i), Decidable (x
158158
Finset.prod_mul_distrib
159159

160160
@[to_additive (attr := simp)]
161-
theorem prod_inv [∀ i, AddCommMonoid (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommGroup γ]
162-
{f : Π₀ i, β i} {h : ∀ i, β i → γ} : (f.prod fun i b => (h i b)⁻¹) = (f.prod h)⁻¹ :=
161+
theorem prod_inv [∀ i, AddCommMonoid (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
162+
[DivisionCommMonoid γ] {f : Π₀ i, β i} {h : ∀ i, β i → γ} :
163+
(f.prod fun i b => (h i b)⁻¹) = (f.prod h)⁻¹ :=
163164
(map_prod (invMonoidHom : γ →* γ) _ f.support).symm
164165

165166
@[to_additive]
166167
theorem prod_eq_one [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMonoid γ]
167168
{f : Π₀ i, β i} {h : ∀ i, β i → γ} (hyp : ∀ i, h i (f i) = 1) : f.prod h = 1 :=
168169
Finset.prod_eq_one fun i _ => hyp i
169170

170-
theorem smul_sum {α : Type*} [Monoid α] [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
171-
[AddCommMonoid γ] [DistribMulAction α γ] {f : Π₀ i, β i} {h : ∀ i, β i → γ} {c : α} :
171+
theorem smul_sum {α : Type*} [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
172+
[AddCommMonoid γ] [DistribSMul α γ] {f : Π₀ i, β i} {h : ∀ i, β i → γ} {c : α} :
172173
c • f.sum h = f.sum fun a b => c • h a b :=
173174
Finset.smul_sum
174175

@@ -419,12 +420,12 @@ variable {R S : Type*}
419420
variable [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
420421

421422
@[to_additive (attr := simp, norm_cast)]
422-
theorem coe_dfinsupp_prod [Monoid R] [CommMonoid S] (f : Π₀ i, β i) (g : ∀ i, β i → R →* S) :
423+
theorem coe_dfinsupp_prod [MulOneClass R] [CommMonoid S] (f : Π₀ i, β i) (g : ∀ i, β i → R →* S) :
423424
⇑(f.prod g) = f.prod fun a b => ⇑(g a b) :=
424425
coe_finset_prod _ _
425426

426427
@[to_additive]
427-
theorem dfinsupp_prod_apply [Monoid R] [CommMonoid S] (f : Π₀ i, β i) (g : ∀ i, β i → R →* S)
428+
theorem dfinsupp_prod_apply [MulOneClass R] [CommMonoid S] (f : Π₀ i, β i) (g : ∀ i, β i → R →* S)
428429
(r : R) : (f.prod g) r = f.prod fun a b => (g a b) r :=
429430
finset_prod_apply _ _ _
430431

Mathlib/Data/Finsupp/Basic.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ theorem cast_finsupp_prod [CommSemiring R] (g : α → M → ℕ) :
346346
Nat.cast_prod _ _
347347

348348
@[simp, norm_cast]
349-
theorem cast_finsupp_sum [CommSemiring R] (g : α → M → ℕ) :
349+
theorem cast_finsupp_sum [AddCommMonoidWithOne R] (g : α → M → ℕ) :
350350
(↑(f.sum g) : R) = f.sum fun a b => ↑(g a b) :=
351351
Nat.cast_sum _ _
352352

@@ -360,7 +360,7 @@ theorem cast_finsupp_prod [CommRing R] (g : α → M → ℤ) :
360360
Int.cast_prod _ _
361361

362362
@[simp, norm_cast]
363-
theorem cast_finsupp_sum [Ring R] (g : α → M → ℤ) :
363+
theorem cast_finsupp_sum [AddCommGroupWithOne R] (g : α → M → ℤ) :
364364
(↑(f.sum g) : R) = f.sum fun a b => ↑(g a b) :=
365365
Int.cast_sum _ _
366366

@@ -564,7 +564,7 @@ theorem mapDomain_mapRange [AddCommMonoid N] (f : α → β) (v : α →₀ M) (
564564
map_add' := hadd }
565565
DFunLike.congr_fun (mapDomain.addMonoidHom_comp_mapRange f g') v
566566

567-
theorem sum_update_add [AddCommMonoid α] [AddCommMonoid β] (f : ι →₀ α) (i : ι) (a : α)
567+
theorem sum_update_add [AddZeroClass α] [AddCommMonoid β] (f : ι →₀ α) (i : ι) (a : α)
568568
(g : ι → α → β) (hg : ∀ i, g i 0 = 0)
569569
(hgg : ∀ (j : ι) (a₁ a₂ : α), g j (a₁ + a₂) = g j a₁ + g j a₂) :
570570
(f.update i a).sum g + g i (f i) = f.sum g + g i a := by
@@ -620,7 +620,7 @@ theorem sum_comapDomain [Zero M] [AddCommMonoid N] (f : α → β) (l : β →
620620
simp only [sum, comapDomain_apply, (· ∘ ·), comapDomain]
621621
exact Finset.sum_preimage_of_bij f _ hf fun x => g x (l x)
622622

623-
theorem eq_zero_of_comapDomain_eq_zero [AddCommMonoid M] (f : α → β) (l : β →₀ M)
623+
theorem eq_zero_of_comapDomain_eq_zero [Zero M] (f : α → β) (l : β →₀ M)
624624
(hf : Set.BijOn f (f ⁻¹' ↑l.support) ↑l.support) : comapDomain f l hf.injOn = 0 → l = 0 := by
625625
rw [← support_eq_empty, ← support_eq_empty, comapDomain]
626626
simp only [Finset.ext_iff, Finset.not_mem_empty, iff_false, mem_preimage]
@@ -720,7 +720,7 @@ theorem some_zero [Zero M] : (0 : Option α →₀ M).some = 0 := by
720720
simp
721721

722722
@[simp]
723-
theorem some_add [AddCommMonoid M] (f g : Option α →₀ M) : (f + g).some = f.some + g.some := by
723+
theorem some_add [AddZeroClass M] (f g : Option α →₀ M) : (f + g).some = f.some + g.some := by
724724
ext
725725
simp
726726

@@ -737,7 +737,7 @@ theorem some_single_some [Zero M] (a : α) (m : M) :
737737
simp [single_apply]
738738

739739
@[to_additive]
740-
theorem prod_option_index [AddCommMonoid M] [CommMonoid N] (f : Option α →₀ M)
740+
theorem prod_option_index [AddZeroClass M] [CommMonoid N] (f : Option α →₀ M)
741741
(b : Option α → M → N) (h_zero : ∀ o, b o 0 = 1)
742742
(h_add : ∀ o m₁ m₂, b o (m₁ + m₂) = b o m₁ * b o m₂) :
743743
f.prod b = b none (f none) * f.some.prod fun a => b (Option.some a) := by

Mathlib/Data/Finsupp/BigOperators.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ it is a member of the support of a member of the collection:
3434

3535
variable {ι M : Type*} [DecidableEq ι]
3636

37-
theorem List.support_sum_subset [AddMonoid M] (l : List (ι →₀ M)) :
37+
theorem List.support_sum_subset [AddZeroClass M] (l : List (ι →₀ M)) :
3838
l.sum.support ⊆ l.foldr (Finsupp.support · ⊔ ·) ∅ := by
3939
induction' l with hd tl IH
4040
· simp
@@ -72,7 +72,7 @@ theorem Finset.mem_sup_support_iff [Zero M] {s : Finset (ι →₀ M)} {x : ι}
7272

7373
open scoped Function -- required for scoped `on` notation
7474

75-
theorem List.support_sum_eq [AddMonoid M] (l : List (ι →₀ M))
75+
theorem List.support_sum_eq [AddZeroClass M] (l : List (ι →₀ M))
7676
(hl : l.Pairwise (_root_.Disjoint on Finsupp.support)) :
7777
l.sum.support = l.foldr (Finsupp.support · ⊔ ·) ∅ := by
7878
induction' l with hd tl IH

Mathlib/Data/Finsupp/SMul.lean

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ instance module [Semiring R] [AddCommMonoid M] [Module R M] : Module R (α →
125125
variable {α M}
126126

127127
@[simp]
128-
theorem support_smul_eq [Semiring R] [AddCommMonoid M] [Module R M] [NoZeroSMulDivisors R M] {b : R}
128+
theorem support_smul_eq [Zero R] [Zero M] [SMulWithZero R M] [NoZeroSMulDivisors R M] {b : R}
129129
(hb : b ≠ 0) {g : α →₀ M} : (b • g).support = g.support :=
130130
Finset.ext fun a => by simp [Finsupp.smul_apply, hb]
131131

@@ -134,25 +134,26 @@ section
134134
variable {p : α → Prop} [DecidablePred p]
135135

136136
@[simp]
137-
theorem filter_smul {_ : Monoid R} [AddMonoid M] [DistribMulAction R M] {b : R} {v : α →₀ M} :
137+
theorem filter_smul [Zero M] [SMulZeroClass R M] {b : R} {v : α →₀ M} :
138138
(b • v).filter p = b • v.filter p :=
139139
DFunLike.coe_injective <| by
140140
simp only [filter_eq_indicator, coe_smul]
141141
exact Set.indicator_const_smul { x | p x } b v
142142

143143
end
144144

145-
theorem mapDomain_smul {_ : Monoid R} [AddCommMonoid M] [DistribMulAction R M] {f : α → β} (b : R)
145+
theorem mapDomain_smul [AddCommMonoid M] [DistribSMul R M] {f : α → β} (b : R)
146146
(v : α →₀ M) : mapDomain f (b • v) = b • mapDomain f v :=
147147
mapDomain_mapRange _ _ _ _ (smul_add b)
148148

149149
theorem smul_single' {_ : Semiring R} (c : R) (a : α) (b : R) :
150150
c • Finsupp.single a b = Finsupp.single a (c * b) := by simp
151151

152-
theorem smul_single_one [Semiring R] (a : α) (b : R) : b • single a (1 : R) = single a b := by
152+
theorem smul_single_one [MulZeroOneClass R] (a : α) (b : R) :
153+
b • single a (1 : R) = single a b := by
153154
rw [smul_single, smul_eq_mul, mul_one]
154155

155-
theorem comapDomain_smul [AddMonoid M] [Monoid R] [DistribMulAction R M] {f : α → β} (r : R)
156+
theorem comapDomain_smul [Zero M] [SMulZeroClass R M] {f : α → β} (r : R)
156157
(v : β →₀ M) (hfv : Set.InjOn f (f ⁻¹' ↑v.support))
157158
(hfrv : Set.InjOn f (f ⁻¹' ↑(r • v).support) :=
158159
hfv.mono <| Set.preimage_mono <| Finset.coe_subset.mpr support_smul) :
@@ -161,24 +162,25 @@ theorem comapDomain_smul [AddMonoid M] [Monoid R] [DistribMulAction R M] {f : α
161162
rfl
162163

163164
/-- A version of `Finsupp.comapDomain_smul` that's easier to use. -/
164-
theorem comapDomain_smul_of_injective [AddMonoid M] [Monoid R] [DistribMulAction R M] {f : α → β}
165+
theorem comapDomain_smul_of_injective [Zero M] [SMulZeroClass R M] {f : α → β}
165166
(hf : Function.Injective f) (r : R) (v : β →₀ M) :
166167
comapDomain f (r • v) hf.injOn = r • comapDomain f v hf.injOn :=
167168
comapDomain_smul _ _ _ _
168169

169170
end
170171

171-
theorem sum_smul_index [Semiring R] [AddCommMonoid M] {g : α →₀ R} {b : R} {h : α → R → M}
172+
theorem sum_smul_index [MulZeroClass R] [AddCommMonoid M] {g : α →₀ R} {b : R} {h : α → R → M}
172173
(h0 : ∀ i, h i 0 = 0) : (b • g).sum h = g.sum fun i a => h i (b * a) :=
173174
Finsupp.sum_mapRange_index h0
174175

175-
theorem sum_smul_index' [AddMonoid M] [DistribSMul R M] [AddCommMonoid N] {g : α →₀ M} {b : R}
176+
theorem sum_smul_index' [Zero M] [SMulZeroClass R M] [AddCommMonoid N] {g : α →₀ M} {b : R}
176177
{h : α → M → N} (h0 : ∀ i, h i 0 = 0) : (b • g).sum h = g.sum fun i c => h i (b • c) :=
177178
Finsupp.sum_mapRange_index h0
178179

179180
/-- A version of `Finsupp.sum_smul_index'` for bundled additive maps. -/
180-
theorem sum_smul_index_addMonoidHom [AddMonoid M] [AddCommMonoid N] [DistribSMul R M] {g : α →₀ M}
181-
{b : R} {h : α → M →+ N} : ((b • g).sum fun a => h a) = g.sum fun i c => h i (b • c) :=
181+
theorem sum_smul_index_addMonoidHom [AddZeroClass M] [AddCommMonoid N] [SMulZeroClass R M]
182+
{g : α →₀ M} {b : R} {h : α → M →+ N} :
183+
((b • g).sum fun a => h a) = g.sum fun i c => h i (b • c) :=
182184
sum_mapRange_index fun i => (h i).map_zero
183185

184186
instance noZeroSMulDivisors [Zero R] [Zero M] [SMulZeroClass R M] {ι : Type*}

Mathlib/Data/Finsupp/SMulWithZero.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ instance isCentralScalar [Zero M] [SMulZeroClass R M] [SMulZeroClass Rᵐᵒᵖ
8080

8181
variable {α M}
8282

83-
theorem support_smul [AddMonoid M] [SMulZeroClass R M] {b : R} {g : α →₀ M} :
83+
theorem support_smul [Zero M] [SMulZeroClass R M] {b : R} {g : α →₀ M} :
8484
(b • g).support ⊆ g.support := fun a => by
8585
simp only [smul_apply, mem_support_iff, Ne]
8686
exact mt fun h => h.symm ▸ smul_zero _
@@ -90,8 +90,8 @@ theorem smul_single [Zero M] [SMulZeroClass R M] (c : R) (a : α) (b : M) :
9090
c • Finsupp.single a b = Finsupp.single a (c • b) :=
9191
mapRange_single
9292

93-
theorem mapRange_smul {_ : Monoid R} [AddMonoid M] [DistribMulAction R M] [AddMonoid N]
94-
[DistribMulAction R N] {f : M → N} {hf : f 0 = 0} (c : R) (v : α →₀ M)
93+
theorem mapRange_smul [Zero M] [SMulZeroClass R M] [Zero N]
94+
[SMulZeroClass R N] {f : M → N} {hf : f 0 = 0} (c : R) (v : α →₀ M)
9595
(hsmul : ∀ x, f (c • x) = c • f x) : mapRange f hf (c • v) = c • mapRange f hf v := by
9696
erw [← mapRange_comp]
9797
· have : f ∘ (c • ·) = (c • ·) ∘ f := funext hsmul

0 commit comments

Comments
 (0)