Documentation

Complexity.Foundations.Data.BitString.CoverCoding

Cover's enumerative coding for weight-bounded Boolean words #

Cover's lexicographic rank (Cslib.BitString.coverRank) and greedy threshold decoder (Cslib.BitString.coverDecode) establish an explicit bijection between words z : Fin q → Bool of Hamming weight at most e and indices below the Hamming-ball size B(q, e) = ∑ j ∈ range (e + 1), q.choose j (Cslib.BitString.ballSize).

Main definitions #

Main results #

References #

Size B(q, e) = ∑ j ∈ range (e + 1), q.choose j of the Hamming ball of radius e in {0, 1}^q.

Instances For
    @[simp]

    The Hamming ball of any radius in the cube of dimension 0 has one point.

    @[simp]

    The Hamming ball of radius 0 has one point.

    Hamming balls are nonempty: 0 < ballSize q e.

    theorem Cslib.BitString.ballSize_succ_succ (q e : ℕ) :
    ballSize (q + 1) (e + 1) = ballSize q (e + 1) + ballSize q e

    Pascal recurrence B(q + 1, e + 1) = B(q, e + 1) + B(q, e) for Hamming-ball sizes.

    The number of words z : Fin q → Bool of weight at most e equals ballSize q e.

    def Cslib.BitString.coverRank {q : ℕ} :
    ℕ → (Fin q → Bool) → ℕ

    Cover's lexicographic rank of a word z : Fin q → Bool among words of weight at most e.

    Instances For

      Cover's greedy threshold decoder recovering a word z : Fin q → Bool of weight at most e from its rank t < ballSize q e.

      Instances For
        theorem Cslib.BitString.weight_cons_succ {q : ℕ} (z : Fin (q + 1) → Bool) :
        weight z = (z 0).toNat + weight fun (i : Fin q) => z i.succ

        Splitting off the first bit of a word z : Fin (q + 1) → Bool in its Hamming weight.

        theorem Cslib.BitString.coverRank_lt_ballSize {q : ℕ} (e : ℕ) (z : Fin q → Bool) (hz : weight z ≤ e) :

        Every word z : Fin q → Bool of weight at most e has coverRank e z < ballSize q e.

        Every decoded word coverDecode q e t has Hamming weight at most e.

        @[simp]
        theorem Cslib.BitString.coverRank_coverDecode {q e t : ℕ} (ht : t < ballSize q e) :
        coverRank e (coverDecode q e t) = t

        Ranking a decoded word coverDecode q e t for t < ballSize q e recovers t.

        @[simp]
        theorem Cslib.BitString.coverDecode_coverRank {q e : ℕ} (z : Fin q → Bool) (hz : weight z ≤ e) :
        coverDecode q e (coverRank e z) = z

        Decoding the rank coverRank e z of a word z : Fin q → Bool with weight z ≤ e recovers z.