Documentation

CslibFrontier.DataStructure.HashFamily.WordRAM.DoubleTabulation

Self-Contained Word-RAM Double Tabulation and High-Independence Hashing ([Thorup2013]) #

This module provides a reusable Word-RAM implementation of Mikkel Thorup's double tabulation hash family (Cslib.Probability.doubleTabHash c d b U M, [Tho13]) over Cslib.WordRAM.Basis.exact and lifts it to Cslib.WordRAM.Basis.standard:

  1. Flat multi-word memory layout (space c d b = (c + 1) * d * 2 ^ b):
    • The top-level table T₁ : DoubleTabTopSeed c d b (Fin c → Fin d → Fin (2 ^ b) → Fin (2 ^ b)) occupies [base, base + c * d * 2 ^ b), storing (T₁ i j ch).val at topAddr base c b i j ch = base + (j.val * c + i.val) * 2 ^ b + ch.val (b-bit words, never packing an intermediate d-tuple Ψ ^ d into a single machine word).
    • The bottom-level table T₂ : DoubleTabBotSeed d b M (Fin d → Fin (2 ^ b) → Fin (2 ^ M)) occupies [base + c * d * 2 ^ b, base + (c + 1) * d * 2 ^ b), storing (T₂ j y).val at botAddr base c d b j y = base + c * d * 2 ^ b + j.val * 2 ^ b + y.val.
  2. Exact uniform seed resampling (resampleCode c d b M):
    • Executes two sequential calls to Tabulation.randFillLoop in resampleSteps c d b = 5 * space c d b + 13 instructions (O((c + 1) * d * 2 ^ b)), sampling (T₁, T₂) from the exact uniform distribution PMF.uniformOfFintype (DoubleTabTopSeed c d b × DoubleTabBotSeed d b M).
  3. Register-by-register deterministic query evaluation (evalCode c d b):
    • For each output coordinate j = 0 .. d - 1, computes the intermediate b-bit character y_j = ⨁_{i < c} T₁[i, j, x_i] via an inner loop over i = 0 .. c - 1, then looks up T₂[j, y_j] and XORs it into the output accumulator in evalSteps c d = (12 * c + 11) * d + 10 deterministic instructions (O(c * d)), without modifying memory and matching (doubleTabHash c d b U M T₁ T₂ u).val.
  4. Reusable HashFamily.WordRAM.Impl and ObliviousSequenceImpl certificates:
    • impl and obliviousSequenceImpl package doubleTabHash as a Word-RAM hash family realizing DataStructure.HashFamily.whpKWiseSpec k U (2 ^ M) δ with failure probability δ = doubleTabFailureProb c d b k, bounded for d = 8 * c by card_not_isKUnique_eight_mul_le when 1 ≤ c and 2 * doubleTabCodeBound c (8 * c) 4 k ≤ 2 ^ (3 * b).
    • provableImpl and provableObliviousSequenceImpl combine KWise (trinomialPolyHash with δ = 0 for n_max < doubleTabThreshold c_exp) and DoubleTabulation (c = 2 * max c_exp 1, d = 8 * c, b = (1 + Nat.clog 2 (max n_max 4)) / 2 and δ = doubleTabFailureProb c d b k, bounded under the condition on k above, for doubleTabThreshold c_exp ≤ n_max). They use O_{c_exp, k}(n_max + 1) words of space for every n_max : ℕ and, whenever U ≤ max n_max 4 ^ c_exp and M ≤ max c_exp 1 * Nat.clog 2 (max n_max 4) + 5, evaluate within provableEvalBound c_exp k instructions, independent of n_max, U, and M.

Main definitions #

Main results #

References #

Section 1: Flat memory layout, seed representations, and slice equivalences #

Number of machine words c * d * 2 ^ b storing the top-level table T₁.

Number of machine words d * 2 ^ b storing the bottom-level table T₂.

Total contiguous memory footprint (c + 1) * d * 2 ^ b words for Double Tabulation at [base, base + space c d b).

def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.topAddr (base c b : ℕ) {d : ℕ} (i : Fin c) (j : Fin d) (ch : Fin (2 ^ b)) :

Memory address base + (j.val * c + i.val) * 2 ^ b + ch.val of top-table entry T₁ i j ch.

Memory address base + c * d * 2 ^ b + j.val * 2 ^ b + y.val of bottom-table entry T₂ j y.

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.topAddr_lt_base_add_topWords (base c d b : ℕ) (i : Fin c) (j : Fin d) (ch : Fin (2 ^ b)) :
topAddr base c b i j ch < base + topWords c d b
theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.botAddr_lt_base_add_space (base c d b : ℕ) (j : Fin d) (y : Fin (2 ^ b)) :
botAddr base c d b j y < base + space c d b

Memory representation predicate for the top-level table T₁ : DoubleTabTopSeed c d b.

Memory representation predicate for the bottom-level table T₂ : DoubleTabBotSeed d b M.

Combined memory representation predicate for (T₁, T₂) at [base, base + space c d b).

Linear-index equivalence Fin c × Fin d × Fin (2 ^ b) ≃ Fin (c * d * 2 ^ b) mapping (i, j, ch) to (j.val * c + i.val) * 2 ^ b + ch.val.

@[simp]
theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.val_topIndexEquiv (c d b : ℕ) (i : Fin c) (j : Fin d) (ch : Fin (2 ^ b)) :
↑((topIndexEquiv c d b) (i, j, ch)) = (↑j * c + ↑i) * 2 ^ b + ↑ch

Equivalence between flat (c * d * 2 ^ b)-word slices and DoubleTabTopSeed c d b.

Equivalence between flat (d * 2 ^ b)-word slices and DoubleTabBotSeed d b M.

Extract the top-level seed T₁ : DoubleTabTopSeed c d b from [base, base + c * d * 2 ^ b).

Extract the bottom-level seed T₂ : DoubleTabBotSeed d b M from [base + c * d * 2 ^ b, base + (c + 1) * d * 2 ^ b).

Extract the pair (T₁, T₂) from [base, base + space c d b).

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.extractTop_apply (base c d b : ℕ) (mem : ℕ → ℕ) (i : Fin c) (j : Fin d) (ch : Fin (2 ^ b)) :
extractTop base c d b mem i j ch = WordRAM.wordOfNat b (mem (topAddr base c b i j ch))
theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.extractBot_apply (base c d b M : ℕ) (mem : ℕ → ℕ) (j : Fin d) (y : Fin (2 ^ b)) :
extractBot base c d b M mem j y = WordRAM.wordOfNat M (mem (botAddr base c d b j y))
theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.extractSeed_eq_of_seedRep {base c d b M : ℕ} {θ : Probability.DoubleTabTopSeed c d b × Probability.DoubleTabBotSeed d b M} {mem : ℕ → ℕ} (hseed : SeedRep base c d b M θ mem) :
extractSeed base c d b M mem = θ

When SeedRep base c d b M θ mem holds, extractSeed base c d b M mem recovers the seed pair θ.

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.SeedRep.congr_mem {base c d b M : ℕ} {θ : Probability.DoubleTabTopSeed c d b × Probability.DoubleTabBotSeed d b M} {mem mem' : ℕ → ℕ} (hrep : SeedRep base c d b M θ mem) (heq : ∀ (a : ℕ), base ≤ a → a < base + space c d b → mem' a = mem a) :
SeedRep base c d b M θ mem'
theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.extractSeed_congr_mem {base c d b M : ℕ} {mem mem' : ℕ → ℕ} (heq : ∀ (a : ℕ), base ≤ a → a < base + space c d b → mem' a = mem a) :
extractSeed base c d b M mem' = extractSeed base c d b M mem

Section 2: Register layout and randomized seed resampling (resampleCode) #

@[reducible, inline]

Register 0: persistent base address base.

@[reducible, inline]

Register 1: input key u.val in evalCode.

@[reducible, inline]

Register 2: output accumulator acc in evalCode.

@[reducible, inline]

Register 3: top-table pointer / randFillLoop write pointer.

@[reducible, inline]

Register 4: bottom-table pointer / randFillLoop end pointer.

@[reducible, inline]

Register 5: bottom-table end pointer / randFillLoop bitmask.

@[reducible, inline]

Register 6: remaining inner-loop count remC / randFillLoop constant 1.

@[reducible, inline]

Register 7: shifted key curU / randFillLoop sampled value.

@[reducible, inline]

Register 8: inner XOR accumulator y_j.

@[reducible, inline]

Register 9: general scratch register for masks, addresses, and loaded entries.

@[reducible, inline]

Register 10: character alphabet size 2 ^ b.

@[reducible, inline]

Register 11: constant 0.

Register injection Fin 6 → Fin 12 mapping Tabulation.randFillLoop's (ptr, end, mask, one, val, extra) to (3, 4, 5, 6, 7, 0).

Setup program before the first randFillLoop call (5 instructions): sets reg 3 ← base, reg 4 ← base + c * d * 2 ^ b, reg 5 ← 2 ^ b - 1, and reg 6 ← 1.

Setup program before the second randFillLoop call (4 instructions): sets reg 3 ← base + c * d * 2 ^ b, reg 4 ← base + c * d * 2 ^ b + d * 2 ^ b, and reg 5 ← 2 ^ M - 1.

Structured Word-RAM program on Data 12 that resamples both T₁ and T₂ via two sequential Tabulation.randFillLoop calls.

Exact instruction count 5 * space c d b + 13 of resampleCode c d b M.

Explicit ProbComp (Data 12 × ℕ) induced by resampleCode c d b M.

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.resampleCode_execRand {w base c d b M : ℕ} {x : WordRAM.Data 12} (hbase : x.regs 0 = base) (hfit_space : WordRAM.Fits w (base + space c d b)) (hfit_mask_b : WordRAM.Fits w (2 ^ b - 1)) (hfit_mask_M : WordRAM.Fits w (2 ^ M - 1)) (hfit_1 : WordRAM.Fits w 1) :
WordRAM.ExecRand w (resampleCode c d b M) x (resampleComp base c d b M x)

Exact ExecRand execution of resampleCode c d b M.

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.mem_support_resampleComp {base c d b M : ℕ} {x : WordRAM.Data 12} (hbase : x.regs 0 = base) {z : WordRAM.Data 12 × ℕ} (hz : z ∈ OracleComp.support (resampleComp base c d b M x)) :
z.1.regs 0 = base ∧ SeedRep base c d b M (extractSeed base c d b M z.1.mem) z.1.mem ∧ (∀ (a : ℕ), a < base ∨ base + space c d b ≤ a → z.1.mem a = x.mem a) ∧ z.2 = resampleSteps c d b

Pathwise postcondition of resampleComp: executes in resampleSteps c d b instructions, preserves reg 0 = base, establishes SeedRep base c d b M (extractSeed base c d b M z.1.mem), and modifies only [base, base + space c d b).

Exact product uniformity of resampleComp: extractSeed base c d b M z.1.mem under resampleComp base c d b M x has distribution PMF.uniformOfFintype (DoubleTabTopSeed c d b × DoubleTabBotSeed d b M).

Section 3: Register-by-register deterministic query evaluation (evalCode) #

Setup before outerLoop c b (8 instructions): initializes reg 2 ← 0, reg 3 ← base, reg 4 ← base + c * d * 2 ^ b, reg 5 ← base + c * d * 2 ^ b + d * 2 ^ b, reg 10 ← 2 ^ b, and reg 11 ← 0.

Body of the inner loop over i = 0 .. c - 1 (10 instructions): extracts ch = reg 7 &&& (2 ^ b - 1), loads mem[reg 3 + ch], XORs into reg 8, shifts reg 7 right by b, advances reg 3 by 2 ^ b (reg 10), and decrements reg 6.

Inner loop computing y_j = ⨁_{i < c} T₁[i, j, x_i] into reg 8.

Body of the outer loop over j = 0 .. d - 1: initializes reg 7 ← reg 1 (u.val), reg 8 ← 0, reg 6 ← c, runs innerLoop b, loads T₂[j, y_j] from mem[reg 4 + reg 8], XORs into reg 2, and advances reg 4 by 2 ^ b (reg 10).

Complete deterministic Word-RAM evaluation program for Double Tabulation on Data 12.

Exact instruction count (12 * c + 11) * d + 10 of evalCode c d b.

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.evalCode_exec {w base c d b U M : ℕ} {T₁ : Probability.DoubleTabTopSeed c d b} {T₂ : Probability.DoubleTabBotSeed d b M} (u : Fin U) {x : WordRAM.Data 12} (hbase : x.regs 0 = base) (hkey : x.regs 1 = ↑u) (hseed : SeedRep base c d b M (T₁, T₂) x.mem) (hfit_space : WordRAM.Fits w (base + space c d b)) (hfit_pow_b : WordRAM.Fits w (2 ^ b)) (hfit_pow_M : WordRAM.Fits w (2 ^ M)) (hfit_u : WordRAM.Fits w ↑u) :
∃ (y : WordRAM.Data 12), WordRAM.Exec w (evalCode c d b) x y (evalSteps c d) ∧ y.mem = x.mem ∧ y.regs 0 = base ∧ y.regs 1 = ↑u ∧ y.regs 2 = ↑(Probability.doubleTabHash c d b U M T₁ T₂ u)

Exact deterministic Exec correctness and complexity of evalCode c d b: from SeedRep base c d b M (T₁, T₂) x.mem, x.regs 0 = base, and x.regs 1 = u.val, evalCode c d b halts in evalSteps c d = (12 * c + 11) * d + 10 instructions with y.regs 2 = (doubleTabHash c d b U M T₁ T₂ u).val, preserving y.regs 0 = base, y.regs 1 = u.val, and y.mem = x.mem.

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.evalCode_execWithin {w base c d b U M : ℕ} {T₁ : Probability.DoubleTabTopSeed c d b} {T₂ : Probability.DoubleTabBotSeed d b M} (u : Fin U) {x : WordRAM.Data 12} (hbase : x.regs 0 = base) (hkey : x.regs 1 = ↑u) (hseed : SeedRep base c d b M (T₁, T₂) x.mem) (hfit_space : WordRAM.Fits w (base + space c d b)) (hfit_pow_b : WordRAM.Fits w (2 ^ b)) (hfit_pow_M : WordRAM.Fits w (2 ^ M)) (hfit_u : WordRAM.Fits w ↑u) :
∃ (y : WordRAM.Data 12), WordRAM.ExecWithin w (evalCode c d b) x y (evalSteps c d) ∧ y.mem = x.mem ∧ y.regs 0 = base ∧ y.regs 1 = ↑u ∧ y.regs 2 = ↑(Probability.doubleTabHash c d b U M T₁ T₂ u) ∧ (WordRAM.Data.Bounded w x → WordRAM.Data.Bounded w y)

ExecWithin corollary of evalCode_exec, also recording y.Bounded w when x.Bounded w.

Section 4: Impl and ObliviousSequenceImpl certificates for Double Tabulation #

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.impl {w base c d b U M : ℕ} (hfit_space : WordRAM.Fits w (base + space c d b)) (hfit_pow_b : WordRAM.Fits w (2 ^ b)) (hfit_pow_M : WordRAM.Fits w (2 ^ M)) (hfit_keys : ∀ (u : Fin U), WordRAM.Fits w ↑u) :
Impl WordRAM.Basis.exact 12 0 w base U (2 ^ M) Fin.elim0

Package Double Tabulation on Data 12 into a Cslib.DataStructure.HashFamily.WordRAM.Impl over Basis.exact with 0 initialization parameters.

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.implStandard {w base c d b U M : ℕ} (hfit_space : WordRAM.Fits w (base + space c d b)) (hfit_pow_b : WordRAM.Fits w (2 ^ b)) (hfit_pow_M : WordRAM.Fits w (2 ^ M)) (hfit_keys : ∀ (u : Fin U), WordRAM.Fits w ↑u) :

Lift impl to Basis.standard.

Finset of k-unique top-level tables T₁ : DoubleTabTopSeed c d b.

Top-seed failure probability #{T₁ | ¬ IsKUnique k (simpleTabTuple T₁)} / |DoubleTabTopSeed c d b| for doubleTabHash.

Explicit failure-probability bound for doubleTabFailureProb c (8 * c) b k ([Thorup2013], Theorem 1(a), p. 4): when 1 ≤ c and 2 * doubleTabCodeBound c (8 * c) 4 k ≤ 2 ^ (3 * b), doubleTabFailureProb c (8 * c) b k ≤ 2 * (doubleTabCodeBound c (8 * c) 4 k) ^ 2 / 2 ^ (6 * b).

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.obliviousSequenceImpl {w base c d b U M k : ℕ} (hU : U ≤ 2 ^ (c * b)) (hfit_space : WordRAM.Fits w (base + space c d b)) (hfit_pow_b : WordRAM.Fits w (2 ^ b)) (hfit_pow_M : WordRAM.Fits w (2 ^ M)) (hfit_keys : ∀ (u : Fin U), WordRAM.Fits w ↑u) :
WordRAM.Randomized.ObliviousSequenceImpl (impl hfit_space hfit_pow_b hfit_pow_M hfit_keys).subroutineCode (whpKWiseSpec k U (2 ^ M) (doubleTabFailureProb c d b k)) w base Fin.elim0

Canonical ObliviousSequenceImpl certificate for impl realizing DataStructure.HashFamily.whpKWiseSpec k U (2 ^ M) (doubleTabFailureProb c d b k) when U ≤ 2 ^ (c * b).

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.obliviousSequenceImplStandard {w base c d b U M k : ℕ} (hU : U ≤ 2 ^ (c * b)) (hfit_space : WordRAM.Fits w (base + space c d b)) (hfit_pow_b : WordRAM.Fits w (2 ^ b)) (hfit_pow_M : WordRAM.Fits w (2 ^ M)) (hfit_keys : ∀ (u : Fin U), WordRAM.Fits w ↑u) :
WordRAM.Randomized.ObliviousSequenceImpl (impl hfit_space hfit_pow_b hfit_pow_M hfit_keys).subroutineCode.toStandard (whpKWiseSpec k U (2 ^ M) (doubleTabFailureProb c d b k)) w base Fin.elim0

Standard-basis lifting of obliviousSequenceImpl.

Section 5: All-n_max regime-switched provableImpl and #

provableObliviousSequenceImpl

@[reducible, inline]

Number of characters c = 2 * max c_exp 1 for polynomial universe U ≤ max n_max 4 ^ c_exp.

@[reducible, inline]

Intermediate tuple length d = 8 * provableC c_exp = 16 * max c_exp 1 (q = 4).

@[reducible, inline]

Character bit-width b = (1 + Nat.clog 2 (max n_max 4)) / 2 at capacity n_max.

2 ^ provableB n_max ≤ 4 * max n_max 4 for every n_max : ℕ.

The 2 ^ provableB n_max cells of one character table fit in the whole Double Tabulation footprint space (provableC c_exp) (provableD c_exp) (provableB n_max).

Whenever U ≤ max n_max 4 ^ c_exp, U ≤ 2 ^ (provableC c_exp * provableB n_max).

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.kWiseImpl {w base n_max U M k : ℕ} (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + KWise.space n_max k)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
Impl WordRAM.Basis.exact 18 3 w base U (2 ^ M) ![n_max, U, M]

Package KWise (CslibFrontier/DataStructure/HashFamily/WordRAM/KWise.lean) into an Impl on Data 18 with 3 initialization parameters ![n_max, U, M].

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.impl18 {w base c d b U M : ℕ} (params : Fin 3 → ℕ) (hfit_space : WordRAM.Fits w (base + space c d b)) (hfit_pow_b : WordRAM.Fits w (2 ^ b)) (hfit_pow_M : WordRAM.Fits w (2 ^ M)) (hfit_keys : ∀ (u : Fin U), WordRAM.Fits w ↑u) :
Impl WordRAM.Basis.exact 18 3 w base U (2 ^ M) params

Lift impl from Data 12 to Data 18 with 3 initialization parameters params so it shares the exact register signature of kWiseImpl.

Footprint size of provableImpl c_exp k n_max U M: KWise.space n_max k when n_max < doubleTabThreshold c_exp, and space (provableC c_exp) (provableD c_exp) (provableB n_max) otherwise.

Failure probability δ of provableObliviousSequenceImpl c_exp k n_max U M: 0 ((((Finset.univ \ {()}).card : ℝ≥0∞) / Fintype.card Unit)) when n_max < doubleTabThreshold c_exp, and doubleTabFailureProb (provableC c_exp) (provableD c_exp) (provableB n_max) k otherwise. The latter is bounded by doubleTabFailureProb_eight_mul_le when 2 * doubleTabCodeBound (provableC c_exp) (provableD c_exp) 4 k ≤ 2 ^ (3 * provableB n_max).

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.provableImpl (c_exp k n_max U M : ℕ) {w base : ℕ} (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + provableSpace c_exp k n_max)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
Impl WordRAM.Basis.exact 18 3 w base U (2 ^ M) ![n_max, U, M]

All-n_max regime-switched Impl (provableImpl): uses kWiseImpl for n_max < doubleTabThreshold c_exp and impl18 with c = provableC c_exp, d = provableD c_exp, b = provableB n_max for doubleTabThreshold c_exp ≤ n_max.

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.provableImplStandard (c_exp k n_max U M : ℕ) {w base : ℕ} (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + provableSpace c_exp k n_max)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
Impl WordRAM.Basis.standard 18 3 w base U (2 ^ M) ![n_max, U, M]

Standard-basis lifting of provableImpl.

@[simp]
theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.provableImpl_space (c_exp k n_max U M : ℕ) {w base : ℕ} (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + provableSpace c_exp k n_max)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
(provableImpl c_exp k n_max U M hw hfit_space hfit_n hfit_U).space = provableSpace c_exp k n_max
@[simp]
theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.provableImpl_subroutineCode_initParams (c_exp k n_max U M : ℕ) {w base : ℕ} (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + provableSpace c_exp k n_max)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
(provableImpl c_exp k n_max U M hw hfit_space hfit_n hfit_U).subroutineCode.initParams = fun (j : Fin (Nat.succ 0).succ.succ) => coreReg (![1, 2, 3] j)
@[simp]
theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.provableImpl_subroutineCode_frontierReg (c_exp k n_max U M : ℕ) {w base : ℕ} (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + provableSpace c_exp k n_max)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
(provableImpl c_exp k n_max U M hw hfit_space hfit_n hfit_U).subroutineCode.frontierReg = frontierReg 18
noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.provableObliviousSequenceImpl (c_exp k n_max U M : ℕ) {w base : ℕ} (hU : U ≤ max n_max 4 ^ c_exp) (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + provableSpace c_exp k n_max)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
WordRAM.Randomized.ObliviousSequenceImpl (provableImpl c_exp k n_max U M hw hfit_space hfit_n hfit_U).subroutineCode (whpKWiseSpec k U (2 ^ M) (provableFailureProb c_exp k n_max)) w base ![n_max, U, M]

All-n_max regime-switched ObliviousSequenceImpl (provableObliviousSequenceImpl) realizing DataStructure.HashFamily.whpKWiseSpec k U (2 ^ M) (provableFailureProb c_exp k n_max) whenever U ≤ max n_max 4 ^ c_exp.

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.provableObliviousSequenceImplStandard (c_exp k n_max U M : ℕ) {w base : ℕ} (hU : U ≤ max n_max 4 ^ c_exp) (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + provableSpace c_exp k n_max)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
WordRAM.Randomized.ObliviousSequenceImpl (provableImpl c_exp k n_max U M hw hfit_space hfit_n hfit_U).subroutineCode.toStandard (whpKWiseSpec k U (2 ^ M) (provableFailureProb c_exp k n_max)) w base ![n_max, U, M]

Standard-basis lifting of provableObliviousSequenceImpl.

Explicit O_{c_exp, k}(1) space factor 16 + k + 16 * (provableC c_exp + 1) * provableD c_exp bounding provableSpace c_exp k n_max by provableSpaceFactor c_exp k * (n_max + 1) across every n_max : ℕ.

All-n_max linear space bound for provableSpace (O_{c_exp, k}(n_max + 1)): for every c_exp, k, n_max : ℕ, provableSpace c_exp k n_max ≤ provableSpaceFactor c_exp k * (n_max + 1).

Uniform O(c_exp) upper bound 21 * max c_exp 1 + 16 on KWise.limbCount n_max U M when U ≤ max n_max 4 ^ c_exp and M ≤ max c_exp 1 * Nat.clog 2 (max n_max 4) + 5.

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.limbCount_le_provableLimbBound {c_exp n_max U M : ℕ} (hU : U ≤ max n_max 4 ^ c_exp) (hM : M ≤ max c_exp 1 * Nat.clog 2 (max n_max 4) + 5) :

Uniform O_{c_exp, k}(1) evaluation instruction bound across all n_max : ℕ.

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.provableImpl_evalSteps_le {c_exp k n_max U M w base : ℕ} (hU : U ≤ max n_max 4 ^ c_exp) (hM : M ≤ max c_exp 1 * Nat.clog 2 (max n_max 4) + 5) (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + provableSpace c_exp k n_max)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
(provableImpl c_exp k n_max U M hw hfit_space hfit_n hfit_U).evalSteps ≤ provableEvalBound c_exp k

All-n_max constant evaluation time bound for provableImpl (O_{c_exp, k}(1)): whenever U ≤ max n_max 4 ^ c_exp and M ≤ max c_exp 1 * Nat.clog 2 (max n_max 4) + 5, (provableImpl ...).evalSteps ≤ provableEvalBound c_exp k, completely independent of n_max, U, and M.

theorem Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation.provableImpl_evalSteps_of_le {c_exp k n_max U M w base : ℕ} (hge : Probability.doubleTabThreshold c_exp ≤ n_max) (hw : 2 * Probability.trinomialDeg U M ≤ w) (hfit_space : WordRAM.Fits w (base + provableSpace c_exp k n_max)) (hfit_n : WordRAM.Fits w (max n_max 2)) (hfit_U : WordRAM.Fits w (max U 2 + 1)) :
(provableImpl c_exp k n_max U M hw hfit_space hfit_n hfit_U).evalSteps = evalSteps (provableC c_exp) (provableD c_exp)

k-independent evaluation time above the threshold: once doubleTabThreshold c_exp ≤ n_max, provableImpl evaluates by Double Tabulation in exactly evalSteps (provableC c_exp) (provableD c_exp) instructions, whatever the independence parameter k, capacity n_max, universe U and output width M.