Skip to content

Commit 2c8c18c

Browse files
committed
feat(Algebra): add abstract prod_apply and FunLike.coe_prod (#39657)
Follow-up of #37779, where abstract `IsApply` classes were introduced. Now, we can prove a generic `sum_apply` lemma and in following PRs this will replace specific ones in function spaces.
1 parent 8479ed7 commit 2c8c18c

5 files changed

Lines changed: 25 additions & 5 deletions

File tree

Mathlib/Algebra/BigOperators/Pi.lean

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public import Mathlib.Algebra.Group.Action.Pi
1212
public import Mathlib.Algebra.Notation.Indicator
1313
public import Mathlib.Algebra.Ring.Pi
1414
public import Mathlib.Data.Fintype.Basic
15+
public import Mathlib.Data.FunLike.IsApply
1516

1617
/-!
1718
# Big operators for Pi Types
@@ -230,3 +231,21 @@ theorem eqOn_fun_finsetProd {ι α β : Type*} [CommMonoid α]
230231
convert! eqOn_finsetProd h v <;> simp
231232

232233
end EqOn
234+
235+
section FunLike
236+
237+
variable {F α β ι : Type*} [FunLike F α β] [CommMonoid β] [CommMonoid F]
238+
[IsOneApply F α β] [IsMulApply F α β]
239+
240+
open Classical in
241+
@[to_additive (attr := simp, grind =)]
242+
theorem prod_apply (s : Finset ι) (f : ι → F) (x : α) : (∏ i ∈ s, f i) x = ∏ i ∈ s, f i x := by
243+
induction s using Finset.induction_on with
244+
| empty => simp
245+
| insert i s his h => simp [his, h]
246+
247+
@[to_additive (attr := norm_cast)]
248+
theorem FunLike.coe_prod (s : Finset ι) (f : ι → F) : ↑(∏ i ∈ s, f i) = ∏ i ∈ s, (f i : α → β) := by
249+
ext; simp
250+
251+
end FunLike

Mathlib/Analysis/Calculus/FDeriv/Add.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ section Add
192192
theorem HasFDerivAtFilter.add (hf : HasFDerivAtFilter f f' L)
193193
(hg : HasFDerivAtFilter g g' L) : HasFDerivAtFilter (f + g) (f' + g') L :=
194194
.of_isLittleO <| (hf.isLittleO.add hg.isLittleO).congr_left fun _ => by
195-
grind [Pi.add_apply, add_apply]
195+
grind [Pi.add_apply, ContinuousLinearMap.add_apply]
196196

197197
@[to_fun (attr := fun_prop)]
198198
theorem HasStrictFDerivAt.add (hf : HasStrictFDerivAt f f' x) (hg : HasStrictFDerivAt g g' x) :

Mathlib/Data/Matrix/PEquiv.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ theorem toMatrix_swap [DecidableEq n] [AddGroupWithOne α] (i j : n) :
161161
(1 : Matrix n n α) - (single i i).toMatrix - (single j j).toMatrix + (single i j).toMatrix +
162162
(single j i).toMatrix := by
163163
ext
164-
dsimp [toMatrix, single, Equiv.swap_apply_def, Equiv.toPEquiv, one_apply]
164+
dsimp [toMatrix, single, Equiv.swap_apply_def, Equiv.toPEquiv, Matrix.one_apply]
165165
split_ifs <;> simp_all
166166

167167
@[simp]

Mathlib/LinearAlgebra/Matrix/Polynomial.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ theorem natDegree_det_X_add_C_le (A B : Matrix n n α) :
5656
(X • A.map C + B.map C : Matrix n n α[X]) (g i) i)
5757
_ ≤ Finset.univ.card • 1 := (Finset.sum_le_card_nsmul _ _ 1 fun (i : n) _ => ?_)
5858
_ ≤ Fintype.card n := by simp [mul_one, Finset.card_univ]
59-
dsimp only [add_apply, smul_apply, map_apply, smul_eq_mul]
59+
dsimp only [Matrix.add_apply, Matrix.smul_apply, map_apply, smul_eq_mul]
6060
compute_degree
6161

6262
theorem coeff_det_X_add_C_zero (A B : Matrix n n α) :
@@ -80,7 +80,7 @@ theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
8080
convert! (coeff_prod_of_natDegree_le (R := α) _ _ _ _).symm
8181
· simp [coeff_C]
8282
· rintro p -
83-
dsimp only [add_apply, smul_apply, map_apply, smul_eq_mul]
83+
dsimp only [Matrix.add_apply, Matrix.smul_apply, map_apply, smul_eq_mul]
8484
compute_degree
8585

8686
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :

Mathlib/LinearAlgebra/QuadraticForm/Dual.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def toDualProd (Q : QuadraticForm R M) [Invertible (2 : R)] :
141141
dsimp only [LinearMap.smul_apply, LinearMap.coe_mk, AddHom.coe_mk, AddHom.toFun_eq_coe,
142142
LinearMap.coe_toAddHom, LinearMap.prod_apply, Function.prod_apply, LinearMap.add_apply,
143143
LinearMap.coe_comp, Function.comp_apply, LinearMap.fst_apply, LinearMap.snd_apply,
144-
LinearMap.sub_apply, dualProd_apply, polarBilin_apply_apply, prod_apply, neg_apply]
144+
LinearMap.sub_apply, dualProd_apply, polarBilin_apply_apply, QuadraticMap.prod_apply,
145+
QuadraticMap.neg_apply]
145146
simp only [polar_sub_right, polar_self, nsmul_eq_mul, Nat.cast_ofNat, polar_comm _ x.1 x.2,
146147
smul_sub, Module.End.smul_def, sub_add_sub_cancel, ← sub_eq_add_neg (Q x.1) (Q x.2)]
147148
rw [← map_sub (⅟2 : Module.End R R), ← mul_sub, ← Module.End.smul_def]

0 commit comments

Comments
 (0)