Constant-independence cluster bounds for linear probing #
This file proves the probabilistic core of constant-time linear probing under $5$-wise independent hashing, adapting Pagh, Pagh and Ružić, Linear Probing with Constant Independence, SIAM J. Comput. 39(3):1107–1120, 2009, Section 2.3 (Lemma 2.1, pp. 1110–1111) and Section 4 (Lemma 4.1, Theorem 4.3, and Theorem 4.5, pp. 1114–1118); see also Cormen, Leiserson, Rivest and Stein, Introduction to Algorithms, Section 11.4 and Vadhan, Pseudorandomness, Section 3.5.
Source statement and proof adaptation #
In [PaghPaghRuzic2009], Lemma 2.1 (Section 2.3, pp. 1110–1111) shows that for a stored key set
$S \subseteq U$ of size $n$, a $5$-wise independent hash family $\mathcal{H} : U \to [r]$ with
maximum load $\bar{\alpha} < 1$, any subset $Q \subset [r]$ of size $q$, any $d > 0$, and any fixed
$x \in U \setminus S$, conditioning on $h(x) = \rho$ leaves a $4$-wise independent family on
$U \setminus \{x\}$ and the centered fourth-moment Markov bound gives
$\Pr[|\{y \in S : h(y) \in h(x) + Q\}| \ge \bar{\alpha} q + d] < 4 \bar{\alpha} q^2 / d^4$.
Combining Lemma 2.1 with the occupied-run witness in Lemma 4.1 (Section 4, p. 1114), Theorem 4.3
(Section 4.1, pp. 1115–1116) and Theorem 4.5 (Section 4.2, p. 1118) bound the expected number of
probes per operation by $O((1 - \bar{\alpha})^{-5/2})$ and $O((1 - \bar{\alpha})^{-13/6})$ for any
maximum load $\bar{\alpha} < 1$.
Our formalization specializes to a power-of-$2$ table of size $m = 2^M \ge 8 n_{\max}$ (exact
uniform load factor $\bar{\alpha} = \alpha = \#S / 2^M \le 1/8$) and an exact uniform $5$-wise
independent family $h : \iota \to X \to \mathrm{Fin}(2^M)$ (IsKWiseIndependentHash 5 h), using an
original simplified dyadic-window proof adaptation in place of the interval-grid decompositions of
Lemmas 4.2 and 4.4 in [PaghPaghRuzic2009]:
- Left-anchored cluster witness (
HasClusterWitness, adapting the proof of Lemma 4.1, p. 1114): If probing key $u$ from $b = h_i(u)$ steps over $t \ge 1$ occupied slots belonging to $S = \mathrm{dom}(s) \setminus \{u\}$, walking backwards from $b$ to the nearest preceding empty slot yields a contiguous cyclic interval $J(b, a, \ell)$ (cyclicInterval M b a ℓ) of length $\ell = a + t \in [t, \#S]$ containing $b$ into which at least $\ell$ keys of $S$ hash. - Centered dyadic-scale window (
scaleWindow, original proof adaptation at load $\le 1/8$): For the dyadic scale $j = \lfloor \log_2 \ell \rfloor + 1 \in \{1, \dots, M\}$, we have $2^{j-1} \le \ell < 2^j$. Every cyclic interval $J(b, a, \ell)$ containing $b$ is contained in a single centered window $W_j(b)$ (scaleWindow M b j) of size at most $2^{j+1}$ (cyclicInterval_subset_scaleWindow,card_scaleWindow_le). Consequently, at least $2^{j-1}$ keys of $S$ hash into $W_j(b)$, whereas at load $\#S \le 2^M / 8$ the expected load of $W_j(b)$ is $\mu_{j,b} \le \#S \cdot 2^{j+1} / 2^M \le 2^{j-2}$, leaving deviation slack $2^{j-1} - \mu_{j,b} \ge 2^{j-2}$. - Conditioned fourth-moment tail bound (
expect_indicator_mul_sum_pow_four_leandexpect_scaleOverload_le, adapting Lemma 2.1, pp. 1110–1111): Conditioning on $h_i(u) = b$ consumes $1$ degree of independence, leaving $4$-wise independence on $S$. Expanding the fourth central moment viaIsKWiseIndependentHash.expect_prodon sets $\mathrm{insert}\ u\ (\mathrm{image}\ t)$ of size at most $5$ bounds the scale-$j$ overload probability (scaleOverload) by $18 / (2^{j-2})^2 = 288 / 4^j$, and summing $\sum_{j=1}^M 2^j \cdot (288 / 4^j)$ yields the original explicit constant upper bound $288 = O(1)$ on the expected number of skipped occupied slots (expect_probe_le_of_cluster_witness,tsum_uniform_probe_le_of_cluster_witness).
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.tableLog,Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.tableSize: power-of-$2$ table bit-width $M = \lceil \log_2 \max(8 n_{\max}, 8) \rceil$ and capacity $2^M$.Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.cyclicSlotMod,Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.probeSlot,Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.backSlot,Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.cyclicInterval,Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.scaleWindow: cyclic slot indexing, forward/backward slot offsets, contiguous cyclic intervals containing $b$, and centered dyadic-scale windows $W_j(b)$.Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.scaleOverload,Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.HasClusterWitness: scale-$j$ window overload event $2^{j-1} \le \#\{x \in S \mid h_i(x) \in W_j(h_i(u))\}$ and left-anchored cluster-witness predicate.
Main results #
Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.eight_mul_le_tableSize,Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.tableSize_le_sixteen_mul: load-factor and linear-space bounds fortableSize.Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.card_cyclicInterval: a cyclic interval of length $\mathrm{len} \le 2^M$ has cardinality $\mathrm{len}$.Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.expect_indicator_mul_sum_pow_four_le: fourth-moment bound for centered bucket indicators conditioned on $h_i(u) = b$ under $5$-wise independence.Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.le_sum_scaleOverload_of_cyclicInterval: a cyclic interval at dyadic scale $j$ holding $2^{j-1}$ keys overloads scale $j$, bounding every $k \le 2^j$ by the dyadic scale-overload sum.Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.expect_scaleOverload_le: scale-$j$ overload probability bound $\le 288 / 4^j$.Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.expect_probe_le_of_cluster_witness,Cslib.DataStructure.Dictionary.WordRAM.LinearProbing.tsum_uniform_probe_le_of_cluster_witness: expected probe count $\le 288$ underFinset.expectandPMF.uniformOfFintype.
References #
Section 1: Table size parameters and load-factor bounds #
Base-2 logarithm $M = \lceil \log_2 \max(8 n_{\max}, 8) \rceil$ of the linear-probing table size, ensuring $M \ge 3$ and $8 n_{\max} \le 2^M < 16 \max(n_{\max}, 1)$.
Power-of-$2$ table size $m = 2^{\mathrm{tableLog}(n_{\max})}$.
Section 2: Fourth central moment under $5$-wise independence conditioned on $h_i(u) = b$ #
Centered indicator of a bucket subset W ⊆ Y: 1 - #W / |Y| on W and - #W / |Y| outside
W.
The uniform expectation of bucketCentered W over a nonempty finite type Y is 0.
bucketCentered W y always has absolute value at most 1.
The second moment of bucketCentered W is at most p = #W / |Y|.
Any moment of degree c ≥ 2 of bucketCentered W has absolute value at most
p = #W / |Y|.
Conditioned fourth-moment bound under $5$-wise independence: for a $5$-wise independent
family h : ι → X → Y, a finite set S ⊆ X, a query point u ∉ S, a target bucket b : Y, and a
window W ⊆ Y of density p = #W / |Y|, the expectation of
(if h i u = b then 1 else 0) * (∑ x ∈ S, bucketCentered W (h i x)) ^ 4 is at most
(𝔼 y, if y = b then 1 else 0) * (#S * p + 16 * (#S * p) ^ 2).
Section 3: Cyclic intervals, scale windows, and expected probe bound #
The scale window scaleWindow M b j has at most 2 ^ (j + 1) elements.
Every cyclic interval cyclicInterval M b a len with a < 2 ^ j and len ≤ 2 ^ j is a
subset of the centered window scaleWindow M b j.
Scale-$j$ window overload event: at least $2^{j-1}$ keys of $S$ hash into the centered window
scaleWindow M (h i u) j around $h_i(u)$.
Instances For
Scale-$j$ overload probability bound: when 8 * n_max ≤ 2 ^ M, #S ≤ n_max, u ∉ S and
hh : IsKWiseIndependentHash 5 h, the probability of scaleOverload M h S u j is at most
288 / (2 ^ j : ℝ) ^ 2. At j = 0 this is the trivial bound 288.
Left-anchored cluster witness predicate for hash family h at (S, u, i, t): if 1 ≤ t,
there is a cyclic interval cyclicInterval M (h i u) a ℓ of length ℓ ∈ [t, #S] with a < ℓ
into which at least ℓ keys of S hash.
Instances For
Dyadic scale bound. Let j = Nat.log 2 x + 1 be the dyadic scale of 1 ≤ x < 2 ^ M. If
a cyclic interval cyclicInterval M (h i u) a len with a < 2 ^ j and len ≤ 2 ^ j holds at
least 2 ^ (j - 1) keys of S, the scale-j window is overloaded, so every k ≤ 2 ^ j is
bounded by the dyadic scale-overload sum.
If a nonnegative probe count probe : ι → ℕ satisfies the left-anchored cluster witness
property — every seed i with 1 ≤ probe i has an occupied cyclic interval
cyclicInterval M (h i u) a ℓ of length ℓ ∈ [probe i, #S] with 0 ≤ a < ℓ into which at
least ℓ keys of S hash — then under a 5-wise independent hash family at load factor
8 * n_max ≤ 2 ^ M and #S ≤ n_max, the expected probe count is at most 288.
Natural-number sum form of expect_probe_le_of_cluster_witness: the sum of probe i over all
seeds i : ι is at most 288 * Fintype.card ι.
ℝ≥0∞ expectation form of expect_probe_le_of_cluster_witness under PMF.uniformOfFintype:
∑' i, (PMF.uniformOfFintype ι) i * (probe i : ℝ≥0∞) ≤ 288.