Documentation

CslibFrontier.Foundations.Data.Code.FlipDecoding

Flip decoding of expander codes #

The flip decoder of Sipser and Spielman [SS96] corrects errors in the expander code of a bipartite graph G (Cslib.BitString.ExpanderCode.code) by local moves. While some variable has more violated than satisfied checks among its neighbours (Cslib.BitString.ExpanderCode.IsFlippable), flip it. This is the algorithm of [GuruswamiSharma2010, §1.1], and the procedure GEN-FLIP of [GuruswamiRudraSudan2025, §18.2.2, Algorithm 18.2.1] with exact check bits.

For a lossless expander, α = c (1 - ε) with ε < 1 / 4 and k = γ n, the hypothesis c · d(x, w) < (2 α - c) k reads d(x, w) < (1 - 2 ε) γ n, as in [GuruswamiSharma2010, §1.1.1]. The source assumes c-left-regularity; we only need left degrees at most c. The number of rounds is counted abstractly: we do not formalize the O(n) data-structure implementation of [GuruswamiSharma2010, §1.1.2] on a machine model.

Main definitions #

Main results #

References #

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

Variable i is flippable in x: it has more violated than satisfied neighbouring checks.

Instances For
    @[instance_reducible]
    instance Cslib.BitString.ExpanderCode.instDecidableIsFlippable {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] (x : ι → Bool) (i : ι) :
    theorem Cslib.BitString.ExpanderCode.exists_isFlippable {ι : 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α : 3 * ↑c < 4 * α) {y w : ι → Bool} (hw : w ∈ code G) (hyw : y ≠ w) (hk : hammingDist y w ≤ k) :
    ∃ (i : ι), IsFlippable G y i

    Progress [GuruswamiSharma2010, Lemma 5]. If left degrees are at most c, sets of at most k variables expand by α with 3 c < 4 α, and y ≠ w is within distance k of a codeword w, some variable is flippable in y.

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

    A pivot rule for the flip decoder: it returns only flippable variables, and returns none only when no variable is flippable.

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

    The pivot rule that returns the first flippable variable of a list.

    theorem Cslib.BitString.ExpanderCode.isFlipRule_firstFlippable {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] {l : List ι} (hl : ∀ (i : ι), i ∈ l) :

    Taking the first flippable variable of a list of all variables is a pivot rule.

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

    One move of the flip decoder: flip a flippable variable.

    theorem Cslib.BitString.flipOn_eq_add {ι : Type u_1} [DecidableEq ι] (T : Finset ι) (x : ι → Bool) :
    flipOn T x = x + fun (l : ι) => decide (l ∈ T)

    Flipping the bits at T adds the indicator of T.

    theorem Cslib.BitString.flipOn_singleton_eq_add_single {ι : Type u_1} [DecidableEq ι] (x : ι → Bool) (i : ι) :

    Flipping one bit adds the corresponding unit vector.

    theorem Cslib.BitString.ExpanderCode.syndrome_flipOn {ι : Type u_1} {κ : Type u_2} [Fintype ι] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] (x : ι → Bool) (i : ι) (j : κ) :
    syndrome G (flipOn {i} x) j = (syndrome G x j ^^ decide (G i j))

    Flipping variable i toggles exactly the checks adjacent to i.

    theorem Cslib.BitString.ExpanderCode.card_unsat_flipOn_add {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] (x : ι → Bool) (i : ι) :
    (unsat G (flipOn {i} x)).card + {j : κ | G i j ∧ syndrome G x j = true}.card = (unsat G x).card + {j : κ | G i j ∧ syndrome G x j = false}.card

    Flipping variable i exchanges its violated and satisfied neighbouring checks.

    theorem Cslib.BitString.ExpanderCode.card_unsat_flipOn_lt {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] {x : ι → Bool} {i : ι} (h : IsFlippable G x i) :
    (unsat G (flipOn {i} x)).card < (unsat G x).card

    Flipping a flippable variable decreases the number of violated checks.

    theorem Cslib.BitString.ExpanderCode.FlipStep.card_unsat_lt {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] {x y : ι → Bool} (h : FlipStep G x y) :
    (unsat G y).card < (unsat G x).card

    A move of the flip decoder decreases the number of violated checks.

    theorem Cslib.BitString.ExpanderCode.add_card_unsat_le_of_relatesInSteps {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] {x y : ι → Bool} {t : ℕ} (h : Relation.RelatesInSteps (FlipStep G) x y t) :
    t + (unsat G y).card ≤ (unsat G x).card

    Number of flips: a run of t moves from x to y has t + #unsat(y) ≤ #unsat(x). In particular the flip decoder stops after at most #unsat(x) ≤ c · d(x, w) moves (card_unsat_le), and at most the number of checks.

    theorem Cslib.BitString.ExpanderCode.hammingDist_lt_and_card_unsat_le {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] {c k : ℕ} {α : ℝ} (hG : Bipartite.IsLeftBounded G c) (hE : Bipartite.IsVertexExpander G k α) {x w : ι → Bool} (hw : w ∈ code G) (hx : ↑c * ↑(hammingDist x w) < (2 * α - ↑c) * ↑k) {y : ι → Bool} (hy : Relation.ReflTransGen (FlipStep G) x y) :
    hammingDist y w < k ∧ (unsat G y).card ≤ (unsat G x).card

    Invariant [GuruswamiSharma2010, Lemma 6]. If c · d(x, w) < (2 α - c) k, every word reached from x by moves of the flip decoder is at distance less than k from the codeword w and violates at most as many checks as x.

    theorem Cslib.BitString.ExpanderCode.eq_of_flip_stuck {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] {c k : ℕ} {α : ℝ} (hG : Bipartite.IsLeftBounded G c) (hE : Bipartite.IsVertexExpander G k α) (hα : 3 * ↑c < 4 * α) {x w : ι → Bool} (hw : w ∈ code G) (hx : ↑c * ↑(hammingDist x w) < (2 * α - ↑c) * ↑k) {y : ι → Bool} (hy : Relation.ReflTransGen (FlipStep G) x y) (hstuck : ∀ (i : ι), ¬IsFlippable G y i) :
    y = w

    Correctness of flip decoding [GuruswamiSharma2010, §1.1.1]. Under the hypotheses of exists_isFlippable and hammingDist_lt_and_card_unsat_le, a word reached from x in which no variable is flippable is the codeword w.

    def Cslib.BitString.ExpanderCode.decode {ι : Type u_1} [DecidableEq ι] (pick : (ι → Bool) → Option ι) :
    ℕ → (ι → Bool) → ι → Bool

    The flip decoder with pivot rule pick, run for at most n rounds: it flips the variable returned by pick and stops when pick returns none.

    theorem Cslib.BitString.ExpanderCode.decode_eq_of_reflTransGen {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] {c k : ℕ} {α : ℝ} (hG : Bipartite.IsLeftBounded G c) (hE : Bipartite.IsVertexExpander G k α) (hα : 3 * ↑c < 4 * α) {x w : ι → Bool} (hw : w ∈ code G) (hx : ↑c * ↑(hammingDist x w) < (2 * α - ↑c) * ↑k) {pick : (ι → Bool) → Option ι} (hpick : IsFlipRule G pick) (n : ℕ) (y : ι → Bool) :
    Relation.ReflTransGen (FlipStep G) x y → (unsat G y).card ≤ n → decode pick n y = w

    decode_eq for every word reached from x.

    theorem Cslib.BitString.ExpanderCode.decode_eq {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] {c k : ℕ} {α : ℝ} (hG : Bipartite.IsLeftBounded G c) (hE : Bipartite.IsVertexExpander G k α) (hα : 3 * ↑c < 4 * α) {x w : ι → Bool} (hw : w ∈ code G) (hx : ↑c * ↑(hammingDist x w) < (2 * α - ↑c) * ↑k) {pick : (ι → Bool) → Option ι} (hpick : IsFlipRule G pick) {n : ℕ} (hn : (unsat G x).card ≤ n) :
    decode pick n x = w

    Flip decoding [SS96] [GuruswamiSharma2010, §1.1]. If left degrees are at most c, sets of at most k variables expand by α with 3 c < 4 α, w is a codeword and c · d(x, w) < (2 α - c) k, then the flip decoder with any pivot rule, run for any number n ≥ #unsat(x) of rounds, returns w. Since #unsat(x) ≤ c · d(x, w) (card_unsat_le), n = c · d(x, w) rounds suffice.

    theorem Cslib.BitString.ExpanderCode.decode_eq_of_two_mul_le {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] {G : ι → κ → Prop} [(i : ι) → (j : κ) → Decidable (G i j)] [DecidableEq ι] {c k : ℕ} {α : ℝ} (hG : Bipartite.IsLeftBounded G c) (hE : Bipartite.IsVertexExpander G k α) (hα : 3 * ↑c < 4 * α) (hk : 0 < k) {x w : ι → Bool} (hw : w ∈ code G) (hx : 2 * hammingDist x w ≤ k) {pick : (ι → Bool) → Option ι} (hpick : IsFlipRule G pick) :
    decode pick (c * hammingDist x w) x = w

    Flip decoding up to half the expansion radius. If left degrees are at most c, sets of at most k > 0 variables expand by α with 3 c < 4 α (ε < 1 / 4 for α = c (1 - ε)), and x differs from the codeword w in at most k / 2 positions, then the flip decoder with any pivot rule recovers w within c · d(x, w) rounds.