Documentation

CslibFrontier.Probability.SaksZhou.Nisan

The Saks–Zhou iteration instantiated with Nisan's generator #

Combines the sink-augmented walk realization of dyadic substochastic matrices (Cslib.Probability.SaksZhou.walkStep, dens_foldl_walkStep_eq) with Nisan's good-hash-seeds lemma (Cslib.Crypto.PRG.Nisan.dens_hashSeeds_far_le) to instantiate the Saks–Zhou randomized rounding iteration (Cslib.Probability.SaksZhou.dens_snapIter_far_le_of_two_le) using one shared hash-seed tuple hs : Fin k → H and n₂ independent rounding shifts z : Fin n₂ → Fin (2 ^ d) (Chattopadhyay and Liao, Appendix A.1; Hoza, Appendix A; Nisan; Saks and Zhou, internal numbering of the publisher copy not consulted).

For any substochastic matrix A whose entries are multiples of 1 / |X| and any pairwise independent hash family h : H → X → X, nisanPow order letter h k A hs averages the 2 ^ k-block run of the ordered walk driven by Nisan.blocks h k x hs over one uniform block. Since every reference iterate of snapIter is dyadic substochastic at precision d (isDyadicSubstochastic_snapIter), when 2 ^ d ∣ |X| each iterate has entries in ℤ / |X| and therefore admits an exact walk over Option ι.

Specializing to Boolean Toeplitz hashing (Cslib.Probability.toeplitzHash) on blocks of even length 2 * m gives bitNisanPow and the square-root-free bound dens_snapIter_bitNisanPow_far_le over seeds of k * (3 * (2 * m) - 1) + n₂ * d bits.

For a matrix supplied by its integer numerators at denominator 2 ^ d, nisanSnapCounts computes all rounds using natural-number weights and hit counts. Its entries divided by 2 ^ d agree with the real iteration for every fixed seed when d ≤ b (snapIter_bitNisanPow_eq_counts). Every positive-round row has total numerator at most 2 ^ d (sum_nisanSnapCounts_le).

Main definitions #

Main results #

References #

noncomputable def Cslib.Probability.SaksZhou.nisanPow {H : Type u_1} {X : Type u_2} {ι : Type u_3} {n b : ℕ} [Fintype X] [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (letter : X ≃ Fin b) (h : H → X → X) (k : ℕ) (A : Matrix ι ι ℝ) (hs : Fin k → H) :
Matrix ι ι ℝ

Approximate (2 ^ k)-th power of a matrix A computed by averaging Nisan's generator Cslib.Crypto.PRG.Nisan.blocks h k x hs on walkStep order letter A over a uniform block, keeping the hash seeds hs : Fin k → H fixed.

@[simp]
theorem Cslib.Probability.SaksZhou.nisanPow_apply {H : Type u_1} {X : Type u_2} {ι : Type u_3} {n b : ℕ} [Fintype X] [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (letter : X ≃ Fin b) (h : H → X → X) (k : ℕ) (A : Matrix ι ι ℝ) (hs : Fin k → H) (i j : ι) :
nisanPow order letter h k A hs i j = ↑{x : X | List.foldl (walkStep order letter A) (some i) (List.ofFn (Crypto.PRG.Nisan.blocks h k x hs)) = some j}.dens
theorem Cslib.Probability.SaksZhou.dens_entryFarSet_nisanPow_le {H : Type u_1} {X : Type u_2} {ι : Type u_3} {n b : ℕ} [Fintype H] [Fintype X] [DecidableEq X] [Nonempty X] [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (letter : X ≃ Fin b) {h : H → X → X} (hh : IsPairwiseIndependentHash h) (k : ℕ) {A : Matrix ι ι ℝ} (h0 : ∀ (i j : ι), 0 ≤ A i j) (h1 : ∀ (i : ι), ∑ j : ι, A i j ≤ 1) (hA : ∀ (i j : ι), ∃ (c : ℕ), A i j * ↑(Fintype.card X) = ↑c) {ε : ℝ} (hε : 0 < ε) :
↑(entryFarSet ε (nisanPow order letter h k A) (A ^ 2 ^ k)).dens ≤ (↑(Fintype.card ι) + 1) * ((2 ^ k - 1) * (↑(Fintype.card ι) + 1) / √↑(Fintype.card X)) / ε

Most hash seeds make nisanPow close to A ^ (2 ^ k): for a pairwise independent hash family h : H → X → X and a substochastic matrix A with entries in ℤ / |X|, the density of hash seeds for which an entry of nisanPow order letter h k A hs - A ^ (2 ^ k) exceeds ε in magnitude is at most (|ι| + 1) * ((2 ^ k - 1) * (|ι| + 1) / √|X|) / ε.

theorem Cslib.Probability.SaksZhou.dens_snapIter_nisanPow_far_le {H : Type u_1} {X : Type u_2} {ι : Type u_3} {n b : ℕ} [Fintype H] [Fintype X] [DecidableEq X] [Nonempty X] [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (letter : X ≃ Fin b) {h : H → X → X} (hh : IsPairwiseIndependentHash h) (d k n₂ : ℕ) (hk : 1 ≤ k) (hdiv : 2 ^ d ∣ Fintype.card X) {M : Matrix ι ι ℝ} {ε : ℝ} (h0 : ∀ (i j : ι), 0 ≤ M i j) (h1 : ∀ (i : ι), ∑ j : ι, M i j ≤ 1) (hM : ∀ (i j : ι), ∃ (c : ℕ), M i j * ↑(Fintype.card X) = ↑c) (hε : 0 < ε) (herr : (↑(Fintype.card ι) + 1) * ((2 ^ k - 1) * (↑(Fintype.card ι) + 1) / √↑(Fintype.card X)) ≤ ε ^ 2) :
↑(rowFarSet (2 ^ (k * n₂) * (↑(Fintype.card ι) * (2 / 2 ^ d))) (fun (p : (Fin k → H) × (Fin n₂ → Fin (2 ^ d))) => snapIter d (fun (A : Matrix ι ι ℝ) => nisanPow order letter h k A p.1) M n₂ p.2) (M ^ 2 ^ (k * n₂))).dens ≤ ↑n₂ * (ε + ↑(Fintype.card ι) ^ 2 * (2 ^ d * ε + (2 ^ d)⁻¹))

Saks–Zhou iteration with Nisan's generator: for a substochastic matrix M over ι with entries in ℤ / |X|, 2 ^ d ∣ |X|, and 1 ≤ k, when (|ι| + 1) * ((2 ^ k - 1) * (|ι| + 1) / √|X|) ≤ ε ^ 2, all but an n₂ * (ε + |ι| ^ 2 * (2 ^ d * ε + 2 ^ (-d))) fraction of pairs (hs, z) satisfy ‖snapIter d (nisanPow order letter h k · hs) M n₂ z - M ^ (2 ^ (k * n₂))‖_∞ ≤ 2 ^ (k * n₂) * |ι| * 2 ^ (1 - d).

Specialization to Boolean Toeplitz hashing #

@[reducible, inline]

A single-level hash seed for Cslib.Probability.toeplitzHash on b-bit blocks: a b × b Boolean Toeplitz matrix encoded in 2 b - 1 bits together with a b-bit shift vector.

@[reducible, inline]

Combined randomness for n₂ Saks–Zhou rounds using k-level Toeplitz-Nisan powering on b-bit blocks and d-bit rounding shifts: k * (3 * b - 1) + n₂ * d bits total.

theorem Cslib.Probability.SaksZhou.card_nisanShiftSeed (b k n₂ d : ℕ) :
Fintype.card (NisanShiftSeed b k n₂ d) = 2 ^ (k * (3 * b - 1) + n₂ * d)

Total cardinality of NisanShiftSeed b k n₂ d is 2 ^ (k * (3 * b - 1) + n₂ * d).

noncomputable def Cslib.Probability.SaksZhou.bitNisanPow {ι : Type u_1} {n : ℕ} [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (b k : ℕ) (A : Matrix ι ι ℝ) (hs : Fin k → ToeplitzSeed b) :
Matrix ι ι ℝ

nisanPow specialized to Cslib.Probability.toeplitzHash on b-bit blocks.

@[simp]
theorem Cslib.Probability.SaksZhou.bitNisanPow_apply {ι : Type u_1} {n : ℕ} [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (b k : ℕ) (A : Matrix ι ι ℝ) (hs : Fin k → ToeplitzSeed b) (i j : ι) :
theorem Cslib.Probability.SaksZhou.snapMatrix_bitNisanPow_apply {ι : Type u_1} {n : ℕ} [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (b k d : ℕ) (A : Matrix ι ι ℝ) (hs : Fin k → ToeplitzSeed b) (y : Fin (2 ^ d)) (i j : ι) :
snapMatrix d (bitNisanPow order b k A hs) y i j = ↑(snapCount (2 ^ d) {x : BitString b | List.foldl (walkStep order (BitString.equivFin b) A) (some i) (List.ofFn (Crypto.PRG.Nisan.blocks toeplitzHash k x hs)) = some j}.card (2 ^ b) ↑y) / 2 ^ d

A rounded entry of Nisan powering can be computed from the number of starting blocks whose walk ends at the requested column, using natural arithmetic for the final rounding.

def Cslib.Probability.SaksZhou.nisanSnapCounts {ι : Type u_1} {n : ℕ} [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (b d k : ℕ) (hs : Fin k → ToeplitzSeed b) (base : Matrix ι ι ℕ) (r : ℕ) :
(Fin r → Fin (2 ^ d)) → Matrix ι ι ℕ

Integer numerators of a seeded Saks–Zhou iteration. The supplied matrix and every round's result have denominator 2 ^ d. Each starting block is counted at its final column, and the result is rounded using that round's shift.

theorem Cslib.Probability.SaksZhou.snapIter_bitNisanPow_eq_counts {ι : Type u_1} {n b d k : ℕ} [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (hdb : d ≤ b) (hs : Fin k → ToeplitzSeed b) (base : Matrix ι ι ℕ) (A : Matrix ι ι ℝ) (hA : ∀ (i j : ι), A i j = ↑(base i j) / 2 ^ d) (r : ℕ) (shifts : Fin r → Fin (2 ^ d)) (i j : ι) :
snapIter d (fun (B : Matrix ι ι ℝ) => bitNisanPow order b k B hs) A r shifts i j = ↑(nisanSnapCounts order b d k hs base r shifts i j) / 2 ^ d

Integer counts agree entry by entry with the rounded real-matrix iteration for every seed and shift sequence, including when the supplied base row sums exceed one.

theorem Cslib.Probability.SaksZhou.sum_nisanSnapCounts_le {ι : Type u_1} {n : ℕ} [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (b d k : ℕ) (hs : Fin k → ToeplitzSeed b) (base : Matrix ι ι ℕ) (r : ℕ) (shifts : Fin (r + 1) → Fin (2 ^ d)) (i : ι) :
∑ j : ι, nisanSnapCounts order b d k hs base (r + 1) shifts i j ≤ 2 ^ d

Every positive round has total numerator at most 2 ^ d in each row. An initial block can contribute to at most one output column, and snapping can only decrease its column's frequency.

theorem Cslib.Probability.SaksZhou.dens_snapIter_bitNisanPow_far_le {ι : Type u_1} {n : ℕ} [Fintype ι] [DecidableEq ι] (order : Fin n ≃ ι) (d m k n₂ : ℕ) (hk : 1 ≤ k) (hdm : d ≤ 2 * m) {M : Matrix ι ι ℝ} {ε : ℝ} (h0 : ∀ (i j : ι), 0 ≤ M i j) (h1 : ∀ (i : ι), ∑ j : ι, M i j ≤ 1) (hM : ∀ (i j : ι), ∃ (c : ℕ), M i j * ↑(Fintype.card (BitString (2 * m))) = ↑c) (hε : 0 < ε) (herr : (↑(Fintype.card ι) + 1) * ((2 ^ k - 1) * (↑(Fintype.card ι) + 1) / 2 ^ m) ≤ ε ^ 2) :
↑(rowFarSet (2 ^ (k * n₂) * (↑(Fintype.card ι) * (2 / 2 ^ d))) (fun (p : NisanShiftSeed (2 * m) k n₂ d) => snapIter d (fun (A : Matrix ι ι ℝ) => bitNisanPow order (2 * m) k A p.1) M n₂ p.2) (M ^ 2 ^ (k * n₂))).dens ≤ ↑n₂ * (ε + ↑(Fintype.card ι) ^ 2 * (2 ^ d * ε + (2 ^ d)⁻¹))

Saks–Zhou iteration with Boolean Toeplitz Nisan powering: on blocks of 2 * m bits with d ≤ 2 * m and 1 ≤ k, if (|ι| + 1) * ((2 ^ k - 1) * (|ι| + 1) / 2 ^ m) ≤ ε ^ 2, all but an n₂ * (ε + |ι| ^ 2 * (2 ^ d * ε + 2 ^ (-d))) fraction of NisanShiftSeed (2 * m) k n₂ d pairs produce a matrix whose every row sums within 2 ^ (k * n₂) * |ι| * 2 ^ (1 - d) of M ^ (2 ^ (k * n₂)).