Documentation

CslibFrontier.Foundations.Data.Code.Varshamov

Binary linear codes at rate 1 - H(δ) #

Varshamov's bound for binary linear codes: if fewer than 2 ^ c nonzero words of 𝔽₂^ι are to be avoided, some matrix with c rows maps all of them to nonzero vectors (Cslib.Code.exists_mulVec_ne_zero_of_card_lt), since a fixed nonzero word lies in the kernel of exactly half of the rows. Applied to the nonzero words of weight less than δ m, whose number the entropy bound controls, this gives a linear code 𝔽₂ⁿ → 𝔽₂ᵐ of relative distance δ whenever n ≤ m (1 - H(δ)) and δ ≤ 1 / 2 (Cslib.Code.exists_linearMap_injective_and_le_hammingDist). Here H(δ) is the binary entropy in bits, Real.binEntropy δ / Real.log 2.

Rounding the length gives three statements of Arora and Barak [AB09], each for every n rather than for large n, and each with a linear code:

Main results #

References #

theorem Cslib.Code.exists_mulVec_ne_zero_of_card_lt {ι : Type u_1} [Fintype ι] {B : Finset (ι → ZMod 2)} (h0 : 0 ∉ B) {c : ℕ} (hB : B.card < 2 ^ c) :
∃ (H : Matrix (Fin c) ι (ZMod 2)), ∀ x ∈ B, H.mulVec x ≠ 0

Varshamov's union bound [Var57]. If a set B of nonzero words of 𝔽₂^ι has fewer than 2 ^ c elements, some matrix with c rows maps every element of B to a nonzero vector: a fixed nonzero word lies in the kernel of a 2 ^ (-c) fraction of the matrices.

theorem Cslib.Code.exists_linearMap_injective_and_le_hammingDist {δ : ℝ} (hδ₀ : 0 ≤ δ) (hδ : δ ≤ 1 / 2) {n m : ℕ} (h : ↑n ≤ ↑m * (1 - Real.binEntropy δ / Real.log 2)) :
∃ (E : (Fin n → ZMod 2) →ₗ[ZMod 2] Fin m → ZMod 2), Function.Injective ⇑E ∧ ∀ (x y : Fin n → ZMod 2), x ≠ y → δ * ↑m ≤ ↑(hammingDist (E x) (E y))

Linear codes at rate 1 - H(δ). For 0 ≤ δ ≤ 1 / 2 and n ≤ m (1 - H(δ)), where H(δ) = Real.binEntropy δ / Real.log 2 is the binary entropy in bits, there is an injective linear map E : 𝔽₂ⁿ → 𝔽₂ᵐ whose distinct codewords differ in at least δ m positions.

theorem Cslib.Code.exists_linearMap_two_mul {δ : ℝ} (hδ₀ : 0 ≤ δ) (hδ : δ < 1 / 2) (n : ℕ) :
∃ (E : (Fin n → ZMod 2) →ₗ[ZMod 2] Fin ⌊2 * ↑n / (1 - Real.binEntropy δ / Real.log 2)⌋₊ → ZMod 2), Function.Injective ⇑E ∧ ∀ (x y : Fin n → ZMod 2), x ≠ y → δ * ↑⌊2 * ↑n / (1 - Real.binEntropy δ / Real.log 2)⌋₊ ≤ ↑(hammingDist (E x) (E y))

Constant-rate codes exist Arora and Barak, Lemma 17.9. For 0 ≤ δ < 1 / 2 and every n, there is an injective map E : {0,1}ⁿ → {0,1}ᵐ, here linear, with m = ⌊2n / (1 - H(δ))⌋ and relative distance δ: distinct codewords differ in at least δ m positions. H(δ) = Real.binEntropy δ / Real.log 2 is the binary entropy in bits. The draft states this for large n and leaves the length unrounded.

theorem Cslib.Code.exists_linearMap_ceil_div {δ : ℝ} (hδ₀ : 0 ≤ δ) (hδ : δ < 1 / 2) (n : ℕ) :
∃ (E : (Fin n → ZMod 2) →ₗ[ZMod 2] Fin ⌈↑n / (1 - Real.binEntropy δ / Real.log 2)⌉₊ → ZMod 2), Function.Injective ⇑E ∧ ∀ (x y : Fin n → ZMod 2), x ≠ y → δ * ↑⌈↑n / (1 - Real.binEntropy δ / Real.log 2)⌉₊ ≤ ↑(hammingDist (E x) (E y))

The Gilbert–Varshamov bound Arora and Barak, Exercise 17.6. For 0 ≤ δ < 1 / 2 and every n, there is an injective map E : {0,1}ⁿ → {0,1}ᵐ, here linear, with m = ⌈n / (1 - H(δ))⌉ and relative distance δ. H(δ) = Real.binEntropy δ / Real.log 2 is the binary entropy in bits. The draft states this for large n and leaves the length unrounded.

theorem Cslib.Code.exists_linearMap_ceil_mul_div {δ : ℝ} (hδ₀ : 0 ≤ δ) (hδ : δ < 1 / 2) (n : ℕ) :
∃ (E : (Fin n → ZMod 2) →ₗ[ZMod 2] Fin ⌈1.1 * ↑n / (1 - Real.binEntropy δ / Real.log 2)⌉₊ → ZMod 2), Function.Injective ⇑E ∧ ∀ (x y : Fin n → ZMod 2), x ≠ y → δ * ↑⌈1.1 * ↑n / (1 - Real.binEntropy δ / Real.log 2)⌉₊ ≤ ↑(hammingDist (E x) (E y))

Linear codes Arora and Barak, Exercise 17.10(b), corrected. For 0 ≤ δ < 1 / 2 and every n, there is an injective linear map E : {0,1}ⁿ → {0,1}ᵐ with m = ⌈1.1 n / (1 - H(δ))⌉ and relative distance δ. H(δ) = Real.binEntropy δ / Real.log 2 is the binary entropy in bits. The draft says "for every δ > 0", which fails for δ ≥ 1 / 2: the length is undefined at δ = 1 / 2, and Plotkin's bound (Exercise 17.7) rules out 2 ^ n codewords of relative distance above 1 / 2 for large n.