Theorem: Irreducible.degree_le_two
File: Mathlib/Analysis/Complex/Polynomial.lean

tactic: obtain ⟨z, hz⟩ : ∃ z : ℂ, aeval z p = 0 :=
  IsAlgClosed.exists_aeval_eq_zero _ p (degree_pos_of_irreducible hp).ne'
state_before: p : ℝ[X]
hp : Irreducible p
⊢ p.degree ≤ 2
state_after: case intro
p : ℝ[X]
hp : Irreducible p
z : ℂ
hz : (aeval z) p = 0
⊢ p.degree ≤ 2

tactic: cases eq_or_ne z.im 0 with
| inl hz0 =>
  lift z to ℝ using hz0
  erw [aeval_ofReal, RCLike.ofReal_eq_zero] at hz
  exact (degree_eq_one_of_irreducible_of_root hp hz).trans_le one_le_two
| inr hz0 =>
  obtain ⟨q, rfl⟩ := p.quadratic_dvd_of_aeval_eq_zero_im_ne_zero hz hz0
  have hd : degree (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) = 2 := by
    compute_degree!
  have hq : IsUnit q := by
    refine (of_irreducible_mul hp).resolve_left (mt isUnit_iff_degree_eq_zero.1 ?_)
    rw [hd]
    exact two_ne_zero
  refine (degree_mul_le _ _).trans_eq ?_
  rwa [isUnit_iff_degree_eq_zero.1 hq, add_zero]
state_before: case intro
p : ℝ[X]
hp : Irreducible p
z : ℂ
hz : (aeval z) p = 0
⊢ p.degree ≤ 2
state_after: no goals

tactic: lift z to ℝ using hz0
state_before: case intro.inl
p : ℝ[X]
hp : Irreducible p
z : ℂ
hz : (aeval z) p = 0
hz0 : z.im = 0
⊢ p.degree ≤ 2
state_after: case intro.inl.intro
p : ℝ[X]
hp : Irreducible p
z : ℝ
hz : (aeval ↑z) p = 0
⊢ p.degree ≤ 2

tactic: erw [aeval_ofReal, RCLike.ofReal_eq_zero] at hz
state_before: case intro.inl.intro
p : ℝ[X]
hp : Irreducible p
z : ℝ
hz : (aeval ↑z) p = 0
⊢ p.degree ≤ 2
state_after: case intro.inl.intro
p : ℝ[X]
hp : Irreducible p
z : ℝ
hz : eval z p = 0
⊢ p.degree ≤ 2

tactic: exact (degree_eq_one_of_irreducible_of_root hp hz).trans_le one_le_two
state_before: case intro.inl.intro
p : ℝ[X]
hp : Irreducible p
z : ℝ
hz : eval z p = 0
⊢ p.degree ≤ 2
state_after: no goals

tactic: obtain ⟨q, rfl⟩ := p.quadratic_dvd_of_aeval_eq_zero_im_ne_zero hz hz0
state_before: case intro.inr
p : ℝ[X]
hp : Irreducible p
z : ℂ
hz : (aeval z) p = 0
hz0 : z.im ≠ 0
⊢ p.degree ≤ 2
state_after: case intro.inr.intro
z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
⊢ ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q).degree ≤ 2

tactic: have hd : degree (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) = 2 := by
  compute_degree!
state_before: case intro.inr.intro
z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
⊢ ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q).degree ≤ 2
state_after: case intro.inr.intro
z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
⊢ ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q).degree ≤ 2

tactic: have hq : IsUnit q := by
  refine (of_irreducible_mul hp).resolve_left (mt isUnit_iff_degree_eq_zero.1 ?_)
  rw [hd]
  exact two_ne_zero
state_before: case intro.inr.intro
z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
⊢ ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q).degree ≤ 2
state_after: case intro.inr.intro
z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
hq : IsUnit q
⊢ ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q).degree ≤ 2

tactic: refine (degree_mul_le _ _).trans_eq ?_
state_before: case intro.inr.intro
z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
hq : IsUnit q
⊢ ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q).degree ≤ 2
state_after: case intro.inr.intro
z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
hq : IsUnit q
⊢ (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree + q.degree = 2

tactic: rwa [isUnit_iff_degree_eq_zero.1 hq, add_zero]
state_before: case intro.inr.intro
z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
hq : IsUnit q
⊢ (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree + q.degree = 2
state_after: no goals

tactic: compute_degree!
state_before: z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
⊢ (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
state_after: no goals

tactic: refine (of_irreducible_mul hp).resolve_left (mt isUnit_iff_degree_eq_zero.1 ?_)
state_before: z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
⊢ IsUnit q
state_after: z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
⊢ ¬(X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 0

tactic: rw [hd]
state_before: z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
⊢ ¬(X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 0
state_after: z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
⊢ ¬2 = 0

tactic: exact two_ne_zero
state_before: z : ℂ
hz0 : z.im ≠ 0
q : ℝ[X]
hp : Irreducible ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q)
hz : (aeval z) ((X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) * q) = 0
hd : (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)).degree = 2
⊢ ¬2 = 0
state_after: no goals