Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.UniformProbing

Self-Contained Open-Addressed Permutation-Probing Dictionary on the Word-RAM #

This file implements a self-contained open-addressed permutation-probing dictionary realizing Cslib.DataStructure.Dictionary.spec U V n_max (query and insert up to n_max distinct keys) on the Word-RAM (Cslib.WordRAM.Basis.exact and Cslib.WordRAM.Basis.standard), combining the power-of-two odd-stride double-hashing construction of Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, third edition (MIT Press, 2009), Section 11.4, "Double hashing", pp. 269–277, the k-wise independence double hashing analysis of J. P. Schmidt and A. Siegel, The Analysis of Closed Hashing under Limited Randomness, STOC 1990, pp. 224–234; extended NYU Courant Technical Report TR1995-687, May 1995, pp. 1–2, 4–7, 37–39, and Mikkel Thorup's Double Tabulation (M. Thorup, Simple Tabulation, Fast Expanders, Double Tabulation, and High Independence, FOCS 2013, pp. 90–99; arXiv:1311.3121v2, pp. 4–5, 11–13, Theorem 1(a) and Lemma 2).

Design and reuse of Cslib.DataStructure.Dictionary.UniformProbing and DoubleHashing #

In the ideal uniform-probing model (CslibFrontier/DataStructure/Dictionary/UniformProbing.lean), each key u : Fin U is assigned an independent random permutation π u : Equiv.Perm (Fin m). Storing an explicit table of U permutations requires Ω(U) words when U = poly(n_max) ≫ n_max.

To achieve a self-contained O_{c_exp}(n_max + 1)-word data structure with assumption-free O_{c_exp}(1) expected operation time whenever U ≤ max n_max 4 ^ c_exp, we construct for each key u : Fin U a full-cycle affine permutation of m = 2 ^ M slots (M = bucketBits n_max = Nat.clog 2 (32 * max n_max 4)): probePerm θ u i = (h₁(u) + i * (2 * h₂(u) + 1)) mod 2 ^ M, where h₁(u) ∈ Fin (2 ^ M) and h₂(u) ∈ Fin (2 ^ (M - 1)) are independent instances of Mikkel Thorup's Double Tabulation (Cslib.DataStructure.HashFamily.WordRAM.DoubleTabulation, with c = 2 * max c_exp 1, d = 8 * c, and b = (1 + Nat.clog 2 (max n_max 4)) / 2).

Because 2 * h₂(u) + 1 is always odd and therefore coprime to 2 ^ M, probePerm θ u is a bijection on Fin (2 ^ M) for every seed θ and key u (DoubleHashing.bijective_oddStrideSeq). We maintain DoubleHashing.OrderedTableRep (probePerm θ) on the concrete Word-RAM slot arrays and bound the expected probe count by probeBound c_exp n_max across all capacities n_max : ℕ: at most 3 probes once doubleTabThreshold c_exp ≤ n_max (DoubleHashing.expect_probeCount_oddStride_doubleTab_le) and at most doubleTabThreshold c_exp below it (DoubleHashing.expect_probeCount_oddStride_unconditional_le). This yields an assumption-free expected operation charge charge c_exp n_max, which is at most the O_{c_exp}(1) bound expectedOpCharge c_exp independent of n_max and U, and equals the threshold-free hashEvalSteps c_exp + 47 above the threshold, together with space c_exp n_max ≤ spaceFactor c_exp * (n_max + 1) = O_{c_exp}(n_max + 1) words of memory.

Main definitions #

Main results #

References #

Section 1: Table Parameters, Seed Space, and Full-Cycle Probe Permutations #

Log₂ of the power-of-2 table size: M = ⌈log₂ (32 * max n_max 4)⌉ ≥ 7.

Power-of-2 number of open-addressed table slots m = 2 ^ bucketBits n_max ≥ 32 * max n_max 4.

@[reducible, inline]

Number of base-2 ^ b characters c = 2 * max c_exp 1 for Double Tabulation under U ≤ max n_max 4 ^ c_exp.

@[reducible, inline]

Intermediate tuple length d = 8 * numChars c_exp = 16 * max c_exp 1 for Double Tabulation.

@[reducible, inline]

Character bit-width b = (1 + Nat.clog 2 (max n_max 4)) / 2 for Double Tabulation.

Memory footprint (numChars c_exp + 1) * tupleLen c_exp * 2 ^ charBits n_max words of a single Double Tabulation table (T₁ and T₂).

Offset 2 * singleTabSpace c_exp n_max of the open-addressed slot arrays relative to base (after the primary hash table at [base, base + singleTabSpace c_exp n_max) and the stride hash table at [base + singleTabSpace c_exp n_max, base + 2 * singleTabSpace c_exp n_max)).

Total memory footprint slotOffset c_exp n_max + 3 * numBuckets n_max words in [base, base + space c_exp n_max).

Explicit O_{c_exp}(1) linear-space factor bounding space c_exp n_max by spaceFactor c_exp * (n_max + 1) across every n_max : ℕ.

theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.space_le (c_exp n_max : ℕ) :
space c_exp n_max ≤ spaceFactor c_exp * (n_max + 1)

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

@[reducible, inline]

Combined Double Tabulation seed DoubleHashSeed c_exp n_max (bucketBits n_max) consisting of the primary hash seed (T₁, T₂) and the half-range stride hash seed (S₁, S₂).

noncomputable def Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.seedLaw (c_exp n_max : ℕ) :
PMF (Seed c_exp n_max)

Uniform reference distribution over Seed c_exp n_max.

def Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.primaryHash {c_exp U n_max : ℕ} (θ : Seed c_exp n_max) (u : Fin U) :
Fin (numBuckets n_max)

Double Tabulation primary slot h₁(u) ∈ Fin (numBuckets n_max).

def Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.rawStrideHash {c_exp U n_max : ℕ} (θ : Seed c_exp n_max) (u : Fin U) :
Fin (2 ^ (bucketBits n_max - 1))

Double Tabulation half-range stride index h₂(u) ∈ Fin (2 ^ (bucketBits n_max - 1)).

def Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.strideHash {c_exp U n_max : ℕ} (θ : Seed c_exp n_max) (u : Fin U) :
Fin (numBuckets n_max)

Odd probe stride 2 * (rawStrideHash θ u).val + 1 ∈ Fin (numBuckets n_max).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.val_strideHash {c_exp U n_max : ℕ} (θ : Seed c_exp n_max) (u : Fin U) :
↑(strideHash θ u) = 2 * ↑(rawStrideHash θ u) + 1
noncomputable def Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.probePerm {c_exp U n_max : ℕ} (θ : Seed c_exp n_max) (u : Fin U) :

Full-cycle double-hashing probe permutation probePerm θ u : Equiv.Perm (Fin (numBuckets n_max)) sending probe index i to (h₁(u) + i * (2 * h₂(u) + 1)) mod 2 ^ M.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.val_probePerm {c_exp U n_max : ℕ} (θ : Seed c_exp n_max) (u : Fin U) (i : Fin (numBuckets n_max)) :
↑((probePerm θ u) i) = (↑(primaryHash θ u) + ↑i * ↑(strideHash θ u)) % numBuckets n_max
@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.probePerm_zero {c_exp U n_max : ℕ} (θ : Seed c_exp n_max) (u : Fin U) :
(probePerm θ u) ⟨0, ⋯⟩ = primaryHash θ u

Section 2: Concrete Slot Extraction and Representation Invariant #

Well-formedness of the flat open-addressed slot arrays at [base + slotOffset c_exp n_max, base + slotOffset c_exp n_max + 3 * numBuckets n_max): each used[j] word is 0 or 1, and whenever used[j] = 1, key[j] < U.

Extract the abstract open-addressed table UniformProbing.Table U (numBuckets n_max) from Word-RAM memory mem.

theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.extractSlots_eq_none_iff {base c_exp U n_max : ℕ} {mem : ℕ → ℕ} (hwf : SlotArrayWF base c_exp U n_max mem) (j : Fin (numBuckets n_max)) :
extractSlots base c_exp U n_max mem j = none ↔ mem (base + slotOffset c_exp n_max + ↑j) = 0
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.extractSlots_eq_some_iff {base c_exp U n_max : ℕ} {mem : ℕ → ℕ} (hwf : SlotArrayWF base c_exp U n_max mem) (j : Fin (numBuckets n_max)) (u : Fin U) (v : ℕ) :
extractSlots base c_exp U n_max mem j = some (u, v) ↔ mem (base + slotOffset c_exp n_max + ↑j) = 1 ∧ mem (base + slotOffset c_exp n_max + numBuckets n_max + ↑j) = ↑u ∧ mem (base + slotOffset c_exp n_max + 2 * numBuckets n_max + ↑j) = v
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.mem_otherOccupiedSlots_extractSlots_iff {base c_exp U n_max : ℕ} {mem : ℕ → ℕ} (hwf : SlotArrayWF base c_exp U n_max mem) (u : Fin U) (j : Fin (numBuckets n_max)) :
j ∈ UniformProbing.otherOccupiedSlots (extractSlots base c_exp U n_max mem) u ↔ mem (base + slotOffset c_exp n_max + ↑j) = 1 ∧ mem (base + slotOffset c_exp n_max + numBuckets n_max + ↑j) ≠ ↑u
structure Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.Rep (w base c_exp U V n_max : ℕ) (θ : Seed c_exp n_max) (s : State U) (x : WordRAM.Data 16) :

Coupled representation invariant Rep w base c_exp U V n_max θ s x on Data 16:

  • x.Bounded w;
  • x.regs 0 = base;
  • DoubleTabulation.SeedRep holds for θ.1 at [base, base + singleTabSpace c_exp n_max) and for θ.2 at [base + singleTabSpace c_exp n_max, base + 2 * singleTabSpace c_exp n_max);
  • SlotArrayWF base c_exp U n_max x.mem and DoubleHashing.OrderedTableRep (probePerm θ) s (extractSlots base c_exp U n_max x.mem) hold on the slot arrays;
  • (Dictionary.dom s).card ≤ n_max and Dictionary.ValuesBounded V s.
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.Rep.unique {w base c_exp U V n_max : ℕ} {θ : Seed c_exp n_max} {s₁ s₂ : State U} {x : WordRAM.Data 16} (h₁ : Rep w base c_exp U V n_max θ s₁ x) (h₂ : Rep w base c_exp U V n_max θ s₂ x) :
s₁ = s₂
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.SlotArrayWF.congr_mem {base c_exp U n_max : ℕ} {mem mem' : ℕ → ℕ} (hmem : ∀ a ∈ { base := base, length := space c_exp n_max }.footprint, mem' a = mem a) (hwf : SlotArrayWF base c_exp U n_max mem) :
SlotArrayWF base c_exp U n_max mem'
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.extractSlots_congr_mem {base c_exp U n_max : ℕ} {mem mem' : ℕ → ℕ} (hmem : ∀ a ∈ { base := base, length := space c_exp n_max }.footprint, mem' a = mem a) :
extractSlots base c_exp U n_max mem' = extractSlots base c_exp U n_max mem
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.Rep.congr {w base c_exp U V n_max : ℕ} {θ : Seed c_exp n_max} {s : State U} {x x' : WordRAM.Data 16} (hbdd : WordRAM.Data.Bounded w x') (hbase : x'.regs 0 = x.regs 0) (hmem : ∀ a ∈ { base := base, length := space c_exp n_max }.footprint, x'.mem a = x.mem a) (hrep : Rep w base c_exp U V n_max θ s x) :
Rep w base c_exp U V n_max θ s x'

Section 3: Register Layout, Allocation, and Randomized Initialization #

@[reducible, inline]

Register 0 (baseReg, persistent): holds the base memory address base.

@[reducible, inline]

Register 1 (curReg): loop condition / Double Tabulation key input.

@[reducible, inline]

Register 2 (zeroReg): memory address / Double Tabulation output.

@[reducible, inline]

Register 3 (oneReg): current probe slot slot ∈ Fin (numBuckets n_max).

@[reducible, inline]

Register 4: slot array base address base + slotOffset c_exp n_max.

@[reducible, inline]

Register 5: bucket mask numBuckets n_max - 1.

@[reducible, inline]

Register 6: odd probe stride strideHash θ u.

@[reducible, inline]

Register 7: table size numBuckets n_max.

@[reducible, inline]

Register 8: constant 0 during probing / general scratch.

@[reducible, inline]

Register 12 (output): operation tag (0 for query, 1 for insert) on input; decoded return value (0 for none/(), v + 1 for some v) on output.

@[reducible, inline]

Register 13: input key u.val < U.

@[reducible, inline]

Register 14 (frontierReg): input value v < V for insert / allocation frontier.

@[reducible, inline]

Register 15: temporary register saving primaryHash θ u across the second hash evaluation.

Register injection Fin 12 → Fin 16 embedding DoubleTabulation into registers 0..11 (preserving regOp = 12, regU = 13, regV = 14, regSave = 15).

Allocation program allocSpan c_exp n_max (3 instructions): copies frontierReg (regV) to baseReg (regBase) and advances frontierReg by space c_exp n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.allocSpan_execWithin {w base c_exp n_max : ℕ} {x : WordRAM.Data 16} (hS : WordRAM.Fits w (base + space c_exp n_max)) (hfr : x.regs regV = base) :
∃ (x₁ : WordRAM.Data 16), WordRAM.ExecWithin w (allocSpan c_exp n_max) x x₁ 3 ∧ x₁.mem = x.mem ∧ x₁.regs regBase = base ∧ x₁.regs regV = base + space c_exp n_max

Deterministic 2-instruction glue advancing regBase by singleTabSpace c_exp n_max.

Deterministic 2-instruction glue restoring regBase from base + singleTabSpace c_exp n_max back to base.

Complete randomized setup program initSetup c_exp n_max: resamples the primary Double Tabulation seed at [base, base + singleTabSpace c_exp n_max) and the stride Double Tabulation seed at [base + singleTabSpace c_exp n_max, base + 2 * singleTabSpace c_exp n_max).

Total instruction count 2 * resampleSteps (numChars c_exp) (tupleLen c_exp) (charBits n_max) + 4 of initSetup c_exp n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.setup_exec_spec {w base c_exp U V n_max : ℕ} {x₁ : WordRAM.Data 16} (hS : WordRAM.Fits w (base + space c_exp n_max)) (hx₁ : WordRAM.Data.Bounded w x₁) (hbase : x₁.regs regBase = base) (hfr : x₁.regs regV = base + space c_exp n_max) (hz : ∀ a ∈ { base := base, length := space c_exp n_max }.footprint, x₁.mem a = 0) :
∃ (ν₀ : PMF (Seed c_exp n_max × WordRAM.Data 16)), WordRAM.ExecCodeDist w (initSetup c_exp n_max) x₁ (PMF.map Prod.snd ν₀) ↑(setupSteps c_exp n_max) ∧ (∀ (θ : Seed c_exp n_max), (PMF.map Prod.fst ν₀) θ ≤ 1 * (seedLaw c_exp n_max) θ) ∧ ∀ p ∈ ν₀.support, p.2.regs regV = base + space c_exp n_max ∧ Rep w base c_exp U V n_max p.1 (empty U) p.2 ∧ 0 ≤ 0 ∧ WordRAM.Modifies { base := base, length := space c_exp n_max }.footprint x₁.mem p.2.mem

Full Randomized.StateTransitionImpl.setup_exec certificate for initSetup c_exp n_max.

Section 4: Lookup and Insertion Operations (opCode) #

Probe inspection snippet probeCheckCode (≤ 9 instructions): checks whether the slot in regSlot belongs to otherOccupiedSlots (extractSlots base c_exp U n_max d.mem) u (i.e., used[slot] = 1 and key[slot] ≠ u.val), storing 1 in regCond if so and 0 otherwise.

One iteration of the probe loop (≤ 11 instructions): advances regSlot by regStride modulo numBuckets n_max (regMaskM) and runs probeCheckCode.

Probe loop: continues advancing regSlot while 0 < regCond (i.e., while regSlot is occupied by a key other than u).

Deterministic 3-instruction glue between the primary and stride DoubleTabulation.evalCode calls: saves (primaryHash θ u).val from regAddr into regSave and advances regBase by singleTabSpace c_exp n_max.

Deterministic 11-instruction glue after the stride DoubleTabulation.evalCode call: restores regBase = base, forms regStride = 2 * regAddr + 1, restores regSlot = regSave, and initializes regSlotBase, regMaskM, regM, and regZero.

Hash evaluation and probe-register setup opEvalHashesCode c_exp n_max: evaluates primaryHash θ u into regSlot, strideHash θ u into regStride, and initializes regSlotBase, regMaskM, regM, and regZero.

Exact deterministic instruction count 2 * DoubleTabulation.evalSteps (numChars c_exp) (tupleLen c_exp) + 15 = O_{c_exp}(1) of opEvalHashesCode c_exp n_max (independent of n_max and U).

Lookup completion program finishQueryCode (≤ 9 instructions): inspects used[regSlot]; if 0, writes 0 (none) into regOp, and if 1, loads val[regSlot] and writes val[regSlot] + 1 (some v) into regOp.

Insertion completion program finishInsertCode (8 instructions): writes used[regSlot] := 1, key[regSlot] := regU, val[regSlot] := regV, and sets regOp := 0.

Complete operation body opCode c_exp n_max for both query and insert.

noncomputable def Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.opPathSteps (c_exp U n_max : ℕ) (θ : Seed c_exp n_max) (T : UniformProbing.Table U (numBuckets n_max)) (u : Fin U) :

Exact pathwise instruction budget 13 * probeCount T u (probePerm θ u) + hashEvalSteps c_exp + 8 for opCode c_exp n_max on table T and key u.

Worst-case instruction bound 13 * numBuckets n_max + hashEvalSteps c_exp + 8 for opCode.

theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.opPathSteps_le_opSteps {c_exp U n_max : ℕ} (θ : Seed c_exp n_max) (T : UniformProbing.Table U (numBuckets n_max)) (u : Fin U) (hO : (UniformProbing.otherOccupiedSlots T u).card < numBuckets n_max) :
opPathSteps c_exp U n_max θ T u ≤ opSteps c_exp n_max

Key extracted from a Dictionary.Op U.

Operation tag (0 for query, 1 for insert).

Encoded output word in regOp after executing op from state s.

theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.opCode_execWithin {w base c_exp U V n_max : ℕ} {θ : Seed c_exp n_max} {s : State U} {x : WordRAM.Data 16} (hS : WordRAM.Fits w (base + space c_exp n_max)) (hV : WordRAM.Fits w V) (hrep : Rep w base c_exp U V n_max θ s x) (op : Op U) (hvalid : (spec U V n_max).valid s op) (hu_fit : WordRAM.Fits w ↑(opKey op)) (hop : x.regs regOp = opTag op) (hu : x.regs regU = ↑(opKey op)) (hv : ∀ (u : Fin U) (v : ℕ), op = Op.insert u v → x.regs regV = v) :
∃ (y : WordRAM.Data 16), WordRAM.ExecWithin w (opCode c_exp n_max) x y (opPathSteps c_exp U n_max θ (extractSlots base c_exp U n_max x.mem) (opKey op)) ∧ Rep w base c_exp U V n_max θ ((spec U V n_max).stepFn s op).1 y ∧ y.regs regOp = opOutWord s op ∧ WordRAM.Modifies { base := base, length := space c_exp n_max }.footprint x.mem y.mem

Pathwise correctness and complexity of opCode c_exp n_max: for any seed θ, dictionary state s, machine state x satisfying Rep w base c_exp U V n_max θ s x, and admissible operation op, opCode c_exp n_max halts deterministically in at most opPathSteps c_exp U n_max θ (extractSlots base c_exp U n_max x.mem) (opKey op) ≤ opSteps c_exp n_max instructions, preserving Rep for ((Dictionary.spec U V n_max).stepFn s op).1, writing opOutWord s op into regOp, and modifying memory only within [base, base + space c_exp n_max).

Section 5: SubroutineCode, StateTransitionImpl, and Expected Probe / Collision Bounds #

Relocatable SubroutineCode over Basis.exact (16 registers, 0 runtime init parameters) for the open-addressed permutation-probing dictionary.

Standalone argument encoder for Dictionary.Op U on 16 registers.

Partial argument-matching predicate for inline and standalone callers.

def Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.decodeOp {U V n_max : ℕ} (op : Op U) :
(Fin 16 → ℕ) → Option ((spec U V n_max).Result op)

Output decoder reading typed operation observations from final registers.

theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.encode_matches {c_exp U n_max : ℕ} (op : Op U) (regs : Fin 16 → ℕ) :
argMatch op fun (i : Fin 16) => if (subroutineCode c_exp n_max).input i = true then encodeOp op i else regs i
theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.arguments_fit {w base c_exp U V n_max : ℕ} (hS : WordRAM.Fits w (base + space c_exp n_max)) (hU_fit : ∀ (u : Fin U), WordRAM.Fits w ↑u) (hV : WordRAM.Fits w V) {s : State U} (op : Op U) (hv : (spec U V n_max).valid s op) (i : Fin 16) :

Expected per-operation instruction charge 13 * doubleTabThreshold c_exp + hashEvalSteps c_exp + 8 = O_{c_exp}(1) for both query and insert (independent of n_max and U). It bounds charge c_exp n_max at every capacity (charge_le_expectedOpCharge).

Expected probe-count bound at capacity n_max: 3 once doubleTabThreshold c_exp ≤ n_max (DoubleHashing.expect_probeCount_oddStride_doubleTab_le), and below the threshold the cap doubleTabThreshold c_exp on the deterministic probe count n_max + 1.

Expected per-operation instruction charge 13 * probeBound c_exp n_max + hashEvalSteps c_exp + 8 at capacity n_max, for both query and insert. It is at most expectedOpCharge c_exp for every n_max, and equals the threshold-free hashEvalSteps c_exp + 47 once doubleTabThreshold c_exp ≤ n_max (charge_of_le).

Above the Double Tabulation threshold the per-operation charge is 13 * 3 + hashEvalSteps c_exp + 8, independent of doubleTabThreshold c_exp.

theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.step_exec_spec {w base c_exp U V n_max : ℕ} (hS : WordRAM.Fits w (base + space c_exp n_max)) (hU_fit : ∀ (u : Fin U), WordRAM.Fits w ↑u) (hV : WordRAM.Fits w V) (hU : U ≤ max n_max 4 ^ c_exp) {s : State U} (o : Op U) (ν : PMF (Seed c_exp n_max × WordRAM.Data 16)) (hv : (spec U V n_max).valid s o) (hseed : ∀ (θ : Seed c_exp n_max), (PMF.map Prod.fst ν) θ ≤ 1 * (seedLaw c_exp n_max) θ) (hsupp : ∀ p ∈ ν.support, Rep w base c_exp U V n_max p.1 s p.2 ∧ argMatch o p.2.regs) :
∃ (μ_step : Seed c_exp n_max × WordRAM.Data 16 → PMF (Seed c_exp n_max × WordRAM.Data 16)) (T_step : Seed c_exp n_max × WordRAM.Data 16 → ENNReal), (∀ p ∈ ν.support, WordRAM.ExecCodeDist w (opCode c_exp n_max) p.2 (PMF.map Prod.snd (μ_step p)) (T_step p) ∧ ∀ q ∈ (μ_step p).support, decodeOp o q.2.regs = some ((spec U V n_max).stepFn s o).2 ∧ Rep w base c_exp U V n_max q.1 ((spec U V n_max).stepFn s o).1 q.2 ∧ WordRAM.Modifies { base := base, length := space c_exp n_max }.footprint p.2.mem q.2.mem) ∧ (∀ (θ' : Seed c_exp n_max), (PMF.map Prod.fst (ν.bind μ_step)) θ' ≤ 1 * (seedLaw c_exp n_max) θ') ∧ ∑' (p : Seed c_exp n_max × WordRAM.Data 16), ν p * (T_step p + ∑' (q : Seed c_exp n_max × WordRAM.Data 16), (μ_step p) q * ↑0) ≤ ↑(charge c_exp n_max) + ∑' (p : Seed c_exp n_max × WordRAM.Data 16), ν p * ↑0
@[reducible, inline]
noncomputable abbrev Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.impl {w base c_exp U V n_max : ℕ} (hS : WordRAM.Fits w (base + space c_exp n_max)) (hU_fit : ∀ (u : Fin U), WordRAM.Fits w ↑u) (hV : WordRAM.Fits w V) (hU : U ≤ max n_max 4 ^ c_exp) :

Composable randomized Word-RAM StateTransitionImpl certificate over Basis.exact for the open-addressed odd-stride double-hashing dictionary realizing Dictionary.spec U V n_max with $O_{c_{\exp}}(1)$ expected operation time (charge c_exp n_max ≤ expectedOpCharge c_exp, and hashEvalSteps c_exp + 47 once doubleTabThreshold c_exp ≤ n_max) and $O_{c_{\exp}}(n_{\max} + 1)$ space (space c_exp n_max) for every n_max : ℕ whenever U ≤ max n_max 4 ^ c_exp.

@[reducible, inline]
noncomputable abbrev Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.implStandard {w base c_exp U V n_max : ℕ} (hS : WordRAM.Fits w (base + space c_exp n_max)) (hU_fit : ∀ (u : Fin U), WordRAM.Fits w ↑u) (hV : WordRAM.Fits w V) (hU : U ≤ max n_max 4 ^ c_exp) :

Standard-basis (Basis.standard) randomized StateTransitionImpl certificate for the open-addressed odd-stride double-hashing dictionary.

theorem Cslib.DataStructure.Dictionary.WordRAM.UniformProbing.seq_expected_amortized {w base c_exp U V n_max : ℕ} (hS : WordRAM.Fits w (base + space c_exp n_max)) (hU_fit : ∀ (u : Fin U), WordRAM.Fits w ↑u) (hV : WordRAM.Fits w V) (hU : U ≤ max n_max 4 ^ c_exp) {x : WordRAM.Data 16} (ops : List (Op U)) (hx : WordRAM.Data.Bounded w x) (hfr : x.regs regV = base) (hz : ∀ a ∈ { base := base, length := space c_exp n_max }.footprint, x.mem a = 0) (hv : (spec U V n_max).ValidHistory (empty U) ops) :
∃ (ν₀ : PMF (Seed c_exp n_max × WordRAM.Data 16)) (ν_final : PMF (Seed c_exp n_max × WordRAM.Data 16)) (T_ops : ENNReal), WordRAM.ExecCodeDist w (subroutineCode c_exp n_max).initFresh x (PMF.map Prod.snd ν₀) (impl hS hU_fit hV hU).initTime ∧ (impl hS hU_fit hV hU).ExecStepsOfFn (empty U) ops ν₀ ν_final T_ops ∧ (∀ (θ : Seed c_exp n_max), (PMF.map Prod.fst ν_final) θ ≤ (seedLaw c_exp n_max) θ) ∧ (∀ p ∈ ν_final.support, Rep w base c_exp U V n_max p.1 ((spec U V n_max).run (empty U) ops).1 p.2) ∧ (impl hS hU_fit hV hU).initTime + T_ops ≤ 3 + ↑(setupSteps c_exp n_max) + ↑((spec U V n_max).totalCost (fun (x : (spec U V n_max).State) (x_1 : (spec U V n_max).Op) => charge c_exp n_max) (empty U) ops)

End-to-end multi-operation expected-time theorem (seq_expected_amortized): from fresh zeroed memory [base, base + space c_exp n_max), initializing the odd-stride double-hashing dictionary (initFresh) and executing the subroutine operation bodies (ExecStepsOfFn) across any admissible operation history ops : List (Dictionary.Op U) fixed independently of the sampled seed (oblivious adversary) takes at most 3 + setupSteps c_exp n_max + ops.length * charge c_exp n_max expected Word-RAM instructions whenever U ≤ max n_max 4 ^ c_exp. The per-operation charge is at most the $O_{c_{\exp}}(1)$ bound expectedOpCharge c_exp for every n_max : ℕ (charge_le_expectedOpCharge) and equals hashEvalSteps c_exp + 47 once doubleTabThreshold c_exp ≤ n_max (charge_of_le).

Ideal uniform-probing expected-step corollary (≤ hashEvalSteps c_exp + 34): when the probe permutation π is drawn uniformly from Equiv.Perm (Fin (numBuckets n_max)) on a table T with at most n_max other occupied slots ((otherOccupiedSlots T u).card ≤ n_max), the expected Word-RAM step count 13 * probeCount T u π + hashEvalSteps c_exp + 8 is at most hashEvalSteps c_exp + 34 (combining expect_probeLinear_le with B = 2 from UniformProbing.expect_unsuccessfulProbes_le_two).