Documentation

CslibFrontier.DataStructure.VanEmdeBoas.WordRAM.Init.Table

Van Emde Boas initializer program and Phase 1–2 lookup-table construction #

This module defines the fixed 32-register structured initializer program initProgram for recursive van Emde Boas trees and certifies its first two phases:

  1. Computing (universeSize d, span d) by d iterations of the layout recurrences (sizeLoop).
  2. Populating the (splitSize k, childSpan k) lookup table of 2 * (d + 1) words at [base + span d, base + span d + 2 * (d + 1)) (tableLoop).

Main definitions #

Main results #

References #

Structured initializer program #

One step of the (universeSize, span) recurrence loop.

Setup for the Phase 2 (splitSize, childSpan) table construction.

Phase 2 loop writing (splitSize (k + 1), childSpan (k + 1)) for k < d.

Setup for the Phase 3 depth-first header initialization.

Downward step of the DFS initializer: write the current node's empty header and either turn around at a leaf or initialize the cluster counter and descend into the summary.

Upward/sibling step of the DFS initializer: ascend to the parent level and either finish when above depth, continue ascending when all clusters are done, or decrement the remaining cluster counter and descend into the next cluster.

Fixed 32-register structured program initializing an empty van Emde Boas tree of depth depth at root and placing stackBase at root + span depth.

The structured initializer program initProgram does not read the word width.

The compiled flat initializer program does not read the word width.

Phase 1: computing (universeSize d, span d) #

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.sizeLoop_spec {w d : ℕ} (rem : ℕ) {k : ℕ} {s : WordRAM.Data 32} (hk : k + rem = d) (hspan : WordRAM.Fits w (span d)) (hd : WordRAM.Fits w d) (h0 : s.regs zero = 0) (h1 : s.regs one = 1) (h2 : s.regs two = 2) (h3 : s.regs three = 3) (h4 : s.regs four = 4) (h5 : s.regs five = 5) (hdepth : s.regs depth = d) (hq : s.regs q = universeSize k) (ht : s.regs t = span k) (hhigh : s.regs high = k) :
∃ (z : WordRAM.Data 32), WordRAM.ExecWithin w sizeLoop s z (8 * rem + 2) ∧ z.regs zero = 0 ∧ z.regs one = 1 ∧ z.regs two = 2 ∧ z.regs three = 3 ∧ z.regs four = 4 ∧ z.regs five = 5 ∧ z.regs root = s.regs root ∧ z.regs depth = d ∧ z.regs q = universeSize d ∧ z.regs t = span d ∧ z.mem = s.mem

sizeLoop advances (q, t, high) from (universeSize k, span k, k) to (universeSize d, span d, d) in 8 * (d - k) + 2 instructions without modifying memory.

Phase 2: populating the (splitSize, childSpan) table #

Lookup-table invariant up to depth m: for all j ≤ m, mem (tbl + 2 * j) = splitSize j and mem (tbl + 2 * j + 1) = childSpan j.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.tableLoop_spec {w base d : ℕ} (rem : ℕ) {k : ℕ} {s : WordRAM.Data 32} (hk : k + rem = d) (ha : WordRAM.Fits w (base + span d + 4 * (d + 1))) (h0 : s.regs zero = 0) (h1 : s.regs one = 1) (h2 : s.regs two = 2) (h3 : s.regs three = 3) (h4 : s.regs four = 4) (h5 : s.regs five = 5) (hroot : s.regs root = base) (hdepth : s.regs depth = d) (hpay : s.regs payload = base + span d) (htbl : s.regs tableBase = base + span d) (hstk : s.regs stackBase = base + span d) (hsp : s.regs sp = base + span d + 2 * (k + 1)) (hq : s.regs q = universeSize k) (ht : s.regs t = span k) (hhigh : s.regs high = k) (hinv : TableInv (base + span d) k s.mem) :
∃ (z : WordRAM.Data 32), WordRAM.ExecWithin w tableLoop s z (12 * rem + 2) ∧ z.regs zero = 0 ∧ z.regs one = 1 ∧ z.regs two = 2 ∧ z.regs three = 3 ∧ z.regs four = 4 ∧ z.regs five = 5 ∧ z.regs root = base ∧ z.regs depth = d ∧ z.regs payload = base + span d ∧ z.regs tableBase = base + span d ∧ z.regs stackBase = base + span d ∧ z.regs sp = base + span d + 2 * (d + 1) ∧ TableInv (base + span d) d z.mem ∧ ∀ (a : ℕ), a < base + span d + 2 * (k + 1) ∨ base + span d + 2 * (d + 1) ≤ a → z.mem a = s.mem a

tableLoop populates the lookup table from depth k up to d in 12 * (d - k) + 2 instructions, advancing sp to base + span d + 2 * (d + 1) and preserving all memory outside [base + span d + 2 * (k + 1), base + span d + 2 * (d + 1)).