Documentation

CslibFrontier.Algorithms.WordRAM.TrimmedYates.InputTrie

Sparse input-trie builder on the word RAM #

Accumulates a list of sparse (setMask S, Signed.encode v) pairs from flat word memory into a depth-d binary trie in O((d + 1) · |es|) instructions (buildInputTrie, exec_buildInputTrie).

Main definitions #

Main results #

Build a depth-d binary trie accumulating the sparse (S, v) pairs stored as 2 * |es| words [setMask S₀, Signed.encode v₀, …] starting at Reg.entryPtr, writing the allocated root to Reg.builtRoot and advancing Reg.free.

theorem Cslib.Algorithms.WordRAM.TrimmedYates.exec_buildInputTrie {w d entryPtr free W : ℕ} (es : List (Finset (Fin d) × ℤ)) (x : WordRAM.Data numRegs) (hd : x.regs Reg.dim = d) (hep : x.regs Reg.entryPtr = entryPtr) (hel : x.regs Reg.entryCount = es.length) (hfree : x.regs Reg.free = free) (hfree_pos : 1 ≤ free) (he_below : entryPtr + 2 * es.length ≤ free) (he_mem : ∀ (p : ℕ) (hp : p < es.length), x.mem (entryPtr + 2 * p) = setMask es[p].1 ∧ x.mem (entryPtr + 2 * p + 1) = WordRAM.Signed.encode es[p].2) (hes_W : entryAbsSum es ≤ W) (hfit_val : WordRAM.Fits w (valueEnvelope d W)) (hfit_free : WordRAM.Fits w (free + 2 + 2 * d * es.length)) :
∃ (y : WordRAM.Data numRegs) (free' : ℕ) (outFn : ℕ → ℕ), WordRAM.ExecWithin w buildInputTrie x y (es.length * (23 * d + 40) + 11) ∧ y.regs Reg.builtRoot = free ∧ y.regs Reg.free = free' ∧ free + 2 ≤ free' ∧ free' ≤ free + 2 + 2 * d * es.length ∧ HoldsTrie y.mem free' d free outFn ∧ (∀ (S : Finset (Fin d)), outFn (setMask S) = WordRAM.Signed.encode (evalEntries es S)) ∧ (∀ (a : ℕ), a < free ∨ free' ≤ a → y.mem a = x.mem a) ∧ ∀ (i : Fin numRegs), 11 ≤ ↑i ∧ ↑i ≤ 15 ∧ i ≠ Reg.free ∨ 44 ≤ ↑i ∧ ↑i ≤ 55 ∨ i = Reg.entryPtr ∨ i = Reg.entryCount → y.regs i = x.regs i

Build a depth-d HoldsTrie from es.length sparse (S, v) pairs in memory within es.length * (23 * d + 40) + 11 standard-basis instructions, preserving caller registers and all memory outside Ico free free'.