-- Mathlib/LinearAlgebra/Eigenspace/Zero.lean
lemma charpoly_nilpotent_tfae [IsNoetherian R M] (φ : Module.End R M) :
    List.TFAE [
      IsNilpotent φ,
      φ.charpoly = X ^ finrank R M,
      ∀ m : M, ∃ (n : ℕ), (φ ^ n) m = 0,
      natTrailingDegree φ.charpoly = finrank R M ]

Proof state:
case h.h.intro
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
tfae_2_to_3 : charpoly φ = X ^ finrank R M → ∀ (m : M), ∃ n, (φ ^ n) m = 0
x✝ : ∀ (m : M), ∃ n, (φ ^ n) m = 0
h : ∀ (m : M), ∃ n, (φ ^ n) m = 0 := x✝
n : ℕ
hn : ∀ b ≥ n, ⨆ m, ker (φ ^ m) = ker (φ ^ b)
x : M
k : ℕ
hk : x ∈ ker (φ ^ k)
⊢ x ∈ ⨆ m, ker (φ ^ m)

Tactic:
exact Submodule.mem_iSup_of_mem _ hk

Result:
no goals

Proof state:
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
tfae_2_to_3 : charpoly φ = X ^ finrank R M → ∀ (m : M), ∃ n, (φ ^ n) m = 0
⊢ [IsNilpotent φ, charpoly φ = X ^ finrank R M, ∀ (m : M), ∃ n, (φ ^ n) m = 0,
      (charpoly φ).natTrailingDegree = finrank R M].TFAE

Tactic:
tfae_have 3 → 1
| h => by
  obtain ⟨n, hn⟩ := Filter.eventually_atTop.mp <| φ.eventually_iSup_ker_pow_eq
  use n
  ext x
  rw [zero_apply, ← mem_ker, ← hn n le_rfl]
  obtain ⟨k, hk⟩ := h x
  rw [← mem_ker] at hk
  exact Submodule.mem_iSup_of_mem _ hk

Result:
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
tfae_2_to_3 : charpoly φ = X ^ finrank R M → ∀ (m : M), ∃ n, (φ ^ n) m = 0
tfae_3_to_1 : (∀ (m : M), ∃ n, (φ ^ n) m = 0) → IsNilpotent φ
⊢ [IsNilpotent φ, charpoly φ = X ^ finrank R M, ∀ (m : M), ∃ n, (φ ^ n) m = 0,
      (charpoly φ).natTrailingDegree = finrank R M].TFAE

Proof state:
case intro
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
tfae_2_to_3 : charpoly φ = X ^ finrank R M → ∀ (m : M), ∃ n, (φ ^ n) m = 0
x✝ : ∀ (m : M), ∃ n, (φ ^ n) m = 0
h : ∀ (m : M), ∃ n, (φ ^ n) m = 0 := x✝
n : ℕ
hn : ∀ b ≥ n, ⨆ m, ker (φ ^ m) = ker (φ ^ b)
⊢ IsNilpotent φ

Tactic:
use n

Result:
case h
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
tfae_2_to_3 : charpoly φ = X ^ finrank R M → ∀ (m : M), ∃ n, (φ ^ n) m = 0
x✝ : ∀ (m : M), ∃ n, (φ ^ n) m = 0
h : ∀ (m : M), ∃ n, (φ ^ n) m = 0 := x✝
n : ℕ
hn : ∀ b ≥ n, ⨆ m, ker (φ ^ m) = ker (φ ^ b)
⊢ φ ^ n = 0

Proof state:
case h
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
h : charpoly φ = X ^ finrank R M
m : M
⊢ φ ^ finrank R M = 0

Tactic:
simpa only [h, map_pow, aeval_X] using φ.aeval_self_charpoly

Result:
no goals

Proof state:
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
h : charpoly φ = X ^ finrank R M
m : M
this : φ ^ finrank R M = 0
⊢ (φ ^ finrank R M) m = 0

Tactic:
simp only [this, LinearMap.zero_apply]

Result:
no goals

Proof state:
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
tfae_2_to_3 : charpoly φ = X ^ finrank R M → ∀ (m : M), ∃ n, (φ ^ n) m = 0
tfae_3_to_1 : (∀ (m : M), ∃ n, (φ ^ n) m = 0) → IsNilpotent φ
⊢ charpoly φ = X ^ finrank R M ↔ (charpoly φ).natTrailingDegree = finrank R M

Tactic:
rw [← φ.charpoly_natDegree, φ.charpoly_monic.eq_X_pow_iff_natTrailingDegree_eq_natDegree]

Result:
no goals

Proof state:
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
⊢ [IsNilpotent φ, charpoly φ = X ^ finrank R M, ∀ (m : M), ∃ n, (φ ^ n) m = 0,
      (charpoly φ).natTrailingDegree = finrank R M].TFAE

Tactic:
tfae_have 2 → 3
| h, m => by
  use finrank R M
  suffices φ ^ finrank R M = 0 by simp only [this, LinearMap.zero_apply]
  simpa only [h, map_pow, aeval_X] using φ.aeval_self_charpoly

Result:
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
tfae_2_to_3 : charpoly φ = X ^ finrank R M → ∀ (m : M), ∃ n, (φ ^ n) m = 0
⊢ [IsNilpotent φ, charpoly φ = X ^ finrank R M, ∀ (m : M), ∃ n, (φ ^ n) m = 0,
      (charpoly φ).natTrailingDegree = finrank R M].TFAE

Proof state:
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
tfae_2_to_3 : charpoly φ = X ^ finrank R M → ∀ (m : M), ∃ n, (φ ^ n) m = 0
x✝ : ∀ (m : M), ∃ n, (φ ^ n) m = 0
h : ∀ (m : M), ∃ n, (φ ^ n) m = 0 := x✝
⊢ IsNilpotent φ

Tactic:
obtain ⟨n, hn⟩ := Filter.eventually_atTop.mp <| φ.eventually_iSup_ker_pow_eq

Result:
case intro
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
tfae_2_to_3 : charpoly φ = X ^ finrank R M → ∀ (m : M), ∃ n, (φ ^ n) m = 0
x✝ : ∀ (m : M), ∃ n, (φ ^ n) m = 0
h : ∀ (m : M), ∃ n, (φ ^ n) m = 0 := x✝
n : ℕ
hn : ∀ b ≥ n, ⨆ m, ker (φ ^ m) = ker (φ ^ b)
⊢ IsNilpotent φ

Proof state:
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
⊢ [IsNilpotent φ, charpoly φ = X ^ finrank R M, ∀ (m : M), ∃ n, (φ ^ n) m = 0,
      (charpoly φ).natTrailingDegree = finrank R M].TFAE

Tactic:
tfae_have 1 → 2 := IsNilpotent.charpoly_eq_X_pow_finrank

Result:
R : Type u_1
M : Type u_3
inst✝⁶ : CommRing R
inst✝⁵ : IsDomain R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : Module.Finite R M
inst✝¹ : Free R M
inst✝ : IsNoetherian R M
φ : End R M
tfae_1_to_2 : IsNilpotent φ → charpoly φ = X ^ finrank R M
⊢ [IsNilpotent φ, charpoly φ = X ^ finrank R M, ∀ (m : M), ∃ n, (φ ^ n) m = 0,
      (charpoly φ).natTrailingDegree = finrank R M].TFAE