Theorem: Matrix.PosSemidef.sq_sqrt
File: Mathlib/LinearAlgebra/Matrix/PosDef.lean

tactic: let C : Matrix n n 𝕜 := hA.1.eigenvectorUnitary
state_before: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
⊢ hA.sqrt ^ 2 = A
state_after: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
⊢ hA.sqrt ^ 2 = A

tactic: let E := diagonal ((↑) ∘ Real.sqrt ∘ hA.1.eigenvalues : n → 𝕜)
state_before: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
⊢ hA.sqrt ^ 2 = A
state_after: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
⊢ hA.sqrt ^ 2 = A

tactic: suffices C * (E * (star C * C) * E) * star C = A by
  rw [Matrix.PosSemidef.sqrt, pow_two]
  simpa only [← mul_assoc] using this
state_before: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
⊢ hA.sqrt ^ 2 = A
state_after: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
⊢ C * (E * (star C * C) * E) * star C = A

tactic: have : E * E = diagonal ((↑) ∘ hA.1.eigenvalues) := by
  rw [diagonal_mul_diagonal]
  congr! with v
  simp [← pow_two, ← RCLike.ofReal_pow, Real.sq_sqrt (hA.eigenvalues_nonneg v)]
state_before: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
⊢ C * (E * (star C * C) * E) * star C = A
state_after: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
this : E * E = diagonal (RCLike.ofReal ∘ ⋯.eigenvalues)
⊢ C * (E * (star C * C) * E) * star C = A

tactic: simpa [C, this] using hA.1.spectral_theorem.symm
state_before: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
this : E * E = diagonal (RCLike.ofReal ∘ ⋯.eigenvalues)
⊢ C * (E * (star C * C) * E) * star C = A
state_after: no goals

tactic: rw [Matrix.PosSemidef.sqrt, pow_two]
state_before: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
this : C * (E * (star C * C) * E) * star C = A
⊢ hA.sqrt ^ 2 = A
state_after: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
this : C * (E * (star C * C) * E) * star C = A
⊢ ↑⋯.eigenvectorUnitary * diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) * star ↑⋯.eigenvectorUnitary *
      (↑⋯.eigenvectorUnitary * diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) * star ↑⋯.eigenvectorUnitary) =
    A

tactic: simpa only [← mul_assoc] using this
state_before: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
this : C * (E * (star C * C) * E) * star C = A
⊢ ↑⋯.eigenvectorUnitary * diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) * star ↑⋯.eigenvectorUnitary *
      (↑⋯.eigenvectorUnitary * diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) * star ↑⋯.eigenvectorUnitary) =
    A
state_after: no goals

tactic: rw [diagonal_mul_diagonal]
state_before: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
⊢ E * E = diagonal (RCLike.ofReal ∘ ⋯.eigenvalues)
state_after: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
⊢ (diagonal fun i => (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) i * (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) i) =
    diagonal (RCLike.ofReal ∘ ⋯.eigenvalues)

tactic: congr! with v
state_before: m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
⊢ (diagonal fun i => (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) i * (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) i) =
    diagonal (RCLike.ofReal ∘ ⋯.eigenvalues)
state_after: case h.e'_5.h
m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
v : n
⊢ (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) v * (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) v =
    (RCLike.ofReal ∘ ⋯.eigenvalues) v

tactic: simp [← pow_two, ← RCLike.ofReal_pow, Real.sq_sqrt (hA.eigenvalues_nonneg v)]
state_before: case h.e'_5.h
m : Type u_1
n : Type u_2
R : Type u_3
𝕜 : Type u_4
inst✝⁷ : Fintype m
inst✝⁶ : Fintype n
inst✝⁵ : CommRing R
inst✝⁴ : PartialOrder R
inst✝³ : StarRing R
inst✝² : StarOrderedRing R
inst✝¹ : RCLike 𝕜
inst✝ : DecidableEq n
A : Matrix n n 𝕜
hA : A.PosSemidef
C : Matrix n n 𝕜 := ↑⋯.eigenvectorUnitary
E : Matrix n n 𝕜 := diagonal (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues)
v : n
⊢ (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) v * (RCLike.ofReal ∘ Real.sqrt ∘ ⋯.eigenvalues) v =
    (RCLike.ofReal ∘ ⋯.eigenvalues) v
state_after: no goals