Regime-switched Word-RAM cuckoo hash family #
This module realizes a cuckoo hash pair by two Word-RAM hash blocks. Below
doubleTabThreshold c_exp, each block uses (2 * maxEvictions n_max + 2)-wise independent
trinomial polynomial hashing. At or above the threshold it uses Mikkel Thorup's double
tabulation [Tho13]. The pure table and replay semantics and generic IsCuckooHashPair
contract are imported from CslibFrontier.DataStructure.Dictionary.CuckooHashing.HashFamily.
The bridge CslibFrontier.DataStructure.Dictionary.WordRAM.CuckooHashing.Analysis proves
isCuckooHashPair_provableFamily: the resulting family satisfies that contract with C_walk = 3
and C_reh = 4 for every n_max : ℕ, whenever U ≤ max n_max 4 ^ c_exp and
32 * max n_max 4 ≤ 2 ^ M. The oblivious dictionary sequence model and constants are unchanged.
Main definitions #
Seed,seedLaw,evalHash1,evalHash2: regime-switched seed space, uniform seed law, and deterministic hash evaluation.IsCuckooHashFamily: specialization of the generic hash-pair contract to this seed law and pair.HashPairRep,initTableHashPairCode,resampleHashPairCode,evalHash1Code,evalHash2Code: two-block Word-RAM layout, initialization, resampling, and evaluation programs.
Main results #
initTableHashPairCode_execWithin,resampleHashPairCode_execRand,evalHash1Code_execWithin,evalHash2Code_execWithin: program correctness.hashPairSpace_le,evalHashSteps_le:O_{c_exp}(n_max + 1)words across all capacities, and at mostevalHashBound c_expevaluation instructions wheneverU ≤ max n_max 4 ^ c_expandM ≤ max c_exp 1 * Nat.clog 2 (max n_max 4) + 5.
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). - J. L. Carter and M. N. Wegman, "Universal classes of hash functions"
Regime-switched seed space and evaluation #
Regime-indexed seed space for a single regime-switched hash block (h₁ or h₂):
- When
reg = true(n_max < doubleTabThreshold c_exp), a(2 * maxEvictions n_max + 2)-wise independent trinomial polynomial seedFin (cuckooK n_max) → Fin (2 ^ trinomialDeg U M). - When
reg = false(doubleTabThreshold c_exp ≤ n_max), a double-tabulation seed pairDoubleTabTopSeed c d b × DoubleTabBotSeed d b Mwithc = DoubleTabulation.provableC c_exp,d = DoubleTabulation.provableD c_exp, andb = DoubleTabulation.provableB n_max.
Instances For
Seed type for a single regime-switched hash block (h₁ or h₂).
Regime-indexed deterministic evaluation of a single hash block (h₁ or h₂).
Deterministic evaluation of a single regime-switched hash block (h₁ or h₂).
Regime-indexed seed space for the unconditional cuckoo hash pair (h₁, h₂).
Seed space for the regime-switched cuckoo hash pair (trinomialPolyHash below
doubleTabThreshold c_exp, doubleTabHash at or above doubleTabThreshold c_exp).
Specialization of IsCuckooHashPair to the regime-switched cuckoo hash pair
(evalHash1, evalHash2) over seedLaw c_exp n_max U M.
Proved unconditionally for every n_max : ℕ (C_walk = 3, C_reh = 4) whenever
U ≤ max n_max 4 ^ c_exp and 32 * max n_max 4 ≤ 2 ^ M via
Cslib.DataStructure.Dictionary.WordRAM.CuckooHashing.isCuckooHashPair_provableFamily.
Two-block Word-RAM hash pair representation and programs #
Word-RAM memory footprint of a single regime-switched hash instance (h₁ or h₂).
Word-RAM memory footprint of the two-block hash pair (h₁, h₂) at hashBase:
singleHashSpace c_exp n_max words at hashBase for h₁ followed by
singleHashSpace c_exp n_max words at hash2Base hashBase c_exp n_max for h₂.
Base address of the second hash instance h₂.
Constant upper bound 24 * doubleTabMinB c_exp + 26 on cuckooK n_max throughout the small
regime n_max < doubleTabThreshold c_exp.
Explicit O_{c_exp}(1) linear-space factor for hashPairSpace c_exp n_max.
All-n_max linear space bound for hashPairSpace (O_{c_exp}(n_max + 1)).
Regime-indexed seed representation for a single hash block at base.
Seed representation for a single regime-switched hash block at base.
Regime-indexed seed extraction for a single hash block at base.
Extract the seed of a single regime-switched hash block at base.
Injective register map embedding Data 18 into Data 19.
Injective register map embedding Data 12 into Data 19.
Body of copyWordsLoop: copies one word from [reg 3] to [reg 4] and increments both
pointers by reg 6 = 1.
Word-slice copy loop while reg 4 < reg 5 do copyWordsBody.
Setup block preparing copyWordsLoop to duplicate
[hashBase, hashBase + singleHashSpace c_exp n_max) into
[hash2Base hashBase c_exp n_max, hash2Base hashBase c_exp n_max + singleHashSpace c_exp n_max).
Deterministic table-initialization program for the two-block hash pair at hashBase:
in the small-n_max regime n_max < doubleTabThreshold c_exp, initializes the KWise lookup table
at hashBase and copies it to hash2Base hashBase c_exp n_max; in the large-n_max regime,
executes a 1-instruction no-op (SingleTableRep is True).
Instruction bound for initTableHashPairCode.
Shifts reg 0 (base) forward by singleHashSpace c_exp n_max (hashBase → hash2Base)
using scratch register 15.
Closed-form machine state after shiftToHash2BaseCode c_exp n_max.
Shifts reg 0 (base) back by singleHashSpace c_exp n_max (hash2Base → hashBase)
using scratch register 15.
Closed-form machine state after unshiftFromHash2BaseCode c_exp n_max.
Program resampling a single regime-switched hash block at reg 0 = base.
Program shifting reg 0 to hash2Base, resampling the second hash block, and restoring
reg 0 = hashBase.
Complete seed-resampling program resampleHashPairCode: resamples both regime-switched hash
blocks at hashBase and hash2Base hashBase c_exp n_max while preserving reg 0 = hashBase and
HashPairTableRep.
Exact instruction count of resampleSingleCode c_exp n_max M.
Exact instruction count of resampleHashPairCode c_exp n_max M.
Explicit ProbComp (Data 19 × ℕ) induced by resampleSingleCode c_exp n_max M at base.
Explicit ProbComp (Data 19 × ℕ) induced by resampleSecondBlockCode c_exp n_max M.
Exact ProbComp semantics of resampleHashPairCode c_exp n_max M.
resampleHashPairCode randomized execution: resamples both regime-switched hash blocks at
hashBase and hash2Base hashBase c_exp n_max.
Exact uniformity of resampleHashPairComp: the extracted seed
extractSeed hashBase c_exp n_max U M z.1.mem is distributed according to
seedLaw c_exp n_max U M.
Word-RAM program evaluating a single regime-switched hash block at reg 0 = base and
reg 1 = u.val into reg 2 (regOut) without modifying memory.
Word-RAM program evaluating h₁(u) into reg 2 (regOut) while preserving
reg 0 = hashBase, reg 1 = u.val, and all of memory (y.mem = x.mem).
Word-RAM program evaluating h₂(u) into reg 2 (regOut) while preserving
reg 0 = hashBase, reg 1 = u.val, and all of memory (y.mem = x.mem).
Step bound for evalSingleCode c_exp n_max.
Step bound for evalHash1Code c_exp n_max and evalHash2Code c_exp n_max.
Instruction bound on evalHashSteps c_exp n_max U M depending only on c_exp. It holds for
all n_max : ℕ whenever U ≤ max n_max 4 ^ c_exp and
M ≤ max c_exp 1 * Nat.clog 2 (max n_max 4) + 5 (evalHashSteps_le); below
doubleTabThreshold c_exp it uses cuckooK n_max ≤ cuckooKBound c_exp
(cuckooK_le_cuckooKBound_of_lt).
All-n_max constant instruction bound for evalHashSteps (O_{c_exp}(1)):
whenever U ≤ max n_max 4 ^ c_exp and M ≤ max c_exp 1 * Nat.clog 2 (max n_max 4) + 5,
evalHashSteps c_exp n_max U M ≤ evalHashBound c_exp.