l3lab/ntp-mathlib huggingface dataset:
theorem inf_iSup_generalizedEigenspace [FiniteDimensional K V] (h : ∀ x ∈ p, f x ∈ p) :
    p ⊓ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⨆ μ, ⨆ k, p ⊓ f.generalizedEigenspace μ k := by
  simp_rw [← (f.generalizedEigenspace _).mono.directed_le.inf_iSup_eq]
  refine le_antisymm (fun m hm ↦ ?_)
    (le_inf_iff.mpr ⟨iSup_le fun μ ↦ inf_le_left, iSup_mono fun μ ↦ inf_le_right⟩)
  classical
  obtain ⟨hm₀ : m ∈ p, hm₁ : m ∈ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k⟩ := hm
  obtain ⟨m, hm₂, rfl⟩ := (mem_iSup_iff_exists_finsupp _ _).mp hm₁
  suffices ∀ μ, (m μ : V) ∈ p by
    exact (mem_iSup_iff_exists_finsupp _ _).mpr ⟨m, fun μ ↦ mem_inf.mp ⟨this μ, hm₂ μ⟩, rfl⟩
  intro μ
  by_cases hμ : μ ∈ m.support; swap; simp only [Finsupp.not_mem_support_iff.mp hμ, p.zero_mem]
  have h_comm : ∀ (μ₁ μ₂ : K),
    Commute ((f - algebraMap K (End K V) μ₁) ^ finrank K V)
            ((f - algebraMap K (End K V) μ₂) ^ finrank K V) := fun μ₁ μ₂ ↦
    ((Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).sub_left
      (Algebra.commute_algebraMap_left _ _)).pow_pow _ _
  let g : End K V := (m.support.erase μ).noncommProd _ fun μ₁ _ μ₂ _ _ ↦ h_comm μ₁ μ₂
  have hfg : Commute f g := Finset.noncommProd_commute _ _ _ _ fun μ' _ ↦
    (Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).pow_right _
  have hg₀ : g (m.sum fun _μ mμ ↦ mμ) = g (m μ) := by
    suffices ∀ μ' ∈ m.support, g (m μ') = if μ' = μ then g (m μ) else 0 by
      rw [map_finsupp_sum, Finsupp.sum_congr (g2 := fun μ' _ ↦ if μ' = μ then g (m μ) else 0) this,
        Finsupp.sum_ite_eq', if_pos hμ]
    rintro μ' hμ'
    

Proof state:
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
m : K →₀ V
hm₂ : ∀ (i : K), m i ∈ ⨆ k, (End.generalizedEigenspace f i) k
hm₀ : (Finsupp.sum m fun _i xi => xi) ∈ p
hm₁ : (Finsupp.sum m fun _i xi => xi) ∈ ⨆ μ, ⨆ k, (End.generalizedEigenspace f μ) k
μ : K
hμ : μ ∈ m.support
h_comm :
  ∀ (μ₁ μ₂ : K),
    Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V)
g : End K V :=
  Finset.noncommProd (Finset.erase m.support μ) (fun μ₁ => (f - (algebraMap K (End K V)) μ₁) ^ finrank K V)
    (_ :
      ∀ μ₁ ∈ ↑(Finset.erase m.support μ),
        ∀ μ₂ ∈ ↑(Finset.erase m.support μ),
          μ₁ ≠ μ₂ →
            Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V))
hfg : Commute f g
μ' : K
hμ' : μ' ∈ m.support
⊢ g (m μ') = if μ' = μ then g (m μ) else 0

Next tactic:
split_ifs with hμμ'
theorem inf_iSup_generalizedEigenspace [FiniteDimensional K V] (h : ∀ x ∈ p, f x ∈ p) :
    p ⊓ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⨆ μ, ⨆ k, p ⊓ f.generalizedEigenspace μ k := by
  simp_rw [← (f.generalizedEigenspace _).mono.directed_le.inf_iSup_eq]
  refine le_antisymm (fun m hm ↦ ?_)
    (le_inf_iff.mpr ⟨iSup_le fun μ ↦ inf_le_left, iSup_mono fun μ ↦ inf_le_right⟩)
  classical
  obtain ⟨hm₀ : m ∈ p, hm₁ : m ∈ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k⟩ := hm
  obtain ⟨m, hm₂, rfl⟩ := (mem_iSup_iff_exists_finsupp _ _).mp hm₁
  suffices ∀ μ, (m μ : V) ∈ p by
    exact (mem_iSup_iff_exists_finsupp _ _).mpr ⟨m, fun μ ↦ mem_inf.mp ⟨this μ, hm₂ μ⟩, rfl⟩
  intro μ
  by_cases hμ : μ ∈ m.support; swap; simp only [Finsupp.not_mem_support_iff.mp hμ, p.zero_mem]
  have h_comm : ∀ (μ₁ μ₂ : K),
    Commute ((f - algebraMap K (End K V) μ₁) ^ finrank K V)
            ((f - algebraMap K (End K V) μ₂) ^ finrank K V) := fun μ₁ μ₂ ↦
    ((Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).sub_left
      (Algebra.commute_algebraMap_left _ _)).pow_pow _ _
  let g : End K V := (m.support.erase μ).noncommProd _ fun μ₁ _ μ₂ _ _ ↦ h_comm μ₁ μ₂
  have hfg : Commute f g := Finset.noncommProd_commute _ _ _ _ fun μ' _ ↦
    (Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).pow_right _
  have hg₀ : g (m.sum fun _μ mμ ↦ mμ) = g (m μ) := by
    suffices ∀ μ' ∈ m.support, g (m μ') = if μ' = μ then g (m μ) else 0 by
      rw [map_finsupp_sum, Finsupp.sum_congr (g2 := fun μ' _ ↦ if μ' = μ then g (m μ) else 0) this,
        Finsupp.sum_ite_eq', if_pos hμ]
    rintro μ' hμ'
    split_ifs with hμμ'
    · 

Proof state:
case pos
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
m : K →₀ V
hm₂ : ∀ (i : K), m i ∈ ⨆ k, (End.generalizedEigenspace f i) k
hm₀ : (Finsupp.sum m fun _i xi => xi) ∈ p
hm₁ : (Finsupp.sum m fun _i xi => xi) ∈ ⨆ μ, ⨆ k, (End.generalizedEigenspace f μ) k
μ : K
hμ : μ ∈ m.support
h_comm :
  ∀ (μ₁ μ₂ : K),
    Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V)
g : End K V :=
  Finset.noncommProd (Finset.erase m.support μ) (fun μ₁ => (f - (algebraMap K (End K V)) μ₁) ^ finrank K V)
    (_ :
      ∀ μ₁ ∈ ↑(Finset.erase m.support μ),
        ∀ μ₂ ∈ ↑(Finset.erase m.support μ),
          μ₁ ≠ μ₂ →
            Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V))
hfg : Commute f g
μ' : K
hμ' : μ' ∈ m.support
hμμ' : μ' = μ
⊢ g (m μ') = g (m μ)

Next tactic:
rw [hμμ']
theorem inf_iSup_generalizedEigenspace [FiniteDimensional K V] (h : ∀ x ∈ p, f x ∈ p) :
    p ⊓ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⨆ μ, ⨆ k, p ⊓ f.generalizedEigenspace μ k := by
  simp_rw [← (f.generalizedEigenspace _).mono.directed_le.inf_iSup_eq]
  refine le_antisymm (fun m hm ↦ ?_)
    (le_inf_iff.mpr ⟨iSup_le fun μ ↦ inf_le_left, iSup_mono fun μ ↦ inf_le_right⟩)
  classical
  obtain ⟨hm₀ : m ∈ p, hm₁ : m ∈ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k⟩ := hm
  obtain ⟨m, hm₂, rfl⟩ := (mem_iSup_iff_exists_finsupp _ _).mp hm₁
  suffices ∀ μ, (m μ : V) ∈ p by
    exact (mem_iSup_iff_exists_finsupp _ _).mpr ⟨m, fun μ ↦ mem_inf.mp ⟨this μ, hm₂ μ⟩, rfl⟩
  intro μ
  by_cases hμ : μ ∈ m.support; swap; simp only [Finsupp.not_mem_support_iff.mp hμ, p.zero_mem]
  have h_comm : ∀ (μ₁ μ₂ : K),
    Commute ((f - algebraMap K (End K V) μ₁) ^ finrank K V)
            ((f - algebraMap K (End K V) μ₂) ^ finrank K V) := fun μ₁ μ₂ ↦
    ((Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).sub_left
      (Algebra.commute_algebraMap_left _ _)).pow_pow _ _
  let g : End K V := (m.support.erase μ).noncommProd _ fun μ₁ _ μ₂ _ _ ↦ h_comm μ₁ μ₂
  have hfg : Commute f g := Finset.noncommProd_commute _ _ _ _ fun μ' _ ↦
    (Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).pow_right _
  have hg₀ : g (m.sum fun _μ mμ ↦ mμ) = g (m μ) := by
    suffices ∀ μ' ∈ m.support, g (m μ') = if μ' = μ then g (m μ) else 0 by
      rw [map_finsupp_sum, Finsupp.sum_congr (g2 := fun μ' _ ↦ if μ' = μ then g (m μ) else 0) this,
        Finsupp.sum_ite_eq', if_pos hμ]
    rintro μ' hμ'
    split_ifs with hμμ'
    · rw [hμμ']
    

Proof state:
case neg
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
m : K →₀ V
hm₂ : ∀ (i : K), m i ∈ ⨆ k, (End.generalizedEigenspace f i) k
hm₀ : (Finsupp.sum m fun _i xi => xi) ∈ p
hm₁ : (Finsupp.sum m fun _i xi => xi) ∈ ⨆ μ, ⨆ k, (End.generalizedEigenspace f μ) k
μ : K
hμ : μ ∈ m.support
h_comm :
  ∀ (μ₁ μ₂ : K),
    Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V)
g : End K V :=
  Finset.noncommProd (Finset.erase m.support μ) (fun μ₁ => (f - (algebraMap K (End K V)) μ₁) ^ finrank K V)
    (_ :
      ∀ μ₁ ∈ ↑(Finset.erase m.support μ),
        ∀ μ₂ ∈ ↑(Finset.erase m.support μ),
          μ₁ ≠ μ₂ →
            Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V))
hfg : Commute f g
μ' : K
hμ' : μ' ∈ m.support
hμμ' : ¬μ' = μ
⊢ g (m μ') = 0

Next tactic:
replace hm₂ : ((f - algebraMap K (End K V) μ') ^ finrank K V) (m μ') = 0 := by
      obtain ⟨k, hk⟩ := (mem_iSup_of_chain _ _).mp (hm₂ μ')
      exact Module.End.generalizedEigenspace_le_generalizedEigenspace_finrank _ _ k hk
theorem inf_iSup_generalizedEigenspace [FiniteDimensional K V] (h : ∀ x ∈ p, f x ∈ p) :
    p ⊓ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⨆ μ, ⨆ k, p ⊓ f.generalizedEigenspace μ k := by
  simp_rw [← (f.generalizedEigenspace _).mono.directed_le.inf_iSup_eq]
  refine le_antisymm (fun m hm ↦ ?_)
    (le_inf_iff.mpr ⟨iSup_le fun μ ↦ inf_le_left, iSup_mono fun μ ↦ inf_le_right⟩)
  classical
  obtain ⟨hm₀ : m ∈ p, hm₁ : m ∈ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k⟩ := hm
  obtain ⟨m, hm₂, rfl⟩ := (mem_iSup_iff_exists_finsupp _ _).mp hm₁
  suffices ∀ μ, (m μ : V) ∈ p by
    exact (mem_iSup_iff_exists_finsupp _ _).mpr ⟨m, fun μ ↦ mem_inf.mp ⟨this μ, hm₂ μ⟩, rfl⟩
  intro μ
  by_cases hμ : μ ∈ m.support; swap; simp only [Finsupp.not_mem_support_iff.mp hμ, p.zero_mem]
  have h_comm : ∀ (μ₁ μ₂ : K),
    Commute ((f - algebraMap K (End K V) μ₁) ^ finrank K V)
            ((f - algebraMap K (End K V) μ₂) ^ finrank K V) := fun μ₁ μ₂ ↦
    ((Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).sub_left
      (Algebra.commute_algebraMap_left _ _)).pow_pow _ _
  let g : End K V := (m.support.erase μ).noncommProd _ fun μ₁ _ μ₂ _ _ ↦ h_comm μ₁ μ₂
  have hfg : Commute f g := Finset.noncommProd_commute _ _ _ _ fun μ' _ ↦
    (Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).pow_right _
  have hg₀ : g (m.sum fun _μ mμ ↦ mμ) = g (m μ) := by
    suffices ∀ μ' ∈ m.support, g (m μ') = if μ' = μ then g (m μ) else 0 by
      rw [map_finsupp_sum, Finsupp.sum_congr (g2 := fun μ' _ ↦ if μ' = μ then g (m μ) else 0) this,
        Finsupp.sum_ite_eq', if_pos hμ]
    rintro μ' hμ'
    split_ifs with hμμ'
    · rw [hμμ']
    replace hm₂ : ((f - algebraMap K (End K V) μ') ^ finrank K V) (m μ') = 0 := by
      

Proof state:
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
m : K →₀ V
hm₂ : ∀ (i : K), m i ∈ ⨆ k, (End.generalizedEigenspace f i) k
hm₀ : (Finsupp.sum m fun _i xi => xi) ∈ p
hm₁ : (Finsupp.sum m fun _i xi => xi) ∈ ⨆ μ, ⨆ k, (End.generalizedEigenspace f μ) k
μ : K
hμ : μ ∈ m.support
h_comm :
  ∀ (μ₁ μ₂ : K),
    Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V)
g : End K V :=
  Finset.noncommProd (Finset.erase m.support μ) (fun μ₁ => (f - (algebraMap K (End K V)) μ₁) ^ finrank K V)
    (_ :
      ∀ μ₁ ∈ ↑(Finset.erase m.support μ),
        ∀ μ₂ ∈ ↑(Finset.erase m.support μ),
          μ₁ ≠ μ₂ →
            Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V))
hfg : Commute f g
μ' : K
hμ' : μ' ∈ m.support
hμμ' : ¬μ' = μ
⊢ ((f - (algebraMap K (End K V)) μ') ^ finrank K V) (m μ') = 0

Next tactic:
obtain ⟨k, hk⟩ := (mem_iSup_of_chain _ _).mp (hm₂ μ')
theorem inf_iSup_generalizedEigenspace [FiniteDimensional K V] (h : ∀ x ∈ p, f x ∈ p) :
    p ⊓ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⨆ μ, ⨆ k, p ⊓ f.generalizedEigenspace μ k := by
  simp_rw [← (f.generalizedEigenspace _).mono.directed_le.inf_iSup_eq]
  refine le_antisymm (fun m hm ↦ ?_)
    (le_inf_iff.mpr ⟨iSup_le fun μ ↦ inf_le_left, iSup_mono fun μ ↦ inf_le_right⟩)
  classical
  obtain ⟨hm₀ : m ∈ p, hm₁ : m ∈ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k⟩ := hm
  obtain ⟨m, hm₂, rfl⟩ := (mem_iSup_iff_exists_finsupp _ _).mp hm₁
  suffices ∀ μ, (m μ : V) ∈ p by
    exact (mem_iSup_iff_exists_finsupp _ _).mpr ⟨m, fun μ ↦ mem_inf.mp ⟨this μ, hm₂ μ⟩, rfl⟩
  intro μ
  by_cases hμ : μ ∈ m.support; swap; simp only [Finsupp.not_mem_support_iff.mp hμ, p.zero_mem]
  have h_comm : ∀ (μ₁ μ₂ : K),
    Commute ((f - algebraMap K (End K V) μ₁) ^ finrank K V)
            ((f - algebraMap K (End K V) μ₂) ^ finrank K V) := fun μ₁ μ₂ ↦
    ((Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).sub_left
      (Algebra.commute_algebraMap_left _ _)).pow_pow _ _
  let g : End K V := (m.support.erase μ).noncommProd _ fun μ₁ _ μ₂ _ _ ↦ h_comm μ₁ μ₂
  have hfg : Commute f g := Finset.noncommProd_commute _ _ _ _ fun μ' _ ↦
    (Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).pow_right _
  have hg₀ : g (m.sum fun _μ mμ ↦ mμ) = g (m μ) := by
    suffices ∀ μ' ∈ m.support, g (m μ') = if μ' = μ then g (m μ) else 0 by
      rw [map_finsupp_sum, Finsupp.sum_congr (g2 := fun μ' _ ↦ if μ' = μ then g (m μ) else 0) this,
        Finsupp.sum_ite_eq', if_pos hμ]
    rintro μ' hμ'
    split_ifs with hμμ'
    · rw [hμμ']
    replace hm₂ : ((f - algebraMap K (End K V) μ') ^ finrank K V) (m μ') = 0 := by
      obtain ⟨k, hk⟩ := (mem_iSup_of_chain _ _).mp (hm₂ μ')
      

Proof state:
case intro
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
m : K →₀ V
hm₂ : ∀ (i : K), m i ∈ ⨆ k, (End.generalizedEigenspace f i) k
hm₀ : (Finsupp.sum m fun _i xi => xi) ∈ p
hm₁ : (Finsupp.sum m fun _i xi => xi) ∈ ⨆ μ, ⨆ k, (End.generalizedEigenspace f μ) k
μ : K
hμ : μ ∈ m.support
h_comm :
  ∀ (μ₁ μ₂ : K),
    Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V)
g : End K V :=
  Finset.noncommProd (Finset.erase m.support μ) (fun μ₁ => (f - (algebraMap K (End K V)) μ₁) ^ finrank K V)
    (_ :
      ∀ μ₁ ∈ ↑(Finset.erase m.support μ),
        ∀ μ₂ ∈ ↑(Finset.erase m.support μ),
          μ₁ ≠ μ₂ →
            Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V))
hfg : Commute f g
μ' : K
hμ' : μ' ∈ m.support
hμμ' : ¬μ' = μ
k : ℕ
hk : m μ' ∈ (End.generalizedEigenspace f μ') k
⊢ ((f - (algebraMap K (End K V)) μ') ^ finrank K V) (m μ') = 0

Next tactic:
exact Module.End.generalizedEigenspace_le_generalizedEigenspace_finrank _ _ k hk
theorem inf_iSup_generalizedEigenspace [FiniteDimensional K V] (h : ∀ x ∈ p, f x ∈ p) :
    p ⊓ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⨆ μ, ⨆ k, p ⊓ f.generalizedEigenspace μ k := by
  simp_rw [← (f.generalizedEigenspace _).mono.directed_le.inf_iSup_eq]
  refine le_antisymm (fun m hm ↦ ?_)
    (le_inf_iff.mpr ⟨iSup_le fun μ ↦ inf_le_left, iSup_mono fun μ ↦ inf_le_right⟩)
  classical
  obtain ⟨hm₀ : m ∈ p, hm₁ : m ∈ ⨆ μ, ⨆ k, f.generalizedEigenspace μ k⟩ := hm
  obtain ⟨m, hm₂, rfl⟩ := (mem_iSup_iff_exists_finsupp _ _).mp hm₁
  suffices ∀ μ, (m μ : V) ∈ p by
    exact (mem_iSup_iff_exists_finsupp _ _).mpr ⟨m, fun μ ↦ mem_inf.mp ⟨this μ, hm₂ μ⟩, rfl⟩
  intro μ
  by_cases hμ : μ ∈ m.support; swap; simp only [Finsupp.not_mem_support_iff.mp hμ, p.zero_mem]
  have h_comm : ∀ (μ₁ μ₂ : K),
    Commute ((f - algebraMap K (End K V) μ₁) ^ finrank K V)
            ((f - algebraMap K (End K V) μ₂) ^ finrank K V) := fun μ₁ μ₂ ↦
    ((Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).sub_left
      (Algebra.commute_algebraMap_left _ _)).pow_pow _ _
  let g : End K V := (m.support.erase μ).noncommProd _ fun μ₁ _ μ₂ _ _ ↦ h_comm μ₁ μ₂
  have hfg : Commute f g := Finset.noncommProd_commute _ _ _ _ fun μ' _ ↦
    (Commute.sub_right rfl <| Algebra.commute_algebraMap_right _ _).pow_right _
  have hg₀ : g (m.sum fun _μ mμ ↦ mμ) = g (m μ) := by
    suffices ∀ μ' ∈ m.support, g (m μ') = if μ' = μ then g (m μ) else 0 by
      rw [map_finsupp_sum, Finsupp.sum_congr (g2 := fun μ' _ ↦ if μ' = μ then g (m μ) else 0) this,
        Finsupp.sum_ite_eq', if_pos hμ]
    rintro μ' hμ'
    split_ifs with hμμ'
    · rw [hμμ']
    replace hm₂ : ((f - algebraMap K (End K V) μ') ^ finrank K V) (m μ') = 0 := by
      obtain ⟨k, hk⟩ := (mem_iSup_of_chain _ _).mp (hm₂ μ')
      exact Module.End.generalizedEigenspace_le_generalizedEigenspace_finrank _ _ k hk
    

Proof state:
case neg
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
m : K →₀ V
hm₀ : (Finsupp.sum m fun _i xi => xi) ∈ p
hm₁ : (Finsupp.sum m fun _i xi => xi) ∈ ⨆ μ, ⨆ k, (End.generalizedEigenspace f μ) k
μ : K
hμ : μ ∈ m.support
h_comm :
  ∀ (μ₁ μ₂ : K),
    Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V)
g : End K V :=
  Finset.noncommProd (Finset.erase m.support μ) (fun μ₁ => (f - (algebraMap K (End K V)) μ₁) ^ finrank K V)
    (_ :
      ∀ μ₁ ∈ ↑(Finset.erase m.support μ),
        ∀ μ₂ ∈ ↑(Finset.erase m.support μ),
          μ₁ ≠ μ₂ →
            Commute ((f - (algebraMap K (End K V)) μ₁) ^ finrank K V) ((f - (algebraMap K (End K V)) μ₂) ^ finrank K V))
hfg : Commute f g
μ' : K
hμ' : μ' ∈ m.support
hμμ' : ¬μ' = μ
hm₂ : ((f - (algebraMap K (End K V)) μ') ^ finrank K V) (m μ') = 0
⊢ g (m μ') = 0

Next tactic:
have : _ = g := (m.support.erase μ).noncommProd_erase_mul (Finset.mem_erase.mpr ⟨hμμ', hμ'⟩)
      (fun μ ↦ (f - algebraMap K (End K V) μ) ^ finrank K V) (fun μ₁ _ μ₂ _ _ ↦ h_comm μ₁ μ₂)
theorem eq_iSup_inf_generalizedEigenspace [FiniteDimensional K V]
    (h : ∀ x ∈ p, f x ∈ p) (h' : ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⊤) :
    p = ⨆ μ, ⨆ k, p ⊓ f.generalizedEigenspace μ k := by
  

Proof state:
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
h' : ⨆ μ, ⨆ k, (End.generalizedEigenspace f μ) k = ⊤
⊢ p = ⨆ μ, ⨆ k, p ⊓ (End.generalizedEigenspace f μ) k

Next tactic:
rw [← inf_iSup_generalizedEigenspace h, h', inf_top_eq]
/-- In finite dimensions, if the generalized eigenspaces of a linear endomorphism span the whole
space then the same is true of its restriction to any invariant submodule. -/
theorem Module.End.iSup_generalizedEigenspace_restrict_eq_top
    {p : Submodule K V} {f : Module.End K V} [FiniteDimensional K V]
    (h : ∀ x ∈ p, f x ∈ p) (h' : ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⊤) :
    ⨆ μ, ⨆ k, Module.End.generalizedEigenspace (LinearMap.restrict f h) μ k = ⊤ := by
  

Proof state:
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
h' : ⨆ μ, ⨆ k, (generalizedEigenspace f μ) k = ⊤
⊢ ⨆ μ, ⨆ k, (generalizedEigenspace (LinearMap.restrict f h) μ) k = ⊤

Next tactic:
have := congr_arg (Submodule.comap p.subtype) (Submodule.eq_iSup_inf_generalizedEigenspace h h')
/-- In finite dimensions, if the generalized eigenspaces of a linear endomorphism span the whole
space then the same is true of its restriction to any invariant submodule. -/
theorem Module.End.iSup_generalizedEigenspace_restrict_eq_top
    {p : Submodule K V} {f : Module.End K V} [FiniteDimensional K V]
    (h : ∀ x ∈ p, f x ∈ p) (h' : ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⊤) :
    ⨆ μ, ⨆ k, Module.End.generalizedEigenspace (LinearMap.restrict f h) μ k = ⊤ := by
  have := congr_arg (Submodule.comap p.subtype) (Submodule.eq_iSup_inf_generalizedEigenspace h h')
  

Proof state:
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
h' : ⨆ μ, ⨆ k, (generalizedEigenspace f μ) k = ⊤
this :
  Submodule.comap (Submodule.subtype p) p =
    Submodule.comap (Submodule.subtype p) (⨆ μ, ⨆ k, p ⊓ (generalizedEigenspace f μ) k)
⊢ ⨆ μ, ⨆ k, (generalizedEigenspace (LinearMap.restrict f h) μ) k = ⊤

Next tactic:
have h_inj : Function.Injective p.subtype := Subtype.coe_injective
/-- In finite dimensions, if the generalized eigenspaces of a linear endomorphism span the whole
space then the same is true of its restriction to any invariant submodule. -/
theorem Module.End.iSup_generalizedEigenspace_restrict_eq_top
    {p : Submodule K V} {f : Module.End K V} [FiniteDimensional K V]
    (h : ∀ x ∈ p, f x ∈ p) (h' : ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⊤) :
    ⨆ μ, ⨆ k, Module.End.generalizedEigenspace (LinearMap.restrict f h) μ k = ⊤ := by
  have := congr_arg (Submodule.comap p.subtype) (Submodule.eq_iSup_inf_generalizedEigenspace h h')
  have h_inj : Function.Injective p.subtype := Subtype.coe_injective
  

Proof state:
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
h' : ⨆ μ, ⨆ k, (generalizedEigenspace f μ) k = ⊤
this :
  Submodule.comap (Submodule.subtype p) p =
    Submodule.comap (Submodule.subtype p) (⨆ μ, ⨆ k, p ⊓ (generalizedEigenspace f μ) k)
h_inj : Injective ⇑(Submodule.subtype p)
⊢ ⨆ μ, ⨆ k, (generalizedEigenspace (LinearMap.restrict f h) μ) k = ⊤

Next tactic:
simp_rw [Submodule.inf_generalizedEigenspace f p h, Submodule.comap_subtype_self,
    ← Submodule.map_iSup, Submodule.comap_map_eq_of_injective h_inj] at this
/-- In finite dimensions, if the generalized eigenspaces of a linear endomorphism span the whole
space then the same is true of its restriction to any invariant submodule. -/
theorem Module.End.iSup_generalizedEigenspace_restrict_eq_top
    {p : Submodule K V} {f : Module.End K V} [FiniteDimensional K V]
    (h : ∀ x ∈ p, f x ∈ p) (h' : ⨆ μ, ⨆ k, f.generalizedEigenspace μ k = ⊤) :
    ⨆ μ, ⨆ k, Module.End.generalizedEigenspace (LinearMap.restrict f h) μ k = ⊤ := by
  have := congr_arg (Submodule.comap p.subtype) (Submodule.eq_iSup_inf_generalizedEigenspace h h')
  have h_inj : Function.Injective p.subtype := Subtype.coe_injective
  simp_rw [Submodule.inf_generalizedEigenspace f p h, Submodule.comap_subtype_self,
    ← Submodule.map_iSup, Submodule.comap_map_eq_of_injective h_inj] at this
  

Proof state:
K : Type u_1
V : Type u_2
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
p : Submodule K V
f : End K V
inst✝ : FiniteDimensional K V
h : ∀ x ∈ p, f x ∈ p
h' : ⨆ μ, ⨆ k, (generalizedEigenspace f μ) k = ⊤
h_inj : Injective ⇑(Submodule.subtype p)
this : ⊤ = ⨆ i, ⨆ i_1, (generalizedEigenspace (LinearMap.restrict f h) i) i_1
⊢ ⨆ μ, ⨆ k, (generalizedEigenspace (LinearMap.restrict f h) μ) k = ⊤

Next tactic:
exact this.symm
theorem eq_toGHSpace_iff {X : Type u} [MetricSpace X] [CompactSpace X] [Nonempty X]
    {p : NonemptyCompacts ℓ_infty_ℝ} :
    ⟦p⟧ = toGHSpace X ↔ ∃ Ψ : X → ℓ_infty_ℝ, Isometry Ψ ∧ range Ψ = p := by
  

Proof state:
X : Type u
inst✝² : MetricSpace X
inst✝¹ : CompactSpace X
inst✝ : Nonempty X
p : NonemptyCompacts ↥(lp (fun n => ℝ) ⊤)
⊢ ⟦p⟧ = toGHSpace X ↔ ∃ Ψ, Isometry Ψ ∧ range Ψ = ↑p

Next tactic:
simp only [toGHSpace, Quotient.eq]
theorem eq_toGHSpace_iff {X : Type u} [MetricSpace X] [CompactSpace X] [Nonempty X]
    {p : NonemptyCompacts ℓ_infty_ℝ} :
    ⟦p⟧ = toGHSpace X ↔ ∃ Ψ : X → ℓ_infty_ℝ, Isometry Ψ ∧ range Ψ = p := by
  simp only [toGHSpace, Quotient.eq]
  

Proof state:
X : Type u
inst✝² : MetricSpace X
inst✝¹ : CompactSpace X
inst✝ : Nonempty X
p : NonemptyCompacts ↥(lp (fun n => ℝ) ⊤)
⊢ p ≈ NonemptyCompacts.kuratowskiEmbedding X ↔ ∃ Ψ, Isometry Ψ ∧ range Ψ = ↑p

Next tactic:
refine' ⟨fun h => _, _⟩
theorem eq_toGHSpace_iff {X : Type u} [MetricSpace X] [CompactSpace X] [Nonempty X]
    {p : NonemptyCompacts ℓ_infty_ℝ} :
    ⟦p⟧ = toGHSpace X ↔ ∃ Ψ : X → ℓ_infty_ℝ, Isometry Ψ ∧ range Ψ = p := by
  simp only [toGHSpace, Quotient.eq]
  refine' ⟨fun h => _, _⟩
  · 

Proof state:
case refine'_1
X : Type u
inst✝² : MetricSpace X
inst✝¹ : CompactSpace X
inst✝ : Nonempty X
p : NonemptyCompacts ↥(lp (fun n => ℝ) ⊤)
h : p ≈ NonemptyCompacts.kuratowskiEmbedding X
⊢ ∃ Ψ, Isometry Ψ ∧ range Ψ = ↑p

Next tactic:
rcases Setoid.symm h with ⟨e⟩
theorem eq_toGHSpace_iff {X : Type u} [MetricSpace X] [CompactSpace X] [Nonempty X]
    {p : NonemptyCompacts ℓ_infty_ℝ} :
    ⟦p⟧ = toGHSpace X ↔ ∃ Ψ : X → ℓ_infty_ℝ, Isometry Ψ ∧ range Ψ = p := by
  simp only [toGHSpace, Quotient.eq]
  refine' ⟨fun h => _, _⟩
  · rcases Setoid.symm h with ⟨e⟩
    

Proof state:
case refine'_1.intro
X : Type u
inst✝² : MetricSpace X
inst✝¹ : CompactSpace X
inst✝ : Nonempty X
p : NonemptyCompacts ↥(lp (fun n => ℝ) ⊤)
h : p ≈ NonemptyCompacts.kuratowskiEmbedding X
e : ↥(NonemptyCompacts.kuratowskiEmbedding X) ≃ᵢ ↥p
⊢ ∃ Ψ, Isometry Ψ ∧ range Ψ = ↑p

Next tactic:
have f := (kuratowskiEmbedding.isometry X).isometryEquivOnRange.trans e