Documentation

CslibFrontier.Foundations.Data.Code.Plotkin

The Plotkin bound #

Let C be a code of length n and minimum distance at least d over an alphabet α of q letters. At every coordinate, by the Cauchy–Schwarz inequality, at least a 1 / q fraction of the ordered pairs of codewords agree (Cslib.Code.sq_card_le_card_mul_sum_sum_ite). Summing over the coordinates, the sum of the distances over all ordered pairs of codewords is at most (1 - 1 / q) n |C|² (Cslib.Code.card_mul_sum_sum_hammingDist_add_le), while each of the |C| (|C| - 1) pairs of distinct codewords contributes at least d. Comparing the two gives the Plotkin bound [Plo60], [GuruswamiRudraSudan2019, Theorem 4.4.1 and Exercise 4.17]: |C| (q d - (q - 1) n) ≤ q d (Cslib.Code.card_mul_sub_le_of_le_minDist), so that |C| ≤ q d / (q d - (q - 1) n) when d > (1 - 1 / q) n (Cslib.Code.card_le_div_of_le_minDist).

The argument only uses the coordinates where codewords may differ, so it bounds every code whose words agree outside a set T of coordinates by the same expression with |T| in place of n (Cslib.Code.card_mul_sub_le_of_le_minDist_of_forall_notMem_eq). Shortening a code to any m coordinates, that is splitting it according to its letters at the other n - m coordinates, gives |C| (q d - (q - 1) m) ≤ q ^ (n - m) q d (Cslib.Code.card_mul_sub_le_pow_mul_of_le_minDist). Two consequences:

Main results #

References #

theorem Cslib.Code.sum_sum_ite_eq_sum_sq {ι : Type u_1} {α : Type u_2} [Fintype α] [DecidableEq α] (C : Finset (ι → α)) (i : ι) :
(∑ x ∈ C, ∑ y ∈ C, if x i = y i then 1 else 0) = ∑ b : α, {x ∈ C | x i = b}.card ^ 2

The ordered pairs of words of C that agree at the coordinate i, counted by their common letter there.

theorem Cslib.Code.sq_card_le_card_mul_sum_sum_ite {ι : Type u_1} {α : Type u_2} [Fintype α] [DecidableEq α] (C : Finset (ι → α)) (i : ι) :
C.card ^ 2 ≤ Fintype.card α * ∑ x ∈ C, ∑ y ∈ C, if x i = y i then 1 else 0

The column bound. At every coordinate, at least a 1 / q fraction of the ordered pairs of words of C agree, where q = |α|.

theorem Cslib.Code.hammingDist_add_sum_ite_eq_card {ι : Type u_1} {α : Type u_2} [Fintype ι] [DecidableEq α] {x y : ι → α} {T : Finset ι} (h : ∀ i ∉ T, x i = y i) :
(hammingDist x y + ∑ i ∈ T, if x i = y i then 1 else 0) = T.card

For words that agree outside T, the Hamming distance plus the number of coordinates of T where they agree is |T|.

theorem Cslib.Code.sum_sum_hammingDist_add_sum_sum_sum_ite {ι : Type u_1} {α : Type u_2} [Fintype ι] [DecidableEq α] {C : Finset (ι → α)} {T : Finset ι} (hT : ∀ x ∈ C, ∀ y ∈ C, ∀ i ∉ T, x i = y i) :
(∑ x ∈ C, ∑ y ∈ C, hammingDist x y + ∑ x ∈ C, ∑ y ∈ C, ∑ i ∈ T, if x i = y i then 1 else 0) = T.card * C.card ^ 2

Double counting for words that agree outside T: the distances plus the agreements in T, summed over the ordered pairs of words of C, add up to |T| |C|².

theorem Cslib.Code.card_mul_sum_sum_hammingDist_add_le {ι : Type u_1} {α : Type u_2} [Fintype ι] [Fintype α] [DecidableEq α] {C : Finset (ι → α)} {T : Finset ι} (hT : ∀ x ∈ C, ∀ y ∈ C, ∀ i ∉ T, x i = y i) :
Fintype.card α * ∑ x ∈ C, ∑ y ∈ C, hammingDist x y + T.card * C.card ^ 2 ≤ Fintype.card α * (T.card * C.card ^ 2)

The total distance of a code whose words agree outside T: q ∑ Δ(x, y) + |T| |C|² ≤ q |T| |C|², the sum over the ordered pairs of words of C, where q = |α|. In other words, the average distance is at most (1 - 1 / q) |T|.

theorem Cslib.Code.card_mul_card_sub_one_mul_le_sum_sum_hammingDist {ι : Type u_1} {α : Type u_2} [Fintype ι] [DecidableEq α] {C : Finset (ι → α)} {d : ℕ} (hd : ↑d ≤ minDist ↑C) :
C.card * (C.card - 1) * d ≤ ∑ x ∈ C, ∑ y ∈ C, hammingDist x y

The distances between distinct words of a code of minimum distance at least d, summed over the ordered pairs of codewords, add up to at least |C| (|C| - 1) d.

theorem Cslib.Code.card_mul_sub_le_of_le_minDist_of_forall_notMem_eq {ι : Type u_1} {α : Type u_2} [Fintype ι] [Fintype α] [DecidableEq α] {C : Finset (ι → α)} {d : ℕ} (hd : ↑d ≤ minDist ↑C) {T : Finset ι} (hT : ∀ x ∈ C, ∀ y ∈ C, ∀ i ∉ T, x i = y i) :

The Plotkin bound for codes that agree outside T. If the words of a code C of minimum distance at least d over q letters agree outside a set T of coordinates, then |C| (q d - (q - 1) |T|) ≤ q d.

theorem Cslib.Code.card_mul_sub_le_pow_mul_of_le_minDist {ι : Type u_1} {α : Type u_2} [Fintype ι] [Fintype α] [DecidableEq α] {C : Finset (ι → α)} {d : ℕ} (hd : ↑d ≤ minDist ↑C) {m : ℕ} (hm : m ≤ Fintype.card ι) :

The Plotkin bound for shortened codes. For a code C of length n and minimum distance at least d over q letters, and any m ≤ n, |C| (q d - (q - 1) m) ≤ q ^ (n - m) q d: fixing the letters at n - m coordinates leaves a code that agrees outside the other m coordinates, to which the Plotkin bound applies [GuruswamiRudraSudan2019, proof of Corollary 4.4.2].

theorem Cslib.Code.card_mul_sub_le_of_le_minDist {ι : Type u_1} {α : Type u_2} [Fintype ι] [Fintype α] [DecidableEq α] {C : Finset (ι → α)} {d : ℕ} (hd : ↑d ≤ minDist ↑C) :

The Plotkin bound [Plo60], [GuruswamiRudraSudan2019, Theorem 4.4.1, part 2]: a code C of length n and minimum distance at least d over q letters satisfies |C| (q d - (q - 1) n) ≤ q d. It bounds |C| when d > (1 - 1 / q) n and says nothing otherwise.

theorem Cslib.Code.card_le_div_of_le_minDist {ι : Type u_1} {α : Type u_2} [Fintype ι] [Fintype α] [DecidableEq α] {C : Finset (ι → α)} {d : ℕ} (hd : ↑d ≤ minDist ↑C) (h : (Fintype.card α - 1) * Fintype.card ι < Fintype.card α * d) :

The Plotkin bound [Plo60], [GuruswamiRudraSudan2019, Theorem 4.4.1, part 2], quotient form: if d > (1 - 1 / q) n, a code of length n and minimum distance at least d over q letters has at most q d / (q d - (q - 1) n) codewords.

theorem Cslib.Code.card_le_mul_of_le_minDist_of_mul_eq {ι : Type u_1} {α : Type u_2} [Fintype ι] [Fintype α] [DecidableEq α] [Nonempty α] {C : Finset (ι → α)} {d : ℕ} (hd : ↑d ≤ minDist ↑C) (hd0 : 0 < d) (h : Fintype.card α * d = (Fintype.card α - 1) * Fintype.card ι) :

The Plotkin bound at relative distance 1 - 1 / q. A code of length n and minimum distance at least d > 0 over q letters with q d = (q - 1) n has at most q n codewords. Shortening one coordinate and applying the Plotkin bound gives this; it sharpens the bound 2 q n of [GuruswamiRudraSudan2019, Theorem 4.4.1, part 1] and, for q ≥ 3, the bound 2 (q - 1) n of its Exercise 4.13.

theorem Cslib.Code.card_le_two_mul_of_le_minDist_of_card_eq {ι : Type u_1} [Fintype ι] {C : Finset (ι → Bool)} {d : ℕ} (hd : ↑d ≤ minDist ↑C) (hd0 : 0 < d) (hn : Fintype.card ι = 2 * d) :

The binary Plotkin bound at relative distance one half. A binary code of length n = 2 d and minimum distance at least d > 0 has at most 2 n codewords; the Hadamard code together with its complements attains this [GuruswamiRudraSudan2019, Exercise 4.14].