Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.PreparationLocality

Prepared catalogue readback after workspace reuse #

Every catalogue, query, record and matrix word described by Instances.Output lies below its heap boundary. A consumer may change the workspace above that boundary while preserving all those words and the producer registers. The readback contract can then be framed against the current state. This does not assert that the producer ran again, or that its original external frame survived: the original producer execution and its initial state remain separate facts.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.Instances.Output.reframe {n D g p : ℕ} (values : ℕ → ℤ) {initial y z : WordRAM.Data 64} (h : Output n D g p values initial y) (hregs : z.regs = y.regs) (hmem : Set.EqOn z.mem y.mem (Set.Iio (y.regs heap))) :
Output n D g p values z z

Transport the actual prepared readback through changes above the heap. The new frame is relative to the current state, not to the original producer input. No execution is asserted.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.Instances.Output.transfer {n D g p : ℕ} (values : ℕ → ℤ) {initial y initial' z : WordRAM.Data 64} (h : Output n D g p values initial y) (hregs : z.regs = y.regs) (hmem : Set.EqOn z.mem y.mem (Set.Iio (y.regs heap))) (hframe : ∀ (q : ℕ), q < 5 + 3 * (n * n) ∨ z.regs heap ≤ q → z.mem q = initial'.mem q) :
Output n D g p values initial' z

Transport prepared readback to a protected-prefix-equivalent state with its own explicit external frame. The prefix premise covers only genuine prepared words; the external frame is relative to the chosen initial state, and no new execution is asserted.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.Instances.Output.output_le_heap {n D g p : ℕ} {values : ℕ → ℤ} {initial y : WordRAM.Data 64} (h : Output n D g p values initial y) :

The record region starts at or before the producer's final heap pointer.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.Instances.Output.inputEnd_le_heap {n D g p : ℕ} {values : ℕ → ℤ} {initial y : WordRAM.Data 64} (h : Output n D g p values initial y) :
5 + 3 * (n * n) ≤ y.regs heap

Original headers and signed matrices precede every prepared record and its workspace.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.Instances.Output.heap_le_budget {n D g p : ℕ} (values : ℕ → ℤ) {initial y : WordRAM.Data 64} (h : Output n D g p values initial y) (hD : 1 ≤ D) (hDn : D ≤ n) (hg : 1 ≤ g) :
y.regs heap ≤ budget n D g p

The computed heap fits the original preparation budget, independently of old registers or dirty memory outside the original arrays.