Documentation

CslibFrontier.Probability.BitString.BinarySymmetricChannel

The binary symmetric channel #

The binary symmetric channel BSC_p with crossover probability p ∈ [0, 1] flips every bit of its input independently with probability p [Guruswami, Rudra and Sudan, Section 6.2] [GRS19]; it is the symmetric channel on two symbols of Shannon, Section 16, of capacity 1 - h₂(p) bits per use. Here it is the probability mass function Cslib.BitString.bsc p x on received words y : ι → Bool, the translate by x of the noise Cslib.BitString.bscNoise p, an independent product (Cslib.Probability.PMF.pi) of coins Cslib.Probability.PMF.coin p showing true with probability p. It delivers y with probability p ^ d (1 - p) ^ (n - d), where d is the Hamming distance of x and y (Cslib.BitString.bsc_apply_toReal); the noise has the law of a random mask of rate p (Cslib.BitString.bscNoise_apply_toReal), so its weight is binomially distributed and exceeds r ≥ n p - 1 with probability at most exp (-2 (r + 1 - n p) ^ 2 / n) by Hoeffding's inequality (Cslib.BitString.bscNoise_toOuterMeasure_lt_weight_toReal_le).

A code with message set M is an encoder E : M → (ι → Bool) with a decoder D : (ι → Bool) → M, and Cslib.BitString.decodingError p E D m is the probability that D fails to recover m from the channel output on E m. A decoder is a nearest-codeword decoder (Cslib.BitString.IsNearestDecoder) if it always returns a message whose codeword is closest to the received word; such decoders exist for every finite nonempty message set, and for p ≤ 1 / 2 they are maximum-likelihood decoders (Cslib.BitString.bsc_apply_toReal_le_of_isNearestDecoder). Achievability of the capacity 1 - h₂(p) by random codes is in CslibFrontier.Probability.BitString.BinarySymmetricChannel.Achievability.

Main definitions #

Main results #

References #

The channel #

noncomputable def Cslib.BitString.bscNoise {ι : Type u_1} [Fintype ι] (p : ↑unitInterval) :
PMF (ι → Bool)

The noise of the binary symmetric channel: every coordinate is flipped independently with probability p.

The noise of BSC_p is the product of independent coins of bias p, one per coordinate.

theorem Cslib.BitString.bscNoise_apply_toReal {ι : Type u_1} [Fintype ι] (p : ↑unitInterval) (e : ι → Bool) :
((bscNoise p) e).toReal = bernoulliWeight (↑p) e

The noise of BSC_p has the law of a random mask of rate p.

noncomputable def Cslib.BitString.bsc {ι : Type u_1} [Fintype ι] (p : ↑unitInterval) (x : ι → Bool) :
PMF (ι → Bool)

The binary symmetric channel BSC_p on words ι → Bool: on input x it delivers x + e, where the noise e flips every bit independently with probability p.

theorem Cslib.BitString.bsc_eq_map {ι : Type u_1} [Fintype ι] (p : ↑unitInterval) (x : ι → Bool) :
bsc p x = PMF.map (fun (x_1 : ι → Bool) => x + x_1) (bscNoise p)

BSC_p delivers the input plus the noise.

theorem Cslib.BitString.bsc_apply {ι : Type u_1} [Fintype ι] (p : ↑unitInterval) (x y : ι → Bool) :
(bsc p x) y = (bscNoise p) (x + y)
theorem Cslib.BitString.bsc_apply_toReal {ι : Type u_1} [Fintype ι] (p : ↑unitInterval) (x y : ι → Bool) :
((bsc p x) y).toReal = ↑p ^ hammingDist x y * (1 - ↑p) ^ (Fintype.card ι - hammingDist x y)

The channel delivers y on input x with probability p ^ d (1 - p) ^ (n - d), where d is the Hamming distance of x and y.

theorem Cslib.BitString.bsc_apply_toReal_anti {ι : Type u_1} [Fintype ι] (p : ↑unitInterval) (hp : ↑p ≤ 1 / 2) {x x' y : ι → Bool} (h : hammingDist x y ≤ hammingDist x' y) :
((bsc p x') y).toReal ≤ ((bsc p x) y).toReal

The likelihood p ^ d (1 - p) ^ (n - d) of BSC_p decreases with the distance d when p ≤ 1 / 2.

theorem Cslib.BitString.bscNoise_toOuterMeasure_lt_weight_toReal {ι : Type u_1} [Fintype ι] (p : ↑unitInterval) (r : ℕ) :
((bscNoise p).toOuterMeasure {e : ι → Bool | r < weight e}).toReal = ∑ k ∈ Finset.range (Fintype.card ι + 1) with r < k, ↑((Fintype.card ι).choose k) * ↑p ^ k * (1 - ↑p) ^ (Fintype.card ι - k)

The number of bits flipped by BSC_p is binomially distributed: more than r of the n bits flip with probability ∑_{r < k ≤ n} C(n, k) p ^ k (1 - p) ^ (n - k).

theorem Cslib.BitString.bscNoise_toOuterMeasure_lt_weight_toReal_le {ι : Type u_1} [Fintype ι] (p : ↑unitInterval) {r : ℕ} (hr : ↑(Fintype.card ι) * ↑p ≤ ↑r + 1) :
((bscNoise p).toOuterMeasure {e : ι → Bool | r < weight e}).toReal ≤ Real.exp (-2 * (↑r + 1 - ↑(Fintype.card ι) * ↑p) ^ 2 / ↑(Fintype.card ι))

Hoeffding's bound on the number of flipped bits: if n p ≤ r + 1, more than r of the n bits flip with probability at most exp (-2 (r + 1 - n p) ^ 2 / n).

Codes, decoders and their errors #

noncomputable def Cslib.BitString.decodingError {ι : Type u_1} [Fintype ι] {M : Type u_2} (p : ↑unitInterval) (E : M → ι → Bool) (D : (ι → Bool) → M) (m : M) :

The probability that the decoder D fails to recover the message m when its codeword E m is sent through BSC_p.

theorem Cslib.BitString.decodingError_def {ι : Type u_1} [Fintype ι] {M : Type u_2} (p : ↑unitInterval) (E : M → ι → Bool) (D : (ι → Bool) → M) (m : M) :
decodingError p E D m = ((bsc p (E m)).toOuterMeasure {y : ι → Bool | D y ≠ m}).toReal

The error probability is the probability, under the channel output on E m, that D does not return m.

theorem Cslib.BitString.bsc_apply_toReal_le_of_isNearestDecoder {ι : Type u_1} [Fintype ι] {M : Type u_2} {E : M → ι → Bool} {D : (ι → Bool) → M} (hD : IsNearestDecoder E D) (p : ↑unitInterval) (hp : ↑p ≤ 1 / 2) (y : ι → Bool) (m : M) :
((bsc p (E m)) y).toReal ≤ ((bsc p (E (D y))) y).toReal

Nearest-codeword decoding is maximum-likelihood decoding on BSC_p for p ≤ 1 / 2: the decoded codeword is at least as likely to produce the received word as any other codeword.

theorem Cslib.BitString.decodingError_eq_bernoulliAverage {ι : Type u_1} [Fintype ι] {M : Type u_2} [DecidableEq ι] [DecidableEq M] (p : ↑unitInterval) (E : M → ι → Bool) (D : (ι → Bool) → M) (m : M) :
decodingError p E D m = bernoulliAverage ↑p fun (e : ι → Bool) => if D (E m + e) ≠ m then 1 else 0

The error probability of a code at m is the probability, over the noise e of BSC_p, that D does not decode E m + e to m.

theorem Cslib.BitString.decodingError_nonneg {ι : Type u_1} [Fintype ι] {M : Type u_2} (p : ↑unitInterval) (E : M → ι → Bool) (D : (ι → Bool) → M) (m : M) :
0 ≤ decodingError p E D m

Error probabilities are nonnegative.

theorem Cslib.BitString.decodingError_le_one {ι : Type u_1} [Fintype ι] {M : Type u_2} (p : ↑unitInterval) (E : M → ι → Bool) (D : (ι → Bool) → M) (m : M) :
decodingError p E D m ≤ 1

Error probabilities are at most one.

theorem Cslib.BitString.decodingError_symm {ι : Type u_1} [Fintype ι] {M : Type u_2} (p : ↑unitInterval) (E : M → ι → Bool) (D : (ι → Bool) → M) (m : M) :
decodingError (unitInterval.symm p) E (fun (y : ι → Bool) => D fun (i : ι) => !y i) m = decodingError p E D m

Flipping every received bit turns BSC_p into BSC_{1 - p}: a decoder D errs on BSC_p exactly as often as the decoder that first complements the received word errs on BSC_{1 - p}.

theorem Cslib.BitString.decodingError_zero_eq_zero {ι : Type u_1} [Fintype ι] {M : Type u_2} {E : M → ι → Bool} {D : (ι → Bool) → M} (hDE : Function.LeftInverse D E) (m : M) :
decodingError 0 E D m = 0

Over the noiseless channel BSC_0, a decoder that inverts the encoder never errs.