Double Tabulation and High Independence ([Thorup2013]) #
This module formalizes the double tabulation hash family and its universal k-uniqueness analysis
following Mikkel Thorup, "Simple Tabulation, Fast Expanders, Double Tabulation, and High
Independence", Proc. 54th IEEE Symposium on Foundations of Computer Science (FOCS 2013),
pp. 90–99, 2013 (arXiv:1311.3121v2, 16 October 2018) [Tho13].
Given keys split into c characters from Φ = Fin (2 ^ b), a first-level simple tabulation table
T₁ : Fin c → Fin d → Fin (2 ^ b) → Fin (2 ^ b) maps each key x : Fin c → Fin (2 ^ b) to an
intermediate d-tuple simpleTabTuple T₁ x : Fin d → Fin (2 ^ b) by XORing the c character
table lookups in each output coordinate j : Fin d. Composing simpleTabTuple T₁ with an
independent second-level simple tabulation table T₂ : Fin d → Fin (2 ^ b) → Fin (2 ^ M) yields
the double tabulation hash doubleTabHash c d b U M T₁ T₂ : Fin U → Fin (2 ^ M).
Source statements and notation mapping #
In Thorup [Tho13] (arXiv:1311.3121v2):
k-uniqueness (IsKUnique, Section 1.1, p. 4): For an output alphabetΨ = Fin (2 ^ b), a functionf : U → Ψ ^ disk-unique if every non-empty subsetX ⊆ Uof size|X| ≤ khas a unique output position character(j₀, f(x₀)_{j₀}), i.e., somex₀ ∈ Xandj₀ ∈ [d]such thatf(x₀)_{j₀} ≠ f(x)_{j₀}for allx ∈ X \ {x₀}.- Siegel's peeling lemma (
isKWiseIndependentHash_of_isKUnique, Section 1.1, Lemma 2, p. 5; Appendix A, p. 19): Iff : α → (Fin d → β)isk-unique andr : Fin d → β → Fin (2 ^ M)is a uniformly random simple tabulation table, thenr ∘ f : α → Fin (2 ^ M)isk-wise independent (IsKWiseIndependentHash k). - Derivable output characters and efficient coding (Section 2, Definition 6, pp. 9–10;
Eqs. (6)–(7), p. 11): For a list
Lofℓdistinct input position characters in[c] × Φ, an output index(α, j) ∈ L × [d]is derivable if there existx, y ∈ Xwhose symmetric differenceA = x △ y ⊆ Lhasαas its last element inLand satisfiesh(x)_j = h(y)_j(equivalentlyh(α)_j = ⨁_{β ∈ A \ {α}} h(β)_j). FixingL(≤ (c |Φ|) ^ ℓchoices) andq ℓequations(A_r, j_r)(≤ (ℓ ^ (2 c) d) ^ (q ℓ)choices) with distinct last-in-Loutput indices determinesq ℓentries ofT₁in terms of earlier entries inL, leaving at most|Θ_top| / |Ψ| ^ (q ℓ)compatible tablesT₁(Eqs. (6)–(7), p. 11). - Many derivable output characters (Section 3, Theorem 7(a) and Lemma 8, p. 12; Lemma 9 and
Eqs. (8)–(11), pp. 12–13): For a violating set
X(|X| ≤ k), order itsℓ* ≤ c |X|active input position charactersα₁, …, α_{ℓ*}by decreasing frequencyn₁ ≥ … ≥ n_{ℓ*} ≥ 1(∑ n_i = c |X|). Lettingγ_{≤ ℓ}count pairs(x, j) ∈ X × [d]whose symmetric-difference witnessx △ ywithh(x)_j = h(y)_jlies in the prefixL_{≤ ℓ} = {α₁, …, α_ℓ}and lettingϕ_ℓcount derivable output indices(α_ℓ, j)at stepℓ, Lemma 8 (p. 12) givesγ_{≤ ℓ*} = d |X|and Lemma 9 (Eq. (8), p. 12) givesγ_{≤ ℓ} - γ_{≤ ℓ - 1} ≤ 2 ϕ_ℓ n_ℓ. By summation by parts (Eqs. (9)–(11), pp. 12–13), whend = 2 q c, some prefixL_{≤ ℓ}(2 ≤ ℓ ≤ c k) has∑_{i=1}^ℓ ϕ_i ≥ q ℓderivable output characters. - Original adaptations:
- In Theorem 1(a) and Section 2 (pp. 4, 11), Thorup states the failure probability asymptotically
as
o(|Φ| ^ 2 / |Ψ| ^ (d / (2 c)))underc = |Φ| ^ o(1)and(c + d) ^ c = |Ψ| ^ o(1). Herecard_not_isKUnique_leandcard_not_isKUnique_eight_mul_leestablish an explicit non-asymptotic finite-seed bound for allc, q, b ≥ 1andd = 2 q cwhenever2 * (c * ((c * k) ^ (2 * c) * d) ^ q) ≤ 2 ^ ((q - 1) * b). - Each non-empty symmetric difference
A ⊆ range(L)of size|A| ≤ 2 cis parameterized in Section 4 by a tupleg : Fin (2 * c) → Fin ℓwhose image inFin ℓhas maximum indexlastIdx g, giving an exactFintype.cardcount(ℓ ^ (2 * c) * d) ^ (q * ℓ).
- In Theorem 1(a) and Section 2 (pp. 4, 11), Thorup states the failure probability asymptotically
as
Main definitions #
Cslib.Probability.IsKUnique:k-uniqueness of a tuple-valued functionf : α → Fin d → β([Tho13], Section 1.1, p. 4).Cslib.Probability.simpleTabAddHom,Cslib.Probability.simpleTabEval: simple tabulation over an additive commutative group and overFin (2 ^ M)via bitwise XOR (BitString.equivFin M).Cslib.Probability.charDigits: base-2 ^ bcharacter extractionFin U → Fin c → Fin (2 ^ b).Cslib.Probability.simpleTabTuple: first-level simple tabulation(Fin c → Fin d → Fin (2 ^ b) → Fin (2 ^ b)) → (Fin c → Fin (2 ^ b)) → (Fin d → Fin (2 ^ b)).Cslib.Probability.DoubleTabTopSeed,Cslib.Probability.DoubleTabBotSeed,Cslib.Probability.doubleTabHash,Cslib.Probability.doubleTabCodeBound,Cslib.Probability.doubleTabMinB,Cslib.Probability.doubleTabThreshold: seed types, composed double tabulation hashFin U → Fin (2 ^ M), per-step code-counting factorc * ((c * k) ^ (2 * c) * d) ^ q, minimum character bit-widthdoubleTabMinB c_exp, and capacity thresholddoubleTabThreshold c_exp = 2 ^ (2 * doubleTabMinB c_exp).
Main results #
Cslib.Probability.isKWiseIndependentHash_of_isKUnique: Siegel's peeling lemma ([Tho13], Lemma 2, p. 5 & Appendix A, p. 19).Cslib.Probability.charDigits_injective:charDigits c bis injective whenU ≤ 2 ^ (c * b).Cslib.Probability.isKWiseIndependentHash_doubleTabHash_of_isKUnique: whenT₁isk-unique andU ≤ 2 ^ (c * b),T₂ ↦ doubleTabHash c d b U M T₁ T₂isk-wise independent.Cslib.Probability.card_not_isKUnique_le,Cslib.Probability.card_not_isKUnique_eight_mul_le,Cslib.Probability.four_le_doubleTabThreshold: explicit universalk-uniqueness bounds forsimpleTabTuple T₁([Tho13], Theorem 1(a), Section 2 Eqs. (6)–(7), Section 3 Theorem 7(a) and Lemmas 8–9) and threshold lower bound4 ≤ doubleTabThreshold c_exp.
References #
Section 1: k-uniqueness and Siegel's peeling lemma #
k-uniqueness ([Tho13], Section 1.1, p. 4): a tuple map f : α → Fin d → β is
k-unique if every non-empty subset X ⊆ α of size #X ≤ k contains a key x₀ ∈ X and output
coordinate j₀ : Fin d whose value f x₀ j₀ differs from f x j₀ for all other x ∈ X.
Instances For
Precomposing a k-unique function f : α → Fin d → β with an injective map g : α' → α
preserves k-uniqueness.
Simple tabulation evaluation over an additive commutative group γ as an additive homomorphism
(Fin d → β → γ) →+ (α → γ).
Siegel's Peeling Lemma ([Tho13], Section 1.1, Lemma 2, p. 5 & Appendix A, p. 19):
If f : α → Fin d → β is k-unique (IsKUnique k f), then composing f with a uniformly random
simple tabulation table r : Fin d → β → Fin (2 ^ M) yields a k-wise independent hash family
α → Fin (2 ^ M).
Section 2: Base-2 ^ b character extraction and double tabulation #
Injectivity of charDigits: when U ≤ 2 ^ (c * b), distinct keys in Fin U have distinct
c-tuples of b-bit characters.
First-level simple tabulation ([Thorup2013], Eq. (2), p. 3 & Theorem 1, p. 4): maps each
character tuple x : Fin c → Fin (2 ^ b) to an intermediate d-tuple Fin d → Fin (2 ^ b) by
XORing T₁ i j (x i) across i : Fin c in each output coordinate j : Fin d.
Mikkel Thorup's Double Tabulation hash function ([Tho13], Section 1.1, p. 5):
extracts c base-2 ^ b characters from u : Fin U, applies simpleTabTuple T₁ to obtain d
intermediate b-bit characters, and applies simpleTabEval T₂ to produce an M-bit hash in
Fin (2 ^ M).
When the top-level table T₁ is k-unique (IsKUnique k (simpleTabTuple T₁)) and
U ≤ 2 ^ (c * b), the bottom-level family fun T₂ => doubleTabHash c d b U M T₁ T₂ is k-wise
independent ([Tho13], Section 1.1, Lemma 2, p. 5).
Section 3: Position-character sets, symmetric differences, and BitString XOR laws #
Section 4: Derivable output characters and Theorem 7(a) ([Thorup2013], §3) #
Section 5: Efficient-code seed counting ([Thorup2013], §2, Eqs. (6)–(7)) #
Per-step efficient-code counting factor c * ((c * k) ^ (2 * c) * d) ^ q from
[Tho13], Section 2, Eqs. (6)–(7), p. 11.
Thorup's Universal k-Uniqueness Bound ([Tho13], Theorem 1(a), Section 2 Eqs. (6)–(7),
and Section 3 Theorem 7(a), pp. 4, 11–13):
For c ≥ 1, q ≥ 1, d = 2 * q * c, and 2 * doubleTabCodeBound c d q k ≤ 2 ^ ((q - 1) * b),
the number of top-level tables T₁ : DoubleTabTopSeed c d b for which simpleTabTuple T₁ fails to
be k-unique satisfies
(2 ^ ((q - 1) * b)) ^ 2 * #{T₁ | ¬ IsKUnique k (simpleTabTuple T₁)} ≤ 2 * (doubleTabCodeBound c d q k) ^ 2 * Fintype.card (DoubleTabTopSeed c d b).
Specialization of card_not_isKUnique_le to q = 4 (d = 8 * c, [Thorup2013], Theorem 1(a),
p. 4): when 2 * doubleTabCodeBound c (8 * c) 4 k ≤ 2 ^ (3 * b), at most a
2 * (doubleTabCodeBound c (8 * c) 4 k) ^ 2 / 2 ^ (6 * b) fraction of top-level tables fail to be
k-unique.
Minimum character bit-width doubleTabMinB c_exp for polynomial universe exponent c_exp : ℕ,
bounding the character bit-width b = (1 + Nat.clog 2 (max n_max 4)) / 2 from below when
doubleTabThreshold c_exp ≤ n_max (n_max = capacity bound) so doubleTabHash satisfies the
high-probability logarithmic k-uniqueness bound via Nat.pow_le_two_pow.
Capacity threshold 2 ^ (2 * doubleTabMinB c_exp) for polynomial universe exponent c_exp : ℕ
above which Double Tabulation with c = 2 * max c_exp 1 characters of bit-width
b = (1 + Nat.clog 2 (max n_max 4)) / 2 achieves logarithmic k-wise independence with
inverse-polynomial failure probability.