Odd-Stride Double Hashing under Limited Independence and Double Tabulation #
This module proves $O(1)$ expected probes for power-of-two odd-stride double hashing
oddStridePerm h₁ h₂ u i = (h₁(u) + i * (2 * h₂(u) + 1)) mod 2 ^ M ([CLRS09], Section 11.4,
pp. 272–274) over open-addressed tables
Cslib.DataStructure.Dictionary.UniformProbing.Table U (2 ^ M)
with key universe size U, table bit-width M (m = 2 ^ M slots), and maximum stored key count
n_max. The bound holds both under $(2 L + 1)$-wise independence for probe cutoff
L = maxProbeCutoff n_max = Nat.clog 2 (max n_max 4) + 4 and under Mikkel Thorup's Double
Tabulation ([Thorup2013], Theorem 1(a) and Lemma 2) with c characters of b bits
(U ≤ 2 ^ (c * b)) or polynomial universe exponent c_exp (U ≤ max n_max 4 ^ c_exp).
Under the hypotheses of the cited theorems, the expected probe count is at most 2 under
$(2 L + 1)$-wise independence (expect_probeCount_oddStride_of_kWiseIndependent) and at most 3
under Double Tabulation with an explicit code bound
(expect_probeCount_oddStride_doubleTab_of_codeBound_le). For the exponent c_exp, the bound 3
is proved for doubleTabThreshold c_exp ≤ n_max (expect_probeCount_oddStride_doubleTab_le), where
doubleTabThreshold c_exp = 2 ^ (2 * doubleTabMinB c_exp) ≥ 2 ^ 25088. Below the threshold the
proof uses only the deterministic bound probeCount ≤ n_max + 1 (probeCount_le_add_one), valid
for every probe permutation family representing the table; together the two cases give
max (doubleTabThreshold c_exp : ℝ≥0∞) 3 for every n_max
(expect_probeCount_oddStride_unconditional_le).
Source statements and notation mapping #
- J. P. Schmidt and A. Siegel ([SS90], STOC 1990, pp. 224–234; extended NYU Courant
Technical Report
TR1995-687, May 1995, pp. 1–2, 4–7, 37–39):- Definition 1 (
TR1995-687, p. 2): Sequential closed-hashing insertion of a key set $D$ into a table of size $n$ ([0..n - 1]) over universe $[0..m - 1]$ along $1$-indexed per-key probe sequences $p(x, 1), p(x, 2), \dots$ and affine double hashing. Here we map table size to $m = 2^M$ (Fin (2 ^ M)), universe toFin U, and probe sequences to $0$-indexed permutationsπ u i. - Definition 2 (
Models UH, DH, and DH_ψ,TR1995-687, pp. 4–5): Formulates two-probe slot uniformity (Condition 1, p. 4) and $\psi$-wise cross-key probe independence for $\psi = c \log n$ (Condition 2, p. 5). - Definition 3 and Equation (1) (
[SchmidtSiegel1990], Theorem 1;TR1995-687, pp. 6–7): Defines the dependency set $\mathrm{dep}(x, D)$, dependency DAG $G(x, D)$, and partial dependency DAG $G_r(x, D)$ (vertices reachable from $x$ starting along the first $r$ probes of $x$). At bounded load factor $\alpha \le 1 / 32$, the trivial vacancy overestimator $q(i) \equiv 1$ yields $O(1)$ expected probes by bounding the probability of size-$w$ partial dependency witnesses without the vacancy inclusion-exclusion machinery needed for $\alpha \to 1$. - Appendix A, Lemma A (
TR1995-687, pp. 37–39): Bounds the probability that a $w$-vertex subset hashes into a dependency tree (Part 1, pp. 37–38) or into a non-tree dependency DAG with spanning tree $Tr$ (Part 2, pp. 38–39) by charging one non-tree collision per vertex with a diamond edge.
- Definition 1 (
- M. Thorup ([Tho13], FOCS 2013, pp. 90–99; arXiv:1311.3121v2, 16 October 2018, Section 1.1
Theorem 1(a) and Lemma 2, and Section 3, pp. 4–5, 11–13):
Conditioned on $k$-uniqueness (
IsKUnique k (simpleTabTuple T₁)),doubleTabHashis $k$-wise independent (isKWiseIndependentHash_doubleTabHash_of_isKUnique), and the fraction of non-$k$-unique top seeds is at most $2 (\mathrm{doubleTabCodeBound}\ c\ (8c)\ 4\ k)^2 / 2^{6b}$ (card_not_isKUnique_eight_mul_le). - Original elementary adaptations:
- Breadth-first search (
BFS) spanning-tree ordering: We order the vertices of a closed partial dependency set $W = \mathrm{partialDepSet}(x_0, r)$ by a flat BFS queue. Every non-tree probe of $x_b$ then hits a slot in the set $F_{< b}$ of slots already enqueued before $x_b$'s expansion, while the $h_{b+1}$ new tree-child slots of $x_b$ are the first $h_{b+1}$ slots of $[\pi(x_b, 0), \dots, \pi(x_b, w - 1)]$ outside $F_{< b}$ independently of the landing index $k_b$. - Power-of-two quotient fiber bound (
Nat.card_odd_mul_mod_eq_le): On $m = 2^M$, an even probe-index difference $\Delta = k_b - j_1 \in [1, w]$ is not invertible mod $2^M$, but the Euclidean quotient map $s \mapsto \lfloor \Delta(2s + 1)/2^M \rfloor \in \mathrm{Fin}\ \Delta$ bounds the stride fiber by $\Delta \le w$. - Deterministic pigeonhole bound & high-probability conditioning bridge: Every odd stride
$2 h_2(u) + 1$ is coprime to $2^M$, so
oddStridePermis a full-cycle permutation on every seed andprobeCount ≤ n_max + 1holds deterministically (probeCount_le_add_one). This bounds both the bad-top-seed tail for $n_{\max} \ge \mathrm{doubleTabThreshold}\ c_{\exp}$ and the entire small-capacity regime $n_{\max} < \mathrm{doubleTabThreshold}\ c_{\exp}$.
- Breadth-first search (
Main definitions #
Cslib.DataStructure.Dictionary.DoubleHashing.OrderedTableRep: open-addressed representation invariant extendingUniformProbing.TableRepwith an acyclic insertion-order rank.Cslib.DataStructure.Dictionary.DoubleHashing.oddStrideSeq,Cslib.DataStructure.Dictionary.DoubleHashing.oddStridePerm,Cslib.DataStructure.Dictionary.DoubleHashing.twoStageOddStridePerm: full-cycle odd-stride double-hashing probe sequence and permutation families onFin (2 ^ M).Cslib.DataStructure.Dictionary.DoubleHashing.maxProbeCutoff,Cslib.DataStructure.Dictionary.DoubleHashing.DoubleTabOddStrideSeed,Cslib.DataStructure.Dictionary.DoubleHashing.doubleTabOddStridePerm,Cslib.DataStructure.Dictionary.DoubleHashing.DoubleHashSeed,Cslib.DataStructure.Dictionary.DoubleHashing.doubleHashOddStridePerm: cutoff parameter and Double Tabulation seed types and permutation families.
Main results #
Cslib.DataStructure.Dictionary.DoubleHashing.OrderedTableRep.empty,Cslib.DataStructure.Dictionary.DoubleHashing.OrderedTableRep.tableInsert,Cslib.DataStructure.Dictionary.DoubleHashing.orderedTableRep_runTable,Cslib.DataStructure.Dictionary.DoubleHashing.exists_orderedTableRep: preservation and existence ofOrderedTableRep.Cslib.DataStructure.Dictionary.DoubleHashing.sum_probeCount_oddStride_le_of_kWiseIndependent,Cslib.DataStructure.Dictionary.DoubleHashing.expect_probeCount_oddStride_of_kWiseIndependent: expected probe count $\le 2$ under $(2 L + 1)$-wise independent $(h_1, h_2)$.Cslib.DataStructure.Dictionary.DoubleHashing.sum_probeCount_oddStride_of_whp_kWiseIndependent,Cslib.DataStructure.Dictionary.DoubleHashing.expect_probeCount_oddStride_of_whp_kWiseIndependentexpected probe count $\le 3$ under high-probability $(2 L + 1)$-wise independence.Cslib.DataStructure.Dictionary.DoubleHashing.sum_probeCount_oddStride_doubleTab_le,Cslib.DataStructure.Dictionary.DoubleHashing.expect_probeCount_oddStride_doubleTab_le,Cslib.DataStructure.Dictionary.DoubleHashing.expect_probeCount_oddStride_unconditional_le: expected probe count $\le 3$ under Double Tabulation for $n_{\max} \ge \mathrm{doubleTabThreshold}\ c_{\exp}$, and $\le \max(\mathrm{doubleTabThreshold}\ c_{\exp}, 3)$ for all $n_{\max}$.
References #
- T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to Algorithms, third edition (MIT Press, 2009), Section 11.4, pp. 269–277
- J. P. Schmidt and A. Siegel, The Analysis of Closed Hashing under Limited Randomness
- M. Thorup, Simple Tabulation, Fast Expanders, Double Tabulation, and High Independence
Section 1: Acyclic Insertion-Order Invariant (OrderedTableRep) #
Open-addressed table representation invariant extending TableRep π s T with an acyclic
insertion-order witness rank : Fin U → ℕ: for every stored key w ∈ Dictionary.dom s and every
failed probe index i : Fin m with i.val < missedProbes (otherOccupiedSlots T w) (π w), the slot
π w i holds a distinct key y ∈ (Dictionary.dom s).erase w with rank y < rank w.
- slot_spec (j : Fin m) (u : Fin U) (v : ℕ) : T j = some (u, v) → s u = some v ∧ ∃ (h : missedProbes (otherOccupiedSlots T u) (π u) < m), j = (π u) ⟨missedProbes (otherOccupiedSlots T u) (π u), h⟩
- key_spec (u : Fin U) (v : ℕ) : s u = some v → ∃ (h : missedProbes (otherOccupiedSlots T u) (π u) < m), T ((π u) ⟨missedProbes (otherOccupiedSlots T u) (π u), h⟩) = some (u, v)
- exists_rank : ∃ (rank : Fin U → ℕ), ∀ w ∈ dom s, ∀ (i : Fin m), ↑i < UniformProbing.missedProbes (UniformProbing.otherOccupiedSlots T w) (π w) → ∃ y ∈ (dom s).erase w, ∃ (vy : ℕ), T ((π w) i) = some (y, vy) ∧ rank y < rank w
Existence of an insertion-order ranking under which every failed probe of a stored key
wis blocked by a strictly lower-ranked keyy ∈ (Dictionary.dom s).erase w.
The empty table satisfies OrderedTableRep under any permutation family π.
Preservation of OrderedTableRep under tableInsert: if OrderedTableRep π s T and
(otherOccupiedSlots T u).card < m, then tableInsert hm π T u v satisfies
OrderedTableRep π (Function.update s u (some v)).
Convenience wrapper for OrderedTableRep.tableInsert when (Dictionary.dom s).card < m.
Any valid operation history preserves OrderedTableRep.
Running any valid operation history from emptyTable U m produces a table satisfying
OrderedTableRep.
Every finite dictionary state s with (Dictionary.dom s).card ≤ m admits an open-addressed
table T : Table U m satisfying OrderedTableRep π s T for any permutation family
π : Fin U → Equiv.Perm (Fin m).
Power-of-two odd-stride double-hashing probe sequence
oddStrideSeq M p s i = (p + i * (2 * s + 1)) mod 2 ^ M on Fin (2 ^ M) ([CLRS09], Section 11.4,
"Double hashing", pp. 272–274).
Because 2 * s.val + 1 is odd and therefore coprime to 2 ^ M, oddStrideSeq M p s is a
bijection on Fin (2 ^ M) for every p and s.
Noncomputable full-cycle permutation Equiv.Perm (Fin (2 ^ M)) induced by primary hash value
p : Fin (2 ^ M) and stride index s : Fin (2 ^ (M - 1)).
Odd-stride double-hashing permutation family Fin U → Equiv.Perm (Fin (2 ^ M)) constructed
from a primary hash function h₁ : Fin U → Fin (2 ^ M) and a half-range stride hash function
h₂ : Fin U → Fin (2 ^ (M - 1)).
Section 3: Dependency Sets and the Minimal Overflow Dichotomy #
Section 4: BFS Spanning-Tree Witness and (2 * L + 1)-Wise Independent Probe Bound #
Seed-Sum Probe-Count Bound under (2 * L + 1)-Wise Independence:
for 1 ≤ M, 32 * max n_max 4 ≤ 2 ^ M, 2 * (2 * maxProbeCutoff n_max) ^ 4 ≤ 2 ^ M, and
any (2 * maxProbeCutoff n_max + 1)-wise independent hash families h₁ and h₂, the sum of
probeCount (T θ) u (oddStridePerm (h₁ θ.1) (h₂ θ.2) u) over all θ : Θ₁ × Θ₂ is at most
2 * Fintype.card (Θ₁ × Θ₂).
Expected Probe-Count Bound under (2 * L + 1)-Wise Independence:
under the hypotheses of sum_probeCount_oddStride_le_of_kWiseIndependent, the expected probe count
of u under PMF.uniformOfFintype (Θ₁ × Θ₂) is at most 2 ([SS90], Theorem 1).
Section 5: High-Probability Conditioning Bridge & Double Tabulation Instantiation #
Odd-stride double-hashing permutation family on a two-stage seed pair
((top₁, bottom₁), (top₂, bottom₂)) : (Θ_top₁ × Θ_bot₁) × (Θ_top₂ × Θ_bot₂).
High-Probability Conditioning Bridge for Odd-Stride Double Hashing:
if H₁ top₁ and H₂ top₂ are (2 * maxProbeCutoff n_max + 1)-wise independent whenever
Good₁ top₁ and Good₂ top₂ hold, and the bad top-seed sets Finset.univ.filter (¬ Goodᵢ ·)
each have density at most 1 / (2 * (n_max + 1)), then the sum of probeCount over all seeds
θ : (Θ_top₁ × Θ_bot₁) × (Θ_top₂ × Θ_bot₂) is at most 3 times the total number of seeds.
Expected Probe-Count Bound under High-Probability (2 * L + 1)-Wise Independence:
under the hypotheses of sum_probeCount_oddStride_of_whp_kWiseIndependent, the expected probe count
of u under PMF.uniformOfFintype ((Θ_top₁ × Θ_bot₁) × (Θ_top₂ × Θ_bot₂)) is at most 3.
Odd-stride double-hashing permutation family driven by two independent doubleTabHash
instances ([Thorup2013], Theorem 1(a)).
Double Tabulation Summed Probe-Count Bound under Explicit Code Bound ([Thorup2013],
Theorem 1(a) & [SchmidtSiegel1990], Theorem 1):
when 1 ≤ c, U ≤ 2 ^ (c * b), 1 ≤ M, 32 * max n_max 4 ≤ 2 ^ M,
2 * (2 * maxProbeCutoff n_max) ^ 4 ≤ 2 ^ M, and
2 * (n_max + 1) * doubleTabCodeBound c (8 * c) 4 (2 * maxProbeCutoff n_max + 1) ≤ 2 ^ (3 * b),
the sum of probeCount over all seeds in DoubleTabOddStrideSeed c b M is at most 3 times the
total number of seeds.
Expected Probe-Count Bound for Double Tabulation Odd-Stride Double Hashing under Explicit Code
Bound: under the hypotheses of sum_probeCount_oddStride_doubleTab_of_codeBound_le, the expected
probe count of u under PMF.uniformOfFintype (DoubleTabOddStrideSeed c b M) is at most 3.
Canonical Double Tabulation seed space for odd-stride double hashing at polynomial universe
exponent c_exp, capacity n_max, and table bit-width M.
Canonical Double Tabulation odd-stride permutation family at polynomial universe exponent
c_exp, capacity n_max, universe size U, and table bit-width M.
Summed Probe-Count Bound for Double Tabulation Odd-Stride Double Hashing above
doubleTabThreshold c_exp ([Thorup2013], Theorem 1(a) & [SchmidtSiegel1990], Theorem 1):
whenever doubleTabThreshold c_exp ≤ n_max, U ≤ max n_max 4 ^ c_exp, and
32 * max n_max 4 ≤ 2 ^ M, the sum of probeCount over all seeds in
DoubleHashSeed c_exp n_max M is at most 3 times the total number of seeds.
O(1) Expected Probes (≤ 3) for Double Tabulation Odd-Stride Double Hashing above
doubleTabThreshold c_exp ([Thorup2013], Theorem 1(a) & [SchmidtSiegel1990], Theorem 1):
whenever doubleTabThreshold c_exp ≤ n_max, U ≤ max n_max 4 ^ c_exp, and
32 * max n_max 4 ≤ 2 ^ M, the expected probe count of u under
PMF.uniformOfFintype (DoubleHashSeed c_exp n_max M) is at most 3.
O_{c_exp}(1) Expected Probe-Count Bound without a Threshold on n_max : ℕ:
whenever U ≤ max n_max 4 ^ c_exp and 32 * max n_max 4 ≤ 2 ^ M, combining the deterministic
full-cycle pigeonhole bound probeCount ≤ n_max + 1 ≤ doubleTabThreshold c_exp for
n_max < doubleTabThreshold c_exp with the Double Tabulation bound ≤ 3 for
doubleTabThreshold c_exp ≤ n_max yields expected probe count at most
max (doubleTabThreshold c_exp : ℝ≥0∞) 3 = doubleTabThreshold c_exp for every n_max : ℕ. Below
the threshold the bound uses no independence property of Double Tabulation.