Documentation

CslibFrontier.Foundations.Algebra.Negacyclic

The negacyclic ring R[X] / (X^n + 1) on coefficient vectors #

For n ≠ 0, an element of R[X] / (X^n + 1) has a unique representative of degree less than n, so it is stored as its coefficient vector Fin n → R. Multiplication by a is the linear action of the n × n negacyclic (anticirculant) matrix rotMatrix a, whose column j holds the coefficients of X^j · a mod (X^n + 1): negacyclicMul a b = rotMatrix a *ᵥ b. Over a commutative ring negacyclicMul is commutative and associative, rotMatrix is multiplicative, and the polynomial inner product innerPoly b r = ∑ j, negacyclicMul (b j) (r j) is symmetric.

Negacyclic R n packages the coefficient vector as a ring. It is a one-field structure rather than a synonym of Fin n → R, so that a * b always means negacyclicMul: a synonym would unfold to the function type, where * also elaborates as the pointwise product. The coefficient vector is Negacyclic.coeffs, and Negacyclic.ofCoeffs builds an element from one; addition, negation and scalar multiplication act coefficientwise. For [CommRing R] and every n, Negacyclic R n is a commutative R-algebra with 1 the constant polynomial. At n = 0 it is the zero ring on Fin 0 → R, a chosen zero-dimensional extension rather than the quotient: there X^0 + 1 = 2 and R[X] / (2) is generally nonzero. Sampling, encoding and norm bounds transfer along Negacyclic.coeffsEquiv and Negacyclic.coeffsLinearEquiv, and innerPoly becomes the dot product ⬝ᵥ over Negacyclic R n (Negacyclic.ofCoeffs_innerPoly).

Main definitions #

Main results #

Negacyclic multiplication of coefficient vectors #

def Cslib.rotMatrix {n : ℕ} {R : Type u_1} [Ring R] (a : Fin n → R) :
Matrix (Fin n) (Fin n) R

The n × n negacyclic (anticirculant) multiplication matrix of a degree-< n polynomial a : Fin n → R in R[X] / (X^n + 1). Column j represents X^j · a(X) mod (X^n + 1).

def Cslib.negacyclicMul {n : ℕ} {R : Type u_1} [Ring R] (a b : Fin n → R) :
Fin n → R

Negacyclic polynomial multiplication a * b mod (X^n + 1) on coefficient vectors Fin n → R, defined as the matrix-vector product rotMatrix a *ᵥ b.

@[simp]
theorem Cslib.rotMatrix_mulVec {n : ℕ} {R : Type u_1} [Ring R] (a b : Fin n → R) :

Negacyclic multiplication is the matrix-vector product with rotMatrix a.

@[simp]
theorem Cslib.rotMatrix_zero {n : ℕ} {R : Type u_1} [Ring R] :

The negacyclic matrix of the zero polynomial is the zero matrix.

theorem Cslib.rotMatrix_add {n : ℕ} {R : Type u_1} [Ring R] (a b : Fin n → R) :

rotMatrix preserves addition of coefficient vectors.

theorem Cslib.rotMatrix_neg {n : ℕ} {R : Type u_1} [Ring R] (a : Fin n → R) :

rotMatrix commutes with negation of coefficient vectors.

theorem Cslib.rotMatrix_sub {n : ℕ} {R : Type u_1} [Ring R] (a b : Fin n → R) :

rotMatrix commutes with subtraction of coefficient vectors.

theorem Cslib.rotMatrix_smul {n : ℕ} {R : Type u_1} [Ring R] (r : R) (a : Fin n → R) :

rotMatrix commutes with scalar multiplication of coefficient vectors.

theorem Cslib.map_rotMatrix {n : ℕ} {R : Type u_1} {S : Type u_2} [Ring R] [Ring S] (f : R →+* S) (a : Fin n → R) :
(rotMatrix a).map ⇑f = rotMatrix (⇑f ∘ a)

rotMatrix commutes with ring homomorphisms.

theorem Cslib.negacyclicMul_add {n : ℕ} {R : Type u_1} [Ring R] (a b c : Fin n → R) :

Negacyclic multiplication distributes over addition on the right.

theorem Cslib.add_negacyclicMul {n : ℕ} {R : Type u_1} [Ring R] (a b c : Fin n → R) :

Negacyclic multiplication distributes over addition on the left.

@[simp]
theorem Cslib.negacyclicMul_zero {n : ℕ} {R : Type u_1} [Ring R] (a : Fin n → R) :

Negacyclic multiplication with zero on the right is zero.

@[simp]
theorem Cslib.zero_negacyclicMul {n : ℕ} {R : Type u_1} [Ring R] (a : Fin n → R) :

Negacyclic multiplication with zero on the left is zero.

@[simp]
theorem Cslib.negacyclicMul_neg {n : ℕ} {R : Type u_1} [Ring R] (a b : Fin n → R) :

Negacyclic multiplication commutes with negation on the right.

@[simp]
theorem Cslib.neg_negacyclicMul {n : ℕ} {R : Type u_1} [Ring R] (a b : Fin n → R) :

Negacyclic multiplication commutes with negation on the left.

theorem Cslib.negacyclicMul_sub {n : ℕ} {R : Type u_1} [Ring R] (a b c : Fin n → R) :

Negacyclic multiplication distributes over subtraction on the right.

theorem Cslib.sub_negacyclicMul {n : ℕ} {R : Type u_1} [Ring R] (a b c : Fin n → R) :

Negacyclic multiplication distributes over subtraction on the left.

theorem Cslib.smul_negacyclicMul {n : ℕ} {R : Type u_1} [Ring R] (r : R) (a b : Fin n → R) :

Negacyclic multiplication commutes with scalar multiplication on the left.

theorem Cslib.negacyclicMul_smul {n : ℕ} {R : Type u_1} [CommRing R] (r : R) (a b : Fin n → R) :

Negacyclic multiplication commutes with scalar multiplication on the right.

theorem Cslib.sum_negacyclicMul {n : ℕ} {R : Type u_1} [Ring R] {ι : Type u_2} (s : Finset ι) (f : ι → Fin n → R) (b : Fin n → R) :
negacyclicMul (∑ i ∈ s, f i) b = ∑ i ∈ s, negacyclicMul (f i) b

Negacyclic multiplication distributes over finite sums on the left.

theorem Cslib.negacyclicMul_sum {n : ℕ} {R : Type u_1} [Ring R] {ι : Type u_2} (s : Finset ι) (a : Fin n → R) (f : ι → Fin n → R) :
negacyclicMul a (∑ i ∈ s, f i) = ∑ i ∈ s, negacyclicMul a (f i)

Negacyclic multiplication distributes over finite sums on the right.

theorem Cslib.map_negacyclicMul {n : ℕ} {R : Type u_1} {S : Type u_2} [Ring R] [Ring S] (f : R →+* S) (a b : Fin n → R) :
⇑f ∘ negacyclicMul a b = negacyclicMul (⇑f ∘ a) (⇑f ∘ b)

Negacyclic multiplication commutes with ring homomorphisms applied to coefficients.

Commutativity and associativity #

theorem Cslib.negacyclicMul_comm {n : ℕ} {R : Type u_1} [CommRing R] (a b : Fin n → R) :

Commutativity of negacyclic polynomial multiplication: a * b = b * a in R[X] / (X^n + 1) over any commutative ring R.

theorem Cslib.rotMatrix_negacyclicMul {n : ℕ} {R : Type u_1} [CommRing R] (a b : Fin n → R) :

Multiplicativity of rotMatrix: the negacyclic multiplication matrix of negacyclicMul a b is the matrix product rotMatrix a * rotMatrix b.

theorem Cslib.negacyclicMul_assoc {n : ℕ} {R : Type u_1} [CommRing R] (a b c : Fin n → R) :

Associativity of negacyclic polynomial multiplication: (a * b) * c = a * (b * c) in R[X] / (X^n + 1) over any commutative ring R.

Coefficient bounds over ℤ #

theorem Cslib.abs_rotMatrix_le {n α : ℕ} {a : Fin n → ℤ} (ha : ∀ (i : Fin n), |a i| ≤ ↑α) (i j : Fin n) :
|rotMatrix a i j| ≤ ↑α

Entrywise absolute-value bound for rotMatrix over ℤ.

theorem Cslib.abs_negacyclicMul_le {n α β : ℕ} {a b : Fin n → ℤ} (ha : ∀ (i : Fin n), |a i| ≤ ↑α) (hb : ∀ (j : Fin n), |b j| ≤ ↑β) (i : Fin n) :
|negacyclicMul a b i| ≤ ↑n * ↑α * ↑β

Infinity-norm bound for negacyclic multiplication: if ‖a‖_∞ ≤ α and ‖b‖_∞ ≤ β, then every coefficient of negacyclicMul a b has absolute value at most n * α * β.

theorem Cslib.sum_abs_rotMatrix_apply {n : ℕ} (a : Fin n → ℤ) (i : Fin n) :
∑ j : Fin n, |rotMatrix a i j| = ∑ j : Fin n, |a j|

Each row of rotMatrix a is a signed rearrangement of a, so its absolute values sum to the ℓ₁ norm of a.

theorem Cslib.abs_negacyclicMul_le_sum_abs_mul {n β : ℕ} {a b : Fin n → ℤ} (hb : ∀ (j : Fin n), |b j| ≤ ↑β) (i : Fin n) :
|negacyclicMul a b i| ≤ (∑ j : Fin n, |a j|) * ↑β

ℓ₁-ℓ∞ bound for negacyclic multiplication: if ‖b‖_∞ ≤ β, then every coefficient of negacyclicMul a b has absolute value at most ‖a‖₁ · β.

Inner products of coefficient-vector tuples #

def Cslib.innerPoly {k n : ℕ} {R : Type u_1} [Ring R] (b r : Fin k → Fin n → R) :
Fin n → R

Polynomial inner product ⟨b, r⟩ = ∑ j : Fin k, negacyclicMul (b j) (r j) over R[X] / (X^n + 1).

theorem Cslib.innerPoly_comm {k n : ℕ} {R : Type u_1} [CommRing R] (a b : Fin k → Fin n → R) :

innerPoly is symmetric over any commutative ring R.

@[simp]
theorem Cslib.innerPoly_zero_left {k n : ℕ} {R : Type u_1} [Ring R] (r : Fin k → Fin n → R) :
innerPoly 0 r = 0
@[simp]
theorem Cslib.innerPoly_zero_right {k n : ℕ} {R : Type u_1} [Ring R] (b : Fin k → Fin n → R) :
innerPoly b 0 = 0
theorem Cslib.innerPoly_add_left {k n : ℕ} {R : Type u_1} [Ring R] (a b r : Fin k → Fin n → R) :
innerPoly (a + b) r = innerPoly a r + innerPoly b r

innerPoly is additive in its first argument.

theorem Cslib.innerPoly_add_right {k n : ℕ} {R : Type u_1} [Ring R] (b r s : Fin k → Fin n → R) :
innerPoly b (r + s) = innerPoly b r + innerPoly b s

innerPoly is additive in its second argument.

theorem Cslib.innerPoly_sub_left {k n : ℕ} {R : Type u_1} [Ring R] (a b r : Fin k → Fin n → R) :
innerPoly (a - b) r = innerPoly a r - innerPoly b r

innerPoly commutes with subtraction in its first argument.

theorem Cslib.innerPoly_sub_right {k n : ℕ} {R : Type u_1} [Ring R] (b r s : Fin k → Fin n → R) :
innerPoly b (r - s) = innerPoly b r - innerPoly b s

innerPoly commutes with subtraction in its second argument.

theorem Cslib.map_innerPoly {k n : ℕ} {R : Type u_1} {S : Type u_2} [Ring R] [Ring S] (f : R →+* S) (a b : Fin k → Fin n → R) :
⇑f ∘ innerPoly a b = innerPoly (fun (j : Fin k) => ⇑f ∘ a j) fun (j : Fin k) => ⇑f ∘ b j

innerPoly commutes with ring homomorphisms applied to polynomial coefficients.

theorem Cslib.abs_innerPoly_le {k n α β : ℕ} {a b : Fin k → Fin n → ℤ} (ha : ∀ (j : Fin k) (i : Fin n), |a j i| ≤ ↑α) (hb : ∀ (j : Fin k) (i : Fin n), |b j i| ≤ ↑β) (i : Fin n) :
|innerPoly a b i| ≤ ↑k * ↑n * ↑α * ↑β

Infinity-norm bound for innerPoly: if every coefficient of a has absolute value at most α and every coefficient of b has absolute value at most β, then every coefficient of innerPoly a b has absolute value at most k * n * α * β.

The ring Negacyclic R n #

structure Cslib.Negacyclic (R : Type u_1) (n : ℕ) :
Type u_1

For n ≠ 0, the negacyclic ring R[X] / (X^n + 1), stored as the coefficient vector of the unique representative of degree less than n. Multiplication is negacyclicMul, never the pointwise product of coefficient vectors. For n = 0 this is the zero ring, a chosen extension rather than the quotient R[X] / (2).

  • ofCoeffs :: (
    • coeffs : Fin n → R

      The coefficient vector of the representative of degree less than n.

  • )
Instances For
    theorem Cslib.Negacyclic.ext_iff {R : Type u_1} {n : ℕ} {x y : Negacyclic R n} :
    x = y ↔ x.coeffs = y.coeffs
    theorem Cslib.Negacyclic.ext {R : Type u_1} {n : ℕ} {x y : Negacyclic R n} (coeffs : x.coeffs = y.coeffs) :
    x = y
    @[simp]
    theorem Cslib.Negacyclic.coeffs_ofCoeffs {R : Type u_1} {n : ℕ} (a : Fin n → R) :
    { coeffs := a }.coeffs = a
    @[simp]
    theorem Cslib.Negacyclic.ofCoeffs_coeffs {R : Type u_1} {n : ℕ} (a : Negacyclic R n) :
    { coeffs := a.coeffs } = a
    def Cslib.Negacyclic.coeffsEquiv {R : Type u_1} {n : ℕ} :
    Negacyclic R n ≃ (Fin n → R)

    Coefficient vectors as a plain equivalence, for transferring sampling and encodings.

    @[simp]
    theorem Cslib.Negacyclic.coeffsEquiv_apply {R : Type u_1} {n : ℕ} (self : Negacyclic R n) (a✝ : Fin n) :
    coeffsEquiv self a✝ = self.coeffs a✝
    @[simp]
    theorem Cslib.Negacyclic.coeffsEquiv_symm_apply_coeffs {R : Type u_1} {n : ℕ} (coeffs : Fin n → R) (a✝ : Fin n) :
    (coeffsEquiv.symm coeffs).coeffs a✝ = coeffs a✝
    @[instance_reducible]
    @[instance_reducible]
    instance Cslib.Negacyclic.instFintype {R : Type u_1} {n : ℕ} [Fintype R] :
    @[instance_reducible]
    instance Cslib.Negacyclic.instZero {R : Type u_1} {n : ℕ} [Zero R] :
    @[instance_reducible]
    instance Cslib.Negacyclic.instAdd {R : Type u_1} {n : ℕ} [Add R] :
    @[instance_reducible]
    instance Cslib.Negacyclic.instNeg {R : Type u_1} {n : ℕ} [Neg R] :
    @[instance_reducible]
    instance Cslib.Negacyclic.instSub {R : Type u_1} {n : ℕ} [Sub R] :
    @[instance_reducible]
    instance Cslib.Negacyclic.instSMul {R : Type u_1} {n : ℕ} {S : Type u_2} [SMul S R] :
    @[simp]
    theorem Cslib.Negacyclic.coeffs_zero {R : Type u_1} {n : ℕ} [Zero R] :
    coeffs 0 = 0
    @[simp]
    theorem Cslib.Negacyclic.coeffs_add {R : Type u_1} {n : ℕ} [Add R] (a b : Negacyclic R n) :
    (a + b).coeffs = a.coeffs + b.coeffs
    @[simp]
    theorem Cslib.Negacyclic.coeffs_neg {R : Type u_1} {n : ℕ} [Neg R] (a : Negacyclic R n) :
    @[simp]
    theorem Cslib.Negacyclic.coeffs_sub {R : Type u_1} {n : ℕ} [Sub R] (a b : Negacyclic R n) :
    (a - b).coeffs = a.coeffs - b.coeffs
    @[simp]
    theorem Cslib.Negacyclic.coeffs_smul {R : Type u_1} {n : ℕ} {S : Type u_2} [SMul S R] (s : S) (a : Negacyclic R n) :
    (s • a).coeffs = s • a.coeffs
    @[instance_reducible]
    @[instance_reducible]
    instance Cslib.Negacyclic.instModule {R : Type u_1} {n : ℕ} {S : Type u_2} [Semiring S] [AddCommGroup R] [Module S R] :
    def Cslib.Negacyclic.coeffsLinearEquiv {R : Type u_1} {n : ℕ} (S : Type u_2) [Semiring S] [AddCommGroup R] [Module S R] :
    Negacyclic R n ≃ₗ[S] Fin n → R

    Coefficient vectors as an S-linear equivalence.

    @[simp]
    theorem Cslib.Negacyclic.coeffsLinearEquiv_symm_apply_coeffs {R : Type u_1} {n : ℕ} (S : Type u_2) [Semiring S] [AddCommGroup R] [Module S R] (coeffs : Fin n → R) (a✝ : Fin n) :
    ((coeffsLinearEquiv S).symm coeffs).coeffs a✝ = coeffs a✝
    @[simp]
    theorem Cslib.Negacyclic.coeffsLinearEquiv_apply {R : Type u_1} {n : ℕ} (S : Type u_2) [Semiring S] [AddCommGroup R] [Module S R] (self : Negacyclic R n) (a✝ : Fin n) :
    (coeffsLinearEquiv S) self a✝ = self.coeffs a✝
    @[simp]
    theorem Cslib.Negacyclic.coeffs_sum {R : Type u_1} {n : ℕ} [AddCommGroup R] {ι : Type u_2} (s : Finset ι) (f : ι → Negacyclic R n) :
    (∑ i ∈ s, f i).coeffs = ∑ i ∈ s, (f i).coeffs
    theorem Cslib.Negacyclic.ofCoeffs_sum {R : Type u_1} {n : ℕ} [AddCommGroup R] {ι : Type u_2} (s : Finset ι) (f : ι → Fin n → R) :
    { coeffs := ∑ i ∈ s, f i } = ∑ i ∈ s, { coeffs := f i }
    @[instance_reducible]
    instance Cslib.Negacyclic.instMul {R : Type u_1} {n : ℕ} [Ring R] :
    @[instance_reducible]
    instance Cslib.Negacyclic.instOne {R : Type u_1} {n : ℕ} [Ring R] :

    The constant polynomial 1: coefficient 1 in degree zero and 0 elsewhere.

    @[simp]
    theorem Cslib.Negacyclic.coeffs_mul {R : Type u_1} {n : ℕ} [Ring R] (a b : Negacyclic R n) :
    @[simp]
    theorem Cslib.Negacyclic.coeffs_one {R : Type u_1} {n : ℕ} [Ring R] (i : Fin n) :
    coeffs 1 i = if ↑i = 0 then 1 else 0
    theorem Cslib.Negacyclic.ofCoeffs_negacyclicMul {R : Type u_1} {n : ℕ} [Ring R] (a b : Fin n → R) :
    { coeffs := negacyclicMul a b } = { coeffs := a } * { coeffs := b }
    @[simp]

    The negacyclic matrix of the constant polynomial 1 is the identity matrix.

    @[simp]
    theorem Cslib.Negacyclic.one_negacyclicMul {R : Type u_1} {n : ℕ} [Ring R] (a : Fin n → R) :

    Multiplying by the coefficients of the constant polynomial 1 is the identity.

    theorem Cslib.Negacyclic.ofCoeffs_innerPoly {R : Type u_1} {n : ℕ} [Ring R] {k : ℕ} (b r : Fin k → Fin n → R) :

    innerPoly is the dot product over Negacyclic R n.

    @[simp]
    theorem Cslib.Negacyclic.negacyclicMul_one {R : Type u_1} {n : ℕ} [CommRing R] (a : Fin n → R) :

    Multiplying by the coefficients of the constant polynomial 1 on the right is the identity.

    @[instance_reducible]
    @[instance_reducible]
    instance Cslib.Negacyclic.instAlgebra {R : Type u_1} {n : ℕ} [CommRing R] :
    @[simp]
    theorem Cslib.Negacyclic.coeffs_algebraMap {R : Type u_1} {n : ℕ} [CommRing R] (r : R) (i : Fin n) :
    ((algebraMap R (Negacyclic R n)) r).coeffs i = if ↑i = 0 then r else 0

    algebraMap R (Negacyclic R n) r is the constant polynomial r.

    @[simp]
    theorem Cslib.Negacyclic.coeffs_natCast {R : Type u_1} {n : ℕ} [CommRing R] (m : ℕ) (i : Fin n) :
    (↑m).coeffs i = if ↑i = 0 then ↑m else 0

    A natural-number cast is the constant polynomial with that value.

    @[simp]
    theorem Cslib.Negacyclic.coeffs_intCast {R : Type u_1} {n : ℕ} [CommRing R] (m : ℤ) (i : Fin n) :
    (↑m).coeffs i = if ↑i = 0 then ↑m else 0

    An integer cast is the constant polynomial with that value.

    @[simp]
    theorem Cslib.Negacyclic.coeffs_ofNat {R : Type u_1} {n : ℕ} [CommRing R] (m : ℕ) [m.AtLeastTwo] (i : Fin n) :

    A numeral is the constant polynomial with that value.