Probabilistic cuckoo hash-pair contract #
IsCuckooHashPair packages the expected displacement, whole-set rehash, and incremental replay
failure bounds required by a cuckoo dictionary. The seed distribution and both hash functions are
arbitrary; no machine representation or concrete hash-family construction is assumed.
The contract is an original strengthened sufficient interface inspired by Pagh and Rodler
[PR04], Section 2.3 (8 December 2003 manuscript, pp. 6–10). Its walk count takes the
supremum over all valid placements, and its goodness event requires successful replay in every
insertion order. CslibFrontier.DataStructure.Dictionary.CuckooHashing proves the contract from
sufficient independence assumptions. The Word-RAM specialization is in
CslibFrontier.DataStructure.Dictionary.WordRAM.CuckooHashing.Analysis.
Main definitions #
IsCuckooHashPair: expected walk bound, whole-set failure probability at most1 / 2, and one-step replay failure bound over an arbitrary seed law.
Main results #
IsCuckooHashPair.mono_consts: monotonicity in the walk and rehash constants.isCuckooHashPair_le_two: hash-pair-independent instance forn_max ≤ 2and positive eviction cap, withC_walk = 1andC_reh = 0.
References #
- R. Pagh and F. F. Rodler, "Cuckoo hashing" (8 December 2003 author manuscript, Section 2.3, pp. 6–10).
General cuckoo hash pair interface (IsCuckooHashPair):
an original strengthened sufficient assumption bundle inspired by Pagh and Rodler [PR04]
(8 December 2003 manuscript, Section 2.3 "Analysis", pp. 6–10), asserting over a
seed distribution μ : PMF Θ and hash pair h₁ h₂ : Θ → Fin U → Fin m:
- (
expected_walk_le): for any setSof fewer thann_maxkeys and absent keyu ∉ S, the expected number of worst-case displacement roundscuckooWalkRounds(sSupover allValidPlacements ofS) is at mostC_walk(cf. [PR04], §2.3, Lemma 1 on manuscript p. 7 and Eq. (3) on manuscript p. 9); - (
rehash_prob_le_half): for any setSof at mostn_maxkeys, the probability thatθ ∼ μfailsGoodForSet(allNodupsublists inS) is at most1 / 2(so each rehash attempt succeeds with probability at least1 / 2and the surviving seed set has measure at least1 / 2); and - (
step_rehash_prob_le): for any insertion-order prefixksof fewer thann_maxdistinct keys and new keyu ∉ ks, the one-step incremental failure probability thatθ ∼ μsurvivespureReplay (h₁ θ) (h₂ θ) MaxLoop ksyet failspureReplay (h₁ θ) (h₂ θ) MaxLoop (ks ++ [u])is at mostC_reh / (max n_max 1 * max MaxLoop 1)(cf. [PR04], §2.3, manuscript pp. 9–10).
- expected_walk_le (S : Finset (Fin U)) (u : Fin U) : S.card < n_max → u ∉ S → ∑' (θ : Θ), μ θ * ↑(cuckooWalkRounds (h₁ θ) (h₂ θ) MaxLoop S u) ≤ ↑C_walk
Expected displacement rounds per new-key insertion is at most
C_walk. - rehash_prob_le_half (S : Finset (Fin U)) : S.card ≤ n_max → μ.toOuterMeasure {θ : Θ | ¬GoodForSet (h₁ θ) (h₂ θ) MaxLoop S} ≤ 1 / 2
Whole-set rehash failure probability on any key set
Sof size≤ n_maxis at most1 / 2. - step_rehash_prob_le (ks : List (Fin U)) (u : Fin U) : ks.Nodup → ks.length < n_max → u ∉ ks → μ.toOuterMeasure {θ : Θ | (pureReplay (h₁ θ) (h₂ θ) MaxLoop ks).isSome = true ∧ (pureReplay (h₁ θ) (h₂ θ) MaxLoop (ks ++ [u])).isNone = true} ≤ ↑C_reh / (max (↑n_max) 1 * max (↑MaxLoop) 1)
One-step incremental rehash probability when appending a new key
u ∉ ksto a duplicate-free key listksof length< n_maxis at mostC_reh / (max n_max 1 * max MaxLoop 1).
Monotonicity of IsCuckooHashPair in the constants C_walk and C_reh.
Reusable hash-pair-independent IsCuckooHashPair instance for n_max ≤ 2 and 0 < MaxLoop
(C_walk = 1, C_reh = 0) over any seed distribution μ and arbitrary hash pair (h₁, h₂)
(without any independence assumption): inserting up to 2 keys into two tables T₁, T₂ always
completes in 1 round with zero rehashes (even if both keys collide in T₁, the displaced first
key is placed into an empty slot of T₂).