-- ArkLib/Data/FieldTheory/NonBinaryField/Basic.lean

import Mathlib.Algebra.Polynomial.FieldDivision

import Mathlib.Tactic.FieldSimp

import Mathlib.Tactic.LinearCombination

section NonBinaryField

variable {F : Type*} [NonBinaryField F]

end NonBinaryField

section

variable {F : Type*} [Field F]

open Polynomial

-- Repository definitions used:
content: def coeff.{u} {F : Type u} [Semiring F] (f : F[X][Y]) (i j : ℕ) : F := (f.coeff j).coeff i

-- Repository lemmas used:
content: theorem List.getElem_append_left{α : Type u_1} {l₁ l₂ : List α} {i : Nat} (hn : i < l₁.length) :\n(l₁ ++ l₂)[i] = l₁[i]

-- Local definitions used:

-- Local lemmas used:
content: private lemma coeffs_of_comp_minus_x_pos_degree {f : Polynomial F} {n : ℕ} (h : 0 < f.degree) :
    (f.comp (-X)).coeff n = if Even n then f.coeff n else -f.coeff n

-- Target theorem and proof:
theorem coeffs_of_comp_minus_x {f : Polynomial F} {n : ℕ} :
    (f.comp (-X)).coeff n = if Even n then f.coeff n else -f.coeff n
:= by
    by_cases hpos : 0 < f.degree
    · rw [coeffs_of_comp_minus_x_pos_degree hpos]
    · have : f.natDegree = 0 := by aesop (add simp natDegree_pos_iff_degree_pos.symm)
      cases n <;> aesop (add simp natDegree_eq_zero)