Theorem: Polynomial.Monic.eq_X_pow_iff_natDegree_le_natTrailingDegree
File: Mathlib/Algebra/Polynomial/Degree/TrailingDegree.lean

tactic: refine ⟨fun h => ?_, fun h => ?_⟩
state_before: R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
⊢ p = X ^ p.natDegree ↔ p.natDegree ≤ p.natTrailingDegree
state_after: case refine_1
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p = X ^ p.natDegree
⊢ p.natDegree ≤ p.natTrailingDegree

case refine_2
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
⊢ p = X ^ p.natDegree

tactic: nontriviality R
state_before: case refine_1
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p = X ^ p.natDegree
⊢ p.natDegree ≤ p.natTrailingDegree
state_after: R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p = X ^ p.natDegree
a✝ : Nontrivial R
⊢ p.natDegree ≤ p.natTrailingDegree

tactic: rw [h, natTrailingDegree_X_pow, ← h]
state_before: R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p = X ^ p.natDegree
a✝ : Nontrivial R
⊢ p.natDegree ≤ p.natTrailingDegree
state_after: no goals

tactic: ext n
state_before: case refine_2
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
⊢ p = X ^ p.natDegree
state_after: case refine_2.a
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
⊢ p.coeff n = (X ^ p.natDegree).coeff n

tactic: rw [coeff_X_pow]
state_before: case refine_2.a
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
⊢ p.coeff n = (X ^ p.natDegree).coeff n
state_after: case refine_2.a
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q : 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
state_before: case refine_2.a
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
n : ℕ
⊢ p.coeff n = if n = p.natDegree then 1 else 0
state_after: case refine_2.a.inl
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q : 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
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q : 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
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q : 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_lt_natTrailingDegree (hn.trans_le h)]
state_before: case refine_2.a.inl
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q : 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
state_after: no goals

tactic: simpa only [if_pos rfl] using h₁.leadingCoeff
state_before: case refine_2.a.inr.inl
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q : R[X]
h₁ : p.Monic
h : p.natDegree ≤ p.natTrailingDegree
⊢ p.coeff p.natDegree = if p.natDegree = p.natDegree then 1 else 0
state_after: no goals

tactic: rw [if_neg hn.ne', coeff_eq_zero_of_natDegree_lt hn]
state_before: case refine_2.a.inr.inr
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q : 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
state_after: no goals