data.matrix.hadamardMathlib.Data.Matrix.Hadamard

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2021 Lu-Ming Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Lu-Ming Zhang
 -/
-import Mathbin.LinearAlgebra.Matrix.Trace
+import LinearAlgebra.Matrix.Trace
 
 #align_import data.matrix.hadamard from "leanprover-community/mathlib"@"d64d67d000b974f0d86a2be7918cf800be6271c8"
 
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2021 Lu-Ming Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Lu-Ming Zhang
-
-! This file was ported from Lean 3 source module data.matrix.hadamard
-! leanprover-community/mathlib commit d64d67d000b974f0d86a2be7918cf800be6271c8
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.LinearAlgebra.Matrix.Trace
 
+#align_import data.matrix.hadamard from "leanprover-community/mathlib"@"d64d67d000b974f0d86a2be7918cf800be6271c8"
+
 /-!
 # Hadamard product of matrices
 
Diff
@@ -54,51 +54,64 @@ def hadamard [Mul α] (A : Matrix m n α) (B : Matrix m n α) : Matrix m n α :=
 #align matrix.hadamard Matrix.hadamard
 -/
 
+#print Matrix.hadamard_apply /-
 -- TODO: set as an equation lemma for `hadamard`, see mathlib4#3024
 @[simp]
 theorem hadamard_apply [Mul α] (A : Matrix m n α) (B : Matrix m n α) (i j) :
     hadamard A B i j = A i j * B i j :=
   rfl
 #align matrix.hadamard_apply Matrix.hadamard_apply
+-/
 
--- mathport name: matrix.hadamard
 scoped infixl:100 " ⊙ " => Matrix.hadamard
 
 section BasicProperties
 
 variable (A : Matrix m n α) (B : Matrix m n α) (C : Matrix m n α)
 
+#print Matrix.hadamard_comm /-
 -- commutativity
 theorem hadamard_comm [CommSemigroup α] : A ⊙ B = B ⊙ A :=
   ext fun _ _ => mul_comm _ _
 #align matrix.hadamard_comm Matrix.hadamard_comm
+-/
 
+#print Matrix.hadamard_assoc /-
 -- associativity
 theorem hadamard_assoc [Semigroup α] : A ⊙ B ⊙ C = A ⊙ (B ⊙ C) :=
   ext fun _ _ => mul_assoc _ _ _
 #align matrix.hadamard_assoc Matrix.hadamard_assoc
+-/
 
+#print Matrix.hadamard_add /-
 -- distributivity
 theorem hadamard_add [Distrib α] : A ⊙ (B + C) = A ⊙ B + A ⊙ C :=
   ext fun _ _ => left_distrib _ _ _
 #align matrix.hadamard_add Matrix.hadamard_add
+-/
 
+#print Matrix.add_hadamard /-
 theorem add_hadamard [Distrib α] : (B + C) ⊙ A = B ⊙ A + C ⊙ A :=
   ext fun _ _ => right_distrib _ _ _
 #align matrix.add_hadamard Matrix.add_hadamard
+-/
 
 -- scalar multiplication
 section Scalar
 
+#print Matrix.smul_hadamard /-
 @[simp]
 theorem smul_hadamard [Mul α] [SMul R α] [IsScalarTower R α α] (k : R) : (k • A) ⊙ B = k • A ⊙ B :=
   ext fun _ _ => smul_mul_assoc _ _ _
 #align matrix.smul_hadamard Matrix.smul_hadamard
+-/
 
+#print Matrix.hadamard_smul /-
 @[simp]
 theorem hadamard_smul [Mul α] [SMul R α] [SMulCommClass R α α] (k : R) : A ⊙ (k • B) = k • A ⊙ B :=
   ext fun _ _ => mul_smul_comm _ _ _
 #align matrix.hadamard_smul Matrix.hadamard_smul
+-/
 
 end Scalar
 
@@ -106,15 +119,19 @@ section Zero
 
 variable [MulZeroClass α]
 
+#print Matrix.hadamard_zero /-
 @[simp]
 theorem hadamard_zero : A ⊙ (0 : Matrix m n α) = 0 :=
   ext fun _ _ => MulZeroClass.mul_zero _
 #align matrix.hadamard_zero Matrix.hadamard_zero
+-/
 
+#print Matrix.zero_hadamard /-
 @[simp]
 theorem zero_hadamard : (0 : Matrix m n α) ⊙ A = 0 :=
   ext fun _ _ => MulZeroClass.zero_mul _
 #align matrix.zero_hadamard Matrix.zero_hadamard
+-/
 
 end Zero
 
@@ -124,13 +141,17 @@ variable [DecidableEq n] [MulZeroOneClass α]
 
 variable (M : Matrix n n α)
 
+#print Matrix.hadamard_one /-
 theorem hadamard_one : M ⊙ (1 : Matrix n n α) = diagonal fun i => M i i := by ext;
   by_cases h : i = j <;> simp [h]
 #align matrix.hadamard_one Matrix.hadamard_one
+-/
 
+#print Matrix.one_hadamard /-
 theorem one_hadamard : (1 : Matrix n n α) ⊙ M = diagonal fun i => M i i := by ext;
   by_cases h : i = j <;> simp [h]
 #align matrix.one_hadamard Matrix.one_hadamard
+-/
 
 end One
 
@@ -138,10 +159,12 @@ section Diagonal
 
 variable [DecidableEq n] [MulZeroClass α]
 
+#print Matrix.diagonal_hadamard_diagonal /-
 theorem diagonal_hadamard_diagonal (v : n → α) (w : n → α) :
     diagonal v ⊙ diagonal w = diagonal (v * w) :=
   ext fun _ _ => (apply_ite₂ _ _ _ _ _ _).trans (congr_arg _ <| MulZeroClass.zero_mul 0)
 #align matrix.diagonal_hadamard_diagonal Matrix.diagonal_hadamard_diagonal
+-/
 
 end Diagonal
 
@@ -151,16 +174,20 @@ variable [Fintype m] [Fintype n]
 
 variable (R) [Semiring α] [Semiring R] [Module R α]
 
+#print Matrix.sum_hadamard_eq /-
 theorem sum_hadamard_eq : ∑ (i : m) (j : n), (A ⊙ B) i j = trace (A ⬝ Bᵀ) :=
   rfl
 #align matrix.sum_hadamard_eq Matrix.sum_hadamard_eq
+-/
 
+#print Matrix.dotProduct_vecMul_hadamard /-
 theorem dotProduct_vecMul_hadamard [DecidableEq m] [DecidableEq n] (v : m → α) (w : n → α) :
     dotProduct (vecMul v (A ⊙ B)) w = trace (diagonal v ⬝ A ⬝ (B ⬝ diagonal w)ᵀ) :=
   by
   rw [← sum_hadamard_eq, Finset.sum_comm]
   simp [dot_product, vec_mul, Finset.sum_mul, mul_assoc]
 #align matrix.dot_product_vec_mul_hadamard Matrix.dotProduct_vecMul_hadamard
+-/
 
 end trace
 
Diff
@@ -151,7 +151,7 @@ variable [Fintype m] [Fintype n]
 
 variable (R) [Semiring α] [Semiring R] [Module R α]
 
-theorem sum_hadamard_eq : (∑ (i : m) (j : n), (A ⊙ B) i j) = trace (A ⬝ Bᵀ) :=
+theorem sum_hadamard_eq : ∑ (i : m) (j : n), (A ⊙ B) i j = trace (A ⬝ Bᵀ) :=
   rfl
 #align matrix.sum_hadamard_eq Matrix.sum_hadamard_eq
 
Diff
@@ -44,7 +44,7 @@ variable {R : Type _}
 
 namespace Matrix
 
-open Matrix BigOperators
+open scoped Matrix BigOperators
 
 #print Matrix.hadamard /-
 /-- `matrix.hadamard` defines the Hadamard product,
Diff
@@ -54,12 +54,6 @@ def hadamard [Mul α] (A : Matrix m n α) (B : Matrix m n α) : Matrix m n α :=
 #align matrix.hadamard Matrix.hadamard
 -/
 
-/- warning: matrix.hadamard_apply -> Matrix.hadamard_apply is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} [_inst_1 : Mul.{u1} α] (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) (i : m) (j : n), Eq.{succ u1} α (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 A B i j) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_1) (A i j) (B i j))
-but is expected to have type
-  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} [_inst_1 : Mul.{u3} α] (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) (i : m) (j : n), Eq.{succ u3} α (Matrix.hadamard.{u3, u2, u1} α m n _inst_1 A B i j) (HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α _inst_1) (A i j) (B i j))
-Case conversion may be inaccurate. Consider using '#align matrix.hadamard_apply Matrix.hadamard_applyₓ'. -/
 -- TODO: set as an equation lemma for `hadamard`, see mathlib4#3024
 @[simp]
 theorem hadamard_apply [Mul α] (A : Matrix m n α) (B : Matrix m n α) (i j) :
@@ -74,45 +68,21 @@ section BasicProperties
 
 variable (A : Matrix m n α) (B : Matrix m n α) (C : Matrix m n α)
 
-/- warning: matrix.hadamard_comm -> Matrix.hadamard_comm is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : CommSemigroup.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α (CommSemigroup.toSemigroup.{u1} α _inst_1)) A B) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α (CommSemigroup.toSemigroup.{u1} α _inst_1)) B A)
-but is expected to have type
-  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) [_inst_1 : CommSemigroup.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α (CommSemigroup.toSemigroup.{u3} α _inst_1)) A B) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α (CommSemigroup.toSemigroup.{u3} α _inst_1)) B A)
-Case conversion may be inaccurate. Consider using '#align matrix.hadamard_comm Matrix.hadamard_commₓ'. -/
 -- commutativity
 theorem hadamard_comm [CommSemigroup α] : A ⊙ B = B ⊙ A :=
   ext fun _ _ => mul_comm _ _
 #align matrix.hadamard_comm Matrix.hadamard_comm
 
-/- warning: matrix.hadamard_assoc -> Matrix.hadamard_assoc is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) (C : Matrix.{u2, u3, u1} m n α) [_inst_1 : Semigroup.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α _inst_1) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α _inst_1) A B) C) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α _inst_1) A (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α _inst_1) B C))
-but is expected to have type
-  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) (C : Matrix.{u2, u1, u3} m n α) [_inst_1 : Semigroup.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α _inst_1) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α _inst_1) A B) C) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α _inst_1) A (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α _inst_1) B C))
-Case conversion may be inaccurate. Consider using '#align matrix.hadamard_assoc Matrix.hadamard_assocₓ'. -/
 -- associativity
 theorem hadamard_assoc [Semigroup α] : A ⊙ B ⊙ C = A ⊙ (B ⊙ C) :=
   ext fun _ _ => mul_assoc _ _ _
 #align matrix.hadamard_assoc Matrix.hadamard_assoc
 
-/- warning: matrix.hadamard_add -> Matrix.hadamard_add is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) (C : Matrix.{u2, u3, u1} m n α) [_inst_1 : Distrib.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) A (HAdd.hAdd.{max u2 u3 u1, max u2 u3 u1, max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (instHAdd.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasAdd.{u1, u2, u3} m n α (Distrib.toHasAdd.{u1} α _inst_1))) B C)) (HAdd.hAdd.{max u2 u3 u1, max u2 u3 u1, max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (instHAdd.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasAdd.{u1, u2, u3} m n α (Distrib.toHasAdd.{u1} α _inst_1))) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) A B) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) A C))
-but is expected to have type
-  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) (C : Matrix.{u2, u1, u3} m n α) [_inst_1 : Distrib.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) A (HAdd.hAdd.{max (max u3 u2) u1, max (max u3 u2) u1, max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (instHAdd.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.add.{u3, u2, u1} m n α (Distrib.toAdd.{u3} α _inst_1))) B C)) (HAdd.hAdd.{max (max u3 u2) u1, max (max u3 u2) u1, max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (instHAdd.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.add.{u3, u2, u1} m n α (Distrib.toAdd.{u3} α _inst_1))) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) A B) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) A C))
-Case conversion may be inaccurate. Consider using '#align matrix.hadamard_add Matrix.hadamard_addₓ'. -/
 -- distributivity
 theorem hadamard_add [Distrib α] : A ⊙ (B + C) = A ⊙ B + A ⊙ C :=
   ext fun _ _ => left_distrib _ _ _
 #align matrix.hadamard_add Matrix.hadamard_add
 
-/- warning: matrix.add_hadamard -> Matrix.add_hadamard is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) (C : Matrix.{u2, u3, u1} m n α) [_inst_1 : Distrib.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) (HAdd.hAdd.{max u2 u3 u1, max u2 u3 u1, max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (instHAdd.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasAdd.{u1, u2, u3} m n α (Distrib.toHasAdd.{u1} α _inst_1))) B C) A) (HAdd.hAdd.{max u2 u3 u1, max u2 u3 u1, max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (instHAdd.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasAdd.{u1, u2, u3} m n α (Distrib.toHasAdd.{u1} α _inst_1))) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) B A) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) C A))
-but is expected to have type
-  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) (C : Matrix.{u2, u1, u3} m n α) [_inst_1 : Distrib.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) (HAdd.hAdd.{max (max u3 u2) u1, max (max u3 u2) u1, max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (instHAdd.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.add.{u3, u2, u1} m n α (Distrib.toAdd.{u3} α _inst_1))) B C) A) (HAdd.hAdd.{max (max u3 u2) u1, max (max u3 u2) u1, max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (instHAdd.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.add.{u3, u2, u1} m n α (Distrib.toAdd.{u3} α _inst_1))) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) B A) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) C A))
-Case conversion may be inaccurate. Consider using '#align matrix.add_hadamard Matrix.add_hadamardₓ'. -/
 theorem add_hadamard [Distrib α] : (B + C) ⊙ A = B ⊙ A + C ⊙ A :=
   ext fun _ _ => right_distrib _ _ _
 #align matrix.add_hadamard Matrix.add_hadamard
@@ -120,23 +90,11 @@ theorem add_hadamard [Distrib α] : (B + C) ⊙ A = B ⊙ A + C ⊙ A :=
 -- scalar multiplication
 section Scalar
 
-/- warning: matrix.smul_hadamard -> Matrix.smul_hadamard is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} {R : Type.{u4}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : Mul.{u1} α] [_inst_2 : SMul.{u4, u1} R α] [_inst_3 : IsScalarTower.{u4, u1, u1} R α α _inst_2 (Mul.toSMul.{u1} α _inst_1) _inst_2] (k : R), Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 (SMul.smul.{u4, max u2 u3 u1} R (Matrix.{u2, u3, u1} m n α) (Matrix.hasSmul.{u1, u2, u3, u4} m n R α _inst_2) k A) B) (SMul.smul.{u4, max u2 u3 u1} R (Matrix.{u2, u3, u1} m n α) (Matrix.hasSmul.{u1, u2, u3, u4} m n R α _inst_2) k (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 A B))
-but is expected to have type
-  forall {α : Type.{u4}} {m : Type.{u2}} {n : Type.{u1}} {R : Type.{u3}} (A : Matrix.{u2, u1, u4} m n α) (B : Matrix.{u2, u1, u4} m n α) [_inst_1 : Mul.{u4} α] [_inst_2 : SMul.{u3, u4} R α] [_inst_3 : IsScalarTower.{u3, u4, u4} R α α _inst_2 (Mul.toSMul.{u4} α _inst_1) _inst_2] (k : R), Eq.{max (max (succ u4) (succ u2)) (succ u1)} (Matrix.{u2, u1, u4} m n α) (Matrix.hadamard.{u4, u2, u1} α m n _inst_1 (HSMul.hSMul.{u3, max (max u4 u2) u1, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.{u2, u1, u4} m n α) (instHSMul.{u3, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.smul.{u4, u2, u1, u3} m n R α _inst_2)) k A) B) (HSMul.hSMul.{u3, max (max u1 u2) u4, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.{u2, u1, u4} m n α) (instHSMul.{u3, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.smul.{u4, u2, u1, u3} m n R α _inst_2)) k (Matrix.hadamard.{u4, u2, u1} α m n _inst_1 A B))
-Case conversion may be inaccurate. Consider using '#align matrix.smul_hadamard Matrix.smul_hadamardₓ'. -/
 @[simp]
 theorem smul_hadamard [Mul α] [SMul R α] [IsScalarTower R α α] (k : R) : (k • A) ⊙ B = k • A ⊙ B :=
   ext fun _ _ => smul_mul_assoc _ _ _
 #align matrix.smul_hadamard Matrix.smul_hadamard
 
-/- warning: matrix.hadamard_smul -> Matrix.hadamard_smul is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} {R : Type.{u4}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : Mul.{u1} α] [_inst_2 : SMul.{u4, u1} R α] [_inst_3 : SMulCommClass.{u4, u1, u1} R α α _inst_2 (Mul.toSMul.{u1} α _inst_1)] (k : R), Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 A (SMul.smul.{u4, max u2 u3 u1} R (Matrix.{u2, u3, u1} m n α) (Matrix.hasSmul.{u1, u2, u3, u4} m n R α _inst_2) k B)) (SMul.smul.{u4, max u2 u3 u1} R (Matrix.{u2, u3, u1} m n α) (Matrix.hasSmul.{u1, u2, u3, u4} m n R α _inst_2) k (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 A B))
-but is expected to have type
-  forall {α : Type.{u4}} {m : Type.{u2}} {n : Type.{u1}} {R : Type.{u3}} (A : Matrix.{u2, u1, u4} m n α) (B : Matrix.{u2, u1, u4} m n α) [_inst_1 : Mul.{u4} α] [_inst_2 : SMul.{u3, u4} R α] [_inst_3 : SMulCommClass.{u3, u4, u4} R α α _inst_2 (Mul.toSMul.{u4} α _inst_1)] (k : R), Eq.{max (max (succ u4) (succ u2)) (succ u1)} (Matrix.{u2, u1, u4} m n α) (Matrix.hadamard.{u4, u2, u1} α m n _inst_1 A (HSMul.hSMul.{u3, max (max u4 u2) u1, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.{u2, u1, u4} m n α) (instHSMul.{u3, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.smul.{u4, u2, u1, u3} m n R α _inst_2)) k B)) (HSMul.hSMul.{u3, max (max u1 u2) u4, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.{u2, u1, u4} m n α) (instHSMul.{u3, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.smul.{u4, u2, u1, u3} m n R α _inst_2)) k (Matrix.hadamard.{u4, u2, u1} α m n _inst_1 A B))
-Case conversion may be inaccurate. Consider using '#align matrix.hadamard_smul Matrix.hadamard_smulₓ'. -/
 @[simp]
 theorem hadamard_smul [Mul α] [SMul R α] [SMulCommClass R α α] (k : R) : A ⊙ (k • B) = k • A ⊙ B :=
   ext fun _ _ => mul_smul_comm _ _ _
@@ -148,23 +106,11 @@ section Zero
 
 variable [MulZeroClass α]
 
-/- warning: matrix.hadamard_zero -> Matrix.hadamard_zero is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) [_inst_1 : MulZeroClass.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (MulZeroClass.toHasMul.{u1} α _inst_1) A (OfNat.ofNat.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (OfNat.mk.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (Zero.zero.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasZero.{u1, u2, u3} m n α (MulZeroClass.toHasZero.{u1} α _inst_1)))))) (OfNat.ofNat.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (OfNat.mk.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (Zero.zero.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasZero.{u1, u2, u3} m n α (MulZeroClass.toHasZero.{u1} α _inst_1)))))
-but is expected to have type
-  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) [_inst_1 : MulZeroClass.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (MulZeroClass.toMul.{u3} α _inst_1) A (OfNat.ofNat.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) 0 (Zero.toOfNat0.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.zero.{u3, u2, u1} m n α (MulZeroClass.toZero.{u3} α _inst_1))))) (OfNat.ofNat.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) 0 (Zero.toOfNat0.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.zero.{u3, u2, u1} m n α (MulZeroClass.toZero.{u3} α _inst_1))))
-Case conversion may be inaccurate. Consider using '#align matrix.hadamard_zero Matrix.hadamard_zeroₓ'. -/
 @[simp]
 theorem hadamard_zero : A ⊙ (0 : Matrix m n α) = 0 :=
   ext fun _ _ => MulZeroClass.mul_zero _
 #align matrix.hadamard_zero Matrix.hadamard_zero
 
-/- warning: matrix.zero_hadamard -> Matrix.zero_hadamard is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) [_inst_1 : MulZeroClass.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (MulZeroClass.toHasMul.{u1} α _inst_1) (OfNat.ofNat.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (OfNat.mk.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (Zero.zero.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasZero.{u1, u2, u3} m n α (MulZeroClass.toHasZero.{u1} α _inst_1))))) A) (OfNat.ofNat.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (OfNat.mk.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (Zero.zero.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasZero.{u1, u2, u3} m n α (MulZeroClass.toHasZero.{u1} α _inst_1)))))
-but is expected to have type
-  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) [_inst_1 : MulZeroClass.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (MulZeroClass.toMul.{u3} α _inst_1) (OfNat.ofNat.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) 0 (Zero.toOfNat0.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.zero.{u3, u2, u1} m n α (MulZeroClass.toZero.{u3} α _inst_1)))) A) (OfNat.ofNat.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) 0 (Zero.toOfNat0.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.zero.{u3, u2, u1} m n α (MulZeroClass.toZero.{u3} α _inst_1))))
-Case conversion may be inaccurate. Consider using '#align matrix.zero_hadamard Matrix.zero_hadamardₓ'. -/
 @[simp]
 theorem zero_hadamard : (0 : Matrix m n α) ⊙ A = 0 :=
   ext fun _ _ => MulZeroClass.zero_mul _
@@ -178,22 +124,10 @@ variable [DecidableEq n] [MulZeroOneClass α]
 
 variable (M : Matrix n n α)
 
-/- warning: matrix.hadamard_one -> Matrix.hadamard_one is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {n : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} n] [_inst_2 : MulZeroOneClass.{u1} α] (M : Matrix.{u2, u2, u1} n n α), Eq.{succ (max u2 u1)} (Matrix.{u2, u2, u1} n n α) (Matrix.hadamard.{u1, u2, u2} α n n (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) M (OfNat.ofNat.{max u2 u1} (Matrix.{u2, u2, u1} n n α) 1 (OfNat.mk.{max u2 u1} (Matrix.{u2, u2, u1} n n α) 1 (One.one.{max u2 u1} (Matrix.{u2, u2, u1} n n α) (Matrix.hasOne.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α _inst_2))))))) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (fun (i : n) => M i i))
-but is expected to have type
-  forall {α : Type.{u2}} {n : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} n] [_inst_2 : MulZeroOneClass.{u2} α] (M : Matrix.{u1, u1, u2} n n α), Eq.{max (succ u2) (succ u1)} (Matrix.{u1, u1, u2} n n α) (Matrix.hadamard.{u2, u1, u1} α n n (MulZeroClass.toMul.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) M (OfNat.ofNat.{max u2 u1} (Matrix.{u1, u1, u2} n n α) 1 (One.toOfNat1.{max u2 u1} (Matrix.{u1, u1, u2} n n α) (Matrix.one.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2)))))) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (fun (i : n) => M i i))
-Case conversion may be inaccurate. Consider using '#align matrix.hadamard_one Matrix.hadamard_oneₓ'. -/
 theorem hadamard_one : M ⊙ (1 : Matrix n n α) = diagonal fun i => M i i := by ext;
   by_cases h : i = j <;> simp [h]
 #align matrix.hadamard_one Matrix.hadamard_one
 
-/- warning: matrix.one_hadamard -> Matrix.one_hadamard is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {n : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} n] [_inst_2 : MulZeroOneClass.{u1} α] (M : Matrix.{u2, u2, u1} n n α), Eq.{succ (max u2 u1)} (Matrix.{u2, u2, u1} n n α) (Matrix.hadamard.{u1, u2, u2} α n n (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (OfNat.ofNat.{max u2 u1} (Matrix.{u2, u2, u1} n n α) 1 (OfNat.mk.{max u2 u1} (Matrix.{u2, u2, u1} n n α) 1 (One.one.{max u2 u1} (Matrix.{u2, u2, u1} n n α) (Matrix.hasOne.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α _inst_2)))))) M) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (fun (i : n) => M i i))
-but is expected to have type
-  forall {α : Type.{u2}} {n : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} n] [_inst_2 : MulZeroOneClass.{u2} α] (M : Matrix.{u1, u1, u2} n n α), Eq.{max (succ u2) (succ u1)} (Matrix.{u1, u1, u2} n n α) (Matrix.hadamard.{u2, u1, u1} α n n (MulZeroClass.toMul.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) (OfNat.ofNat.{max u2 u1} (Matrix.{u1, u1, u2} n n α) 1 (One.toOfNat1.{max u2 u1} (Matrix.{u1, u1, u2} n n α) (Matrix.one.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2))))) M) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (fun (i : n) => M i i))
-Case conversion may be inaccurate. Consider using '#align matrix.one_hadamard Matrix.one_hadamardₓ'. -/
 theorem one_hadamard : (1 : Matrix n n α) ⊙ M = diagonal fun i => M i i := by ext;
   by_cases h : i = j <;> simp [h]
 #align matrix.one_hadamard Matrix.one_hadamard
@@ -204,12 +138,6 @@ section Diagonal
 
 variable [DecidableEq n] [MulZeroClass α]
 
-/- warning: matrix.diagonal_hadamard_diagonal -> Matrix.diagonal_hadamard_diagonal is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {n : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} n] [_inst_2 : MulZeroClass.{u1} α] (v : n -> α) (w : n -> α), Eq.{succ (max u2 u1)} (Matrix.{u2, u2, u1} n n α) (Matrix.hadamard.{u1, u2, u2} α n n (MulZeroClass.toHasMul.{u1} α _inst_2) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) v) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) w)) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (n -> α) (n -> α) (n -> α) (instHMul.{max u2 u1} (n -> α) (Pi.instMul.{u2, u1} n (fun (ᾰ : n) => α) (fun (i : n) => MulZeroClass.toHasMul.{u1} α _inst_2))) v w))
-but is expected to have type
-  forall {α : Type.{u2}} {n : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} n] [_inst_2 : MulZeroClass.{u2} α] (v : n -> α) (w : n -> α), Eq.{max (succ u2) (succ u1)} (Matrix.{u1, u1, u2} n n α) (Matrix.hadamard.{u2, u1, u1} α n n (MulZeroClass.toMul.{u2} α _inst_2) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toZero.{u2} α _inst_2) v) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toZero.{u2} α _inst_2) w)) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toZero.{u2} α _inst_2) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (n -> α) (n -> α) (n -> α) (instHMul.{max u2 u1} (n -> α) (Pi.instMul.{u1, u2} n (fun (ᾰ : n) => α) (fun (i : n) => MulZeroClass.toMul.{u2} α _inst_2))) v w))
-Case conversion may be inaccurate. Consider using '#align matrix.diagonal_hadamard_diagonal Matrix.diagonal_hadamard_diagonalₓ'. -/
 theorem diagonal_hadamard_diagonal (v : n → α) (w : n → α) :
     diagonal v ⊙ diagonal w = diagonal (v * w) :=
   ext fun _ _ => (apply_ite₂ _ _ _ _ _ _).trans (congr_arg _ <| MulZeroClass.zero_mul 0)
@@ -223,22 +151,10 @@ variable [Fintype m] [Fintype n]
 
 variable (R) [Semiring α] [Semiring R] [Module R α]
 
-/- warning: matrix.sum_hadamard_eq -> Matrix.sum_hadamard_eq is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : Fintype.{u2} m] [_inst_2 : Fintype.{u3} n] [_inst_3 : Semiring.{u1} α], Eq.{succ u1} α (Finset.sum.{u1, u2} α m (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Finset.univ.{u2} m _inst_1) (fun (i : m) => Finset.sum.{u1, u3} α n (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Finset.univ.{u3} n _inst_2) (fun (j : n) => Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) A B i j))) (Matrix.trace.{u2, u1} m α _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u2, u3, u2} m n m α _inst_2 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) A (Matrix.transpose.{u1, u2, u3} m n α B)))
-but is expected to have type
-  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) [_inst_1 : Fintype.{u2} m] [_inst_2 : Fintype.{u1} n] [_inst_3 : Semiring.{u3} α], Eq.{succ u3} α (Finset.sum.{u3, u2} α m (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) (Finset.univ.{u2} m _inst_1) (fun (i : m) => Finset.sum.{u3, u1} α n (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) (Finset.univ.{u1} n _inst_2) (fun (j : n) => Matrix.hadamard.{u3, u2, u1} α m n (NonUnitalNonAssocSemiring.toMul.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) A B i j))) (Matrix.trace.{u2, u3} m α _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) (Matrix.mul.{u3, u2, u1, u2} m n m α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) A (Matrix.transpose.{u3, u2, u1} m n α B)))
-Case conversion may be inaccurate. Consider using '#align matrix.sum_hadamard_eq Matrix.sum_hadamard_eqₓ'. -/
 theorem sum_hadamard_eq : (∑ (i : m) (j : n), (A ⊙ B) i j) = trace (A ⬝ Bᵀ) :=
   rfl
 #align matrix.sum_hadamard_eq Matrix.sum_hadamard_eq
 
-/- warning: matrix.dot_product_vec_mul_hadamard -> Matrix.dotProduct_vecMul_hadamard is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : Fintype.{u2} m] [_inst_2 : Fintype.{u3} n] [_inst_3 : Semiring.{u1} α] [_inst_6 : DecidableEq.{succ u2} m] [_inst_7 : DecidableEq.{succ u3} n] (v : m -> α) (w : n -> α), Eq.{succ u1} α (Matrix.dotProduct.{u1, u3} n α _inst_2 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.vecMul.{u1, u2, u3} m n α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)) _inst_1 v (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) A B)) w) (Matrix.trace.{u2, u1} m α _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u2, u3, u2} m n m α _inst_2 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u2, u2, u3} m m n α _inst_1 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.diagonal.{u1, u2} m α (fun (a : m) (b : m) => _inst_6 a b) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) v) A) (Matrix.transpose.{u1, u2, u3} m n α (Matrix.mul.{u1, u2, u3, u3} m n n α _inst_2 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) B (Matrix.diagonal.{u1, u3} n α (fun (a : n) (b : n) => _inst_7 a b) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) w)))))
-but is expected to have type
-  forall {α : Type.{u1}} {m : Type.{u3}} {n : Type.{u2}} (A : Matrix.{u3, u2, u1} m n α) (B : Matrix.{u3, u2, u1} m n α) [_inst_1 : Fintype.{u3} m] [_inst_2 : Fintype.{u2} n] [_inst_3 : Semiring.{u1} α] [_inst_6 : DecidableEq.{succ u3} m] [_inst_7 : DecidableEq.{succ u2} n] (v : m -> α) (w : n -> α), Eq.{succ u1} α (Matrix.dotProduct.{u1, u2} n α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.vecMul.{u1, u3, u2} m n α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)) _inst_1 v (Matrix.hadamard.{u1, u3, u2} α m n (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) A B)) w) (Matrix.trace.{u3, u1} m α _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u3, u2, u3} m n m α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u3, u3, u2} m m n α _inst_1 (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.diagonal.{u1, u3} m α (fun (a : m) (b : m) => _inst_6 a b) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α _inst_3)) v) A) (Matrix.transpose.{u1, u3, u2} m n α (Matrix.mul.{u1, u3, u2, u2} m n n α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) B (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_7 a b) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α _inst_3)) w)))))
-Case conversion may be inaccurate. Consider using '#align matrix.dot_product_vec_mul_hadamard Matrix.dotProduct_vecMul_hadamardₓ'. -/
 theorem dotProduct_vecMul_hadamard [DecidableEq m] [DecidableEq n] (v : m → α) (w : n → α) :
     dotProduct (vecMul v (A ⊙ B)) w = trace (diagonal v ⬝ A ⬝ (B ⬝ diagonal w)ᵀ) :=
   by
Diff
@@ -184,9 +184,7 @@ lean 3 declaration is
 but is expected to have type
   forall {α : Type.{u2}} {n : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} n] [_inst_2 : MulZeroOneClass.{u2} α] (M : Matrix.{u1, u1, u2} n n α), Eq.{max (succ u2) (succ u1)} (Matrix.{u1, u1, u2} n n α) (Matrix.hadamard.{u2, u1, u1} α n n (MulZeroClass.toMul.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) M (OfNat.ofNat.{max u2 u1} (Matrix.{u1, u1, u2} n n α) 1 (One.toOfNat1.{max u2 u1} (Matrix.{u1, u1, u2} n n α) (Matrix.one.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2)))))) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (fun (i : n) => M i i))
 Case conversion may be inaccurate. Consider using '#align matrix.hadamard_one Matrix.hadamard_oneₓ'. -/
-theorem hadamard_one : M ⊙ (1 : Matrix n n α) = diagonal fun i => M i i :=
-  by
-  ext
+theorem hadamard_one : M ⊙ (1 : Matrix n n α) = diagonal fun i => M i i := by ext;
   by_cases h : i = j <;> simp [h]
 #align matrix.hadamard_one Matrix.hadamard_one
 
@@ -196,9 +194,7 @@ lean 3 declaration is
 but is expected to have type
   forall {α : Type.{u2}} {n : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} n] [_inst_2 : MulZeroOneClass.{u2} α] (M : Matrix.{u1, u1, u2} n n α), Eq.{max (succ u2) (succ u1)} (Matrix.{u1, u1, u2} n n α) (Matrix.hadamard.{u2, u1, u1} α n n (MulZeroClass.toMul.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) (OfNat.ofNat.{max u2 u1} (Matrix.{u1, u1, u2} n n α) 1 (One.toOfNat1.{max u2 u1} (Matrix.{u1, u1, u2} n n α) (Matrix.one.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2))))) M) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (fun (i : n) => M i i))
 Case conversion may be inaccurate. Consider using '#align matrix.one_hadamard Matrix.one_hadamardₓ'. -/
-theorem one_hadamard : (1 : Matrix n n α) ⊙ M = diagonal fun i => M i i :=
-  by
-  ext
+theorem one_hadamard : (1 : Matrix n n α) ⊙ M = diagonal fun i => M i i := by ext;
   by_cases h : i = j <;> simp [h]
 #align matrix.one_hadamard Matrix.one_hadamard
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Lu-Ming Zhang
 
 ! This file was ported from Lean 3 source module data.matrix.hadamard
-! leanprover-community/mathlib commit 3e068ece210655b7b9a9477c3aff38a492400aa1
+! leanprover-community/mathlib commit d64d67d000b974f0d86a2be7918cf800be6271c8
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,6 +13,9 @@ import Mathbin.LinearAlgebra.Matrix.Trace
 /-!
 # Hadamard product of matrices
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 This file defines the Hadamard product `matrix.hadamard`
 and contains basic properties about them.
 
Diff
@@ -43,12 +43,20 @@ namespace Matrix
 
 open Matrix BigOperators
 
+#print Matrix.hadamard /-
 /-- `matrix.hadamard` defines the Hadamard product,
     which is the pointwise product of two matrices of the same size.-/
 def hadamard [Mul α] (A : Matrix m n α) (B : Matrix m n α) : Matrix m n α :=
   of fun i j => A i j * B i j
 #align matrix.hadamard Matrix.hadamard
+-/
 
+/- warning: matrix.hadamard_apply -> Matrix.hadamard_apply is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} [_inst_1 : Mul.{u1} α] (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) (i : m) (j : n), Eq.{succ u1} α (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 A B i j) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_1) (A i j) (B i j))
+but is expected to have type
+  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} [_inst_1 : Mul.{u3} α] (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) (i : m) (j : n), Eq.{succ u3} α (Matrix.hadamard.{u3, u2, u1} α m n _inst_1 A B i j) (HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α _inst_1) (A i j) (B i j))
+Case conversion may be inaccurate. Consider using '#align matrix.hadamard_apply Matrix.hadamard_applyₓ'. -/
 -- TODO: set as an equation lemma for `hadamard`, see mathlib4#3024
 @[simp]
 theorem hadamard_apply [Mul α] (A : Matrix m n α) (B : Matrix m n α) (i j) :
@@ -63,21 +71,45 @@ section BasicProperties
 
 variable (A : Matrix m n α) (B : Matrix m n α) (C : Matrix m n α)
 
+/- warning: matrix.hadamard_comm -> Matrix.hadamard_comm is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : CommSemigroup.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α (CommSemigroup.toSemigroup.{u1} α _inst_1)) A B) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α (CommSemigroup.toSemigroup.{u1} α _inst_1)) B A)
+but is expected to have type
+  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) [_inst_1 : CommSemigroup.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α (CommSemigroup.toSemigroup.{u3} α _inst_1)) A B) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α (CommSemigroup.toSemigroup.{u3} α _inst_1)) B A)
+Case conversion may be inaccurate. Consider using '#align matrix.hadamard_comm Matrix.hadamard_commₓ'. -/
 -- commutativity
 theorem hadamard_comm [CommSemigroup α] : A ⊙ B = B ⊙ A :=
   ext fun _ _ => mul_comm _ _
 #align matrix.hadamard_comm Matrix.hadamard_comm
 
+/- warning: matrix.hadamard_assoc -> Matrix.hadamard_assoc is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) (C : Matrix.{u2, u3, u1} m n α) [_inst_1 : Semigroup.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α _inst_1) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α _inst_1) A B) C) (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α _inst_1) A (Matrix.hadamard.{u1, u2, u3} α m n (Semigroup.toHasMul.{u1} α _inst_1) B C))
+but is expected to have type
+  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) (C : Matrix.{u2, u1, u3} m n α) [_inst_1 : Semigroup.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α _inst_1) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α _inst_1) A B) C) (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α _inst_1) A (Matrix.hadamard.{u3, u2, u1} α m n (Semigroup.toMul.{u3} α _inst_1) B C))
+Case conversion may be inaccurate. Consider using '#align matrix.hadamard_assoc Matrix.hadamard_assocₓ'. -/
 -- associativity
 theorem hadamard_assoc [Semigroup α] : A ⊙ B ⊙ C = A ⊙ (B ⊙ C) :=
   ext fun _ _ => mul_assoc _ _ _
 #align matrix.hadamard_assoc Matrix.hadamard_assoc
 
+/- warning: matrix.hadamard_add -> Matrix.hadamard_add is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) (C : Matrix.{u2, u3, u1} m n α) [_inst_1 : Distrib.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) A (HAdd.hAdd.{max u2 u3 u1, max u2 u3 u1, max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (instHAdd.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasAdd.{u1, u2, u3} m n α (Distrib.toHasAdd.{u1} α _inst_1))) B C)) (HAdd.hAdd.{max u2 u3 u1, max u2 u3 u1, max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (instHAdd.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasAdd.{u1, u2, u3} m n α (Distrib.toHasAdd.{u1} α _inst_1))) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) A B) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) A C))
+but is expected to have type
+  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) (C : Matrix.{u2, u1, u3} m n α) [_inst_1 : Distrib.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) A (HAdd.hAdd.{max (max u3 u2) u1, max (max u3 u2) u1, max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (instHAdd.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.add.{u3, u2, u1} m n α (Distrib.toAdd.{u3} α _inst_1))) B C)) (HAdd.hAdd.{max (max u3 u2) u1, max (max u3 u2) u1, max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (instHAdd.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.add.{u3, u2, u1} m n α (Distrib.toAdd.{u3} α _inst_1))) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) A B) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) A C))
+Case conversion may be inaccurate. Consider using '#align matrix.hadamard_add Matrix.hadamard_addₓ'. -/
 -- distributivity
 theorem hadamard_add [Distrib α] : A ⊙ (B + C) = A ⊙ B + A ⊙ C :=
   ext fun _ _ => left_distrib _ _ _
 #align matrix.hadamard_add Matrix.hadamard_add
 
+/- warning: matrix.add_hadamard -> Matrix.add_hadamard is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) (C : Matrix.{u2, u3, u1} m n α) [_inst_1 : Distrib.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) (HAdd.hAdd.{max u2 u3 u1, max u2 u3 u1, max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (instHAdd.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasAdd.{u1, u2, u3} m n α (Distrib.toHasAdd.{u1} α _inst_1))) B C) A) (HAdd.hAdd.{max u2 u3 u1, max u2 u3 u1, max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (Matrix.{u2, u3, u1} m n α) (instHAdd.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasAdd.{u1, u2, u3} m n α (Distrib.toHasAdd.{u1} α _inst_1))) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) B A) (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α _inst_1) C A))
+but is expected to have type
+  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) (C : Matrix.{u2, u1, u3} m n α) [_inst_1 : Distrib.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) (HAdd.hAdd.{max (max u3 u2) u1, max (max u3 u2) u1, max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (instHAdd.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.add.{u3, u2, u1} m n α (Distrib.toAdd.{u3} α _inst_1))) B C) A) (HAdd.hAdd.{max (max u3 u2) u1, max (max u3 u2) u1, max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (Matrix.{u2, u1, u3} m n α) (instHAdd.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.add.{u3, u2, u1} m n α (Distrib.toAdd.{u3} α _inst_1))) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) B A) (Matrix.hadamard.{u3, u2, u1} α m n (Distrib.toMul.{u3} α _inst_1) C A))
+Case conversion may be inaccurate. Consider using '#align matrix.add_hadamard Matrix.add_hadamardₓ'. -/
 theorem add_hadamard [Distrib α] : (B + C) ⊙ A = B ⊙ A + C ⊙ A :=
   ext fun _ _ => right_distrib _ _ _
 #align matrix.add_hadamard Matrix.add_hadamard
@@ -85,11 +117,23 @@ theorem add_hadamard [Distrib α] : (B + C) ⊙ A = B ⊙ A + C ⊙ A :=
 -- scalar multiplication
 section Scalar
 
+/- warning: matrix.smul_hadamard -> Matrix.smul_hadamard is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} {R : Type.{u4}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : Mul.{u1} α] [_inst_2 : SMul.{u4, u1} R α] [_inst_3 : IsScalarTower.{u4, u1, u1} R α α _inst_2 (Mul.toSMul.{u1} α _inst_1) _inst_2] (k : R), Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 (SMul.smul.{u4, max u2 u3 u1} R (Matrix.{u2, u3, u1} m n α) (Matrix.hasSmul.{u1, u2, u3, u4} m n R α _inst_2) k A) B) (SMul.smul.{u4, max u2 u3 u1} R (Matrix.{u2, u3, u1} m n α) (Matrix.hasSmul.{u1, u2, u3, u4} m n R α _inst_2) k (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 A B))
+but is expected to have type
+  forall {α : Type.{u4}} {m : Type.{u2}} {n : Type.{u1}} {R : Type.{u3}} (A : Matrix.{u2, u1, u4} m n α) (B : Matrix.{u2, u1, u4} m n α) [_inst_1 : Mul.{u4} α] [_inst_2 : SMul.{u3, u4} R α] [_inst_3 : IsScalarTower.{u3, u4, u4} R α α _inst_2 (Mul.toSMul.{u4} α _inst_1) _inst_2] (k : R), Eq.{max (max (succ u4) (succ u2)) (succ u1)} (Matrix.{u2, u1, u4} m n α) (Matrix.hadamard.{u4, u2, u1} α m n _inst_1 (HSMul.hSMul.{u3, max (max u4 u2) u1, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.{u2, u1, u4} m n α) (instHSMul.{u3, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.smul.{u4, u2, u1, u3} m n R α _inst_2)) k A) B) (HSMul.hSMul.{u3, max (max u1 u2) u4, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.{u2, u1, u4} m n α) (instHSMul.{u3, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.smul.{u4, u2, u1, u3} m n R α _inst_2)) k (Matrix.hadamard.{u4, u2, u1} α m n _inst_1 A B))
+Case conversion may be inaccurate. Consider using '#align matrix.smul_hadamard Matrix.smul_hadamardₓ'. -/
 @[simp]
 theorem smul_hadamard [Mul α] [SMul R α] [IsScalarTower R α α] (k : R) : (k • A) ⊙ B = k • A ⊙ B :=
   ext fun _ _ => smul_mul_assoc _ _ _
 #align matrix.smul_hadamard Matrix.smul_hadamard
 
+/- warning: matrix.hadamard_smul -> Matrix.hadamard_smul is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} {R : Type.{u4}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : Mul.{u1} α] [_inst_2 : SMul.{u4, u1} R α] [_inst_3 : SMulCommClass.{u4, u1, u1} R α α _inst_2 (Mul.toSMul.{u1} α _inst_1)] (k : R), Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 A (SMul.smul.{u4, max u2 u3 u1} R (Matrix.{u2, u3, u1} m n α) (Matrix.hasSmul.{u1, u2, u3, u4} m n R α _inst_2) k B)) (SMul.smul.{u4, max u2 u3 u1} R (Matrix.{u2, u3, u1} m n α) (Matrix.hasSmul.{u1, u2, u3, u4} m n R α _inst_2) k (Matrix.hadamard.{u1, u2, u3} α m n _inst_1 A B))
+but is expected to have type
+  forall {α : Type.{u4}} {m : Type.{u2}} {n : Type.{u1}} {R : Type.{u3}} (A : Matrix.{u2, u1, u4} m n α) (B : Matrix.{u2, u1, u4} m n α) [_inst_1 : Mul.{u4} α] [_inst_2 : SMul.{u3, u4} R α] [_inst_3 : SMulCommClass.{u3, u4, u4} R α α _inst_2 (Mul.toSMul.{u4} α _inst_1)] (k : R), Eq.{max (max (succ u4) (succ u2)) (succ u1)} (Matrix.{u2, u1, u4} m n α) (Matrix.hadamard.{u4, u2, u1} α m n _inst_1 A (HSMul.hSMul.{u3, max (max u4 u2) u1, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.{u2, u1, u4} m n α) (instHSMul.{u3, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.smul.{u4, u2, u1, u3} m n R α _inst_2)) k B)) (HSMul.hSMul.{u3, max (max u1 u2) u4, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.{u2, u1, u4} m n α) (instHSMul.{u3, max (max u4 u2) u1} R (Matrix.{u2, u1, u4} m n α) (Matrix.smul.{u4, u2, u1, u3} m n R α _inst_2)) k (Matrix.hadamard.{u4, u2, u1} α m n _inst_1 A B))
+Case conversion may be inaccurate. Consider using '#align matrix.hadamard_smul Matrix.hadamard_smulₓ'. -/
 @[simp]
 theorem hadamard_smul [Mul α] [SMul R α] [SMulCommClass R α α] (k : R) : A ⊙ (k • B) = k • A ⊙ B :=
   ext fun _ _ => mul_smul_comm _ _ _
@@ -101,11 +145,23 @@ section Zero
 
 variable [MulZeroClass α]
 
+/- warning: matrix.hadamard_zero -> Matrix.hadamard_zero is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) [_inst_1 : MulZeroClass.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (MulZeroClass.toHasMul.{u1} α _inst_1) A (OfNat.ofNat.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (OfNat.mk.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (Zero.zero.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasZero.{u1, u2, u3} m n α (MulZeroClass.toHasZero.{u1} α _inst_1)))))) (OfNat.ofNat.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (OfNat.mk.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (Zero.zero.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasZero.{u1, u2, u3} m n α (MulZeroClass.toHasZero.{u1} α _inst_1)))))
+but is expected to have type
+  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) [_inst_1 : MulZeroClass.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (MulZeroClass.toMul.{u3} α _inst_1) A (OfNat.ofNat.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) 0 (Zero.toOfNat0.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.zero.{u3, u2, u1} m n α (MulZeroClass.toZero.{u3} α _inst_1))))) (OfNat.ofNat.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) 0 (Zero.toOfNat0.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.zero.{u3, u2, u1} m n α (MulZeroClass.toZero.{u3} α _inst_1))))
+Case conversion may be inaccurate. Consider using '#align matrix.hadamard_zero Matrix.hadamard_zeroₓ'. -/
 @[simp]
 theorem hadamard_zero : A ⊙ (0 : Matrix m n α) = 0 :=
   ext fun _ _ => MulZeroClass.mul_zero _
 #align matrix.hadamard_zero Matrix.hadamard_zero
 
+/- warning: matrix.zero_hadamard -> Matrix.zero_hadamard is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) [_inst_1 : MulZeroClass.{u1} α], Eq.{succ (max u2 u3 u1)} (Matrix.{u2, u3, u1} m n α) (Matrix.hadamard.{u1, u2, u3} α m n (MulZeroClass.toHasMul.{u1} α _inst_1) (OfNat.ofNat.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (OfNat.mk.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (Zero.zero.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasZero.{u1, u2, u3} m n α (MulZeroClass.toHasZero.{u1} α _inst_1))))) A) (OfNat.ofNat.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (OfNat.mk.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) 0 (Zero.zero.{max u2 u3 u1} (Matrix.{u2, u3, u1} m n α) (Matrix.hasZero.{u1, u2, u3} m n α (MulZeroClass.toHasZero.{u1} α _inst_1)))))
+but is expected to have type
+  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) [_inst_1 : MulZeroClass.{u3} α], Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Matrix.{u2, u1, u3} m n α) (Matrix.hadamard.{u3, u2, u1} α m n (MulZeroClass.toMul.{u3} α _inst_1) (OfNat.ofNat.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) 0 (Zero.toOfNat0.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.zero.{u3, u2, u1} m n α (MulZeroClass.toZero.{u3} α _inst_1)))) A) (OfNat.ofNat.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) 0 (Zero.toOfNat0.{max (max u3 u2) u1} (Matrix.{u2, u1, u3} m n α) (Matrix.zero.{u3, u2, u1} m n α (MulZeroClass.toZero.{u3} α _inst_1))))
+Case conversion may be inaccurate. Consider using '#align matrix.zero_hadamard Matrix.zero_hadamardₓ'. -/
 @[simp]
 theorem zero_hadamard : (0 : Matrix m n α) ⊙ A = 0 :=
   ext fun _ _ => MulZeroClass.zero_mul _
@@ -119,12 +175,24 @@ variable [DecidableEq n] [MulZeroOneClass α]
 
 variable (M : Matrix n n α)
 
+/- warning: matrix.hadamard_one -> Matrix.hadamard_one is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {n : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} n] [_inst_2 : MulZeroOneClass.{u1} α] (M : Matrix.{u2, u2, u1} n n α), Eq.{succ (max u2 u1)} (Matrix.{u2, u2, u1} n n α) (Matrix.hadamard.{u1, u2, u2} α n n (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) M (OfNat.ofNat.{max u2 u1} (Matrix.{u2, u2, u1} n n α) 1 (OfNat.mk.{max u2 u1} (Matrix.{u2, u2, u1} n n α) 1 (One.one.{max u2 u1} (Matrix.{u2, u2, u1} n n α) (Matrix.hasOne.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α _inst_2))))))) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (fun (i : n) => M i i))
+but is expected to have type
+  forall {α : Type.{u2}} {n : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} n] [_inst_2 : MulZeroOneClass.{u2} α] (M : Matrix.{u1, u1, u2} n n α), Eq.{max (succ u2) (succ u1)} (Matrix.{u1, u1, u2} n n α) (Matrix.hadamard.{u2, u1, u1} α n n (MulZeroClass.toMul.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) M (OfNat.ofNat.{max u2 u1} (Matrix.{u1, u1, u2} n n α) 1 (One.toOfNat1.{max u2 u1} (Matrix.{u1, u1, u2} n n α) (Matrix.one.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2)))))) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (fun (i : n) => M i i))
+Case conversion may be inaccurate. Consider using '#align matrix.hadamard_one Matrix.hadamard_oneₓ'. -/
 theorem hadamard_one : M ⊙ (1 : Matrix n n α) = diagonal fun i => M i i :=
   by
   ext
   by_cases h : i = j <;> simp [h]
 #align matrix.hadamard_one Matrix.hadamard_one
 
+/- warning: matrix.one_hadamard -> Matrix.one_hadamard is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {n : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} n] [_inst_2 : MulZeroOneClass.{u1} α] (M : Matrix.{u2, u2, u1} n n α), Eq.{succ (max u2 u1)} (Matrix.{u2, u2, u1} n n α) (Matrix.hadamard.{u1, u2, u2} α n n (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (OfNat.ofNat.{max u2 u1} (Matrix.{u2, u2, u1} n n α) 1 (OfNat.mk.{max u2 u1} (Matrix.{u2, u2, u1} n n α) 1 (One.one.{max u2 u1} (Matrix.{u2, u2, u1} n n α) (Matrix.hasOne.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α _inst_2)))))) M) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α _inst_2)) (fun (i : n) => M i i))
+but is expected to have type
+  forall {α : Type.{u2}} {n : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} n] [_inst_2 : MulZeroOneClass.{u2} α] (M : Matrix.{u1, u1, u2} n n α), Eq.{max (succ u2) (succ u1)} (Matrix.{u1, u1, u2} n n α) (Matrix.hadamard.{u2, u1, u1} α n n (MulZeroClass.toMul.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) (OfNat.ofNat.{max u2 u1} (Matrix.{u1, u1, u2} n n α) 1 (One.toOfNat1.{max u2 u1} (Matrix.{u1, u1, u2} n n α) (Matrix.one.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2))))) M) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (fun (i : n) => M i i))
+Case conversion may be inaccurate. Consider using '#align matrix.one_hadamard Matrix.one_hadamardₓ'. -/
 theorem one_hadamard : (1 : Matrix n n α) ⊙ M = diagonal fun i => M i i :=
   by
   ext
@@ -137,6 +205,12 @@ section Diagonal
 
 variable [DecidableEq n] [MulZeroClass α]
 
+/- warning: matrix.diagonal_hadamard_diagonal -> Matrix.diagonal_hadamard_diagonal is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {n : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} n] [_inst_2 : MulZeroClass.{u1} α] (v : n -> α) (w : n -> α), Eq.{succ (max u2 u1)} (Matrix.{u2, u2, u1} n n α) (Matrix.hadamard.{u1, u2, u2} α n n (MulZeroClass.toHasMul.{u1} α _inst_2) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) v) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) w)) (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (n -> α) (n -> α) (n -> α) (instHMul.{max u2 u1} (n -> α) (Pi.instMul.{u2, u1} n (fun (ᾰ : n) => α) (fun (i : n) => MulZeroClass.toHasMul.{u1} α _inst_2))) v w))
+but is expected to have type
+  forall {α : Type.{u2}} {n : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} n] [_inst_2 : MulZeroClass.{u2} α] (v : n -> α) (w : n -> α), Eq.{max (succ u2) (succ u1)} (Matrix.{u1, u1, u2} n n α) (Matrix.hadamard.{u2, u1, u1} α n n (MulZeroClass.toMul.{u2} α _inst_2) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toZero.{u2} α _inst_2) v) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toZero.{u2} α _inst_2) w)) (Matrix.diagonal.{u2, u1} n α (fun (a : n) (b : n) => _inst_1 a b) (MulZeroClass.toZero.{u2} α _inst_2) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (n -> α) (n -> α) (n -> α) (instHMul.{max u2 u1} (n -> α) (Pi.instMul.{u1, u2} n (fun (ᾰ : n) => α) (fun (i : n) => MulZeroClass.toMul.{u2} α _inst_2))) v w))
+Case conversion may be inaccurate. Consider using '#align matrix.diagonal_hadamard_diagonal Matrix.diagonal_hadamard_diagonalₓ'. -/
 theorem diagonal_hadamard_diagonal (v : n → α) (w : n → α) :
     diagonal v ⊙ diagonal w = diagonal (v * w) :=
   ext fun _ _ => (apply_ite₂ _ _ _ _ _ _).trans (congr_arg _ <| MulZeroClass.zero_mul 0)
@@ -150,10 +224,22 @@ variable [Fintype m] [Fintype n]
 
 variable (R) [Semiring α] [Semiring R] [Module R α]
 
+/- warning: matrix.sum_hadamard_eq -> Matrix.sum_hadamard_eq is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : Fintype.{u2} m] [_inst_2 : Fintype.{u3} n] [_inst_3 : Semiring.{u1} α], Eq.{succ u1} α (Finset.sum.{u1, u2} α m (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Finset.univ.{u2} m _inst_1) (fun (i : m) => Finset.sum.{u1, u3} α n (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Finset.univ.{u3} n _inst_2) (fun (j : n) => Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) A B i j))) (Matrix.trace.{u2, u1} m α _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u2, u3, u2} m n m α _inst_2 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) A (Matrix.transpose.{u1, u2, u3} m n α B)))
+but is expected to have type
+  forall {α : Type.{u3}} {m : Type.{u2}} {n : Type.{u1}} (A : Matrix.{u2, u1, u3} m n α) (B : Matrix.{u2, u1, u3} m n α) [_inst_1 : Fintype.{u2} m] [_inst_2 : Fintype.{u1} n] [_inst_3 : Semiring.{u3} α], Eq.{succ u3} α (Finset.sum.{u3, u2} α m (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) (Finset.univ.{u2} m _inst_1) (fun (i : m) => Finset.sum.{u3, u1} α n (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) (Finset.univ.{u1} n _inst_2) (fun (j : n) => Matrix.hadamard.{u3, u2, u1} α m n (NonUnitalNonAssocSemiring.toMul.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) A B i j))) (Matrix.trace.{u2, u3} m α _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) (Matrix.mul.{u3, u2, u1, u2} m n m α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α (Semiring.toNonAssocSemiring.{u3} α _inst_3))) A (Matrix.transpose.{u3, u2, u1} m n α B)))
+Case conversion may be inaccurate. Consider using '#align matrix.sum_hadamard_eq Matrix.sum_hadamard_eqₓ'. -/
 theorem sum_hadamard_eq : (∑ (i : m) (j : n), (A ⊙ B) i j) = trace (A ⬝ Bᵀ) :=
   rfl
 #align matrix.sum_hadamard_eq Matrix.sum_hadamard_eq
 
+/- warning: matrix.dot_product_vec_mul_hadamard -> Matrix.dotProduct_vecMul_hadamard is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {m : Type.{u2}} {n : Type.{u3}} (A : Matrix.{u2, u3, u1} m n α) (B : Matrix.{u2, u3, u1} m n α) [_inst_1 : Fintype.{u2} m] [_inst_2 : Fintype.{u3} n] [_inst_3 : Semiring.{u1} α] [_inst_6 : DecidableEq.{succ u2} m] [_inst_7 : DecidableEq.{succ u3} n] (v : m -> α) (w : n -> α), Eq.{succ u1} α (Matrix.dotProduct.{u1, u3} n α _inst_2 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.vecMul.{u1, u2, u3} m n α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)) _inst_1 v (Matrix.hadamard.{u1, u2, u3} α m n (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) A B)) w) (Matrix.trace.{u2, u1} m α _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u2, u3, u2} m n m α _inst_2 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u2, u2, u3} m m n α _inst_1 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.diagonal.{u1, u2} m α (fun (a : m) (b : m) => _inst_6 a b) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) v) A) (Matrix.transpose.{u1, u2, u3} m n α (Matrix.mul.{u1, u2, u3, u3} m n n α _inst_2 (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) B (Matrix.diagonal.{u1, u3} n α (fun (a : n) (b : n) => _inst_7 a b) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)))) w)))))
+but is expected to have type
+  forall {α : Type.{u1}} {m : Type.{u3}} {n : Type.{u2}} (A : Matrix.{u3, u2, u1} m n α) (B : Matrix.{u3, u2, u1} m n α) [_inst_1 : Fintype.{u3} m] [_inst_2 : Fintype.{u2} n] [_inst_3 : Semiring.{u1} α] [_inst_6 : DecidableEq.{succ u3} m] [_inst_7 : DecidableEq.{succ u2} n] (v : m -> α) (w : n -> α), Eq.{succ u1} α (Matrix.dotProduct.{u1, u2} n α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.vecMul.{u1, u3, u2} m n α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3)) _inst_1 v (Matrix.hadamard.{u1, u3, u2} α m n (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) A B)) w) (Matrix.trace.{u3, u1} m α _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u3, u2, u3} m n m α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.mul.{u1, u3, u3, u2} m m n α _inst_1 (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (Matrix.diagonal.{u1, u3} m α (fun (a : m) (b : m) => _inst_6 a b) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α _inst_3)) v) A) (Matrix.transpose.{u1, u3, u2} m n α (Matrix.mul.{u1, u3, u2, u2} m n n α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α _inst_3))) B (Matrix.diagonal.{u1, u2} n α (fun (a : n) (b : n) => _inst_7 a b) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α _inst_3)) w)))))
+Case conversion may be inaccurate. Consider using '#align matrix.dot_product_vec_mul_hadamard Matrix.dotProduct_vecMul_hadamardₓ'. -/
 theorem dotProduct_vecMul_hadamard [DecidableEq m] [DecidableEq n] (v : m → α) (w : n → α) :
     dotProduct (vecMul v (A ⊙ B)) w = trace (diagonal v ⬝ A ⬝ (B ⬝ diagonal w)ᵀ) :=
   by
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Lu-Ming Zhang
 
 ! This file was ported from Lean 3 source module data.matrix.hadamard
-! leanprover-community/mathlib commit 3d7987cda72abc473c7cdbbb075170e9ac620042
+! leanprover-community/mathlib commit 3e068ece210655b7b9a9477c3aff38a492400aa1
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -45,11 +45,17 @@ open Matrix BigOperators
 
 /-- `matrix.hadamard` defines the Hadamard product,
     which is the pointwise product of two matrices of the same size.-/
-@[simp]
-def hadamard [Mul α] (A : Matrix m n α) (B : Matrix m n α) : Matrix m n α
-  | i, j => A i j * B i j
+def hadamard [Mul α] (A : Matrix m n α) (B : Matrix m n α) : Matrix m n α :=
+  of fun i j => A i j * B i j
 #align matrix.hadamard Matrix.hadamard
 
+-- TODO: set as an equation lemma for `hadamard`, see mathlib4#3024
+@[simp]
+theorem hadamard_apply [Mul α] (A : Matrix m n α) (B : Matrix m n α) (i j) :
+    hadamard A B i j = A i j * B i j :=
+  rfl
+#align matrix.hadamard_apply Matrix.hadamard_apply
+
 -- mathport name: matrix.hadamard
 scoped infixl:100 " ⊙ " => Matrix.hadamard
 
Diff
@@ -97,12 +97,12 @@ variable [MulZeroClass α]
 
 @[simp]
 theorem hadamard_zero : A ⊙ (0 : Matrix m n α) = 0 :=
-  ext fun _ _ => mul_zero _
+  ext fun _ _ => MulZeroClass.mul_zero _
 #align matrix.hadamard_zero Matrix.hadamard_zero
 
 @[simp]
 theorem zero_hadamard : (0 : Matrix m n α) ⊙ A = 0 :=
-  ext fun _ _ => zero_mul _
+  ext fun _ _ => MulZeroClass.zero_mul _
 #align matrix.zero_hadamard Matrix.zero_hadamard
 
 end Zero
@@ -133,7 +133,7 @@ variable [DecidableEq n] [MulZeroClass α]
 
 theorem diagonal_hadamard_diagonal (v : n → α) (w : n → α) :
     diagonal v ⊙ diagonal w = diagonal (v * w) :=
-  ext fun _ _ => (apply_ite₂ _ _ _ _ _ _).trans (congr_arg _ <| zero_mul 0)
+  ext fun _ _ => (apply_ite₂ _ _ _ _ _ _).trans (congr_arg _ <| MulZeroClass.zero_mul 0)
 #align matrix.diagonal_hadamard_diagonal Matrix.diagonal_hadamard_diagonal
 
 end Diagonal

Changes in mathlib4

mathlib3
mathlib4
style: replace '.-/' by '. -/' (#11938)

Purely automatic replacement. If this is in any way controversial; I'm happy to just close this PR.

Diff
@@ -40,7 +40,7 @@ namespace Matrix
 open Matrix BigOperators
 
 /-- `Matrix.hadamard` defines the Hadamard product,
-    which is the pointwise product of two matrices of the same size.-/
+    which is the pointwise product of two matrices of the same size. -/
 def hadamard [Mul α] (A : Matrix m n α) (B : Matrix m n α) : Matrix m n α :=
   of fun i j => A i j * B i j
 #align matrix.hadamard Matrix.hadamard
chore: remove mathport name: <expression> lines (#11928)

Quoting [@digama0](https://github.com/digama0):

These were actually never meant to go in the file, they are basically debugging information and only useful on significantly broken mathport files. You can safely remove all of them.

Diff
@@ -52,7 +52,6 @@ theorem hadamard_apply [Mul α] (A : Matrix m n α) (B : Matrix m n α) (i j) :
   rfl
 #align matrix.hadamard_apply Matrix.hadamard_apply
 
--- mathport name: matrix.hadamard
 scoped infixl:100 " ⊙ " => Matrix.hadamard
 
 section BasicProperties
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -33,7 +33,6 @@ hadamard product, hadamard
 
 
 variable {α β γ m n : Type*}
-
 variable {R : Type*}
 
 namespace Matrix
@@ -113,7 +112,6 @@ end Zero
 section One
 
 variable [DecidableEq n] [MulZeroOneClass α]
-
 variable (M : Matrix n n α)
 
 theorem hadamard_one : M ⊙ (1 : Matrix n n α) = diagonal fun i => M i i := by
@@ -142,7 +140,6 @@ end Diagonal
 section trace
 
 variable [Fintype m] [Fintype n]
-
 variable (R) [Semiring α] [Semiring R] [Module R α]
 
 theorem sum_hadamard_eq : (∑ i : m, ∑ j : n, (A ⊙ B) i j) = trace (A * Bᵀ) :=
chore: Matrix.mulVec and Matrix.vecMul get infix notation (#10297)

Zulip discussion: https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Notation.20for.20mul_vec.20and.20vec_mul

Co-authored-by: Martin Dvorak <mdvorak@ista.ac.at>

Diff
@@ -150,7 +150,7 @@ theorem sum_hadamard_eq : (∑ i : m, ∑ j : n, (A ⊙ B) i j) = trace (A * B
 #align matrix.sum_hadamard_eq Matrix.sum_hadamard_eq
 
 theorem dotProduct_vecMul_hadamard [DecidableEq m] [DecidableEq n] (v : m → α) (w : n → α) :
-    dotProduct (vecMul v (A ⊙ B)) w = trace (diagonal v * A * (B * diagonal w)ᵀ) := by
+    dotProduct (v ᵥ* (A ⊙ B)) w = trace (diagonal v * A * (B * diagonal w)ᵀ) := by
   rw [← sum_hadamard_eq, Finset.sum_comm]
   simp [dotProduct, vecMul, Finset.sum_mul, mul_assoc]
 #align matrix.dot_product_vec_mul_hadamard Matrix.dotProduct_vecMul_hadamard
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -100,12 +100,12 @@ variable [MulZeroClass α]
 
 @[simp]
 theorem hadamard_zero : A ⊙ (0 : Matrix m n α) = 0 :=
-  ext fun _ _ => MulZeroClass.mul_zero _
+  ext fun _ _ => mul_zero _
 #align matrix.hadamard_zero Matrix.hadamard_zero
 
 @[simp]
 theorem zero_hadamard : (0 : Matrix m n α) ⊙ A = 0 :=
-  ext fun _ _ => MulZeroClass.zero_mul _
+  ext fun _ _ => zero_mul _
 #align matrix.zero_hadamard Matrix.zero_hadamard
 
 end Zero
@@ -134,7 +134,7 @@ variable [DecidableEq n] [MulZeroClass α]
 
 theorem diagonal_hadamard_diagonal (v : n → α) (w : n → α) :
     diagonal v ⊙ diagonal w = diagonal (v * w) :=
-  ext fun _ _ => (apply_ite₂ _ _ _ _ _ _).trans (congr_arg _ <| MulZeroClass.zero_mul 0)
+  ext fun _ _ => (apply_ite₂ _ _ _ _ _ _).trans (congr_arg _ <| zero_mul 0)
 #align matrix.diagonal_hadamard_diagonal Matrix.diagonal_hadamard_diagonal
 
 end Diagonal
refactor(Data/Matrix): Eliminate notation in favor of HMul (#6487)

The main difficulty here is that * has a slightly difference precedence to . notably around smul and neg.

The other annoyance is that ↑U ⬝ A ⬝ ↑U⁻¹ : Matrix m m 𝔸 now has to be written U.val * A * (U⁻¹).val in order to typecheck.

A downside of this change to consider: if you have a goal of A * (B * C) = (A * B) * C, mul_assoc now gives the illusion of matching, when in fact Matrix.mul_assoc is needed. Previously the distinct symbol made it easy to avoid this mistake.

On the flipside, there is now no need to rewrite by Matrix.mul_eq_mul all the time (indeed, the lemma is now removed).

Diff
@@ -145,12 +145,12 @@ variable [Fintype m] [Fintype n]
 
 variable (R) [Semiring α] [Semiring R] [Module R α]
 
-theorem sum_hadamard_eq : (∑ i : m, ∑ j : n, (A ⊙ B) i j) = trace (A ⬝ Bᵀ) :=
+theorem sum_hadamard_eq : (∑ i : m, ∑ j : n, (A ⊙ B) i j) = trace (A * Bᵀ) :=
   rfl
 #align matrix.sum_hadamard_eq Matrix.sum_hadamard_eq
 
 theorem dotProduct_vecMul_hadamard [DecidableEq m] [DecidableEq n] (v : m → α) (w : n → α) :
-    dotProduct (vecMul v (A ⊙ B)) w = trace (diagonal v ⬝ A ⬝ (B ⬝ diagonal w)ᵀ) := by
+    dotProduct (vecMul v (A ⊙ B)) w = trace (diagonal v * A * (B * diagonal w)ᵀ) := by
   rw [← sum_hadamard_eq, Finset.sum_comm]
   simp [dotProduct, vecMul, Finset.sum_mul, mul_assoc]
 #align matrix.dot_product_vec_mul_hadamard Matrix.dotProduct_vecMul_hadamard
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -32,9 +32,9 @@ hadamard product, hadamard
 -/
 
 
-variable {α β γ m n : Type _}
+variable {α β γ m n : Type*}
 
-variable {R : Type _}
+variable {R : Type*}
 
 namespace Matrix
 
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2021 Lu-Ming Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Lu-Ming Zhang
-
-! This file was ported from Lean 3 source module data.matrix.hadamard
-! leanprover-community/mathlib commit 3e068ece210655b7b9a9477c3aff38a492400aa1
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.LinearAlgebra.Matrix.Trace
 
+#align_import data.matrix.hadamard from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
+
 /-!
 # Hadamard product of matrices
 
chore: cleanup whitespace (#5988)

Grepping for [^ .:{-] [^ :] and reviewing the results. Once I started I couldn't stop. :-)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -27,7 +27,7 @@ and contains basic properties about them.
 
 ## References
 
-*  <https://en.wikipedia.org/wiki/hadamard_product_(matrices)>
+* <https://en.wikipedia.org/wiki/hadamard_product_(matrices)>
 
 ## Tags
 
feat: port Data.Matrix.Hadamard (#3238)

Co-authored-by: Moritz Firsching <firsching@google.com>

Dependencies 8 + 385

386 files ported (98.0%)
159189 lines ported (98.1%)
Show graph

The unported dependencies are