Documentation

CslibFrontier.Computability.Circuit.Boolean.HardnessAmplification.DirectProduct.Decode

Direct-product decoding #

The direct-product decoder of Impagliazzo, Jaiswal, Kabanets and Wigderson (preprint of 2009-10-19, Theorem 1.2 and Algorithm 2; Carmosino, Impagliazzo, Kabanets and Kolokolova cite it as their Theorem 4.1) turns a map C' : (Fin k → U) → Fin k → V that agrees with the direct product f ^ k on a δ fraction of tuples into a hypothesis for f. It is stated here as a pure function: no circuits and no running time.

Library formulation. Inputs are uniform k-tuples with a random position subset P, in place of IJKW's k-sets. This avoids their collision term; it does not prove the k-set version. A seed is a set P of positions, a tuple b₀ and m trials (j, r). On input x, a trial queries trialTuple P b₀ x (j, r): b₀ on P, x at j and r elsewhere. It is accepted when j ∉ P and C' gives it the values that C' b₀ has on P. dpDecode outputs the value of C' at j for the first accepted trial, or a default.

Per-seed analysis. card_filter_dpDecode_err_le_ge fixes P and b₀ and shows that at least half of the trial vectors give a hypothesis with error at most ε #U. It assumes that the tuples consistent with the seed have density at least δ / 2 and that at most an ε / 64 fraction of them disagree with f in ε k / 64 or more positions. The module CslibFrontier.Computability.Circuit.Boolean.HardnessAmplification.DirectProduct.Density discharges these hypotheses for a δ / 4 fraction of seeds and proves the counting headline, and DirectProduct.Complexity bounds the decoder's circuit size. The analysis follows the shape of IJKW's Lemmas 3.8–3.10. Its constants (ε / 64, (64 / ε) log (4 / δ), (16 / δ) log (8 / ε)) are ours, derived for the tuple formulation; they are not IJKW's. The parameter roles are swapped relative to IJKW's Theorem 1.2: ε here is their output error δ, and δ here is their agreement ε. The tuple form also omits their Algorithm 1 lookup that answers x = aᵢ with the corresponding output.

Main definitions #

Main results #

References #

@[reducible, inline]

A trial: a free position j and a filler tuple r.

def Cslib.Circuits.Boolean.DirectProduct.trialTuple {U : Type u_1} {k : ℕ} (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) (t : Trial U k) :
Fin k → U

The tuple queried by a trial: b₀ on P, the input x at the free position t.1, and the filler t.2 elsewhere.

theorem Cslib.Circuits.Boolean.DirectProduct.card_filter_trialTuple {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) (q : Fin k → (Fin k → U) → Prop) [(j : Fin k) → (y : Fin k → U) → Decidable (q j y)] :
{t : Trial U k | t.1 ∉ P ∧ q t.1 (trialTuple P b₀ x t)}.card = Fintype.card U ^ (P.card + 1) * {p : Fin k × (Fin k → U) | p.1 ∉ P ∧ (∀ i ∈ P, p.2 i = b₀ i) ∧ p.2 p.1 = x ∧ q p.1 p.2}.card

Counting trials: the trials with free position outside P whose tuple satisfies q (which may depend on the free position) number #U ^ (#P + 1) for each pair (y, j) with y = b₀ on P, y j = x, j ∉ P and q j y.

def Cslib.Circuits.Boolean.DirectProduct.accepts {U : Type u_1} {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) (t : Trial U k) :

A trial is accepted at x when its free position lies outside P and C' gives its tuple the same values on P as it gives b₀.

def Cslib.Circuits.Boolean.DirectProduct.dpDecode {U : Type u_1} {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (dflt : V) (P : Finset (Fin k)) (b₀ : Fin k → U) {m : ℕ} (v : Fin m → Trial U k) (x : U) :
V

The direct-product decoder: on input x, the value of C' at the free position of the first accepted trial, or dflt if no trial is accepted.

theorem Cslib.Circuits.Boolean.DirectProduct.trialTuple_eq {U : Type u_1} {k : ℕ} (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) (t : Trial U k) :
trialTuple P b₀ x t = Function.update (P.piecewise b₀ t.2) t.1 x

The trial tuple overwrites the free position of b₀ on P and the filler elsewhere.

theorem Cslib.Circuits.Boolean.DirectProduct.accepts_eq {U : Type u_1} {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) (t : Trial U k) :
accepts C' P b₀ x t = decide (t.1 ∉ P ∧ ∀ i ∈ P, C' (trialTuple P b₀ x t) i = C' b₀ i)

Unfolding the acceptance test.

@[simp]
theorem Cslib.Circuits.Boolean.DirectProduct.dpDecode_zero {U : Type u_1} {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (dflt : V) (P : Finset (Fin k)) (b₀ : Fin k → U) (v : Fin 0 → Trial U k) (x : U) :
dpDecode C' dflt P b₀ v x = dflt

With no trials, the decoder outputs the default.

theorem Cslib.Circuits.Boolean.DirectProduct.dpDecode_cons {U : Type u_1} {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (dflt : V) (P : Finset (Fin k)) (b₀ : Fin k → U) {m : ℕ} (t : Trial U k) (w : Fin m → Trial U k) (x : U) :
dpDecode C' dflt P b₀ (Fin.cons t w) x = if accepts C' P b₀ x t = true then C' (trialTuple P b₀ x t) t.1 else dpDecode C' dflt P b₀ w x

The decoder answers from the first trial if it is accepted, and otherwise from the rest.

def Cslib.Circuits.Boolean.DirectProduct.acceptedPairs {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) :
Finset (Fin k × (Fin k → U))

The pairs (j, y) that account for the trials accepted at x: j ∉ P, y = b₀ on P, y j = x and C' y = C' b₀ on P.

def Cslib.Circuits.Boolean.DirectProduct.badPairs {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (f : U → V) (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) :
Finset (Fin k × (Fin k → U))

The accepted pairs at which C' disagrees with f.

theorem Cslib.Circuits.Boolean.DirectProduct.card_filter_accepts {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) :
{t : Trial U k | accepts C' P b₀ x t = true}.card = Fintype.card U ^ (P.card + 1) * (acceptedPairs C' P b₀ x).card

The trials accepted at x number #U ^ (#P + 1) per accepted pair.

theorem Cslib.Circuits.Boolean.DirectProduct.card_filter_dpDecode_ne_mul_le {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (f : U → V) (dflt : V) (P : Finset (Fin k)) (b₀ : Fin k → U) (m : ℕ) (x : U) :
{v : Fin m → Trial U k | dpDecode C' dflt P b₀ v x ≠ f x}.card * (acceptedPairs C' P b₀ x).card ≤ (badPairs C' f P b₀ x).card * Fintype.card (Trial U k) ^ m + (acceptedPairs C' P b₀ x).card * (Fintype.card (Trial U k) - Fintype.card U ^ (P.card + 1) * (acceptedPairs C' P b₀ x).card) ^ m

Error at one input: weighted by the number a of accepted pairs at x, the trial vectors on which the decoder errs at x are at most the bad pairs times N ^ m, plus a times the vectors rejecting every trial. Here N is the number of trials.

def Cslib.Circuits.Boolean.DirectProduct.consistent {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (P : Finset (Fin k)) (b₀ : Fin k → U) :
Finset (Fin k → U)

The tuples consistent with the seed: equal to b₀ on P, with the same C' values there.

@[simp]
theorem Cslib.Circuits.Boolean.DirectProduct.mem_consistent {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] {C' : (Fin k → U) → Fin k → V} {P : Finset (Fin k)} {b₀ y : Fin k → U} :
y ∈ consistent C' P b₀ ↔ (∀ i ∈ P, y i = b₀ i) ∧ ∀ i ∈ P, C' y i = C' b₀ i
theorem Cslib.Circuits.Boolean.DirectProduct.acceptedPairs_eq_filter {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) :
acceptedPairs C' P b₀ x = {p ∈ Pᶜ ×ˢ consistent C' P b₀ | p.2 p.1 = x}

The accepted pairs are the free positions of the consistent tuples that carry x.

theorem Cslib.Circuits.Boolean.DirectProduct.badPairs_eq_filter {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (f : U → V) (P : Finset (Fin k)) (b₀ : Fin k → U) (x : U) :
badPairs C' f P b₀ x = {p ∈ {p ∈ Pᶜ ×ˢ consistent C' P b₀ | C' p.2 p.1 ≠ f (p.2 p.1)} | p.2 p.1 = x}

The bad pairs are the free disagreement positions of the consistent tuples that carry x.

theorem Cslib.Circuits.Boolean.DirectProduct.sum_card_acceptedPairs_nsmul {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] {M : Type u_3} [AddCommMonoid M] (C' : (Fin k → U) → Fin k → V) (P : Finset (Fin k)) (b₀ : Fin k → U) (g : U → M) :
∑ x : U, (acceptedPairs C' P b₀ x).card • g x = ∑ y ∈ consistent C' P b₀, ∑ j ∈ Pᶜ, g (y j)

Accepted pairs by input: weighting the accepted pairs at x by g x and summing over x is summing g (y j) over the free positions j of the consistent tuples y.

theorem Cslib.Circuits.Boolean.DirectProduct.sum_card_badPairs {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (f : U → V) (P : Finset (Fin k)) (b₀ : Fin k → U) :
∑ x : U, (badPairs C' f P b₀ x).card = ∑ y ∈ consistent C' P b₀, {j ∉ P | C' y j ≠ f (y j)}.card

Bad pairs by tuple: the bad pairs, summed over inputs, are the free positions at which a consistent tuple disagrees with f.

theorem Cslib.Circuits.Boolean.DirectProduct.card_filter_acceptedPairs_lt_mul_le {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (P : Finset (Fin k)) (b₀ : Fin k → U) {μ : ℝ} (hμ0 : 0 < μ) (hμ1 : μ ≤ 1) (hS : μ * ↑(Fintype.card U) ^ Pᶜ.card ≤ ↑(consistent C' P b₀).card) :
↑{x : U | ↑(acceptedPairs C' P b₀ x).card < ↑(consistent C' P b₀).card * ↑Pᶜ.card / (4 * ↑(Fintype.card U))}.card * ↑Pᶜ.card ≤ 8 * ↑(Fintype.card U) * Real.log (2 / μ)

Few inputs are rarely accepted: if the consistent tuples have density at least μ among the tuples agreeing with b₀ on P, the inputs with fewer than #S w / (4 #U) accepted pairs, where S is the consistent set and w = #Pᶜ, number at most 8 #U log (2 / μ) / w. This is the tuple-formulation analogue of IJKW's Lemma 3.9, proved, as there, from the weight bound of their Lemma 2.13 (Cslib.Probability.sub_mul_le_two_mul_sum_sum).

theorem Cslib.Circuits.Boolean.DirectProduct.card_filter_dpDecode_ne_le {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (f : U → V) (dflt : V) (P : Finset (Fin k)) (b₀ : Fin k → U) (m : ℕ) (x : U) {θ : ℝ} (hθ : 0 < θ) (ha : θ ≤ ↑(acceptedPairs C' P b₀ x).card) :
↑{v : Fin m → Trial U k | dpDecode C' dflt P b₀ v x ≠ f x}.card ≤ ↑(badPairs C' f P b₀ x).card * ↑(Fintype.card (Trial U k)) ^ m / θ + ↑(Fintype.card (Trial U k)) ^ m * Real.exp (-(↑m * (↑(Fintype.card U) ^ (P.card + 1) * θ / ↑(Fintype.card (Trial U k)))))

Error at one input, real form: if at least θ > 0 pairs are accepted at x, the decoder errs at x on at most #bad N ^ m / θ + N ^ m exp (-m #U ^ (#P + 1) θ / N) trial vectors, where N is the number of trials.

def Cslib.Circuits.Boolean.DirectProduct.disagreements {U : Type u_1} {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (f : U → V) (y : Fin k → U) :

The disagreement positions of a tuple: where C' differs from f coordinatewise.

@[simp]
theorem Cslib.Circuits.Boolean.DirectProduct.mem_disagreements {U : Type u_1} {k : ℕ} {V : Type u_2} [DecidableEq V] {C' : (Fin k → U) → Fin k → V} {f : U → V} {y : Fin k → U} {j : Fin k} :
j ∈ disagreements C' f y ↔ C' y j ≠ f (y j)
theorem Cslib.Circuits.Boolean.DirectProduct.sum_card_filter_dpDecode_ne_le {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (f : U → V) (dflt : V) (P : Finset (Fin k)) (b₀ : Fin k → U) (m : ℕ) {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) (hε1 : ε ≤ 1) (hδ1 : δ ≤ 1) (hk : k ≤ 2 * Pᶜ.card) (hw : 64 / ε * Real.log (4 / δ) ≤ ↑Pᶜ.card) (hm : 16 / δ * Real.log (8 / ε) ≤ ↑m) (hS : δ / 2 * ↑(Fintype.card U) ^ Pᶜ.card ≤ ↑(consistent C' P b₀).card) (hH : ↑{y ∈ consistent C' P b₀ | ε / 64 * ↑k ≤ ↑(disagreements C' f y).card}.card ≤ ε / 64 * ↑(consistent C' P b₀).card) :
∑ x : U, ↑{v : Fin m → Trial U k | dpDecode C' dflt P b₀ v x ≠ f x}.card ≤ ε * ↑(Fintype.card U) * ↑(Fintype.card (Trial U k)) ^ m / 2

Total error of a good seed. Suppose the consistent tuples have density at least δ / 2 on the slice of b₀ and at most an ε / 64 fraction of them have ε k / 64 or more disagreements. If k ≤ 2 #Pᶜ, #Pᶜ ≥ (64 / ε) log (4 / δ) and m ≥ (16 / δ) log (8 / ε), then the errors of the decoder, summed over inputs and trial vectors, are at most ε #U N ^ m / 2. These constants are ours (derived for the tuple formulation), not IJKW's. The two seed hypotheses are discharged for a δ / 4 fraction of seeds in the module DirectProduct.Density.

theorem Cslib.Circuits.Boolean.DirectProduct.card_filter_dpDecode_err_le_ge {U : Type u_1} [Fintype U] [DecidableEq U] {k : ℕ} {V : Type u_2} [DecidableEq V] (C' : (Fin k → U) → Fin k → V) (f : U → V) (dflt : V) (P : Finset (Fin k)) (b₀ : Fin k → U) (m : ℕ) {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) (hε1 : ε ≤ 1) (hδ1 : δ ≤ 1) (hk : k ≤ 2 * Pᶜ.card) (hw : 64 / ε * Real.log (4 / δ) ≤ ↑Pᶜ.card) (hm : 16 / δ * Real.log (8 / ε) ≤ ↑m) (hS : δ / 2 * ↑(Fintype.card U) ^ Pᶜ.card ≤ ↑(consistent C' P b₀).card) (hH : ↑{y ∈ consistent C' P b₀ | ε / 64 * ↑k ≤ ↑(disagreements C' f y).card}.card ≤ ε / 64 * ↑(consistent C' P b₀).card) :
↑(Fintype.card (Trial U k)) ^ m / 2 ≤ ↑{v : Fin m → Trial U k | ↑{x : U | dpDecode C' dflt P b₀ v x ≠ f x}.card ≤ ε * ↑(Fintype.card U)}.card

A good seed decodes well for half of the trial vectors. Under the hypotheses of sum_card_filter_dpDecode_ne_le, at least half of the trial vectors v give a hypothesis dpDecode C' dflt P b₀ v that differs from f on at most ε #U inputs. The two seed hypotheses are discharged for a δ / 4 fraction of seeds in the module DirectProduct.Density.