Documentation

CslibFrontier.Crypto.Computational.GoldreichLevin.Nonuniform

Nonuniform Goldreich–Levin decoding #

Goldreich–Levin decoding [GL89] recovers a string x from a predictor for its parities x ⬝ r with agreement 1 / 2 + ε, with probability at least 1 / 2 over random masks and for one of 2 ^ k guesses (Cslib.Crypto.GoldreichLevin.decode_failure_le_half). This module turns that into a statement about fixed choices, as needed for nonuniform reconstruction: for a family of predictors pred x with targets target x, if a set good of indices has agreement at least 1 / 2 + ε, then one fixed choice of masks and of the guess makes the corrected-majority candidate equal to the target for at least #good / 2 ^ (k + 1) of the indices (Cslib.Crypto.GoldreichLevin.exists_card_candidate_eq). The proof averages the success probability over the masks and over a uniformly random guess (Cslib.Crypto.GoldreichLevin.card_mul_le_two_mul_sum_card_candidate_eq).

The same sum gives a density form: a #good / (2 ^ (k + 2) * #X) fraction of the choices of masks and guess each recover a 1 / 2 ^ (k + 2) fraction of the good targets (Cslib.Crypto.GoldreichLevin.dens_filter_candidate_eq_ge). Reverse averaging also finds the good indices: if the predictors agree with the parities on a 1 / 2 + ε fraction of all pairs, then an ε / 2 fraction of the indices have agreement 1 / 2 + ε / 2 (Cslib.Crypto.GoldreichLevin.dens_filter_agreement_ge). Both use Fintype.expect_sub_le_dens_filter.

Main results #

References #

theorem Cslib.Crypto.GoldreichLevin.agreement_eq_card_div {n : ℕ} (predictor : BitString n → Bool) (x : BitString n) :
agreement predictor x = ↑{r : BitString n | predictor r = x ⬝ᵥ r}.card / 2 ^ n

Agreement as a count: the fraction of queries on which the predictor is right.

theorem Cslib.Crypto.GoldreichLevin.card_le_two_mul_card_filter_mem_candidates {n k : ℕ} (predictor : BitString n → Bool) (x : BitString n) (ε : ℝ) (hε : 0 < ε) (hk : 0 < k) (h : 1 / 2 + ε ≤ agreement predictor x) (hsize : ↑n ≤ 2 * ε ^ 2 * ↑(2 ^ k - 1)) :
Fintype.card (Fin k → BitString n) ≤ 2 * {masks : Fin k → BitString n | x ∈ candidates predictor masks}.card

The decoding guarantee in counting form. If a predictor agrees with the parities of x on a 1 / 2 + ε fraction of queries and n ≤ 2 * ε ^ 2 * (2 ^ k - 1), then x is a candidate for at least half of the choices of the k masks.

theorem Cslib.Crypto.GoldreichLevin.card_mul_le_two_mul_sum_card_candidate_eq {n k : ℕ} {X : Type u_1} [Fintype X] (pred : X → BitString n → Bool) (target : X → BitString n) (ε : ℝ) (hε : 0 < ε) (hk : 0 < k) (hsize : ↑n ≤ 2 * ε ^ 2 * ↑(2 ^ k - 1)) (good : Finset X) (hgood : ∀ x ∈ good, 1 / 2 + ε ≤ agreement (pred x) (target x)) :
good.card * Fintype.card (Fin k → BitString n) ≤ 2 * ∑ mg : (Fin k → BitString n) × BitString k, {x : X | candidate (pred x) mg.1 mg.2 = target x}.card

The Goldreich–Levin count, summed over masks and guesses. Let pred x be predictors for the parities of target x, and let every index of good have agreement at least 1 / 2 + ε, with n ≤ 2 * ε ^ 2 * (2 ^ k - 1) and k ≥ 1. Summed over all masks and guesses, the number of indices whose corrected-majority candidate equals the target is at least half of #good times the number of masks.

theorem Cslib.Crypto.GoldreichLevin.exists_card_candidate_eq {n k : ℕ} {X : Type u_1} [Fintype X] (pred : X → BitString n → Bool) (target : X → BitString n) (ε : ℝ) (hε : 0 < ε) (hk : 0 < k) (hsize : ↑n ≤ 2 * ε ^ 2 * ↑(2 ^ k - 1)) (good : Finset X) (hgood : ∀ x ∈ good, 1 / 2 + ε ≤ agreement (pred x) (target x)) :
∃ (masks : Fin k → BitString n) (guess : BitString k), good.card ≤ 2 ^ (k + 1) * {x : X | candidate (pred x) masks guess = target x}.card

Nonuniform Goldreich–Levin decoding. Let pred x be predictors for the parities of target x, indexed by a finite type, and let every index of good have agreement at least 1 / 2 + ε, with n ≤ 2 * ε ^ 2 * (2 ^ k - 1) and k ≥ 1. Then for some fixed masks and guess the corrected-majority candidate equals the target for at least #good / 2 ^ (k + 1) indices.

theorem Cslib.Crypto.GoldreichLevin.dens_filter_candidate_eq_ge {n k : ℕ} {X : Type u_1} [Fintype X] [Nonempty X] (pred : X → BitString n → Bool) (target : X → BitString n) (ε : ℝ) (hε : 0 < ε) (hk : 0 < k) (hsize : ↑n ≤ 2 * ε ^ 2 * ↑(2 ^ k - 1)) (good : Finset X) (hgood : ∀ x ∈ good, 1 / 2 + ε ≤ agreement (pred x) (target x)) :
↑good.card / (2 ^ (k + 2) * ↑(Fintype.card X)) ≤ ↑{mg : (Fin k → BitString n) × BitString k | good.card ≤ 2 ^ (k + 2) * {x : X | candidate (pred x) mg.1 mg.2 = target x}.card}.dens

Nonuniform Goldreich–Levin decoding, density form. Under the hypotheses of exists_card_candidate_eq, the corrected-majority candidate equals the target for at least #good / 2 ^ (k + 2) indices for at least a #good / (2 ^ (k + 2) * #X) fraction of the masks and guesses. This is reverse averaging (Fintype.expect_sub_le_dens_filter) applied to the sum card_mul_le_two_mul_sum_card_candidate_eq.

theorem Cslib.Crypto.GoldreichLevin.dens_filter_agreement_ge {n : ℕ} {X : Type u_1} [Fintype X] [Nonempty X] (pred : X → BitString n → Bool) (target : X → BitString n) {ε : ℝ} (hε : 0 ≤ ε) (hagree : (1 / 2 + ε) * (↑(Fintype.card X) * 2 ^ n) ≤ ↑{xr : X × BitString n | pred xr.1 xr.2 = target xr.1 ⬝ᵥ xr.2}.card) :
ε / 2 ≤ ↑{x : X | 1 / 2 + ε / 2 ≤ agreement (pred x) (target x)}.dens

Averaging for Goldreich–Levin. If predictors pred x agree with the parities of target x on a 1 / 2 + ε fraction of all pairs (x, r), with 0 ≤ ε, then at least an ε / 2 fraction of the indices x have agreement at least 1 / 2 + ε / 2. This is reverse averaging (Fintype.expect_sub_le_dens_filter) for the agreement, which is at most 1.

theorem Cslib.Crypto.GoldreichLevin.card_filter_agreement_ge {n : ℕ} {X : Type u_1} [Fintype X] [Nonempty X] (pred : X → BitString n → Bool) (target : X → BitString n) {ε : ℝ} (hε : 0 ≤ ε) (hagree : (1 / 2 + ε) * (↑(Fintype.card X) * 2 ^ n) ≤ ↑{xr : X × BitString n | pred xr.1 xr.2 = target xr.1 ⬝ᵥ xr.2}.card) :
ε / 2 * ↑(Fintype.card X) ≤ ↑{x : X | 1 / 2 + ε / 2 ≤ agreement (pred x) (target x)}.card

Averaging for Goldreich–Levin, counting form. If predictors pred x agree with the parities of target x on a 1 / 2 + ε fraction of all pairs (x, r), with 0 ≤ ε, then at least ε / 2 * #X indices have agreement at least 1 / 2 + ε / 2.