Documentation

CslibFrontier.Probability.IID.FunctionCollision

Collisions of a function on uniform samples #

For a function f : M → β whose values lie in a finite set D, and s independent uniform samples x : Fin s → M, this module bounds from below the probability that two samples are different points with the same value under f:

1 - exp (-s (s - 1) / (2 |D|)) - C(s, 2) / |M| ≤ P(∃ i j, f (x i) = f (x j) ∧ x i ≠ x j).

This is the probabilistic content of [BS23], §8.3, Lemma 8.2 (printed p. 294), with its two error terms kept explicit. The first term is Theorem B.1(i) for the pushforward law of the values, which is not uniform in general; the proof applies Cslib.Probability.PMF.one_sub_exp_neg_le_iid_not_injective, which holds for every law. The second term bounds the probability that two samples are the same point, by the union bound Cslib.Probability.PMF.iid_not_injective_le.

Differences from [BS23] #

Main results #

References #

theorem Cslib.Probability.PMF.one_sub_exp_neg_sub_choose_le_iid_uniformOfFintype_exists_collision {M β : Type} [Fintype M] [Nonempty M] (f : M → β) (D : Finset β) (hf : ∀ (m : M), f m ∈ D) (s : ℕ) :
1 - Real.exp (-(↑s * (↑s - 1) / (2 * ↑D.card))) - ↑(s.choose 2) * (↑(Fintype.card M))⁻¹ ≤ ((iid (uniformOfFintype M) s).toOuterMeasure {x : Fin s → M | ∃ (i : Fin s) (j : Fin s), f (x i) = f (x j) ∧ x i ≠ x j}).toReal

Collisions of a function on uniform samples (the probabilistic content of [BS23], §8.3, Lemma 8.2, printed p. 294, with explicit error terms): if every value of f lies in the finite set D, then among s independent uniform samples two are different points with the same value of f with probability at least 1 - exp (-s (s - 1) / (2 |D|)) - C(s, 2) / |M|.

theorem Cslib.Probability.PMF.half_le_one_sub_exp_neg_sub_choose_of_hundred_mul_le {N K : ℕ} (hN : 0 < N) (hK : 100 * N ≤ K) :
1 / 2 ≤ 1 - Real.exp (-(↑(⌈2 * √↑N⌉₊ + 1) * (↑(⌈2 * √↑N⌉₊ + 1) - 1) / (2 * ↑N))) - ↑((⌈2 * √↑N⌉₊ + 1).choose 2) * (↑K)⁻¹

The parameters of Lemma 8.2 ([BS23], §8.3, Algorithm BirthdayAttack, printed p. 294): for K ≥ 100 N and s = ⌈2 √N⌉ + 1, 1/2 ≤ 1 - exp (-s (s - 1) / (2 N)) - C(s, 2) / K. With r = ⌈2 √N⌉, 4 N ≤ r (r + 1) ≤ 12 N.

theorem Cslib.Probability.PMF.one_eighth_le_iid_uniformOfFintype_exists_collision {M β : Type} [Fintype M] [Nonempty M] (f : M → β) (D : Finset β) (hf : ∀ (m : M), f m ∈ D) (hcard : 16 ≤ D.card) (hdomain : D.card * D.card ≤ Fintype.card M) :
1 / 8 ≤ ((iid (uniformOfFintype M) D.card.sqrt).toOuterMeasure {x : Fin D.card.sqrt → M | ∃ (i : Fin D.card.sqrt) (j : Fin D.card.sqrt), f (x i) = f (x j) ∧ x i ≠ x j}).toReal

If a function's values lie in a set D of size at least 16 and its domain has at least |D|² points, ⌊√|D|⌋ independent uniform draws contain two distinct points with the same value with probability at least 1/8.