Documentation

Complexity.Algorithms.WordRAM.VanEmdeBoas.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 #

Constant and recurrence-seed setup for Phase 1.

Instances For

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

    Instances For

      Phase 1 loop computing (universeSize d, span d).

      Instances For

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

        Instances For

          One step of the Phase 2 table-population loop.

          Instances For

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

            Instances For

              Setup for the Phase 3 depth-first header initialization.

              Instances For

                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.

                Instances For

                  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.

                  Instances For

                    Full body of the Phase 3 DFS loop.

                    Instances For

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

                      Instances For

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

                        State after one iteration of sizeBody at depth k.

                        Instances For
                          theorem Cslib.Algorithms.WordRAM.VanEmdeBoas.sizeBody_exec {w d k : ℕ} {s : WordRAM.Data 32} (hk : k < d) (hspan : WordRAM.Fits w (Lean.VanEmdeBoas.span d)) (hd : WordRAM.Fits w d) (h1 : s.regs one = 1) (h5 : s.regs five = 5) (hq : s.regs q = Lean.VanEmdeBoas.universeSize k) (ht : s.regs t = Lean.VanEmdeBoas.span k) (hhigh : s.regs high = k) :
                          theorem Cslib.Algorithms.WordRAM.VanEmdeBoas.sizeLoop_spec {w d : ℕ} (rem : ℕ) {k : ℕ} {s : WordRAM.Data 32} (hk : k + rem = d) (hspan : WordRAM.Fits w (Lean.VanEmdeBoas.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 = Lean.VanEmdeBoas.universeSize k) (ht : s.regs t = Lean.VanEmdeBoas.span k) (hhigh : s.regs high = k) :

                          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 #

                          theorem Cslib.Algorithms.WordRAM.VanEmdeBoas.tableSetup_exec {w base d : ℕ} {s : WordRAM.Data 32} (ha : WordRAM.Fits w (base + Lean.VanEmdeBoas.span d + 4 * (d + 1))) (h0 : s.regs zero = 0) (h1 : s.regs one = 1) (h2 : s.regs two = 2) (h5 : s.regs five = 5) (hroot : s.regs root = base) (ht : s.regs t = Lean.VanEmdeBoas.span d) :

                          State after one iteration of tableBody at depth k and pointer sp₀.

                          Instances For
                            theorem Cslib.Algorithms.WordRAM.VanEmdeBoas.tableBody_exec {w base d k : ℕ} {s : WordRAM.Data 32} (hk : k < d) (ha : WordRAM.Fits w (base + Lean.VanEmdeBoas.span d + 4 * (d + 1))) (h1 : s.regs one = 1) (h5 : s.regs five = 5) (hsp : s.regs sp = base + Lean.VanEmdeBoas.span d + 2 * (k + 1)) (hq : s.regs q = Lean.VanEmdeBoas.universeSize k) (ht : s.regs t = Lean.VanEmdeBoas.span k) (hhigh : s.regs high = k) :

                            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.

                            Instances For
                              theorem Cslib.Algorithms.WordRAM.VanEmdeBoas.tableLoop_spec {w base d : ℕ} (rem : ℕ) {k : ℕ} {s : WordRAM.Data 32} (hk : k + rem = d) (ha : WordRAM.Fits w (base + Lean.VanEmdeBoas.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 + Lean.VanEmdeBoas.span d) (htbl : s.regs tableBase = base + Lean.VanEmdeBoas.span d) (hstk : s.regs stackBase = base + Lean.VanEmdeBoas.span d) (hsp : s.regs sp = base + Lean.VanEmdeBoas.span d + 2 * (k + 1)) (hq : s.regs q = Lean.VanEmdeBoas.universeSize k) (ht : s.regs t = Lean.VanEmdeBoas.span k) (hhigh : s.regs high = k) (hinv : TableInv (base + Lean.VanEmdeBoas.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 + Lean.VanEmdeBoas.span d ∧ z.regs tableBase = base + Lean.VanEmdeBoas.span d ∧ z.regs stackBase = base + Lean.VanEmdeBoas.span d ∧ z.regs sp = base + Lean.VanEmdeBoas.span d + 2 * (d + 1) ∧ TableInv (base + Lean.VanEmdeBoas.span d) d z.mem ∧ ∀ (a : ℕ), a < base + Lean.VanEmdeBoas.span d + 2 * (k + 1) ∨ base + Lean.VanEmdeBoas.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)).