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
    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 μ₁ μ₂)
    rw [← this, LinearMap.mul_apply, hm₂, _root_.map_zero]
  have hg₁ : MapsTo g p p := Finset.noncommProd_induction _ _ _ (fun g' : End K V ↦ MapsTo g' p p)
      (fun f₁ f₂ ↦ MapsTo.comp) (mapsTo_id _) fun μ' _ ↦ by
    suffices MapsTo (f - algebraMap K (End K V) μ') p p by
      simp only [LinearMap.coe_pow]; exact this.iterate (finrank K V)
    intro x hx
    rw [LinearMap.sub_apply, algebraMap_end_apply]
    exact p.sub_mem (h _ hx) (smul_mem p μ' hx)
  have hg₂ : MapsTo g ↑(⨆ k, f.generalizedEigenspace μ k) ↑(⨆ k, f.generalizedEigenspace μ k) :=
    f.mapsTo_iSup_generalizedEigenspace_of_comm hfg μ
  have hg₃ : InjOn g ↑(⨆ k, f.generalizedEigenspace μ k) := by
    apply LinearMap.injOn_of_disjoint_ker (subset_refl _)
    have this := f.independent_generalizedEigenspace
    simp_rw [f.iSup_generalizedEigenspace_eq_generalizedEigenspace_finrank] at this ⊢
    rw [LinearMap.ker_noncommProd_eq_of_supIndep_ker _ _ <| this.supIndep' (m.support.erase μ),
      ← Finset.sup_eq_iSup]
    exact Finset.supIndep_iff_disjoint_erase.mp (this.supIndep' m.support) μ hμ
  have hg₄ : SurjOn g
      ↑(p ⊓ ⨆ k, f.generalizedEigenspace μ k) ↑(p ⊓ ⨆ k, f.generalizedEigenspace μ k) := by
    have : MapsTo g
        ↑(p ⊓ ⨆ k, f.generalizedEigenspace μ k) ↑(p ⊓ ⨆ k, f.generalizedEigenspace μ k) :=
      hg₁.inter_inter hg₂
    rw [← LinearMap.injOn_iff_surjOn this]
    exact hg₃.mono (inter_subset_right _ _)
  specialize hm₂ μ
  obtain ⟨y, ⟨hy₀ : y ∈ p, hy₁ : y ∈ ⨆ k, f.generalizedEigenspace μ k⟩, hy₂ : g y = g (m μ)⟩ :=
    hg₄ ⟨(hg₀ ▸ hg₁ hm₀), hg₂ hm₂⟩
  

Proof state:
case pos.intro.intro.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₀ : (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
hg₀ : g (Finsupp.sum m fun _μ mμ => mμ) = g (m μ)
hg₁ : MapsTo ⇑g ↑p ↑p
hg₂ : MapsTo ⇑g ↑(⨆ k, (End.generalizedEigenspace f μ) k) ↑(⨆ k, (End.generalizedEigenspace f μ) k)
hg₃ : InjOn ⇑g ↑(⨆ k, (End.generalizedEigenspace f μ) k)
hg₄ : SurjOn ⇑g ↑(p ⊓ ⨆ k, (End.generalizedEigenspace f μ) k) ↑(p ⊓ ⨆ k, (End.generalizedEigenspace f μ) k)
hm₂ : m μ ∈ ⨆ k, (End.generalizedEigenspace f μ) k
y : V
hy₂ : g y = g (m μ)
hy₀ : y ∈ p
hy₁ : y ∈ ⨆ k, (End.generalizedEigenspace f μ) k
⊢ m μ ∈ p

Next tactic:
rwa [← hg₃ hy₁ hm₂ hy₂]