linear_algebra.eigenspace.basicMathlib.LinearAlgebra.Eigenspace.Basic

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -478,7 +478,7 @@ theorem generalizedEigenspace_restrict (f : End R M) (p : Submodule R M) (k : 
   · rw [pow_zero, pow_zero, LinearMap.one_eq_id]
     apply (Submodule.ker_subtype _).symm
   ·
-    erw [pow_succ', pow_succ', LinearMap.ker_comp, LinearMap.ker_comp, ih, ← LinearMap.ker_comp,
+    erw [pow_succ, pow_succ, LinearMap.ker_comp, LinearMap.ker_comp, ih, ← LinearMap.ker_comp,
       LinearMap.comp_assoc]
 #align module.End.generalized_eigenspace_restrict Module.End.generalizedEigenspace_restrict
 -/
Diff
@@ -143,7 +143,7 @@ theorem mem_spectrum_of_hasEigenvalue {f : End R M} {μ : R} (hμ : HasEigenvalu
 theorem hasEigenvalue_iff_mem_spectrum [FiniteDimensional K V] {f : End K V} {μ : K} :
     f.HasEigenvalue μ ↔ μ ∈ spectrum K f :=
   Iff.intro mem_spectrum_of_hasEigenvalue fun h => by
-    rwa [spectrum.mem_iff, IsUnit.sub_iff, LinearMap.isUnit_iff_ker_eq_bot] at h 
+    rwa [spectrum.mem_iff, IsUnit.sub_iff, LinearMap.isUnit_iff_ker_eq_bot] at h
 #align module.End.has_eigenvalue_iff_mem_spectrum Module.End.hasEigenvalue_iff_mem_spectrum
 -/
 
@@ -262,7 +262,7 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
       by
       simp only [S, DFinsupp.lsum_apply_apply, DFinsupp.sumAddHom_apply,
         LinearMap.toAddMonoidHom_coe, DFinsupp.sum, h_l_support, Submodule.subtype_apply,
-        Submodule.coe_eq_zero, Finset.sum_insert hμ₀, h_sum_l_support'_eq_0, add_zero] at hl 
+        Submodule.coe_eq_zero, Finset.sum_insert hμ₀, h_sum_l_support'_eq_0, add_zero] at hl
       exact hl
     -- Thus, all coefficients in `l` are `0`.
     show l = 0
@@ -390,7 +390,7 @@ theorem maximalGeneralizedEigenspace_eq [h : IsNoetherian R M] (f : End R M) (μ
     maximalGeneralizedEigenspace f μ =
       f.generalizedEigenspace μ (maximalGeneralizedEigenspaceIndex f μ) :=
   by
-  rw [isNoetherian_iff_wellFounded] at h 
+  rw [isNoetherian_iff_wellFounded] at h
   exact (WellFounded.iSup_eq_monotonicSequenceLimit h (f.generalized_eigenspace μ) : _)
 #align module.End.maximal_generalized_eigenspace_eq Module.End.maximalGeneralizedEigenspace_eq
 -/
Diff
@@ -165,30 +165,115 @@ theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
 any eigenspace has trivial intersection with the span of all the other eigenspaces. -/
 theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.eigenspace := by
   classical
+  -- Define an operation from `Π₀ μ : K, f.eigenspace μ`, the vector space of of finitely-supported
+  -- choices of an eigenvector from each eigenspace, to `V`, by sending a collection to its sum.
+  let S :
+    @LinearMap K K _ _ (RingHom.id K) (Π₀ μ : K, f.eigenspace μ) V
+      (@DFinsupp.addCommMonoid K (fun μ => f.eigenspace μ) _) _
+      (@DFinsupp.module K _ (fun μ => f.eigenspace μ) _ _ _) _ :=
+    @DFinsupp.lsum K K ℕ _ V _ _ _ _ _ _ _ _ _ fun μ => (f.eigenspace μ).Subtype
+  -- We need to show that if a finitely-supported collection `l` of representatives of the
+  -- eigenspaces has sum `0`, then it itself is zero.
+  suffices ∀ l : Π₀ μ, f.eigenspace μ, S l = 0 → l = 0
+    by
+    rw [CompleteLattice.independent_iff_dfinsupp_lsum_injective]
+    change Function.Injective S
+    rw [←
+      @LinearMap.ker_eq_bot K K (Π₀ μ, f.eigenspace μ) V _ _
+        (@DFinsupp.addCommGroup K (fun μ => f.eigenspace μ) _)]
+    rw [eq_bot_iff]
+    exact this
+  intro l hl
+  -- We apply induction on the finite set of eigenvalues from which `l` selects a nonzero
+  -- eigenvector, i.e. on the support of `l`.
+  induction' h_l_support : l.support using Finset.induction with μ₀ l_support' hμ₀ ih generalizing l
+  -- If the support is empty, all coefficients are zero and we are done.
+  · exact DFinsupp.support_eq_empty.1 h_l_support
+  -- Now assume that the support of `l` contains at least one eigenvalue `μ₀`. We define a new
+  -- collection of representatives `l'` to apply the induction hypothesis on later. The collection
+  -- of representatives `l'` is derived from `l` by multiplying the coefficient of the eigenvector
+  -- with eigenvalue `μ` by `μ - μ₀`.
+  · let l' :=
+      DFinsupp.mapRange.linearMap (fun μ => (μ - μ₀) • @LinearMap.id K (f.eigenspace μ) _ _ _) l
+    -- The support of `l'` is the support of `l` without `μ₀`.
+    have h_l_support' : l'.support = l_support' :=
+      by
+      rw [← Finset.erase_insert hμ₀, ← h_l_support]
+      ext a
+      have : ¬(a = μ₀ ∨ l a = 0) ↔ ¬a = μ₀ ∧ ¬l a = 0 := not_or
+      simp only [l', DFinsupp.mapRange.linearMap_apply, DFinsupp.mapRange_apply,
+        DFinsupp.mem_support_iff, Finset.mem_erase, id.def, LinearMap.id_coe, LinearMap.smul_apply,
+        Ne.def, smul_eq_zero, sub_eq_zero, this]
+    -- The entries of `l'` add up to `0`.
+    have total_l' : S l' = 0 := by
+      let g := f - algebraMap K (End K V) μ₀
+      let a : Π₀ μ : K, V := DFinsupp.mapRange.linearMap (fun μ => (f.eigenspace μ).Subtype) l
+      calc
+        S l' =
+            DFinsupp.lsum ℕ (fun μ => (f.eigenspace μ).Subtype.comp ((μ - μ₀) • LinearMap.id)) l :=
+          _
+        _ = DFinsupp.lsum ℕ (fun μ => g.comp (f.eigenspace μ).Subtype) l := _
+        _ = DFinsupp.lsum ℕ (fun μ => g) a := _
+        _ = g (DFinsupp.lsum ℕ (fun μ => (LinearMap.id : V →ₗ[K] V)) a) := _
+        _ = g (S l) := _
+        _ = 0 := by rw [hl, g.map_zero]
+      · exact DFinsupp.sum_mapRange_index.linearMap
+      · congr
+        ext μ v
+        simp only [g, eq_self_iff_true, Function.comp_apply, id.def, LinearMap.coe_comp,
+          LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply, Module.algebraMap_end_apply,
+          sub_left_inj, sub_smul, Submodule.coe_smul_of_tower, Submodule.coe_sub,
+          Submodule.subtype_apply, mem_eigenspace_iff.1 v.prop]
+      · rw [DFinsupp.sum_mapRange_index.linearMap]
+      ·
+        simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, map_dfinsupp_sum, id.def,
+          LinearMap.toAddMonoidHom_coe, DFinsupp.lsum_apply_apply]
+      · congr
+        simp only [S, a, DFinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
+    -- Therefore, by the induction hypothesis, all entries of `l'` are zero.
+    have l'_eq_0 := ih l' total_l' h_l_support'
+    -- By the definition of `l'`, this means that `(μ - μ₀) • l μ = 0` for all `μ`.
+    have h_smul_eq_0 : ∀ μ, (μ - μ₀) • l μ = 0 :=
+      by
+      intro μ
+      calc
+        (μ - μ₀) • l μ = l' μ := by
+          simp only [l', LinearMap.id_coe, id.def, LinearMap.smul_apply, DFinsupp.mapRange_apply,
+            DFinsupp.mapRange.linearMap_apply]
+        _ = 0 := by rw [l'_eq_0]; rfl
+    -- Thus, the eigenspace-representatives in `l` for all `μ ≠ μ₀` are `0`.
+    have h_lμ_eq_0 : ∀ μ : K, μ ≠ μ₀ → l μ = 0 :=
+      by
+      intro μ hμ
+      apply Classical.or_iff_not_imp_left.1 (smul_eq_zero.1 (h_smul_eq_0 μ))
+      rwa [sub_eq_zero]
+    -- So if we sum over all these representatives, we obtain `0`.
+    have h_sum_l_support'_eq_0 : (Finset.sum l_support' fun μ => (l μ : V)) = 0 :=
+      by
+      rw [← Finset.sum_const_zero]
+      apply Finset.sum_congr rfl
+      intro μ hμ
+      rw [Submodule.coe_eq_zero, h_lμ_eq_0]
+      rintro rfl
+      exact hμ₀ hμ
+    -- The only potentially nonzero eigenspace-representative in `l` is the one corresponding to
+    -- `μ₀`. But since the overall sum is `0` by assumption, this representative must also be `0`.
+    have : l μ₀ = 0 :=
+      by
+      simp only [S, DFinsupp.lsum_apply_apply, DFinsupp.sumAddHom_apply,
+        LinearMap.toAddMonoidHom_coe, DFinsupp.sum, h_l_support, Submodule.subtype_apply,
+        Submodule.coe_eq_zero, Finset.sum_insert hμ₀, h_sum_l_support'_eq_0, add_zero] at hl 
+      exact hl
+    -- Thus, all coefficients in `l` are `0`.
+    show l = 0
+    · ext μ
+      by_cases h_cases : μ = μ₀
+      · rwa [h_cases, SetLike.coe_eq_coe, DFinsupp.coe_zero, Pi.zero_apply]
+      exact congr_arg (coe : _ → V) (h_lμ_eq_0 μ h_cases)
 #align module.End.eigenspaces_independent Module.End.eigenspaces_independent
 -/
 
 #print Module.End.eigenvectors_linearIndependent /-
--- Define an operation from `Π₀ μ : K, f.eigenspace μ`, the vector space of of finitely-supported
--- choices of an eigenvector from each eigenspace, to `V`, by sending a collection to its sum.
--- We need to show that if a finitely-supported collection `l` of representatives of the
--- eigenspaces has sum `0`, then it itself is zero.
--- We apply induction on the finite set of eigenvalues from which `l` selects a nonzero
--- eigenvector, i.e. on the support of `l`.
--- If the support is empty, all coefficients are zero and we are done.
--- Now assume that the support of `l` contains at least one eigenvalue `μ₀`. We define a new
--- collection of representatives `l'` to apply the induction hypothesis on later. The collection
--- of representatives `l'` is derived from `l` by multiplying the coefficient of the eigenvector
--- with eigenvalue `μ` by `μ - μ₀`.
--- The support of `l'` is the support of `l` without `μ₀`.
--- The entries of `l'` add up to `0`.
--- Therefore, by the induction hypothesis, all entries of `l'` are zero.
--- By the definition of `l'`, this means that `(μ - μ₀) • l μ = 0` for all `μ`.
--- Thus, the eigenspace-representatives in `l` for all `μ ≠ μ₀` are `0`.
--- So if we sum over all these representatives, we obtain `0`.
--- The only potentially nonzero eigenspace-representative in `l` is the one corresponding to
--- `μ₀`. But since the overall sum is `0` by assumption, this representative must also be `0`.
--- Thus, all coefficients in `l` are `0`.
 /-- Eigenvectors corresponding to distinct eigenvalues of a linear operator are linearly
     independent. (Lemma 5.10 of [axler2015])
 
Diff
@@ -165,115 +165,30 @@ theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
 any eigenspace has trivial intersection with the span of all the other eigenspaces. -/
 theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.eigenspace := by
   classical
-  -- Define an operation from `Π₀ μ : K, f.eigenspace μ`, the vector space of of finitely-supported
-  -- choices of an eigenvector from each eigenspace, to `V`, by sending a collection to its sum.
-  let S :
-    @LinearMap K K _ _ (RingHom.id K) (Π₀ μ : K, f.eigenspace μ) V
-      (@DFinsupp.addCommMonoid K (fun μ => f.eigenspace μ) _) _
-      (@DFinsupp.module K _ (fun μ => f.eigenspace μ) _ _ _) _ :=
-    @DFinsupp.lsum K K ℕ _ V _ _ _ _ _ _ _ _ _ fun μ => (f.eigenspace μ).Subtype
-  -- We need to show that if a finitely-supported collection `l` of representatives of the
-  -- eigenspaces has sum `0`, then it itself is zero.
-  suffices ∀ l : Π₀ μ, f.eigenspace μ, S l = 0 → l = 0
-    by
-    rw [CompleteLattice.independent_iff_dfinsupp_lsum_injective]
-    change Function.Injective S
-    rw [←
-      @LinearMap.ker_eq_bot K K (Π₀ μ, f.eigenspace μ) V _ _
-        (@DFinsupp.addCommGroup K (fun μ => f.eigenspace μ) _)]
-    rw [eq_bot_iff]
-    exact this
-  intro l hl
-  -- We apply induction on the finite set of eigenvalues from which `l` selects a nonzero
-  -- eigenvector, i.e. on the support of `l`.
-  induction' h_l_support : l.support using Finset.induction with μ₀ l_support' hμ₀ ih generalizing l
-  -- If the support is empty, all coefficients are zero and we are done.
-  · exact DFinsupp.support_eq_empty.1 h_l_support
-  -- Now assume that the support of `l` contains at least one eigenvalue `μ₀`. We define a new
-  -- collection of representatives `l'` to apply the induction hypothesis on later. The collection
-  -- of representatives `l'` is derived from `l` by multiplying the coefficient of the eigenvector
-  -- with eigenvalue `μ` by `μ - μ₀`.
-  · let l' :=
-      DFinsupp.mapRange.linearMap (fun μ => (μ - μ₀) • @LinearMap.id K (f.eigenspace μ) _ _ _) l
-    -- The support of `l'` is the support of `l` without `μ₀`.
-    have h_l_support' : l'.support = l_support' :=
-      by
-      rw [← Finset.erase_insert hμ₀, ← h_l_support]
-      ext a
-      have : ¬(a = μ₀ ∨ l a = 0) ↔ ¬a = μ₀ ∧ ¬l a = 0 := not_or
-      simp only [l', DFinsupp.mapRange.linearMap_apply, DFinsupp.mapRange_apply,
-        DFinsupp.mem_support_iff, Finset.mem_erase, id.def, LinearMap.id_coe, LinearMap.smul_apply,
-        Ne.def, smul_eq_zero, sub_eq_zero, this]
-    -- The entries of `l'` add up to `0`.
-    have total_l' : S l' = 0 := by
-      let g := f - algebraMap K (End K V) μ₀
-      let a : Π₀ μ : K, V := DFinsupp.mapRange.linearMap (fun μ => (f.eigenspace μ).Subtype) l
-      calc
-        S l' =
-            DFinsupp.lsum ℕ (fun μ => (f.eigenspace μ).Subtype.comp ((μ - μ₀) • LinearMap.id)) l :=
-          _
-        _ = DFinsupp.lsum ℕ (fun μ => g.comp (f.eigenspace μ).Subtype) l := _
-        _ = DFinsupp.lsum ℕ (fun μ => g) a := _
-        _ = g (DFinsupp.lsum ℕ (fun μ => (LinearMap.id : V →ₗ[K] V)) a) := _
-        _ = g (S l) := _
-        _ = 0 := by rw [hl, g.map_zero]
-      · exact DFinsupp.sum_mapRange_index.linearMap
-      · congr
-        ext μ v
-        simp only [g, eq_self_iff_true, Function.comp_apply, id.def, LinearMap.coe_comp,
-          LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply, Module.algebraMap_end_apply,
-          sub_left_inj, sub_smul, Submodule.coe_smul_of_tower, Submodule.coe_sub,
-          Submodule.subtype_apply, mem_eigenspace_iff.1 v.prop]
-      · rw [DFinsupp.sum_mapRange_index.linearMap]
-      ·
-        simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, map_dfinsupp_sum, id.def,
-          LinearMap.toAddMonoidHom_coe, DFinsupp.lsum_apply_apply]
-      · congr
-        simp only [S, a, DFinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
-    -- Therefore, by the induction hypothesis, all entries of `l'` are zero.
-    have l'_eq_0 := ih l' total_l' h_l_support'
-    -- By the definition of `l'`, this means that `(μ - μ₀) • l μ = 0` for all `μ`.
-    have h_smul_eq_0 : ∀ μ, (μ - μ₀) • l μ = 0 :=
-      by
-      intro μ
-      calc
-        (μ - μ₀) • l μ = l' μ := by
-          simp only [l', LinearMap.id_coe, id.def, LinearMap.smul_apply, DFinsupp.mapRange_apply,
-            DFinsupp.mapRange.linearMap_apply]
-        _ = 0 := by rw [l'_eq_0]; rfl
-    -- Thus, the eigenspace-representatives in `l` for all `μ ≠ μ₀` are `0`.
-    have h_lμ_eq_0 : ∀ μ : K, μ ≠ μ₀ → l μ = 0 :=
-      by
-      intro μ hμ
-      apply Classical.or_iff_not_imp_left.1 (smul_eq_zero.1 (h_smul_eq_0 μ))
-      rwa [sub_eq_zero]
-    -- So if we sum over all these representatives, we obtain `0`.
-    have h_sum_l_support'_eq_0 : (Finset.sum l_support' fun μ => (l μ : V)) = 0 :=
-      by
-      rw [← Finset.sum_const_zero]
-      apply Finset.sum_congr rfl
-      intro μ hμ
-      rw [Submodule.coe_eq_zero, h_lμ_eq_0]
-      rintro rfl
-      exact hμ₀ hμ
-    -- The only potentially nonzero eigenspace-representative in `l` is the one corresponding to
-    -- `μ₀`. But since the overall sum is `0` by assumption, this representative must also be `0`.
-    have : l μ₀ = 0 :=
-      by
-      simp only [S, DFinsupp.lsum_apply_apply, DFinsupp.sumAddHom_apply,
-        LinearMap.toAddMonoidHom_coe, DFinsupp.sum, h_l_support, Submodule.subtype_apply,
-        Submodule.coe_eq_zero, Finset.sum_insert hμ₀, h_sum_l_support'_eq_0, add_zero] at hl 
-      exact hl
-    -- Thus, all coefficients in `l` are `0`.
-    show l = 0
-    · ext μ
-      by_cases h_cases : μ = μ₀
-      · rwa [h_cases, SetLike.coe_eq_coe, DFinsupp.coe_zero, Pi.zero_apply]
-      exact congr_arg (coe : _ → V) (h_lμ_eq_0 μ h_cases)
 #align module.End.eigenspaces_independent Module.End.eigenspaces_independent
 -/
 
 #print Module.End.eigenvectors_linearIndependent /-
+-- Define an operation from `Π₀ μ : K, f.eigenspace μ`, the vector space of of finitely-supported
+-- choices of an eigenvector from each eigenspace, to `V`, by sending a collection to its sum.
+-- We need to show that if a finitely-supported collection `l` of representatives of the
+-- eigenspaces has sum `0`, then it itself is zero.
+-- We apply induction on the finite set of eigenvalues from which `l` selects a nonzero
+-- eigenvector, i.e. on the support of `l`.
+-- If the support is empty, all coefficients are zero and we are done.
+-- Now assume that the support of `l` contains at least one eigenvalue `μ₀`. We define a new
+-- collection of representatives `l'` to apply the induction hypothesis on later. The collection
+-- of representatives `l'` is derived from `l` by multiplying the coefficient of the eigenvector
+-- with eigenvalue `μ` by `μ - μ₀`.
+-- The support of `l'` is the support of `l` without `μ₀`.
+-- The entries of `l'` add up to `0`.
+-- Therefore, by the induction hypothesis, all entries of `l'` are zero.
+-- By the definition of `l'`, this means that `(μ - μ₀) • l μ = 0` for all `μ`.
+-- Thus, the eigenspace-representatives in `l` for all `μ ≠ μ₀` are `0`.
+-- So if we sum over all these representatives, we obtain `0`.
+-- The only potentially nonzero eigenspace-representative in `l` is the one corresponding to
+-- `μ₀`. But since the overall sum is `0` by assumption, this representative must also be `0`.
+-- Thus, all coefficients in `l` are `0`.
 /-- Eigenvectors corresponding to distinct eigenvalues of a linear operator are linearly
     independent. (Lemma 5.10 of [axler2015])
 
Diff
@@ -245,7 +245,7 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
     have h_lμ_eq_0 : ∀ μ : K, μ ≠ μ₀ → l μ = 0 :=
       by
       intro μ hμ
-      apply or_iff_not_imp_left.1 (smul_eq_zero.1 (h_smul_eq_0 μ))
+      apply Classical.or_iff_not_imp_left.1 (smul_eq_zero.1 (h_smul_eq_0 μ))
       rwa [sub_eq_zero]
     -- So if we sum over all these representatives, we obtain `0`.
     have h_sum_l_support'_eq_0 : (Finset.sum l_support' fun μ => (l μ : V)) = 0 :=
Diff
@@ -3,9 +3,9 @@ Copyright (c) 2020 Alexander Bentkamp. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
 -/
-import Mathbin.Algebra.Algebra.Spectrum
-import Mathbin.LinearAlgebra.GeneralLinearGroup
-import Mathbin.LinearAlgebra.FiniteDimensional
+import Algebra.Algebra.Spectrum
+import LinearAlgebra.GeneralLinearGroup
+import LinearAlgebra.FiniteDimensional
 
 #align_import linear_algebra.eigenspace.basic from "leanprover-community/mathlib"@"6b31d1eebd64eab86d5bd9936bfaada6ca8b5842"
 
Diff
@@ -226,7 +226,7 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
           Submodule.subtype_apply, mem_eigenspace_iff.1 v.prop]
       · rw [DFinsupp.sum_mapRange_index.linearMap]
       ·
-        simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, LinearMap.map_dFinsupp_sum, id.def,
+        simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, map_dfinsupp_sum, id.def,
           LinearMap.toAddMonoidHom_coe, DFinsupp.lsum_apply_apply]
       · congr
         simp only [S, a, DFinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
Diff
@@ -226,7 +226,7 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
           Submodule.subtype_apply, mem_eigenspace_iff.1 v.prop]
       · rw [DFinsupp.sum_mapRange_index.linearMap]
       ·
-        simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, LinearMap.map_dfinsupp_sum, id.def,
+        simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, LinearMap.map_dFinsupp_sum, id.def,
           LinearMap.toAddMonoidHom_coe, DFinsupp.lsum_apply_apply]
       · congr
         simp only [S, a, DFinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
Diff
@@ -422,7 +422,7 @@ theorem hasGeneralizedEigenvalue_of_hasEigenvalue {f : End R M} {μ : R} {k : 
     (hμ : f.HasEigenvalue μ) : f.HasGeneralizedEigenvalue μ k :=
   by
   apply has_generalized_eigenvalue_of_has_generalized_eigenvalue_of_le hk
-  rw [has_generalized_eigenvalue, generalized_eigenspace, OrderHom.coe_fun_mk, pow_one]
+  rw [has_generalized_eigenvalue, generalized_eigenspace, OrderHom.coe_mk, pow_one]
   exact hμ
 #align module.End.has_generalized_eigenvalue_of_has_eigenvalue Module.End.hasGeneralizedEigenvalue_of_hasEigenvalue
 -/
@@ -473,7 +473,7 @@ theorem generalizedEigenspace_restrict (f : End R M) (p : Submodule R M) (k : 
     generalizedEigenspace (LinearMap.restrict f hfp) μ k =
       Submodule.comap p.Subtype (f.generalizedEigenspace μ k) :=
   by
-  simp only [generalized_eigenspace, OrderHom.coe_fun_mk, ← LinearMap.ker_comp]
+  simp only [generalized_eigenspace, OrderHom.coe_mk, ← LinearMap.ker_comp]
   induction' k with k ih
   · rw [pow_zero, pow_zero, LinearMap.one_eq_id]
     apply (Submodule.ker_subtype _).symm
@@ -506,7 +506,7 @@ theorem generalized_eigenvec_disjoint_range_ker [FiniteDimensional K V] (f : End
             (f.generalized_eigenspace μ (finrank K V)) =
           ((f - algebraMap _ _ μ) ^ finrank K V *
               (f - algebraMap K (End K V) μ) ^ finrank K V).ker :=
-        by simpa only [generalized_eigenspace, OrderHom.coe_fun_mk, ← LinearMap.ker_comp]
+        by simpa only [generalized_eigenspace, OrderHom.coe_mk, ← LinearMap.ker_comp]
       _ = f.generalized_eigenspace μ (finrank K V + finrank K V) := by rw [← pow_add]; rfl
       _ = f.generalized_eigenspace μ (finrank K V) := by
         rw [generalized_eigenspace_eq_generalized_eigenspace_finrank_of_le]; linarith
Diff
@@ -2,16 +2,13 @@
 Copyright (c) 2020 Alexander Bentkamp. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
-
-! This file was ported from Lean 3 source module linear_algebra.eigenspace.basic
-! leanprover-community/mathlib commit 6b31d1eebd64eab86d5bd9936bfaada6ca8b5842
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Algebra.Algebra.Spectrum
 import Mathbin.LinearAlgebra.GeneralLinearGroup
 import Mathbin.LinearAlgebra.FiniteDimensional
 
+#align_import linear_algebra.eigenspace.basic from "leanprover-community/mathlib"@"6b31d1eebd64eab86d5bd9936bfaada6ca8b5842"
+
 /-!
 # Eigenvectors and eigenvalues
 
Diff
@@ -172,9 +172,9 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
   -- choices of an eigenvector from each eigenspace, to `V`, by sending a collection to its sum.
   let S :
     @LinearMap K K _ _ (RingHom.id K) (Π₀ μ : K, f.eigenspace μ) V
-      (@Dfinsupp.addCommMonoid K (fun μ => f.eigenspace μ) _) _
-      (@Dfinsupp.module K _ (fun μ => f.eigenspace μ) _ _ _) _ :=
-    @Dfinsupp.lsum K K ℕ _ V _ _ _ _ _ _ _ _ _ fun μ => (f.eigenspace μ).Subtype
+      (@DFinsupp.addCommMonoid K (fun μ => f.eigenspace μ) _) _
+      (@DFinsupp.module K _ (fun μ => f.eigenspace μ) _ _ _) _ :=
+    @DFinsupp.lsum K K ℕ _ V _ _ _ _ _ _ _ _ _ fun μ => (f.eigenspace μ).Subtype
   -- We need to show that if a finitely-supported collection `l` of representatives of the
   -- eigenspaces has sum `0`, then it itself is zero.
   suffices ∀ l : Π₀ μ, f.eigenspace μ, S l = 0 → l = 0
@@ -183,7 +183,7 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
     change Function.Injective S
     rw [←
       @LinearMap.ker_eq_bot K K (Π₀ μ, f.eigenspace μ) V _ _
-        (@Dfinsupp.addCommGroup K (fun μ => f.eigenspace μ) _)]
+        (@DFinsupp.addCommGroup K (fun μ => f.eigenspace μ) _)]
     rw [eq_bot_iff]
     exact this
   intro l hl
@@ -191,48 +191,48 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
   -- eigenvector, i.e. on the support of `l`.
   induction' h_l_support : l.support using Finset.induction with μ₀ l_support' hμ₀ ih generalizing l
   -- If the support is empty, all coefficients are zero and we are done.
-  · exact Dfinsupp.support_eq_empty.1 h_l_support
+  · exact DFinsupp.support_eq_empty.1 h_l_support
   -- Now assume that the support of `l` contains at least one eigenvalue `μ₀`. We define a new
   -- collection of representatives `l'` to apply the induction hypothesis on later. The collection
   -- of representatives `l'` is derived from `l` by multiplying the coefficient of the eigenvector
   -- with eigenvalue `μ` by `μ - μ₀`.
   · let l' :=
-      Dfinsupp.mapRange.linearMap (fun μ => (μ - μ₀) • @LinearMap.id K (f.eigenspace μ) _ _ _) l
+      DFinsupp.mapRange.linearMap (fun μ => (μ - μ₀) • @LinearMap.id K (f.eigenspace μ) _ _ _) l
     -- The support of `l'` is the support of `l` without `μ₀`.
     have h_l_support' : l'.support = l_support' :=
       by
       rw [← Finset.erase_insert hμ₀, ← h_l_support]
       ext a
       have : ¬(a = μ₀ ∨ l a = 0) ↔ ¬a = μ₀ ∧ ¬l a = 0 := not_or
-      simp only [l', Dfinsupp.mapRange.linearMap_apply, Dfinsupp.mapRange_apply,
-        Dfinsupp.mem_support_iff, Finset.mem_erase, id.def, LinearMap.id_coe, LinearMap.smul_apply,
+      simp only [l', DFinsupp.mapRange.linearMap_apply, DFinsupp.mapRange_apply,
+        DFinsupp.mem_support_iff, Finset.mem_erase, id.def, LinearMap.id_coe, LinearMap.smul_apply,
         Ne.def, smul_eq_zero, sub_eq_zero, this]
     -- The entries of `l'` add up to `0`.
     have total_l' : S l' = 0 := by
       let g := f - algebraMap K (End K V) μ₀
-      let a : Π₀ μ : K, V := Dfinsupp.mapRange.linearMap (fun μ => (f.eigenspace μ).Subtype) l
+      let a : Π₀ μ : K, V := DFinsupp.mapRange.linearMap (fun μ => (f.eigenspace μ).Subtype) l
       calc
         S l' =
-            Dfinsupp.lsum ℕ (fun μ => (f.eigenspace μ).Subtype.comp ((μ - μ₀) • LinearMap.id)) l :=
+            DFinsupp.lsum ℕ (fun μ => (f.eigenspace μ).Subtype.comp ((μ - μ₀) • LinearMap.id)) l :=
           _
-        _ = Dfinsupp.lsum ℕ (fun μ => g.comp (f.eigenspace μ).Subtype) l := _
-        _ = Dfinsupp.lsum ℕ (fun μ => g) a := _
-        _ = g (Dfinsupp.lsum ℕ (fun μ => (LinearMap.id : V →ₗ[K] V)) a) := _
+        _ = DFinsupp.lsum ℕ (fun μ => g.comp (f.eigenspace μ).Subtype) l := _
+        _ = DFinsupp.lsum ℕ (fun μ => g) a := _
+        _ = g (DFinsupp.lsum ℕ (fun μ => (LinearMap.id : V →ₗ[K] V)) a) := _
         _ = g (S l) := _
         _ = 0 := by rw [hl, g.map_zero]
-      · exact Dfinsupp.sum_mapRange_index.linearMap
+      · exact DFinsupp.sum_mapRange_index.linearMap
       · congr
         ext μ v
         simp only [g, eq_self_iff_true, Function.comp_apply, id.def, LinearMap.coe_comp,
           LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply, Module.algebraMap_end_apply,
           sub_left_inj, sub_smul, Submodule.coe_smul_of_tower, Submodule.coe_sub,
           Submodule.subtype_apply, mem_eigenspace_iff.1 v.prop]
-      · rw [Dfinsupp.sum_mapRange_index.linearMap]
+      · rw [DFinsupp.sum_mapRange_index.linearMap]
       ·
-        simp only [Dfinsupp.sumAddHom_apply, LinearMap.id_coe, LinearMap.map_dfinsupp_sum, id.def,
-          LinearMap.toAddMonoidHom_coe, Dfinsupp.lsum_apply_apply]
+        simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, LinearMap.map_dfinsupp_sum, id.def,
+          LinearMap.toAddMonoidHom_coe, DFinsupp.lsum_apply_apply]
       · congr
-        simp only [S, a, Dfinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
+        simp only [S, a, DFinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
     -- Therefore, by the induction hypothesis, all entries of `l'` are zero.
     have l'_eq_0 := ih l' total_l' h_l_support'
     -- By the definition of `l'`, this means that `(μ - μ₀) • l μ = 0` for all `μ`.
@@ -241,8 +241,8 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
       intro μ
       calc
         (μ - μ₀) • l μ = l' μ := by
-          simp only [l', LinearMap.id_coe, id.def, LinearMap.smul_apply, Dfinsupp.mapRange_apply,
-            Dfinsupp.mapRange.linearMap_apply]
+          simp only [l', LinearMap.id_coe, id.def, LinearMap.smul_apply, DFinsupp.mapRange_apply,
+            DFinsupp.mapRange.linearMap_apply]
         _ = 0 := by rw [l'_eq_0]; rfl
     -- Thus, the eigenspace-representatives in `l` for all `μ ≠ μ₀` are `0`.
     have h_lμ_eq_0 : ∀ μ : K, μ ≠ μ₀ → l μ = 0 :=
@@ -263,15 +263,15 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
     -- `μ₀`. But since the overall sum is `0` by assumption, this representative must also be `0`.
     have : l μ₀ = 0 :=
       by
-      simp only [S, Dfinsupp.lsum_apply_apply, Dfinsupp.sumAddHom_apply,
-        LinearMap.toAddMonoidHom_coe, Dfinsupp.sum, h_l_support, Submodule.subtype_apply,
+      simp only [S, DFinsupp.lsum_apply_apply, DFinsupp.sumAddHom_apply,
+        LinearMap.toAddMonoidHom_coe, DFinsupp.sum, h_l_support, Submodule.subtype_apply,
         Submodule.coe_eq_zero, Finset.sum_insert hμ₀, h_sum_l_support'_eq_0, add_zero] at hl 
       exact hl
     -- Thus, all coefficients in `l` are `0`.
     show l = 0
     · ext μ
       by_cases h_cases : μ = μ₀
-      · rwa [h_cases, SetLike.coe_eq_coe, Dfinsupp.coe_zero, Pi.zero_apply]
+      · rwa [h_cases, SetLike.coe_eq_coe, DFinsupp.coe_zero, Pi.zero_apply]
       exact congr_arg (coe : _ → V) (h_lμ_eq_0 μ h_cases)
 #align module.End.eigenspaces_independent Module.End.eigenspaces_independent
 -/
Diff
@@ -222,7 +222,7 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
         _ = 0 := by rw [hl, g.map_zero]
       · exact Dfinsupp.sum_mapRange_index.linearMap
       · congr
-        ext (μ v)
+        ext μ v
         simp only [g, eq_self_iff_true, Function.comp_apply, id.def, LinearMap.coe_comp,
           LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply, Module.algebraMap_end_apply,
           sub_left_inj, sub_smul, Submodule.coe_smul_of_tower, Submodule.coe_sub,
Diff
@@ -72,9 +72,11 @@ def eigenspace (f : End R M) (μ : R) : Submodule R M :=
 #align module.End.eigenspace Module.End.eigenspace
 -/
 
+#print Module.End.eigenspace_zero /-
 @[simp]
 theorem eigenspace_zero (f : End R M) : f.eigenspace 0 = f.ker := by simp [eigenspace]
 #align module.End.eigenspace_zero Module.End.eigenspace_zero
+-/
 
 #print Module.End.HasEigenvector /-
 /-- A nonzero element of an eigenspace is an eigenvector. (Def 5.7 of [axler2015]) -/
@@ -109,14 +111,18 @@ theorem hasEigenvalue_of_hasEigenvector {f : End R M} {μ : R} {x : M} (h : HasE
 #align module.End.has_eigenvalue_of_has_eigenvector Module.End.hasEigenvalue_of_hasEigenvector
 -/
 
+#print Module.End.mem_eigenspace_iff /-
 theorem mem_eigenspace_iff {f : End R M} {μ : R} {x : M} : x ∈ eigenspace f μ ↔ f x = μ • x := by
   rw [eigenspace, LinearMap.mem_ker, LinearMap.sub_apply, algebra_map_End_apply, sub_eq_zero]
 #align module.End.mem_eigenspace_iff Module.End.mem_eigenspace_iff
+-/
 
+#print Module.End.HasEigenvector.apply_eq_smul /-
 theorem HasEigenvector.apply_eq_smul {f : End R M} {μ : R} {x : M} (hx : f.HasEigenvector μ x) :
     f x = μ • x :=
   mem_eigenspace_iff.mp hx.1
 #align module.End.has_eigenvector.apply_eq_smul Module.End.HasEigenvector.apply_eq_smul
+-/
 
 #print Module.End.HasEigenvalue.exists_hasEigenvector /-
 theorem HasEigenvalue.exists_hasEigenvector {f : End R M} {μ : R} (hμ : f.HasEigenvalue μ) :
@@ -125,6 +131,7 @@ theorem HasEigenvalue.exists_hasEigenvector {f : End R M} {μ : R} (hμ : f.HasE
 #align module.End.has_eigenvalue.exists_has_eigenvector Module.End.HasEigenvalue.exists_hasEigenvector
 -/
 
+#print Module.End.mem_spectrum_of_hasEigenvalue /-
 theorem mem_spectrum_of_hasEigenvalue {f : End R M} {μ : R} (hμ : HasEigenvalue f μ) :
     μ ∈ spectrum R f := by
   refine' spectrum.mem_iff.mpr fun h_unit => _
@@ -133,13 +140,17 @@ theorem mem_spectrum_of_hasEigenvalue {f : End R M} {μ : R} (hμ : HasEigenvalu
   refine' hv.2 ((linear_map.ker_eq_bot'.mp f'.ker) v (_ : μ • v - f v = 0))
   rw [hv.apply_eq_smul, sub_self]
 #align module.End.mem_spectrum_of_has_eigenvalue Module.End.mem_spectrum_of_hasEigenvalue
+-/
 
+#print Module.End.hasEigenvalue_iff_mem_spectrum /-
 theorem hasEigenvalue_iff_mem_spectrum [FiniteDimensional K V] {f : End K V} {μ : K} :
     f.HasEigenvalue μ ↔ μ ∈ spectrum K f :=
   Iff.intro mem_spectrum_of_hasEigenvalue fun h => by
     rwa [spectrum.mem_iff, IsUnit.sub_iff, LinearMap.isUnit_iff_ker_eq_bot] at h 
 #align module.End.has_eigenvalue_iff_mem_spectrum Module.End.hasEigenvalue_iff_mem_spectrum
+-/
 
+#print Module.End.eigenspace_div /-
 theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
     eigenspace f (a / b) = (b • f - algebraMap K (End K V) a).ker :=
   calc
@@ -150,6 +161,7 @@ theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
     _ = (b • (f - b⁻¹ • algebraMap K (End K V) a)).ker := by rw [LinearMap.ker_smul _ b hb]
     _ = (b • f - algebraMap K (End K V) a).ker := by rw [smul_sub, smul_inv_smul₀ hb]
 #align module.End.eigenspace_div Module.End.eigenspace_div
+-/
 
 #print Module.End.eigenspaces_independent /-
 /-- The eigenspaces of a linear operator form an independent family of subspaces of `V`.  That is,
@@ -293,16 +305,20 @@ def generalizedEigenspace (f : End R M) (μ : R) : ℕ →o Submodule R M
 #align module.End.generalized_eigenspace Module.End.generalizedEigenspace
 -/
 
+#print Module.End.mem_generalizedEigenspace /-
 @[simp]
 theorem mem_generalizedEigenspace (f : End R M) (μ : R) (k : ℕ) (m : M) :
     m ∈ f.generalizedEigenspace μ k ↔ ((f - μ • 1) ^ k) m = 0 :=
   Iff.rfl
 #align module.End.mem_generalized_eigenspace Module.End.mem_generalizedEigenspace
+-/
 
+#print Module.End.generalizedEigenspace_zero /-
 @[simp]
 theorem generalizedEigenspace_zero (f : End R M) (k : ℕ) :
     f.generalizedEigenspace 0 k = (f ^ k).ker := by simp [Module.End.generalizedEigenspace]
 #align module.End.generalized_eigenspace_zero Module.End.generalizedEigenspace_zero
+-/
 
 #print Module.End.HasGeneralizedEigenvector /-
 /-- A nonzero element of a generalized eigenspace is a generalized eigenvector.
@@ -352,12 +368,14 @@ theorem generalizedEigenspace_le_maximal (f : End R M) (μ : R) (k : ℕ) :
 #align module.End.generalized_eigenspace_le_maximal Module.End.generalizedEigenspace_le_maximal
 -/
 
+#print Module.End.mem_maximalGeneralizedEigenspace /-
 @[simp]
 theorem mem_maximalGeneralizedEigenspace (f : End R M) (μ : R) (m : M) :
     m ∈ f.maximalGeneralizedEigenspace μ ↔ ∃ k : ℕ, ((f - μ • 1) ^ k) m = 0 := by
   simp only [maximal_generalized_eigenspace, ← mem_generalized_eigenspace,
     Submodule.mem_iSup_of_chain]
 #align module.End.mem_maximal_generalized_eigenspace Module.End.mem_maximalGeneralizedEigenspace
+-/
 
 #print Module.End.maximalGeneralizedEigenspaceIndex /-
 /-- If there exists a natural number `k` such that the kernel of `(f - μ • id) ^ k` is the
@@ -450,6 +468,7 @@ theorem generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le [FiniteDime
 #align module.End.generalized_eigenspace_eq_generalized_eigenspace_finrank_of_le Module.End.generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le
 -/
 
+#print Module.End.generalizedEigenspace_restrict /-
 /-- If `f` maps a subspace `p` into itself, then the generalized eigenspace of the restriction
     of `f` to `p` is the part of the generalized eigenspace of `f` that lies in `p`. -/
 theorem generalizedEigenspace_restrict (f : End R M) (p : Submodule R M) (k : ℕ) (μ : R)
@@ -465,7 +484,9 @@ theorem generalizedEigenspace_restrict (f : End R M) (p : Submodule R M) (k : 
     erw [pow_succ', pow_succ', LinearMap.ker_comp, LinearMap.ker_comp, ih, ← LinearMap.ker_comp,
       LinearMap.comp_assoc]
 #align module.End.generalized_eigenspace_restrict Module.End.generalizedEigenspace_restrict
+-/
 
+#print Module.End.eigenspace_restrict_le_eigenspace /-
 /-- If `p` is an invariant submodule of an endomorphism `f`, then the `μ`-eigenspace of the
 restriction of `f` to `p` is a submodule of the `μ`-eigenspace of `f`. -/
 theorem eigenspace_restrict_le_eigenspace (f : End R M) {p : Submodule R M} (hfp : ∀ x ∈ p, f x ∈ p)
@@ -475,7 +496,9 @@ theorem eigenspace_restrict_le_eigenspace (f : End R M) {p : Submodule R M} (hfp
   simp only [SetLike.mem_coe, mem_eigenspace_iff, LinearMap.restrict_apply] at hx ⊢
   exact congr_arg coe hx
 #align module.End.eigenspace_restrict_le_eigenspace Module.End.eigenspace_restrict_le_eigenspace
+-/
 
+#print Module.End.generalized_eigenvec_disjoint_range_ker /-
 /-- Generalized eigenrange and generalized eigenspace for exponent `finrank K V` are disjoint. -/
 theorem generalized_eigenvec_disjoint_range_ker [FiniteDimensional K V] (f : End K V) (μ : K) :
     Disjoint (f.generalizedEigenrange μ (finrank K V)) (f.generalizedEigenspace μ (finrank K V)) :=
@@ -494,7 +517,9 @@ theorem generalized_eigenvec_disjoint_range_ker [FiniteDimensional K V] (f : End
     Submodule.map_inf_eq_map_inf_comap, top_inf_eq, h]
   apply Submodule.map_comap_le
 #align module.End.generalized_eigenvec_disjoint_range_ker Module.End.generalized_eigenvec_disjoint_range_ker
+-/
 
+#print Module.End.eigenspace_restrict_eq_bot /-
 /-- If an invariant subspace `p` of an endomorphism `f` is disjoint from the `μ`-eigenspace of `f`,
 then the restriction of `f` to `p` has trivial `μ`-eigenspace. -/
 theorem eigenspace_restrict_eq_bot {f : End R M} {p : Submodule R M} (hfp : ∀ x ∈ p, f x ∈ p)
@@ -504,6 +529,7 @@ theorem eigenspace_restrict_eq_bot {f : End R M} {p : Submodule R M} (hfp : ∀
   intro x hx
   simpa using hμp.le_bot ⟨eigenspace_restrict_le_eigenspace f hfp μ ⟨x, hx, rfl⟩, x.prop⟩
 #align module.End.eigenspace_restrict_eq_bot Module.End.eigenspace_restrict_eq_bot
+-/
 
 #print Module.End.pos_finrank_generalizedEigenspace_of_hasEigenvalue /-
 /-- The generalized eigenspace of an eigenvalue has positive dimension for positive exponents. -/
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
 
 ! This file was ported from Lean 3 source module linear_algebra.eigenspace.basic
-! leanprover-community/mathlib commit 6b0169218d01f2837d79ea2784882009a0da1aa1
+! leanprover-community/mathlib commit 6b31d1eebd64eab86d5bd9936bfaada6ca8b5842
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -15,6 +15,9 @@ import Mathbin.LinearAlgebra.FiniteDimensional
 /-!
 # Eigenvectors and eigenvalues
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 This file defines eigenspaces, eigenvalues, and eigenvalues, as well as their generalized
 counterparts. We follow Axler's approach [axler2015] because it allows us to derive many properties
 without choosing a basis and without using matrices.
Diff
@@ -146,7 +146,6 @@ theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
     _ = (f - b⁻¹ • algebraMap K (End K V) a).ker := rfl
     _ = (b • (f - b⁻¹ • algebraMap K (End K V) a)).ker := by rw [LinearMap.ker_smul _ b hb]
     _ = (b • f - algebraMap K (End K V) a).ker := by rw [smul_sub, smul_inv_smul₀ hb]
-    
 #align module.End.eigenspace_div Module.End.eigenspace_div
 
 #print Module.End.eigenspaces_independent /-
@@ -206,7 +205,6 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
         _ = g (Dfinsupp.lsum ℕ (fun μ => (LinearMap.id : V →ₗ[K] V)) a) := _
         _ = g (S l) := _
         _ = 0 := by rw [hl, g.map_zero]
-        
       · exact Dfinsupp.sum_mapRange_index.linearMap
       · congr
         ext (μ v)
@@ -231,7 +229,6 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
           simp only [l', LinearMap.id_coe, id.def, LinearMap.smul_apply, Dfinsupp.mapRange_apply,
             Dfinsupp.mapRange.linearMap_apply]
         _ = 0 := by rw [l'_eq_0]; rfl
-        
     -- Thus, the eigenspace-representatives in `l` for all `μ ≠ μ₀` are `0`.
     have h_lμ_eq_0 : ∀ μ : K, μ ≠ μ₀ → l μ = 0 :=
       by
@@ -490,7 +487,6 @@ theorem generalized_eigenvec_disjoint_range_ker [FiniteDimensional K V] (f : End
       _ = f.generalized_eigenspace μ (finrank K V + finrank K V) := by rw [← pow_add]; rfl
       _ = f.generalized_eigenspace μ (finrank K V) := by
         rw [generalized_eigenspace_eq_generalized_eigenspace_finrank_of_le]; linarith
-      
   rw [disjoint_iff_inf_le, generalized_eigenrange, LinearMap.range_eq_map,
     Submodule.map_inf_eq_map_inf_comap, top_inf_eq, h]
   apply Submodule.map_comap_le
@@ -516,7 +512,6 @@ theorem pos_finrank_generalizedEigenspace_of_hasEigenvalue [FiniteDimensional K
     _ < finrank K (f.eigenspace μ) := (Submodule.finrank_lt_finrank_of_lt (bot_lt_iff_ne_bot.2 hx))
     _ ≤ finrank K (f.generalizedEigenspace μ k) :=
       Submodule.finrank_mono ((f.generalizedEigenspace μ).Monotone (Nat.succ_le_of_lt hk))
-    
 #align module.End.pos_finrank_generalized_eigenspace_of_has_eigenvalue Module.End.pos_finrank_generalizedEigenspace_of_hasEigenvalue
 -/
 
@@ -530,7 +525,6 @@ theorem map_generalizedEigenrange_le {f : End K V} {μ : K} {n : ℕ} :
     _ = ((f - algebraMap _ _ μ) ^ n * f).range := by rw [Algebra.mul_sub_algebraMap_pow_commutes]
     _ = Submodule.map ((f - algebraMap _ _ μ) ^ n) f.range := (LinearMap.range_comp _ _)
     _ ≤ f.generalizedEigenrange μ n := LinearMap.map_le_range
-    
 #align module.End.map_generalized_eigenrange_le Module.End.map_generalizedEigenrange_le
 -/
 
Diff
@@ -61,40 +61,50 @@ open FiniteDimensional
 variable {K R : Type v} {V M : Type w} [CommRing R] [AddCommGroup M] [Module R M] [Field K]
   [AddCommGroup V] [Module K V]
 
+#print Module.End.eigenspace /-
 /-- The submodule `eigenspace f μ` for a linear map `f` and a scalar `μ` consists of all vectors `x`
     such that `f x = μ • x`. (Def 5.36 of [axler2015])-/
 def eigenspace (f : End R M) (μ : R) : Submodule R M :=
   (f - algebraMap R (End R M) μ).ker
 #align module.End.eigenspace Module.End.eigenspace
+-/
 
 @[simp]
 theorem eigenspace_zero (f : End R M) : f.eigenspace 0 = f.ker := by simp [eigenspace]
 #align module.End.eigenspace_zero Module.End.eigenspace_zero
 
+#print Module.End.HasEigenvector /-
 /-- A nonzero element of an eigenspace is an eigenvector. (Def 5.7 of [axler2015]) -/
 def HasEigenvector (f : End R M) (μ : R) (x : M) : Prop :=
   x ∈ eigenspace f μ ∧ x ≠ 0
 #align module.End.has_eigenvector Module.End.HasEigenvector
+-/
 
+#print Module.End.HasEigenvalue /-
 /-- A scalar `μ` is an eigenvalue for a linear map `f` if there are nonzero vectors `x`
     such that `f x = μ • x`. (Def 5.5 of [axler2015]) -/
 def HasEigenvalue (f : End R M) (a : R) : Prop :=
   eigenspace f a ≠ ⊥
 #align module.End.has_eigenvalue Module.End.HasEigenvalue
+-/
 
+#print Module.End.Eigenvalues /-
 /-- The eigenvalues of the endomorphism `f`, as a subtype of `R`. -/
 def Eigenvalues (f : End R M) : Type _ :=
   { μ : R // f.HasEigenvalue μ }
 #align module.End.eigenvalues Module.End.Eigenvalues
+-/
 
 instance (f : End R M) : Coe f.Eigenvalues R :=
   coeSubtype
 
+#print Module.End.hasEigenvalue_of_hasEigenvector /-
 theorem hasEigenvalue_of_hasEigenvector {f : End R M} {μ : R} {x : M} (h : HasEigenvector f μ x) :
     HasEigenvalue f μ := by
   rw [has_eigenvalue, Submodule.ne_bot_iff]
   use x; exact h
 #align module.End.has_eigenvalue_of_has_eigenvector Module.End.hasEigenvalue_of_hasEigenvector
+-/
 
 theorem mem_eigenspace_iff {f : End R M} {μ : R} {x : M} : x ∈ eigenspace f μ ↔ f x = μ • x := by
   rw [eigenspace, LinearMap.mem_ker, LinearMap.sub_apply, algebra_map_End_apply, sub_eq_zero]
@@ -105,10 +115,12 @@ theorem HasEigenvector.apply_eq_smul {f : End R M} {μ : R} {x : M} (hx : f.HasE
   mem_eigenspace_iff.mp hx.1
 #align module.End.has_eigenvector.apply_eq_smul Module.End.HasEigenvector.apply_eq_smul
 
+#print Module.End.HasEigenvalue.exists_hasEigenvector /-
 theorem HasEigenvalue.exists_hasEigenvector {f : End R M} {μ : R} (hμ : f.HasEigenvalue μ) :
     ∃ v, f.HasEigenvector μ v :=
   Submodule.exists_mem_ne_zero_of_ne_bot hμ
 #align module.End.has_eigenvalue.exists_has_eigenvector Module.End.HasEigenvalue.exists_hasEigenvector
+-/
 
 theorem mem_spectrum_of_hasEigenvalue {f : End R M} {μ : R} (hμ : HasEigenvalue f μ) :
     μ ∈ spectrum R f := by
@@ -137,6 +149,7 @@ theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
     
 #align module.End.eigenspace_div Module.End.eigenspace_div
 
+#print Module.End.eigenspaces_independent /-
 /-- The eigenspaces of a linear operator form an independent family of subspaces of `V`.  That is,
 any eigenspace has trivial intersection with the span of all the other eigenspaces. -/
 theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.eigenspace := by
@@ -249,7 +262,9 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
       · rwa [h_cases, SetLike.coe_eq_coe, Dfinsupp.coe_zero, Pi.zero_apply]
       exact congr_arg (coe : _ → V) (h_lμ_eq_0 μ h_cases)
 #align module.End.eigenspaces_independent Module.End.eigenspaces_independent
+-/
 
+#print Module.End.eigenvectors_linearIndependent /-
 /-- Eigenvectors corresponding to distinct eigenvalues of a linear operator are linearly
     independent. (Lemma 5.10 of [axler2015])
 
@@ -261,7 +276,9 @@ theorem eigenvectors_linearIndependent (f : End K V) (μs : Set K) (xs : μs →
     (f.eigenspaces_independent.comp Subtype.coe_injective) (fun μ => (h_eigenvec μ).1) fun μ =>
     (h_eigenvec μ).2
 #align module.End.eigenvectors_linear_independent Module.End.eigenvectors_linearIndependent
+-/
 
+#print Module.End.generalizedEigenspace /-
 /-- The generalized eigenspace for a linear map `f`, a scalar `μ`, and an exponent `k ∈ ℕ` is the
 kernel of `(f - μ • id) ^ k`. (Def 8.10 of [axler2015]). Furthermore, a generalized eigenspace for
 some exponent `k` is contained in the generalized eigenspace for exponents larger than `k`. -/
@@ -274,6 +291,7 @@ def generalizedEigenspace (f : End R M) (μ : R) : ℕ →o Submodule R M
       LinearMap.ker_le_ker_comp ((f - algebraMap R (End R M) μ) ^ k)
         ((f - algebraMap R (End R M) μ) ^ (m - k))
 #align module.End.generalized_eigenspace Module.End.generalizedEigenspace
+-/
 
 @[simp]
 theorem mem_generalizedEigenspace (f : End R M) (μ : R) (k : ℕ) (m : M) :
@@ -286,24 +304,31 @@ theorem generalizedEigenspace_zero (f : End R M) (k : ℕ) :
     f.generalizedEigenspace 0 k = (f ^ k).ker := by simp [Module.End.generalizedEigenspace]
 #align module.End.generalized_eigenspace_zero Module.End.generalizedEigenspace_zero
 
+#print Module.End.HasGeneralizedEigenvector /-
 /-- A nonzero element of a generalized eigenspace is a generalized eigenvector.
     (Def 8.9 of [axler2015])-/
 def HasGeneralizedEigenvector (f : End R M) (μ : R) (k : ℕ) (x : M) : Prop :=
   x ≠ 0 ∧ x ∈ generalizedEigenspace f μ k
 #align module.End.has_generalized_eigenvector Module.End.HasGeneralizedEigenvector
+-/
 
+#print Module.End.HasGeneralizedEigenvalue /-
 /-- A scalar `μ` is a generalized eigenvalue for a linear map `f` and an exponent `k ∈ ℕ` if there
     are generalized eigenvectors for `f`, `k`, and `μ`. -/
 def HasGeneralizedEigenvalue (f : End R M) (μ : R) (k : ℕ) : Prop :=
   generalizedEigenspace f μ k ≠ ⊥
 #align module.End.has_generalized_eigenvalue Module.End.HasGeneralizedEigenvalue
+-/
 
+#print Module.End.generalizedEigenrange /-
 /-- The generalized eigenrange for a linear map `f`, a scalar `μ`, and an exponent `k ∈ ℕ` is the
     range of `(f - μ • id) ^ k`. -/
 def generalizedEigenrange (f : End R M) (μ : R) (k : ℕ) : Submodule R M :=
   ((f - algebraMap R (End R M) μ) ^ k).range
 #align module.End.generalized_eigenrange Module.End.generalizedEigenrange
+-/
 
+#print Module.End.exp_ne_zero_of_hasGeneralizedEigenvalue /-
 /-- The exponent of a generalized eigenvalue is never 0. -/
 theorem exp_ne_zero_of_hasGeneralizedEigenvalue {f : End R M} {μ : R} {k : ℕ}
     (h : f.HasGeneralizedEigenvalue μ k) : k ≠ 0 :=
@@ -311,16 +336,21 @@ theorem exp_ne_zero_of_hasGeneralizedEigenvalue {f : End R M} {μ : R} {k : ℕ}
   rintro rfl
   exact h LinearMap.ker_id
 #align module.End.exp_ne_zero_of_has_generalized_eigenvalue Module.End.exp_ne_zero_of_hasGeneralizedEigenvalue
+-/
 
+#print Module.End.maximalGeneralizedEigenspace /-
 /-- The union of the kernels of `(f - μ • id) ^ k` over all `k`. -/
 def maximalGeneralizedEigenspace (f : End R M) (μ : R) : Submodule R M :=
   ⨆ k, f.generalizedEigenspace μ k
 #align module.End.maximal_generalized_eigenspace Module.End.maximalGeneralizedEigenspace
+-/
 
+#print Module.End.generalizedEigenspace_le_maximal /-
 theorem generalizedEigenspace_le_maximal (f : End R M) (μ : R) (k : ℕ) :
     f.generalizedEigenspace μ k ≤ f.maximalGeneralizedEigenspace μ :=
   le_iSup _ _
 #align module.End.generalized_eigenspace_le_maximal Module.End.generalizedEigenspace_le_maximal
+-/
 
 @[simp]
 theorem mem_maximalGeneralizedEigenspace (f : End R M) (μ : R) (m : M) :
@@ -329,13 +359,16 @@ theorem mem_maximalGeneralizedEigenspace (f : End R M) (μ : R) (m : M) :
     Submodule.mem_iSup_of_chain]
 #align module.End.mem_maximal_generalized_eigenspace Module.End.mem_maximalGeneralizedEigenspace
 
+#print Module.End.maximalGeneralizedEigenspaceIndex /-
 /-- If there exists a natural number `k` such that the kernel of `(f - μ • id) ^ k` is the
 maximal generalized eigenspace, then this value is the least such `k`. If not, this value is not
 meaningful. -/
 noncomputable def maximalGeneralizedEigenspaceIndex (f : End R M) (μ : R) :=
   monotonicSequenceLimitIndex (f.generalizedEigenspace μ)
 #align module.End.maximal_generalized_eigenspace_index Module.End.maximalGeneralizedEigenspaceIndex
+-/
 
+#print Module.End.maximalGeneralizedEigenspace_eq /-
 /-- For an endomorphism of a Noetherian module, the maximal eigenspace is always of the form kernel
 `(f - μ • id) ^ k` for some `k`. -/
 theorem maximalGeneralizedEigenspace_eq [h : IsNoetherian R M] (f : End R M) (μ : R) :
@@ -345,7 +378,9 @@ theorem maximalGeneralizedEigenspace_eq [h : IsNoetherian R M] (f : End R M) (μ
   rw [isNoetherian_iff_wellFounded] at h 
   exact (WellFounded.iSup_eq_monotonicSequenceLimit h (f.generalized_eigenspace μ) : _)
 #align module.End.maximal_generalized_eigenspace_eq Module.End.maximalGeneralizedEigenspace_eq
+-/
 
+#print Module.End.hasGeneralizedEigenvalue_of_hasGeneralizedEigenvalue_of_le /-
 /-- A generalized eigenvalue for some exponent `k` is also
     a generalized eigenvalue for exponents larger than `k`. -/
 theorem hasGeneralizedEigenvalue_of_hasGeneralizedEigenvalue_of_le {f : End R M} {μ : R} {k : ℕ}
@@ -356,13 +391,17 @@ theorem hasGeneralizedEigenvalue_of_hasGeneralizedEigenvalue_of_le {f : End R M}
   rw [← le_bot_iff, ← hk]
   exact (f.generalized_eigenspace μ).Monotone hm
 #align module.End.has_generalized_eigenvalue_of_has_generalized_eigenvalue_of_le Module.End.hasGeneralizedEigenvalue_of_hasGeneralizedEigenvalue_of_le
+-/
 
+#print Module.End.eigenspace_le_generalizedEigenspace /-
 /-- The eigenspace is a subspace of the generalized eigenspace. -/
 theorem eigenspace_le_generalizedEigenspace {f : End R M} {μ : R} {k : ℕ} (hk : 0 < k) :
     f.eigenspace μ ≤ f.generalizedEigenspace μ k :=
   (f.generalizedEigenspace μ).Monotone (Nat.succ_le_of_lt hk)
 #align module.End.eigenspace_le_generalized_eigenspace Module.End.eigenspace_le_generalizedEigenspace
+-/
 
+#print Module.End.hasGeneralizedEigenvalue_of_hasEigenvalue /-
 /-- All eigenvalues are generalized eigenvalues. -/
 theorem hasGeneralizedEigenvalue_of_hasEigenvalue {f : End R M} {μ : R} {k : ℕ} (hk : 0 < k)
     (hμ : f.HasEigenvalue μ) : f.HasGeneralizedEigenvalue μ k :=
@@ -371,7 +410,9 @@ theorem hasGeneralizedEigenvalue_of_hasEigenvalue {f : End R M} {μ : R} {k : 
   rw [has_generalized_eigenvalue, generalized_eigenspace, OrderHom.coe_fun_mk, pow_one]
   exact hμ
 #align module.End.has_generalized_eigenvalue_of_has_eigenvalue Module.End.hasGeneralizedEigenvalue_of_hasEigenvalue
+-/
 
+#print Module.End.hasEigenvalue_of_hasGeneralizedEigenvalue /-
 /-- All generalized eigenvalues are eigenvalues. -/
 theorem hasEigenvalue_of_hasGeneralizedEigenvalue {f : End R M} {μ : R} {k : ℕ}
     (hμ : f.HasGeneralizedEigenvalue μ k) : f.HasEigenvalue μ :=
@@ -380,27 +421,34 @@ theorem hasEigenvalue_of_hasGeneralizedEigenvalue {f : End R M} {μ : R} {k : 
   erw [LinearMap.ker_eq_bot] at contra ⊢; rw [LinearMap.coe_pow]
   exact Function.Injective.iterate contra k
 #align module.End.has_eigenvalue_of_has_generalized_eigenvalue Module.End.hasEigenvalue_of_hasGeneralizedEigenvalue
+-/
 
+#print Module.End.hasGeneralizedEigenvalue_iff_hasEigenvalue /-
 /-- Generalized eigenvalues are actually just eigenvalues. -/
 @[simp]
 theorem hasGeneralizedEigenvalue_iff_hasEigenvalue {f : End R M} {μ : R} {k : ℕ} (hk : 0 < k) :
     f.HasGeneralizedEigenvalue μ k ↔ f.HasEigenvalue μ :=
   ⟨hasEigenvalue_of_hasGeneralizedEigenvalue, hasGeneralizedEigenvalue_of_hasEigenvalue hk⟩
 #align module.End.has_generalized_eigenvalue_iff_has_eigenvalue Module.End.hasGeneralizedEigenvalue_iff_hasEigenvalue
+-/
 
+#print Module.End.generalizedEigenspace_le_generalizedEigenspace_finrank /-
 /-- Every generalized eigenvector is a generalized eigenvector for exponent `finrank K V`.
     (Lemma 8.11 of [axler2015]) -/
 theorem generalizedEigenspace_le_generalizedEigenspace_finrank [FiniteDimensional K V] (f : End K V)
     (μ : K) (k : ℕ) : f.generalizedEigenspace μ k ≤ f.generalizedEigenspace μ (finrank K V) :=
   ker_pow_le_ker_pow_finrank _ _
 #align module.End.generalized_eigenspace_le_generalized_eigenspace_finrank Module.End.generalizedEigenspace_le_generalizedEigenspace_finrank
+-/
 
+#print Module.End.generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le /-
 /-- Generalized eigenspaces for exponents at least `finrank K V` are equal to each other. -/
 theorem generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le [FiniteDimensional K V]
     (f : End K V) (μ : K) {k : ℕ} (hk : finrank K V ≤ k) :
     f.generalizedEigenspace μ k = f.generalizedEigenspace μ (finrank K V) :=
   ker_pow_eq_ker_pow_finrank_of_le hk
 #align module.End.generalized_eigenspace_eq_generalized_eigenspace_finrank_of_le Module.End.generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le
+-/
 
 /-- If `f` maps a subspace `p` into itself, then the generalized eigenspace of the restriction
     of `f` to `p` is the part of the generalized eigenspace of `f` that lies in `p`. -/
@@ -458,6 +506,7 @@ theorem eigenspace_restrict_eq_bot {f : End R M} {p : Submodule R M} (hfp : ∀
   simpa using hμp.le_bot ⟨eigenspace_restrict_le_eigenspace f hfp μ ⟨x, hx, rfl⟩, x.prop⟩
 #align module.End.eigenspace_restrict_eq_bot Module.End.eigenspace_restrict_eq_bot
 
+#print Module.End.pos_finrank_generalizedEigenspace_of_hasEigenvalue /-
 /-- The generalized eigenspace of an eigenvalue has positive dimension for positive exponents. -/
 theorem pos_finrank_generalizedEigenspace_of_hasEigenvalue [FiniteDimensional K V] {f : End K V}
     {k : ℕ} {μ : K} (hx : f.HasEigenvalue μ) (hk : 0 < k) :
@@ -469,7 +518,9 @@ theorem pos_finrank_generalizedEigenspace_of_hasEigenvalue [FiniteDimensional K
       Submodule.finrank_mono ((f.generalizedEigenspace μ).Monotone (Nat.succ_le_of_lt hk))
     
 #align module.End.pos_finrank_generalized_eigenspace_of_has_eigenvalue Module.End.pos_finrank_generalizedEigenspace_of_hasEigenvalue
+-/
 
+#print Module.End.map_generalizedEigenrange_le /-
 /-- A linear map maps a generalized eigenrange into itself. -/
 theorem map_generalizedEigenrange_le {f : End K V} {μ : K} {n : ℕ} :
     Submodule.map f (f.generalizedEigenrange μ n) ≤ f.generalizedEigenrange μ n :=
@@ -481,6 +532,7 @@ theorem map_generalizedEigenrange_le {f : End K V} {μ : K} {n : ℕ} :
     _ ≤ f.generalizedEigenrange μ n := LinearMap.map_le_range
     
 #align module.End.map_generalized_eigenrange_le Module.End.map_generalizedEigenrange_le
+-/
 
 end End
 
Diff
@@ -3,14 +3,14 @@ Copyright (c) 2020 Alexander Bentkamp. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
 
-! This file was ported from Lean 3 source module linear_algebra.eigenspace
-! leanprover-community/mathlib commit 58a272265b5e05f258161260dd2c5d247213cbd3
+! This file was ported from Lean 3 source module linear_algebra.eigenspace.basic
+! leanprover-community/mathlib commit 6b0169218d01f2837d79ea2784882009a0da1aa1
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathbin.FieldTheory.IsAlgClosed.Spectrum
-import Mathbin.Order.Hom.Basic
+import Mathbin.Algebra.Algebra.Spectrum
 import Mathbin.LinearAlgebra.GeneralLinearGroup
+import Mathbin.LinearAlgebra.FiniteDimensional
 
 /-!
 # Eigenvectors and eigenvalues
@@ -32,6 +32,13 @@ of the map `(f - μ • id) ^ k`. The nonzero elements of a generalized eigenspa
 eigenvectors `x`. If there are generalized eigenvectors for a natural number `k` and a scalar `μ`,
 the scalar `μ` is called a generalized eigenvalue.
 
+The fact that the eigenvalues are the roots of the minimal polynomial is proved in
+`linear_algebra.eigenspace.minpoly`.
+
+The existence of eigenvalues over an algebraically closed field
+(and the fact that the generalized eigenspaces then span) is deferred to
+`linear_algebra.eigenspace.is_alg_closed`.
+
 ## References
 
 * [Sheldon Axler, *Linear Algebra Done Right*][axler2015]
@@ -49,9 +56,7 @@ namespace Module
 
 namespace End
 
-open Module PrincipalIdealRing Polynomial FiniteDimensional
-
-open scoped Polynomial
+open FiniteDimensional
 
 variable {K R : Type v} {V M : Type w} [CommRing R] [AddCommGroup M] [Module R M] [Field K]
   [AddCommGroup V] [Module K V]
@@ -132,105 +137,6 @@ theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
     
 #align module.End.eigenspace_div Module.End.eigenspace_div
 
-theorem eigenspace_aeval_polynomial_degree_1 (f : End K V) (q : K[X]) (hq : degree q = 1) :
-    eigenspace f (-q.coeff 0 / q.leadingCoeff) = (aeval f q).ker :=
-  calc
-    eigenspace f (-q.coeff 0 / q.leadingCoeff) =
-        (q.leadingCoeff • f - algebraMap K (End K V) (-q.coeff 0)).ker :=
-      by rw [eigenspace_div]; intro h; rw [leading_coeff_eq_zero_iff_deg_eq_bot.1 h] at hq ;
-      cases hq
-    _ = (aeval f (C q.leadingCoeff * X + C (q.coeff 0))).ker := by rw [C_mul', aeval_def];
-      simp [algebraMap, Algebra.toRingHom]
-    _ = (aeval f q).ker := by rwa [← eq_X_add_C_of_degree_eq_one]
-    
-#align module.End.eigenspace_aeval_polynomial_degree_1 Module.End.eigenspace_aeval_polynomial_degree_1
-
-theorem ker_aeval_ring_hom'_unit_polynomial (f : End K V) (c : K[X]ˣ) :
-    (aeval f (c : K[X])).ker = ⊥ :=
-  by
-  rw [Polynomial.eq_C_of_degree_eq_zero (degree_coe_units c)]
-  simp only [aeval_def, eval₂_C]
-  apply ker_algebra_map_End
-  apply coeff_coe_units_zero_ne_zero c
-#align module.End.ker_aeval_ring_hom'_unit_polynomial Module.End.ker_aeval_ring_hom'_unit_polynomial
-
-theorem aeval_apply_of_hasEigenvector {f : End K V} {p : K[X]} {μ : K} {x : V}
-    (h : f.HasEigenvector μ x) : aeval f p x = p.eval μ • x :=
-  by
-  apply p.induction_on
-  · intro a; simp [Module.algebraMap_end_apply]
-  · intro p q hp hq; simp [hp, hq, add_smul]
-  · intro n a hna
-    rw [mul_comm, pow_succ, mul_assoc, AlgHom.map_mul, LinearMap.mul_apply, mul_comm, hna]
-    simp only [mem_eigenspace_iff.1 h.1, smul_smul, aeval_X, eval_mul, eval_C, eval_pow, eval_X,
-      LinearMap.map_smulₛₗ, RingHom.id_apply, mul_comm]
-#align module.End.aeval_apply_of_has_eigenvector Module.End.aeval_apply_of_hasEigenvector
-
-section minpoly
-
-theorem isRoot_of_hasEigenvalue {f : End K V} {μ : K} (h : f.HasEigenvalue μ) :
-    (minpoly K f).IsRoot μ :=
-  by
-  rcases(Submodule.ne_bot_iff _).1 h with ⟨w, ⟨H, ne0⟩⟩
-  refine' Or.resolve_right (smul_eq_zero.1 _) ne0
-  simp [← aeval_apply_of_has_eigenvector ⟨H, ne0⟩, minpoly.aeval K f]
-#align module.End.is_root_of_has_eigenvalue Module.End.isRoot_of_hasEigenvalue
-
-variable [FiniteDimensional K V] (f : End K V)
-
-variable {f} {μ : K}
-
-theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ :=
-  by
-  cases' dvd_iff_is_root.2 h with p hp
-  rw [has_eigenvalue, eigenspace]
-  intro con
-  cases' (LinearMap.isUnit_iff_ker_eq_bot _).2 Con with u hu
-  have p_ne_0 : p ≠ 0 := by
-    intro con
-    apply minpoly.ne_zero f.is_integral
-    rw [hp, Con, MulZeroClass.mul_zero]
-  have h_deg := minpoly.degree_le_of_ne_zero K f p_ne_0 _
-  · rw [hp, degree_mul, degree_X_sub_C, Polynomial.degree_eq_natDegree p_ne_0] at h_deg 
-    norm_cast at h_deg 
-    linarith
-  · have h_aeval := minpoly.aeval K f
-    revert h_aeval
-    simp [hp, ← hu]
-#align module.End.has_eigenvalue_of_is_root Module.End.hasEigenvalue_of_isRoot
-
-theorem hasEigenvalue_iff_isRoot : f.HasEigenvalue μ ↔ (minpoly K f).IsRoot μ :=
-  ⟨isRoot_of_hasEigenvalue, hasEigenvalue_of_isRoot⟩
-#align module.End.has_eigenvalue_iff_is_root Module.End.hasEigenvalue_iff_isRoot
-
-/-- An endomorphism of a finite-dimensional vector space has finitely many eigenvalues. -/
-noncomputable instance (f : End K V) : Fintype f.Eigenvalues :=
-  Set.Finite.fintype
-    (by
-      have h : minpoly K f ≠ 0 := minpoly.ne_zero f.is_integral
-      convert (minpoly K f).rootSet_finite K
-      ext μ
-      have : μ ∈ {μ : K | f.eigenspace μ = ⊥ → False} ↔ ¬f.eigenspace μ = ⊥ := by tauto
-      convert rfl.mpr this
-      simp [Polynomial.rootSet_def, Polynomial.mem_roots h, ← has_eigenvalue_iff_is_root,
-        has_eigenvalue])
-
-end minpoly
-
--- This is Lemma 5.21 of [axler2015], although we are no longer following that proof.
-/-- Every linear operator on a vector space over an algebraically closed field has
-    an eigenvalue. -/
-theorem exists_eigenvalue [IsAlgClosed K] [FiniteDimensional K V] [Nontrivial V] (f : End K V) :
-    ∃ c : K, f.HasEigenvalue c :=
-  by
-  simp_rw [has_eigenvalue_iff_mem_spectrum]
-  exact spectrum.nonempty_of_isAlgClosed_of_finiteDimensional K f
-#align module.End.exists_eigenvalue Module.End.exists_eigenvalue
-
-noncomputable instance [IsAlgClosed K] [FiniteDimensional K V] [Nontrivial V] (f : End K V) :
-    Inhabited f.Eigenvalues :=
-  ⟨⟨f.exists_eigenvalue.some, f.exists_eigenvalue.choose_spec⟩⟩
-
 /-- The eigenspaces of a linear operator form an independent family of subspaces of `V`.  That is,
 any eigenspace has trivial intersection with the span of all the other eigenspaces. -/
 theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.eigenspace := by
@@ -576,72 +482,6 @@ theorem map_generalizedEigenrange_le {f : End K V} {μ : K} {n : ℕ} :
     
 #align module.End.map_generalized_eigenrange_le Module.End.map_generalizedEigenrange_le
 
-/-- The generalized eigenvectors span the entire vector space (Lemma 8.21 of [axler2015]). -/
-theorem iSup_generalizedEigenspace_eq_top [IsAlgClosed K] [FiniteDimensional K V] (f : End K V) :
-    (⨆ (μ : K) (k : ℕ), f.generalizedEigenspace μ k) = ⊤ :=
-  by
-  -- We prove the claim by strong induction on the dimension of the vector space.
-  induction' h_dim : finrank K V using Nat.strong_induction_on with n ih generalizing V
-  cases n
-  -- If the vector space is 0-dimensional, the result is trivial.
-  · rw [← top_le_iff]
-    simp only [finrank_eq_zero.1 (Eq.trans (finrank_top _ _) h_dim), bot_le]
-  -- Otherwise the vector space is nontrivial.
-  · haveI : Nontrivial V := finrank_pos_iff.1 (by rw [h_dim]; apply Nat.zero_lt_succ)
-    -- Hence, `f` has an eigenvalue `μ₀`.
-    obtain ⟨μ₀, hμ₀⟩ : ∃ μ₀, f.has_eigenvalue μ₀ := exists_eigenvalue f
-    -- We define `ES` to be the generalized eigenspace
-    let ES := f.generalized_eigenspace μ₀ (finrank K V)
-    -- and `ER` to be the generalized eigenrange.
-    let ER := f.generalized_eigenrange μ₀ (finrank K V)
-    -- `f` maps `ER` into itself.
-    have h_f_ER : ∀ x : V, x ∈ ER → f x ∈ ER := fun x hx =>
-      map_generalized_eigenrange_le (Submodule.mem_map_of_mem hx)
-    -- Therefore, we can define the restriction `f'` of `f` to `ER`.
-    let f' : End K ER := f.restrict h_f_ER
-    -- The dimension of `ES` is positive
-    have h_dim_ES_pos : 0 < finrank K ES := by
-      dsimp only [ES]
-      rw [h_dim]
-      apply pos_finrank_generalized_eigenspace_of_has_eigenvalue hμ₀ (Nat.zero_lt_succ n)
-    -- and the dimensions of `ES` and `ER` add up to `finrank K V`.
-    have h_dim_add : finrank K ER + finrank K ES = finrank K V := by
-      apply LinearMap.finrank_range_add_finrank_ker
-    -- Therefore the dimension `ER` mus be smaller than `finrank K V`.
-    have h_dim_ER : finrank K ER < n.succ := by linarith
-    -- This allows us to apply the induction hypothesis on `ER`:
-    have ih_ER : (⨆ (μ : K) (k : ℕ), f'.generalized_eigenspace μ k) = ⊤ :=
-      ih (finrank K ER) h_dim_ER f' rfl
-    -- The induction hypothesis gives us a statement about subspaces of `ER`. We can transfer this
-    -- to a statement about subspaces of `V` via `submodule.subtype`:
-    have ih_ER' : (⨆ (μ : K) (k : ℕ), (f'.generalized_eigenspace μ k).map ER.subtype) = ER := by
-      simp only [(Submodule.map_iSup _ _).symm, ih_ER, Submodule.map_subtype_top ER]
-    -- Moreover, every generalized eigenspace of `f'` is contained in the corresponding generalized
-    -- eigenspace of `f`.
-    have hff' :
-      ∀ μ k, (f'.generalized_eigenspace μ k).map ER.subtype ≤ f.generalized_eigenspace μ k :=
-      by
-      intros
-      rw [generalized_eigenspace_restrict]
-      apply Submodule.map_comap_le
-    -- It follows that `ER` is contained in the span of all generalized eigenvectors.
-    have hER : ER ≤ ⨆ (μ : K) (k : ℕ), f.generalized_eigenspace μ k :=
-      by
-      rw [← ih_ER']
-      exact iSup₂_mono hff'
-    -- `ES` is contained in this span by definition.
-    have hES : ES ≤ ⨆ (μ : K) (k : ℕ), f.generalized_eigenspace μ k :=
-      le_trans (le_iSup (fun k => f.generalized_eigenspace μ₀ k) (finrank K V))
-        (le_iSup (fun μ : K => ⨆ k : ℕ, f.generalized_eigenspace μ k) μ₀)
-    -- Moreover, we know that `ER` and `ES` are disjoint.
-    have h_disjoint : Disjoint ER ES := generalized_eigenvec_disjoint_range_ker f μ₀
-    -- Since the dimensions of `ER` and `ES` add up to the dimension of `V`, it follows that the
-    -- span of all generalized eigenvectors is all of `V`.
-    show (⨆ (μ : K) (k : ℕ), f.generalized_eigenspace μ k) = ⊤
-    · rw [← top_le_iff, ← Submodule.eq_top_of_disjoint ER ES h_dim_add h_disjoint]
-      apply sup_le hER hES
-#align module.End.supr_generalized_eigenspace_eq_top Module.End.iSup_generalizedEigenspace_eq_top
-
 end End
 
 end Module

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 1 (#12338)

A PR accompanying #12339.

Zulip discussion

Diff
@@ -369,7 +369,8 @@ theorem independent_generalizedEigenspace [NoZeroSMulDivisors R M] (f : End R M)
       Finset.supIndep_iff_disjoint_erase]
     exact fun s μ _ ↦ this _ _ (s.not_mem_erase μ)
   intro μ₁ s
-  induction' s using Finset.induction_on with μ₂ s _ ih; simp
+  induction' s using Finset.induction_on with μ₂ s _ ih
+  · simp
   intro hμ₁₂
   obtain ⟨hμ₁₂ : μ₁ ≠ μ₂, hμ₁ : μ₁ ∉ s⟩ := by rwa [Finset.mem_insert, not_or] at hμ₁₂
   specialize ih hμ₁
chore: split RingTheory.Nilpotent (#12184)

Mathlib.RingTheory.Nilpotent has a few very simple definitions (Mathlib.Data.Nat.Lattice is sufficient to state them), but needs some pretty heavy imports (ideals, linear algebra) towards the end. This change moves the heavier parts into a new file.

Diff
@@ -6,6 +6,7 @@ Authors: Alexander Bentkamp
 import Mathlib.Algebra.Algebra.Spectrum
 import Mathlib.LinearAlgebra.GeneralLinearGroup
 import Mathlib.LinearAlgebra.FiniteDimensional
+import Mathlib.RingTheory.Nilpotent.Basic
 
 #align_import linear_algebra.eigenspace.basic from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1"
 
chore: superfluous parentheses part 2 (#12131)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -479,7 +479,7 @@ theorem pos_finrank_generalizedEigenspace_of_hasEigenvalue [FiniteDimensional K
     0 < finrank K (f.generalizedEigenspace μ k) :=
   calc
     0 = finrank K (⊥ : Submodule K V) := by rw [finrank_bot]
-    _ < finrank K (f.eigenspace μ) := (Submodule.finrank_lt_finrank_of_lt (bot_lt_iff_ne_bot.2 hx))
+    _ < finrank K (f.eigenspace μ) := Submodule.finrank_lt_finrank_of_lt (bot_lt_iff_ne_bot.2 hx)
     _ ≤ finrank K (f.generalizedEigenspace μ k) :=
       Submodule.finrank_mono ((f.generalizedEigenspace μ).monotone (Nat.succ_le_of_lt hk))
 
feat: MulActionHom in the semilinear style (#6057)

Generalize MulActionHom so that it allows two different monoids acting, related by a morphism. This is inspired by the treatment of (semi)linear maps in mathlib, and allows to refactor them.

Let M, N, X, Y be types, with SMul M X and SMul N Y, and let φ : M → N be a map.

  • MulActionHom φ X Y, the type of equivariant functions from X to Y, consists of functions f : X → Y such that f (m • x) = (φ m) • (f x) for all m : M and x : X.

Assume that we have Monoid M, Monoid N and that φ : M →* N. For A, B by types with AddMonoid A and AddMonoid B, endowed with DistribMulAction M A and DistribMulAction M B:

  • DistribMulActionHom φ A B is the type of equivariant additive monoid homomorphisms from A to B.

Similarly, when R and S are types with Semiring R, Semiring S, MulSemiringAction M R and MulSemiringAction N S

  • SMulSemiringHom φ R S is the type of equivariant ring homomorphisms from R to S.

The above types have corresponding classes:

  • MulActionHomClass F φ X Y states that F is a type of bundled X → Y homs which are φ-equivariant
  • DistribMulActionHomClass F φ A B states that F is a type of bundled A → B homs preserving the additive monoid structure and φ-equivariant
  • SMulSemiringHomClass F φ R S states that F is a type of bundled R → S homs preserving the ring structure and φ-equivariant

Notation

We introduce the following notation to code equivariant maps (the subscript index is for equivariant) :

  • X →ₑ[φ] Y is MulActionHom φ X Y.
  • A →ₑ+[φ] B is DistribMulActionHom φ A B.
  • R →ₑ+*[φ] S is MulSemiringActionHom φ R S.

When M = N and φ = MonoidHom.id M, we provide the backward compatible notation :

  • X →[M] Y is MulActionHom ([@id](https://github.com/id) M) X Y
  • A →+[M] B is DistribMulActionHom (MonoidHom.id M) A B
  • R →+*[M] S is MulSemiringActionHom (MonoidHom.id M) R S

This more general definition is propagated all over mathlib, in particular to LinearMap.

The treatment of composition of equivariant maps is inspired by that of semilinear maps. We provide classes CompTriple and MonoidHom.CompTriple of “composable triples`, and various instances for them.

Diff
@@ -530,7 +530,7 @@ lemma iSup_generalizedEigenspace_inf_le_add
   · rw [LinearMap.mul_apply, LinearMap.pow_map_zero_of_le hj hk₂, LinearMap.map_zero]
 
 lemma map_smul_of_iInf_generalizedEigenspace_ne_bot [NoZeroSMulDivisors R M]
-    {L F : Type*} [SMul R L] [FunLike F L (End R M)] [SMulHomClass F R L (End R M)] (f : F)
+    {L F : Type*} [SMul R L] [FunLike F L (End R M)] [MulActionHomClass F R L (End R M)] (f : F)
     (μ : L → R) (h_ne : ⨅ x, ⨆ k, (f x).generalizedEigenspace (μ x) k ≠ ⊥)
     (t : R) (x : L) :
     μ (t • x) = t • μ x := by
change the order of operation in zsmulRec and nsmulRec (#11451)

We change the following field in the definition of an additive commutative monoid:

 nsmul_succ : ∀ (n : ℕ) (x : G),
-  AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
+  AddMonoid.nsmul (n + 1) x = AddMonoid.nsmul n x + x

where the latter is more natural

We adjust the definitions of ^ in monoids, groups, etc. Originally there was a warning comment about why this natural order was preferred

use x * npowRec n x and not npowRec n x * x in the definition to make sure that definitional unfolding of npowRec is blocked, to avoid deep recursion issues.

but it seems to no longer apply.

Remarks on the PR :

  • pow_succ and pow_succ' have switched their meanings.
  • Most of the time, the proofs were adjusted by priming/unpriming one lemma, or exchanging left and right; a few proofs were more complicated to adjust.
  • In particular, [Mathlib/NumberTheory/RamificationInertia.lean] used Ideal.IsPrime.mul_mem_pow which is defined in [Mathlib/RingTheory/DedekindDomain/Ideal.lean]. Changing the order of operation forced me to add the symmetric lemma Ideal.IsPrime.mem_pow_mul.
  • the docstring for Cauchy condensation test in [Mathlib/Analysis/PSeries.lean] was mathematically incorrect, I added the mention that the function is antitone.
Diff
@@ -426,7 +426,7 @@ theorem generalizedEigenspace_restrict (f : End R M) (p : Submodule R M) (k : 
   induction' k with k ih
   · rw [pow_zero, pow_zero, LinearMap.one_eq_id]
     apply (Submodule.ker_subtype _).symm
-  · erw [pow_succ', pow_succ', LinearMap.ker_comp, LinearMap.ker_comp, ih, ← LinearMap.ker_comp,
+  · erw [pow_succ, pow_succ, LinearMap.ker_comp, LinearMap.ker_comp, ih, ← LinearMap.ker_comp,
       LinearMap.comp_assoc]
 #align module.End.generalized_eigenspace_restrict Module.End.generalizedEigenspace_restrict
 
refactor: optimize proofs with omega (#11093)

I ran tryAtEachStep on all files under Mathlib to find all locations where omega succeeds. For each that was a linarith without an only, I tried replacing it with omega, and I verified that elaboration time got smaller. (In almost all cases, there was a noticeable speedup.) I also replaced some slow aesops along the way.

Diff
@@ -458,7 +458,7 @@ theorem generalized_eigenvec_disjoint_range_ker [FiniteDimensional K V] (f : End
               rw [generalizedEigenspace, OrderHom.coe_mk, ← LinearMap.ker_comp]; rfl
       _ = f.generalizedEigenspace μ (finrank K V + finrank K V) := by rw [← pow_add]; rfl
       _ = f.generalizedEigenspace μ (finrank K V) := by
-        rw [generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le]; linarith
+        rw [generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le]; omega
   rw [disjoint_iff_inf_le, generalizedEigenrange, LinearMap.range_eq_map,
     Submodule.map_inf_eq_map_inf_comap, top_inf_eq, h]
   apply Submodule.map_comap_le
chore: prepare Lean version bump with explicit simp (#10999)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -338,9 +338,9 @@ lemma disjoint_generalizedEigenspace [NoZeroSMulDivisors R M]
     (mapsTo_generalizedEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ₂) μ₂ l)
   have : IsNilpotent (f₂ - f₁) := by
     apply Commute.isNilpotent_sub (x := f₂) (y := f₁) _ ⟨l, ?_⟩ ⟨k, ?_⟩
-    · ext; simp [smul_sub, sub_sub, smul_comm μ₁, add_sub_left_comm]
+    · ext; simp [f₁, f₂, smul_sub, sub_sub, smul_comm μ₁, add_sub_left_comm]
     all_goals ext ⟨x, _, _⟩; simpa [LinearMap.restrict_apply, LinearMap.pow_restrict _] using ‹_›
-  have hf₁₂ : f₂ - f₁ = algebraMap R (End R p) (μ₁ - μ₂) := by ext; simp [sub_smul]
+  have hf₁₂ : f₂ - f₁ = algebraMap R (End R p) (μ₁ - μ₂) := by ext; simp [f₁, f₂, sub_smul]
   rw [hf₁₂, IsNilpotent.map_iff (NoZeroSMulDivisors.algebraMap_injective R (End R p)),
     isNilpotent_iff_eq_zero, sub_eq_zero] at this
   contradiction
@@ -539,7 +539,7 @@ lemma map_smul_of_iInf_generalizedEigenspace_ne_bot [NoZeroSMulDivisors R M]
   have : ⨅ x, g x ≤ g x ⊓ g (t • x) := le_inf_iff.mpr ⟨iInf_le g x, iInf_le g (t • x)⟩
   refine h_ne <| eq_bot_iff.mpr (le_trans this (disjoint_iff_inf_le.mp ?_))
   apply Disjoint.mono_left (iSup_generalizedEigenspace_le_smul (f x) (μ x) t)
-  simp only [map_smul]
+  simp only [g, map_smul]
   exact disjoint_iSup_generalizedEigenspace (t • f x) (Ne.symm contra)
 
 lemma map_add_of_iInf_generalizedEigenspace_ne_bot_of_commute [NoZeroSMulDivisors R M]
@@ -553,7 +553,7 @@ lemma map_add_of_iInf_generalizedEigenspace_ne_bot_of_commute [NoZeroSMulDivisor
     le_inf_iff.mpr ⟨le_inf_iff.mpr ⟨iInf_le g x, iInf_le g y⟩, iInf_le g (x + y)⟩
   refine h_ne <| eq_bot_iff.mpr (le_trans this (disjoint_iff_inf_le.mp ?_))
   apply Disjoint.mono_left (iSup_generalizedEigenspace_inf_le_add (f x) (f y) (μ x) (μ y) (h x y))
-  simp only [map_add]
+  simp only [g, map_add]
   exact disjoint_iSup_generalizedEigenspace (f x + f y) (Ne.symm contra)
 
 end End
refactor(Data/FunLike): use unbundled inheritance from FunLike (#8386)

The FunLike hierarchy is very big and gets scanned through each time we need a coercion (via the CoeFun instance). It looks like unbundled inheritance suits Lean 4 better here. The only class that still extends FunLike is EquivLike, since that has a custom coe_injective' field that is easier to implement. All other classes should take FunLike or EquivLike as a parameter.

Zulip thread

Important changes

Previously, morphism classes would be Type-valued and extend FunLike:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  extends FunLike F A B :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

After this PR, they should be Prop-valued and take FunLike as a parameter:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  [FunLike F A B] : Prop :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

(Note that A B stay marked as outParam even though they are not purely required to be so due to the FunLike parameter already filling them in. This is required to see through type synonyms, which is important in the category theory library. Also, I think keeping them as outParam is slightly faster.)

Similarly, MyEquivClass should take EquivLike as a parameter.

As a result, every mention of [MyHomClass F A B] should become [FunLike F A B] [MyHomClass F A B].

Remaining issues

Slower (failing) search

While overall this gives some great speedups, there are some cases that are noticeably slower. In particular, a failing application of a lemma such as map_mul is more expensive. This is due to suboptimal processing of arguments. For example:

variable [FunLike F M N] [Mul M] [Mul N] (f : F) (x : M) (y : M)

theorem map_mul [MulHomClass F M N] : f (x * y) = f x * f y

example [AddHomClass F A B] : f (x * y) = f x * f y := map_mul f _ _

Before this PR, applying map_mul f gives the goals [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Since M and N are out_params, [MulHomClass F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found.

After this PR, the goals become [FunLike F ?M ?N] [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Now [FunLike F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found, before trying MulHomClass F M N which fails. Since the Mul hierarchy is very big, this can be slow to fail, especially when there is no such Mul instance.

A long-term but harder to achieve solution would be to specify the order in which instance goals get solved. For example, we'd like to change the arguments to map_mul to look like [FunLike F M N] [Mul M] [Mul N] [highPriority <| MulHomClass F M N] because MulHomClass fails or succeeds much faster than the others.

As a consequence, the simpNF linter is much slower since by design it tries and fails to apply many map_ lemmas. The same issue occurs a few times in existing calls to simp [map_mul], where map_mul is tried "too soon" and fails. Thanks to the speedup of leanprover/lean4#2478 the impact is very limited, only in files that already were close to the timeout.

simp not firing sometimes

This affects map_smulₛₗ and related definitions. For simp lemmas Lean apparently uses a slightly different mechanism to find instances, so that rw can find every argument to map_smulₛₗ successfully but simp can't: leanprover/lean4#3701.

Missing instances due to unification failing

Especially in the category theory library, we might sometimes have a type A which is also accessible as a synonym (Bundled A hA).1. Instance synthesis doesn't always work if we have f : A →* B but x * y : (Bundled A hA).1 or vice versa. This seems to be mostly fixed by keeping A B as outParams in MulHomClass F A B. (Presumably because Lean will do a definitional check A =?= (Bundled A hA).1 instead of using the syntax in the discrimination tree.)

Workaround for issues

The timeouts can be worked around for now by specifying which map_mul we mean, either as map_mul f for some explicit f, or as e.g. MonoidHomClass.map_mul.

map_smulₛₗ not firing as simp lemma can be worked around by going back to the pre-FunLike situation and making LinearMap.map_smulₛₗ a simp lemma instead of the generic map_smulₛₗ. Writing simp [map_smulₛₗ _] also works.

Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott@tqft.net> Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -341,7 +341,7 @@ lemma disjoint_generalizedEigenspace [NoZeroSMulDivisors R M]
     · ext; simp [smul_sub, sub_sub, smul_comm μ₁, add_sub_left_comm]
     all_goals ext ⟨x, _, _⟩; simpa [LinearMap.restrict_apply, LinearMap.pow_restrict _] using ‹_›
   have hf₁₂ : f₂ - f₁ = algebraMap R (End R p) (μ₁ - μ₂) := by ext; simp [sub_smul]
-  rw [hf₁₂, IsNilpotent.map_iff (NoZeroSMulDivisors.algebraMap_injective _ _),
+  rw [hf₁₂, IsNilpotent.map_iff (NoZeroSMulDivisors.algebraMap_injective R (End R p)),
     isNilpotent_iff_eq_zero, sub_eq_zero] at this
   contradiction
 
@@ -530,7 +530,7 @@ lemma iSup_generalizedEigenspace_inf_le_add
   · rw [LinearMap.mul_apply, LinearMap.pow_map_zero_of_le hj hk₂, LinearMap.map_zero]
 
 lemma map_smul_of_iInf_generalizedEigenspace_ne_bot [NoZeroSMulDivisors R M]
-    {L F : Type*} [SMul R L] [SMulHomClass F R L (End R M)] (f : F)
+    {L F : Type*} [SMul R L] [FunLike F L (End R M)] [SMulHomClass F R L (End R M)] (f : F)
     (μ : L → R) (h_ne : ⨅ x, ⨆ k, (f x).generalizedEigenspace (μ x) k ≠ ⊥)
     (t : R) (x : L) :
     μ (t • x) = t • μ x := by
@@ -543,7 +543,7 @@ lemma map_smul_of_iInf_generalizedEigenspace_ne_bot [NoZeroSMulDivisors R M]
   exact disjoint_iSup_generalizedEigenspace (t • f x) (Ne.symm contra)
 
 lemma map_add_of_iInf_generalizedEigenspace_ne_bot_of_commute [NoZeroSMulDivisors R M]
-    {L F : Type*} [Add L] [AddHomClass F L (End R M)] (f : F)
+    {L F : Type*} [Add L] [FunLike F L (End R M)] [AddHomClass F L (End R M)] (f : F)
     (μ : L → R) (h_ne : ⨅ x, ⨆ k, (f x).generalizedEigenspace (μ x) k ≠ ⊥)
     (h : ∀ x y, Commute (f x) (f y)) (x y : L) :
     μ (x + y) = μ x + μ y := by
feat: Cyclic extensions are kummer. (#9368)

Co-authored-by: Andrew Yang <36414270+erdOne@users.noreply.github.com>

Diff
@@ -109,6 +109,10 @@ theorem HasEigenvector.apply_eq_smul {f : End R M} {μ : R} {x : M} (hx : f.HasE
   mem_eigenspace_iff.mp hx.1
 #align module.End.has_eigenvector.apply_eq_smul Module.End.HasEigenvector.apply_eq_smul
 
+theorem HasEigenvector.pow_apply {f : End R M} {μ : R} {v : M} (hv : f.HasEigenvector μ v) (n : ℕ) :
+    (f ^ n) v = μ ^ n • v := by
+  induction n <;> simp [*, pow_succ f, hv.apply_eq_smul, smul_smul, pow_succ' μ]
+
 theorem HasEigenvalue.exists_hasEigenvector {f : End R M} {μ : R} (hμ : f.HasEigenvalue μ) :
     ∃ v, f.HasEigenvector μ v :=
   Submodule.exists_mem_ne_zero_of_ne_bot hμ
chore(*): drop $/<| before fun (#9361)

Subset of #9319

Diff
@@ -397,7 +397,7 @@ theorem independent_generalizedEigenspace [NoZeroSMulDivisors R M] (f : End R M)
 any eigenspace has trivial intersection with the span of all the other eigenspaces. -/
 theorem eigenspaces_independent [NoZeroSMulDivisors R M] (f : End R M) :
     CompleteLattice.Independent f.eigenspace :=
-  f.independent_generalizedEigenspace.mono <| fun μ ↦ le_iSup (generalizedEigenspace f μ) 1
+  f.independent_generalizedEigenspace.mono fun μ ↦ le_iSup (generalizedEigenspace f μ) 1
 
 /-- Eigenvectors corresponding to distinct eigenvalues of a linear operator are linearly
     independent. (Lemma 5.10 of [axler2015])
chore(*): use ∀ s ⊆ t, _ etc (#9276)

Changes in this PR shouldn't change the public API. The only changes about ∃ x ∈ s, _ is inside a proof.

Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com>

Diff
@@ -358,7 +358,7 @@ lemma injOn_generalizedEigenspace [NoZeroSMulDivisors R M] (f : End R M) :
 theorem independent_generalizedEigenspace [NoZeroSMulDivisors R M] (f : End R M) :
     CompleteLattice.Independent (fun μ ↦ ⨆ k, f.generalizedEigenspace μ k) := by
   classical
-  suffices ∀ μ (s : Finset R) (_ : μ ∉ s), Disjoint (⨆ k, f.generalizedEigenspace μ k)
+  suffices ∀ μ (s : Finset R), μ ∉ s → Disjoint (⨆ k, f.generalizedEigenspace μ k)
       (s.sup fun μ ↦ ⨆ k, f.generalizedEigenspace μ k) by
     simp_rw [CompleteLattice.independent_iff_supIndep_of_injOn f.injOn_generalizedEigenspace,
       Finset.supIndep_iff_disjoint_erase]
feat: a family of generalized eigenvalues for a commuting linear family of endomorphims must be linear (#8656)
Diff
@@ -495,6 +495,63 @@ theorem map_generalizedEigenrange_le {f : End K V} {μ : K} {n : ℕ} :
 
 #align module.End.map_generalized_eigenrange_le Module.End.map_generalizedEigenrange_le
 
+lemma iSup_generalizedEigenspace_le_smul (f : Module.End R M) (μ t : R) :
+    (⨆ k, f.generalizedEigenspace μ k) ≤ ⨆ k, (t • f).generalizedEigenspace (t * μ) k := by
+  intro m hm
+  simp only [Submodule.mem_iSup_of_chain, mem_generalizedEigenspace] at hm ⊢
+  refine Exists.imp (fun k hk ↦ ?_) hm
+  rw [mul_smul, ← smul_sub, smul_pow, LinearMap.smul_apply, hk, smul_zero]
+
+lemma iSup_generalizedEigenspace_inf_le_add
+    (f₁ f₂ : End R M) (μ₁ μ₂ : R) (h : Commute f₁ f₂) :
+    (⨆ k, f₁.generalizedEigenspace μ₁ k) ⊓ (⨆ k, f₂.generalizedEigenspace μ₂ k) ≤
+    ⨆ k, (f₁ + f₂).generalizedEigenspace (μ₁ + μ₂) k := by
+  intro m hm
+  simp only [iSup_le_iff, Submodule.mem_inf, Submodule.mem_iSup_of_chain,
+    mem_generalizedEigenspace] at hm ⊢
+  obtain ⟨⟨k₁, hk₁⟩, ⟨k₂, hk₂⟩⟩ := hm
+  use k₁ + k₂ - 1
+  have : f₁ + f₂ - (μ₁ + μ₂) • 1 = (f₁ - μ₁ • 1) + (f₂ - μ₂ • 1) := by
+    rw [add_smul]; exact add_sub_add_comm f₁ f₂ (μ₁ • 1) (μ₂ • 1)
+  replace h : Commute (f₁ - μ₁ • 1) (f₂ - μ₂ • 1) :=
+    (h.sub_right <| Algebra.commute_algebraMap_right μ₂ f₁).sub_left
+      (Algebra.commute_algebraMap_left μ₁ _)
+  rw [this, h.add_pow', LinearMap.coeFn_sum, Finset.sum_apply]
+  refine Finset.sum_eq_zero fun ⟨i, j⟩ hij ↦ ?_
+  suffices (((f₁ - μ₁ • 1) ^ i) * ((f₂ - μ₂ • 1) ^ j)) m = 0 by
+    rw [LinearMap.smul_apply, this, smul_zero]
+  cases' Nat.le_or_le_of_add_eq_add_pred (Finset.mem_antidiagonal.mp hij) with hi hj
+  · rw [(h.pow_pow i j).eq, LinearMap.mul_apply, LinearMap.pow_map_zero_of_le hi hk₁,
+      LinearMap.map_zero]
+  · rw [LinearMap.mul_apply, LinearMap.pow_map_zero_of_le hj hk₂, LinearMap.map_zero]
+
+lemma map_smul_of_iInf_generalizedEigenspace_ne_bot [NoZeroSMulDivisors R M]
+    {L F : Type*} [SMul R L] [SMulHomClass F R L (End R M)] (f : F)
+    (μ : L → R) (h_ne : ⨅ x, ⨆ k, (f x).generalizedEigenspace (μ x) k ≠ ⊥)
+    (t : R) (x : L) :
+    μ (t • x) = t • μ x := by
+  by_contra contra
+  let g : L → Submodule R M := fun x ↦ ⨆ k, (f x).generalizedEigenspace (μ x) k
+  have : ⨅ x, g x ≤ g x ⊓ g (t • x) := le_inf_iff.mpr ⟨iInf_le g x, iInf_le g (t • x)⟩
+  refine h_ne <| eq_bot_iff.mpr (le_trans this (disjoint_iff_inf_le.mp ?_))
+  apply Disjoint.mono_left (iSup_generalizedEigenspace_le_smul (f x) (μ x) t)
+  simp only [map_smul]
+  exact disjoint_iSup_generalizedEigenspace (t • f x) (Ne.symm contra)
+
+lemma map_add_of_iInf_generalizedEigenspace_ne_bot_of_commute [NoZeroSMulDivisors R M]
+    {L F : Type*} [Add L] [AddHomClass F L (End R M)] (f : F)
+    (μ : L → R) (h_ne : ⨅ x, ⨆ k, (f x).generalizedEigenspace (μ x) k ≠ ⊥)
+    (h : ∀ x y, Commute (f x) (f y)) (x y : L) :
+    μ (x + y) = μ x + μ y := by
+  by_contra contra
+  let g : L → Submodule R M := fun x ↦ ⨆ k, (f x).generalizedEigenspace (μ x) k
+  have : ⨅ x, g x ≤ (g x ⊓ g y) ⊓ g (x + y) :=
+    le_inf_iff.mpr ⟨le_inf_iff.mpr ⟨iInf_le g x, iInf_le g y⟩, iInf_le g (x + y)⟩
+  refine h_ne <| eq_bot_iff.mpr (le_trans this (disjoint_iff_inf_le.mp ?_))
+  apply Disjoint.mono_left (iSup_generalizedEigenspace_inf_le_add (f x) (f y) (μ x) (μ y) (h x y))
+  simp only [map_add]
+  exact disjoint_iSup_generalizedEigenspace (f x + f y) (Ne.symm contra)
+
 end End
 
 end Module
feat: if a Lie algebra has non-degenerate Killing form then its Cartan subalgebras are Abelian (#8430)

Note: the proof (due to Zassenhaus) makes no assumption about the characteristic of the coefficients.

Diff
@@ -295,6 +295,28 @@ lemma mapsTo_iSup_generalizedEigenspace_of_comm {f g : End R M} (h : Commute f g
   rintro x ⟨k, hk⟩
   exact ⟨k, f.mapsTo_generalizedEigenspace_of_comm h μ k hk⟩
 
+/-- The restriction of `f - μ • 1` to the `k`-fold generalized `μ`-eigenspace is nilpotent. -/
+lemma isNilpotent_restrict_sub_algebraMap (f : End R M) (μ : R) (k : ℕ)
+    (h : MapsTo (f - algebraMap R (End R M) μ)
+      (f.generalizedEigenspace μ k) (f.generalizedEigenspace μ k) :=
+      mapsTo_generalizedEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ) μ k) :
+    IsNilpotent ((f - algebraMap R (End R M) μ).restrict h) := by
+  use k
+  ext
+  simp [LinearMap.restrict_apply, LinearMap.pow_restrict _]
+
+/-- The restriction of `f - μ • 1` to the generalized `μ`-eigenspace is nilpotent. -/
+lemma isNilpotent_restrict_iSup_sub_algebraMap [IsNoetherian R M] (f : End R M) (μ : R)
+    (h : MapsTo (f - algebraMap R (End R M) μ)
+      ↑(⨆ k, f.generalizedEigenspace μ k) ↑(⨆ k, f.generalizedEigenspace μ k) :=
+      mapsTo_iSup_generalizedEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ) μ) :
+    IsNilpotent ((f - algebraMap R (End R M) μ).restrict h) := by
+  obtain ⟨l, hl⟩ : ∃ l, ⨆ k, f.generalizedEigenspace μ k = f.generalizedEigenspace μ l :=
+    ⟨_, maximalGeneralizedEigenspace_eq f μ⟩
+  use l
+  ext ⟨x, hx⟩
+  simpa [hl, LinearMap.restrict_apply, LinearMap.pow_restrict _] using hx
+
 lemma disjoint_generalizedEigenspace [NoZeroSMulDivisors R M]
     (f : End R M) {μ₁ μ₂ : R} (hμ : μ₁ ≠ μ₂) (k l : ℕ) :
     Disjoint (f.generalizedEigenspace μ₁ k) (f.generalizedEigenspace μ₂ l) := by
feat: generalized eigenspaces are independent (#8177)

The main change is to upgrade the existing Module.End.eigenspaces_independent, which applied only to eigenspaces (and required a [Field K] assumption) to Module.End.independent_generalizedEigenspace, which applies to generalized eigenspaces (and requires only [NoZeroSMulDivisors R M])

Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>

Diff
@@ -53,7 +53,7 @@ namespace Module
 
 namespace End
 
-open FiniteDimensional
+open FiniteDimensional Set
 
 variable {K R : Type v} {V M : Type w} [CommRing R] [AddCommGroup M] [Module R M] [Field K]
   [AddCommGroup V] [Module K V]
@@ -141,117 +141,6 @@ theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
     _ = LinearMap.ker (b • f - algebraMap K (End K V) a) := by rw [smul_sub, smul_inv_smul₀ hb]
 #align module.End.eigenspace_div Module.End.eigenspace_div
 
-/-- The eigenspaces of a linear operator form an independent family of subspaces of `V`.  That is,
-any eigenspace has trivial intersection with the span of all the other eigenspaces. -/
-theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.eigenspace := by
-  classical
-  -- Define an operation from `Π₀ μ : K, f.eigenspace μ`, the vector space of finitely-supported
-  -- choices of an eigenvector from each eigenspace, to `V`, by sending a collection to its sum.
-  let S : @LinearMap K K _ _ (RingHom.id K) (Π₀ μ : K, f.eigenspace μ) V
-      (@DFinsupp.addCommMonoid K (fun μ => f.eigenspace μ) _) _
-      (@DFinsupp.module K _ (fun μ => f.eigenspace μ) _ _ _) _ :=
-    @DFinsupp.lsum K K ℕ _ V _ _ _ _ _ _ _ _ _ fun μ => (f.eigenspace μ).subtype
-  -- We need to show that if a finitely-supported collection `l` of representatives of the
-  -- eigenspaces has sum `0`, then it itself is zero.
-  suffices ∀ l : Π₀ μ, f.eigenspace μ, S l = 0 → l = 0 by
-    rw [CompleteLattice.independent_iff_dfinsupp_lsum_injective]
-    change Function.Injective S
-    rw [← @LinearMap.ker_eq_bot K K (Π₀ μ, f.eigenspace μ) V _ _
-      (@DFinsupp.addCommGroup K (fun μ => f.eigenspace μ) _)]
-    rw [eq_bot_iff]
-    exact this
-  intro l hl
-  -- We apply induction on the finite set of eigenvalues from which `l` selects a nonzero
-  -- eigenvector, i.e. on the support of `l`.
-  induction' h_l_support : l.support using Finset.induction with μ₀ l_support' hμ₀ ih generalizing l
-  -- If the support is empty, all coefficients are zero and we are done.
-  · exact DFinsupp.support_eq_empty.1 h_l_support
-  -- Now assume that the support of `l` contains at least one eigenvalue `μ₀`. We define a new
-  -- collection of representatives `l'` to apply the induction hypothesis on later. The collection
-  -- of representatives `l'` is derived from `l` by multiplying the coefficient of the eigenvector
-  -- with eigenvalue `μ` by `μ - μ₀`.
-  · let l' := DFinsupp.mapRange.linearMap
-      (fun μ => (μ - μ₀) • @LinearMap.id K (f.eigenspace μ) _ _ _) l
-    -- The support of `l'` is the support of `l` without `μ₀`.
-    have h_l_support' : l'.support = l_support' := by
-      rw [← Finset.erase_insert hμ₀, ← h_l_support]
-      ext a
-      have : ¬(a = μ₀ ∨ l a = 0) ↔ ¬a = μ₀ ∧ ¬l a = 0 := not_or
-      simp only [DFinsupp.mapRange.linearMap_apply, DFinsupp.mapRange_apply,
-        DFinsupp.mem_support_iff, Finset.mem_erase, id.def, LinearMap.id_coe, LinearMap.smul_apply,
-        Ne.def, smul_eq_zero, sub_eq_zero, this]
-    -- The entries of `l'` add up to `0`.
-    have total_l' : S l' = 0 := by
-      let g := f - algebraMap K (End K V) μ₀
-      let a : Π₀ _ : K, V := DFinsupp.mapRange.linearMap (fun μ => (f.eigenspace μ).subtype) l
-      calc
-        S l' =
-          DFinsupp.lsum ℕ (fun μ => (f.eigenspace μ).subtype.comp ((μ - μ₀) • LinearMap.id)) l := ?_
-        _ = DFinsupp.lsum ℕ (fun μ => g.comp (f.eigenspace μ).subtype) l := ?_
-        _ = DFinsupp.lsum ℕ (fun _ => g) a := ?_
-        _ = g (DFinsupp.lsum ℕ (fun _ => (LinearMap.id : V →ₗ[K] V)) a) := ?_
-        _ = g (S l) := ?_
-        _ = 0 := by rw [hl, g.map_zero]
-      · exact DFinsupp.sum_mapRange_index.linearMap
-      · congr
-        ext μ v
-        simp only [LinearMap.coe_comp, Function.comp_apply, LinearMap.smul_apply, LinearMap.id_coe,
-          id.def, sub_smul, Submodule.subtype_apply, Submodule.coe_sub, Submodule.coe_smul_of_tower,
-          LinearMap.sub_apply, mem_eigenspace_iff.1 v.prop, algebraMap_end_apply]
-      · rw [DFinsupp.sum_mapRange_index.linearMap]
-      · simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, map_dfinsupp_sum, id.def,
-          LinearMap.toAddMonoidHom_coe, DFinsupp.lsum_apply_apply]
-      · simp only [DFinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
-    -- Therefore, by the induction hypothesis, all entries of `l'` are zero.
-    have l'_eq_0 := ih l' total_l' h_l_support'
-    -- By the definition of `l'`, this means that `(μ - μ₀) • l μ = 0` for all `μ`.
-    have h_smul_eq_0 : ∀ μ, (μ - μ₀) • l μ = 0 := by
-      intro μ
-      calc
-        (μ - μ₀) • l μ = l' μ := by
-          simp only [LinearMap.id_coe, id.def, LinearMap.smul_apply, DFinsupp.mapRange_apply,
-            DFinsupp.mapRange.linearMap_apply]
-        _ = 0 := by rw [l'_eq_0]; rfl
-    -- Thus, the eigenspace-representatives in `l` for all `μ ≠ μ₀` are `0`.
-    have h_lμ_eq_0 : ∀ μ : K, μ ≠ μ₀ → l μ = 0 := by
-      intro μ hμ
-      apply or_iff_not_imp_left.1 (smul_eq_zero.1 (h_smul_eq_0 μ))
-      rwa [sub_eq_zero]
-    -- So if we sum over all these representatives, we obtain `0`.
-    have h_sum_l_support'_eq_0 : (Finset.sum l_support' fun μ => (l μ : V)) = 0 := by
-      rw [← Finset.sum_const_zero]
-      apply Finset.sum_congr rfl
-      intro μ hμ
-      rw [Submodule.coe_eq_zero, h_lμ_eq_0]
-      rintro rfl
-      exact hμ₀ hμ
-    -- The only potentially nonzero eigenspace-representative in `l` is the one corresponding to
-    -- `μ₀`. But since the overall sum is `0` by assumption, this representative must also be `0`.
-    have : l μ₀ = 0 := by
-      simp only [DFinsupp.lsum_apply_apply, DFinsupp.sumAddHom_apply,
-        LinearMap.toAddMonoidHom_coe, DFinsupp.sum, h_l_support, Submodule.subtype_apply,
-        Submodule.coe_eq_zero, Finset.sum_insert hμ₀, h_sum_l_support'_eq_0, add_zero] at hl
-      exact hl
-    -- Thus, all coefficients in `l` are `0`.
-    show l = 0
-    · ext μ
-      by_cases h_cases : μ = μ₀
-      · rwa [h_cases, SetLike.coe_eq_coe, DFinsupp.coe_zero, Pi.zero_apply]
-      · exact congr_arg _ (h_lμ_eq_0 μ h_cases)
-#align module.End.eigenspaces_independent Module.End.eigenspaces_independent
-
-/-- Eigenvectors corresponding to distinct eigenvalues of a linear operator are linearly
-    independent. (Lemma 5.10 of [axler2015])
-
-    We use the eigenvalues as indexing set to ensure that there is only one eigenvector for each
-    eigenvalue in the image of `xs`. -/
-theorem eigenvectors_linearIndependent (f : End K V) (μs : Set K) (xs : μs → V)
-    (h_eigenvec : ∀ μ : μs, f.HasEigenvector μ (xs μ)) : LinearIndependent K xs :=
-  CompleteLattice.Independent.linearIndependent _
-    (f.eigenspaces_independent.comp Subtype.coe_injective) (fun μ => (h_eigenvec μ).1) fun μ =>
-    (h_eigenvec μ).2
-#align module.End.eigenvectors_linear_independent Module.End.eigenvectors_linearIndependent
-
 /-- The generalized eigenspace for a linear map `f`, a scalar `μ`, and an exponent `k ∈ ℕ` is the
 kernel of `(f - μ • id) ^ k`. (Def 8.10 of [axler2015]). Furthermore, a generalized eigenspace for
 some exponent `k` is contained in the generalized eigenspace for exponents larger than `k`. -/
@@ -379,6 +268,11 @@ theorem generalizedEigenspace_le_generalizedEigenspace_finrank [FiniteDimensiona
   ker_pow_le_ker_pow_finrank _ _
 #align module.End.generalized_eigenspace_le_generalized_eigenspace_finrank Module.End.generalizedEigenspace_le_generalizedEigenspace_finrank
 
+@[simp] theorem iSup_generalizedEigenspace_eq_generalizedEigenspace_finrank
+    [FiniteDimensional K V] (f : End K V) (μ : K) :
+    ⨆ k, f.generalizedEigenspace μ k = f.generalizedEigenspace μ (finrank K V) :=
+  le_antisymm (iSup_le (generalizedEigenspace_le_generalizedEigenspace_finrank f μ)) (le_iSup _ _)
+
 /-- Generalized eigenspaces for exponents at least `finrank K V` are equal to each other. -/
 theorem generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le [FiniteDimensional K V]
     (f : End K V) (μ : K) {k : ℕ} (hk : finrank K V ≤ k) :
@@ -386,6 +280,116 @@ theorem generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le [FiniteDime
   ker_pow_eq_ker_pow_finrank_of_le hk
 #align module.End.generalized_eigenspace_eq_generalized_eigenspace_finrank_of_le Module.End.generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le
 
+lemma mapsTo_generalizedEigenspace_of_comm {f g : End R M} (h : Commute f g) (μ : R) (k : ℕ) :
+    MapsTo g (f.generalizedEigenspace μ k) (f.generalizedEigenspace μ k) := by
+  replace h : Commute ((f - μ • (1 : End R M)) ^ k) g :=
+    (h.sub_left <| Algebra.commute_algebraMap_left μ g).pow_left k
+  intro x hx
+  simp only [SetLike.mem_coe, mem_generalizedEigenspace] at hx ⊢
+  rw [← LinearMap.comp_apply, ← LinearMap.mul_eq_comp, h.eq, LinearMap.mul_eq_comp,
+    LinearMap.comp_apply, hx, map_zero]
+
+lemma mapsTo_iSup_generalizedEigenspace_of_comm {f g : End R M} (h : Commute f g) (μ : R) :
+    MapsTo g ↑(⨆ k, f.generalizedEigenspace μ k) ↑(⨆ k, f.generalizedEigenspace μ k) := by
+  simp only [MapsTo, Submodule.coe_iSup_of_chain, mem_iUnion, SetLike.mem_coe]
+  rintro x ⟨k, hk⟩
+  exact ⟨k, f.mapsTo_generalizedEigenspace_of_comm h μ k hk⟩
+
+lemma disjoint_generalizedEigenspace [NoZeroSMulDivisors R M]
+    (f : End R M) {μ₁ μ₂ : R} (hμ : μ₁ ≠ μ₂) (k l : ℕ) :
+    Disjoint (f.generalizedEigenspace μ₁ k) (f.generalizedEigenspace μ₂ l) := by
+  nontriviality M
+  have := NoZeroSMulDivisors.isReduced R M
+  rw [disjoint_iff]
+  set p := f.generalizedEigenspace μ₁ k ⊓ f.generalizedEigenspace μ₂ l
+  by_contra hp
+  replace hp : Nontrivial p := Submodule.nontrivial_iff_ne_bot.mpr hp
+  let f₁ : End R p := (f - algebraMap R (End R M) μ₁).restrict <| MapsTo.inter_inter
+    (mapsTo_generalizedEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ₁) μ₁ k)
+    (mapsTo_generalizedEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ₁) μ₂ l)
+  let f₂ : End R p := (f - algebraMap R (End R M) μ₂).restrict <| MapsTo.inter_inter
+    (mapsTo_generalizedEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ₂) μ₁ k)
+    (mapsTo_generalizedEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ₂) μ₂ l)
+  have : IsNilpotent (f₂ - f₁) := by
+    apply Commute.isNilpotent_sub (x := f₂) (y := f₁) _ ⟨l, ?_⟩ ⟨k, ?_⟩
+    · ext; simp [smul_sub, sub_sub, smul_comm μ₁, add_sub_left_comm]
+    all_goals ext ⟨x, _, _⟩; simpa [LinearMap.restrict_apply, LinearMap.pow_restrict _] using ‹_›
+  have hf₁₂ : f₂ - f₁ = algebraMap R (End R p) (μ₁ - μ₂) := by ext; simp [sub_smul]
+  rw [hf₁₂, IsNilpotent.map_iff (NoZeroSMulDivisors.algebraMap_injective _ _),
+    isNilpotent_iff_eq_zero, sub_eq_zero] at this
+  contradiction
+
+lemma disjoint_iSup_generalizedEigenspace [NoZeroSMulDivisors R M]
+    (f : End R M) {μ₁ μ₂ : R} (hμ : μ₁ ≠ μ₂) :
+    Disjoint (⨆ k, f.generalizedEigenspace μ₁ k) (⨆ k, f.generalizedEigenspace μ₂ k) := by
+  simp_rw [(f.generalizedEigenspace μ₁).mono.directed_le.disjoint_iSup_left,
+    (f.generalizedEigenspace μ₂).mono.directed_le.disjoint_iSup_right]
+  exact disjoint_generalizedEigenspace f hμ
+
+lemma injOn_generalizedEigenspace [NoZeroSMulDivisors R M] (f : End R M) :
+    InjOn (⨆ k, f.generalizedEigenspace · k) {μ | ⨆ k, f.generalizedEigenspace μ k ≠ ⊥} := by
+  rintro μ₁ _ μ₂ hμ₂ (hμ₁₂ : ⨆ k, f.generalizedEigenspace μ₁ k = ⨆ k, f.generalizedEigenspace μ₂ k)
+  by_contra contra
+  apply hμ₂
+  simpa only [hμ₁₂, disjoint_self] using f.disjoint_iSup_generalizedEigenspace contra
+
+theorem independent_generalizedEigenspace [NoZeroSMulDivisors R M] (f : End R M) :
+    CompleteLattice.Independent (fun μ ↦ ⨆ k, f.generalizedEigenspace μ k) := by
+  classical
+  suffices ∀ μ (s : Finset R) (_ : μ ∉ s), Disjoint (⨆ k, f.generalizedEigenspace μ k)
+      (s.sup fun μ ↦ ⨆ k, f.generalizedEigenspace μ k) by
+    simp_rw [CompleteLattice.independent_iff_supIndep_of_injOn f.injOn_generalizedEigenspace,
+      Finset.supIndep_iff_disjoint_erase]
+    exact fun s μ _ ↦ this _ _ (s.not_mem_erase μ)
+  intro μ₁ s
+  induction' s using Finset.induction_on with μ₂ s _ ih; simp
+  intro hμ₁₂
+  obtain ⟨hμ₁₂ : μ₁ ≠ μ₂, hμ₁ : μ₁ ∉ s⟩ := by rwa [Finset.mem_insert, not_or] at hμ₁₂
+  specialize ih hμ₁
+  rw [Finset.sup_insert, disjoint_iff, Submodule.eq_bot_iff]
+  rintro x ⟨hx, hx'⟩
+  simp only [SetLike.mem_coe] at hx hx'
+  suffices x ∈ ⨆ k, generalizedEigenspace f μ₂ k by
+    rw [← Submodule.mem_bot (R := R), ← (f.disjoint_iSup_generalizedEigenspace hμ₁₂).eq_bot]
+    exact ⟨hx, this⟩
+  obtain ⟨y, hy, z, hz, rfl⟩ := Submodule.mem_sup.mp hx'; clear hx'
+  let g := f - algebraMap R (End R M) μ₂
+  obtain ⟨k : ℕ, hk : (g ^ k) y = 0⟩ := by simpa using hy
+  have hyz : (g ^ k) (y + z) ∈
+      (⨆ k, generalizedEigenspace f μ₁ k) ⊓ s.sup fun μ ↦ ⨆ k, f.generalizedEigenspace μ k := by
+    refine ⟨f.mapsTo_iSup_generalizedEigenspace_of_comm ?_ μ₁ hx, ?_⟩
+    · exact Algebra.mul_sub_algebraMap_pow_commutes f μ₂ k
+    · rw [SetLike.mem_coe, map_add, hk, zero_add]
+      suffices (s.sup fun μ ↦ ⨆ k, f.generalizedEigenspace μ k).map (g ^ k) ≤
+          s.sup fun μ ↦ ⨆ k, f.generalizedEigenspace μ k by exact this (Submodule.mem_map_of_mem hz)
+      simp_rw [Finset.sup_eq_iSup, Submodule.map_iSup (ι := R), Submodule.map_iSup (ι := _ ∈ s)]
+      refine iSup₂_mono fun μ _ ↦ ?_
+      rintro - ⟨u, hu, rfl⟩
+      refine f.mapsTo_iSup_generalizedEigenspace_of_comm ?_ μ hu
+      exact Algebra.mul_sub_algebraMap_pow_commutes f μ₂ k
+  rw [ih.eq_bot, Submodule.mem_bot] at hyz
+  simp_rw [Submodule.mem_iSup_of_chain, mem_generalizedEigenspace]
+  exact ⟨k, hyz⟩
+
+/-- The eigenspaces of a linear operator form an independent family of subspaces of `M`.  That is,
+any eigenspace has trivial intersection with the span of all the other eigenspaces. -/
+theorem eigenspaces_independent [NoZeroSMulDivisors R M] (f : End R M) :
+    CompleteLattice.Independent f.eigenspace :=
+  f.independent_generalizedEigenspace.mono <| fun μ ↦ le_iSup (generalizedEigenspace f μ) 1
+
+/-- Eigenvectors corresponding to distinct eigenvalues of a linear operator are linearly
+    independent. (Lemma 5.10 of [axler2015])
+
+    We use the eigenvalues as indexing set to ensure that there is only one eigenvector for each
+    eigenvalue in the image of `xs`. -/
+theorem eigenvectors_linearIndependent [NoZeroSMulDivisors R M]
+    (f : End R M) (μs : Set R) (xs : μs → M)
+    (h_eigenvec : ∀ μ : μs, f.HasEigenvector μ (xs μ)) : LinearIndependent R xs :=
+  CompleteLattice.Independent.linearIndependent _
+    (f.eigenspaces_independent.comp Subtype.coe_injective) (fun μ => (h_eigenvec μ).1) fun μ =>
+    (h_eigenvec μ).2
+#align module.End.eigenvectors_linear_independent Module.End.eigenvectors_linearIndependent
+
 /-- If `f` maps a subspace `p` into itself, then the generalized eigenspace of the restriction
     of `f` to `p` is the part of the generalized eigenspace of `f` that lies in `p`. -/
 theorem generalizedEigenspace_restrict (f : End R M) (p : Submodule R M) (k : ℕ) (μ : R)
@@ -400,6 +404,12 @@ theorem generalizedEigenspace_restrict (f : End R M) (p : Submodule R M) (k : 
       LinearMap.comp_assoc]
 #align module.End.generalized_eigenspace_restrict Module.End.generalizedEigenspace_restrict
 
+lemma _root_.Submodule.inf_generalizedEigenspace (f : End R M) (p : Submodule R M) {k : ℕ} {μ : R}
+    (hfp : ∀ x : M, x ∈ p → f x ∈ p) :
+    p ⊓ f.generalizedEigenspace μ k =
+      (generalizedEigenspace (LinearMap.restrict f hfp) μ k).map p.subtype := by
+  rw [f.generalizedEigenspace_restrict _ _ _ hfp, Submodule.map_comap_eq, Submodule.range_subtype]
+
 /-- If `p` is an invariant submodule of an endomorphism `f`, then the `μ`-eigenspace of the
 restriction of `f` to `p` is a submodule of the `μ`-eigenspace of `f`. -/
 theorem eigenspace_restrict_le_eigenspace (f : End R M) {p : Submodule R M} (hfp : ∀ x ∈ p, f x ∈ p)
chore: unify map_dfinsupp_sum/prod lemmas (#7151)
Diff
@@ -199,7 +199,7 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
           id.def, sub_smul, Submodule.subtype_apply, Submodule.coe_sub, Submodule.coe_smul_of_tower,
           LinearMap.sub_apply, mem_eigenspace_iff.1 v.prop, algebraMap_end_apply]
       · rw [DFinsupp.sum_mapRange_index.linearMap]
-      · simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, LinearMap.map_dfinsupp_sum, id.def,
+      · simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, map_dfinsupp_sum, id.def,
           LinearMap.toAddMonoidHom_coe, DFinsupp.lsum_apply_apply]
       · simp only [DFinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
     -- Therefore, by the induction hypothesis, all entries of `l'` are zero.
chore: use FunLike for OrderHom (#5805)

Co-authored-by: Jujian Zhang <jujian.zhang1998@outlook.com> Co-authored-by: Oliver Nash <github@olivernash.org>

Diff
@@ -353,7 +353,7 @@ theorem eigenspace_le_generalizedEigenspace {f : End R M} {μ : R} {k : ℕ} (hk
 theorem hasGeneralizedEigenvalue_of_hasEigenvalue {f : End R M} {μ : R} {k : ℕ} (hk : 0 < k)
     (hμ : f.HasEigenvalue μ) : f.HasGeneralizedEigenvalue μ k := by
   apply hasGeneralizedEigenvalue_of_hasGeneralizedEigenvalue_of_le hk
-  rw [HasGeneralizedEigenvalue, generalizedEigenspace, OrderHom.coe_fun_mk, pow_one]
+  rw [HasGeneralizedEigenvalue, generalizedEigenspace, OrderHom.coe_mk, pow_one]
   exact hμ
 #align module.End.has_generalized_eigenvalue_of_has_eigenvalue Module.End.hasGeneralizedEigenvalue_of_hasEigenvalue
 
@@ -392,7 +392,7 @@ theorem generalizedEigenspace_restrict (f : End R M) (p : Submodule R M) (k : 
     (hfp : ∀ x : M, x ∈ p → f x ∈ p) :
     generalizedEigenspace (LinearMap.restrict f hfp) μ k =
       Submodule.comap p.subtype (f.generalizedEigenspace μ k) := by
-  simp only [generalizedEigenspace, OrderHom.coe_fun_mk, ← LinearMap.ker_comp]
+  simp only [generalizedEigenspace, OrderHom.coe_mk, ← LinearMap.ker_comp]
   induction' k with k ih
   · rw [pow_zero, pow_zero, LinearMap.one_eq_id]
     apply (Submodule.ker_subtype _).symm
@@ -419,7 +419,7 @@ theorem generalized_eigenvec_disjoint_range_ker [FiniteDimensional K V] (f : End
         (f.generalizedEigenspace μ (finrank K V)) =
           LinearMap.ker ((f - algebraMap _ _ μ) ^ finrank K V *
             (f - algebraMap K (End K V) μ) ^ finrank K V) := by
-              rw [generalizedEigenspace, OrderHom.coe_fun_mk, ← LinearMap.ker_comp]; rfl
+              rw [generalizedEigenspace, OrderHom.coe_mk, ← LinearMap.ker_comp]; rfl
       _ = f.generalizedEigenspace μ (finrank K V + finrank K V) := by rw [← pow_add]; rfl
       _ = f.generalizedEigenspace μ (finrank K V) := by
         rw [generalizedEigenspace_eq_generalizedEigenspace_finrank_of_le]; linarith
chore: fix grammar mistakes (#6121)
Diff
@@ -145,7 +145,7 @@ theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
 any eigenspace has trivial intersection with the span of all the other eigenspaces. -/
 theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.eigenspace := by
   classical
-  -- Define an operation from `Π₀ μ : K, f.eigenspace μ`, the vector space of of finitely-supported
+  -- Define an operation from `Π₀ μ : K, f.eigenspace μ`, the vector space of finitely-supported
   -- choices of an eigenvector from each eigenspace, to `V`, by sending a collection to its sum.
   let S : @LinearMap K K _ _ (RingHom.id K) (Π₀ μ : K, f.eigenspace μ) V
       (@DFinsupp.addCommMonoid K (fun μ => f.eigenspace μ) _) _
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,16 +2,13 @@
 Copyright (c) 2020 Alexander Bentkamp. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alexander Bentkamp
-
-! This file was ported from Lean 3 source module linear_algebra.eigenspace.basic
-! leanprover-community/mathlib commit 6b0169218d01f2837d79ea2784882009a0da1aa1
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Algebra.Algebra.Spectrum
 import Mathlib.LinearAlgebra.GeneralLinearGroup
 import Mathlib.LinearAlgebra.FiniteDimensional
 
+#align_import linear_algebra.eigenspace.basic from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1"
+
 /-!
 # Eigenvectors and eigenvalues
 
chore: cleanup whitespace (#5988)

Grepping for [^ .:{-] [^ :] and reviewing the results. Once I started I couldn't stop. :-)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -141,7 +141,7 @@ theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
     _ = LinearMap.ker (f - b⁻¹ • algebraMap K (End K V) a) := rfl
     _ = LinearMap.ker (b • (f - b⁻¹ • algebraMap K (End K V) a)) := by
         rw [LinearMap.ker_smul _ b hb]
-    _ =  LinearMap.ker (b • f - algebraMap K (End K V) a) := by rw [smul_sub, smul_inv_smul₀ hb]
+    _ = LinearMap.ker (b • f - algebraMap K (End K V) a) := by rw [smul_sub, smul_inv_smul₀ hb]
 #align module.End.eigenspace_div Module.End.eigenspace_div
 
 /-- The eigenspaces of a linear operator form an independent family of subspaces of `V`.  That is,
@@ -159,7 +159,7 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
   suffices ∀ l : Π₀ μ, f.eigenspace μ, S l = 0 → l = 0 by
     rw [CompleteLattice.independent_iff_dfinsupp_lsum_injective]
     change Function.Injective S
-    rw [←  @LinearMap.ker_eq_bot K K (Π₀ μ, f.eigenspace μ) V _ _
+    rw [← @LinearMap.ker_eq_bot K K (Π₀ μ, f.eigenspace μ) V _ _
       (@DFinsupp.addCommGroup K (fun μ => f.eigenspace μ) _)]
     rw [eq_bot_iff]
     exact this
chore: rename Dfinsupp to DFinsupp (#5822)

See #4354

Diff
@@ -151,16 +151,16 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
   -- Define an operation from `Π₀ μ : K, f.eigenspace μ`, the vector space of of finitely-supported
   -- choices of an eigenvector from each eigenspace, to `V`, by sending a collection to its sum.
   let S : @LinearMap K K _ _ (RingHom.id K) (Π₀ μ : K, f.eigenspace μ) V
-      (@Dfinsupp.addCommMonoid K (fun μ => f.eigenspace μ) _) _
-      (@Dfinsupp.module K _ (fun μ => f.eigenspace μ) _ _ _) _ :=
-    @Dfinsupp.lsum K K ℕ _ V _ _ _ _ _ _ _ _ _ fun μ => (f.eigenspace μ).subtype
+      (@DFinsupp.addCommMonoid K (fun μ => f.eigenspace μ) _) _
+      (@DFinsupp.module K _ (fun μ => f.eigenspace μ) _ _ _) _ :=
+    @DFinsupp.lsum K K ℕ _ V _ _ _ _ _ _ _ _ _ fun μ => (f.eigenspace μ).subtype
   -- We need to show that if a finitely-supported collection `l` of representatives of the
   -- eigenspaces has sum `0`, then it itself is zero.
   suffices ∀ l : Π₀ μ, f.eigenspace μ, S l = 0 → l = 0 by
     rw [CompleteLattice.independent_iff_dfinsupp_lsum_injective]
     change Function.Injective S
     rw [←  @LinearMap.ker_eq_bot K K (Π₀ μ, f.eigenspace μ) V _ _
-      (@Dfinsupp.addCommGroup K (fun μ => f.eigenspace μ) _)]
+      (@DFinsupp.addCommGroup K (fun μ => f.eigenspace μ) _)]
     rw [eq_bot_iff]
     exact this
   intro l hl
@@ -168,43 +168,43 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
   -- eigenvector, i.e. on the support of `l`.
   induction' h_l_support : l.support using Finset.induction with μ₀ l_support' hμ₀ ih generalizing l
   -- If the support is empty, all coefficients are zero and we are done.
-  · exact Dfinsupp.support_eq_empty.1 h_l_support
+  · exact DFinsupp.support_eq_empty.1 h_l_support
   -- Now assume that the support of `l` contains at least one eigenvalue `μ₀`. We define a new
   -- collection of representatives `l'` to apply the induction hypothesis on later. The collection
   -- of representatives `l'` is derived from `l` by multiplying the coefficient of the eigenvector
   -- with eigenvalue `μ` by `μ - μ₀`.
-  · let l' := Dfinsupp.mapRange.linearMap
+  · let l' := DFinsupp.mapRange.linearMap
       (fun μ => (μ - μ₀) • @LinearMap.id K (f.eigenspace μ) _ _ _) l
     -- The support of `l'` is the support of `l` without `μ₀`.
     have h_l_support' : l'.support = l_support' := by
       rw [← Finset.erase_insert hμ₀, ← h_l_support]
       ext a
       have : ¬(a = μ₀ ∨ l a = 0) ↔ ¬a = μ₀ ∧ ¬l a = 0 := not_or
-      simp only [Dfinsupp.mapRange.linearMap_apply, Dfinsupp.mapRange_apply,
-        Dfinsupp.mem_support_iff, Finset.mem_erase, id.def, LinearMap.id_coe, LinearMap.smul_apply,
+      simp only [DFinsupp.mapRange.linearMap_apply, DFinsupp.mapRange_apply,
+        DFinsupp.mem_support_iff, Finset.mem_erase, id.def, LinearMap.id_coe, LinearMap.smul_apply,
         Ne.def, smul_eq_zero, sub_eq_zero, this]
     -- The entries of `l'` add up to `0`.
     have total_l' : S l' = 0 := by
       let g := f - algebraMap K (End K V) μ₀
-      let a : Π₀ _ : K, V := Dfinsupp.mapRange.linearMap (fun μ => (f.eigenspace μ).subtype) l
+      let a : Π₀ _ : K, V := DFinsupp.mapRange.linearMap (fun μ => (f.eigenspace μ).subtype) l
       calc
         S l' =
-          Dfinsupp.lsum ℕ (fun μ => (f.eigenspace μ).subtype.comp ((μ - μ₀) • LinearMap.id)) l := ?_
-        _ = Dfinsupp.lsum ℕ (fun μ => g.comp (f.eigenspace μ).subtype) l := ?_
-        _ = Dfinsupp.lsum ℕ (fun _ => g) a := ?_
-        _ = g (Dfinsupp.lsum ℕ (fun _ => (LinearMap.id : V →ₗ[K] V)) a) := ?_
+          DFinsupp.lsum ℕ (fun μ => (f.eigenspace μ).subtype.comp ((μ - μ₀) • LinearMap.id)) l := ?_
+        _ = DFinsupp.lsum ℕ (fun μ => g.comp (f.eigenspace μ).subtype) l := ?_
+        _ = DFinsupp.lsum ℕ (fun _ => g) a := ?_
+        _ = g (DFinsupp.lsum ℕ (fun _ => (LinearMap.id : V →ₗ[K] V)) a) := ?_
         _ = g (S l) := ?_
         _ = 0 := by rw [hl, g.map_zero]
-      · exact Dfinsupp.sum_mapRange_index.linearMap
+      · exact DFinsupp.sum_mapRange_index.linearMap
       · congr
         ext μ v
         simp only [LinearMap.coe_comp, Function.comp_apply, LinearMap.smul_apply, LinearMap.id_coe,
           id.def, sub_smul, Submodule.subtype_apply, Submodule.coe_sub, Submodule.coe_smul_of_tower,
           LinearMap.sub_apply, mem_eigenspace_iff.1 v.prop, algebraMap_end_apply]
-      · rw [Dfinsupp.sum_mapRange_index.linearMap]
-      · simp only [Dfinsupp.sumAddHom_apply, LinearMap.id_coe, LinearMap.map_dfinsupp_sum, id.def,
-          LinearMap.toAddMonoidHom_coe, Dfinsupp.lsum_apply_apply]
-      · simp only [Dfinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
+      · rw [DFinsupp.sum_mapRange_index.linearMap]
+      · simp only [DFinsupp.sumAddHom_apply, LinearMap.id_coe, LinearMap.map_dfinsupp_sum, id.def,
+          LinearMap.toAddMonoidHom_coe, DFinsupp.lsum_apply_apply]
+      · simp only [DFinsupp.sum_mapRange_index.linearMap, LinearMap.id_comp]
     -- Therefore, by the induction hypothesis, all entries of `l'` are zero.
     have l'_eq_0 := ih l' total_l' h_l_support'
     -- By the definition of `l'`, this means that `(μ - μ₀) • l μ = 0` for all `μ`.
@@ -212,8 +212,8 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
       intro μ
       calc
         (μ - μ₀) • l μ = l' μ := by
-          simp only [LinearMap.id_coe, id.def, LinearMap.smul_apply, Dfinsupp.mapRange_apply,
-            Dfinsupp.mapRange.linearMap_apply]
+          simp only [LinearMap.id_coe, id.def, LinearMap.smul_apply, DFinsupp.mapRange_apply,
+            DFinsupp.mapRange.linearMap_apply]
         _ = 0 := by rw [l'_eq_0]; rfl
     -- Thus, the eigenspace-representatives in `l` for all `μ ≠ μ₀` are `0`.
     have h_lμ_eq_0 : ∀ μ : K, μ ≠ μ₀ → l μ = 0 := by
@@ -231,15 +231,15 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
     -- The only potentially nonzero eigenspace-representative in `l` is the one corresponding to
     -- `μ₀`. But since the overall sum is `0` by assumption, this representative must also be `0`.
     have : l μ₀ = 0 := by
-      simp only [Dfinsupp.lsum_apply_apply, Dfinsupp.sumAddHom_apply,
-        LinearMap.toAddMonoidHom_coe, Dfinsupp.sum, h_l_support, Submodule.subtype_apply,
+      simp only [DFinsupp.lsum_apply_apply, DFinsupp.sumAddHom_apply,
+        LinearMap.toAddMonoidHom_coe, DFinsupp.sum, h_l_support, Submodule.subtype_apply,
         Submodule.coe_eq_zero, Finset.sum_insert hμ₀, h_sum_l_support'_eq_0, add_zero] at hl
       exact hl
     -- Thus, all coefficients in `l` are `0`.
     show l = 0
     · ext μ
       by_cases h_cases : μ = μ₀
-      · rwa [h_cases, SetLike.coe_eq_coe, Dfinsupp.coe_zero, Pi.zero_apply]
+      · rwa [h_cases, SetLike.coe_eq_coe, DFinsupp.coe_zero, Pi.zero_apply]
       · exact congr_arg _ (h_lμ_eq_0 μ h_cases)
 #align module.End.eigenspaces_independent Module.End.eigenspaces_independent
 
chore: remove superfluous parentheses in calls to ext (#5258)

Co-authored-by: Xavier Roblot <46200072+xroblot@users.noreply.github.com> Co-authored-by: Joël Riou <joel.riou@universite-paris-saclay.fr> Co-authored-by: Riccardo Brasca <riccardo.brasca@gmail.com> Co-authored-by: Yury G. Kudryashov <urkud@urkud.name> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com> Co-authored-by: Pol'tta / Miyahara Kō <pol_tta@outlook.jp> Co-authored-by: Jason Yuen <jason_yuen2007@hotmail.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com> Co-authored-by: Jireh Loreaux <loreaujy@gmail.com> Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: Heather Macbeth <25316162+hrmacbeth@users.noreply.github.com> Co-authored-by: Jujian Zhang <jujian.zhang1998@outlook.com> Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>

Diff
@@ -197,7 +197,7 @@ theorem eigenspaces_independent (f : End K V) : CompleteLattice.Independent f.ei
         _ = 0 := by rw [hl, g.map_zero]
       · exact Dfinsupp.sum_mapRange_index.linearMap
       · congr
-        ext (μ v)
+        ext μ v
         simp only [LinearMap.coe_comp, Function.comp_apply, LinearMap.smul_apply, LinearMap.id_coe,
           id.def, sub_smul, Submodule.subtype_apply, Submodule.coe_sub, Submodule.coe_smul_of_tower,
           LinearMap.sub_apply, mem_eigenspace_iff.1 v.prop, algebraMap_end_apply]
feat: port Analysis.InnerProductSpace.Spectrum (#5058)

Co-authored-by: Johan Commelin <johan@commelin.net>

Diff
@@ -87,8 +87,15 @@ def Eigenvalues (f : End R M) : Type _ :=
   { μ : R // f.HasEigenvalue μ }
 #align module.End.eigenvalues Module.End.Eigenvalues
 
--- Porting note: this instance does not compile and does not seem to be used in this file
--- instance (f : End R M) : Coe f.Eigenvalues R := coeSubtype
+@[coe]
+def Eigenvalues.val (f : Module.End R M) : Eigenvalues f → R := Subtype.val
+
+instance Eigenvalues.instCoeOut {f : Module.End R M} : CoeOut (Eigenvalues f) R where
+  coe := Eigenvalues.val f
+
+instance Eigenvalues.instDecidableEq [DecidableEq R] (f : Module.End R M) :
+    DecidableEq (Eigenvalues f) :=
+  inferInstanceAs (DecidableEq (Subtype (fun x : R => HasEigenvalue f x)))
 
 theorem hasEigenvalue_of_hasEigenvector {f : End R M} {μ : R} {x : M} (h : HasEigenvector f μ x) :
     HasEigenvalue f μ := by
feat: port LinearAlgebra.Eigenspace.Basic (#4842)

Two instances defined in Data.Dfinsupp.Basic are used in this file (with explicit arguments) so I gave them names.

Dependencies 10 + 521

522 files ported (98.1%)
217111 lines ported (98.5%)
Show graph

The unported dependencies are