The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V09. Commutative algebra I: ideals, polynomials, factorization

Mathlib.Algebra.Polynomial.Reverse

57 declarations. Mathlib docs · Source

Reverse of a univariate polynomial

The main definition is reverse. Applying reverse to a polynomial f : R[X] produces the polynomial with a reversed list of coefficients, equivalent to X^f.natDegree * f(1/X).

The main result is that reverse (f * g) = reverse f * reverse g, provided the leading coefficients of f and g do not multiply to zero.

theorem Polynomial.reflect.match_1.congr_eq_1 E1 #

∀ {R : Type u_1} [inst : Semiring R] (motive : Polynomial R → Sort u_2) (x : Polynomial R)
  (h_1 : (f : ℕ →₀ R) → motive (AddMonoidAlgebra.ofCoeff f)) (f : ℕ →₀ R),
  x = AddMonoidAlgebra.ofCoeff f →
    (match x with
      | AddMonoidAlgebra.ofCoeff f => h_1 f) ≍
      h_1 f

def Polynomial.revAtFun E1 #

ℕ → ℕ → ℕ

If i ≤ N, then revAtFun N i returns N - i, otherwise it returns i. This is the map used by the embedding revAt.

theorem Polynomial.revAtFun_invol E1 #

∀ {N i : ℕ}, Polynomial.revAtFun N (Polynomial.revAtFun N i) = i

theorem Polynomial.revAtFun_inj E1 #

∀ {N : ℕ}, Function.Injective (Polynomial.revAtFun N)

def Polynomial.revAt E1 #

ℕ → ℕ ↪ ℕ

If i ≤ N, then revAt N i returns N - i, otherwise it returns i. Essentially, this embedding is only used for i ≤ N. The advantage of revAt N i over N - i is that revAt is an involution.

theorem Polynomial.revAtFun_eq E0 #

∀ (N i : ℕ), Polynomial.revAtFun N i = (Polynomial.revAt N) i

We prefer to use the bundled revAt over unbundled revAtFun.

theorem Polynomial.revAt_invol E0 #

∀ {N i : ℕ}, (Polynomial.revAt N) ((Polynomial.revAt N) i) = i

theorem Polynomial.revAt_le E0 #

∀ {N i : ℕ}, i ≤ N → (Polynomial.revAt N) i = N - i

theorem Polynomial.revAt_eq_self_of_lt E1 #

∀ {N i : ℕ}, N < i → (Polynomial.revAt N) i = i

theorem Polynomial.revAt_add E1 #

∀ {N O n o : ℕ}, n ≤ N → o ≤ O → (Polynomial.revAt (N + O)) (n + o) = (Polynomial.revAt N) n + (Polynomial.revAt O) o

theorem Polynomial.revAt_zero E1 #

∀ (N : ℕ), (Polynomial.revAt N) 0 = N

def Polynomial.reflect E1 #

{R : Type u_1} → [inst : Semiring R] → ℕ → Polynomial R → Polynomial R

reflect N f is the polynomial such that (reflect N f).coeff i = f.coeff (revAt N i). In other words, the terms with exponent [0, ..., N] now have exponent [N, ..., 0].

In practice, reflect is only used when N is at least as large as the degree of f.

Eventually, it will be used with N exactly equal to the degree of f.

theorem Polynomial.reflect_support E1 #

∀ {R : Type u_1} [inst : Semiring R] (N : ℕ) (f : Polynomial R),
  (Polynomial.reflect N f).support = Finset.image (⇑(Polynomial.revAt N)) f.support

theorem Polynomial.coeff_reflect E0 #

∀ {R : Type u_1} [inst : Semiring R] (N : ℕ) (f : Polynomial R) (i : ℕ),
  (Polynomial.reflect N f).coeff i = f.coeff ((Polynomial.revAt N) i)

theorem Polynomial.reflect_reflect E0 #

∀ {R : Type u_1} [inst : Semiring R] {N : ℕ} {p : Polynomial R}, Polynomial.reflect N (Polynomial.reflect N p) = p

theorem Polynomial.reflect_zero E0 #

∀ {R : Type u_1} [inst : Semiring R] {N : ℕ}, Polynomial.reflect N 0 = 0

theorem Polynomial.reflect_eq_zero_iff E0 #

∀ {R : Type u_1} [inst : Semiring R] {N : ℕ} {f : Polynomial R}, Polynomial.reflect N f = 0 ↔ f = 0

theorem Polynomial.reflect_add E0 #

∀ {R : Type u_1} [inst : Semiring R] (f g : Polynomial R) (N : ℕ),
  Polynomial.reflect N (f + g) = Polynomial.reflect N f + Polynomial.reflect N g

theorem Polynomial.reflect_C_mul E0 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R) (r : R) (N : ℕ),
  Polynomial.reflect N (Polynomial.C r * f) = Polynomial.C r * Polynomial.reflect N f

theorem Polynomial.reflect_C_mul_X_pow E1 #

∀ {R : Type u_1} [inst : Semiring R] (N n : ℕ) {c : R},
  Polynomial.reflect N (Polynomial.C c * Polynomial.X ^ n) = Polynomial.C c * Polynomial.X ^ (Polynomial.revAt N) n

theorem Polynomial.reflect_C E0 #

∀ {R : Type u_1} [inst : Semiring R] (r : R) (N : ℕ),
  Polynomial.reflect N (Polynomial.C r) = Polynomial.C r * Polynomial.X ^ N

theorem Polynomial.reflect_monomial E0 #

∀ {R : Type u_1} [inst : Semiring R] (N n : ℕ),
  Polynomial.reflect N (Polynomial.X ^ n) = Polynomial.X ^ (Polynomial.revAt N) n

theorem Polynomial.reflect_one_X E0 #

∀ {R : Type u_1} [inst : Semiring R], Polynomial.reflect 1 Polynomial.X = 1

theorem Polynomial.reflect_map E1 #

∀ {R : Type u_1} [inst : Semiring R] {S : Type u_2} [inst_1 : Semiring S] (f : R →+* S) (p : Polynomial R) (n : ℕ),
  Polynomial.reflect n (Polynomial.map f p) = Polynomial.map f (Polynomial.reflect n p)

theorem Polynomial.reflect_one E0 #

∀ {R : Type u_1} [inst : Semiring R] (n : ℕ), Polynomial.reflect n 1 = Polynomial.X ^ n

theorem Polynomial.reflect_mul_induction E1 #

∀ {R : Type u_1} [inst : Semiring R] (cf cg N O : ℕ) (f g : Polynomial R),
  f.support.card ≤ cf.succ →
    g.support.card ≤ cg.succ →
      f.natDegree ≤ N →
        g.natDegree ≤ O → Polynomial.reflect (N + O) (f * g) = Polynomial.reflect N f * Polynomial.reflect O g

theorem Polynomial.reflect_mul E0 #

∀ {R : Type u_1} [inst : Semiring R] (f g : Polynomial R) {F G : ℕ},
  f.natDegree ≤ F →
    g.natDegree ≤ G → Polynomial.reflect (F + G) (f * g) = Polynomial.reflect F f * Polynomial.reflect G g

theorem Polynomial.natDegree_reflect_le E1 #

∀ {R : Type u_1} [inst : Semiring R] {N : ℕ} {p : Polynomial R}, (Polynomial.reflect N p).natDegree ≤ max N p.natDegree

theorem Polynomial.eval₂_reflect_mul_pow E1 #

∀ {R : Type u_1} [inst : Semiring R] {S : Type u_2} [inst_1 : CommSemiring S] (i : R →+* S) (x : S)
  [inst_2 : Invertible x] (N : ℕ) (f : Polynomial R),
  f.natDegree ≤ N → Polynomial.eval₂ i (⅟x) (Polynomial.reflect N f) * x ^ N = Polynomial.eval₂ i x f

theorem Polynomial.eval₂_reflect_eq_zero_iff E0 #

∀ {R : Type u_1} [inst : Semiring R] {S : Type u_2} [inst_1 : CommSemiring S] (i : R →+* S) (x : S)
  [inst_2 : Invertible x] (N : ℕ) (f : Polynomial R),
  f.natDegree ≤ N → (Polynomial.eval₂ i (⅟x) (Polynomial.reflect N f) = 0 ↔ Polynomial.eval₂ i x f = 0)

def Polynomial.reverse E1 #

{R : Type u_1} → [inst : Semiring R] → Polynomial R → Polynomial R

The reverse of a polynomial f is the polynomial obtained by "reading f backwards". Even though this is not the actual definition, reverse f = f (1/X) * X ^ f.natDegree.

theorem Polynomial.coeff_reverse E1 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R) (n : ℕ),
  f.reverse.coeff n = f.coeff ((Polynomial.revAt f.natDegree) n)

theorem Polynomial.coeff_zero_reverse E0 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R), f.reverse.coeff 0 = f.leadingCoeff

theorem Polynomial.reverse_zero E0 #

∀ {R : Type u_1} [inst : Semiring R], Polynomial.reverse 0 = 0

theorem Polynomial.reverse_eq_zero E0 #

∀ {R : Type u_1} [inst : Semiring R] {f : Polynomial R}, f.reverse = 0 ↔ f = 0

theorem Polynomial.reverse_natDegree_le E1 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R), f.reverse.natDegree ≤ f.natDegree

theorem Polynomial.natDegree_eq_reverse_natDegree_add_natTrailingDegree E1 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R), f.natDegree = f.reverse.natDegree + f.natTrailingDegree

theorem Polynomial.reverse_natDegree E1 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R), f.reverse.natDegree = f.natDegree - f.natTrailingDegree

theorem Polynomial.reverse_leadingCoeff E1 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R), f.reverse.leadingCoeff = f.trailingCoeff

theorem Polynomial.natTrailingDegree_reverse E1 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R), f.reverse.natTrailingDegree = 0

theorem Polynomial.reverse_trailingCoeff E1 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R), f.reverse.trailingCoeff = f.leadingCoeff

theorem Polynomial.reverse_mul E1 #

∀ {R : Type u_1} [inst : Semiring R] {f g : Polynomial R},
  f.leadingCoeff * g.leadingCoeff ≠ 0 → (f * g).reverse = f.reverse * g.reverse

theorem Polynomial.reverse_mul_of_domain E0 #

∀ {R : Type u_2} [inst : Semiring R] [NoZeroDivisors R] (f g : Polynomial R), (f * g).reverse = f.reverse * g.reverse

theorem Polynomial.trailingCoeff_mul E1 #

∀ {R : Type u_2} [inst : Semiring R] [NoZeroDivisors R] (p q : Polynomial R),
  (p * q).trailingCoeff = p.trailingCoeff * q.trailingCoeff

theorem Polynomial.coeff_one_reverse E0 #

∀ {R : Type u_1} [inst : Semiring R] (f : Polynomial R), f.reverse.coeff 1 = f.nextCoeff

theorem Polynomial.reverse_C E0 #

∀ {R : Type u_1} [inst : Semiring R] (t : R), (Polynomial.C t).reverse = Polynomial.C t

theorem Polynomial.reverse_mul_X E0 #

∀ {R : Type u_1} [inst : Semiring R] (p : Polynomial R), (p * Polynomial.X).reverse = p.reverse

theorem Polynomial.reverse_X_mul E0 #

∀ {R : Type u_1} [inst : Semiring R] (p : Polynomial R), (Polynomial.X * p).reverse = p.reverse

theorem Polynomial.reverse_mul_X_pow E0 #

∀ {R : Type u_1} [inst : Semiring R] (p : Polynomial R) (n : ℕ), (p * Polynomial.X ^ n).reverse = p.reverse

theorem Polynomial.reverse_X_pow_mul E0 #

∀ {R : Type u_1} [inst : Semiring R] (p : Polynomial R) (n : ℕ), (Polynomial.X ^ n * p).reverse = p.reverse

theorem Polynomial.reverse_add_C E0 #

∀ {R : Type u_1} [inst : Semiring R] (p : Polynomial R) (t : R),
  (p + Polynomial.C t).reverse = p.reverse + Polynomial.C t * Polynomial.X ^ p.natDegree

theorem Polynomial.reverse_C_add E0 #

∀ {R : Type u_1} [inst : Semiring R] (p : Polynomial R) (t : R),
  (Polynomial.C t + p).reverse = Polynomial.C t * Polynomial.X ^ p.natDegree + p.reverse

theorem Polynomial.eval₂_reverse_mul_pow E1 #

∀ {R : Type u_1} [inst : Semiring R] {S : Type u_2} [inst_1 : CommSemiring S] (i : R →+* S) (x : S)
  [inst_2 : Invertible x] (f : Polynomial R),
  Polynomial.eval₂ i (⅟x) f.reverse * x ^ f.natDegree = Polynomial.eval₂ i x f

theorem Polynomial.eval₂_reverse_eq_zero_iff E0 #

∀ {R : Type u_1} [inst : Semiring R] {S : Type u_2} [inst_1 : CommSemiring S] (i : R →+* S) (x : S)
  [inst_2 : Invertible x] (f : Polynomial R), Polynomial.eval₂ i (⅟x) f.reverse = 0 ↔ Polynomial.eval₂ i x f = 0

theorem Polynomial.reflect_neg E0 #

∀ {R : Type u_1} [inst : Ring R] (f : Polynomial R) (N : ℕ), Polynomial.reflect N (-f) = -Polynomial.reflect N f

theorem Polynomial.reflect_sub E0 #

∀ {R : Type u_1} [inst : Ring R] (f g : Polynomial R) (N : ℕ),
  Polynomial.reflect N (f - g) = Polynomial.reflect N f - Polynomial.reflect N g

theorem Polynomial.reverse_neg E0 #

∀ {R : Type u_1} [inst : Ring R] (f : Polynomial R), (-f).reverse = -f.reverse