Theorem: Polynomial.natDegree_eq_reverse_natDegree_add_natTrailingDegree
File: Mathlib/Algebra/Polynomial/Reverse.lean

tactic: by_cases hf : f = 0
state_before: R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
⊢ f.natDegree = f.reverse.natDegree + f.natTrailingDegree
state_after: case pos
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : f = 0
⊢ f.natDegree = f.reverse.natDegree + f.natTrailingDegree

case neg
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.natDegree = f.reverse.natDegree + f.natTrailingDegree

tactic: apply le_antisymm
state_before: case neg
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.natDegree = f.reverse.natDegree + f.natTrailingDegree
state_after: case neg.a
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.natDegree ≤ f.reverse.natDegree + f.natTrailingDegree

case neg.a
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.reverse.natDegree + f.natTrailingDegree ≤ f.natDegree

tactic: rw [hf, reverse_zero, natDegree_zero, natTrailingDegree_zero]
state_before: case pos
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : f = 0
⊢ f.natDegree = f.reverse.natDegree + f.natTrailingDegree
state_after: no goals

tactic: refine tsub_le_iff_right.mp ?_
state_before: case neg.a
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.natDegree ≤ f.reverse.natDegree + f.natTrailingDegree
state_after: case neg.a
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.natDegree - f.natTrailingDegree ≤ f.reverse.natDegree

tactic: apply le_natDegree_of_ne_zero
state_before: case neg.a
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.natDegree - f.natTrailingDegree ≤ f.reverse.natDegree
state_after: case neg.a.h
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.reverse.coeff (f.natDegree - f.natTrailingDegree) ≠ 0

tactic: rw [reverse, coeff_reflect, ← revAt_le f.natTrailingDegree_le_natDegree, revAt_invol]
state_before: case neg.a.h
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.reverse.coeff (f.natDegree - f.natTrailingDegree) ≠ 0
state_after: case neg.a.h
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.coeff f.natTrailingDegree ≠ 0

tactic: exact trailingCoeff_nonzero_iff_nonzero.mpr hf
state_before: case neg.a.h
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.coeff f.natTrailingDegree ≠ 0
state_after: no goals

tactic: rw [← le_tsub_iff_left f.reverse_natDegree_le]
state_before: case neg.a
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.reverse.natDegree + f.natTrailingDegree ≤ f.natDegree
state_after: case neg.a
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.natTrailingDegree ≤ f.natDegree - f.reverse.natDegree

tactic: apply natTrailingDegree_le_of_ne_zero
state_before: case neg.a
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.natTrailingDegree ≤ f.natDegree - f.reverse.natDegree
state_after: case neg.a.h
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.coeff (f.natDegree - f.reverse.natDegree) ≠ 0

tactic: have key := mt leadingCoeff_eq_zero.mp (mt reverse_eq_zero.mp hf)
state_before: case neg.a.h
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
⊢ f.coeff (f.natDegree - f.reverse.natDegree) ≠ 0
state_after: case neg.a.h
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
key : ¬f.reverse.leadingCoeff = 0
⊢ f.coeff (f.natDegree - f.reverse.natDegree) ≠ 0

tactic: rwa [leadingCoeff, coeff_reverse, revAt_le f.reverse_natDegree_le] at key
state_before: case neg.a.h
R : Type u_1
inst✝ : Semiring R
f✝ f : R[X]
hf : ¬f = 0
key : ¬f.reverse.leadingCoeff = 0
⊢ f.coeff (f.natDegree - f.reverse.natDegree) ≠ 0
state_after: no goals