Documentation

Complexity.Probability.PairwiseIndependentHash

Pairwise independent hash families #

A family of functions h i : X → Y, indexed by a seed i drawn uniformly from a finite type ι, is pairwise independent (Cslib.Probability.IsPairwiseIndependentHash) if each value h i x is uniformly distributed on Y and the values at any two distinct points are independent Arora and Barak, Definition 8.14. Wegman and Carter call such families strongly universal₂ [WC81], after the universal families of [CW79]. Probabilities over the seed are densities Finset.dens of sets of seeds, and averages are uniform expectations 𝔼 i.

Fix a finite set S ⊆ X and a target y : Y. The size N i = #{x ∈ S | h i x = y} of the cell of y has mean μ = #S / |Y| and second factorial moment 𝔼 N (N - 1) = #S (#S - 1) / |Y|², so its variance is μ (1 - 1 / |Y|) ≤ μ, and Chebyshev's inequality bounds its deviations. For the probability that S hits y:

The same argument shows that exactly one element of S hits y with probability at least μ - #S (#S - 1) / |Y|², hence at least 3 / 16 when |Y| ≤ 4 #S ≤ 2 |Y|: the lemma of Valiant and Vazirani [VV86] in Arora and Barak, Section 17.4, where the bound is 1 / 8.

Main definitions #

Main results #

References #

structure Cslib.Probability.IsPairwiseIndependentHash {ι : Type u_1} {X : Type u_2} {Y : Type u_3} [Fintype ι] [Fintype Y] [DecidableEq Y] (h : ι → X → Y) :

A family of functions h i : X → Y, indexed by a seed i : ι drawn uniformly at random, is pairwise independent if every value h i x is uniformly distributed on Y, and the values h i x₁ and h i x₂ at distinct points are independent: a 1 / |Y| fraction of the seeds sends x to y, and a 1 / |Y|² fraction sends x₁ ≠ x₂ to y₁ and y₂. The first condition follows from the second unless X has exactly one element.

  • dens_filter_apply_eq (x : X) (y : Y) : {i : ι | h i x = y}.dens = (↑(Fintype.card Y))⁻¹

    Every value is uniformly distributed.

  • dens_filter_apply_eq_and_apply_eq {x₁ x₂ : X} (hx : x₁ ≠ x₂) (y₁ y₂ : Y) : {i : ι | h i x₁ = y₁ ∧ h i x₂ = y₂}.dens = (↑(Fintype.card Y) ^ 2)⁻¹

    The values at two distinct points are independent.

Instances For
    theorem Cslib.Probability.IsPairwiseIndependentHash.nonempty {ι : Type u_1} {X : Type u_2} {Y : Type u_3} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} (hh : IsPairwiseIndependentHash h) (x : X) (y : Y) :

    A pairwise independent family with a point x : X and a value y : Y has a seed.

    theorem Cslib.Probability.IsPairwiseIndependentHash.comp {ι : Type u_1} {X : Type u_2} {Y : Type u_3} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} (hh : IsPairwiseIndependentHash h) {X' : Type u_5} {e : X' → X} (he : Function.Injective e) :
    IsPairwiseIndependentHash fun (i : ι) => h i ∘ e

    Restricting a pairwise independent family along an injective map keeps it pairwise independent.

    theorem Cslib.Probability.IsPairwiseIndependentHash.comp_seedEquiv {ι : Type u_1} {X : Type u_2} {Y : Type u_3} [Fintype ι] [Fintype Y] [DecidableEq Y] {h : ι → X → Y} {ι' : Type u_5} [Fintype ι'] (hh : IsPairwiseIndependentHash h) (e : ι' ≃ ι) :
    IsPairwiseIndependentHash fun (i : ι') => h (e i)

    Relabelling seeds: precomposing the seeds of a pairwise independent family with an equivalence keeps it pairwise independent.

    theorem Cslib.Probability.IsPairwiseIndependentHash.expect_card_filter_apply_eq {ι : 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) (y : Y) :
    (Finset.univ.expect fun (i : ι) => ↑{x ∈ S | h i x = y}.card) = ↑S.card / ↑(Fintype.card Y)

    The mean cell size: #{x ∈ S | h i x = y} has expectation #S / |Y|.

    theorem Cslib.Probability.IsPairwiseIndependentHash.expect_card_filter_mul_card_filter_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) (y : Y) :
    (Finset.univ.expect fun (i : ι) => ↑{x ∈ S | h i x = y}.card * (↑{x ∈ S | h i x = y}.card - 1)) = ↑S.card * (↑S.card - 1) / ↑(Fintype.card Y) ^ 2

    The second factorial moment of the cell size: N (N - 1), the number of ordered pairs of distinct elements of the cell N = #{x ∈ S | h i x = y}, has expectation #S (#S - 1) / |Y|².

    theorem Cslib.Probability.IsPairwiseIndependentHash.expect_card_filter_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) (y : Y) :
    (Finset.univ.expect fun (i : ι) => (↑{x ∈ S | h i x = y}.card - ↑S.card / ↑(Fintype.card Y)) ^ 2) = ↑S.card / ↑(Fintype.card Y) * (1 - 1 / ↑(Fintype.card Y))

    The variance of the cell size: #{x ∈ S | h i x = y} has variance #S / |Y| * (1 - 1 / |Y|).

    theorem Cslib.Probability.IsPairwiseIndependentHash.expect_card_filter_sub_sq_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) (y : Y) :
    (Finset.univ.expect fun (i : ι) => (↑{x ∈ S | h i x = y}.card - ↑S.card / ↑(Fintype.card Y)) ^ 2) ≤ ↑S.card / ↑(Fintype.card Y)

    The variance of the cell size is at most its mean #S / |Y|.

    theorem Cslib.Probability.IsPairwiseIndependentHash.dens_filter_le_abs_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) (y : Y) {ε : 𝕜} (hε : 0 < ε) :
    ↑{i : ι | ε ≤ |↑{x ∈ S | h i x = y}.card - ↑S.card / ↑(Fintype.card Y)|}.dens ≤ ↑S.card / ↑(Fintype.card Y) / ε ^ 2

    Chebyshev's inequality for the cell size: #{x ∈ S | h i x = y} is at distance at least ε > 0 from its mean μ = #S / |Y| with probability at most μ / ε².

    theorem Cslib.Probability.IsPairwiseIndependentHash.dens_filter_mem_image_le {ι : 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) (y : Y) :
    {i : ι | y ∈ Finset.image (h i) S}.dens ≤ ↑S.card / ↑(Fintype.card Y)

    First moment bound: S hits y with probability at most the mean cell size #S / |Y|.

    theorem Cslib.Probability.IsPairwiseIndependentHash.dens_filter_notMem_image_le {ι : 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} (hS : S.Nonempty) (y : Y) :
    {i : ι | y ∉ Finset.image (h i) S}.dens ≤ ↑(Fintype.card Y) / ↑S.card

    Second moment bound: a nonempty S misses y with probability at most the inverse |Y| / #S of the mean cell size.

    theorem Cslib.Probability.IsPairwiseIndependentHash.one_sub_le_dens_filter_mem_image {ι : 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} (hS : S.Nonempty) (y : Y) :
    1 - ↑(Fintype.card Y) / ↑S.card ≤ {i : ι | y ∈ Finset.image (h i) S}.dens

    A nonempty S hits y with probability at least 1 - |Y| / #S.

    theorem Cslib.Probability.IsPairwiseIndependentHash.four_mul_card_filter_notMem_image_le {ι : 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} (hS : 4 * Fintype.card Y ≤ S.card) (y : Y) :
    4 * {i : ι | y ∉ Finset.image (h i) S}.card ≤ Fintype.card ι

    Large sets are hit: if #S ≥ 4 |Y|, at most a quarter of the seeds miss a target, in counts.

    theorem Cslib.Probability.IsPairwiseIndependentHash.four_mul_card_filter_mem_image_le {ι : 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} (hS : 4 * S.card ≤ Fintype.card Y) (y : Y) :
    4 * {i : ι | y ∈ Finset.image (h i) S}.card ≤ Fintype.card ι

    Small sets are missed: if 4 #S ≤ |Y|, at most a quarter of the seeds hit a target, in counts.

    theorem Cslib.Probability.IsPairwiseIndependentHash.sub_le_dens_filter_mem_image {ι : 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) (y : Y) :
    ↑S.card / ↑(Fintype.card Y) - ↑S.card * (↑S.card - 1) / (2 * ↑(Fintype.card Y) ^ 2) ≤ ↑{i : ι | y ∈ Finset.image (h i) S}.dens

    Inclusion–exclusion for hitting a target: S hits y with probability at least #S / |Y| - #S (#S - 1) / (2 |Y|²).

    theorem Cslib.Probability.IsPairwiseIndependentHash.three_quarters_mul_le_dens_filter_mem_image {ι : 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} (y : Y) (hS : 2 * S.card ≤ Fintype.card Y) :
    3 / 4 * (↑S.card / ↑(Fintype.card Y)) ≤ {i : ι | y ∈ Finset.image (h i) S}.dens

    The set lower bound protocol of Goldwasser and Sipser: if 2 #S ≤ |Y|, then S hits y with probability at least three quarters of the mean cell size #S / |Y| Arora and Barak, Section 8.2.

    theorem Cslib.Probability.IsPairwiseIndependentHash.sub_le_dens_filter_card_filter_eq_one {ι : 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) (y : Y) :
    ↑S.card / ↑(Fintype.card Y) - ↑S.card * (↑S.card - 1) / ↑(Fintype.card Y) ^ 2 ≤ ↑{i : ι | {x ∈ S | h i x = y}.card = 1}.dens

    Inclusion–exclusion for a unique preimage: exactly one element of S hits y with probability at least #S / |Y| - #S (#S - 1) / |Y|².

    theorem Cslib.Probability.IsPairwiseIndependentHash.three_sixteenths_le_dens_filter_card_filter_eq_one {ι : 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} (y : Y) (hS₁ : Fintype.card Y ≤ 4 * S.card) (hS₂ : 2 * S.card ≤ Fintype.card Y) :
    3 / 16 ≤ {i : ι | {x ∈ S | h i x = y}.card = 1}.dens

    The Valiant–Vazirani lemma: if |Y| ≤ 4 #S ≤ 2 |Y|, then exactly one element of S hits y with probability at least 3 / 16 Arora and Barak, Section 17.4.