l3lab/ntp-mathlib huggingface dataset:
theorem eigenspace_aeval_polynomial_degree_1 (f : End K V) (q : K[X]) (hq : degree q = 1) :
    eigenspace f (-q.coeff 0 / q.leadingCoeff) = LinearMap.ker (aeval f q) :=
  calc
    eigenspace f (-q.coeff 0 / q.leadingCoeff)
    _ = LinearMap.ker (q.leadingCoeff • f - algebraMap K (End K V) (-q.coeff 0)) := by
          rw [eigenspace_div]
          intro h
          

Proof state:
case hb
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
q : K[X]
hq : degree q = 1
h : leadingCoeff q = 0
⊢ False

Next tactic:
rw [leadingCoeff_eq_zero_iff_deg_eq_bot.1 h] at hq
theorem eigenspace_aeval_polynomial_degree_1 (f : End K V) (q : K[X]) (hq : degree q = 1) :
    eigenspace f (-q.coeff 0 / q.leadingCoeff) = LinearMap.ker (aeval f q) :=
  calc
    eigenspace f (-q.coeff 0 / q.leadingCoeff)
    _ = LinearMap.ker (q.leadingCoeff • f - algebraMap K (End K V) (-q.coeff 0)) := by
          rw [eigenspace_div]
          intro h
          rw [leadingCoeff_eq_zero_iff_deg_eq_bot.1 h] at hq
          

Proof state:
case hb
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
q : K[X]
hq : ⊥ = 1
h : leadingCoeff q = 0
⊢ False

Next tactic:
cases hq
theorem eigenspace_aeval_polynomial_degree_1 (f : End K V) (q : K[X]) (hq : degree q = 1) :
    eigenspace f (-q.coeff 0 / q.leadingCoeff) = LinearMap.ker (aeval f q) :=
  calc
    eigenspace f (-q.coeff 0 / q.leadingCoeff)
    _ = LinearMap.ker (q.leadingCoeff • f - algebraMap K (End K V) (-q.coeff 0)) := by
          rw [eigenspace_div]
          intro h
          rw [leadingCoeff_eq_zero_iff_deg_eq_bot.1 h] at hq
          cases hq
    _ = LinearMap.ker (aeval f (C q.leadingCoeff * X + C (q.coeff 0))) := by
          

Proof state:
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
q : K[X]
hq : degree q = 1
⊢ LinearMap.ker (leadingCoeff q • f - (algebraMap K (End K V)) (-coeff q 0)) =
    LinearMap.ker ((aeval f) (C (leadingCoeff q) * X + C (coeff q 0)))

Next tactic:
rw [C_mul', aeval_def]
theorem eigenspace_aeval_polynomial_degree_1 (f : End K V) (q : K[X]) (hq : degree q = 1) :
    eigenspace f (-q.coeff 0 / q.leadingCoeff) = LinearMap.ker (aeval f q) :=
  calc
    eigenspace f (-q.coeff 0 / q.leadingCoeff)
    _ = LinearMap.ker (q.leadingCoeff • f - algebraMap K (End K V) (-q.coeff 0)) := by
          rw [eigenspace_div]
          intro h
          rw [leadingCoeff_eq_zero_iff_deg_eq_bot.1 h] at hq
          cases hq
    _ = LinearMap.ker (aeval f (C q.leadingCoeff * X + C (q.coeff 0))) := by
          rw [C_mul', aeval_def]; 

Proof state:
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
q : K[X]
hq : degree q = 1
⊢ LinearMap.ker (leadingCoeff q • f - (algebraMap K (End K V)) (-coeff q 0)) =
    LinearMap.ker (eval₂ (algebraMap K (End K V)) f (leadingCoeff q • X + C (coeff q 0)))

Next tactic:
simp [algebraMap, Algebra.toRingHom]
theorem eigenspace_aeval_polynomial_degree_1 (f : End K V) (q : K[X]) (hq : degree q = 1) :
    eigenspace f (-q.coeff 0 / q.leadingCoeff) = LinearMap.ker (aeval f q) :=
  calc
    eigenspace f (-q.coeff 0 / q.leadingCoeff)
    _ = LinearMap.ker (q.leadingCoeff • f - algebraMap K (End K V) (-q.coeff 0)) := by
          rw [eigenspace_div]
          intro h
          rw [leadingCoeff_eq_zero_iff_deg_eq_bot.1 h] at hq
          cases hq
    _ = LinearMap.ker (aeval f (C q.leadingCoeff * X + C (q.coeff 0))) := by
          rw [C_mul', aeval_def]; simp [algebraMap, Algebra.toRingHom]
    _ = LinearMap.ker (aeval f q) := by 

Proof state:
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
q : K[X]
hq : degree q = 1
⊢ LinearMap.ker ((aeval f) (C (leadingCoeff q) * X + C (coeff q 0))) = LinearMap.ker ((aeval f) q)

Next tactic:
rwa [← eq_X_add_C_of_degree_eq_one]
theorem ker_aeval_ring_hom'_unit_polynomial (f : End K V) (c : K[X]ˣ) :
    LinearMap.ker (aeval f (c : K[X])) = ⊥ := by
  

Proof state:
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
c : K[X]ˣ
⊢ LinearMap.ker ((aeval f) ↑c) = ⊥

Next tactic:
rw [Polynomial.eq_C_of_degree_eq_zero (degree_coe_units c)]
theorem ker_aeval_ring_hom'_unit_polynomial (f : End K V) (c : K[X]ˣ) :
    LinearMap.ker (aeval f (c : K[X])) = ⊥ := by
  rw [Polynomial.eq_C_of_degree_eq_zero (degree_coe_units c)]
  

Proof state:
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
c : K[X]ˣ
⊢ LinearMap.ker ((aeval f) (C (coeff (↑c) 0))) = ⊥

Next tactic:
simp only [aeval_def, eval₂_C]
theorem ker_aeval_ring_hom'_unit_polynomial (f : End K V) (c : K[X]ˣ) :
    LinearMap.ker (aeval f (c : K[X])) = ⊥ := by
  rw [Polynomial.eq_C_of_degree_eq_zero (degree_coe_units c)]
  simp only [aeval_def, eval₂_C]
  

Proof state:
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
c : K[X]ˣ
⊢ LinearMap.ker ((algebraMap K (End K V)) (coeff (↑c) 0)) = ⊥

Next tactic:
apply ker_algebraMap_end
theorem ker_aeval_ring_hom'_unit_polynomial (f : End K V) (c : K[X]ˣ) :
    LinearMap.ker (aeval f (c : K[X])) = ⊥ := by
  rw [Polynomial.eq_C_of_degree_eq_zero (degree_coe_units c)]
  simp only [aeval_def, eval₂_C]
  apply ker_algebraMap_end
  

Proof state:
case ha
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
c : K[X]ˣ
⊢ coeff (↑c) 0 ≠ 0

Next tactic:
apply coeff_coe_units_zero_ne_zero c
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
  

Proof state:
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
p : K[X]
μ : K
x : V
h : HasEigenvector f μ x
⊢ ((aeval f) p) x = eval μ p • x

Next tactic:
refine' p.induction_on _ _ _
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
  refine' p.induction_on _ _ _
  · 

Proof state:
case refine'_1
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
p : K[X]
μ : K
x : V
h : HasEigenvector f μ x
⊢ ∀ (a : K), ((aeval f) (C a)) x = eval μ (C a) • x

Next tactic:
intro a
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
  refine' p.induction_on _ _ _
  · intro a; 

Proof state:
case refine'_1
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
p : K[X]
μ : K
x : V
h : HasEigenvector f μ x
a : K
⊢ ((aeval f) (C a)) x = eval μ (C a) • x

Next tactic:
simp [Module.algebraMap_end_apply]
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
  refine' p.induction_on _ _ _
  · intro a; simp [Module.algebraMap_end_apply]
  · 

Proof state:
case refine'_2
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
p : K[X]
μ : K
x : V
h : HasEigenvector f μ x
⊢ ∀ (p q : K[X]),
    ((aeval f) p) x = eval μ p • x → ((aeval f) q) x = eval μ q • x → ((aeval f) (p + q)) x = eval μ (p + q) • x

Next tactic:
intro p q hp hq
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
  refine' p.induction_on _ _ _
  · intro a; simp [Module.algebraMap_end_apply]
  · intro p q hp hq; 

Proof state:
case refine'_2
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
p✝ : K[X]
μ : K
x : V
h : HasEigenvector f μ x
p q : K[X]
hp : ((aeval f) p) x = eval μ p • x
hq : ((aeval f) q) x = eval μ q • x
⊢ ((aeval f) (p + q)) x = eval μ (p + q) • x

Next tactic:
simp [hp, hq, add_smul]
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
  refine' p.induction_on _ _ _
  · intro a; simp [Module.algebraMap_end_apply]
  · intro p q hp hq; simp [hp, hq, add_smul]
  · 

Proof state:
case refine'_3
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
p : K[X]
μ : K
x : V
h : HasEigenvector f μ x
⊢ ∀ (n : ℕ) (a : K),
    ((aeval f) (C a * X ^ n)) x = eval μ (C a * X ^ n) • x →
      ((aeval f) (C a * X ^ (n + 1))) x = eval μ (C a * X ^ (n + 1)) • x

Next tactic:
intro n a hna
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
  refine' p.induction_on _ _ _
  · intro a; simp [Module.algebraMap_end_apply]
  · intro p q hp hq; simp [hp, hq, add_smul]
  · intro n a hna
    

Proof state:
case refine'_3
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
p : K[X]
μ : K
x : V
h : HasEigenvector f μ x
n : ℕ
a : K
hna : ((aeval f) (C a * X ^ n)) x = eval μ (C a * X ^ n) • x
⊢ ((aeval f) (C a * X ^ (n + 1))) x = eval μ (C a * X ^ (n + 1)) • x

Next tactic:
rw [mul_comm, pow_succ, mul_assoc, AlgHom.map_mul, LinearMap.mul_apply, mul_comm, hna]
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
  refine' 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]
    

Proof state:
case refine'_3
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
p : K[X]
μ : K
x : V
h : HasEigenvector f μ x
n : ℕ
a : K
hna : ((aeval f) (C a * X ^ n)) x = eval μ (C a * X ^ n) • x
⊢ ((aeval f) X) (eval μ (C a * X ^ n) • x) = eval μ (X * (C a * X ^ n)) • x

Next tactic:
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]
theorem isRoot_of_hasEigenvalue {f : End K V} {μ : K} (h : f.HasEigenvalue μ) :
    (minpoly K f).IsRoot μ := by
  

Proof state:
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
μ : K
h : HasEigenvalue f μ
⊢ IsRoot (minpoly K f) μ

Next tactic:
rcases (Submodule.ne_bot_iff _).1 h with ⟨w, ⟨H, ne0⟩⟩
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⟩⟩
  

Proof state:
case intro.intro
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
μ : K
h : HasEigenvalue f μ
w : V
H : w ∈ eigenspace f μ
ne0 : w ≠ 0
⊢ IsRoot (minpoly K f) μ

Next tactic:
refine' Or.resolve_right (smul_eq_zero.1 _) ne0
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
  

Proof state:
case intro.intro
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
μ : K
h : HasEigenvalue f μ
w : V
H : w ∈ eigenspace f μ
ne0 : w ≠ 0
⊢ eval μ (minpoly K f) • w = 0

Next tactic:
simp [← aeval_apply_of_hasEigenvector ⟨H, ne0⟩, minpoly.aeval K f]
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  

Proof state:
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
⊢ HasEigenvalue f μ

Next tactic:
cases' dvd_iff_isRoot.2 h with p hp
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  

Proof state:
case intro
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
⊢ HasEigenvalue f μ

Next tactic:
rw [HasEigenvalue, eigenspace]
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, eigenspace]
  

Proof state:
case intro
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
⊢ LinearMap.ker (f - (algebraMap K (End K V)) μ) ≠ ⊥

Next tactic:
intro con
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, eigenspace]
  intro con
  

Proof state:
case intro
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
⊢ False

Next tactic:
cases' (LinearMap.isUnit_iff_ker_eq_bot _).2 con with u hu
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, eigenspace]
  intro con
  cases' (LinearMap.isUnit_iff_ker_eq_bot _).2 con with u hu
  

Proof state:
case intro.intro
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
⊢ False

Next tactic:
have p_ne_0 : p ≠ 0 := by
    intro con
    apply minpoly.ne_zero f.isIntegral
    rw [hp, con, mul_zero]
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, eigenspace]
  intro con
  cases' (LinearMap.isUnit_iff_ker_eq_bot _).2 con with u hu
  have p_ne_0 : p ≠ 0 := by
    

Proof state:
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
⊢ p ≠ 0

Next tactic:
intro con
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, eigenspace]
  intro con
  cases' (LinearMap.isUnit_iff_ker_eq_bot _).2 con with u hu
  have p_ne_0 : p ≠ 0 := by
    intro con
    

Proof state:
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con✝ : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
con : p = 0
⊢ False

Next tactic:
apply minpoly.ne_zero f.isIntegral
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, 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.isIntegral
    

Proof state:
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con✝ : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
con : p = 0
⊢ minpoly K f = 0

Next tactic:
rw [hp, con, mul_zero]
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, 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.isIntegral
    rw [hp, con, mul_zero]
  

Proof state:
case intro.intro
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
p_ne_0 : p ≠ 0
⊢ False

Next tactic:
have : (aeval f) p = 0 := by
    have h_aeval := minpoly.aeval K f
    revert h_aeval
    simp [hp, ← hu]
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, 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.isIntegral
    rw [hp, con, mul_zero]
  have : (aeval f) p = 0 := by
    

Proof state:
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
p_ne_0 : p ≠ 0
⊢ (aeval f) p = 0

Next tactic:
have h_aeval := minpoly.aeval K f
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, 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.isIntegral
    rw [hp, con, mul_zero]
  have : (aeval f) p = 0 := by
    have h_aeval := minpoly.aeval K f
    

Proof state:
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
p_ne_0 : p ≠ 0
h_aeval : (aeval f) (minpoly K f) = 0
⊢ (aeval f) p = 0

Next tactic:
revert h_aeval
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, 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.isIntegral
    rw [hp, con, mul_zero]
  have : (aeval f) p = 0 := by
    have h_aeval := minpoly.aeval K f
    revert h_aeval
    

Proof state:
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
p_ne_0 : p ≠ 0
⊢ (aeval f) (minpoly K f) = 0 → (aeval f) p = 0

Next tactic:
simp [hp, ← hu]
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, 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.isIntegral
    rw [hp, con, mul_zero]
  have : (aeval f) p = 0 := by
    have h_aeval := minpoly.aeval K f
    revert h_aeval
    simp [hp, ← hu]
  

Proof state:
case intro.intro
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
p_ne_0 : p ≠ 0
this : (aeval f) p = 0
⊢ False

Next tactic:
have h_deg := minpoly.degree_le_of_ne_zero K f p_ne_0 this
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, 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.isIntegral
    rw [hp, con, mul_zero]
  have : (aeval f) p = 0 := by
    have h_aeval := minpoly.aeval K f
    revert h_aeval
    simp [hp, ← hu]
  have h_deg := minpoly.degree_le_of_ne_zero K f p_ne_0 this
  

Proof state:
case intro.intro
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
p_ne_0 : p ≠ 0
this : (aeval f) p = 0
h_deg : degree (minpoly K f) ≤ degree p
⊢ False

Next tactic:
rw [hp, degree_mul, degree_X_sub_C, Polynomial.degree_eq_natDegree p_ne_0] at h_deg
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, 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.isIntegral
    rw [hp, con, mul_zero]
  have : (aeval f) p = 0 := by
    have h_aeval := minpoly.aeval K f
    revert h_aeval
    simp [hp, ← hu]
  have h_deg := minpoly.degree_le_of_ne_zero K f p_ne_0 this
  rw [hp, degree_mul, degree_X_sub_C, Polynomial.degree_eq_natDegree p_ne_0] at h_deg
  

Proof state:
case intro.intro
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
p_ne_0 : p ≠ 0
this : (aeval f) p = 0
h_deg : 1 + ↑(natDegree p) ≤ ↑(natDegree p)
⊢ False

Next tactic:
norm_cast at h_deg
theorem hasEigenvalue_of_isRoot (h : (minpoly K f).IsRoot μ) : f.HasEigenvalue μ := by
  cases' dvd_iff_isRoot.2 h with p hp
  rw [HasEigenvalue, 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.isIntegral
    rw [hp, con, mul_zero]
  have : (aeval f) p = 0 := by
    have h_aeval := minpoly.aeval K f
    revert h_aeval
    simp [hp, ← hu]
  have h_deg := minpoly.degree_le_of_ne_zero K f p_ne_0 this
  rw [hp, degree_mul, degree_X_sub_C, Polynomial.degree_eq_natDegree p_ne_0] at h_deg
  norm_cast at h_deg
  

Proof state:
case intro.intro
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : IsRoot (minpoly K f) μ
p : K[X]
hp : minpoly K f = (X - C μ) * p
con : LinearMap.ker (f - (algebraMap K (End K V)) μ) = ⊥
u : (V →ₗ[K] V)ˣ
hu : ↑u = f - (algebraMap K (End K V)) μ
p_ne_0 : p ≠ 0
this : (aeval f) p = 0
h_deg : 1 + natDegree p ≤ natDegree p
⊢ False

Next tactic:
linarith
lemma finite_hasEigenvalue : Set.Finite f.HasEigenvalue := by
  

Proof state:
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
⊢ Set.Finite (HasEigenvalue f)

Next tactic:
have h : minpoly K f ≠ 0 := minpoly.ne_zero f.isIntegral
lemma finite_hasEigenvalue : Set.Finite f.HasEigenvalue := by
  have h : minpoly K f ≠ 0 := minpoly.ne_zero f.isIntegral
  

Proof state:
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : minpoly K f ≠ 0
⊢ Set.Finite (HasEigenvalue f)

Next tactic:
convert (minpoly K f).rootSet_finite K
lemma finite_hasEigenvalue : Set.Finite f.HasEigenvalue := by
  have h : minpoly K f ≠ 0 := minpoly.ne_zero f.isIntegral
  convert (minpoly K f).rootSet_finite K
  

Proof state:
case h.e'_2
K : Type v
V : Type w
inst✝³ : Field K
inst✝² : AddCommGroup V
inst✝¹ : Module K V
inst✝ : FiniteDimensional K V
f : End K V
μ : K
h : minpoly K f ≠ 0
⊢ HasEigenvalue f = rootSet (minpoly K f) K

Next tactic:
ext μ