Theorem: Polynomial.mirror_eval_one
File: Mathlib/Data/Polynomial/Mirror.lean

tactic: simp_rw [eval_eq_sum_range, one_pow, mul_one, mirror_natDegree]
state_before: R : Type u_1
inst✝ : Semiring R
p q : R[X]
⊢ eval 1 (mirror p) = eval 1 p

tactic: refine' Finset.sum_bij_ne_zero _ _ _ _ _
state_before: R : Type u_1
inst✝ : Semiring R
p q : R[X]
⊢ (Finset.sum (Finset.range (natDegree p + 1)) fun x => coeff (mirror p) x) =
    Finset.sum (Finset.range (natDegree p + 1)) fun x => coeff p x

tactic: exact fun n _ _ => revAt (p.natDegree + p.natTrailingDegree) n
state_before: case refine'_1
R : Type u_1
inst✝ : Semiring R
p q : R[X]
⊢ (a : ℕ) → a ∈ Finset.range (natDegree p + 1) → coeff (mirror p) a ≠ 0 → ℕ

tactic: intro n hn hp
state_before: case refine'_2
R : Type u_1
inst✝ : Semiring R
p q : R[X]
⊢ ∀ (a : ℕ),
    a ∈ Finset.range (natDegree p + 1) →
      coeff (mirror p) a ≠ 0 → ↑(revAt (natDegree p + natTrailingDegree p)) a ∈ Finset.range (natDegree p + 1)

tactic: rw [Finset.mem_range_succ_iff] at *
state_before: case refine'_2
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ∈ Finset.range (natDegree p + 1)
hp : coeff (mirror p) n ≠ 0
⊢ ↑(revAt (natDegree p + natTrailingDegree p)) n ∈ Finset.range (natDegree p + 1)

tactic: rw [revAt_le (hn.trans (Nat.le_add_right _ _))]
state_before: case refine'_2
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ≤ natDegree p
hp : coeff (mirror p) n ≠ 0
⊢ ↑(revAt (natDegree p + natTrailingDegree p)) n ≤ natDegree p

tactic: rw [tsub_le_iff_tsub_le, add_comm, add_tsub_cancel_right, ← mirror_natTrailingDegree]
state_before: case refine'_2
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ≤ natDegree p
hp : coeff (mirror p) n ≠ 0
⊢ natDegree p + natTrailingDegree p - n ≤ natDegree p

tactic: exact natTrailingDegree_le_of_ne_zero hp
state_before: case refine'_2
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ≤ natDegree p
hp : coeff (mirror p) n ≠ 0
⊢ natTrailingDegree (mirror p) ≤ n

tactic: exact fun n₁ n₂ _ _ _ _ h => by rw [← @revAt_invol _ n₁, h, revAt_invol]
state_before: case refine'_3
R : Type u_1
inst✝ : Semiring R
p q : R[X]
⊢ ∀ (a₁ a₂ : ℕ),
    a₁ ∈ Finset.range (natDegree p + 1) →
      coeff (mirror p) a₁ ≠ 0 →
        a₂ ∈ Finset.range (natDegree p + 1) →
          coeff (mirror p) a₂ ≠ 0 →
            ↑(revAt (natDegree p + natTrailingDegree p)) a₁ = ↑(revAt (natDegree p + natTrailingDegree p)) a₂ → a₁ = a₂

tactic: rw [← @revAt_invol _ n₁, h, revAt_invol]
state_before: R : Type u_1
inst✝ : Semiring R
p q : R[X]
n₁ n₂ : ℕ
x✝³ : n₁ ∈ Finset.range (natDegree p + 1)
x✝² : coeff (mirror p) n₁ ≠ 0
x✝¹ : n₂ ∈ Finset.range (natDegree p + 1)
x✝ : coeff (mirror p) n₂ ≠ 0
h : ↑(revAt (natDegree p + natTrailingDegree p)) n₁ = ↑(revAt (natDegree p + natTrailingDegree p)) n₂
⊢ n₁ = n₂

tactic: intro n hn hp
state_before: case refine'_4
R : Type u_1
inst✝ : Semiring R
p q : R[X]
⊢ ∀ (b : ℕ),
    b ∈ Finset.range (natDegree p + 1) → coeff p b ≠ 0 → ∃ a h₁ h₂, b = ↑(revAt (natDegree p + natTrailingDegree p)) a

tactic: use revAt (p.natDegree + p.natTrailingDegree) n
state_before: case refine'_4
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ∈ Finset.range (natDegree p + 1)
hp : coeff p n ≠ 0
⊢ ∃ a h₁ h₂, n = ↑(revAt (natDegree p + natTrailingDegree p)) a

tactic: refine' ⟨_, _, revAt_invol.symm⟩
state_before: case refine'_4
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ∈ Finset.range (natDegree p + 1)
hp : coeff p n ≠ 0
⊢ ∃ h₁ h₂, n = ↑(revAt (natDegree p + natTrailingDegree p)) (↑(revAt (natDegree p + natTrailingDegree p)) n)

tactic: rw [Finset.mem_range_succ_iff] at *
state_before: case refine'_4.refine'_1
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ∈ Finset.range (natDegree p + 1)
hp : coeff p n ≠ 0
⊢ ↑(revAt (natDegree p + natTrailingDegree p)) n ∈ Finset.range (natDegree p + 1)

tactic: rw [revAt_le (hn.trans (Nat.le_add_right _ _))]
state_before: case refine'_4.refine'_1
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ≤ natDegree p
hp : coeff p n ≠ 0
⊢ ↑(revAt (natDegree p + natTrailingDegree p)) n ≤ natDegree p

tactic: rw [tsub_le_iff_tsub_le, add_comm, add_tsub_cancel_right]
state_before: case refine'_4.refine'_1
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ≤ natDegree p
hp : coeff p n ≠ 0
⊢ natDegree p + natTrailingDegree p - n ≤ natDegree p

tactic: exact natTrailingDegree_le_of_ne_zero hp
state_before: case refine'_4.refine'_1
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ≤ natDegree p
hp : coeff p n ≠ 0
⊢ natTrailingDegree p ≤ n

tactic: change p.mirror.coeff _ ≠ 0
state_before: case refine'_4.refine'_2
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ∈ Finset.range (natDegree p + 1)
hp : coeff p n ≠ 0
⊢ coeff (mirror p) (↑(revAt (natDegree p + natTrailingDegree p)) n) ≠ 0

tactic: rwa [coeff_mirror, revAt_invol]
state_before: case refine'_4.refine'_2
R : Type u_1
inst✝ : Semiring R
p q : R[X]
n : ℕ
hn : n ∈ Finset.range (natDegree p + 1)
hp : coeff p n ≠ 0
⊢ coeff (mirror p) (↑(revAt (natDegree p + natTrailingDegree p)) n) ≠ 0

tactic: exact fun n _ _ => p.coeff_mirror n
state_before: case refine'_5
R : Type u_1
inst✝ : Semiring R
p q : R[X]
⊢ ∀ (a : ℕ),
    a ∈ Finset.range (natDegree p + 1) →
      coeff (mirror p) a ≠ 0 → coeff (mirror p) a = coeff p (↑(revAt (natDegree p + natTrailingDegree p)) a)