Documentation

CslibFrontier.Foundations.Data.Code.ExpanderCode

Expander codes: rate and distance #

The expander code of a bipartite graph G : ι → κ → Prop [SS96] has a bit for every left vertex (variable) and a parity check for every right vertex (check). A word x : ι → Bool is a codeword when every check sees an even number of ones among its neighbours, i.e. when it lies in the kernel of the 0/1 incidence matrix (Cslib.BitString.ExpanderCode.checkMatrix). This is the code C(G) of [GuruswamiRudraSudan2025, Definition 11.3.1], a binary linear code given as a Submodule Bool (ι → Bool); when G has small degrees it is a low-density parity-check code.

The source states these for c-left-regular graphs with k = γ n; here left degrees need only be at most c (Cslib.Bipartite.IsLeftBounded) and k is any natural number. Flip decoding is in CslibFrontier.Foundations.Data.Code.FlipDecoding.

Main definitions #

Main results #

References #

def Cslib.BitString.ExpanderCode.checkMatrix {ι : Type u_1} {κ : Type u_2} (G : ι → κ → Prop) [(i : ι) → (j : κ) → Decidable (G i j)] :
Matrix κ ι Bool

The check matrix of a bipartite graph: entry (j, i) is true iff variable i is adjacent to check j.

def Cslib.BitString.ExpanderCode.code {ι : Type u_1} {κ : Type u_2} [Fintype ι] (G : ι → κ → Prop) [(i : ι) → (j : κ) → Decidable (G i j)] :

The expander code of a bipartite graph [SS96] [GuruswamiRudraSudan2025, Definition 11.3.1]: the words on which every check, the sum of the bits of its neighbours, vanishes.

def Cslib.BitString.ExpanderCode.syndrome {ι : Type u_1} {κ : Type u_2} [Fintype ι] (G : ι → κ → Prop) [(i : ι) → (j : κ) → Decidable (G i j)] (x : ι → Bool) :
κ → Bool

The syndrome of a word: the value of every check.

def Cslib.BitString.ExpanderCode.unsat {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] (G : ι → κ → Prop) [(i : ι) → (j : κ) → Decidable (G i j)] (x : ι → Bool) :

The checks violated by a word.

theorem Cslib.BitString.ExpanderCode.syndrome_apply {ι : Type u_1} {κ : Type u_2} [Fintype ι] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] (x : ι → Bool) (j : κ) :
syndrome G x j = parityOn {i : ι | G i j} x

Check j is the parity of the bits of its neighbours.

theorem Cslib.BitString.ExpanderCode.mem_code {ι : Type u_1} {κ : Type u_2} [Fintype ι] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {x : ι → Bool} :
x ∈ code G ↔ syndrome G x = 0
theorem Cslib.BitString.ExpanderCode.syndrome_add {ι : Type u_1} {κ : Type u_2} [Fintype ι] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] (x y : ι → Bool) :
syndrome G (x + y) = syndrome G x + syndrome G y
theorem Cslib.BitString.ExpanderCode.syndrome_add_of_mem {ι : Type u_1} {κ : Type u_2} [Fintype ι] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {x w : ι → Bool} (hw : w ∈ code G) :
syndrome G (x + w) = syndrome G x

Adding a codeword does not change the syndrome.

theorem Cslib.BitString.ExpanderCode.mem_code_iff_unsat_eq_empty {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {x : ι → Bool} :
x ∈ code G ↔ unsat G x = ∅

A word is a codeword iff it violates no check.

theorem Cslib.BitString.ExpanderCode.mem_unsat_iff {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {y w : ι → Bool} (hw : w ∈ code G) {j : κ} :
j ∈ unsat G y ↔ Odd (Finset.bipartiteBelow G {i : ι | y i ≠ w i} j).card

A check is violated by y iff it sees an odd number of errors, the positions where y differs from a codeword w.

theorem Cslib.BitString.ExpanderCode.uniqueNeighbors_subset_unsat {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {y w : ι → Bool} (hw : w ∈ code G) :
Bipartite.uniqueNeighbors G {i : ι | y i ≠ w i} ⊆ unsat G y

The unique neighbours of the errors are violated checks.

theorem Cslib.BitString.ExpanderCode.unsat_subset_neighbors {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {y w : ι → Bool} (hw : w ∈ code G) :
unsat G y ⊆ Bipartite.neighbors G {i : ι | y i ≠ w i}

Violated checks are neighbours of the errors.

theorem Cslib.BitString.ExpanderCode.card_unsat_le {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {c : ℕ} (hG : Bipartite.IsLeftBounded G c) {y w : ι → Bool} (hw : w ∈ code G) :
(unsat G y).card ≤ c * hammingDist y w

If left degrees are at most c, a word at distance e from a codeword violates at most c e checks.

Rate #

theorem Cslib.BitString.ExpanderCode.two_pow_card_le {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] :

2 ^ n ≤ |C(G)| · 2 ^ m: the code is the kernel of a linear map into 2 ^ m words.

theorem Cslib.BitString.ExpanderCode.two_pow_sub_le_card_code {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] :

Rate [GuruswamiRudraSudan2025, proof of Theorem 11.3.6] [GuruswamiSharma2010, §1]: with n variables and m checks the code, the solution space of m homogeneous linear equations, has dimension at least n - m, i.e. at least 2 ^ (n - m) codewords.

theorem Cslib.BitString.ExpanderCode.one_sub_card_div_card_le_rate {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] (hι : 0 < Fintype.card ι) :
1 - ↑(Fintype.card κ) / ↑(Fintype.card ι) ≤ Real.logb 2 ↑(Nat.card ↥(code G)) / ↑(Fintype.card ι)

Rate in real form: log₂ |C(G)| / n ≥ 1 - m / n.

theorem Cslib.BitString.ExpanderCode.one_sub_div_le_rate_of_isBiregular {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {c d : ℕ} (hG : Bipartite.IsBiregular G c d) (hd : 0 < d) (hι : 0 < Fintype.card ι) :
1 - ↑c / ↑d ≤ Real.logb 2 ↑(Nat.card ↥(code G)) / ↑(Fintype.card ι)

Rate of a biregular expander code: if G is (c, d)-biregular, the rate log₂ |C(G)| / n is at least 1 - c / d.

Distance #

theorem Cslib.BitString.ExpanderCode.uniqueNeighbors_eq_empty {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {x w : ι → Bool} (hx : x ∈ code G) (hw : w ∈ code G) :
Bipartite.uniqueNeighbors G {i : ι | x i ≠ w i} = ∅

The set where two codewords differ has no unique neighbour.

theorem Cslib.BitString.ExpanderCode.lt_hammingDist {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {c k : ℕ} {α : ℝ} (hG : Bipartite.IsLeftBounded G c) (hE : Bipartite.IsVertexExpander G k α) (hα : ↑c < 2 * α) {x w : ι → Bool} (hx : x ∈ code G) (hw : w ∈ code G) (hxw : x ≠ w) :

Distance of expander codes [GuruswamiRudraSudan2025, Theorem 11.3.6]. If left degrees are at most c and sets of at most k variables expand by a factor α > c / 2, distinct codewords differ in more than k positions.

theorem Cslib.BitString.ExpanderCode.lt_minDist {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {c k : ℕ} {α : ℝ} (hG : Bipartite.IsLeftBounded G c) (hE : Bipartite.IsVertexExpander G k α) (hα : ↑c < 2 * α) :
↑k < Code.minDist ↑(code G)

The minimum distance of the expander code exceeds k.

theorem Cslib.BitString.ExpanderCode.two_mul_mul_le_hammingDist {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {c k : ℕ} {α : ℝ} (hG : Bipartite.IsLeftBounded G c) (hE : Bipartite.IsVertexExpander G k α) (hα : ↑c < 2 * α) {x w : ι → Bool} (hx : x ∈ code G) (hw : w ∈ code G) (hxw : x ≠ w) :
2 * α * ↑k ≤ ↑c * ↑(hammingDist x w)

Improved distance of expander codes [GuruswamiRudraSudan2025, Theorem 11.3.8] [GuruswamiSharma2010, Theorem 4]. Under the hypotheses of lt_hammingDist, distinct codewords satisfy 2 α k ≤ c · d(x, w). With α = c (1 - ε) and k = γ n this is the source's distance bound 2 γ (1 - ε) n.