Deterministic Resizable Word RAM State-Transition Implementations #
Reusable deterministic (demonic-growth-resilient) subroutine packaging (SubroutineCode) and
potential-amortized ([CLRS09], Chapter 17) state-transition implementation certificates
(StateTransitionImpl) over the word-granular Resizable Word RAM (Cslib.WordRAM.Resizable),
accompanying the word-granular resizable memory models of [LLYZ23a],
Section 2.1, and [KLZ26], Section 5.1, and adapting the bit-granular virtual-memory
variant of [LLYZ24], Section 3.2, at word granularity.
Unlike fixed-capacity Cslib.DataStructure.WordRAM.StateTransitionImpl (whose workspace
[base, base + space) has a single state-independent length space), a Resizable Word RAM
implementation owns the active suffix [base, x.frontier) above a caller prefix [0, base) and
tracks two state/operation-indexed word bounds:
- Resting space bound (
spaceBound : D.State → ℕ): after initialization and after every completed operation reaching abstract states, the hardware frontier satisfiesbase ≤ x.frontier ∧ x.frontier ≤ base + spaceBound sandx.regs P.baseReg = base. - Intermediate peak bound (
peakSpaceBound : D.State → D.Op → ℕ): while executingo : D.Opfroms : D.State, every intermediate machine configuration keeps its hardware frontier≤ base + peakSpaceBound s o(RDemonicExec w (base + peakSpaceBound s o) P.code ...), while preserving caller memory[0, base)(∀ addr < base, y.mem addr = x.mem addr). - Trajectory-relative address-space fit (
PeakFitsOpSeq,PeakFitsHistory): multi-operation execution theorems (steps_amortized,seq_amortized,steps_amortized_ofFn,seq_amortized_ofFn) requireFits w (base + peakSpaceBound s_t o_t)only along states actually reached by validops, never globally across alls : D.State.
Main definitions #
Cslib.DataStructure.WordRAM.Resizable.SubroutineCode: relocatable Resizable Word RAM subroutine code bundle (baseReg, injectiveinitParams,input,initCode,code).Cslib.DataStructure.WordRAM.Resizable.PeakFitsOpSeq,Cslib.DataStructure.WordRAM.Resizable.PeakFitsHistory,Cslib.DataStructure.WordRAM.Resizable.maxPeakSpaceHistory: trajectory-relative peak-frontier admissibility along valid relational and functional operation sequences.Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl: deterministic Resizable Word RAM implementation and amortized-cost certificate forD : StateTransitionSpec.Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.ofFn:abbrevconstructor for functional specifications ([D.HasStepFn f]).Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.ExecSteps,Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.ExecProgramSteps: structured (RDemonicExec) and compiled flat-program (ExecRProgramDist) multi-operation execution relations.
Main results #
Cslib.DataStructure.WordRAM.Resizable.SubroutineCode.mapSimulates,Cslib.DataStructure.WordRAM.Resizable.SubroutineCode.not_readsWidth_mapSimulates: basis simulation transport and¬ReadsWidthpreservation onSubroutineCode.Cslib.DataStructure.WordRAM.Resizable.peakFitsOpSeq_iff_peakFitsHistory,Cslib.DataStructure.WordRAM.Resizable.peakFitsHistory_of_fits_maxPeakSpaceHistory: equivalence of relational and functional trajectory fit predicates and reduction tomaxPeakSpaceHistory.Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.mapSimulates,Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.toStandard: basis transport fromBasis.exacttoBasis.standard.Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.steps_amortized,Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.seq_amortized,Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.steps_amortized_ofFn,Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.seq_amortized_ofFn: trajectory-relative multi-operation amortized execution bounds preserving caller memory[0, base).Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.initProg_exec,Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.ExecSteps.toExecProgramSteps,Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.seq_program_amortized,Cslib.DataStructure.WordRAM.Resizable.StateTransitionImpl.seq_program_amortized_ofFn: compilation to flatRProgram(P.initCode.program out,P.code.program out) underExecRProgramDist.
References #
- [CLRS09] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein, Introduction to Algorithms, 3rd ed., MIT Press, 2009, Chapter 17.
- [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).
Relocatable Resizable Word RAM SubroutineCode #
Uniform machine code for a relocatable subroutine over the word-granular Resizable Word RAM
(RCode B r_ds). Owns the active suffix [base, x.frontier) recorded in baseReg, leaving the
caller prefix [0, base) untouched.
- baseReg : Fin r_ds
Persistent register holding the base address
baseof this structure's resizable suffix. Injective register map carrying runtime initialization parameters (
params) intoinitCode.Mask marking caller-overwritable argument/scratch registers (
falseon persistent registers).baseRegis persistent across standalone argument preparation.- initCode : WordRAM.Resizable.RCode B r_ds
- code : WordRAM.Resizable.RCode B r_ds
Unified operation dispatcher executing
D.Opwith.grow/.shrinkresizing.
Whether either initCode or code inspects the ambient word width w.
Compiled flat initialization RProgram halting with register out.
Compiled flat operation RProgram halting with register out.
Standalone register-preparation map overwriting P.input registers with encode o.
Deliver encoded operation arguments into P.input registers while preserving persistent
registers, memory, and x.frontier.
prepare preserves RData.Bounded w whenever the encoded input registers fit in w bits.
Transport a SubroutineCode bundle along a defined-evaluation basis simulation.
Transport an exact-basis SubroutineCode to Basis.standard.
Trajectory-relative peak-frontier admissibility #
Trajectory-relative peak-frontier fit along a relational operation sequence ops from s:
requires Fits w (base + peakSpaceBound s_t o_t) only at states s_t reachable along ops under
D.step, never globally across all s : D.State.
Trajectory-relative peak-frontier fit along a functional operation history ops from s
([D.HasStepFn f]).
On any functional specification [D.HasStepFn f], PeakFitsOpSeq and PeakFitsHistory
coincide.
Maximum peakSpaceBound s_t o_t encountered along the deterministic trajectory of ops from
s ([D.HasStepFn f]).
Bounding base + maxPeakSpaceHistory peakSpaceBound s ops by 2 ^ w establishes
PeakFitsHistory along ops.
Deterministic Resizable Word RAM StateTransitionImpl #
Reusable deterministic (demonic-growth-resilient) Resizable Word RAM implementation certificate
for P : SubroutineCode B r_ds k_init realizing D : StateTransitionSpec at word width w, base
address base, runtime initialization parameters params, and initial state s₀, with
potential-amortized operation charges ([CLRS09], Chapter 17), state-dependent resting footprint
[base, base + spaceBound s), and intermediate peak bound [base, base + peakSpaceBound s o).
Resting post-operation word-footprint upper bound
x.frontier ≤ base + spaceBound s.Peak intermediate word-footprint upper bound
y.frontier ≤ base + peakSpaceBound s oacross every machine configuration visited while executingofroms.- initTime : ℕ
Worst-case instruction bound for
P.initCode. - initPotential : ℕ
Upper bound on initial concrete potential after initialization (
0when unamortized). Amortized instruction charge per operation (excluding trailing standalone
halt).Representation invariant linking abstract state
D.Stateand concreteRData r_ds.- potential : WordRAM.Resizable.RData r_ds → ℕ
Concrete nonnegative integer potential (
0when worst-case / unamortized). Standalone register encoding for argument delivery.
Partial argument-matching predicate for inline callers (refined by
encode).Output decoder reading typed operation observations from final registers.
- bounded {s : D.State} {x : WordRAM.Resizable.RData r_ds} : self.rep s x → WordRAM.Resizable.RData.Bounded w x
Represented configurations satisfy
RData.Bounded w. - frontier_le {s : D.State} {x : WordRAM.Resizable.RData r_ds} : self.rep s x → base ≤ x.frontier ∧ x.frontier ≤ base + self.spaceBound s ∧ x.regs P.baseReg = base
Resting frontier bounds and persistent
baseReg = baseinvariant on represented states. - arguments_fit {s : D.State} (o : D.Op) : D.valid s o → ∀ (i : Fin r_ds), P.input i = true → WordRAM.Fits w (self.encode o i)
Standalone encoded arguments fit in
w-bit words on admissible calls. - encode_matches (o : D.Op) (regs : Fin r_ds → ℕ) : self.argMatch o fun (i : Fin r_ds) => if P.input i = true then self.encode o i else regs i
Full standalone argument delivery satisfies
argMatch. - init_exec {x₀ : WordRAM.Resizable.RData r_ds} : WordRAM.Resizable.RData.Bounded w x₀ → x₀.frontier = base → (∀ (j : Fin k_init), x₀.regs (P.initParams j) = params j) → WordRAM.Fits w (base + self.spaceBound s₀) → ∃ (y : WordRAM.Resizable.RData r_ds), (WordRAM.Resizable.RDemonicExec w (base + self.spaceBound s₀) P.initCode x₀ self.initTime fun (x : WordRAM.Resizable.RData r_ds) => x = y) ∧ self.rep s₀ y ∧ self.potential y ≤ self.initPotential ∧ ∀ addr < base, y.mem addr = x₀.mem addr
Demonic-safe initialization of
P.initCodefromx₀.frontier = basewhenFits w (base + spaceBound s₀), preserving caller memory[0, base). - step_exec {s : D.State} {x : WordRAM.Resizable.RData r_ds} (o : D.Op) : self.rep s x → D.valid s o → self.argMatch o x.regs → WordRAM.Fits w (base + self.peakSpaceBound s o) → ∃ (y : WordRAM.Resizable.RData r_ds) (s' : D.State) (a : D.Result o) (n : ℕ), (WordRAM.Resizable.RDemonicExec w (base + self.peakSpaceBound s o) P.code x n fun (x : WordRAM.Resizable.RData r_ds) => x = y) ∧ D.step s o s' a ∧ self.decode o y.regs = some a ∧ self.rep s' y ∧ (∀ addr < base, y.mem addr = x.mem addr) ∧ n + self.potential y ≤ self.charge s o + self.potential x
Demonic-safe execution of
P.codeon admissibleowhenFits w (base + peakSpaceBound s o), preserving caller memory[0, base)and satisfyingn + potential y ≤ charge s o + potential x.
Construct a StateTransitionImpl for a deterministic specification ([D.HasStepFn f]) from a
functional step_exec proof at D.stepFn s o. Defined as abbrev so D.Result reduces
transparently without unfolding StateTransitionSpec.ofFn.
Lift a StateTransitionImpl certificate along any defined-evaluation basis simulation.
Lift an exact-basis StateTransitionImpl certificate to Basis.standard.
Prepare registers for operation o on x.
Caller-frame preservation: any caller step that preserves persistent registers, frontier,
[base, x.frontier), and RData.Bounded w preserves C.rep and C.potential.
Trajectory-relative multi-operation execution and flat RProgram compilation #
Structured multi-operation execution relation C.ExecSteps s x ops tr s_fin z t_ops over
RDemonicExec: at every step o, P.code executes within peak frontier
base + C.peakSpaceBound s o, witnesses a valid transition D.step s o s₁ a with decoded output
C.decode o y.regs = some a, preserves C.rep (hence resting frontier
base ≤ y.frontier ≤ base + C.spaceBound s₁ and y.regs P.baseReg = base), and preserves caller
memory [0, base).
- nil {B : WordRAM.Basis} {r_ds k_init w base : ℕ} {P : SubroutineCode B r_ds k_init} {D : StateTransitionSpec} {params : Fin k_init → ℕ} {s₀ : D.State} {C : StateTransitionImpl P D w base params s₀} (s : D.State) (x : WordRAM.Resizable.RData r_ds) : C.ExecSteps s x [] [] s x 0
- cons {B : WordRAM.Basis} {r_ds k_init w base : ℕ} {P : SubroutineCode B r_ds k_init} {D : StateTransitionSpec} {params : Fin k_init → ℕ} {s₀ : D.State} {C : StateTransitionImpl P D w base params s₀} {s s₁ s_fin : D.State} {x y z : WordRAM.Resizable.RData r_ds} {o : D.Op} {ops : List D.Op} {a : D.Result o} {tr : D.Transcript} {n rest : ℕ} : (WordRAM.Resizable.RDemonicExec w (base + C.peakSpaceBound s o) P.code (C.prepare o x) n fun (x : WordRAM.Resizable.RData r_ds) => x = y) → D.step s o s₁ a → C.decode o y.regs = some a → C.rep s₁ y → (∀ addr < base, y.mem addr = x.mem addr) → C.ExecSteps s₁ y ops tr s_fin z rest → C.ExecSteps s x (o :: ops) ({ op := o, result := a, nextState := s₁ } :: tr) s_fin z (n + rest)
ExecSteps preserves caller memory [0, base) across the entire operation sequence.
Trajectory-relative multi-operation amortized theorem (steps_amortized).
Requires PeakFitsOpSeq w base C.peakSpaceBound s ops only along states reached by ops from
s, never globally over all D.State.
End-to-end deterministic amortized sequence theorem (seq_amortized).
Functional-specification specialization of steps_amortized ([D.HasStepFn f]).
End-to-end deterministic amortized sequence theorem for functional specifications
(seq_amortized_ofFn).
Compile P.initCode to the flat RProgram specification ExecRProgramDist (P.initProg out).
Sequential flat-RProgram execution relation C.ExecProgramSteps p_op out over
ExecRProgramDist: ties every post-state y to the operational halting distribution of p_op at
.halted (y.regs out) y, enforcing PeakFrontierLe (base + C.peakSpaceBound s o), output
decoding, C.rep, and caller-prefix [0, base) preservation at every step.
- nil {B : WordRAM.Basis} {r_ds k_init w base : ℕ} {P : SubroutineCode B r_ds k_init} {D : StateTransitionSpec} {params : Fin k_init → ℕ} {s₀ : D.State} {C : StateTransitionImpl P D w base params s₀} {p_op : WordRAM.Resizable.RProgram B r_ds} {out : Fin r_ds} (s : D.State) (x : WordRAM.Resizable.RData r_ds) : C.ExecProgramSteps p_op out s x [] [] s x 0
- cons {B : WordRAM.Basis} {r_ds k_init w base : ℕ} {P : SubroutineCode B r_ds k_init} {D : StateTransitionSpec} {params : Fin k_init → ℕ} {s₀ : D.State} {C : StateTransitionImpl P D w base params s₀} {p_op : WordRAM.Resizable.RProgram B r_ds} {out : Fin r_ds} {s s₁ s_fin : D.State} {x y z : WordRAM.Resizable.RData r_ds} {o : D.Op} {ops : List D.Op} {a : D.Result o} {tr : D.Transcript} {n_op rest : ℕ} : WordRAM.Resizable.ExecRProgramDist w p_op out (C.prepare o x) (PMF.pure y) (↑n_op) (base + C.peakSpaceBound s o) → D.step s o s₁ a → C.decode o y.regs = some a → C.rep s₁ y → (∀ addr < base, y.mem addr = x.mem addr) → C.ExecProgramSteps p_op out s₁ y ops tr s_fin z rest → C.ExecProgramSteps p_op out s x (o :: ops) ({ op := o, result := a, nextState := s₁ } :: tr) s_fin z (n_op + rest)
Compile any structured C.ExecSteps derivation to C.ExecProgramSteps (P.opProg out) out,
charging + 1 instruction per operation for the trailing halt out.
End-to-end flat-RProgram amortized sequence theorem (seq_program_amortized).
End-to-end flat-RProgram amortized sequence theorem for functional specifications
(seq_program_amortized_ofFn).
.halt-rejection soundness lemma (not_execProgramSteps_halt): a 1-instruction
[.halt out] stub cannot satisfy C.ExecProgramSteps [.halt out] out on (o :: ops) whenever
every valid post-state (s₁, a) from (s, o) is incompatible with the unmodified prepared state
C.prepare o x.