Documentation

CslibFrontier.DataStructure.HashFamily.WordRAM.RuntimeReducedKWise.ParamsInit

Runtime ReducedKWise Parameters and Four-Russians Table Initialization #

Defines the 162-word limb scratch layout (accWords, prodWords, scratchWords), the 19-word runtime parameter vector (HashParams, mkHashParams), loop-verification helpers on Memory.Prog, and the parameter-free (¬ReadsWidth) runtime Four-Russians carryless multiplication table builder (initTableGenProg) for the two-stage universe-reduced $k$-wise independent polynomial hash family of [BFCKK24].

Main definitions #

Main results #

References #

Section 1: 162-word scratch layout, runtime HashParams, and loop helpers #

Number of accumulator limb words (54 ≥ reducedLimbCount t) at [scratchBase, +54).

Number of product limb words (108 ≥ 2 * reducedLimbCount t) at [scratchBase + 54, +108).

Total scratch footprint (54 + 108 = 162 words) for runtime polynomial hash evaluation.

19-word runtime parameter vector passed to initTableGenProg and evalHashGenProg.

Instances For

    Populate the 19-word HashParams vector for (w, w₀, b, b', k).

    @[reducible, inline]

    Total word space allocated for hash parameters and polynomial state.

    @[reducible, inline]

    Number of seed words for the hash family.

    @[reducible, inline]

    Number of bottom-limb words.

    @[reducible, inline]

    Bitmask for limb size $m$.

    @[reducible, inline]

    Half-limb width $h$.

    @[reducible, inline]

    Bitmask for half-limb width $h$.

    @[reducible, inline]

    Bitmask for $m - h$ bits.

    @[reducible, inline]

    Bitmask for $m - 2h$ bits.

    @[reducible, inline]

    Shift amount for remainder reduction.

    @[reducible, inline]

    Bitmask for chunk width $c$.

    @[reducible, inline]

    Twice the chunk width, $2c$.

    @[reducible, inline]

    Power of two $2^{2c}$.

    @[reducible, inline]

    Bitmask for $2c$ bits.

    @[reducible, inline]

    Packing shift parameter $p$.

    @[reducible, inline]

    Bitmask for $p$ bits.

    @[reducible, inline]

    Number of initial limb words $L_0$.

    @[reducible, inline]

    Polynomial degree parameter $k$.

    @[reducible, inline]

    Target hash output bit-length $b'$.

    @[simp]
    @[simp]
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.RuntimeReducedKWise.hpMaskH_mk (w w₀ b b' k : ℕ) :
    hpMaskH (mkHashParams w w₀ b b' k) = 2 ^ ((w₀ - 1) / 2) - 1
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.RuntimeReducedKWise.hpMaskMH_mk (w w₀ b b' k : ℕ) :
    hpMaskMH (mkHashParams w w₀ b b' k) = 2 ^ (w₀ - 1 - (w₀ - 1) / 2) - 1
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.RuntimeReducedKWise.hpMaskM2H_mk (w w₀ b b' k : ℕ) :
    hpMaskM2H (mkHashParams w w₀ b b' k) = 2 ^ (w₀ - 1 - 2 * ((w₀ - 1) / 2)) - 1
    @[simp]
    theorem Cslib.DataStructure.HashFamily.WordRAM.RuntimeReducedKWise.fits_mkHashParams {w w₀ b b' k hashBase scratchBase : ℕ} (_hw₀_pos : 0 < w₀) (hw₀ : w₀ ≤ w) (hb' : b' ≤ w) (hc_lt : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') < w) (hfit_hash : WordRAM.Fits w (hashBase + ReducedKWise.space w w₀ b b' k)) (hfit_scr : WordRAM.Fits w (scratchBase + scratchWords)) (i : Fin 19) :
    WordRAM.Fits w (mkHashParams w w₀ b b' k i)

    Every word of mkHashParams w w₀ b b' k fits in a w-bit register.

    Section 2: Runtime Memory.Prog table construction (initTableGenProg) #

    Full runtime Four-Russians table initialization Memory.Prog.

    theorem Cslib.DataStructure.HashFamily.WordRAM.RuntimeReducedKWise.initTableGenProg_spec {w w₀ b b' k hashBase : ℕ} {s₀ : Memory.State} (hc_lt : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') < w) (hfr : hashBase + ReducedKWise.space w w₀ b b' k ≤ s₀.frontier) (hfit : WordRAM.Fits w (hashBase + ReducedKWise.space w w₀ b b' k)) :
    have hp := mkHashParams w w₀ b b' k; have prog := initTableGenProg (hp, hashBase); have s' := (Memory.spec 0).clientState s₀ prog; InitTableGenPre w (hp, hashBase) s₀ ∧ (Memory.spec w).ValidHistory s₀ ((Memory.spec w).clientHistory s₀ prog) ∧ WordRAM.Realization.memoryCost prog s₀ ≤ 4 * 2 ^ (2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b')) ∧ s'.frontier = s₀.frontier ∧ ReducedKWise.TableRep hashBase w w₀ b b' k s'.mem ∧ ∀ (a : ℕ), a < ReducedKWise.tabBase hashBase w₀ b b' k ∨ hashBase + ReducedKWise.space w w₀ b b' k ≤ a → s'.mem a = s₀.mem a

    Full specification of initTableGenProg.

    Section 3: Key reduction and word-zeroing helpers #

    theorem Cslib.DataStructure.HashFamily.WordRAM.RuntimeReducedKWise.zeroWordsLoop_spec {w baseAddr n : ℕ} {s₀ : Memory.State} (hfr : baseAddr + n ≤ s₀.frontier) :
    have prog := WordRAM.Realization.iterate zeroWordsStepProg baseAddr n 0; have s' := (Memory.spec 0).clientState s₀ prog; WordRAM.Realization.iterationSafe zeroWordsStepProg ZeroWordsStepPre w baseAddr n 0 s₀ ∧ (Memory.spec w).ValidHistory s₀ ((Memory.spec w).clientHistory s₀ prog) ∧ WordRAM.Realization.memoryCost prog s₀ ≤ n ∧ s'.frontier = s₀.frontier ∧ (∀ d < n, s'.mem (baseAddr + d) = 0) ∧ ∀ (a : ℕ), a < baseAddr ∨ baseAddr + n ≤ a → s'.mem a = s₀.mem a