Documentation

CslibFrontier.Foundations.Data.Code.RandomLinear

The distance of random linear codes #

A k-by-n generating matrix G over 𝔽₂ encodes x ∈ 𝔽₂ᵏ as the combination x ᵥ* G of its rows. For a fixed nonzero x, this combination is uniformly distributed when G is uniform: every word y ∈ 𝔽₂ⁿ is hit by a 2⁻ⁿ fraction of the matrices (Cslib.Code.card_filter_vecMul_eq_mul_two_pow), since G ↦ x ᵥ* G is additive and onto (the matrix whose row i is y, for some i with x i = 1, is sent to y), so its fibers have equal size (AddMonoidHom.card_fiber_eq_of_mem_range). A union bound over the 2ᵏ - 1 nonzero messages and the entropy bound on the volume of a Hamming ball then give Goldreich's Proposition E.1 (Cslib.Code.one_sub_inv_two_pow_lt_card_filter_le_hammingDist): if 2 d ≤ n and k + t ≤ n (1 - H₂(d / n)), a uniformly random generating matrix yields a code of distance at least d with probability greater than 1 - 2⁻ᵗ.

Main results #

References #

theorem Cslib.Code.card_filter_vecMul_eq_mul_two_pow {k n : ℕ} {x : Fin k → ZMod 2} (hx : x ≠ 0) (y : Fin n → ZMod 2) :
{G : Matrix (Fin k) (Fin n) (ZMod 2) | Matrix.vecMul x G = y}.card * 2 ^ n = 2 ^ (k * n)

A nonzero combination of the rows of a uniform matrix is uniform: for a nonzero x ∈ 𝔽₂ᵏ and any y ∈ 𝔽₂ⁿ, exactly a 2⁻ⁿ fraction of the k-by-n matrices G satisfy x ᵥ* G = y.

theorem Cslib.Code.one_sub_inv_two_pow_lt_card_filter_le_hammingDist {k n d t : ℕ} (hd : 2 * d ≤ n) (h : ↑k + ↑t ≤ ↑n * (1 - Real.binEntropy (↑d / ↑n) / Real.log 2)) :
1 - (1 / 2) ^ t < ↑{G : Matrix (Fin k) (Fin n) (ZMod 2) | ∀ (x y : Fin k → ZMod 2), x ≠ y → d ≤ hammingDist (Matrix.vecMul x G) (Matrix.vecMul y G)}.card / ↑(Fintype.card (Matrix (Fin k) (Fin n) (ZMod 2)))

The distance of random linear codes Goldreich, Proposition E.1. If 2 d ≤ n and k + t ≤ n (1 - H₂(d / n)), where H₂(δ) = Real.binEntropy δ / Real.log 2 is the binary entropy in bits, then a uniformly random k-by-n generating matrix G over 𝔽₂ yields a code of distance at least d (every two messages are encoded d positions apart) with probability greater than 1 - 2⁻ᵗ.

The source states the hypothesis for large k as n ≥ max(2d, (k + t) / (1 - H₂(d / n))); this theorem holds at every k where the hypothesis does, so it implies the eventual statement. The quotient is multiplied out because 1 - H₂(1 / 2) = 0, where the source's bound is infinite (and Lean's quotient would be 0).