Resizable Word RAM machine model #
This module formalizes the word-granular Resizable Word RAM machine model (RData, RInstr,
RProgram, RCode, and RDemonicExec), grounding the resizable word-prefix memory model of
[LLYZ23a], [LLYZ24], and [KLZ26] directly on
Cslib.WordRAM instructions.
A machine configuration RData r holds r registers (regs : Fin r → ℕ), word-addressed memory
(mem : ℕ → ℕ), and the 0-indexed active word frontier (frontier : ℕ, [0, frontier)):
- Bounds-checked access (
evalResizable):Op.load d aandOp.store a srequirex.regs a < x.frontier, faulting (none) otherwise. - Single-word resizing primitives (
RInstr.grow,RInstr.shrink):grow dstextends[0, frontier)by1word to[0, frontier + 1)whenFits w (frontier + 1), stores oldfrontierindst, and initializes cellfrontierdemonically (DemonicGrow w frontier 1, matching [KLZ26], Section 5.1, PDF pp. 16–17 / printed pp. 15–16 and Footnote 10, PDF p. 18 / printed p. 17);shrinkcontracts[0, frontier)by1word when1 ≤ frontierand zeroes cellfrontier - 1. Multi-word resizing (growDirtyCode,growZeroCode,shrinkCode) is provided as derivedRCodesubroutines costingΘ(k + 1)instructions. - Direct
realizebridge (RDemonicExec.of_execBounded,RDemonicExec.of_realizesBounded): anyExecBounded w L c x.toData y TwithL ≤ x.frontierlifts directly toRDemonicExec.
Main definitions #
Cslib.WordRAM.Resizable.RData,Cslib.WordRAM.Resizable.RData.Bounded: resizable machine data and its word/frontier boundedness invariant.Cslib.WordRAM.Resizable.DemonicGrow,Cslib.WordRAM.Resizable.evalResizable: demonic growth relation and bounds-checked data instruction evaluation.Cslib.WordRAM.Resizable.RInstr,Cslib.WordRAM.Resizable.RProgram,Cslib.WordRAM.Resizable.RState,Cslib.WordRAM.Resizable.RCfg,Cslib.WordRAM.Resizable.RCode: flat and structured Resizable Word RAM programs and states.Cslib.WordRAM.Resizable.RDemonicExec: big-step demonic execution tracking stepsTand peak hardware word frontierL_peak.Cslib.WordRAM.Resizable.growDirtyCode,Cslib.WordRAM.Resizable.growZeroCode,Cslib.WordRAM.Resizable.shrinkCode: derived exact-basis (Basis.exact)RCodesubroutines forΘ(k + 1)-step demonic growth, zero-initialized growth, and multi-word shrinking.
Main results #
Cslib.WordRAM.Resizable.clear_demonicGrow_eq: clearing[frontier, frontier + k)afterDemonicGrowrecovers canonical zero-extended memory.Cslib.WordRAM.Resizable.RDemonicExec.of_execBounded,Cslib.WordRAM.Resizable.RDemonicExec.of_realizesBounded,Cslib.WordRAM.Resizable.RDemonicExec.mapSimulates: liftingExecBounded/RealizesBoundedprograms and transporting bases.Cslib.WordRAM.Resizable.growDirtyCode_exec,Cslib.WordRAM.Resizable.growZeroCode_exec,Cslib.WordRAM.Resizable.shrinkCode_exec:Θ(k + 1)-step execution certificates for the derived bulk resize subroutines.
References #
- [Hagerup1998] Torben Hagerup, Sorting and Searching on the Word RAM, STACS 1998.
- [RR03] Rajeev Raman and Satti Srinivasa Rao, Succinct Dynamic Dictionaries and Trees, ICALP 2003, LNCS 2719, pp. 357–368, Section 1.1.
- [LLYZ23a] Tianxiao Li, Jingxun Liang, Huacheng Yu, and Renfei Zhou, Dynamic
"Succincter", FOCS 2023, pp. 1715–1733 (
arXiv:2309.12950v1, Section 2.1, PDF pp. 6–7 / printed pp. 5–6). - [LLYZ24] Tianxiao Li, Jingxun Liang, Huacheng Yu, and Renfei Zhou, Dynamic
Dictionary with Subconstant Wasted Bits per Key, SODA 2024 (
arXiv:2310.20536v1, Section 3.2, PDF pp. 9–10 / printed pp. 8–9). - [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 pp. 16–20 / printed pp. 15–19; Theorem 5.2(6) and Footnote 10, PDF p. 18 / printed p. 17).
Resizable machine data and demonic word growth #
Underlying fixed-memory WordRAM.Data r (registers and memory).
Demonic word-granular growth of [0, L) by k words at word width w
([KuszmaulLiangZhou2026], Section 5.1): cells a < L retain their values, cells a ∈ [L, L + k)
receive arbitrary w-bit words (Fits w (mem' a)), and cells a ≥ L + k hold 0.
Zero-word growth is the identity transition on any memory zeroed above L.
Composing a k-word demonic growth from L with a 1-word demonic growth from L + k.
Zero-initializing [L, L + k) via clear mem L k satisfies DemonicGrow when zero above.
DemonicGrow w x.frontier k preserves RData.Bounded w when Fits w (x.frontier + k).
Clearing [frontier, frontier + k) after DemonicGrow recovers x.mem when x.Bounded w.
Any data instruction whose fixed-memory Op.eval succeeds with Op.BoundedAccess L x.toData
for L ≤ x.frontier evaluates identically under evalResizable and preserves x.frontier.
evalResizable preserves RData.Bounded w.
Basis simulation transports evalResizable.
Flat and structured Resizable Word RAM programs #
Flat instructions of a word-granular Resizable Word RAM over basis B and r registers.
- op {B : Basis} {r : ℕ} (o : Op B r) : RInstr B r
- jump {B : Basis} {r : ℕ} (t : ℕ) : RInstr B r
Jump unconditionally to instruction
t. - branch {B : Basis} {r : ℕ} (c : Cond r) (t : ℕ) : RInstr B r
Jump to
tifcholds, otherwise advancepcby1. - halt {B : Basis} {r : ℕ} (i : Fin r) : RInstr B r
Halt with the contents of register
ias output. - rand {B : Basis} {r : ℕ} (dst src : Fin r) : RInstr B r
Sample uniformly from
[0, regs src]intodst. - grow {B : Basis} {r : ℕ} (dst : Fin r) : RInstr B r
- shrink {B : Basis} {r : ℕ} : RInstr B r
Absorbing configuration for clocked execution of a flat Resizable Word RAM program.
Structured programs of a Resizable Word RAM: bounds-checked data instructions, sequencing,
conditionals, while loops, uniform random sampling (rand), single-word demonic grow, and
single-word shrink.
- op {B : Basis} {r : ℕ} (o : Op B r) : RCode B r
- seq {B : Basis} {r : ℕ} (c₁ c₂ : RCode B r) : RCode B r
- branch {B : Basis} {r : ℕ} (c : Cond r) (pos neg : RCode B r) : RCode B r
- loop {B : Basis} {r : ℕ} (c : Cond r) (body : RCode B r) : RCode B r
- rand {B : Basis} {r : ℕ} (dst src : Fin r) : RCode B r
- grow {B : Basis} {r : ℕ} (dst : Fin r) : RCode B r
- shrink {B : Basis} {r : ℕ} : RCode B r
Locating the parts of an assembled structured program #
An assembled branch starts with its test, which jumps over the negative arm.
The negative arm of an assembled branch follows its test.
The negative arm of an assembled branch ends with a jump over the positive arm.
The positive arm of an assembled branch follows the jump that ends the negative arm.
The test of an assembled loop is followed by its exit jump.
The body of an assembled loop follows its test and exit jump.
The body of an assembled loop is followed by a jump back to the test.
Big-step demonic execution (RDemonicExec) #
Big-step demonic execution judgment RDemonicExec w L_peak c x T P: at word width w,
starting from x : RData r, the structured program c : RCode B r executes without faulting in at
most T instructions, keeps the active hardware word frontier ≤ L_peak at every step, and
establishes postcondition P y on the resulting state y : RData r for every demonic choice
of newly grown memory words (DemonicGrow) on grow instructions.
- op {B : Basis} {r w L_peak : ℕ} {o : Op B r} {x y : RData r} {P : RData r → Prop} : x.frontier ≤ L_peak → evalResizable w o x = some y → P y → RDemonicExec w L_peak (RCode.op o) x 1 P
- grow {B : Basis} {r w L_peak : ℕ} {dst : Fin r} {x : RData r} {P : RData r → Prop} : x.frontier + 1 ≤ L_peak → Fits w (x.frontier + 1) → (∀ (mem' : ℕ → ℕ), DemonicGrow w x.frontier 1 x.mem mem' → P { regs := Function.update x.regs dst x.frontier, mem := mem', frontier := x.frontier + 1 }) → RDemonicExec w L_peak (RCode.grow dst) x 1 P
- shrink {B : Basis} {r w L_peak : ℕ} {x : RData r} {P : RData r → Prop} : x.frontier ≤ L_peak → 1 ≤ x.frontier → P { regs := x.regs, mem := clear x.mem (x.frontier - 1) 1, frontier := x.frontier - 1 } → RDemonicExec w L_peak RCode.shrink x 1 P
- rand {B : Basis} {r w L_peak : ℕ} {dst src : Fin r} {x : RData r} {P : RData r → Prop} : x.frontier ≤ L_peak → Fits w (x.regs src) → (∀ v ≤ x.regs src, P (x.set dst v)) → RDemonicExec w L_peak (RCode.rand dst src) x 1 P
- seq {B : Basis} {r w L_peak : ℕ} {c₁ c₂ : RCode B r} {x : RData r} {T₁ T₂ : ℕ} {Q P : RData r → Prop} : RDemonicExec w L_peak c₁ x T₁ Q → (∀ (y : RData r), Q y → RDemonicExec w L_peak c₂ y T₂ P) → RDemonicExec w L_peak (c₁.seq c₂) x (T₁ + T₂) P
- branch_pos {B : Basis} {r w L_peak : ℕ} {c : Cond r} {pos neg : RCode B r} {x : RData r} {T : ℕ} {P : RData r → Prop} : c.Holds x.toData → RDemonicExec w L_peak pos x T P → RDemonicExec w L_peak (RCode.branch c pos neg) x (T + 1) P
- branch_neg {B : Basis} {r w L_peak : ℕ} {c : Cond r} {pos neg : RCode B r} {x : RData r} {T : ℕ} {P : RData r → Prop} : ¬c.Holds x.toData → RDemonicExec w L_peak neg x T P → RDemonicExec w L_peak (RCode.branch c pos neg) x (T + 2) P
- loop_exit {B : Basis} {r w L_peak : ℕ} {c : Cond r} {body : RCode B r} {x : RData r} {P : RData r → Prop} : x.frontier ≤ L_peak → ¬c.Holds x.toData → P x → RDemonicExec w L_peak (RCode.loop c body) x 2 P
- loop_iter {B : Basis} {r w L_peak : ℕ} {c : Cond r} {body : RCode B r} {x : RData r} {T₁ T₂ : ℕ} {Q P : RData r → Prop} : c.Holds x.toData → RDemonicExec w L_peak body x T₁ Q → (∀ (y : RData r), Q y → RDemonicExec w L_peak (RCode.loop c body) y T₂ P) → RDemonicExec w L_peak (RCode.loop c body) x (T₁ + 2 + T₂) P
- mono {B : Basis} {r w L_peak : ℕ} {c : RCode B r} {x : RData r} {T₁ T₂ : ℕ} {P Q : RData r → Prop} : RDemonicExec w L_peak c x T₁ P → T₁ ≤ T₂ → (∀ (y : RData r), P y → Q y) → RDemonicExec w L_peak c x T₂ Q
Every RDemonicExec requires the entry hardware frontier to satisfy x.frontier ≤ L_peak.
Enlarge the peak hardware frontier bound L₁ ≤ L₂.
Deterministic sequential composition specialized to equality postcondition · = y.
Indexed relational loop rule for RDemonicExec.
Indexed deterministic loop rule for RDemonicExec.
Transport RDemonicExec along any defined-evaluation basis simulation φ : B.Simulates B'.
Lift any frontier-bounded structured execution ExecBoundedExact w L c x.toData y n with
L ≤ x.frontier ≤ L_peak directly to RDemonicExec on RCode.ofCode c.
Main ExecBounded → RDemonicExec bridge (RDemonicExec.of_execBounded).
Every ExecBounded w L c x.toData y T whose address bound L lies at or below x.frontier lifts
directly to RDemonicExec w L_peak (RCode.ofCode c) x T with unchanged hardware frontier.
Lift any register-only ExecWithin execution directly to RDemonicExec.
Direct RealizesBounded → RDemonicExec bridge (RDemonicExec.of_realizesBounded).
Any Memory.Prog client certified by RealizesBounded whose post-state frontier stays
≤ x.frontier (for example, any non-allocating segment using only Memory.read, Memory.write,
arithmetic glue, conditionals, iterate, and boundedWhile when x.regs frontier ≤ x.frontier)
executes directly on the Resizable Word RAM via RCode.ofCode.
Derived Θ(k + 1) bulk resize subroutines (growDirtyCode, growZeroCode, shrinkCode) #
Derived Θ(k + 1) demonic growth (growDirtyCode_exec).
Deterministic post-state of growZeroCode.
Derived exact-basis (Basis.exact) subroutine growing by regs count words via 1-word .grow
and immediately zeroing each newly grown word in 5 * count + 6 instructions.
Derived Θ(k + 1) zero-initialized growth (growZeroCode_exec).
Deterministic post-state of shrinkCode.
Derived Θ(k + 1) multi-word shrink (shrinkCode_exec).