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

Proof steps:
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 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
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: 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
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: 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)
⊢ 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: 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)
this : E * E = diagonal (RCLike.ofReal ∘ ⋯.eigenvalues)
⊢ C * (E * (star C * C) * E) * star C = A
state_after: no goals
tactic: simpa [C, this] using hA.1.spectral_theorem.symm