Documentation

CslibFrontier.DataStructure.HashFamily.WordRAM.ReducedKWise

Universe-Reduced k-Wise Independent Hashing with Bit-Packed Tables #

This module provides a reusable Word-RAM implementation of the two-stage universe-reduced k-wise independent hash family (Cslib.Probability.reducedPolyHash U w₀ b b' k) over Cslib.WordRAM.Basis.exact and lifts it to Cslib.WordRAM.Basis.standard:

  1. Two-stage construction without any universe restriction (U ≤ 2 ^ w₀, 0 < w₀ ≤ w):
    • Stage 1 (overflow-free multiply-shift reduction): reduces any w₀-bit key u : Fin U (0 < w₀ ≤ w) to R = min w₀ (3 * b) bits via multiplyShiftReduced U w₀ (3 * b) α u using oddMulModWord (39 deterministic instructions, no 2 * w₀ ≤ w restriction).
    • Stage 2 (limb-aligned trinomial polynomial hash with bit-packed Four-Russians table): evaluates a degree-< k polynomial over GF(2)[X] / (X^{2·3^t} + X^{3^t} + 1) on the reduced key using L = reducedLimbCount t ≤ 54 limbs of c = reducedChunkBits t = 3 ^ (t - 3) bits and a bit-packed Four-Russians carryless multiplication table of reducedTableBits t ≤ max 8 (2 ^ (b / 2)) = o(2 ^ b) bits (b' ≤ 3 * b).
  2. Compact O(k) + o(2 ^ b) / w-word memory layout (space w w₀ b b' k):
    • [base, base + 1 + k * L) stores the top seed α : Fin (2 ^ (w₀ - 1)) (1 word) and the k * L c-bit limbs of the polynomial coefficients β : Fin k → Fin (2 ^ (2 * 3 ^ t)) (1 + k * L ≤ 1 + 54 * k = O(k) words).
    • [base + 1 + k * L, base + space w w₀ b b' k) stores the bit-packed carryless multiplication table in tableWords w w₀ b b' = reducedTableWords t w words.
  3. O(1) worst-case evaluation time for fixed k (evalCode w w₀ b b' k):
    • Executes in evalSteps w₀ b b' k ≤ evalBound k = 47250 * k + 591 = O(k) deterministic instructions completely independent of w, w₀, b, b', and U.
  4. Conditional k-wise independence and HashFamily.WordRAM.Impl packaging:
    • Conditioned on any top seed α ∈ reducedGoodTop U w₀ (3 * b) S that is injective on S : Finset (Fin U) (failure probability ≤ (#S * (#S - 1)) / 2 ^ min w₀ (3 * b)), the restricted family on S is exact k-wise independent (IsKWiseIndependentHash k).

Main definitions #

Main results #

References #

Section 1: Memory layout, representation predicates, and seed extraction #

Number of seed words 1 + k * reducedLimbCount (reducedTrinomialStep w₀ b b') (1 word for the multiply-shift seed α and k * L words for the c-bit limbs of the k polynomial coefficients).

Number of words reducedTableWords (reducedTrinomialStep w₀ b b') w occupied by the bit-packed Four-Russians carryless multiplication table.

Total memory footprint seedWords w₀ b b' k + tableWords w w₀ b b' in words.

Base address base + seedWords w₀ b b' k of the bit-packed carryless multiplication table.

Address base + 1 + (m.val + L * j.val) of the m-th limb of polynomial coefficient j.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.shiftRight_lt_pow_sub {m h a : ℕ} (hle : h ≤ m) (ha : a < 2 ^ m) :
a >>> h < 2 ^ (m - h)

Bit offset (idx &&& (2 ^ reducedPackShift t w - 1)) * (2 * reducedChunkBits t) of a packed carryless-multiplication table slot fits below the word width w.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.tableWords_le {w w₀ b b' : ℕ} (hw₀ : w₀ ≤ w) (hb' : b' ≤ 3 * b) (hb'_w : b' ≤ w) (hw : 2 ≤ w) :
tableWords w w₀ b b' ≤ 2 * max 8 (2 ^ (b / 2)) / w + 1
theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.space_le {w w₀ b b' k : ℕ} (hw₀ : w₀ ≤ w) (hb' : b' ≤ 3 * b) (hb'_w : b' ≤ w) (hw : 2 ≤ w) :
space w w₀ b b' k ≤ 2 + 54 * k + 2 * max 8 (2 ^ (b / 2)) / w

Compact space bound: whenever w₀ ≤ w, b' ≤ 3 * b, b' ≤ w, and 2 ≤ w, space w w₀ b b' k uses at most 2 + 54 * k + 2 * max 8 (2 ^ (b / 2)) / w words (O(k) + o(2 ^ b) / w).

Whenever 2 * reducedChunkBits t ≤ w and Fits w (base + space w w₀ b b' k), we have strict inequality 2 * reducedChunkBits t < w (and hence 2 ^ (2 * reducedChunkBits t) < 2 ^ w).

Deterministic precomputed table invariant at tabBase base w₀ b b' k: every table word is < 2 ^ (2 ^ p * (2 * c)) and every 2 * c-bit slice idx < 2 ^ (2 * c) stores clmul (idx >>> c) (idx &&& (2 ^ c - 1)).

Seed representation invariant linking θ : ReducedPolySeed w₀ b b' k to memory at [base, base + seedWords w₀ b b' k).

def Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.Rep (base w w₀ b b' k : ℕ) (θ : Probability.ReducedPolySeed w₀ b b' k) (mem : ℕ → ℕ) :

Combined table + seed invariant TableRep ∧ SeedRep.

Equivalence (Fin 1 → Fin (2 ^ (w₀ - 1))) ≃ ReducedTopSeed w₀.

Equivalence between flat k * L-word slices of c-bit limbs and ReducedBotSeed w₀ b b' k.

Extract the top-level multiply-shift seed α : ReducedTopSeed w₀ from mem base.

Extract the bottom-level polynomial seed β : ReducedBotSeed w₀ b b' k from [base + 1, base + 1 + k * L).

Extract the full seed (α, β) : ReducedPolySeed w₀ b b' k from memory.

@[simp]
theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.extractTop_val (base w₀ : ℕ) (mem : ℕ → ℕ) :
↑(extractTop base w₀ mem) = ↑(WordRAM.wordOfNat (w₀ - 1) (mem base))
theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.getLimb_extractBot_val (base w₀ b b' k : ℕ) (mem : ℕ → ℕ) (j : Fin k) (m : Fin (Probability.reducedLimbCount (Probability.reducedTrinomialStep w₀ b b'))) :
have t := Probability.reducedTrinomialStep w₀ b b'; have c := Probability.reducedChunkBits t; have L := Probability.reducedLimbCount t; Probability.getLimb c ↑(extractBot base w₀ b b' k mem j) ↑m = ↑(WordRAM.wordOfNat c (mem (base + 1 + (↑m + L * ↑j))))
theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.extractSeed_of_seedRep {base w₀ b b' k : ℕ} {θ : Probability.ReducedPolySeed w₀ b b' k} {mem : ℕ → ℕ} (hseed : SeedRep base w₀ b b' k θ mem) :
extractSeed base w₀ b b' k mem = θ

Extracting a seed from memory satisfying SeedRep recovers the original seed θ.

Register layout on Data 240 #

Reduced-key limb register 20 + m % 54 (0 ≤ m < L ≤ 54).

Horner accumulator limb register 74 + m % 54 (0 ≤ m < L ≤ 54).

Carryless product limb register 128 + d % 108 (0 ≤ d < 2 * L ≤ 108).

Register embedding Fin 6 → Fin 240 for Tabulation.randFillLoop: maps [0, 1, 2, 3, 4, 5] ↦ [3, 4, 5, 6, 7, 0].

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.tableRep_congr {base w w₀ b b' k : ℕ} {mem₁ mem₂ : ℕ → ℕ} (htab : TableRep base w w₀ b b' k mem₁) (heq : ∀ (a : ℕ), base ≤ a → a < base + space w w₀ b b' k → mem₁ a = mem₂ a) :
TableRep base w w₀ b b' k mem₂

TableRep depends only on memory in [base, base + space w w₀ b b' k).

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.seedRep_congr {base w w₀ b b' k : ℕ} {θ : Probability.ReducedPolySeed w₀ b b' k} {mem₁ mem₂ : ℕ → ℕ} (hseed : SeedRep base w₀ b b' k θ mem₁) (heq : ∀ (a : ℕ), base ≤ a → a < base + space w w₀ b b' k → mem₁ a = mem₂ a) :
SeedRep base w₀ b b' k θ mem₂

SeedRep depends only on memory in [base, base + space w w₀ b b' k).

Section 2: Bit-packed Four-Russians table construction (initTableCode) #

Closed-form state after initTableSetupCode w w₀ b b' k.

29-instruction body of clmulTabLoop on Data 240, populating slice idx &&& (2 ^ p - 1) of mem[tabBase + (idx >>> p)] with clmul (idx >>> c) (idx &&& (2 ^ c - 1)).

Loop while idx < 2 ^ (2 * c) do clmulTabBody populating the bit-packed carryless multiplication table.

Full table initialization program on Data 240.

Exact instruction count 31 * 2 ^ (2 * c) + 13 of initTableCode w w₀ b b' k.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.clmulTab_getLimb_update_lt {p c tBase idx j val : ℕ} {mem : ℕ → ℕ} (hj : j < idx) (hval : val < 2 ^ (2 * c)) :
have wIdx := idx >>> p; have sh := (idx &&& 2 ^ p - 1) * (2 * c); have w' := mem (tBase + wIdx) &&& 1 <<< sh - 1 ^^^ val <<< sh; Probability.getLimb (2 * c) (Function.update mem (tBase + wIdx) w' (tBase + j >>> p)) (j &&& 2 ^ p - 1) = Probability.getLimb (2 * c) (mem (tBase + j >>> p)) (j &&& 2 ^ p - 1)

Modifying the bit-packed slice (idx >>> p, idx &&& (2 ^ p - 1)) by clearing all bits at or above sh = (idx &&& (2 ^ p - 1)) * (2 * c) and XORing in val <<< sh (val < 2 ^ (2 * c)) preserves getLimb (2 * c) at every strictly earlier entry j < idx.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.update_word_lt {tBase wIdx newW B : ℕ} {mem : ℕ → ℕ} (hnew : newW < B) (hold : ∀ w' < wIdx, mem (tBase + w') < B) {w' : ℕ} (hw' : w' ≤ wIdx) :
Function.update mem (tBase + wIdx) newW (tBase + w') < B

Updating word tBase + wIdx to a value below B preserves the < B bound on every word tBase + w' with w' ≤ wIdx, assuming all strictly earlier words already satisfy < B.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.clmulTab_prev_limb {t w tBase idx : ℕ} {mem : ℕ → ℕ} (hidx : idx < 2 ^ (2 * Probability.reducedChunkBits t)) (hentry : ∀ i < idx, Probability.getLimb (2 * Probability.reducedChunkBits t) (mem (tBase + i >>> Probability.reducedPackShift t w)) (i &&& 2 ^ Probability.reducedPackShift t w - 1) = clmul (i >>> Probability.reducedChunkBits t) (i &&& 2 ^ Probability.reducedChunkBits t - 1)) :
have c := Probability.reducedChunkBits t; have p := Probability.reducedPackShift t w; have u := idx >>> c; have v := idx &&& 2 ^ c - 1; have prevIdx := u <<< c + v >>> 1; have wIdx := idx >>> p; have masked := mem (tBase + wIdx) &&& 1 <<< ((idx &&& 2 ^ p - 1) * (2 * c)) - 1; Function.update mem (tBase + wIdx) masked (tBase + prevIdx >>> p) >>> ((prevIdx &&& 2 ^ p - 1) * (2 * c)) &&& 2 ^ (2 * c) - 1 = clmul u (v >>> 1)

After masking bits at or above slot (idx &&& (2 ^ p - 1)) * (2 * c) of word tBase + (idx >>> p), reading the packed limb at prevIdx = ((idx >>> c) <<< c) + (v >>> 1) returns clmul (idx >>> c) ((idx &&& (2 ^ c - 1)) >>> 1) whenever all strictly earlier entries < idx hold their carryless products.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.clmulTabLoop_exec {w tBase t : ℕ} (hc_lt : 2 * Probability.reducedChunkBits t < w) (hfit_end : WordRAM.Fits w (tBase + Probability.reducedTableWords t w)) :
have c := Probability.reducedChunkBits t; have p := Probability.reducedPackShift t w; ∀ (rem idx : ℕ) (x : WordRAM.Data 240), idx + rem = 2 ^ (2 * c) → x.regs 0 = x.regs 0 → x.regs 1 = tBase → x.regs 2 = idx → x.regs 3 = 2 ^ (2 * c) → x.regs 4 = c → x.regs 5 = 2 ^ c - 1 → x.regs 6 = 1 → x.regs 7 = p → x.regs 8 = 2 ^ p - 1 → x.regs 9 = 2 * c → x.regs 18 = 2 ^ (2 * c) - 1 → (∀ wIdx < idx >>> p, x.mem (tBase + wIdx) < 2 ^ (2 ^ p * (2 * c))) → (∀ i < idx, Probability.getLimb (2 * c) (x.mem (tBase + i >>> p)) (i &&& 2 ^ p - 1) = clmul (i >>> c) (i &&& 2 ^ c - 1)) → ∃ (y : WordRAM.Data 240), WordRAM.Exec w clmulTabLoop x y (31 * rem + 2) ∧ y.regs 0 = x.regs 0 ∧ (∀ wIdx < Probability.reducedTableWords t w, y.mem (tBase + wIdx) < 2 ^ (2 ^ p * (2 * c))) ∧ (∀ i < 2 ^ (2 * c), Probability.getLimb (2 * c) (y.mem (tBase + i >>> p)) (i &&& 2 ^ p - 1) = clmul (i >>> c) (i &&& 2 ^ c - 1)) ∧ ∀ (a : ℕ), a < tBase + idx >>> p ∨ tBase + Probability.reducedTableWords t w ≤ a → y.mem a = x.mem a
theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.initTableCode_exec {w base w₀ b b' k : ℕ} {x : WordRAM.Data 240} (hbase : x.regs 0 = base) (hc : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') ≤ w) (hfit_space : WordRAM.Fits w (base + space w w₀ b b' k)) :
∃ (y : WordRAM.Data 240), WordRAM.Exec w (initTableCode w w₀ b b' k) x y (initTableSteps w₀ b b') ∧ y.regs 0 = base ∧ TableRep base w w₀ b b' k y.mem ∧ ∀ (a : ℕ), a < tabBase base w₀ b b' k ∨ base + space w w₀ b b' k ≤ a → y.mem a = x.mem a

Deterministic execution of initTableCode w w₀ b b' k: establishes TableRep, preserves reg 0 = base, and modifies only [tabBase base w₀ b b' k, base + space w w₀ b b' k).

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.initTableCode_execWithin {w base w₀ b b' k : ℕ} {x : WordRAM.Data 240} (hbase : x.regs 0 = base) (hc : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') ≤ w) (hfit_space : WordRAM.Fits w (base + space w w₀ b b' k)) :
∃ (y : WordRAM.Data 240), WordRAM.ExecWithin w (initTableCode w w₀ b b' k) x y (initTableSteps w₀ b b') ∧ y.regs 0 = base ∧ TableRep base w w₀ b b' k y.mem ∧ ∀ (a : ℕ), a < tabBase base w₀ b b' k ∨ base + space w w₀ b b' k ≤ a → y.mem a = x.mem a

ExecWithin corollary of initTableCode_exec.

Section 3: Exact uniform seed resampling (resampleCode) #

5-instruction setup for the top-seed Tabulation.randFillLoop call on Data 240.

4-instruction setup for the bottom-seed Tabulation.randFillLoop call on Data 240.

Structured Word-RAM program on Data 240 that resamples both α and β via two sequential Tabulation.randFillLoop calls.

Exact instruction count 5 * seedWords w₀ b b' k + 13 of resampleCode w₀ b b' k.

Explicit ProbComp (Data 240 × ℕ) induced by resampleCode w₀ b b' k.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.resampleCode_execRand {w base w₀ b b' k : ℕ} {x : WordRAM.Data 240} (hbase : x.regs 0 = base) (hw₀ : w₀ ≤ w) (hc : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') ≤ w) (hfit_space : WordRAM.Fits w (base + space w w₀ b b' k)) :
WordRAM.ExecRand w (resampleCode w₀ b b' k) x (resampleComp base w₀ b b' k x)

Exact ExecRand execution of resampleCode w₀ b b' k.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.mem_support_resampleComp {base w w₀ b b' k : ℕ} {x : WordRAM.Data 240} (hbase : x.regs 0 = base) (htab : TableRep base w w₀ b b' k x.mem) {z : WordRAM.Data 240 × ℕ} (hz : z ∈ OracleComp.support (resampleComp base w₀ b b' k x)) :
z.1.regs 0 = base ∧ TableRep base w w₀ b b' k z.1.mem ∧ SeedRep base w₀ b b' k (extractSeed base w₀ b b' k z.1.mem) z.1.mem ∧ (∀ (a : ℕ), a < base ∨ base + seedWords w₀ b b' k ≤ a → z.1.mem a = x.mem a) ∧ z.2 = resampleSteps w₀ b b' k

Pathwise postcondition of resampleComp: executes in resampleSteps w₀ b b' k instructions, preserves reg 0 = base and TableRep, establishes SeedRep, and modifies only [base, base + seedWords w₀ b b' k).

Exact product uniformity of resampleComp: extractSeed base w₀ b b' k z.1.mem under resampleComp base w₀ b b' k x has distribution PMF.uniformOfFintype (ReducedPolySeed w₀ b b' k).

Section 4: Word-RAM evalCode and deterministic execution #

Ascending sequential composition of n blocks f 0, f 1, ..., f (n - 1).

Part 1a of Stage 1 (12 instructions): loads α = x.mem (x.regs 0), sets half-width masks and shifts in regs 5..10, and splits α and x' = x.regs 1 &&& (2 ^ m - 1) into regs 12..15.

Part 1b of Stage 1 (18 instructions): combines the half-words in regs 12..15 into halfMulMod m α x' in reg 3.

Part 1c of Stage 1 (9 instructions): finishes oddMulModWord w₀ α u and shifts right by w₀ - min w₀ (3 * b) into reg 3.

Stage 1 of evalCode (39 instructions): computes the multiply-shift reduced key oddMulModWord w₀ α u >>> (w₀ - min w₀ (3 * b)) into reg 3.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.reduceKeyCode_exec {w w₀ b : ℕ} (hw₀_pos : 0 < w₀) (hw₀ : w₀ ≤ w) (x : WordRAM.Data 240) (hα : x.mem (x.regs 0) < 2 ^ (w₀ - 1)) (hu : x.regs 1 < 2 ^ w₀) :
∃ (y : WordRAM.Data 240), WordRAM.Exec w (reduceKeyCode w₀ b) x y 39 ∧ y.regs 0 = x.regs 0 ∧ y.regs 3 = Probability.oddMulModWord w₀ (x.mem (x.regs 0)) (x.regs 1) >>> (w₀ - min w₀ (3 * b)) ∧ y.mem = x.mem

Stage 1 execution: computes oddMulModWord w₀ (x.mem (x.regs 0)) (x.regs 1) >>> (w₀ - min w₀ (3 * b)) into reg 3 in 39 steps, preserving reg 0 and memory.

Step m of Stage 2 (5 instructions): extracts limb m of r_val from reg 3 into xReg m, shifts reg 3 right by c, and zeroes accReg m.

Stage 2a of evalCode: extracts all L limbs of the reduced key into xReg 0 .. xReg (L - 1) and zeroes accReg 0 .. accReg (L - 1).

Stage 2b of evalCode (8 instructions): loads table/chunk constants into regs 4..9 and reg 18.

Register invariant preserved across all Stage 3 Horner operations.

def Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.ClmulInv (base w w₀ b b' k r_val acc_val : ℕ) (x : WordRAM.Data 240) :

Invariant combining HornerConsts and the current accumulator limbs in accReg.

Inner step (i, m) (13 instructions): looks up clmul (accLimb i) (xLimb m) in the bit-packed Four-Russians table and XORs its low and high c-bit halves into prodReg (i + m) and prodReg (i + m + 1).

Full L × L limb-by-limb carryless multiplication into prodReg 0 .. prodReg (2 * L - 1).

Step m < 2 * L₀ of trinomial reduction and seed addition (6 instructions): loads limb m of coefficient coeffIdx from memory, reduces the product limbs in prodReg modulo X ^ (2 * 3 ^ t) + X ^ (3 ^ t) + 1, and writes the XOR into accReg m.

Trinomial reduction and seed addition across all 2 * L₀ = L limbs.

Step j < k of Horner polynomial evaluation: multiplies accReg by xReg into prodReg, reduces modulo the trinomial, and adds coefficient k - 1 - j.

Stage 3 of evalCode: k Horner steps evaluating polynomialHash.

Step m < L of Stage 4 (5 instructions): masks and shifts accReg m into reg 2 to reconstruct the low b' bits of the polynomial evaluation.

Stage 4 of evalCode: packs the low b' bits of accReg 0 .. accReg (L - 1) into reg 2.

Complete deterministic Word-RAM hash evaluation program evalCode w w₀ b b' k on Data 240: reduces reg 1 via Stage 1 (reduceKeyCode), unpacks limbs and sets up Horner constants via Stage 2 (initLimbsCode, hornerSetupCode), runs k Horner steps via Stage 3 (hornerCode), and packs the low b' bits into reg 2 via Stage 4 (packOutCode).

Exact instruction count of evalCode w w₀ b b' k.

Parameter-independent O(k) upper bound 47250 * k + 591 on evalSteps w₀ b b' k.

evalSteps w₀ b b' k is O(k) (evalSteps_le): for all w₀, b, b', k : ℕ, evalSteps w₀ b b' k ≤ evalBound k = 47250 * k + 591.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.evalCode_exec {base w U w₀ b b' k : ℕ} (hw₀_pos : 0 < w₀) (hw₀ : w₀ ≤ w) (hU : U ≤ 2 ^ w₀) (hb' : b' ≤ w) (hc_lt : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') < w) (hfit_space : WordRAM.Fits w (base + space w w₀ b b' k)) (θ : Probability.ReducedPolySeed w₀ b b' k) (u : Fin U) (x : WordRAM.Data 240) (h0 : x.regs 0 = base) (h1 : x.regs 1 = ↑u) (htab : TableRep base w w₀ b b' k x.mem) (hseed : SeedRep base w₀ b b' k θ x.mem) :
∃ (y : WordRAM.Data 240), WordRAM.Exec w (evalCode w w₀ b b' k) x y (evalSteps w₀ b b' k) ∧ y.regs 0 = base ∧ y.regs 2 = ↑(Probability.reducedPolyHash U w₀ b b' k θ u) ∧ y.mem = x.mem

Deterministic execution of evalCode w w₀ b b' k: evaluates (reducedPolyHash U w₀ b b' k θ u).val into reg 2 in evalSteps w₀ b b' k instructions while preserving reg 0 = base and all memory.

theorem Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.evalCode_execWithin {base w U w₀ b b' k : ℕ} (hw₀_pos : 0 < w₀) (hw₀ : w₀ ≤ w) (hU : U ≤ 2 ^ w₀) (hb' : b' ≤ w) (hc_lt : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') < w) (hfit_space : WordRAM.Fits w (base + space w w₀ b b' k)) (θ : Probability.ReducedPolySeed w₀ b b' k) (u : Fin U) (x : WordRAM.Data 240) (h0 : x.regs 0 = base) (h1 : x.regs 1 = ↑u) (htab : TableRep base w w₀ b b' k x.mem) (hseed : SeedRep base w₀ b b' k θ x.mem) :
∃ (y : WordRAM.Data 240), WordRAM.ExecWithin w (evalCode w w₀ b b' k) x y (evalSteps w₀ b b' k) ∧ y.mem = x.mem ∧ y.regs 0 = base ∧ y.regs 2 = ↑(Probability.reducedPolyHash U w₀ b b' k θ u)

ExecWithin wrapper for evalCode_exec.

Section 5: Packaging as HashFamily.WordRAM.Impl #

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.impl {w base U w₀ b b' k : ℕ} (hw₀_pos : 0 < w₀) (hw₀ : w₀ ≤ w) (hU : U ≤ 2 ^ w₀) (hb' : b' ≤ w) (hc_lt : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') < w) (hfit_space : WordRAM.Fits w (base + space w w₀ b b' k)) :
Impl WordRAM.Basis.exact 240 0 w base U (2 ^ b') ![]

Package ReducedKWise into a reusable HashFamily.WordRAM.Impl certificate over Basis.exact on Data 240.

noncomputable def Cslib.DataStructure.HashFamily.WordRAM.ReducedKWise.implStandard {w base U w₀ b b' k : ℕ} (hw₀_pos : 0 < w₀) (hw₀ : w₀ ≤ w) (hU : U ≤ 2 ^ w₀) (hb' : b' ≤ w) (hc_lt : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') < w) (hfit_space : WordRAM.Fits w (base + space w w₀ b b' k)) :
Impl WordRAM.Basis.standard 240 0 w base U (2 ^ b') ![]

Standard-basis lifting of impl.