Documentation

CslibFrontier.Probability.SmallBias.Code

Small-bias sample spaces and balanced linear codes #

A sample space G : σ → ι → Bool (for a generator, σ is the set of seeds and G s the output on the seed s) has a binary linear code Cslib.BitString.sampleCode G, which encodes a message v : ι → Bool as the word s ↦ v ⬝ᵥ G s indexed by the seeds. Bit s of the codeword of the i-th unit vector is bit i of G s (Cslib.BitString.sampleCode_single), and every Bool-linear map (ι → Bool) → (σ → Bool) is the code of exactly one sample space (Cslib.BitString.sampleCode_injective, Cslib.BitString.sampleCode_ofCode).

The distance between the codewords of u ≠ v is the number of seeds at which the parity on the nonempty set {i | u i ≠ v i} is odd, and the bias of G on that set is one minus twice its fraction. So G, with a uniform seed, is ε-biased exactly when the codewords of every two distinct messages are at distance between (1 - ε) |σ| / 2 and (1 + ε) |σ| / 2 (Cslib.BitString.isSmallBias_map_iff_hammingDist_sampleCode). With the seeds σ = {0,1}^k and messages of ℓ bits, this is the correspondence of Goldreich, Exercise 8.41 between ε-bias generators of stretch ℓ and binary linear codes from ℓ-bit strings to 2^k-bit strings whose codewords are pairwise at distance (1 ± ε) 2^(k-1).

Main definitions #

Main results #

References #

def Cslib.BitString.sampleCode {σ : Type u_1} {ι : Type u_2} [Fintype ι] (G : σ → ι → Bool) :
(ι → Bool) →ₗ[Bool] σ → Bool

The binary linear code of a sample space G: the message v is encoded as the word whose bit at the seed s is the parity v ⬝ᵥ G s.

@[simp]
theorem Cslib.BitString.sampleCode_apply {σ : Type u_1} {ι : Type u_2} [Fintype ι] (G : σ → ι → Bool) (v : ι → Bool) (s : σ) :
(sampleCode G) v s = v ⬝ᵥ G s
theorem Cslib.BitString.sampleCode_single {σ : Type u_1} {ι : Type u_2} [Fintype ι] [DecidableEq ι] (G : σ → ι → Bool) (i : ι) (s : σ) :
(sampleCode G) (Pi.single i true) s = G s i

Bit s of the codeword of the i-th unit vector is bit i of the sample G s Goldreich, guideline to Exercise 8.41.

theorem Cslib.BitString.sampleCode_ofCode {σ : Type u_1} {ι : Type u_2} [Fintype ι] [DecidableEq ι] (C : (ι → Bool) →ₗ[Bool] σ → Bool) :
(sampleCode fun (s : σ) (i : ι) => C (Pi.single i true) s) = C

Every binary linear code is the code of a sample space: the one whose sample at s lists the bits at s of the codewords of the unit vectors.

Distinct sample spaces have distinct codes.

theorem Cslib.BitString.hammingDist_sampleCode {σ : Type u_1} {ι : Type u_2} [Fintype ι] [Fintype σ] (G : σ → ι → Bool) (u v : ι → Bool) :
hammingDist ((sampleCode G) u) ((sampleCode G) v) = {s : σ | (u + v) ⬝ᵥ G s = true}.card

The codewords of u and v differ exactly at the seeds where the parity of u + v is odd.

theorem Cslib.BitString.isSmallBias_map_iff_hammingDist_sampleCode {σ : Type u_1} {ι : Type u_2} [Fintype ι] [Fintype σ] [Nonempty σ] [DecidableEq ι] (G : σ → ι → Bool) {ε : ℝ} :
IsSmallBias ε (PMF.map G (Probability.PMF.uniformOfFintype σ)) ↔ ∀ (u v : ι → Bool), u ≠ v → (1 - ε) * ↑(Fintype.card σ) / 2 ≤ ↑(hammingDist ((sampleCode G) u) ((sampleCode G) v)) ∧ ↑(hammingDist ((sampleCode G) u) ((sampleCode G) v)) ≤ (1 + ε) * ↑(Fintype.card σ) / 2

Small-bias generators are balanced linear codes Goldreich, Exercise 8.41: a sample space G, with a uniform seed, is ε-biased exactly when the codewords of any two distinct messages under its linear code sampleCode G are at Hamming distance between (1 - ε) |σ| / 2 and (1 + ε) |σ| / 2. For σ = {0,1}^k these bounds are (1 ± ε) 2^(k-1).