Word-RAM Cuckoo Hashing: Las Vegas Rehashing and Insertion #
This module implements full-table Las Vegas rehashing (rehashLoopCode) and dictionary insertion
(insertCode) for Pagh and Rodler's cuckoo hashing dictionary [PR04] on the randomized
Word RAM, building on the layout, lookup, and bounded displacement primitives in
CslibFrontier.DataStructure.Dictionary.WordRAM.CuckooHashing.Evict.
When evictLoopCode reaches the displacement cap maxEvictions n_max during a new-key insertion,
rehashLoopCode repeatedly resamples both hash blocks via resampleAtBaseCode, clears T₁ and
T₂, and replays insKeys in insertion order until all stored keys settle. By
loopExitPMF_map_eq_uniformOfFinset, the resulting exit seed is distributed uniformly over
survivingSeeds evalHash1 evalHash2 (maxEvictions n_max) ks.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.rehashLoopCode: Las Vegas full-table resampling and insertion-order replay loop.Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.RehashLoopInv,Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.RehashLoopPost: loop invariant and exit postcondition forrehashLoopCode.Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.insertCode: dictionary insertion subroutine combining two-probe lookup, in-place overwrite, bounded displacement, and Las Vegas rehashing.
Main results #
Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.rehashLoopCode_execCodeDist: geometric Las Vegas termination, expected step bound, and exact conditional-uniform exit law for full-table rehashing.Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.insertCode_execCodeDist: distributional execution specification forinsertCodemaintainingRepWithKeysand exact surviving-seed transition.
References #
- R. Pagh and F. F. Rodler, "Cuckoo hashing" (8 December 2003 author manuscript, Section 2.3, pp. 6–10).
- M. Thorup, "Simple Tabulation, Fast Expanders, Double Tabulation, and High
Independence" (FOCS 2013, pp. 90–99;
arXiv:1311.3121v2, pp. 4–5, 11–13).
Table clearing and insertion-order replay (clearTablesCode, replayLoopCode) #
Las Vegas full-table rehashing (rehashLoopCode, rehashLoopCode_execCodeDist) #
Loop invariant for rehashLoopCode: machine configuration is word-bounded, reg 0 = base,
the header and HashPairTableRep are intact, insKeys / insVals realize (ks, s), and all
memory modifications since x₀ lie inside [base, base + space c_exp n_max).
Exit postcondition for rehashLoopCode: RehashLoopInv holds together with HashPairRep
for θ_mem = extractSeed ... z.mem and a valid replayed table tbl in T₁, T₂.
Under the ≤ 1 / 2 rehash failure probability bound hreh, every duplicate-free key list ks
of length at most n_max has a nonempty set of surviving seeds of cardinality at least half the
seed space.
Las Vegas rehash loop: synchronizes (Cond.lt 18 17) from mem[base + 16] and repeats
rehashAttemptCode while 0 < mem[base + 16].
Expected step bound for rehashLoopCode.
Geometric Las Vegas termination, expected step bound, and exact conditional-uniform exit law for
rehashLoopCode.
Dictionary insertion (insertCode, insertCode_execCodeDist) #
Full insert operation (insertCode): stores u.val = reg 3 in mem[base + 11] and
v = reg 4 in mem[base + 18], runs probeKeyCode, and branches on foundFlag = mem[base + 13]
between in-place value overwrite and new-key insertion with bounded eviction and Las Vegas rehash.
Base step overhead of insertCode outside the eviction and rehash loops.
Worst-case expected step bound of insertCode when a rehash may be triggered.
State-and-seed-dependent step bound for insertCode on insertion-order key list ks,
seed θ, dictionary state s, and key u.
Distributional execution specification for insertCode maintaining RepWithKeys and exact
conditional-uniform surviving-seed transition.