linear_algebra.matrix.hermitianMathlib.LinearAlgebra.Matrix.Hermitian

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)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -323,11 +323,11 @@ theorem IsHermitian.adjugate [Fintype m] [DecidableEq m] {A : Matrix m m α} (hA
 
 end CommRing
 
-section IsROrC
+section RCLike
 
-open IsROrC
+open RCLike
 
-variable [IsROrC α] [IsROrC β]
+variable [RCLike α] [RCLike β]
 
 #print Matrix.IsHermitian.coe_re_apply_self /-
 /-- The diagonal elements of a complex hermitian matrix are real. -/
@@ -364,7 +364,7 @@ theorem isHermitian_iff_isSymmetric [Fintype n] [DecidableEq n] {A : Matrix n n
 #align matrix.is_hermitian_iff_is_symmetric Matrix.isHermitian_iff_isSymmetric
 -/
 
-end IsROrC
+end RCLike
 
 end Matrix
 
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2022 Alexander Bentkamp. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
 -/
-import Mathbin.Analysis.InnerProductSpace.PiL2
+import Analysis.InnerProductSpace.PiL2
 
 #align_import linear_algebra.matrix.hermitian from "leanprover-community/mathlib"@"f60c6087a7275b72d5db3c5a1d0e19e35a429c0a"
 
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2022 Alexander Bentkamp. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
-
-! This file was ported from Lean 3 source module linear_algebra.matrix.hermitian
-! leanprover-community/mathlib commit f60c6087a7275b72d5db3c5a1d0e19e35a429c0a
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Analysis.InnerProductSpace.PiL2
 
+#align_import linear_algebra.matrix.hermitian from "leanprover-community/mathlib"@"f60c6087a7275b72d5db3c5a1d0e19e35a429c0a"
+
 /-! # Hermitian matrices
 
 > THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
Diff
@@ -66,7 +66,7 @@ protected theorem IsHermitian.isSelfAdjoint {A : Matrix n n α} (h : A.IsHermiti
 #print Matrix.IsHermitian.ext /-
 @[ext]
 theorem IsHermitian.ext {A : Matrix n n α} : (∀ i j, star (A j i) = A i j) → A.IsHermitian := by
-  intro h; ext (i j); exact h i j
+  intro h; ext i j; exact h i j
 #align matrix.is_hermitian.ext Matrix.IsHermitian.ext
 -/
 
@@ -359,7 +359,7 @@ theorem isHermitian_iff_isSymmetric [Fintype n] [DecidableEq n] {A : Matrix n n
   · rintro (h : Aᴴ = A) x y
     rw [h]
   · intro h
-    ext (i j)
+    ext i j
     simpa only [(Pi.single_star i 1).symm, ← star_mul_vec, mul_one, dot_product_single,
       single_vec_mul, star_one, one_mul] using
       h (@Pi.single _ _ _ (fun i => AddZeroClass.toHasZero α) i 1)
Diff
@@ -36,7 +36,6 @@ variable {α β : Type _} {m n : Type _} {A : Matrix n n α}
 
 open scoped Matrix
 
--- mathport name: «expr⟪ , ⟫»
 local notation "⟪" x ", " y "⟫" => @inner α _ _ x y
 
 section Star
@@ -83,11 +82,13 @@ theorem IsHermitian.ext_iff {A : Matrix n n α} : A.IsHermitian ↔ ∀ i j, sta
 #align matrix.is_hermitian.ext_iff Matrix.IsHermitian.ext_iff
 -/
 
+#print Matrix.IsHermitian.map /-
 @[simp]
 theorem IsHermitian.map {A : Matrix n n α} (h : A.IsHermitian) (f : α → β)
     (hf : Function.Semiconj f star star) : (A.map f).IsHermitian :=
   (conjTranspose_map f hf).symm.trans <| h.Eq.symm ▸ rfl
 #align matrix.is_hermitian.map Matrix.IsHermitian.map
+-/
 
 #print Matrix.IsHermitian.transpose /-
 theorem IsHermitian.transpose {A : Matrix n n α} (h : A.IsHermitian) : Aᵀ.IsHermitian := by
@@ -108,17 +109,21 @@ theorem IsHermitian.conjTranspose {A : Matrix n n α} (h : A.IsHermitian) : Aᴴ
 #align matrix.is_hermitian.conj_transpose Matrix.IsHermitian.conjTranspose
 -/
 
+#print Matrix.IsHermitian.submatrix /-
 @[simp]
 theorem IsHermitian.submatrix {A : Matrix n n α} (h : A.IsHermitian) (f : m → n) :
     (A.submatrix f f).IsHermitian :=
   (conjTranspose_submatrix _ _ _).trans (h.symm ▸ rfl)
 #align matrix.is_hermitian.submatrix Matrix.IsHermitian.submatrix
+-/
 
+#print Matrix.isHermitian_submatrix_equiv /-
 @[simp]
 theorem isHermitian_submatrix_equiv {A : Matrix n n α} (e : m ≃ n) :
     (A.submatrix e e).IsHermitian ↔ A.IsHermitian :=
   ⟨fun h => by simpa using h.submatrix e.symm, fun h => h.submatrix _⟩
 #align matrix.is_hermitian_submatrix_equiv Matrix.isHermitian_submatrix_equiv
+-/
 
 end Star
 
@@ -133,6 +138,7 @@ theorem isHermitian_conjTranspose_iff (A : Matrix n n α) : Aᴴ.IsHermitian ↔
 #align matrix.is_hermitian_conj_transpose_iff Matrix.isHermitian_conjTranspose_iff
 -/
 
+#print Matrix.IsHermitian.fromBlocks /-
 /-- A block matrix `A.from_blocks B C D` is hermitian,
     if `A` and `D` are hermitian and `Bᴴ = C`. -/
 theorem IsHermitian.fromBlocks {A : Matrix m m α} {B : Matrix m n α} {C : Matrix n m α}
@@ -144,7 +150,9 @@ theorem IsHermitian.fromBlocks {A : Matrix m m α} {B : Matrix m n α} {C : Matr
   rw [from_blocks_conj_transpose]
   congr <;> assumption
 #align matrix.is_hermitian.from_blocks Matrix.IsHermitian.fromBlocks
+-/
 
+#print Matrix.isHermitian_fromBlocks_iff /-
 /-- This is the `iff` version of `matrix.is_hermitian.from_blocks`. -/
 theorem isHermitian_fromBlocks_iff {A : Matrix m m α} {B : Matrix m n α} {C : Matrix n m α}
     {D : Matrix n n α} :
@@ -154,6 +162,7 @@ theorem isHermitian_fromBlocks_iff {A : Matrix m m α} {B : Matrix m n α} {C :
       congr_arg toBlocks₂₂ h⟩,
     fun ⟨hA, hBC, hCB, hD⟩ => IsHermitian.fromBlocks hA hBC hD⟩
 #align matrix.is_hermitian_from_blocks_iff Matrix.isHermitian_fromBlocks_iff
+-/
 
 end InvolutiveStar
 
@@ -161,6 +170,7 @@ section AddMonoid
 
 variable [AddMonoid α] [StarAddMonoid α] [AddMonoid β] [StarAddMonoid β]
 
+#print Matrix.isHermitian_diagonal_of_self_adjoint /-
 /-- A diagonal matrix is hermitian if the entries are self-adjoint -/
 theorem isHermitian_diagonal_of_self_adjoint [DecidableEq n] (v : n → α) (h : IsSelfAdjoint v) :
     (diagonal v).IsHermitian :=
@@ -169,7 +179,9 @@ theorem isHermitian_diagonal_of_self_adjoint [DecidableEq n] (v : n → α) (h :
         v).trans <|
     congr_arg _ h
 #align matrix.is_hermitian_diagonal_of_self_adjoint Matrix.isHermitian_diagonal_of_self_adjoint
+-/
 
+#print Matrix.isHermitian_diagonal /-
 /-- A diagonal matrix is hermitian if the entries have the trivial `star` operation
 (such as on the reals). -/
 @[simp]
@@ -177,17 +189,22 @@ theorem isHermitian_diagonal [TrivialStar α] [DecidableEq n] (v : n → α) :
     (diagonal v).IsHermitian :=
   isHermitian_diagonal_of_self_adjoint _ (IsSelfAdjoint.all _)
 #align matrix.is_hermitian_diagonal Matrix.isHermitian_diagonal
+-/
 
+#print Matrix.isHermitian_zero /-
 @[simp]
 theorem isHermitian_zero : (0 : Matrix n n α).IsHermitian :=
   isSelfAdjoint_zero _
 #align matrix.is_hermitian_zero Matrix.isHermitian_zero
+-/
 
+#print Matrix.IsHermitian.add /-
 @[simp]
 theorem IsHermitian.add {A B : Matrix n n α} (hA : A.IsHermitian) (hB : B.IsHermitian) :
     (A + B).IsHermitian :=
   IsSelfAdjoint.add hA hB
 #align matrix.is_hermitian.add Matrix.IsHermitian.add
+-/
 
 end AddMonoid
 
@@ -195,13 +212,17 @@ section AddCommMonoid
 
 variable [AddCommMonoid α] [StarAddMonoid α]
 
+#print Matrix.isHermitian_add_transpose_self /-
 theorem isHermitian_add_transpose_self (A : Matrix n n α) : (A + Aᴴ).IsHermitian :=
   isSelfAdjoint_add_star_self A
 #align matrix.is_hermitian_add_transpose_self Matrix.isHermitian_add_transpose_self
+-/
 
+#print Matrix.isHermitian_transpose_add_self /-
 theorem isHermitian_transpose_add_self (A : Matrix n n α) : (Aᴴ + A).IsHermitian :=
   isSelfAdjoint_star_add_self A
 #align matrix.is_hermitian_transpose_add_self Matrix.isHermitian_transpose_add_self
+-/
 
 end AddCommMonoid
 
@@ -209,16 +230,20 @@ section AddGroup
 
 variable [AddGroup α] [StarAddMonoid α]
 
+#print Matrix.IsHermitian.neg /-
 @[simp]
 theorem IsHermitian.neg {A : Matrix n n α} (h : A.IsHermitian) : (-A).IsHermitian :=
   IsSelfAdjoint.neg h
 #align matrix.is_hermitian.neg Matrix.IsHermitian.neg
+-/
 
+#print Matrix.IsHermitian.sub /-
 @[simp]
 theorem IsHermitian.sub {A B : Matrix n n α} (hA : A.IsHermitian) (hB : B.IsHermitian) :
     (A - B).IsHermitian :=
   IsSelfAdjoint.sub hA hB
 #align matrix.is_hermitian.sub Matrix.IsHermitian.sub
+-/
 
 end AddGroup
 
@@ -226,29 +251,37 @@ section NonUnitalSemiring
 
 variable [NonUnitalSemiring α] [StarRing α] [NonUnitalSemiring β] [StarRing β]
 
+#print Matrix.isHermitian_mul_conjTranspose_self /-
 /-- Note this is more general than `is_self_adjoint.mul_star_self` as `B` can be rectangular. -/
 theorem isHermitian_mul_conjTranspose_self [Fintype n] (A : Matrix m n α) : (A ⬝ Aᴴ).IsHermitian :=
   by rw [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose]
 #align matrix.is_hermitian_mul_conj_transpose_self Matrix.isHermitian_mul_conjTranspose_self
+-/
 
+#print Matrix.isHermitian_transpose_mul_self /-
 /-- Note this is more general than `is_self_adjoint.star_mul_self` as `B` can be rectangular. -/
 theorem isHermitian_transpose_mul_self [Fintype m] (A : Matrix m n α) : (Aᴴ ⬝ A).IsHermitian := by
   rw [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose]
 #align matrix.is_hermitian_transpose_mul_self Matrix.isHermitian_transpose_mul_self
+-/
 
+#print Matrix.isHermitian_conjTranspose_mul_mul /-
 /-- Note this is more general than `is_self_adjoint.conjugate'` as `B` can be rectangular. -/
 theorem isHermitian_conjTranspose_mul_mul [Fintype m] {A : Matrix m m α} (B : Matrix m n α)
     (hA : A.IsHermitian) : (Bᴴ ⬝ A ⬝ B).IsHermitian := by
   simp only [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose, hA.eq,
     Matrix.mul_assoc]
 #align matrix.is_hermitian_conj_transpose_mul_mul Matrix.isHermitian_conjTranspose_mul_mul
+-/
 
+#print Matrix.isHermitian_mul_mul_conjTranspose /-
 /-- Note this is more general than `is_self_adjoint.conjugate` as `B` can be rectangular. -/
 theorem isHermitian_mul_mul_conjTranspose [Fintype m] {A : Matrix m m α} (B : Matrix n m α)
     (hA : A.IsHermitian) : (B ⬝ A ⬝ Bᴴ).IsHermitian := by
   simp only [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose, hA.eq,
     Matrix.mul_assoc]
 #align matrix.is_hermitian_mul_mul_conj_transpose Matrix.isHermitian_mul_mul_conjTranspose
+-/
 
 end NonUnitalSemiring
 
@@ -256,12 +289,14 @@ section Semiring
 
 variable [Semiring α] [StarRing α] [Semiring β] [StarRing β]
 
+#print Matrix.isHermitian_one /-
 /-- Note this is more general for matrices than `is_self_adjoint_one` as it does not
 require `fintype n`, which is necessary for `monoid (matrix n n R)`. -/
 @[simp]
 theorem isHermitian_one [DecidableEq n] : (1 : Matrix n n α).IsHermitian :=
   conjTranspose_one
 #align matrix.is_hermitian_one Matrix.isHermitian_one
+-/
 
 end Semiring
 
@@ -269,15 +304,19 @@ section CommRing
 
 variable [CommRing α] [StarRing α]
 
+#print Matrix.IsHermitian.inv /-
 theorem IsHermitian.inv [Fintype m] [DecidableEq m] {A : Matrix m m α} (hA : A.IsHermitian) :
     A⁻¹.IsHermitian := by simp [is_hermitian, conj_transpose_nonsing_inv, hA.eq]
 #align matrix.is_hermitian.inv Matrix.IsHermitian.inv
+-/
 
+#print Matrix.isHermitian_inv /-
 @[simp]
 theorem isHermitian_inv [Fintype m] [DecidableEq m] (A : Matrix m m α) [Invertible A] :
     A⁻¹.IsHermitian ↔ A.IsHermitian :=
   ⟨fun h => by rw [← inv_inv_of_invertible A]; exact is_hermitian.inv h, IsHermitian.inv⟩
 #align matrix.is_hermitian_inv Matrix.isHermitian_inv
+-/
 
 #print Matrix.IsHermitian.adjugate /-
 theorem IsHermitian.adjugate [Fintype m] [DecidableEq m] {A : Matrix m m α} (hA : A.IsHermitian) :
@@ -293,17 +332,22 @@ open IsROrC
 
 variable [IsROrC α] [IsROrC β]
 
+#print Matrix.IsHermitian.coe_re_apply_self /-
 /-- The diagonal elements of a complex hermitian matrix are real. -/
 theorem IsHermitian.coe_re_apply_self {A : Matrix n n α} (h : A.IsHermitian) (i : n) :
     (re (A i i) : α) = A i i := by rw [← conj_eq_iff_re, ← star_def, ← conj_transpose_apply, h.eq]
 #align matrix.is_hermitian.coe_re_apply_self Matrix.IsHermitian.coe_re_apply_self
+-/
 
+#print Matrix.IsHermitian.coe_re_diag /-
 /-- The diagonal elements of a complex hermitian matrix are real. -/
 theorem IsHermitian.coe_re_diag {A : Matrix n n α} (h : A.IsHermitian) :
     (fun i => (re (A.diag i) : α)) = A.diag :=
   funext h.coe_re_apply_self
 #align matrix.is_hermitian.coe_re_diag Matrix.IsHermitian.coe_re_diag
+-/
 
+#print Matrix.isHermitian_iff_isSymmetric /-
 /-- A matrix is hermitian iff the corresponding linear map is self adjoint. -/
 theorem isHermitian_iff_isSymmetric [Fintype n] [DecidableEq n] {A : Matrix n n α} :
     IsHermitian A ↔ A.toEuclideanLin.IsSymmetric :=
@@ -321,6 +365,7 @@ theorem isHermitian_iff_isSymmetric [Fintype n] [DecidableEq n] {A : Matrix n n
       h (@Pi.single _ _ _ (fun i => AddZeroClass.toHasZero α) i 1)
         (@Pi.single _ _ _ (fun i => AddZeroClass.toHasZero α) j 1)
 #align matrix.is_hermitian_iff_is_symmetric Matrix.isHermitian_iff_isSymmetric
+-/
 
 end IsROrC
 
Diff
@@ -91,7 +91,7 @@ theorem IsHermitian.map {A : Matrix n n α} (h : A.IsHermitian) (f : α → β)
 
 #print Matrix.IsHermitian.transpose /-
 theorem IsHermitian.transpose {A : Matrix n n α} (h : A.IsHermitian) : Aᵀ.IsHermitian := by
-  rw [is_hermitian, conj_transpose, transpose_map]; congr ; exact h
+  rw [is_hermitian, conj_transpose, transpose_map]; congr; exact h
 #align matrix.is_hermitian.transpose Matrix.IsHermitian.transpose
 -/
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
 
 ! This file was ported from Lean 3 source module linear_algebra.matrix.hermitian
-! leanprover-community/mathlib commit caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c
+! leanprover-community/mathlib commit f60c6087a7275b72d5db3c5a1d0e19e35a429c0a
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -12,6 +12,9 @@ import Mathbin.Analysis.InnerProductSpace.PiL2
 
 /-! # Hermitian matrices
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 This file defines hermitian matrices and some basic results about them.
 
 See also `is_self_adjoint`, which generalizes this definition to other star rings.
@@ -40,33 +43,45 @@ section Star
 
 variable [Star α] [Star β]
 
+#print Matrix.IsHermitian /-
 /-- A matrix is hermitian if it is equal to its conjugate transpose. On the reals, this definition
 captures symmetric matrices. -/
 def IsHermitian (A : Matrix n n α) : Prop :=
   Aᴴ = A
 #align matrix.is_hermitian Matrix.IsHermitian
+-/
 
+#print Matrix.IsHermitian.eq /-
 theorem IsHermitian.eq {A : Matrix n n α} (h : A.IsHermitian) : Aᴴ = A :=
   h
 #align matrix.is_hermitian.eq Matrix.IsHermitian.eq
+-/
 
+#print Matrix.IsHermitian.isSelfAdjoint /-
 protected theorem IsHermitian.isSelfAdjoint {A : Matrix n n α} (h : A.IsHermitian) :
     IsSelfAdjoint A :=
   h
 #align matrix.is_hermitian.is_self_adjoint Matrix.IsHermitian.isSelfAdjoint
+-/
 
+#print Matrix.IsHermitian.ext /-
 @[ext]
 theorem IsHermitian.ext {A : Matrix n n α} : (∀ i j, star (A j i) = A i j) → A.IsHermitian := by
   intro h; ext (i j); exact h i j
 #align matrix.is_hermitian.ext Matrix.IsHermitian.ext
+-/
 
+#print Matrix.IsHermitian.apply /-
 theorem IsHermitian.apply {A : Matrix n n α} (h : A.IsHermitian) (i j : n) : star (A j i) = A i j :=
   congr_fun (congr_fun h _) _
 #align matrix.is_hermitian.apply Matrix.IsHermitian.apply
+-/
 
+#print Matrix.IsHermitian.ext_iff /-
 theorem IsHermitian.ext_iff {A : Matrix n n α} : A.IsHermitian ↔ ∀ i j, star (A j i) = A i j :=
   ⟨IsHermitian.apply, IsHermitian.ext⟩
 #align matrix.is_hermitian.ext_iff Matrix.IsHermitian.ext_iff
+-/
 
 @[simp]
 theorem IsHermitian.map {A : Matrix n n α} (h : A.IsHermitian) (f : α → β)
@@ -74,18 +89,24 @@ theorem IsHermitian.map {A : Matrix n n α} (h : A.IsHermitian) (f : α → β)
   (conjTranspose_map f hf).symm.trans <| h.Eq.symm ▸ rfl
 #align matrix.is_hermitian.map Matrix.IsHermitian.map
 
+#print Matrix.IsHermitian.transpose /-
 theorem IsHermitian.transpose {A : Matrix n n α} (h : A.IsHermitian) : Aᵀ.IsHermitian := by
   rw [is_hermitian, conj_transpose, transpose_map]; congr ; exact h
 #align matrix.is_hermitian.transpose Matrix.IsHermitian.transpose
+-/
 
+#print Matrix.isHermitian_transpose_iff /-
 @[simp]
 theorem isHermitian_transpose_iff (A : Matrix n n α) : Aᵀ.IsHermitian ↔ A.IsHermitian :=
   ⟨by intro h; rw [← transpose_transpose A]; exact is_hermitian.transpose h, IsHermitian.transpose⟩
 #align matrix.is_hermitian_transpose_iff Matrix.isHermitian_transpose_iff
+-/
 
+#print Matrix.IsHermitian.conjTranspose /-
 theorem IsHermitian.conjTranspose {A : Matrix n n α} (h : A.IsHermitian) : Aᴴ.IsHermitian :=
   h.transpose.map _ fun _ => rfl
 #align matrix.is_hermitian.conj_transpose Matrix.IsHermitian.conjTranspose
+-/
 
 @[simp]
 theorem IsHermitian.submatrix {A : Matrix n n α} (h : A.IsHermitian) (f : m → n) :
@@ -105,10 +126,12 @@ section InvolutiveStar
 
 variable [InvolutiveStar α]
 
+#print Matrix.isHermitian_conjTranspose_iff /-
 @[simp]
 theorem isHermitian_conjTranspose_iff (A : Matrix n n α) : Aᴴ.IsHermitian ↔ A.IsHermitian :=
   IsSelfAdjoint.star_iff
 #align matrix.is_hermitian_conj_transpose_iff Matrix.isHermitian_conjTranspose_iff
+-/
 
 /-- A block matrix `A.from_blocks B C D` is hermitian,
     if `A` and `D` are hermitian and `Bᴴ = C`. -/
@@ -256,9 +279,11 @@ theorem isHermitian_inv [Fintype m] [DecidableEq m] (A : Matrix m m α) [Inverti
   ⟨fun h => by rw [← inv_inv_of_invertible A]; exact is_hermitian.inv h, IsHermitian.inv⟩
 #align matrix.is_hermitian_inv Matrix.isHermitian_inv
 
+#print Matrix.IsHermitian.adjugate /-
 theorem IsHermitian.adjugate [Fintype m] [DecidableEq m] {A : Matrix m m α} (hA : A.IsHermitian) :
     A.adjugate.IsHermitian := by simp [is_hermitian, adjugate_conj_transpose, hA.eq]
 #align matrix.is_hermitian.adjugate Matrix.IsHermitian.adjugate
+-/
 
 end CommRing
 
Diff
@@ -31,7 +31,7 @@ namespace Matrix
 
 variable {α β : Type _} {m n : Type _} {A : Matrix n n α}
 
-open Matrix
+open scoped Matrix
 
 -- mathport name: «expr⟪ , ⟫»
 local notation "⟪" x ", " y "⟫" => @inner α _ _ x y
Diff
@@ -56,11 +56,8 @@ protected theorem IsHermitian.isSelfAdjoint {A : Matrix n n α} (h : A.IsHermiti
 #align matrix.is_hermitian.is_self_adjoint Matrix.IsHermitian.isSelfAdjoint
 
 @[ext]
-theorem IsHermitian.ext {A : Matrix n n α} : (∀ i j, star (A j i) = A i j) → A.IsHermitian :=
-  by
-  intro h
-  ext (i j)
-  exact h i j
+theorem IsHermitian.ext {A : Matrix n n α} : (∀ i j, star (A j i) = A i j) → A.IsHermitian := by
+  intro h; ext (i j); exact h i j
 #align matrix.is_hermitian.ext Matrix.IsHermitian.ext
 
 theorem IsHermitian.apply {A : Matrix n n α} (h : A.IsHermitian) (i j : n) : star (A j i) = A i j :=
@@ -77,19 +74,13 @@ theorem IsHermitian.map {A : Matrix n n α} (h : A.IsHermitian) (f : α → β)
   (conjTranspose_map f hf).symm.trans <| h.Eq.symm ▸ rfl
 #align matrix.is_hermitian.map Matrix.IsHermitian.map
 
-theorem IsHermitian.transpose {A : Matrix n n α} (h : A.IsHermitian) : Aᵀ.IsHermitian :=
-  by
-  rw [is_hermitian, conj_transpose, transpose_map]
-  congr
-  exact h
+theorem IsHermitian.transpose {A : Matrix n n α} (h : A.IsHermitian) : Aᵀ.IsHermitian := by
+  rw [is_hermitian, conj_transpose, transpose_map]; congr ; exact h
 #align matrix.is_hermitian.transpose Matrix.IsHermitian.transpose
 
 @[simp]
 theorem isHermitian_transpose_iff (A : Matrix n n α) : Aᵀ.IsHermitian ↔ A.IsHermitian :=
-  ⟨by
-    intro h
-    rw [← transpose_transpose A]
-    exact is_hermitian.transpose h, IsHermitian.transpose⟩
+  ⟨by intro h; rw [← transpose_transpose A]; exact is_hermitian.transpose h, IsHermitian.transpose⟩
 #align matrix.is_hermitian_transpose_iff Matrix.isHermitian_transpose_iff
 
 theorem IsHermitian.conjTranspose {A : Matrix n n α} (h : A.IsHermitian) : Aᴴ.IsHermitian :=
@@ -262,9 +253,7 @@ theorem IsHermitian.inv [Fintype m] [DecidableEq m] {A : Matrix m m α} (hA : A.
 @[simp]
 theorem isHermitian_inv [Fintype m] [DecidableEq m] (A : Matrix m m α) [Invertible A] :
     A⁻¹.IsHermitian ↔ A.IsHermitian :=
-  ⟨fun h => by
-    rw [← inv_inv_of_invertible A]
-    exact is_hermitian.inv h, IsHermitian.inv⟩
+  ⟨fun h => by rw [← inv_inv_of_invertible A]; exact is_hermitian.inv h, IsHermitian.inv⟩
 #align matrix.is_hermitian_inv Matrix.isHermitian_inv
 
 theorem IsHermitian.adjugate [Fintype m] [DecidableEq m] {A : Matrix m m α} (hA : A.IsHermitian) :
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
 
 ! This file was ported from Lean 3 source module linear_algebra.matrix.hermitian
-! leanprover-community/mathlib commit 9abfa6f0727d5adc99067e325e15d1a9de17fd8e
+! leanprover-community/mathlib commit caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -281,7 +281,7 @@ variable [IsROrC α] [IsROrC β]
 
 /-- The diagonal elements of a complex hermitian matrix are real. -/
 theorem IsHermitian.coe_re_apply_self {A : Matrix n n α} (h : A.IsHermitian) (i : n) :
-    (re (A i i) : α) = A i i := by rw [← eq_conj_iff_re, ← star_def, ← conj_transpose_apply, h.eq]
+    (re (A i i) : α) = A i i := by rw [← conj_eq_iff_re, ← star_def, ← conj_transpose_apply, h.eq]
 #align matrix.is_hermitian.coe_re_apply_self Matrix.IsHermitian.coe_re_apply_self
 
 /-- The diagonal elements of a complex hermitian matrix are real. -/
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
 
 ! This file was ported from Lean 3 source module linear_algebra.matrix.hermitian
-! leanprover-community/mathlib commit 9f0d61b4475e3c3cba6636ab51cdb1f3949d2e1d
+! leanprover-community/mathlib commit 9abfa6f0727d5adc99067e325e15d1a9de17fd8e
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,8 @@ import Mathbin.Analysis.InnerProductSpace.PiL2
 
 This file defines hermitian matrices and some basic results about them.
 
+See also `is_self_adjoint`, which generalizes this definition to other star rings.
+
 ## Main definition
 
  * `matrix.is_hermitian` : a matrix `A : matrix n n α` is hermitian if `Aᴴ = A`.
@@ -34,9 +36,9 @@ open Matrix
 -- mathport name: «expr⟪ , ⟫»
 local notation "⟪" x ", " y "⟫" => @inner α _ _ x y
 
-section NonUnitalSemiring
+section Star
 
-variable [NonUnitalSemiring α] [StarRing α] [NonUnitalSemiring β] [StarRing β]
+variable [Star α] [Star β]
 
 /-- A matrix is hermitian if it is equal to its conjugate transpose. On the reals, this definition
 captures symmetric matrices. -/
@@ -48,6 +50,11 @@ theorem IsHermitian.eq {A : Matrix n n α} (h : A.IsHermitian) : Aᴴ = A :=
   h
 #align matrix.is_hermitian.eq Matrix.IsHermitian.eq
 
+protected theorem IsHermitian.isSelfAdjoint {A : Matrix n n α} (h : A.IsHermitian) :
+    IsSelfAdjoint A :=
+  h
+#align matrix.is_hermitian.is_self_adjoint Matrix.IsHermitian.isSelfAdjoint
+
 @[ext]
 theorem IsHermitian.ext {A : Matrix n n α} : (∀ i j, star (A j i) = A i j) → A.IsHermitian :=
   by
@@ -57,48 +64,13 @@ theorem IsHermitian.ext {A : Matrix n n α} : (∀ i j, star (A j i) = A i j) 
 #align matrix.is_hermitian.ext Matrix.IsHermitian.ext
 
 theorem IsHermitian.apply {A : Matrix n n α} (h : A.IsHermitian) (i j : n) : star (A j i) = A i j :=
-  by
-  unfold is_hermitian at h
-  rw [← h, conj_transpose_apply, star_star, h]
+  congr_fun (congr_fun h _) _
 #align matrix.is_hermitian.apply Matrix.IsHermitian.apply
 
 theorem IsHermitian.ext_iff {A : Matrix n n α} : A.IsHermitian ↔ ∀ i j, star (A j i) = A i j :=
   ⟨IsHermitian.apply, IsHermitian.ext⟩
 #align matrix.is_hermitian.ext_iff Matrix.IsHermitian.ext_iff
 
-theorem isHermitian_mul_conjTranspose_self [Fintype n] (A : Matrix n n α) : (A ⬝ Aᴴ).IsHermitian :=
-  by rw [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose]
-#align matrix.is_hermitian_mul_conj_transpose_self Matrix.isHermitian_mul_conjTranspose_self
-
-theorem isHermitian_transpose_mul_self [Fintype n] (A : Matrix n n α) : (Aᴴ ⬝ A).IsHermitian := by
-  rw [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose]
-#align matrix.is_hermitian_transpose_mul_self Matrix.isHermitian_transpose_mul_self
-
-theorem isHermitian_conjTranspose_mul_mul [Fintype m] {A : Matrix m m α} (B : Matrix m n α)
-    (hA : A.IsHermitian) : (Bᴴ ⬝ A ⬝ B).IsHermitian := by
-  simp only [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose, hA.eq,
-    Matrix.mul_assoc]
-#align matrix.is_hermitian_conj_transpose_mul_mul Matrix.isHermitian_conjTranspose_mul_mul
-
-theorem isHermitian_mul_mul_conjTranspose [Fintype m] {A : Matrix m m α} (B : Matrix n m α)
-    (hA : A.IsHermitian) : (B ⬝ A ⬝ Bᴴ).IsHermitian := by
-  simp only [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose, hA.eq,
-    Matrix.mul_assoc]
-#align matrix.is_hermitian_mul_mul_conj_transpose Matrix.isHermitian_mul_mul_conjTranspose
-
-theorem isHermitian_add_transpose_self (A : Matrix n n α) : (A + Aᴴ).IsHermitian := by
-  simp [is_hermitian, add_comm]
-#align matrix.is_hermitian_add_transpose_self Matrix.isHermitian_add_transpose_self
-
-theorem isHermitian_transpose_add_self (A : Matrix n n α) : (Aᴴ + A).IsHermitian := by
-  simp [is_hermitian, add_comm]
-#align matrix.is_hermitian_transpose_add_self Matrix.isHermitian_transpose_add_self
-
-@[simp]
-theorem isHermitian_zero : (0 : Matrix n n α).IsHermitian :=
-  conjTranspose_zero
-#align matrix.is_hermitian_zero Matrix.isHermitian_zero
-
 @[simp]
 theorem IsHermitian.map {A : Matrix n n α} (h : A.IsHermitian) (f : α → β)
     (hf : Function.Semiconj f star star) : (A.map f).IsHermitian :=
@@ -124,20 +96,6 @@ theorem IsHermitian.conjTranspose {A : Matrix n n α} (h : A.IsHermitian) : Aᴴ
   h.transpose.map _ fun _ => rfl
 #align matrix.is_hermitian.conj_transpose Matrix.IsHermitian.conjTranspose
 
-@[simp]
-theorem isHermitian_conjTranspose_iff (A : Matrix n n α) : Aᴴ.IsHermitian ↔ A.IsHermitian :=
-  ⟨by
-    intro h
-    rw [← conj_transpose_conj_transpose A]
-    exact is_hermitian.conj_transpose h, IsHermitian.conjTranspose⟩
-#align matrix.is_hermitian_conj_transpose_iff Matrix.isHermitian_conjTranspose_iff
-
-@[simp]
-theorem IsHermitian.add {A B : Matrix n n α} (hA : A.IsHermitian) (hB : B.IsHermitian) :
-    (A + B).IsHermitian :=
-  (conjTranspose_add _ _).trans (hA.symm ▸ hB.symm ▸ rfl)
-#align matrix.is_hermitian.add Matrix.IsHermitian.add
-
 @[simp]
 theorem IsHermitian.submatrix {A : Matrix n n α} (h : A.IsHermitian) (f : m → n) :
     (A.submatrix f f).IsHermitian :=
@@ -150,11 +108,16 @@ theorem isHermitian_submatrix_equiv {A : Matrix n n α} (e : m ≃ n) :
   ⟨fun h => by simpa using h.submatrix e.symm, fun h => h.submatrix _⟩
 #align matrix.is_hermitian_submatrix_equiv Matrix.isHermitian_submatrix_equiv
 
-/-- The real diagonal matrix `diagonal v` is hermitian. -/
+end Star
+
+section InvolutiveStar
+
+variable [InvolutiveStar α]
+
 @[simp]
-theorem isHermitian_diagonal [DecidableEq n] (v : n → ℝ) : (diagonal v).IsHermitian :=
-  diagonal_conjTranspose _
-#align matrix.is_hermitian_diagonal Matrix.isHermitian_diagonal
+theorem isHermitian_conjTranspose_iff (A : Matrix n n α) : Aᴴ.IsHermitian ↔ A.IsHermitian :=
+  IsSelfAdjoint.star_iff
+#align matrix.is_hermitian_conj_transpose_iff Matrix.isHermitian_conjTranspose_iff
 
 /-- A block matrix `A.from_blocks B C D` is hermitian,
     if `A` and `D` are hermitian and `Bᴴ = C`. -/
@@ -162,9 +125,7 @@ theorem IsHermitian.fromBlocks {A : Matrix m m α} {B : Matrix m n α} {C : Matr
     {D : Matrix n n α} (hA : A.IsHermitian) (hBC : Bᴴ = C) (hD : D.IsHermitian) :
     (A.fromBlocks B C D).IsHermitian :=
   by
-  have hCB : Cᴴ = B := by
-    rw [← hBC]
-    simp
+  have hCB : Cᴴ = B := by rw [← hBC, conj_transpose_conj_transpose]
   unfold Matrix.IsHermitian
   rw [from_blocks_conj_transpose]
   congr <;> assumption
@@ -180,35 +141,115 @@ theorem isHermitian_fromBlocks_iff {A : Matrix m m α} {B : Matrix m n α} {C :
     fun ⟨hA, hBC, hCB, hD⟩ => IsHermitian.fromBlocks hA hBC hD⟩
 #align matrix.is_hermitian_from_blocks_iff Matrix.isHermitian_fromBlocks_iff
 
-end NonUnitalSemiring
+end InvolutiveStar
 
-section Semiring
+section AddMonoid
 
-variable [Semiring α] [StarRing α] [Semiring β] [StarRing β]
+variable [AddMonoid α] [StarAddMonoid α] [AddMonoid β] [StarAddMonoid β]
 
+/-- A diagonal matrix is hermitian if the entries are self-adjoint -/
+theorem isHermitian_diagonal_of_self_adjoint [DecidableEq n] (v : n → α) (h : IsSelfAdjoint v) :
+    (diagonal v).IsHermitian :=
+  (-- TODO: add a `pi.has_trivial_star` instance and remove the `funext`
+        diagonal_conjTranspose
+        v).trans <|
+    congr_arg _ h
+#align matrix.is_hermitian_diagonal_of_self_adjoint Matrix.isHermitian_diagonal_of_self_adjoint
+
+/-- A diagonal matrix is hermitian if the entries have the trivial `star` operation
+(such as on the reals). -/
 @[simp]
-theorem isHermitian_one [DecidableEq n] : (1 : Matrix n n α).IsHermitian :=
-  conjTranspose_one
-#align matrix.is_hermitian_one Matrix.isHermitian_one
+theorem isHermitian_diagonal [TrivialStar α] [DecidableEq n] (v : n → α) :
+    (diagonal v).IsHermitian :=
+  isHermitian_diagonal_of_self_adjoint _ (IsSelfAdjoint.all _)
+#align matrix.is_hermitian_diagonal Matrix.isHermitian_diagonal
 
-end Semiring
+@[simp]
+theorem isHermitian_zero : (0 : Matrix n n α).IsHermitian :=
+  isSelfAdjoint_zero _
+#align matrix.is_hermitian_zero Matrix.isHermitian_zero
+
+@[simp]
+theorem IsHermitian.add {A B : Matrix n n α} (hA : A.IsHermitian) (hB : B.IsHermitian) :
+    (A + B).IsHermitian :=
+  IsSelfAdjoint.add hA hB
+#align matrix.is_hermitian.add Matrix.IsHermitian.add
 
-section Ring
+end AddMonoid
 
-variable [Ring α] [StarRing α] [Ring β] [StarRing β]
+section AddCommMonoid
+
+variable [AddCommMonoid α] [StarAddMonoid α]
+
+theorem isHermitian_add_transpose_self (A : Matrix n n α) : (A + Aᴴ).IsHermitian :=
+  isSelfAdjoint_add_star_self A
+#align matrix.is_hermitian_add_transpose_self Matrix.isHermitian_add_transpose_self
+
+theorem isHermitian_transpose_add_self (A : Matrix n n α) : (Aᴴ + A).IsHermitian :=
+  isSelfAdjoint_star_add_self A
+#align matrix.is_hermitian_transpose_add_self Matrix.isHermitian_transpose_add_self
+
+end AddCommMonoid
+
+section AddGroup
+
+variable [AddGroup α] [StarAddMonoid α]
 
 @[simp]
 theorem IsHermitian.neg {A : Matrix n n α} (h : A.IsHermitian) : (-A).IsHermitian :=
-  (conjTranspose_neg _).trans (congr_arg _ h)
+  IsSelfAdjoint.neg h
 #align matrix.is_hermitian.neg Matrix.IsHermitian.neg
 
 @[simp]
 theorem IsHermitian.sub {A B : Matrix n n α} (hA : A.IsHermitian) (hB : B.IsHermitian) :
     (A - B).IsHermitian :=
-  (conjTranspose_sub _ _).trans (hA.symm ▸ hB.symm ▸ rfl)
+  IsSelfAdjoint.sub hA hB
 #align matrix.is_hermitian.sub Matrix.IsHermitian.sub
 
-end Ring
+end AddGroup
+
+section NonUnitalSemiring
+
+variable [NonUnitalSemiring α] [StarRing α] [NonUnitalSemiring β] [StarRing β]
+
+/-- Note this is more general than `is_self_adjoint.mul_star_self` as `B` can be rectangular. -/
+theorem isHermitian_mul_conjTranspose_self [Fintype n] (A : Matrix m n α) : (A ⬝ Aᴴ).IsHermitian :=
+  by rw [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose]
+#align matrix.is_hermitian_mul_conj_transpose_self Matrix.isHermitian_mul_conjTranspose_self
+
+/-- Note this is more general than `is_self_adjoint.star_mul_self` as `B` can be rectangular. -/
+theorem isHermitian_transpose_mul_self [Fintype m] (A : Matrix m n α) : (Aᴴ ⬝ A).IsHermitian := by
+  rw [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose]
+#align matrix.is_hermitian_transpose_mul_self Matrix.isHermitian_transpose_mul_self
+
+/-- Note this is more general than `is_self_adjoint.conjugate'` as `B` can be rectangular. -/
+theorem isHermitian_conjTranspose_mul_mul [Fintype m] {A : Matrix m m α} (B : Matrix m n α)
+    (hA : A.IsHermitian) : (Bᴴ ⬝ A ⬝ B).IsHermitian := by
+  simp only [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose, hA.eq,
+    Matrix.mul_assoc]
+#align matrix.is_hermitian_conj_transpose_mul_mul Matrix.isHermitian_conjTranspose_mul_mul
+
+/-- Note this is more general than `is_self_adjoint.conjugate` as `B` can be rectangular. -/
+theorem isHermitian_mul_mul_conjTranspose [Fintype m] {A : Matrix m m α} (B : Matrix n m α)
+    (hA : A.IsHermitian) : (B ⬝ A ⬝ Bᴴ).IsHermitian := by
+  simp only [is_hermitian, conj_transpose_mul, conj_transpose_conj_transpose, hA.eq,
+    Matrix.mul_assoc]
+#align matrix.is_hermitian_mul_mul_conj_transpose Matrix.isHermitian_mul_mul_conjTranspose
+
+end NonUnitalSemiring
+
+section Semiring
+
+variable [Semiring α] [StarRing α] [Semiring β] [StarRing β]
+
+/-- Note this is more general for matrices than `is_self_adjoint_one` as it does not
+require `fintype n`, which is necessary for `monoid (matrix n n R)`. -/
+@[simp]
+theorem isHermitian_one [DecidableEq n] : (1 : Matrix n n α).IsHermitian :=
+  conjTranspose_one
+#align matrix.is_hermitian_one Matrix.isHermitian_one
+
+end Semiring
 
 section CommRing
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
 
 ! This file was ported from Lean 3 source module linear_algebra.matrix.hermitian
-! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a
+! leanprover-community/mathlib commit 9f0d61b4475e3c3cba6636ab51cdb1f3949d2e1d
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -32,7 +32,7 @@ variable {α β : Type _} {m n : Type _} {A : Matrix n n α}
 open Matrix
 
 -- mathport name: «expr⟪ , ⟫»
-local notation "⟪" x ", " y "⟫" => @inner α (PiLp 2 fun _ : n => α) _ x y
+local notation "⟪" x ", " y "⟫" => @inner α _ _ x y
 
 section NonUnitalSemiring
 
@@ -251,14 +251,10 @@ theorem IsHermitian.coe_re_diag {A : Matrix n n α} (h : A.IsHermitian) :
 
 /-- A matrix is hermitian iff the corresponding linear map is self adjoint. -/
 theorem isHermitian_iff_isSymmetric [Fintype n] [DecidableEq n] {A : Matrix n n α} :
-    IsHermitian A ↔
-      LinearMap.IsSymmetric
-        ((PiLp.linearEquiv 2 α fun _ : n => α).symm.conj A.toLin' : Module.End α (PiLp 2 _)) :=
+    IsHermitian A ↔ A.toEuclideanLin.IsSymmetric :=
   by
   rw [LinearMap.IsSymmetric, (PiLp.equiv 2 fun _ : n => α).symm.Surjective.Forall₂]
-  simp only [LinearEquiv.conj_apply, LinearMap.comp_apply, LinearEquiv.coe_coe,
-    PiLp.linearEquiv_apply, PiLp.linearEquiv_symm_apply, LinearEquiv.symm_symm]
-  simp_rw [EuclideanSpace.inner_eq_star_dotProduct, Equiv.apply_symm_apply, to_lin'_apply,
+  simp only [to_euclidean_lin_pi_Lp_equiv_symm, EuclideanSpace.inner_piLp_equiv_symm, to_lin'_apply,
     star_mul_vec, dot_product_mul_vec]
   constructor
   · rintro (h : Aᴴ = A) x y

Changes in mathlib4

mathlib3
mathlib4
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
@@ -31,7 +31,6 @@ variable {α β : Type*} {m n : Type*} {A : Matrix n n α}
 
 open scoped Matrix
 
--- mathport name: «expr⟪ , ⟫»
 local notation "⟪" x ", " y "⟫" => @inner α _ _ x y
 
 section Star
feat: Decidable instances for matrix symmetry (#11878)

These are stated in the most general form possible, where they simply unfold the definition. This allows a few proofs to be golfed.

Diff
@@ -43,6 +43,9 @@ captures symmetric matrices. -/
 def IsHermitian (A : Matrix n n α) : Prop := Aᴴ = A
 #align matrix.is_hermitian Matrix.IsHermitian
 
+instance (A : Matrix n n α) [Decidable (Aᴴ = A)] : Decidable (IsHermitian A) :=
+  inferInstanceAs <| Decidable (_ = _)
+
 theorem IsHermitian.eq {A : Matrix n n α} (h : A.IsHermitian) : Aᴴ = A := h
 #align matrix.is_hermitian.eq Matrix.IsHermitian.eq
 
chore: Rename IsROrC to RCLike (#10819)

IsROrC contains data, which goes against the expectation that classes prefixed with Is are prop-valued. People have been complaining about this on and off, so this PR renames IsROrC to RCLike.

Diff
@@ -269,11 +269,11 @@ theorem IsHermitian.zpow [Fintype m] [DecidableEq m] {A : Matrix m m α} (h : A.
 
 end CommRing
 
-section IsROrC
+section RCLike
 
-open IsROrC
+open RCLike
 
-variable [IsROrC α] [IsROrC β]
+variable [RCLike α] [RCLike β]
 
 /-- The diagonal elements of a complex hermitian matrix are real. -/
 theorem IsHermitian.coe_re_apply_self {A : Matrix n n α} (h : A.IsHermitian) (i : n) :
@@ -301,6 +301,6 @@ theorem isHermitian_iff_isSymmetric [Fintype n] [DecidableEq n] {A : Matrix n n
       single_vecMul, star_one, one_mul] using h (Pi.single i 1) (Pi.single j 1)
 #align matrix.is_hermitian_iff_is_symmetric Matrix.isHermitian_iff_isSymmetric
 
-end IsROrC
+end RCLike
 
 end Matrix
chore: tidy various files (#9851)
Diff
@@ -139,7 +139,7 @@ theorem isHermitian_diagonal_of_self_adjoint [DecidableEq n] (v : n → α) (h :
 #align matrix.is_hermitian_diagonal_of_self_adjoint Matrix.isHermitian_diagonal_of_self_adjoint
 
 /-- A diagonal matrix is hermitian if each diagonal entry is self-adjoint -/
-lemma isHermitian_diagonal_iff [DecidableEq n]{d : n → α} :
+lemma isHermitian_diagonal_iff [DecidableEq n] {d : n → α} :
     IsHermitian (diagonal d) ↔ (∀ i : n, IsSelfAdjoint (d i)) := by
   simp [isSelfAdjoint_iff, IsHermitian, conjTranspose, diagonal_transpose, diagonal_map]
 
feat(LinearAlgebra/Matrix/PosDef): unique positive semidef square root (#8809)

This PR adds two main results about positive semidefinite matrices:

  • a positive semidefinite matrix has a unique positive semidefinite square root;
  • if A is positive semidefinite then x* A x = 0 implies A x = 0 (proof extracted from #8594).

Co-authored-by: Adrian Wüthrich (@awueth)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -131,13 +131,18 @@ section AddMonoid
 
 variable [AddMonoid α] [StarAddMonoid α] [AddMonoid β] [StarAddMonoid β]
 
-/-- A diagonal matrix is hermitian if the entries are self-adjoint -/
+/-- A diagonal matrix is hermitian if the entries are self-adjoint (as a vector) -/
 theorem isHermitian_diagonal_of_self_adjoint [DecidableEq n] (v : n → α) (h : IsSelfAdjoint v) :
     (diagonal v).IsHermitian :=
   (-- TODO: add a `pi.has_trivial_star` instance and remove the `funext`
         diagonal_conjTranspose v).trans <| congr_arg _ h
 #align matrix.is_hermitian_diagonal_of_self_adjoint Matrix.isHermitian_diagonal_of_self_adjoint
 
+/-- A diagonal matrix is hermitian if each diagonal entry is self-adjoint -/
+lemma isHermitian_diagonal_iff [DecidableEq n]{d : n → α} :
+    IsHermitian (diagonal d) ↔ (∀ i : n, IsSelfAdjoint (d i)) := by
+  simp [isSelfAdjoint_iff, IsHermitian, conjTranspose, diagonal_transpose, diagonal_map]
+
 /-- A diagonal matrix is hermitian if the entries have the trivial `star` operation
 (such as on the reals). -/
 @[simp]
feat(LinearAlgebra/Matrix): powers preserve IsSymm and IsHermitian (#9036)
Diff
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
 -/
 import Mathlib.Analysis.InnerProductSpace.PiL2
+import Mathlib.LinearAlgebra.Matrix.ZPow
 
 #align_import linear_algebra.matrix.hermitian from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c"
 
@@ -215,6 +216,10 @@ theorem isHermitian_mul_mul_conjTranspose [Fintype m] {A : Matrix m m α} (B : M
   simp only [IsHermitian, conjTranspose_mul, conjTranspose_conjTranspose, hA.eq, Matrix.mul_assoc]
 #align matrix.is_hermitian_mul_mul_conj_transpose Matrix.isHermitian_mul_mul_conjTranspose
 
+lemma commute_iff [Fintype n] {A B : Matrix n n α}
+    (hA : A.IsHermitian) (hB : B.IsHermitian) : Commute A B ↔ (A * B).IsHermitian :=
+  hA.isSelfAdjoint.commute_iff hB.isSelfAdjoint
+
 end NonUnitalSemiring
 
 section Semiring
@@ -228,6 +233,9 @@ theorem isHermitian_one [DecidableEq n] : (1 : Matrix n n α).IsHermitian :=
   conjTranspose_one
 #align matrix.is_hermitian_one Matrix.isHermitian_one
 
+theorem IsHermitian.pow [Fintype n] [DecidableEq n] {A : Matrix n n α} (h : A.IsHermitian) (k : ℕ) :
+    (A ^ k).IsHermitian := IsSelfAdjoint.pow h _
+
 end Semiring
 
 section CommRing
@@ -248,6 +256,12 @@ theorem IsHermitian.adjugate [Fintype m] [DecidableEq m] {A : Matrix m m α} (hA
     A.adjugate.IsHermitian := by simp [IsHermitian, adjugate_conjTranspose, hA.eq]
 #align matrix.is_hermitian.adjugate Matrix.IsHermitian.adjugate
 
+/-- Note that `IsSelfAdjoint.zpow` does not apply to matrices as they are not a division ring. -/
+theorem IsHermitian.zpow [Fintype m] [DecidableEq m] {A : Matrix m m α} (h : A.IsHermitian)
+    (k : ℤ) :
+    (A ^ k).IsHermitian := by
+  rw [IsHermitian, conjTranspose_zpow, h]
+
 end CommRing
 
 section IsROrC
refactor: remove PiLp.equiv (#6501)

This removes the (PiLp.equiv 2 fun i => α i) abbreviation, replacing it with its implementation (WithLp.equiv 2 (∀ i, α i)). The same thing is done for PiLp.linearEquiv.

Diff
@@ -270,7 +270,7 @@ theorem IsHermitian.coe_re_diag {A : Matrix n n α} (h : A.IsHermitian) :
 /-- A matrix is hermitian iff the corresponding linear map is self adjoint. -/
 theorem isHermitian_iff_isSymmetric [Fintype n] [DecidableEq n] {A : Matrix n n α} :
     IsHermitian A ↔ A.toEuclideanLin.IsSymmetric := by
-  rw [LinearMap.IsSymmetric, (PiLp.equiv 2 fun _ : n => α).symm.surjective.forall₂]
+  rw [LinearMap.IsSymmetric, (WithLp.equiv 2 (n → α)).symm.surjective.forall₂]
   simp only [toEuclideanLin_piLp_equiv_symm, EuclideanSpace.inner_piLp_equiv_symm, toLin'_apply,
     star_mulVec, dotProduct_mulVec]
   constructor
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
@@ -194,24 +194,24 @@ section NonUnitalSemiring
 variable [NonUnitalSemiring α] [StarRing α] [NonUnitalSemiring β] [StarRing β]
 
 /-- Note this is more general than `IsSelfAdjoint.mul_star_self` as `B` can be rectangular. -/
-theorem isHermitian_mul_conjTranspose_self [Fintype n] (A : Matrix m n α) : (A ⬝ Aᴴ).IsHermitian :=
+theorem isHermitian_mul_conjTranspose_self [Fintype n] (A : Matrix m n α) : (A * Aᴴ).IsHermitian :=
   by rw [IsHermitian, conjTranspose_mul, conjTranspose_conjTranspose]
 #align matrix.is_hermitian_mul_conj_transpose_self Matrix.isHermitian_mul_conjTranspose_self
 
 /-- Note this is more general than `IsSelfAdjoint.star_mul_self` as `B` can be rectangular. -/
-theorem isHermitian_transpose_mul_self [Fintype m] (A : Matrix m n α) : (Aᴴ ⬝ A).IsHermitian := by
+theorem isHermitian_transpose_mul_self [Fintype m] (A : Matrix m n α) : (Aᴴ * A).IsHermitian := by
   rw [IsHermitian, conjTranspose_mul, conjTranspose_conjTranspose]
 #align matrix.is_hermitian_transpose_mul_self Matrix.isHermitian_transpose_mul_self
 
 /-- Note this is more general than `IsSelfAdjoint.conjugate'` as `B` can be rectangular. -/
 theorem isHermitian_conjTranspose_mul_mul [Fintype m] {A : Matrix m m α} (B : Matrix m n α)
-    (hA : A.IsHermitian) : (Bᴴ ⬝ A ⬝ B).IsHermitian := by
+    (hA : A.IsHermitian) : (Bᴴ * A * B).IsHermitian := by
   simp only [IsHermitian, conjTranspose_mul, conjTranspose_conjTranspose, hA.eq, Matrix.mul_assoc]
 #align matrix.is_hermitian_conj_transpose_mul_mul Matrix.isHermitian_conjTranspose_mul_mul
 
 /-- Note this is more general than `IsSelfAdjoint.conjugate` as `B` can be rectangular. -/
 theorem isHermitian_mul_mul_conjTranspose [Fintype m] {A : Matrix m m α} (B : Matrix n m α)
-    (hA : A.IsHermitian) : (B ⬝ A ⬝ Bᴴ).IsHermitian := by
+    (hA : A.IsHermitian) : (B * A * Bᴴ).IsHermitian := by
   simp only [IsHermitian, conjTranspose_mul, conjTranspose_conjTranspose, hA.eq, Matrix.mul_assoc]
 #align matrix.is_hermitian_mul_mul_conj_transpose Matrix.isHermitian_mul_mul_conjTranspose
 
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
@@ -26,7 +26,7 @@ self-adjoint matrix, hermitian matrix
 
 namespace Matrix
 
-variable {α β : Type _} {m n : Type _} {A : Matrix n n α}
+variable {α β : Type*} {m n : Type*} {A : Matrix n n α}
 
 open scoped 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) 2022 Alexander Bentkamp. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
-
-! This file was ported from Lean 3 source module linear_algebra.matrix.hermitian
-! leanprover-community/mathlib commit caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Analysis.InnerProductSpace.PiL2
 
+#align_import linear_algebra.matrix.hermitian from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c"
+
 /-! # Hermitian matrices
 
 This file defines hermitian matrices and some basic results about them.
chore: remove superfluous parentheses in calls to ext (#5258)

Co-authored-by: Xavier Roblot <46200072+xroblot@users.noreply.github.com> Co-authored-by: Joël Riou <joel.riou@universite-paris-saclay.fr> Co-authored-by: Riccardo Brasca <riccardo.brasca@gmail.com> Co-authored-by: Yury G. Kudryashov <urkud@urkud.name> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com> Co-authored-by: Pol'tta / Miyahara Kō <pol_tta@outlook.jp> Co-authored-by: Jason Yuen <jason_yuen2007@hotmail.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com> Co-authored-by: Jireh Loreaux <loreaujy@gmail.com> Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: Heather Macbeth <25316162+hrmacbeth@users.noreply.github.com> Co-authored-by: Jujian Zhang <jujian.zhang1998@outlook.com> Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>

Diff
@@ -54,7 +54,7 @@ protected theorem IsHermitian.isSelfAdjoint {A : Matrix n n α} (h : A.IsHermiti
 
 -- @[ext] -- Porting note: incorrect ext, not a structure or a lemma proving x = y
 theorem IsHermitian.ext {A : Matrix n n α} : (∀ i j, star (A j i) = A i j) → A.IsHermitian := by
-  intro h; ext (i j); exact h i j
+  intro h; ext i j; exact h i j
 #align matrix.is_hermitian.ext Matrix.IsHermitian.ext
 
 theorem IsHermitian.apply {A : Matrix n n α} (h : A.IsHermitian) (i j : n) : star (A j i) = A i j :=
@@ -280,7 +280,7 @@ theorem isHermitian_iff_isSymmetric [Fintype n] [DecidableEq n] {A : Matrix n n
   · rintro (h : Aᴴ = A) x y
     rw [h]
   · intro h
-    ext (i j)
+    ext i j
     simpa only [(Pi.single_star i 1).symm, ← star_mulVec, mul_one, dotProduct_single,
       single_vecMul, star_one, one_mul] using h (Pi.single i 1) (Pi.single j 1)
 #align matrix.is_hermitian_iff_is_symmetric Matrix.isHermitian_iff_isSymmetric
feat: port LinearAlgebra.Matrix.Hermitian (#4467)

Dependencies 12 + 909

910 files ported (98.7%)
403648 lines ported (98.6%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file