Documentation

CslibFrontier.Probability.PairwiseIndependentHash.Retention

Retention by pairwise independent hashing #

Fix a target set B ⊆ Y and a pairwise independent family h i : X → Y. A point x is retained by the seed i when its hash h i x lies in B. Each point is then retained with probability exactly p = #B / |Y|, and the retention events of two distinct points are independent: both are retained with probability exactly p ^ 2 (IsPairwiseIndependentHash.expect_boole_apply_mem_and_apply_mem). This is sampling at rate p with pairwise independence, the technique of Chor and Goldreich [CG89] built on the hash families of Carter and Wegman [CW79], [WC81]. For polynomial or affine hashing over a finite field with a box B, the rate p ranges over the ratios of box size to field size.

The number N i = #{x ∈ S | h i x ∈ B} of retained points of a finite set S therefore has mean #S p, second factorial moment #S (#S - 1) p ^ 2 and variance #S p (1 - p), and Chebyshev's inequality bounds its deviations. In particular fewer than half of the expected number of points are retained with probability at most 4 / (#S p). For a single target, B = {y}, these are the cell-size moments of CslibFrontier.Probability.PairwiseIndependentHash.

Conversely, by inclusion–exclusion some point of S is retained with probability at least min (#S p) 1 / 2, and at least 3 #S p / 4 when 2 #S p ≤ 1. When h is a pairwise independence generator G : {0,1}^{2n} → ({0,1}^n)^n (seeds ι = {0,1}^{2n}, points X = Fin n), this says that one of the n outputs lands in a set of density p: Exercise 7.23 of Goldreich, used there in the proof of Lemma 7.22.

Main results #

References #

theorem Cslib.Probability.IsPairwiseIndependentHash.expect_boole_apply_mem {ι : Type u_1} {X : Type u_2} {Y : Type u_3} {𝕜 : Type u_4} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} [Semifield 𝕜] [CharZero 𝕜] (hh : IsPairwiseIndependentHash h) (x : X) (B : Finset Y) :
(Finset.univ.expect fun (i : ι) => if h i x ∈ B then 1 else 0) = ↑B.card / ↑(Fintype.card Y)

Retention probability: a point is retained, its hash lying in B, with probability #B / |Y|.

theorem Cslib.Probability.IsPairwiseIndependentHash.dens_filter_apply_mem {ι : Type u_1} {X : Type u_2} {Y : Type u_3} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} (hh : IsPairwiseIndependentHash h) (x : X) (B : Finset Y) :
{i : ι | h i x ∈ B}.dens = ↑B.card / ↑(Fintype.card Y)

Retention probability: a point is retained, its hash lying in B, with probability #B / |Y|.

theorem Cslib.Probability.IsPairwiseIndependentHash.expect_boole_apply_mem_and_apply_mem {ι : Type u_1} {X : Type u_2} {Y : Type u_3} {𝕜 : Type u_4} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} [Semifield 𝕜] [CharZero 𝕜] (hh : IsPairwiseIndependentHash h) {x₁ x₂ : X} (hx : x₁ ≠ x₂) (B₁ B₂ : Finset Y) :
(Finset.univ.expect fun (i : ι) => if h i x₁ ∈ B₁ ∧ h i x₂ ∈ B₂ then 1 else 0) = ↑B₁.card / ↑(Fintype.card Y) * (↑B₂.card / ↑(Fintype.card Y))

Pairwise independent retention: two distinct points are retained by B₁ and B₂ with probability #B₁ / |Y| * (#B₂ / |Y|).

theorem Cslib.Probability.IsPairwiseIndependentHash.dens_filter_apply_mem_and_apply_mem {ι : Type u_1} {X : Type u_2} {Y : Type u_3} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} (hh : IsPairwiseIndependentHash h) {x₁ x₂ : X} (hx : x₁ ≠ x₂) (B₁ B₂ : Finset Y) :
{i : ι | h i x₁ ∈ B₁ ∧ h i x₂ ∈ B₂}.dens = ↑B₁.card / ↑(Fintype.card Y) * (↑B₂.card / ↑(Fintype.card Y))

Pairwise independent retention: two distinct points are retained by B₁ and B₂ with probability #B₁ / |Y| * (#B₂ / |Y|).

theorem Cslib.Probability.IsPairwiseIndependentHash.expect_card_filter_apply_mem {ι : Type u_1} {X : Type u_2} {Y : Type u_3} {𝕜 : Type u_4} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} [Semifield 𝕜] [CharZero 𝕜] (hh : IsPairwiseIndependentHash h) (S : Finset X) (B : Finset Y) :
(Finset.univ.expect fun (i : ι) => ↑{x ∈ S | h i x ∈ B}.card) = ↑S.card * (↑B.card / ↑(Fintype.card Y))

The mean number of retained points of S is #S * (#B / |Y|).

theorem Cslib.Probability.IsPairwiseIndependentHash.expect_card_filter_apply_mem_mul_sub_one {ι : Type u_1} {X : Type u_2} {Y : Type u_3} {𝕜 : Type u_4} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} [Field 𝕜] [CharZero 𝕜] (hh : IsPairwiseIndependentHash h) (S : Finset X) (B : Finset Y) :
(Finset.univ.expect fun (i : ι) => ↑{x ∈ S | h i x ∈ B}.card * (↑{x ∈ S | h i x ∈ B}.card - 1)) = ↑S.card * (↑S.card - 1) * (↑B.card / ↑(Fintype.card Y)) ^ 2

The second factorial moment of the number of retained points: the number of ordered pairs of distinct retained points of S has expectation #S (#S - 1) (#B / |Y|) ^ 2.

theorem Cslib.Probability.IsPairwiseIndependentHash.expect_card_filter_apply_mem_sub_sq {ι : Type u_1} {X : Type u_2} {Y : Type u_3} {𝕜 : Type u_4} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} [Field 𝕜] [CharZero 𝕜] (hh : IsPairwiseIndependentHash h) (S : Finset X) (B : Finset Y) :
(Finset.univ.expect fun (i : ι) => (↑{x ∈ S | h i x ∈ B}.card - ↑S.card * (↑B.card / ↑(Fintype.card Y))) ^ 2) = ↑S.card * (↑B.card / ↑(Fintype.card Y)) * (1 - ↑B.card / ↑(Fintype.card Y))

The variance of the number of retained points is #S p (1 - p) with p = #B / |Y|.

theorem Cslib.Probability.IsPairwiseIndependentHash.dens_le_abs_card_filter_apply_mem_sub_le {ι : Type u_1} {X : Type u_2} {Y : Type u_3} {𝕜 : Type u_4} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] (hh : IsPairwiseIndependentHash h) (S : Finset X) (B : Finset Y) {ε : 𝕜} (hε : 0 < ε) :
↑{i : ι | ε ≤ |↑{x ∈ S | h i x ∈ B}.card - ↑S.card * (↑B.card / ↑(Fintype.card Y))|}.dens ≤ ↑S.card * (↑B.card / ↑(Fintype.card Y)) / ε ^ 2

Chebyshev's inequality for the number of retained points: it is at distance at least ε > 0 from its mean #S p, with p = #B / |Y|, with probability at most #S p / ε².

theorem Cslib.Probability.IsPairwiseIndependentHash.dens_two_mul_card_filter_apply_mem_lt_le {ι : Type u_1} {X : Type u_2} {Y : Type u_3} {𝕜 : Type u_4} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] (hh : IsPairwiseIndependentHash h) (S : Finset X) (B : Finset Y) (hpos : 0 < ↑S.card * (↑B.card / ↑(Fintype.card Y))) :
↑{i : ι | 2 * ↑{x ∈ S | h i x ∈ B}.card < ↑S.card * (↑B.card / ↑(Fintype.card Y))}.dens ≤ 4 / (↑S.card * (↑B.card / ↑(Fintype.card Y)))

Lower tail of the number of retained points: fewer than half of the expected number #S p, with p = #B / |Y|, are retained with probability at most 4 / (#S p).

theorem Cslib.Probability.IsPairwiseIndependentHash.sub_le_dens_filter_exists_apply_mem {ι : Type u_1} {X : Type u_2} {Y : Type u_3} {𝕜 : Type u_4} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] (hh : IsPairwiseIndependentHash h) (S : Finset X) (B : Finset Y) :
↑S.card * (↑B.card / ↑(Fintype.card Y)) - ↑S.card * (↑S.card - 1) * (↑B.card / ↑(Fintype.card Y)) ^ 2 / 2 ≤ ↑{i : ι | ∃ x ∈ S, h i x ∈ B}.dens

Inclusion–exclusion for retention: some point of S is retained with probability at least #S p - #S (#S - 1) p ^ 2 / 2, where p = #B / |Y|.

theorem Cslib.Probability.IsPairwiseIndependentHash.min_mul_div_two_le_dens_filter_exists_apply_mem {ι : Type u_1} {X : Type u_2} {Y : Type u_3} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} (hh : IsPairwiseIndependentHash h) (S : Finset X) (B : Finset Y) :
min (↑S.card * B.dens) 1 / 2 ≤ {i : ι | ∃ x ∈ S, h i x ∈ B}.dens

A pairwise independent generator hits a dense set Goldreich, Exercise 7.23, first claim: some point of S is sent into a set B of density p = #B / |Y| with probability at least min (#S p) 1 / 2. Goldreich states it for a pairwise independence generator G : {0,1}^{2n} → ({0,1}^n)^n as in his Lemma 7.22: the case ι = {0,1}^{2n}, X = Fin n, S = univ and Y = {0,1}^n. As in the guideline, the bound follows from inclusion–exclusion on min #S ⌈1 / p⌉ points of S.

theorem Cslib.Probability.IsPairwiseIndependentHash.three_quarters_mul_le_dens_filter_exists_apply_mem {ι : Type u_1} {X : Type u_2} {Y : Type u_3} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} (hh : IsPairwiseIndependentHash h) {S : Finset X} {B : Finset Y} (hSB : 2 * ↑S.card * B.dens ≤ 1) :
3 / 4 * (↑S.card * B.dens) ≤ {i : ι | ∃ x ∈ S, h i x ∈ B}.dens

A pairwise independent generator hits a sparse set Goldreich, Exercise 7.23, second claim: if the set B has density p = #B / |Y| with p ≤ 1 / (2 #S), then some point of S is sent into B with probability at least 0.75 #S p. The case of Goldreich's generator is as in min_mul_div_two_le_dens_filter_exists_apply_mem.