Documentation

CslibFrontier.Algorithms.WordRAM.ThreeSum.ChanHe.TraversalInvariant

Concrete worklist invariant for the native Chan–He traversal #

The invariant connects the reserved native stack, existing finite recursion, retained arrays, output-pointer table and fresh heap. Remaining work pays for both future output cells and future allocations. In particular, allocation bounds decrease with the mathematical work measure rather than granting an unbounded heap to each kernel call.

Main definitions #

These proof invariants are original and do not add a machine model or operational oracle.

Fixed parameters and concrete memory reservations of a complete native root traversal.

  • n : ℕ

    Maximum column cardinality.

  • m : ℕ

    Candidate-prime bound.

  • Λ : ℕ

    Label-bit parameter.

  • U : ℕ

    Node input magnitude.

  • N : ℕ

    Common number of four-cell packed groups.

  • fuel : ℕ

    Root recursion fuel.

  • primes : ℕ

    Prime bitmap base.

  • stack : ℕ

    Reserved native word-stack base.

  • capacity : ℕ

    Reserved native word-stack capacity.

  • table : ℕ

    Unsigned output-pointer table base.

  • outputCapacity : ℕ

    Reserved output-pointer table capacity.

  • floor : ℕ

    First address permitted for allocated heavy and packed arrays.

  • ceiling : ℕ

    Final upper bound on the fresh heap pointer.

  • retained : ℕ → ℕ

    Protected original memory below the stack, including the complete frontend forest.

Persistent caller registers, including actual zero and one used by native branches.

theorem Cslib.Algorithms.WordRAM.ThreeSum.ChanHe.Traversal.Arena.Controls.congr {a : Arena} {x y : WordRAM.Data 128} (h : a.Controls x) (hp : ∀ (i : Fin 128), ↑i ∈ [71, 72, 73, 74, 75, 76, 78, 80, 81, 82, 83] → y.regs i = x.regs i) :

Exact register preservation transfers all persistent caller parameters. The heap and accumulated count are deliberately absent from this fixed register set.

theorem Cslib.Algorithms.WordRAM.ThreeSum.ChanHe.Traversal.Arena.Controls.of_regs_71_96 {a : Arena} {x y : WordRAM.Data 128} (h : a.Controls x) (hr : ∀ (i : Fin 128), 71 ≤ ↑i → ↑i < 96 → y.regs i = x.regs i) :

Preserving registers 71–95 preserves all persistent caller parameters.

Concrete non-overlap and capacity obligations for the reserved native layout.

The reserved stack fits inside the gap between a.stack and a.floor.

A single signed envelope covers both actual native kernels at every worklist transition.

The actual native bitmap is retained below the reserved stack.

Proof state of the actual stack loop; no part of this structure is evaluated by the program.

Remaining transitions include empty entries and zero-fuel leaves.

Full readback and allocation invariant at the actual native loop header.

A live loop has at least one pending entry, since each entry occupies seven actual words.

A finished actual loop has emitted the complete target, with every array already read back.