Pagh–Rodler Cuckoo Hashing on the Randomized Word RAM #
This module packages Pagh and Rodler's two-table cuckoo hashing dictionary [PR04] on the
randomized Word RAM (Cslib.WordRAM.Basis.exact and Cslib.WordRAM.Basis.standard), realizing the
bounded-capacity lookup-and-insert specification Cslib.DataStructure.Dictionary.spec U V n_max via
a composable, assumption-free Cslib.DataStructure.WordRAM.Randomized.StateTransitionImpl
certificate (seedSlack := 2, potential := 0) and an expected-amortized sequence theorem
cuckoo_seq_expected_amortized.
Design overview #
Memory layout, lookup, and bounded displacement (
CslibFrontier.DataStructure.Dictionary.WordRAM.CuckooHashing.Evict):- Contiguous
[base, base + space c_exp n_max)block ofO_{c_exp}(n_max + 1)words (space_le) storing a20-word header, the regime-switched hash pair (KWisebelowdoubleTabThreshold c_exp, Thorup'sDoubleTabulation[Tho13] at or above it), two sub-tablesT₁, T₂of sizetableSize n_max ≥ 32 * max n_max 4, and insertion-order arraysinsKeys,insVals. - Deterministic two-probe lookup
queryCode(queryCode_execWithin) and bounded displacement loopevictLoopCode(evictLoopCode_execWithin).
- Contiguous
Las Vegas rehashing and insertion (
CslibFrontier.DataStructure.Dictionary.WordRAM.CuckooHashing.Rehash):rehashLoopCoderesamples(h₁, h₂), clearsT₁, T₂, and replaysinsKeysin insertion order until all stored keys settle, yielding an exact conditional-uniform exit law oversurvivingSeeds(rehashLoopCode_execCodeDist).insertCodeupdates present keys in place and inserts absent keys via bounded displacement followed by Las Vegas rehashing on overflow (insertCode_execCodeDist).
Unconditional
O_{c_exp}(1)expected-amortized bounds (seedSlack = 2,potential = 0):- Because
Dictionary.spechas no deletion operation andrehashLoopCodereplaysinsKeysin exact insertion order, the surviving-seed set shrinks monotonically across operations, so keeping surviving seeds and rejection-sampling uniformly on overflow maintains the exact conditional uniform distribution (unifOn_rehash_eq), bounded by2 * seedLaw. - Whenever
U ≤ max n_max 4 ^ c_exp,isCuckooHashFamily_tableBitsdischargesIsCuckooHashFamily c_exp U n_max (tableBits n_max) (maxEvictions n_max) 3 4unconditionally viaisCuckooHashPair_provableFamily[PaghRodler2004, Thorup2013], givingO_{c_exp}(1)worst-case lookup andO_{c_exp}(1)expected-amortized insertion (expectedOpCharge c_exp) independent ofn_maxandU.
- Because
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.opCode: combined operation body dispatching betweenqueryCodeandinsertCode.Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.cuckooCode:SubroutineCode .exact 19 2packagingallocSpan,initSetup, andopCode.Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.charge,Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.expectedOpCharge: per-operation amortized instruction charges and capacity/universe-independentO_{c_exp}(1)charge bound.Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.impl,Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.implStandard: composable randomized Word-RAMStateTransitionImplcertificates overBasis.exactandBasis.standard.
Main results #
Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.isCuckooHashFamily_tableBits: unconditionalIsCuckooHashFamilyinstance (C_walk = 3,C_reh = 4) for everyn_max : ℕunderU ≤ max n_max 4 ^ c_exp.Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.charge_le_expectedOpCharge: boundschargebyexpectedOpCharge c_expwheneverU ≤ max n_max 4 ^ c_exp.Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.cuckoo_steps_expected_amortized,Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.cuckoo_seq_expected_amortized: continuation and end-to-end expected-time bounds across arbitrary validquery/inserthistories underU ≤ max n_max 4 ^ c_exp.
References #
- R. Pagh and F. F. Rodler, "Cuckoo hashing" (8 December 2003 author manuscript, Section 2.3, "Analysis", pp. 6–10: Lemma 1 on p. 7, Eq. (3) on p. 9, and rehash analysis on pp. 9–10).
- M. Thorup, "Simple Tabulation, Fast Expanders, Double Tabulation, and High
Independence" (FOCS 2013, pp. 90–99;
arXiv:1311.3121v2, Theorem 1(a) and Lemma 2 on pp. 4–5, and Section 3, Theorem 7(a) and Lemmas 8–9 on pp. 11–13). - M. Mitzenmacher and E. Upfal, Probability and Computing, 2nd ed.
- J. L. Carter and M. N. Wegman, "Universal classes of hash functions"
- M. N. Wegman and J. L. Carter, "New hash functions and their use in authentication and set equality"
- T. H. Cormen, C. E. Leiserson, R. L. Rivest and C. Stein, Introduction to Algorithms
Combined operation body (opCode): dispatches on reg 2 = 0 (queryCode) vs reg 2 ≠ 0
(insertCode).
State-independent expected step bound for a single opCode invocation under an arbitrary
input distribution (used in the standalone Randomized.StateTransitionImpl certificate, while
cuckoo_seq_expected_amortized establishes the tighter charge / expectedOpCharge bound along
valid trajectories from initFresh).
cuckooCode, impl, and expected-amortized sequence theorems #
Relocatable SubroutineCode bundle for Pagh–Rodler cuckoo hashing over Basis.exact.
Unconditional Pagh–Rodler cuckoo hash family certificate at tableBits n_max (C_walk = 3,
C_reh = 4):
whenever U ≤ max n_max 4 ^ c_exp, the regime-switched Word-RAM cuckoo hash pair (KWise
below doubleTabThreshold c_exp, DoubleTabulation at or above doubleTabThreshold c_exp)
satisfies IsCuckooHashFamily c_exp U n_max (tableBits n_max) (maxEvictions n_max) 3 4 for
every capacity n_max : ℕ ([PaghRodler2004], [Thorup2013]).
O(c_exp⁴) = O_{c_exp}(1) worst-case instruction bound for query via opCode c_exp n_max.
O(c_exp⁴) = O_{c_exp}(1) expected amortized instruction bound for insert (C_walk = 3,
C_reh = 4), independent of n_max and U whenever U ≤ max n_max 4 ^ c_exp.
O(c_exp⁴) = O_{c_exp}(1) expected amortized per-operation instruction charge for Pagh–Rodler
cuckoo hashing, completely independent of n_max and U whenever U ≤ max n_max 4 ^ c_exp.
Composable randomized Word-RAM StateTransitionImpl certificate for Pagh–Rodler cuckoo hashing
over Basis.exact, unconditional whenever U ≤ max n_max 4 ^ c_exp.
Standard-basis (Basis.standard) randomized StateTransitionImpl certificate for Pagh–Rodler
cuckoo hashing, unconditional whenever U ≤ max n_max 4 ^ c_exp.
Coupled multi-step execution telescope for Pagh–Rodler cuckoo hashing maintaining the exact
conditional-uniform in-memory seed marginal
PMF.uniformOfFinset (survivingSeeds evalHash1 evalHash2 (maxEvictions n_max) ks) hE across an
operation sequence ops.
Unconditional end-to-end expected-amortized theorem for Pagh–Rodler cuckoo hashing.
Whenever U ≤ max n_max 4 ^ c_exp, starting from zeroed memory in
[base, base + space c_exp n_max), initializing cuckooCode c_exp n_max and executing any valid
sequence ops : List (Dictionary.Op U) of query and insert operations takes expected
instruction cost at most spanSteps + setupSteps c_exp n_max U + (Dictionary.spec U V n_max).totalCost (expectedOpCharge c_exp) (Dictionary.empty U) ops,
where expectedOpCharge c_exp charges O(c_exp⁴) = O_{c_exp}(1) instructions per query and
insert operation (completely independent of n_max and U!) and space c_exp n_max ≤ spaceFactor c_exp * (n_max + 1) uses O_{c_exp}(n_max + 1) words of memory across every
capacity n_max : ℕ ([PaghRodler2004], [Thorup2013]).