Theorem: Polynomial.coeff_mirror
File: Mathlib/Algebra/Polynomial/Mirror.lean

tactic: by_cases h2 : p.natDegree < n
state_before: R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
⊢ p.mirror.coeff n = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)
state_after: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
⊢ p.mirror.coeff n = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)

case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : ¬p.natDegree < n
⊢ p.mirror.coeff n = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)

tactic: rw [not_lt] at h2
state_before: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : ¬p.natDegree < n
⊢ p.mirror.coeff n = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)
state_after: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
⊢ p.mirror.coeff n = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)

tactic: rw [revAt_le (h2.trans (Nat.le_add_right _ _))]
state_before: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
⊢ p.mirror.coeff n = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)
state_after: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
⊢ p.mirror.coeff n = p.coeff (p.natDegree + p.natTrailingDegree - n)

tactic: by_cases h3 : p.natTrailingDegree ≤ n
state_before: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
⊢ p.mirror.coeff n = p.coeff (p.natDegree + p.natTrailingDegree - n)
state_after: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
h3 : p.natTrailingDegree ≤ n
⊢ p.mirror.coeff n = p.coeff (p.natDegree + p.natTrailingDegree - n)

case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
h3 : ¬p.natTrailingDegree ≤ n
⊢ p.mirror.coeff n = p.coeff (p.natDegree + p.natTrailingDegree - n)

tactic: rw [not_le] at h3
state_before: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
h3 : ¬p.natTrailingDegree ≤ n
⊢ p.mirror.coeff n = p.coeff (p.natDegree + p.natTrailingDegree - n)
state_after: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
h3 : n < p.natTrailingDegree
⊢ p.mirror.coeff n = p.coeff (p.natDegree + p.natTrailingDegree - n)

tactic: rw [coeff_eq_zero_of_natDegree_lt (lt_tsub_iff_right.mpr (Nat.add_lt_add_left h3 _))]
state_before: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
h3 : n < p.natTrailingDegree
⊢ p.mirror.coeff n = p.coeff (p.natDegree + p.natTrailingDegree - n)
state_after: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
h3 : n < p.natTrailingDegree
⊢ p.mirror.coeff n = 0

tactic: exact coeff_eq_zero_of_lt_natTrailingDegree (by rwa [mirror_natTrailingDegree])
state_before: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
h3 : n < p.natTrailingDegree
⊢ p.mirror.coeff n = 0
state_after: no goals

tactic: rw [coeff_eq_zero_of_natDegree_lt (by rwa [mirror_natDegree])]
state_before: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
⊢ p.mirror.coeff n = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)
state_after: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
⊢ 0 = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)

tactic: by_cases h1 : n ≤ p.natDegree + p.natTrailingDegree
state_before: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
⊢ 0 = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)
state_after: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
h1 : n ≤ p.natDegree + p.natTrailingDegree
⊢ 0 = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)

case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
h1 : ¬n ≤ p.natDegree + p.natTrailingDegree
⊢ 0 = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)

tactic: rwa [mirror_natDegree]
state_before: R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
⊢ p.mirror.natDegree < n
state_after: no goals

tactic: rw [revAt_le h1, coeff_eq_zero_of_lt_natTrailingDegree]
state_before: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
h1 : n ≤ p.natDegree + p.natTrailingDegree
⊢ 0 = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)
state_after: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
h1 : n ≤ p.natDegree + p.natTrailingDegree
⊢ p.natDegree + p.natTrailingDegree - n < p.natTrailingDegree

tactic: exact (tsub_lt_iff_left h1).mpr (Nat.add_lt_add_right h2 _)
state_before: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
h1 : n ≤ p.natDegree + p.natTrailingDegree
⊢ p.natDegree + p.natTrailingDegree - n < p.natTrailingDegree
state_after: no goals

tactic: rw [← revAtFun_eq, revAtFun, if_neg h1, coeff_eq_zero_of_natDegree_lt h2]
state_before: case neg
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : p.natDegree < n
h1 : ¬n ≤ p.natDegree + p.natTrailingDegree
⊢ 0 = p.coeff ((revAt (p.natDegree + p.natTrailingDegree)) n)
state_after: no goals

tactic: rw [← tsub_add_eq_add_tsub h2, ← tsub_tsub_assoc h2 h3, mirror, coeff_mul_X_pow', if_pos h3,
  coeff_reverse, revAt_le (tsub_le_self.trans h2)]
state_before: case pos
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
h3 : p.natTrailingDegree ≤ n
⊢ p.mirror.coeff n = p.coeff (p.natDegree + p.natTrailingDegree - n)
state_after: no goals

tactic: rwa [mirror_natTrailingDegree]
state_before: R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
h2 : n ≤ p.natDegree
h3 : n < p.natTrailingDegree
⊢ n < p.mirror.natTrailingDegree
state_after: no goals