-- Mathlib/Algebra/Polynomial/Degree/TrailingDegree.lean
lemma eq_X_pow_iff_natDegree_le_natTrailingDegree (h₁ : p.Monic) :
    p = X ^ p.natDegree ↔ p.natDegree ≤ p.natTrailingDegree

Proof state:
case refine_2.a.inr.inl
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
⊢ p.coeff p.natDegree = if p.natDegree = p.natDegree then 1 else 0

Tactic:
simpa only [if_pos rfl] using h₁.leadingCoeff

Result:
no goals

Proof state:
case refine_2.a.inl
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
hn : n < p.natDegree
⊢ p.coeff n = if n = p.natDegree then 1 else 0

Tactic:
rw [if_neg hn.ne, coeff_eq_zero_of_lt_natTrailingDegree (hn.trans_le h)]

Result:
no goals

Proof state:
case refine_2.a
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
⊢ p.coeff n = (X ^ p.natDegree).coeff n

Tactic:
rw [coeff_X_pow]

Result:
case refine_2.a
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
⊢ p.coeff n = if n = p.natDegree then 1 else 0

Proof state:
case refine_2.a.inr.inr
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
hn : p.natDegree < n
⊢ p.coeff n = if n = p.natDegree then 1 else 0

Tactic:
rw [if_neg hn.ne', coeff_eq_zero_of_natDegree_lt hn]

Result:
no goals

Proof state:
case refine_1
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p = X ^ p.natDegree
⊢ p.natDegree ≤ p.natTrailingDegree

Tactic:
nontriviality R

Result:
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p = X ^ p.natDegree
a✝ : Nontrivial R
⊢ p.natDegree ≤ p.natTrailingDegree

Proof state:
case refine_2.a
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
⊢ p.coeff n = if n = p.natDegree then 1 else 0

Tactic:
obtain hn | rfl | hn := lt_trichotomy n p.natDegree

Result:
case refine_2.a.inl
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
hn : n < p.natDegree
⊢ p.coeff n = if n = p.natDegree then 1 else 0

case refine_2.a.inr.inl
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
⊢ p.coeff p.natDegree = if p.natDegree = p.natDegree then 1 else 0

case refine_2.a.inr.inr
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
hn : p.natDegree < n
⊢ p.coeff n = if n = p.natDegree then 1 else 0

Proof state:
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
⊢ p = X ^ p.natDegree ↔ p.natDegree ≤ p.natTrailingDegree

Tactic:
refine ⟨fun h => ?_, fun h => ?_⟩

Result:
case refine_1
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p = X ^ p.natDegree
⊢ p.natDegree ≤ p.natTrailingDegree

case refine_2
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
⊢ p = X ^ p.natDegree

Proof state:
case refine_2
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
⊢ p = X ^ p.natDegree

Tactic:
ext n

Result:
case refine_2.a
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
⊢ p.coeff n = (X ^ p.natDegree).coeff n

Proof state:
R : Type u
inst✝ : Semiring R
p : R[X]
h₁ : p.Monic
h : p = X ^ p.natDegree
a✝ : Nontrivial R
⊢ p.natDegree ≤ p.natTrailingDegree

Tactic:
rw [h, natTrailingDegree_X_pow, ← h]

Result:
no goals