l3lab/ntp-mathlib huggingface dataset:
/-- *Diagonalization theorem*, *spectral theorem*; version 1: A self-adjoint operator `T` on a
finite-dimensional inner product space `E` acts diagonally on the decomposition of `E` into the
direct sum of the eigenspaces of `T`. -/
theorem diagonalization_apply_self_apply (v : E) (μ : Eigenvalues T) :
    hT.diagonalization (T v) μ = (μ : 𝕜) • hT.diagonalization v μ := by
  suffices
    ∀ w : PiLp 2 fun μ : Eigenvalues T => eigenspace T μ,
      T (hT.diagonalization.symm w) = hT.diagonalization.symm fun μ => (μ : 𝕜) • w μ by
    simpa only [LinearIsometryEquiv.symm_apply_apply, LinearIsometryEquiv.apply_symm_apply] using
      congr_arg (fun w => hT.diagonalization w μ) (this (hT.diagonalization v))
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
v : E
μ : Eigenvalues T
⊢ ∀ (w : PiLp 2 fun μ => ↥(eigenspace T (↑T μ))),
    T ((LinearIsometryEquiv.symm (diagonalization hT)) w) =
      (LinearIsometryEquiv.symm (diagonalization hT)) fun μ => ↑T μ • w μ

Next tactic:
intro w
/-- *Diagonalization theorem*, *spectral theorem*; version 1: A self-adjoint operator `T` on a
finite-dimensional inner product space `E` acts diagonally on the decomposition of `E` into the
direct sum of the eigenspaces of `T`. -/
theorem diagonalization_apply_self_apply (v : E) (μ : Eigenvalues T) :
    hT.diagonalization (T v) μ = (μ : 𝕜) • hT.diagonalization v μ := by
  suffices
    ∀ w : PiLp 2 fun μ : Eigenvalues T => eigenspace T μ,
      T (hT.diagonalization.symm w) = hT.diagonalization.symm fun μ => (μ : 𝕜) • w μ by
    simpa only [LinearIsometryEquiv.symm_apply_apply, LinearIsometryEquiv.apply_symm_apply] using
      congr_arg (fun w => hT.diagonalization w μ) (this (hT.diagonalization v))
  intro w
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
v : E
μ : Eigenvalues T
w : PiLp 2 fun μ => ↥(eigenspace T (↑T μ))
⊢ T ((LinearIsometryEquiv.symm (diagonalization hT)) w) =
    (LinearIsometryEquiv.symm (diagonalization hT)) fun μ => ↑T μ • w μ

Next tactic:
have hwT : ∀ μ, T (w μ) = (μ : 𝕜) • w μ := fun μ => mem_eigenspace_iff.1 (w μ).2
/-- *Diagonalization theorem*, *spectral theorem*; version 1: A self-adjoint operator `T` on a
finite-dimensional inner product space `E` acts diagonally on the decomposition of `E` into the
direct sum of the eigenspaces of `T`. -/
theorem diagonalization_apply_self_apply (v : E) (μ : Eigenvalues T) :
    hT.diagonalization (T v) μ = (μ : 𝕜) • hT.diagonalization v μ := by
  suffices
    ∀ w : PiLp 2 fun μ : Eigenvalues T => eigenspace T μ,
      T (hT.diagonalization.symm w) = hT.diagonalization.symm fun μ => (μ : 𝕜) • w μ by
    simpa only [LinearIsometryEquiv.symm_apply_apply, LinearIsometryEquiv.apply_symm_apply] using
      congr_arg (fun w => hT.diagonalization w μ) (this (hT.diagonalization v))
  intro w
  have hwT : ∀ μ, T (w μ) = (μ : 𝕜) • w μ := fun μ => mem_eigenspace_iff.1 (w μ).2
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
v : E
μ : Eigenvalues T
w : PiLp 2 fun μ => ↥(eigenspace T (↑T μ))
hwT : ∀ (μ : Eigenvalues T), T ↑(w μ) = ↑T μ • ↑(w μ)
⊢ T ((LinearIsometryEquiv.symm (diagonalization hT)) w) =
    (LinearIsometryEquiv.symm (diagonalization hT)) fun μ => ↑T μ • w μ

Next tactic:
simp only [hwT, diagonalization_symm_apply, map_sum, Submodule.coe_smul_of_tower]
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
⊢ HasEigenvector T (↑(eigenvalues hT hn i)) ((eigenvectorBasis hT hn) i)

Next tactic:
let v : E := hT.eigenvectorBasis hn i
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
⊢ HasEigenvector T (↑(eigenvalues hT hn i)) ((eigenvectorBasis hT hn) i)

Next tactic:
let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
⊢ HasEigenvector T (↑(eigenvalues hT hn i)) ((eigenvectorBasis hT hn) i)

Next tactic:
simp_rw [eigenvalues]
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
⊢ HasEigenvector T
    (↑(IsROrC.re
        (↑T
          (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn
            (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
            (_ :
              OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ =>
                Submodule.subtypeₗᵢ (eigenspace T (↑T μ)))))))
    ((eigenvectorBasis hT hn) i)

Next tactic:
change HasEigenvector T (IsROrC.re μ) v
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
⊢ HasEigenvector T (↑(IsROrC.re μ)) v

Next tactic:
have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
    have H₂ : v ≠ 0 := by simpa using (hT.eigenvectorBasis hn).toBasis.ne_zero i
    exact ⟨H₁, H₂⟩
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
⊢ HasEigenvector T μ v

Next tactic:
have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
⊢ v ∈ eigenspace T μ

Next tactic:
simp_rw [eigenvectorBasis]
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
⊢ (DirectSum.IsInternal.subordinateOrthonormalBasis hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ))
        (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
      i ∈
    eigenspace T
      (↑T
        (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn
          (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
          (_ :
            OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ)))))

Next tactic:
exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
    

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
H₁ : v ∈ eigenspace T μ
⊢ HasEigenvector T μ v

Next tactic:
have H₂ : v ≠ 0 := by simpa using (hT.eigenvectorBasis hn).toBasis.ne_zero i
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
    have H₂ : v ≠ 0 := by 

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
H₁ : v ∈ eigenspace T μ
⊢ v ≠ 0

Next tactic:
simpa using (hT.eigenvectorBasis hn).toBasis.ne_zero i
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
    have H₂ : v ≠ 0 := by simpa using (hT.eigenvectorBasis hn).toBasis.ne_zero i
    

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
H₁ : v ∈ eigenspace T μ
H₂ : v ≠ 0
⊢ HasEigenvector T μ v

Next tactic:
exact ⟨H₁, H₂⟩
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
    have H₂ : v ≠ 0 := by simpa using (hT.eigenvectorBasis hn).toBasis.ne_zero i
    exact ⟨H₁, H₂⟩
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
key : HasEigenvector T μ v
⊢ HasEigenvector T (↑(IsROrC.re μ)) v

Next tactic:
have re_μ : ↑(IsROrC.re μ) = μ := by
    rw [← IsROrC.conj_eq_iff_re]
    exact hT.conj_eigenvalue_eq_self (hasEigenvalue_of_hasEigenvector key)
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
    have H₂ : v ≠ 0 := by simpa using (hT.eigenvectorBasis hn).toBasis.ne_zero i
    exact ⟨H₁, H₂⟩
  have re_μ : ↑(IsROrC.re μ) = μ := by
    

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
key : HasEigenvector T μ v
⊢ ↑(IsROrC.re μ) = μ

Next tactic:
rw [← IsROrC.conj_eq_iff_re]
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
    have H₂ : v ≠ 0 := by simpa using (hT.eigenvectorBasis hn).toBasis.ne_zero i
    exact ⟨H₁, H₂⟩
  have re_μ : ↑(IsROrC.re μ) = μ := by
    rw [← IsROrC.conj_eq_iff_re]
    

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
key : HasEigenvector T μ v
⊢ (starRingEnd 𝕜) μ = μ

Next tactic:
exact hT.conj_eigenvalue_eq_self (hasEigenvalue_of_hasEigenvector key)
theorem hasEigenvector_eigenvectorBasis (i : Fin n) :
    HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
  let v : E := hT.eigenvectorBasis hn i
  let μ : 𝕜 :=
    (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
      hT.orthogonalFamily_eigenspaces').val
  simp_rw [eigenvalues]
  change HasEigenvector T (IsROrC.re μ) v
  have key : HasEigenvector T μ v := by
    have H₁ : v ∈ eigenspace T μ := by
      simp_rw [eigenvectorBasis]
      exact
        hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
          hT.orthogonalFamily_eigenspaces'
    have H₂ : v ≠ 0 := by simpa using (hT.eigenvectorBasis hn).toBasis.ne_zero i
    exact ⟨H₁, H₂⟩
  have re_μ : ↑(IsROrC.re μ) = μ := by
    rw [← IsROrC.conj_eq_iff_re]
    exact hT.conj_eigenvalue_eq_self (hasEigenvalue_of_hasEigenvector key)
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
i : Fin n
v : E := (eigenvectorBasis hT hn) i
μ : 𝕜 :=
  ↑T
    (DirectSum.IsInternal.subordinateOrthonormalBasisIndex hn (_ : DirectSum.IsInternal fun μ => eigenspace T (↑T μ)) i
      (_ : OrthogonalFamily 𝕜 (fun μ => ↥(eigenspace T (↑T μ))) fun μ => Submodule.subtypeₗᵢ (eigenspace T (↑T μ))))
key : HasEigenvector T μ v
re_μ : ↑(IsROrC.re μ) = μ
⊢ HasEigenvector T (↑(IsROrC.re μ)) v

Next tactic:
simpa [re_μ] using key
/-- *Diagonalization theorem*, *spectral theorem*; version 2: A self-adjoint operator `T` on a
finite-dimensional inner product space `E` acts diagonally on the identification of `E` with
Euclidean space induced by an orthonormal basis of eigenvectors of `T`. -/
theorem eigenvectorBasis_apply_self_apply (v : E) (i : Fin n) :
    (hT.eigenvectorBasis hn).repr (T v) i =
      hT.eigenvalues hn i * (hT.eigenvectorBasis hn).repr v i := by
  

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
v : E
i : Fin n
⊢ (eigenvectorBasis hT hn).repr (T v) i = ↑(eigenvalues hT hn i) * (eigenvectorBasis hT hn).repr v i

Next tactic:
suffices
    ∀ w : EuclideanSpace 𝕜 (Fin n),
      T ((hT.eigenvectorBasis hn).repr.symm w) =
        (hT.eigenvectorBasis hn).repr.symm fun i => hT.eigenvalues hn i * w i by
    simpa [OrthonormalBasis.sum_repr_symm] using
      congr_arg (fun v => (hT.eigenvectorBasis hn).repr v i)
        (this ((hT.eigenvectorBasis hn).repr v))
/-- *Diagonalization theorem*, *spectral theorem*; version 2: A self-adjoint operator `T` on a
finite-dimensional inner product space `E` acts diagonally on the identification of `E` with
Euclidean space induced by an orthonormal basis of eigenvectors of `T`. -/
theorem eigenvectorBasis_apply_self_apply (v : E) (i : Fin n) :
    (hT.eigenvectorBasis hn).repr (T v) i =
      hT.eigenvalues hn i * (hT.eigenvectorBasis hn).repr v i := by
  suffices
    ∀ w : EuclideanSpace 𝕜 (Fin n),
      T ((hT.eigenvectorBasis hn).repr.symm w) =
        (hT.eigenvectorBasis hn).repr.symm fun i => hT.eigenvalues hn i * w i by
    

Proof state:
𝕜 : Type u_1
inst✝³ : IsROrC 𝕜
E : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace 𝕜 E
T : E →ₗ[𝕜] E
hT : IsSymmetric T
inst✝ : FiniteDimensional 𝕜 E
n : ℕ
hn : FiniteDimensional.finrank 𝕜 E = n
v : E
i : Fin n
this :
  ∀ (w : EuclideanSpace 𝕜 (Fin n)),
    T ((LinearIsometryEquiv.symm (eigenvectorBasis hT hn).repr) w) =
      (LinearIsometryEquiv.symm (eigenvectorBasis hT hn).repr) fun i => ↑(eigenvalues hT hn i) * w i
⊢ (eigenvectorBasis hT hn).repr (T v) i = ↑(eigenvalues hT hn i) * (eigenvectorBasis hT hn).repr v i

Next tactic:
simpa [OrthonormalBasis.sum_repr_symm] using
      congr_arg (fun v => (hT.eigenvectorBasis hn).repr v i)
        (this ((hT.eigenvectorBasis hn).repr v))