Documentation

CslibFrontier.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation

Universe-Reduced Salted General-q Bit-Packed Double Tabulation ([Thorup2013]) #

This module provides a Word-RAM implementation of universe-reduced salted general-q double tabulation hashing with bit-packed lookup tables:

  1. Stage 1 (multiplyShiftReduced via oddMulModWord): maps any key u : Fin U (U ≤ 2 ^ w₀, 0 < w₀ ≤ w) to a reduced key rKey ∈ Fin (2 ^ min w₀ R) without 2 * w₀ ≤ w overflow, failing injectivity on a window W_set : Finset (Fin U) with probability at most (#W_set * (#W_set - 1)) / 2 ^ R.
  2. Stage 2 (salted general-q doubleTabHash with bit-packed tables): appends a salt character s : Fin s_max (s_max ≤ 2 ^ b_char) to the c_tab base-2 ^ b_char characters of rKey (min w₀ R ≤ c_tab * b_char) and evaluates (c_tab + 1, d, b_char, M_out) double tabulation with d = 2 * q * (c_tab + 1). Both T₁ ((c_tab + 1) * d * 2 ^ b_char entries of b_char bits) and T₂ (d * 2 ^ b_char entries of M_out bits) are stored in BitPackedArrays so the total footprint is ≤ (((c_tab + 1) * d * b_char + d * M_out) * 2 ^ b_char + w - 1) / w + 6 words for every word width w > 0 (including w ≫ n_max).
  3. Exact uniform resampling (resampleCode) and Memory.Prog evaluation (evalGenProg): resampleCode populates (α, T₁, T₂) from the exact uniform distribution in O((topWords + botWords) + 1) instructions via Tabulation.randFillLoop, and evalGenProg evaluates the hash in O(c_tab * d) deterministic instructions via Memory.Prog and realize (¬ReadsWidth, single compiled Code .exact independent of (c_tab, d, b_char, M_out, U, w)).

Main definitions #

Main results #

References #

Section 1: Salted double-tabulation model, conditional k-wise independence, and layout #

@[reducible, inline]

Number of entries (c_tab + 1) * d * 2 ^ b_char in the top-level bit-packed table T₁.

@[reducible, inline]

Number of entries d * 2 ^ b_char in the bottom-level bit-packed table T₂.

Number of w-bit words storing T₁ as a BitPackedArray of b_char-bit entries.

Number of w-bit words storing T₂ as a BitPackedArray of M_out-bit entries.

Word offset 1 + topWords w c_tab d b_char of the bottom-level bit-packed table T₂.

Total footprint 1 + topWords + botWords in w-bit machine words.

theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.space_pos (w c_tab d b_char M_out : ℕ) :
0 < space w c_tab d b_char M_out
theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.space_le (w c_tab d b_char M_out : ℕ) :
space w c_tab d b_char M_out ≤ (topEntries c_tab d b_char * b_char + botEntries d b_char * M_out + w - 1) / w + 6

Bit-packed word bound valid for every word width w: space w c_tab d b_char M_out ≤ (topEntries * b_char + botEntries * M_out + w - 1) / w + 6.

@[reducible, inline]

Combined seed type (α, T₁, T₂) for universe-reduced salted double tabulation.

@[reducible, inline]
abbrev Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.Seed.alpha {w₀ c_tab d b_char M_out : ℕ} (θ : Seed w₀ c_tab d b_char M_out) :
Fin (2 ^ (w₀ - 1))

Extract Stage 1 multiplier α from seed.

@[reducible, inline]
abbrev Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.Seed.top {w₀ c_tab d b_char M_out : ℕ} (θ : Seed w₀ c_tab d b_char M_out) :
Probability.DoubleTabTopSeed (c_tab + 1) d b_char

Extract Stage 2 top table T₁ from seed.

@[reducible, inline]
abbrev Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.Seed.bot {w₀ c_tab d b_char M_out : ℕ} (θ : Seed w₀ c_tab d b_char M_out) :

Extract Stage 2 bottom table T₂ from seed.

def Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.saltedChars (c_tab b_char : ℕ) {R' s_max : ℕ} (s : Fin s_max) (rKey : Fin R') :
Fin (c_tab + 1) → Fin (2 ^ b_char)

Salted (c_tab + 1)-character tuple: the first c_tab characters extract base-2 ^ b_char digits of the reduced key rKey, and the final character at index c_tab encodes the salt s.

theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.saltedChars_injective {c_tab b_char R' s_max : ℕ} (hs : s_max ≤ 2 ^ b_char) (hR' : R' ≤ 2 ^ (c_tab * b_char)) :
Function.Injective fun (p : Fin s_max × Fin R') => saltedChars c_tab b_char p.1 p.2

Injectivity of saltedChars when s_max ≤ 2 ^ b_char and R' ≤ 2 ^ (c_tab * b_char).

def Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.evalSalted (U w₀ R c_tab d b_char M_out s_max : ℕ) (θ : Seed w₀ c_tab d b_char M_out) (p : Fin s_max × Fin U) :
Fin (2 ^ M_out)

Universe-reduced salted double tabulation hash mapping (s, u) : Fin s_max × Fin U to Fin (2 ^ M_out).

def Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.GoodTop (U w₀ R c_tab d b_char k : ℕ) (W_set : Finset (Fin U)) (α : Fin (2 ^ (w₀ - 1))) (T₁ : Probability.DoubleTabTopSeed (c_tab + 1) d b_char) :

Good top-seed event on a key window W_set : Finset (Fin U): Stage 1 multiplyShiftReduced is injective on W_set and Stage 2 simpleTabTuple T₁ is k-unique.

theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.isKWiseIndependentHash_evalSalted_of_goodTop {U w₀ R c_tab d b_char M_out s_max k : ℕ} {W_set : Finset (Fin U)} {α : Fin (2 ^ (w₀ - 1))} {T₁ : Probability.DoubleTabTopSeed (c_tab + 1) d b_char} (hs : s_max ≤ 2 ^ b_char) (hcov : min w₀ R ≤ c_tab * b_char) (hgood : GoodTop U w₀ R c_tab d b_char k W_set α T₁) :
Probability.IsKWiseIndependentHash k fun (T₂ : Probability.DoubleTabBotSeed d b_char M_out) (p : Fin s_max × ↥W_set) => evalSalted U w₀ R c_tab d b_char M_out s_max (α, T₁, T₂) (p.1, ↑p.2)

Conditional exact k-wise independence on Fin s_max × W_set: whenever s_max ≤ 2 ^ b_char, min w₀ R ≤ c_tab * b_char, and GoodTop holds for (α, T₁), the bottom-table family T₂ ↦ evalSalted ... (α, T₁, T₂) restricted to Fin s_max × W_set is exact k-wise independent.

Probability bound on ¬ IsKUnique k (simpleTabTuple T₁) under PMF.uniformOfFintype, lifted from Cslib.Probability.card_not_isKUnique_le.

theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.toOuterMeasure_not_goodTop_le {U w₀ R c_tab d b_char M_out q k : ℕ} (hw₀ : 0 < w₀) (hU : U ≤ 2 ^ w₀) (hq : 1 ≤ q) (hd : d = 2 * q * (c_tab + 1)) (hbound : 2 * Probability.doubleTabCodeBound (c_tab + 1) d q k ≤ 2 ^ ((q - 1) * b_char)) (W_set : Finset (Fin U)) :
(Probability.PMF.uniformOfFintype (Seed w₀ c_tab d b_char M_out)).toOuterMeasure {θ : Seed w₀ c_tab d b_char M_out | ¬GoodTop U w₀ R c_tab d b_char k W_set θ.1 θ.top} ≤ ↑(W_set.card * (W_set.card - 1)) / 2 ^ R + 2 * ↑(Probability.doubleTabCodeBound (c_tab + 1) d q k) ^ 2 / (2 ^ ((q - 1) * b_char)) ^ 2

Explicit failure-probability bound on ¬ GoodTop: for a uniform seed θ : Seed w₀ c_tab d b_char M_out, when 0 < w₀, U ≤ 2 ^ w₀, 1 ≤ q, d = 2 * q * (c_tab + 1), and 2 * doubleTabCodeBound (c_tab + 1) d q k ≤ 2 ^ ((q - 1) * b_char), the probability that GoodTop U w₀ R c_tab d b_char k W_set θ.1 θ.2.1 fails is at most (#W_set * (#W_set - 1)) / 2 ^ R + 2 * (doubleTabCodeBound (c_tab + 1) d q k) ^ 2 / (2 ^ ((q - 1) * b_char)) ^ 2.

Section 2: Bit-packed slice uniformity, SeedRep, and resampleCode #

For 0 < w and idx < N, every bit index idx * k + j (j < k) lies in word (idx * k + j) / w < packedWords N k w.

theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.testBit_readPacked {arrBase k w : ℕ} (hw : 0 < w) (hkw : k ≤ w) (mem : ℕ → ℕ) (idx : ℕ) {j : ℕ} (hj : j < k) :
(Dictionary.WordRAM.BitPackedArray.readPacked arrBase k w mem idx).testBit j = (mem (arrBase + (idx * k + j) / w)).testBit ((idx * k + j) % w)

Exact bit-level characterization of readPacked: for 0 < w, k ≤ w, and j < k, bit j of readPacked arrBase k w mem idx equals bit (idx * k + j) % w of word mem (arrBase + (idx * k + j) / w).

Extract N bit-packed k-bit entries from mem starting at arrBase.

Additive homomorphism projecting packedWords N k w w-bit strings onto N k-bit strings by reading bits [idx * k, (idx + 1) * k).

Map from a raw w-bit word slice Fin (packedWords N k w) → Fin (2 ^ w) to Fin N → Fin (2 ^ k) matching extractPackedSlice.

Pushforward of PMF.uniformOfFintype (Fin (packedWords N k w) → Fin (2 ^ w)) along packedSliceOfWords is PMF.uniformOfFintype (Fin N → Fin (2 ^ k)).

def Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.extractSeed (base w w₀ c_tab d b_char M_out : ℕ) (mem : ℕ → ℕ) :
Seed w₀ c_tab d b_char M_out

Extract the full seed (α, T₁, T₂) from [base, base + space w c_tab d b_char M_out).

def Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.SeedRep (base w w₀ c_tab d b_char M_out : ℕ) (θ : Seed w₀ c_tab d b_char M_out) (mem : ℕ → ℕ) :

Representation predicate for (α, T₁, T₂) in [base, base + space w c_tab d b_char M_out).

theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.seedRep_extractSeed {base w w₀ c_tab d b_char M_out : ℕ} {mem : ℕ → ℕ} (hα : mem base < 2 ^ (w₀ - 1)) :
SeedRep base w w₀ c_tab d b_char M_out (extractSeed base w w₀ c_tab d b_char M_out mem) mem
theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.extractSeed_eq_of_seedRep {base w w₀ c_tab d b_char M_out : ℕ} {θ : Seed w₀ c_tab d b_char M_out} {mem : ℕ → ℕ} (hrep : SeedRep base w w₀ c_tab d b_char M_out θ mem) :
extractSeed base w w₀ c_tab d b_char M_out mem = θ
theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.seedRep_congr_mem {base w w₀ c_tab d b_char M_out : ℕ} {θ : Seed w₀ c_tab d b_char M_out} {mem mem' : ℕ → ℕ} (hw : 0 < w) (hrep : SeedRep base w w₀ c_tab d b_char M_out θ mem) (heq : ∀ (a : ℕ), base ≤ a → a < base + space w c_tab d b_char M_out → mem' a = mem a) :
SeedRep base w w₀ c_tab d b_char M_out θ mem'
theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.SeedRep.congr_on {base w w₀ c_tab d b_char M_out : ℕ} {θ : Seed w₀ c_tab d b_char M_out} {mem mem' : ℕ → ℕ} (hrep : SeedRep base w w₀ c_tab d b_char M_out θ mem) (hw : 0 < w) (heq : ∀ (a : ℕ), base ≤ a → a < base + space w c_tab d b_char M_out → mem' a = mem a) :
SeedRep base w w₀ c_tab d b_char M_out θ mem'

Congruence of SeedRep under memory updates preserving [base, base + space).

Single-pass randFillLoop seed resampling (resampleCode) #

Structured Word-RAM program on Data 12 (keeping reg 0 = base) that samples (α, T₁, T₂) into [base, base + space w c_tab d b_char M_out).

Instruction count 5 * (topWords + botWords) + 10 of resampleCode.

Explicit ProbComp (Data 12 × ℕ) induced by resampleCode.

theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.resampleCode_execRand {w w₀ base c_tab d b_char M_out : ℕ} {x : WordRAM.Data 12} (hw : 0 < w) (hw₀_le : w₀ ≤ w) (hbase : x.regs 0 = base) (hfit_end : WordRAM.Fits w (base + space w c_tab d b_char M_out)) :
WordRAM.ExecRand w (resampleCode w w₀ c_tab d b_char M_out) x (resampleComp base w w₀ c_tab d b_char M_out x)
theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.isQueryBounded_resampleComp (base w w₀ c_tab d b_char M_out : ℕ) (x : WordRAM.Data 12) :
OracleComp.IsQueryBounded (resampleComp base w w₀ c_tab d b_char M_out x) (1 + (topWords w c_tab d b_char + botWords w d b_char M_out))
theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.mem_support_resampleComp {base w w₀ c_tab d b_char M_out : ℕ} {x : WordRAM.Data 12} (hw : 0 < w) (hw₀_le : w₀ ≤ w) (hbase : x.regs 0 = base) (hfit_end : WordRAM.Fits w (base + space w c_tab d b_char M_out)) (hx_bdd : WordRAM.Data.Bounded w x) {z : WordRAM.Data 12 × ℕ} (hz : z ∈ OracleComp.support (resampleComp base w w₀ c_tab d b_char M_out x)) :
z.1.regs 0 = base ∧ SeedRep base w w₀ c_tab d b_char M_out (extractSeed base w w₀ c_tab d b_char M_out z.1.mem) z.1.mem ∧ (∀ q < topWords w c_tab d b_char + botWords w d b_char M_out, z.1.mem (base + 1 + q) < 2 ^ w) ∧ (∀ (a : ℕ), a < base ∨ base + space w c_tab d b_char M_out ≤ a → z.1.mem a = x.mem a) ∧ WordRAM.Data.Bounded w z.1 ∧ z.2 = resampleSteps w c_tab d b_char M_out

Pathwise postcondition of resampleComp: executes in resampleSteps instructions, preserves reg 0 = base, establishes SeedRep, preserves Bounded w, and modifies only [base, base + space).

theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.map_extractSeed_eval_resampleComp {base w w₀ c_tab d b_char M_out : ℕ} (hw : 0 < w) (hb_le : b_char ≤ w) (hM_le : M_out ≤ w) (x : WordRAM.Data 12) :
PMF.map (fun (z : WordRAM.Data 12 × ℕ) => extractSeed base w w₀ c_tab d b_char M_out z.1.mem) (resampleComp base w w₀ c_tab d b_char M_out x).eval = Probability.PMF.uniformOfFintype (Seed w₀ c_tab d b_char M_out)

Exact product uniformity of resampleComp: when 0 < w, b_char ≤ w, and M_out ≤ w, the extracted seed extractSeed base w w₀ c_tab d b_char M_out z.1.mem under resampleComp has exact uniform distribution PMF.uniformOfFintype (Seed w₀ c_tab d b_char M_out).

Section 3: Memory.Prog + realize deterministic O(c_tab * d) evaluation #

Runtime register block of 16 precomputed hash parameters for parameter-free Realizes.

Instances For

    Construct the 16-word parameter vector for (w, w₀, R, c_tab, d, b_char, M_out).

    Word width $w$ in the hash parameter vector.

    Shift count $w₀ - R$ in the hash parameter vector.

    Half-chunk bitwidth $\lfloor(w₀ - 1) / 2\rfloor$ in the hash parameter vector.

    Double half-chunk bitwidth $2 \lfloor(w₀ - 1) / 2\rfloor$ in the hash parameter vector.

    Low chunk mask $2^{w₀ - 1} - 1$ in the hash parameter vector.

    First half-chunk mask in the hash parameter vector.

    Second half-chunk mask in the hash parameter vector.

    Top remainder bit mask in the hash parameter vector.

    Character bitwidth $b$ in the hash parameter vector.

    Character mask $2^b - 1$ in the hash parameter vector.

    Character radix $2^b$ in the hash parameter vector.

    Output word count $M_{\mathrm{out}}$ in the hash parameter vector.

    Memory word offset of bottom table in the hash parameter vector.

    Chunk count plus one ($c_{\mathrm{tab}} + 1$) in the hash parameter vector.

    Chunk count $c_{\mathrm{tab}}$ in the hash parameter vector.

    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpW_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpW (mkHashParams w w₀ R c_tab d b_char M_out) = w
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpShiftR_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpShiftR (mkHashParams w w₀ R c_tab d b_char M_out) = w₀ - R
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpHalfM_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpHalfM (mkHashParams w w₀ R c_tab d b_char M_out) = (w₀ - 1) / 2
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpTwoHalfM_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpTwoHalfM (mkHashParams w w₀ R c_tab d b_char M_out) = 2 * ((w₀ - 1) / 2)
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpMaskM_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpMaskM (mkHashParams w w₀ R c_tab d b_char M_out) = 2 ^ (w₀ - 1) - 1
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpMaskHalf_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpMaskHalf (mkHashParams w w₀ R c_tab d b_char M_out) = 2 ^ ((w₀ - 1) / 2) - 1
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpMaskRem_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpMaskRem (mkHashParams w w₀ R c_tab d b_char M_out) = 2 ^ (w₀ - 1 - (w₀ - 1) / 2) - 1
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpMaskTop_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpMaskTop (mkHashParams w w₀ R c_tab d b_char M_out) = 2 ^ (w₀ - 1 - 2 * ((w₀ - 1) / 2)) - 1
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpBChar_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpBChar (mkHashParams w w₀ R c_tab d b_char M_out) = b_char
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpMaskB_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpMaskB (mkHashParams w w₀ R c_tab d b_char M_out) = 2 ^ b_char - 1
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpPowB_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpPowB (mkHashParams w w₀ R c_tab d b_char M_out) = 2 ^ b_char
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpMOut_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpMOut (mkHashParams w w₀ R c_tab d b_char M_out) = M_out
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpOffBot_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpOffBot (mkHashParams w w₀ R c_tab d b_char M_out) = offBot w c_tab d b_char
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpCPlusOne_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpCPlusOne (mkHashParams w w₀ R c_tab d b_char M_out) = c_tab + 1
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpCTab_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpCTab (mkHashParams w w₀ R c_tab d b_char M_out) = c_tab
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.hpD_mk (w w₀ R c_tab d b_char M_out : ℕ) :
    hpD (mkHashParams w w₀ R c_tab d b_char M_out) = d

    Well-formedness envelope for HashParams at base on a w-bit machine.

    Fit of all 16 words in mkHashParams under HashEnv.

    Inner-loop body (p = ((hp, (base, j)), ((i, y_acc), r_cur))): extracts character i from r_cur, reads T₁[i, j, ch], XORs into y_acc, and shifts r_cur right by b_char.

    Outer-loop body (p = ((hp, (base, (s_val, rKey))), (j, out_acc))): computes y_j across all c_tab + 1 characters, reads T₂[j, y_j], and XORs into out_acc.

    @[reducible, inline]

    Extract the XOR accumulator y from the inner-loop state ((i, y), r).

    Loop-safety, state-preservation, and accumulator-range invariant for innerStepGenProg.

    Parameter-free Memory.Prog hash evaluation (p = (hp, ((base, s_val), u_val))): computes rKey = oddMulModWord w₀ (s.mem base) u_val >>> (w₀ - R) and evaluates (c_tab + 1, d) bit-packed double tabulation in O(c_tab * d) deterministic steps.

    Specialized Memory.Prog hash evaluation at concrete (w, w₀, R, c_tab, d, b_char, M_out).

    Functional correctness, ValidHistory, and memoryCost of evalProg #

    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.evalProg_spec {U w w₀ R c_tab d b_char M_out s_max base : ℕ} {θ : Seed w₀ c_tab d b_char M_out} {s : Memory.State} (hw₀ : 0 < w₀) (hs_max : s_max ≤ 2 ^ b_char) (hrep : SeedRep base w w₀ c_tab d b_char M_out θ s.mem) (salt : Fin s_max) (u : Fin U) :
    (Memory.spec 0).clientResult s (evalProg w w₀ R c_tab d b_char M_out ((base, ↑salt), ↑u)) = ↑(evalSalted U w₀ R c_tab d b_char M_out s_max θ (salt, u)) ∧ (Memory.spec 0).clientState s (evalProg w w₀ R c_tab d b_char M_out ((base, ↑salt), ↑u)) = s

    Exact functional correctness and state preservation of evalProg: under SeedRep, evalProg leaves s unchanged and returns (evalSalted ... θ (salt, u)).val.

    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.memoryCost_evalProg (w w₀ R c_tab d b_char M_out : ℕ) (d_in : (ℕ × ℕ) × ℕ) (s : Memory.State) :
    WordRAM.Realization.memoryCost (evalProg w w₀ R c_tab d b_char M_out d_in) s = 1 + 2 * d * (c_tab + 2)

    Exact memoryCost of evalProg: 1 + 2 * d * (c_tab + 2) (O(c_tab * d)).

    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.validHistory_evalGenProg {w : ℕ} {hp : HashParams} {base s_val u_val : ℕ} {s : Memory.State} (hpre : EvalGenPre w (hp, (base, s_val), u_val) s) (hfr : base + space w (hpCTab hp) (hpD hp) (hpBChar hp) (hpMOut hp) ≤ s.frontier) :

    Memory history admissibility (ValidHistory) for evalGenProg under EvalGenPre and base + space ≤ s.frontier.

    theorem Cslib.DataStructure.HashFamily.WordRAM.BitPackedDoubleTabulation.validHistory_evalProg {w w₀ R c_tab d b_char M_out base s_val u_val : ℕ} {s : Memory.State} (hpre : EvalGenPre w (mkHashParams w w₀ R c_tab d b_char M_out, (base, s_val), u_val) s) (hfr : base + space w c_tab d b_char M_out ≤ s.frontier) :
    (Memory.spec w).ValidHistory s ((Memory.spec w).clientHistory s (evalProg w w₀ R c_tab d b_char M_out ((base, s_val), u_val)))

    Specialized ValidHistory lemma for evalProg.