Documentation

CslibFrontier.Foundations.Data.Code.ReedSolomon

Reed–Solomon codes #

The Reed–Solomon code with degree bound k and evaluation points α : ι → F in a field F consists of the words i ↦ p (α i) of values of the polynomials p of degree less than k (Cslib.Code.reedSolomon) [RS60], [GRS19], MacWilliams and Sloane, Chapter 10. It is a linear code of length n = |ι|. When the points are distinct, a nonzero polynomial of degree less than k vanishes at fewer than k of them, so a nonzero codeword has weight at least n - k + 1 (Cslib.Code.le_hammingNorm_of_mem_reedSolomon); the product of X - α i over k - 1 of the points shows that this is attained, so for 1 ≤ k ≤ n the minimum distance is exactly n - k + 1 (Cslib.Code.minDist_reedSolomon). For k ≤ n the polynomials of degree less than k are determined by their values, so the code has dimension k (Cslib.Code.finrank_reedSolomon). Dimension plus minimum distance is n + 1: Reed–Solomon codes meet the Singleton bound Cslib.Code.finrank_add_le_card_add_one with equality.

Main definitions #

Main results #

References #

noncomputable def Cslib.Code.reedSolomon {F : Type u_1} {ι : Type u_2} [Field F] (α : ι → F) (k : ℕ) :
Submodule F (ι → F)

The Reed–Solomon code with degree bound k and evaluation points α: the words i ↦ p (α i) for the polynomials p of degree less than k. The points are usually distinct.

theorem Cslib.Code.mem_reedSolomon {F : Type u_1} {ι : Type u_2} [Field F] {α : ι → F} {k : ℕ} {w : ι → F} :
w ∈ reedSolomon α k ↔ ∃ (p : Polynomial F), p.degree < ↑k ∧ (fun (i : ι) => Polynomial.eval (α i) p) = w

A word is a codeword of reedSolomon α k exactly when it is i ↦ p (α i) for a polynomial p of degree less than k.

theorem Cslib.Code.eval_mem_reedSolomon {F : Type u_1} {ι : Type u_2} [Field F] {k : ℕ} (α : ι → F) {p : Polynomial F} (hp : p.degree < ↑k) :
(fun (i : ι) => Polynomial.eval (α i) p) ∈ reedSolomon α k

The values i ↦ p (α i) of a polynomial p of degree less than k form a codeword of reedSolomon α k.

theorem Cslib.Code.card_filter_eval_eq_zero_le {F : Type u_1} {ι : Type u_2} [Field F] {α : ι → F} [Fintype ι] [DecidableEq F] (hα : Function.Injective α) {p : Polynomial F} (hp : p ≠ 0) :
{i : ι | Polynomial.eval (α i) p = 0}.card ≤ p.natDegree

A nonzero polynomial vanishes at no more of the distinct points α i than its degree.

theorem Cslib.Code.card_filter_eval_eq_eval_le {F : Type u_1} {ι : Type u_2} [Field F] {α : ι → F} [Fintype ι] [DecidableEq F] (hα : Function.Injective α) {d : ℕ} {P Q : Polynomial F} (hP : P.natDegree ≤ d) (hQ : Q.natDegree ≤ d) (hne : P ≠ Q) :
{i : ι | Polynomial.eval (α i) P = Polynomial.eval (α i) Q}.card ≤ d

Two distinct polynomials of natDegree at most d agree at no more than d of the distinct points α i.

theorem Cslib.Code.le_hammingNorm_of_mem_reedSolomon {F : Type u_1} {ι : Type u_2} [Field F] {α : ι → F} {k : ℕ} [Fintype ι] [DecidableEq F] (hα : Function.Injective α) {w : ι → F} (hw : w ∈ reedSolomon α k) (hw0 : w ≠ 0) :

With distinct points, a nonzero codeword of the Reed–Solomon code with degree bound k has weight at least n - k + 1.

theorem Cslib.Code.le_minDist_reedSolomon {F : Type u_1} {ι : Type u_2} [Field F] {α : ι → F} [Fintype ι] [DecidableEq F] (hα : Function.Injective α) (k : ℕ) :
↑(Fintype.card ι - k + 1) ≤ minDist ↑(reedSolomon α k)

With distinct points, the Reed–Solomon code with degree bound k has minimum distance at least n - k + 1.

theorem Cslib.Code.minDist_reedSolomon {F : Type u_1} {ι : Type u_2} [Field F] {α : ι → F} {k : ℕ} [Fintype ι] [DecidableEq F] (hα : Function.Injective α) (hk : 1 ≤ k) (hkn : k ≤ Fintype.card ι) :
minDist ↑(reedSolomon α k) = ↑(Fintype.card ι - k + 1)

The distance of Reed–Solomon codes. With distinct points, the Reed–Solomon code with degree bound 1 ≤ k ≤ n has minimum distance exactly n - k + 1.

theorem Cslib.Code.eq_of_hammingDist_le_reedSolomon {F : Type u_1} {ι : Type u_2} [Field F] {α : ι → F} {k : ℕ} [Fintype ι] [DecidableEq F] (hα : Function.Injective α) {e : ℕ} (huniq : 2 * e + k ≤ Fintype.card ι) {f c₁ c₂ : ι → F} (hc₁ : c₁ ∈ reedSolomon α k) (hc₂ : c₂ ∈ reedSolomon α k) (hd₁ : hammingDist f c₁ ≤ e) (hd₂ : hammingDist f c₂ ≤ e) :
c₁ = c₂

Unique decoding for Reed–Solomon codes. With distinct points, inside the unique-decoding radius 2 * e + k ≤ n, a word is within Hamming distance e of at most one codeword.

theorem Cslib.Code.finrank_reedSolomon {F : Type u_1} {ι : Type u_2} [Field F] {α : ι → F} {k : ℕ} [Fintype ι] (hα : Function.Injective α) (hkn : k ≤ Fintype.card ι) :

With distinct points, the Reed–Solomon code with degree bound k ≤ n has dimension k.