Skip to content

Commit a5f5e46

Browse files
committed
chore: Make Finset.prod_product and Fintype.prod_prod_type more uniform (#16884)
Make more variables explicit in the rewriting lemmas. Unsimp `Fintype.prod_prod_type` since `Finset.prod_product` is not simp.
1 parent d1b7ef7 commit a5f5e46

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

Mathlib/Algebra/BigOperators/Group/Finset.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -776,26 +776,26 @@ lemma prod_mul_prod_comm (f g h i : α → β) :
776776
simp_rw [prod_mul_distrib, mul_mul_mul_comm]
777777

778778
@[to_additive]
779-
theorem prod_product {s : Finset γ} {t : Finset α} {f : γ × α → β} :
779+
theorem prod_product (s : Finset γ) (t : Finset α) (f : γ × α → β) :
780780
∏ x ∈ s ×ˢ t, f x = ∏ x ∈ s, ∏ y ∈ t, f (x, y) :=
781781
prod_finset_product (s ×ˢ t) s (fun _a => t) fun _p => mem_product
782782

783783
/-- An uncurried version of `Finset.prod_product`. -/
784784
@[to_additive "An uncurried version of `Finset.sum_product`"]
785-
theorem prod_product' {s : Finset γ} {t : Finset α} {f : γ → α → β} :
785+
theorem prod_product' (s : Finset γ) (t : Finset α) (f : γ → α → β) :
786786
∏ x ∈ s ×ˢ t, f x.1 x.2 = ∏ x ∈ s, ∏ y ∈ t, f x y :=
787-
prod_product
787+
prod_product ..
788788

789789
@[to_additive]
790-
theorem prod_product_right {s : Finset γ} {t : Finset α} {f : γ × α → β} :
790+
theorem prod_product_right (s : Finset γ) (t : Finset α) (f : γ × α → β) :
791791
∏ x ∈ s ×ˢ t, f x = ∏ y ∈ t, ∏ x ∈ s, f (x, y) :=
792792
prod_finset_product_right (s ×ˢ t) t (fun _a => s) fun _p => mem_product.trans and_comm
793793

794794
/-- An uncurried version of `Finset.prod_product_right`. -/
795795
@[to_additive "An uncurried version of `Finset.sum_product_right`"]
796-
theorem prod_product_right' {s : Finset γ} {t : Finset α} {f : γ → α → β} :
796+
theorem prod_product_right' (s : Finset γ) (t : Finset α) (f : γ → α → β) :
797797
∏ x ∈ s ×ˢ t, f x.1 x.2 = ∏ y ∈ t, ∏ x ∈ s, f x y :=
798-
prod_product_right
798+
prod_product_right ..
799799

800800
/-- Generalization of `Finset.prod_comm` to the case when the inner `Finset`s depend on the outer
801801
variable. -/

Mathlib/Algebra/MonoidAlgebra/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ theorem mul_apply_antidiagonal [Mul G] (f g : MonoidAlgebra k G) (x : G) (s : Fi
396396
let F : G × G → k := fun p => if p.1 * p.2 = x then f p.1 * g p.2 else 0
397397
calc
398398
(f * g) x = ∑ a₁ ∈ f.support, ∑ a₂ ∈ g.support, F (a₁, a₂) := mul_apply f g x
399-
_ = ∑ p ∈ f.support ×ˢ g.support, F p := Finset.sum_product.symm
399+
_ = ∑ p ∈ f.support ×ˢ g.support, F p := by rw [Finset.sum_product]
400400
_ = ∑ p ∈ (f.support ×ˢ g.support).filter fun p : G × G => p.1 * p.2 = x, f p.1 * g p.2 :=
401401
(Finset.sum_filter _ _).symm
402402
_ = ∑ p ∈ s.filter fun p : G × G => p.1 ∈ f.support ∧ p.2 ∈ g.support, f p.1 * g p.2 :=

Mathlib/Data/Fintype/BigOperators.lean

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,26 +224,26 @@ theorem Fintype.prod_sum_type (f : α₁ ⊕ α₂ → M) :
224224
∏ x, f x = (∏ a₁, f (Sum.inl a₁)) * ∏ a₂, f (Sum.inr a₂) :=
225225
prod_disj_sum _ _ _
226226

227-
@[to_additive (attr := simp) Fintype.sum_prod_type]
228-
theorem Fintype.prod_prod_type [CommMonoid γ] {f : α₁ × α₂ → γ} :
227+
@[to_additive Fintype.sum_prod_type]
228+
theorem Fintype.prod_prod_type [CommMonoid γ] (f : α₁ × α₂ → γ) :
229229
∏ x, f x = ∏ x, ∏ y, f (x, y) :=
230-
Finset.prod_product
230+
Finset.prod_product ..
231231

232232
/-- An uncurried version of `Finset.prod_prod_type`. -/
233233
@[to_additive Fintype.sum_prod_type' "An uncurried version of `Finset.sum_prod_type`"]
234-
theorem Fintype.prod_prod_type' [CommMonoid γ] {f : α₁ → α₂ → γ} :
234+
theorem Fintype.prod_prod_type' [CommMonoid γ] (f : α₁ → α₂ → γ) :
235235
∏ x : α₁ × α₂, f x.1 x.2 = ∏ x, ∏ y, f x y :=
236-
Finset.prod_product'
236+
Finset.prod_product' ..
237237

238238
@[to_additive Fintype.sum_prod_type_right]
239-
theorem Fintype.prod_prod_type_right [CommMonoid γ] {f : α₁ × α₂ → γ} :
239+
theorem Fintype.prod_prod_type_right [CommMonoid γ] (f : α₁ × α₂ → γ) :
240240
∏ x, f x = ∏ y, ∏ x, f (x, y) :=
241-
Finset.prod_product_right
241+
Finset.prod_product_right ..
242242

243243
/-- An uncurried version of `Finset.prod_prod_type_right`. -/
244244
@[to_additive Fintype.sum_prod_type_right' "An uncurried version of `Finset.sum_prod_type_right`"]
245-
theorem Fintype.prod_prod_type_right' [CommMonoid γ] {f : α₁ → α₂ → γ} :
245+
theorem Fintype.prod_prod_type_right' [CommMonoid γ] (f : α₁ → α₂ → γ) :
246246
∏ x : α₁ × α₂, f x.1 x.2 = ∏ y, ∏ x, f x y :=
247-
Finset.prod_product_right'
247+
Finset.prod_product_right' ..
248248

249249
end

Mathlib/Data/Matrix/Composition.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ variable [Semiring R] [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J]
5555
@[simps!]
5656
def compRingEquiv : Matrix I I (Matrix J J R) ≃+* Matrix (I × J) (I × J) R where
5757
__ := Matrix.compAddEquiv I I J J R
58-
map_mul' _ _ := by
59-
ext _ _
60-
exact (Matrix.sum_apply _ _ _ _).trans <| Eq.symm Fintype.sum_prod_type
58+
map_mul' _ _ := by ext; exact (Matrix.sum_apply ..).trans <| .symm <| Fintype.sum_prod_type ..
6159

6260
end Semiring
6361

Mathlib/LinearAlgebra/Matrix/Trace.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ theorem _root_.AddMonoidHom.map_trace [AddCommMonoid S] (f : R →+ S) (A : Matr
109109

110110
lemma trace_blockDiagonal [DecidableEq p] (M : p → Matrix n n R) :
111111
trace (blockDiagonal M) = ∑ i, trace (M i) := by
112-
simp [blockDiagonal, trace, Finset.sum_comm (γ := n)]
112+
simp [blockDiagonal, trace, Finset.sum_comm (γ := n), Fintype.sum_prod_type]
113113

114114
lemma trace_blockDiagonal' [DecidableEq p] {m : p → Type*} [∀ i, Fintype (m i)]
115115
(M : ∀ i, Matrix (m i) (m i) R) :

Mathlib/RingTheory/MatrixAlgebra.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ theorem invFun_algebraMap (M : Matrix n n R) : invFun R A n (M.map (algebraMap R
9696
simp only [Algebra.algebraMap_eq_smul_one, smul_tmul, ← tmul_sum, mul_boole]
9797
congr
9898
conv_rhs => rw [matrix_eq_sum_stdBasisMatrix M]
99-
convert Finset.sum_product (β := Matrix n n R); simp
99+
convert Finset.sum_product (β := Matrix n n R) ..; simp
100100

101101
theorem right_inv (M : Matrix n n A) : (toFunAlgHom R A n) (invFun R A n M) = M := by
102102
simp only [invFun, map_sum, stdBasisMatrix, apply_ite ↑(algebraMap R A), smul_eq_mul,
103103
mul_boole, toFunAlgHom_apply, RingHom.map_zero, RingHom.map_one, Matrix.map_apply,
104104
Pi.smul_def]
105-
convert Finset.sum_product (β := Matrix n n A)
105+
convert Finset.sum_product (β := Matrix n n A) ..
106106
conv_lhs => rw [matrix_eq_sum_stdBasisMatrix M]
107107
refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => Matrix.ext fun a b => ?_
108108
simp only [stdBasisMatrix, smul_apply, Matrix.map_apply]

0 commit comments

Comments
 (0)