Documentation

Complexity.Algorithms.WordRAM.VanEmdeBoas.Successor

Native van Emde Boas strict-successor certification #

This module certifies the native strict-successor operation (successorDescent followed by successorUnwind) in Complexity.Algorithms.WordRAM.VanEmdeBoas.Program.

During descent, each recursive cluster or summary call pushes a four-word continuation frame (kind, payload, q, t) into the scratch stack [stackBase₀, stackBase₀ + 4 * d). Because Tree.successor checks the cached maximum before recursing, every recursive descent is guaranteed to find a key (found = 1), and successorUnwind pops the pushed frames to reconstruct the universe key in out while restoring sp = stackBase₀.

Main definitions #

Main results #

References #

structure Cslib.Algorithms.WordRAM.VanEmdeBoas.SuccessorEntry (stackBase₀ sp₀ base query : ℕ) (s : WordRAM.Data 32) :

The constant, stack, and traversal registers at entry to successorDescent.

Instances For

    Effect of pushing a four-word continuation frame (k, pay, qv, tv) at sp₀.

    Instances For

      Mathematical description of one successorDescentBody iteration.

      Instances For
        theorem Cslib.Algorithms.WordRAM.VanEmdeBoas.successorDescentBody_exec {d w stackBase₀ sp₀ base query : ℕ} {tree : Lean.VanEmdeBoas.Tree d} {s : WordRAM.Data 32} (hs : SuccessorEntry stackBase₀ sp₀ base query s) (ht : tree.Valid) (hr : Rep tree base s.mem) (ha : WordRAM.Fits w (base + Lean.VanEmdeBoas.span d)) (hsp : WordRAM.Fits w (sp₀ + 4 * d)) :

        One native successor-descent iteration executes in at most 42 instructions.

        structure Cslib.Algorithms.WordRAM.VanEmdeBoas.UnwindState (stackBase₀ sp₀ ans : ℕ) (mem : ℕ → ℕ) (s : WordRAM.Data 32) :

        Register and memory invariant at the start of an unwind stage at stack pointer sp₀.

        Instances For

          Mathematical description of one successorUnwindBody iteration popping at sp₀.

          Instances For
            theorem Cslib.Algorithms.WordRAM.VanEmdeBoas.successorUnwindBody_cluster_exec {w stackBase₀ sp₀ pay qv tv childAns : ℕ} {mem : ℕ → ℕ} {s : WordRAM.Data 32} (hs : UnwindState stackBase₀ (sp₀ + 4) childAns mem s) (hk : mem sp₀ = 0) (hpay : mem (sp₀ + 1) = pay) (hqv : mem (sp₀ + 2) = qv) (htv : mem (sp₀ + 3) = tv) (hsp : WordRAM.Fits w (sp₀ + 4)) (hout : WordRAM.Fits w (pay + childAns)) :

            One cluster-return unwind step (kind = 0) executes in at most 19 instructions.

            theorem Cslib.Algorithms.WordRAM.VanEmdeBoas.successorUnwindBody_summary_exec {d w stackBase₀ sp₀ base j cm : ℕ} {mem : ℕ → ℕ} {s : WordRAM.Data 32} (hs : UnwindState stackBase₀ (sp₀ + 4) j mem s) (hk : mem sp₀ = 1) (hpay : mem (sp₀ + 1) = base) (hqv : mem (sp₀ + 2) = Lean.VanEmdeBoas.universeSize d) (htv : mem (sp₀ + 3) = Lean.VanEmdeBoas.span d) (hj : j < Lean.VanEmdeBoas.universeSize d) (hcm : mem (base + 5 + (j + 1) * Lean.VanEmdeBoas.span d + 1) = cm) (hcm_lt : cm < Lean.VanEmdeBoas.universeSize d) (ha : WordRAM.Fits w (base + Lean.VanEmdeBoas.span (d + 1))) (hsp : WordRAM.Fits w (sp₀ + 4)) :

            One summary-return unwind step (kind = 1) executes in at most 19 instructions.

            theorem Cslib.Algorithms.WordRAM.VanEmdeBoas.successor_loop_spec {d w stackBase₀ base query : ℕ} {tree : Lean.VanEmdeBoas.Tree d} {s : WordRAM.Data 32} (hs : SuccessorEntry stackBase₀ stackBase₀ base query s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hdisj : base + Lean.VanEmdeBoas.span d ≤ stackBase₀) (hfit : WordRAM.Fits w (stackBase₀ + 4 * d)) :
            ∃ (z : WordRAM.Data 32), WordRAM.ExecWithin w (successorDescent.seq successorUnwind) s z (65 * (d + 1) + 4) ∧ (if z.regs found = 0 then none else some (z.regs out)) = tree.successor query ∧ z.regs sp = stackBase₀ ∧ Rep tree base z.mem ∧ ∀ (a : ℕ), a < stackBase₀ ∨ stackBase₀ + 4 * d ≤ a → z.mem a = s.mem a

            Complete certification of successorDescent; successorUnwind from sp = stackBase₀: executes in at most 65 * (d + 1) + 4 instructions, computes tree.successor query, restores sp = stackBase₀, preserves Rep tree base z.mem, and frames memory outside [stackBase₀, stackBase₀ + 4 * d).