Documentation

CslibFrontier.DataStructure.Dictionary.KickTree.QuotientPerm

Universal key-quotienting bijection across arbitrary universes U ≥ n #

This module constructs an explicit, computable, zero-collision key-quotienting bijection quotientPermEquiv : Fin (2 ^ a) ≃ Fin (2 ^ m) × Fin (2 ^ (a - m)) (for all m ≤ a) and a universal full-quotient bit-width bound mul_fullQuotBits_le_clog_choose (for all U, n), together with high-probability intra-shard κ-wise (κ = Θ(c log n)) distributional transfer (for target bucket sets lying within a single shard σ via bucketShard _ b = σ) across every universe U ≥ n once n ≥ quotientPermThreshold c, without assuming U ≥ n ^ (1 + Ω(1)) or log U ≤ poly(log n).

Source attribution and formalization adaptations #

Main definitions #

Main results #

References #

Section 1: Full-quotient bit-width and information-theoretic space bound #

Bucket-index bit-width ⌊log₂ n⌋ for full key quotienting at capacity n.

Stored quotient bit-width ⌈log₂ U⌉ - ⌊log₂ n⌋ per key at universe U and capacity n.

If U ≤ 2 ^ w, then fullQuotBits U n ≤ w.

Canonical injective embedding Fin U → Fin (2 ^ keyBits U) preserving .val.

Universal information-theoretic full-quotient bit bound: for all U and n (including n = 0, n = U, and U < n), n quotients of fullQuotBits U n bits occupy at most ⌈log₂ C(U, n)⌉ + 2 * n bits.

Full-quotient + value space against Dynamic.optBits U V n = ⌈log₂ C(U, n)⌉ + n * ⌈log₂ V⌉.

Section 2: Unified deterministic key-quotienting bijection (Case A + Case B) #

Unified round-function bundle across Case A and Case B.

  • caseA : CaseARounds a m

    Case A 2-round unbalanced Feistel functions (m + caseAGap c n ≤ a).

  • caseB : CaseBRounds a m (nrRounds c)

    Case B sharded nrRounds c-block Naor–Reingold functions (a < m + caseAGap c n).

def Cslib.DataStructure.Dictionary.KickTree.quotientPermEquiv {a m c n : ℕ} (hma : m ≤ a) (r : QuotientPermRounds a m c n) :
Fin (2 ^ a) ≃ Fin (2 ^ m) × Fin (2 ^ (a - m))

Universal deterministic key-quotienting bijection across all m ≤ a: dispatches to caseAEquiv when m + caseAGap c n ≤ a and to caseBEquiv when a < m + caseAGap c n.

def Cslib.DataStructure.Dictionary.KickTree.quotientPermEncode {a m c n : ℕ} (hma : m ≤ a) (r : QuotientPermRounds a m c n) (u : Fin (2 ^ a)) :
Fin (2 ^ m) × Fin (2 ^ (a - m))

Forward key-quotienting map u ↦ (bucket, quot) in O(c) round evaluations.

def Cslib.DataStructure.Dictionary.KickTree.quotientPermDecode {a m c n : ℕ} (hma : m ≤ a) (r : QuotientPermRounds a m c n) (p : Fin (2 ^ m) × Fin (2 ^ (a - m))) :
Fin (2 ^ a)

Inverse key-reconstruction map (bucket, quot) ↦ u in O(c) round evaluations.

@[simp]

Full-quotient specialization (u : Fin (2 ^ keyBits U)) ≃ Fin (2 ^ bucketIndexBits n) × Fin (2 ^ fullQuotBits U n) for any n ≤ U.

Section 3: Concrete Double-Tabulation + oddMulModWord instantiation #

Concrete computable seed bundle for the universal key-quotienting bijection and auxiliary hash across all m ≤ a.

Instances For
    @[instance_reducible]

    Concrete QuotientPermRounds instantiated from θ : QuotientPermSeed a m b_aux c n.

    def Cslib.DataStructure.Dictionary.KickTree.concreteBucket {a m b_aux c n : ℕ} (hma : m ≤ a) (θ : QuotientPermSeed a m b_aux c n) (u : Fin (2 ^ a)) :
    Fin (2 ^ m)

    Concrete bucket index (quotientPermEquiv hma (concreteRounds θ) u).1 : Fin (2 ^ m).

    def Cslib.DataStructure.Dictionary.KickTree.concreteQuot {a m b_aux c n : ℕ} (hma : m ≤ a) (θ : QuotientPermSeed a m b_aux c n) (u : Fin (2 ^ a)) :
    Fin (2 ^ (a - m))

    Concrete stored quotient (quotientPermEquiv hma (concreteRounds θ) u).2 in Fin (2 ^ (a - m)).

    def Cslib.DataStructure.Dictionary.KickTree.concreteAux {a m b_aux c n : ℕ} (hma : m ≤ a) (θ : QuotientPermSeed a m b_aux c n) (u : Fin (2 ^ a)) :
    Fin (2 ^ b_aux)

    Concrete b_aux-bit auxiliary hash accompanying concreteBucket.

    theorem Cslib.DataStructure.Dictionary.KickTree.dist_concreteCaseA_restrict_le {a m b_aux c n : ℕ} (hma : m ≤ a) (hgap : m + caseAGap c n ≤ a) (hn : quotientPermThreshold c ≤ n) {S T : Finset (Fin (2 ^ a))} (hS : S.card ≤ n) (hTS : T ⊆ S) (hT : T.card ≤ quotientPermInd c n) :
    dist (PMF.map (fun (θ : QuotientPermSeed a m b_aux c n) (u : ↥T) => (concreteBucket hma θ ↑u, concreteAux hma θ ↑u)) (Probability.PMF.uniformOfFintype (QuotientPermSeed a m b_aux c n))) (Probability.PMF.uniformOfFintype (↥T → Fin (2 ^ m) × Fin (2 ^ b_aux))) ≤ 1 / ↑n ^ (c + 1)

    Concrete Case A statistical-distance transfer: when m + caseAGap c n ≤ a, quotientPermThreshold c ≤ n, #S ≤ n, and T ⊆ S (#T ≤ quotientPermInd c n), the joint distribution of (concreteBucket hma θ u, concreteAux hma θ u)_{u ∈ T} under uniform θ : QuotientPermSeed a m b_aux c n is within 1 / n ^ (c + 1) of uniform.

    theorem Cslib.DataStructure.Dictionary.KickTree.dist_concreteCaseB_shardTuple_le {a m b_aux c n : ℕ} (hma : m ≤ a) (hcaseB : a < m + caseAGap c n) (hn : quotientPermThreshold c ≤ n) (hm_lo : bucketIndexBits n ≤ m) (hm_hi : m ≤ 8 * quotientPermCharBits n) {T : Finset (Fin (2 ^ a))} (hT : T.card ≤ quotientPermInd c n) (yEmb : ↥T ↪ Fin (2 ^ suffixBits a m)) :
    dist (PMF.map (fun (θ : QuotientPermSeed a m b_aux c n) => (fun (u : ↥T) => ((FeistelPerm.bitDomainEquiv ⋯) ↑u).1 ^^^ (concreteRounds θ).caseB.fShard (yEmb u), ((Equiv.refl ↥T).embeddingCongr (nrComposedEquiv (suffixBits a m) (nrRounds c) (concreteRounds θ).caseB.nrBlocks)) yEmb, fun (u : ↥T) => concreteAux hma θ ↑u)) (Probability.PMF.uniformOfFintype (QuotientPermSeed a m b_aux c n))) (Probability.PMF.uniformOfFintype ((↥T → Fin (2 ^ shardBits m)) × (↥T ↪ Fin (2 ^ suffixBits a m)) × (↥T → Fin (2 ^ b_aux)))) ≤ 1 / (4 * ↑n ^ (c + 2))

    Concrete Case B shard-tuple statistical-distance transfer: when bucketIndexBits n ≤ m ≤ a < m + caseAGap c n, m ≤ 8 * quotientPermCharBits n, quotientPermThreshold c ≤ n, #T ≤ quotientPermInd c n, and yEmb : T ↪ Fin (2 ^ suffixBits a m), the distribution of (shard, nrPerm ∘ yEmb, concreteAux) under uniform θ : QuotientPermSeed a m b_aux c n is within 1 / (4 * n ^ (c + 2)) of Uniform × UniformInj × Uniform.

    theorem Cslib.DataStructure.Dictionary.KickTree.prob_concreteCaseB_shardLoad_outside_le {a m b_aux c n k_mom : ℕ} (hma : m ≤ a) (hcaseB : a < m + caseAGap c n) (hn : quotientPermThreshold c ≤ n) (hm_hi : m ≤ 8 * quotientPermCharBits n) (hk_pos : 1 ≤ k_mom) (hk_ind : 2 * k_mom ≤ quotientPermInd c n) (S : Finset (Fin (2 ^ a))) {a_dev : ℝ} (hk_mu : 2 * ↑k_mom ≤ 3 * (↑S.card / 2 ^ shardBits m)) (ha_dev : 0 < a_dev) :
    ((Probability.PMF.uniformOfFintype (QuotientPermSeed a m b_aux c n)).toOuterMeasure {θ : QuotientPermSeed a m b_aux c n | ∃ (σ : Fin (2 ^ shardBits m)), a_dev ≤ |↑{u ∈ S | bucketShard m (concreteBucket hma θ u) = σ}.card - ↑S.card / 2 ^ shardBits m|}).toReal ≤ 1 / (8 * ↑n ^ (c + 2)) + 2 ^ (shardBits m + 1) * (3 * ↑k_mom * (↑S.card / 2 ^ shardBits m) / a_dev ^ 2) ^ k_mom

    Concrete Case B shard-load concentration: in Case B (a < m + caseAGap c n), the probability that any shard σ : Fin (2 ^ shardBits m) deviates from mean load #S / 2 ^ shardBits m by at least a_dev > 0 is bounded via FeistelPerm.dens_exists_bucketLoad_sub_ge_le.

    theorem Cslib.DataStructure.Dictionary.KickTree.prob_concreteQuotientPerm_forall_mem_le {a m b_aux c n : ℕ} (hma : m ≤ a) (hn : quotientPermThreshold c ≤ n) (hm_lo : bucketIndexBits n ≤ m) (hm_hi : m ≤ 8 * quotientPermCharBits n) {S T : Finset (Fin (2 ^ a))} (hS : S.card ≤ n) (hTS : T ⊆ S) (hT : T.card ≤ quotientPermInd c n) (σ : Fin (2 ^ shardBits m)) (B : Finset (Fin (2 ^ m))) (hB : ∀ b ∈ B, bucketShard m b = σ) (A : Finset (Fin (2 ^ b_aux))) :
    ((Probability.PMF.uniformOfFintype (QuotientPermSeed a m b_aux c n)).toOuterMeasure {θ : QuotientPermSeed a m b_aux c n | ∀ u ∈ T, concreteBucket hma θ u ∈ B ∧ concreteAux hma θ u ∈ A}).toReal ≤ (↑B.card / 2 ^ m * (↑A.card / 2 ^ b_aux)) ^ T.card + 1 / ↑n ^ (c + 1)

    Unified Fin (2 ^ a) multiplicative tail bound across Case A and Case B (shared intra-shard target bucket set B and auxiliary set A).

    theorem Cslib.DataStructure.Dictionary.KickTree.prob_concreteQuotientPerm_forall_mem_perKey_le {a m b_aux c n : ℕ} (hma : m ≤ a) (hn : quotientPermThreshold c ≤ n) (hm_lo : bucketIndexBits n ≤ m) (hm_hi : m ≤ 8 * quotientPermCharBits n) {S T : Finset (Fin (2 ^ a))} (hS : S.card ≤ n) (hTS : T ⊆ S) (hT : T.card ≤ quotientPermInd c n) (σ : Fin (2 ^ shardBits m)) (B : Fin (2 ^ a) → Finset (Fin (2 ^ m))) (hB : ∀ u ∈ T, ∀ b ∈ B u, bucketShard m b = σ) (A : Fin (2 ^ a) → Finset (Fin (2 ^ b_aux))) :
    ((Probability.PMF.uniformOfFintype (QuotientPermSeed a m b_aux c n)).toOuterMeasure {θ : QuotientPermSeed a m b_aux c n | ∀ u ∈ T, concreteBucket hma θ u ∈ B u ∧ concreteAux hma θ u ∈ A u}).toReal ≤ 2 * ∏ u ∈ T, ↑(B u).card / 2 ^ m * (↑(A u).card / 2 ^ b_aux) + 1 / ↑n ^ (c + 1)

    Per-key Fin (2 ^ a) multiplicative tail bound across Case A and Case B (per-key intra-shard target bucket sets B u satisfying ∀ u ∈ T, ∀ b ∈ B u, bucketShard m b = σ, factor 2).

    Full-quotient bucket index Fin (2 ^ bucketIndexBits n) of u : Fin U (n ≤ U).

    Full-quotient stored quotient Fin (2 ^ fullQuotBits U n) of u : Fin U (n ≤ U).

    Inverse key-reconstruction map (bucket, quot) ↦ Fin (2 ^ keyBits U) for n ≤ U.

    def Cslib.DataStructure.Dictionary.KickTree.fullAux {U b_aux c n : ℕ} (hnU : n ≤ U) (θ : QuotientPermSeed (FeistelQuotient.keyBits U) (bucketIndexBits n) b_aux c n) (u : Fin U) :
    Fin (2 ^ b_aux)

    Auxiliary b_aux-bit hash accompanying fullBucket for u : Fin U (n ≤ U).

    theorem Cslib.DataStructure.Dictionary.KickTree.prob_fullQuotientPerm_forall_mem_le {U b_aux c n : ℕ} (hnU : n ≤ U) (hn : quotientPermThreshold c ≤ n) {S T : Finset (Fin U)} (hS : S.card ≤ n) (hTS : T ⊆ S) (hT : T.card ≤ quotientPermInd c n) (σ : Fin (2 ^ shardBits (bucketIndexBits n))) (B : Finset (Fin (2 ^ bucketIndexBits n))) (hB : ∀ b ∈ B, bucketShard (bucketIndexBits n) b = σ) (A : Finset (Fin (2 ^ b_aux))) :

    Universal Fin U multiplicative tail bound across every U ≥ n above quotientPermThreshold c (shared intra-shard target bucket set B with ∀ b ∈ B, bucketShard (bucketIndexBits n) b = σ and auxiliary set A, factor 1, without assuming U ≥ n ^ (1 + Ω(1)) or log U ≤ poly(log n)).

    theorem Cslib.DataStructure.Dictionary.KickTree.prob_fullQuotientPerm_forall_mem_perKey_le {U b_aux c n : ℕ} (hnU : n ≤ U) (hn : quotientPermThreshold c ≤ n) {S T : Finset (Fin U)} (hS : S.card ≤ n) (hTS : T ⊆ S) (hT : T.card ≤ quotientPermInd c n) (σ : Fin (2 ^ shardBits (bucketIndexBits n))) (B : Fin U → Finset (Fin (2 ^ bucketIndexBits n))) (hB : ∀ u ∈ T, ∀ b ∈ B u, bucketShard (bucketIndexBits n) b = σ) (A : Fin U → Finset (Fin (2 ^ b_aux))) :
    ((Probability.PMF.uniformOfFintype (QuotientPermSeed (FeistelQuotient.keyBits U) (bucketIndexBits n) b_aux c n)).toOuterMeasure {θ : QuotientPermSeed (FeistelQuotient.keyBits U) (bucketIndexBits n) b_aux c n | ∀ u ∈ T, fullBucket hnU θ u ∈ B u ∧ fullAux hnU θ u ∈ A u}).toReal ≤ 2 * ∏ u ∈ T, ↑(B u).card / 2 ^ bucketIndexBits n * (↑(A u).card / 2 ^ b_aux) + 1 / ↑n ^ (c + 1)

    Universal per-key Fin U multiplicative tail bound across every U ≥ n above quotientPermThreshold c (per-key intra-shard target bucket sets B u satisfying ∀ u ∈ T, ∀ b ∈ B u, bucketShard (bucketIndexBits n) b = σ and auxiliary sets A u, factor 2, without assuming U ≥ n ^ (1 + Ω(1)) or log U ≤ poly(log n)).