Frontier-bounded structured word-RAM executions #
Cslib.WordRAM.Exec and Cslib.WordRAM.ExecWithin evaluate memory loads and stores on an
unbounded cell array ℕ → ℕ without checking an allocation frontier. On the Resizable Word RAM,
by contrast, load and store succeed only at addresses strictly below the current hardware
word frontier frontier.
This module refines Exec and ExecWithin to ExecBoundedExact and ExecBounded, recording on
every load d a and store a s that the accessed word address x.regs a lies strictly below an
explicit address bound L. Pairing Realization.Realizes with the frontier-bounded realization
judgment Realization.RealizesBounded allows every non-allocating Memory.Prog client compiled by
realize to lift directly to the Resizable Word RAM (RDemonicExec.of_execBounded) without
duplicating the compiler or modifying CslibFrontier/Tactic/Realize.lean.
Main definitions #
Cslib.WordRAM.IsRegOnlyOp,Cslib.WordRAM.IsRegOnlyCode: predicates for data instructions and structured programs that perform no memory accesses (loadorstore) and norandsampling.Cslib.WordRAM.Op.BoundedAccess: side condition requiringx.regs a < Lonloadandstore.Cslib.WordRAM.ExecBoundedExact,Cslib.WordRAM.ExecBounded: exact-step and bounded-step structured executions whose memory accesses stay strictly belowL.
Main results #
Cslib.WordRAM.ExecBounded.toExecWithin: forget the address boundLback toExecWithin.Cslib.WordRAM.ExecBounded.mono_bound: enlarge the address boundL₁ ≤ L₂.Cslib.WordRAM.ExecBounded.of_execWithin_regOnly: lift any register-onlyExecWithinexecution toExecBoundedat an arbitrary boundL.Cslib.WordRAM.ExecBounded.mapSimulates: transport frontier-bounded executions along any defined-evaluation basis simulationBasis.Simulates.Cslib.WordRAM.SubroutineCode.zeroFillCode_execBounded: frontier-bounded execution ofSubroutineCode.zeroFillCode.
References #
- [Hag98] Torben Hagerup, Sorting and Searching on the Word RAM, STACS 1998 (standard word-RAM register and memory instruction semantics).
- [KLZ26] William Kuszmaul, Jingxun Liang, and Renfei Zhou, Succinct Dynamic
Rank/Select: Bypassing the Tree-Structure Bottleneck, SODA 2026 (
arXiv:2510.19175v1, Section 5.1, PDF p. 16 / printed p. 15: memory accesses restricted to the active word prefix).
Register-only instructions and bounded memory access #
Every Code.IsGlue fragment is register-only.
copyBank uses only register-copy instructions.
Exact and bounded executions with address bound L #
ExecBoundedExact w L c x y n: at word size w, the structured program c leads from data
x to data y in n instructions, and every load or store accesses an address < L.
- op {B : Basis} {r w L : ℕ} {o : Op B r} {x y : Data r} : Op.BoundedAccess L o x → Op.eval w o x = some y → ExecBoundedExact w L (Code.op o) x y 1
A data instruction whose memory access (if any) is
< Ltakes1instruction. - seq {B : Basis} {r w L : ℕ} {c₁ c₂ : Code B r} {x y z : Data r} {m n : ℕ} : ExecBoundedExact w L c₁ x y m → ExecBoundedExact w L c₂ y z n → ExecBoundedExact w L (c₁.seq c₂) x z (m + n)
Sequencing adds the instruction counts.
- branch_pos {B : Basis} {r w L : ℕ} {c : Cond r} {pos neg : Code B r} {x y : Data r} {n : ℕ} : c.Holds x → ExecBoundedExact w L pos x y n → ExecBoundedExact w L (Code.branch c pos neg) x y (n + 1)
Positive branch of a conditional adds
1instruction. - branch_neg {B : Basis} {r w L : ℕ} {c : Cond r} {pos neg : Code B r} {x y : Data r} {n : ℕ} : ¬c.Holds x → ExecBoundedExact w L neg x y n → ExecBoundedExact w L (Code.branch c pos neg) x y (n + 2)
Negative branch of a conditional adds
2instructions. - loop_exit {B : Basis} {r w L : ℕ} {c : Cond r} {body : Code B r} {x : Data r} : ¬c.Holds x → ExecBoundedExact w L (Code.loop c body) x x 2
Exiting a while loop takes
2instructions. - loop_iter {B : Basis} {r w L : ℕ} {c : Cond r} {body : Code B r} {x y z : Data r} {m n : ℕ} : c.Holds x →
ExecBoundedExact w L body x y m →
ExecBoundedExact w L (Code.loop c body) y z n → ExecBoundedExact w L (Code.loop c body) x z (m + n + 2)
One iteration of a while loop followed by the rest adds
m + n + 2instructions.
Instances For
Forget the address bound L to obtain an ordinary Exec.
Enlarge the address bound L₁ ≤ L₂.
Lift any register-only Exec to ExecBoundedExact at an arbitrary bound L.
Transport ExecBoundedExact along a defined-evaluation basis simulation.
Every exact execution within n instructions is a bounded execution within n.
Word-boundedness is preserved along ExecBoundedExact.
Unwritten registers keep their values along ExecBoundedExact.
A frontier-bounded structured execution is a run of any containing flat program.
A frontier-bounded structured execution followed by halt out is a halting run.
Forget the address bound L to obtain ExecWithin.
Enlarge the instruction budget T ≤ T₂.
Enlarge the address bound L₁ ≤ L₂.
Lift any register-only ExecWithin execution to ExecBounded at an arbitrary bound L.
Word-boundedness is preserved along ExecBounded.
Unwritten registers keep their values along ExecBounded.
Transport ExecBounded along a defined-evaluation basis simulation.
Single data instruction with bounded access.
Word-width read into register d.
Sequential composition of frontier-bounded executions.
Positive branch of a conditional.
Negative branch of a conditional.
Conditional with a shared bound on both alternatives.
One loop iteration followed by the rest adds T₁ + 2 instructions to the bound.
Loop through explicit states xs 0, …, xs k under address bound L.
Frontier-bounded counterpart of ExecWithin.loop_invariant_state_additive.
Frontier-bounded execution of P.zeroFillCode clearing [base, base + space) with all
stores strictly below base + space.