Documentation

CslibFrontier.Computability.Circuit.Boolean.Polarization

Polarization of circuit samplers #

The Polarization Lemma of Sahai and Vadhan [SahaiVadhan2003, Lemma 3.3] acts on pairs of circuits: from De Morgan circuits C₀ and C₁ with n inputs and m outputs it builds circuits whose output distributions are the polarized pair Cslib.Probability.PMF.polarize of the output distributions of C₀ and C₁, up to the flattening of tuples of outputs into one bit string.

The XOR construction on j + 1 coordinates (xorMixCircuit C₀ C₁ j c) reads j selector bits r and j + 1 blocks of n data bits. A chain of exclusive-or gadgets computes the last selector c ⊕ parity r, completing r to BitString.parityComplete c r (xorMixStage). Coordinate i then runs C₁ or C₀ on data block i according to selector bit i, through a multiplexer (xorMixBlock). On uniform inputs the selectors are uniform among the strings of parity c and the data blocks are independent uniform seeds, so the output distribution is the XOR construction xorMix (outputDist_xorMixCircuit). Independent copies are Circuit.replicate (Circuit.outputDist_replicate), and the polarization construction alternates the two (polarizeCircuit, outputDist_polarizeCircuit). Flattening is injective, so the polarized circuits are exactly as far apart as the polarized distributions (dist_outputDist_polarizeCircuit).

The numbers of coordinates are passed as predecessors, lam for lam + 1 inner coordinates and k for k + 1 outer coordinates. The XOR construction needs at least one coordinate, and this keeps the circuit types free of subtraction. Every circuit here has an explicit structure. Their codes are generated in polynomial time by Boolean.Polarization.PolyTime (computableInPolyTime_polarizeCode); their sizes are not stated separately.

Main definitions #

Main results #

References #

def Cslib.Circuits.Boolean.xorChainProgram {N : ℕ} (c : Bool) (j : ℕ) :
(Fin j → Fin N) → Program signature N (4 * j + 1)

A De Morgan program whose last gate computes c ⊕ x (sel 0) ⊕ ⋯ ⊕ x (sel (j - 1)): a constant gate followed by j exclusive-or gadgets. Unlike parityProgram, it reads arbitrary inputs, folds in a constant, and handles j = 0.

theorem Cslib.Circuits.Boolean.trace_xorChainProgram {N : ℕ} (c : Bool) (j : ℕ) (sel : Fin j → Fin N) (x : BitString N) :
(xorChainProgram c j sel).trace interpretation x (Wire.gate (Fin.last (4 * j))) = (c ^^ parity j (x ∘ sel))

The last gate of xorChainProgram c j sel computes c ⊕ parity (x ∘ sel).

def Cslib.Circuits.Boolean.xorMixStageWire (j n : ℕ) (i : Fin (j + 1)) (t : Fin (n + 1)) :
Wire (j + (j + 1) * n) (4 * j + 1)

The wire feeding bit t of output block i of the selection stage: at t = 0, selector input i for i < j and the last gate of the chain for i = j; at t = t' + 1, bit t' of data block i.

def Cslib.Circuits.Boolean.xorMixStage (c : Bool) (j n : ℕ) :
Circuit signature (j + (j + 1) * n) ((j + 1) * (n + 1))

The selection stage of the XOR construction: from j selector bits r and j + 1 data blocks of n bits, output j + 1 blocks of n + 1 bits, block i being bit i of BitString.parityComplete c r followed by data block i.

Block i of the output of the selection stage is bit i of the completed selector followed by data block i.

One coordinate of the XOR construction: on a selector bit b followed by n data bits y, output C₁ y if b holds and C₀ y otherwise, through muxCircuit.

theorem Cslib.Circuits.Boolean.eval_xorMixBlock {n m : ℕ} (C₀ C₁ : Circuit signature n m) (b : Bool) (y : BitString n) :
(xorMixBlock C₀ C₁).eval interpretation (Fin.cons b y) = bif b then C₁.eval interpretation y else C₀.eval interpretation y

xorMixBlock C₀ C₁ runs C₁ or C₀ on the data bits according to the selector bit.

def Cslib.Circuits.Boolean.xorMixCircuit {n m : ℕ} (C₀ C₁ : Circuit signature n m) (j : ℕ) (c : Bool) :
Circuit signature (j + (j + 1) * n) ((j + 1) * m)

The XOR construction on circuits [SahaiVadhan2003, Lemma 3.5], on j + 1 coordinates: the inputs are j selector bits followed by j + 1 consecutive blocks of n data bits, and output block i is C₁ or C₀ on data block i, according to bit i of the selector completed to parity c.

theorem Cslib.Circuits.Boolean.eval_xorMixCircuit {n m : ℕ} (C₀ C₁ : Circuit signature n m) (j : ℕ) (c : Bool) (r : BitString j) (d : Fin (j + 1) → BitString n) :
BitString.block ((xorMixCircuit C₀ C₁ j c).eval interpretation (Fin.append r (BitString.blocksEquiv.symm d))) = fun (i : Fin (j + 1)) => bif BitString.parityComplete c r i then C₁.eval interpretation (d i) else C₀.eval interpretation (d i)

Output block i of xorMixCircuit C₀ C₁ j c on selector bits r and data blocks d is C₁ (d i) or C₀ (d i), according to bit i of BitString.parityComplete c r.

The XOR construction on circuits samples the XOR construction of the output distributions of C₀ and C₁, with the j + 1 output blocks flattened by Cslib.BitString.blocksEquiv.

def Cslib.Circuits.Boolean.polarizeCircuit {n m : ℕ} (C₀ C₁ : Circuit signature n m) (lam ell k : ℕ) (c : Bool) :
Circuit signature (k + (k + 1) * (ell * (lam + (lam + 1) * n))) ((k + 1) * (ell * ((lam + 1) * m)))

The polarization construction on circuits [SahaiVadhan2003, proof of Lemma 3.3]: the XOR construction on k + 1 coordinates applied to ell independent copies of the XOR construction on lam + 1 coordinates.

def Cslib.Circuits.Boolean.polarizeEquiv (K ell L m : ℕ) :
(Fin K → Fin ell → Fin L → BitString m) ≃ BitString (K * (ell * (L * m)))

The flattening of K × ell × L outputs of m bits into one bit string, in consecutive blocks.

theorem Cslib.Circuits.Boolean.outputDist_polarizeCircuit {n m : ℕ} (C₀ C₁ : Circuit signature n m) (lam ell k : ℕ) (c : Bool) :

The polarization construction on circuits samples the polarized pair of the output distributions of C₀ and C₁, flattened by polarizeEquiv.

The polarized circuits are as far apart as the polarized distributions of the output distributions of C₀ and C₁, with lam + 1 inner and k + 1 outer coordinates.