Randomized Resizable Word RAM State-Transition Implementations #
Reusable randomized subroutine implementation certificates (Randomized.StateTransitionImpl) over
the word-granular Resizable Word RAM (Cslib.WordRAM.Resizable.ExecRCodeDist and
ExecRProgramDist), 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.
Expected potential-amortized step charges ([CLRS09], Chapter 17) compose across sequences by
linearity of expectation ([MU17], Section 2.1). A certificate couples
[base, x.frontier) execution with Seed : Type, state-indexed seedLaw : D.State → PMF Seed up
to seedSlack : ℝ≥0∞, resting bound spaceBound, and peak bound peakSpaceBound; sequence
theorems require Fits w (base + peakSpaceBound s_t o_t) only along reachable states of ops and
compile to ExecRProgramDist (rejecting 1-instruction [.halt out] stubs).
Main definitions #
Randomized.CoupledRState,Randomized.StateTransitionImpl,Randomized.StateTransitionImpl.ofFn: coupled state bundle, randomized Resizable Word RAM certificate, andabbrevconstructor for[D.HasStepFn stepFn].Resizable.StateTransitionImpl.toRandomized: canonical embedding of deterministic certificates.Randomized.StateTransitionImpl.ExecSteps,Randomized.StateTransitionImpl.ExecStepsOfFn,Randomized.StateTransitionImpl.ExecProgramSteps,Randomized.StateTransitionImpl.ExecProgramStepsOfFn: structured and flat-program execution relations.
Main results #
Randomized.StateTransitionImpl.mapSimulates,Randomized.StateTransitionImpl.toStandard: basis transport fromBasis.exacttoBasis.standard.Randomized.StateTransitionImpl.steps_expected_amortized,Randomized.StateTransitionImpl.seq_expected_amortized,Randomized.StateTransitionImpl.steps_expected_amortized_ofFn,Randomized.StateTransitionImpl.seq_expected_amortized_ofFn: trajectory-relative expected-amortized sequence bounds preserving caller memory[0, base).Randomized.StateTransitionImpl.ExecSteps.toExecRProgramDist,Randomized.StateTransitionImpl.ExecStepsOfFn.toExecRProgramDist,Randomized.StateTransitionImpl.seq_toExecRProgramDist,Randomized.StateTransitionImpl.seq_toExecRProgramDist_ofFn: compilation to flatExecRProgramDistacross multi-operation sequences.Randomized.StateTransitionImpl.not_execProgramSteps_halt,Randomized.StateTransitionImpl.not_execProgramStepsOfFn_halt:.halt-rejection soundness checks on compiled flatRProgramsequences.
References #
- [CLRS09] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein, Introduction to Algorithms, 3rd ed., MIT Press, 2009, Chapter 17.
- [MU17] Michael Mitzenmacher and Eli Upfal, Probability and Computing, 2nd ed., Cambridge University Press, 2017, Section 2.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).
Coupled latent seed, abstract specification state, and concrete Resizable Word RAM state
RData r.
- seed : Seed
Latent random seed.
- state : State
Abstract specification state.
- data : WordRAM.Resizable.RData r
Concrete Resizable Word RAM register, memory, and frontier state.
Reusable randomized Resizable Word RAM implementation certificate with state-dependent resting
footprint [base, base + spaceBound s) and intermediate execution peak bound
[base, base + peakSpaceBound s o).
- Seed : Type
Latent random seed type (such as hash-function keys or random coins).
Reference distribution on
Seedindexed by abstract state.- seedSlack : ENNReal
Resting post-operation word-footprint upper bound
x.frontier ≤ base + spaceBound s.Peak intermediate word-footprint upper bound
y.frontier ≤ base + peakSpaceBound s o.- initTime : ENNReal
Expected instruction bound for
P.initCode. - initPotential : ℕ
Upper bound on initial concrete potential (
0when unamortized). Amortized instruction charge per operation.
Representation invariant coupling latent seed, abstract state, and concrete
RData r_ds.Concrete nonnegative potential function (
0when worst-case expected).Standalone register encoding for argument delivery.
Register-agreement predicate checked at subroutine entry.
Output decoder reading typed operation results from final registers.
- bounded {θ : self.Seed} {s : D.State} {x : WordRAM.Resizable.RData r_ds} : self.rep θ s x → WordRAM.Resizable.RData.Bounded w x
- rep_supported {θ : self.Seed} {s : D.State} {x x' : WordRAM.Resizable.RData r_ds} : (∀ (i : Fin r_ds), P.input i = false → x'.regs i = x.regs i) → x'.frontier = x.frontier → (∀ (a : ℕ), base ≤ a → a < x.frontier → x'.mem a = x.mem a) → WordRAM.Resizable.RData.Bounded w x' → self.rep θ s x → self.rep θ s x'
- 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₀) → ∃ (ν₀ : PMF (self.Seed × WordRAM.Resizable.RData r_ds)), WordRAM.Resizable.ExecRCodeDist w P.initCode x₀ (PMF.map Prod.snd ν₀) self.initTime (base + self.spaceBound s₀) ∧ (∀ (θ : self.Seed), (PMF.map Prod.fst ν₀) θ ≤ self.seedSlack * (self.seedLaw s₀) θ) ∧ ∀ p ∈ ν₀.support, self.rep p.1 s₀ p.2 ∧ self.potential p.1 p.2 ≤ self.initPotential ∧ ∀ addr < base, p.2.mem addr = x₀.mem addr
- singleState : Prop
- step_exec (o : D.Op) (ν : PMF (CoupledRState self.Seed D.State r_ds)) : (self.singleState → ∃ (s : D.State), ∀ t ∈ ν.support, t.state = s) → (∀ (s : D.State), (∀ t ∈ ν.support, t.state = s) → ∀ (θ : self.Seed), (PMF.map CoupledRState.seed ν) θ ≤ self.seedSlack * (self.seedLaw s) θ) → (∀ t ∈ ν.support, D.valid t.state o ∧ self.rep t.seed t.state t.data ∧ self.argMatch o t.data.regs ∧ WordRAM.Fits w (base + self.peakSpaceBound t.state o)) → ∃ (μ_step : CoupledRState self.Seed D.State r_ds → PMF (CoupledRState self.Seed D.State r_ds)) (T_step : CoupledRState self.Seed D.State r_ds → ENNReal), (∀ t ∈ ν.support, WordRAM.Resizable.ExecRCodeDist w P.code t.data (PMF.map CoupledRState.data (μ_step t)) (T_step t) (base + self.peakSpaceBound t.state o) ∧ ∀ q ∈ (μ_step t).support, ∃ (a : D.Result o), D.step t.state o q.state a ∧ self.decode o q.data.regs = some a ∧ self.rep q.seed q.state q.data ∧ ∀ addr < base, q.data.mem addr = t.data.mem addr) ∧ (∀ (s' : D.State), (∀ q ∈ (ν.bind μ_step).support, q.state = s') → ∀ (θ' : self.Seed), (PMF.map CoupledRState.seed (ν.bind μ_step)) θ' ≤ self.seedSlack * (self.seedLaw s') θ') ∧ (self.singleState → ∃ (s' : D.State), ∀ q ∈ (ν.bind μ_step).support, q.state = s') ∧ ∑' (t : CoupledRState self.Seed D.State r_ds), ν t * (T_step t + ∑' (q : CoupledRState self.Seed D.State r_ds), (μ_step t) q * ↑(self.potential q.seed q.data)) ≤ ∑' (t : CoupledRState self.Seed D.State r_ds), ν t * (↑(self.charge t.state o) + ↑(self.potential t.seed t.data))
Deterministic-to-randomized embedding (toRandomized) #
Canonical embedding of any deterministic Resizable.StateTransitionImpl certificate into
Resizable.Randomized.StateTransitionImpl (Seed := Unit, seedLaw := fun _ => PMF.pure (),
seedSlack := 1).
ofFn, basis transport, and caller framing on Randomized.StateTransitionImpl #
Construct a Randomized.StateTransitionImpl for a functional specification
([D.HasStepFn stepFn]). Defined as abbrev (singleState := True) so D.Result reduces
transparently without unfolding StateTransitionSpec.ofFn.
Lift a Randomized.StateTransitionImpl certificate along any defined-evaluation basis
simulation φ : B.Simulates B'.
Lift an exact-basis Randomized.StateTransitionImpl certificate to Basis.standard.
Prepare registers for operation o on x.
Trajectory-relative expected-amortized sequence theorems #
Structured multi-operation distributional execution C.ExecSteps over ExecRCodeDist.
- 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₀} (ν : PMF (CoupledRState C.Seed D.State r_ds)) : C.ExecSteps [] ν ν 0 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₀} {o : D.Op} {ops : List D.Op} {ν ν_final : PMF (CoupledRState C.Seed D.State r_ds)} {μ_step : CoupledRState C.Seed D.State r_ds → PMF (CoupledRState C.Seed D.State r_ds)} {T_step : CoupledRState C.Seed D.State r_ds → ENNReal} {T_rest C_rest : ENNReal} : (∀ t ∈ ν.support, WordRAM.Resizable.ExecRCodeDist w P.code (C.prepare o t.data) (PMF.map CoupledRState.data (μ_step t)) (T_step t) (base + C.peakSpaceBound t.state o) ∧ ∀ q ∈ (μ_step t).support, ∃ (a : D.Result o), D.step t.state o q.state a ∧ C.decode o q.data.regs = some a ∧ C.rep q.seed q.state q.data ∧ ∀ addr < base, q.data.mem addr = t.data.mem addr) → C.ExecSteps ops (ν.bind μ_step) ν_final T_rest C_rest → C.ExecSteps (o :: ops) ν ν_final (∑' (t : CoupledRState C.Seed D.State r_ds), ν t * T_step t + T_rest) (∑' (t : CoupledRState C.Seed D.State r_ds), ν t * ↑(C.charge t.state o) + C_rest)
ExecSteps preserves caller memory [0, base) across all support states.
Trajectory-relative multi-operation expected-amortized telescope
(steps_expected_amortized).
Requires PeakFitsOpSeq w base C.peakSpaceBound t.state ops only along states reached by ops
from ν.support.
End-to-end expected-amortized sequence theorem (seq_expected_amortized).
Functional-specification sequence theorems (ExecStepsOfFn, *_ofFn) #
Structured multi-operation distributional execution relation for functional specifications
([D.HasStepFn stepFn]).
- 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₀} {stepFn : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn stepFn] (s : D.State) (ν : PMF (C.Seed × WordRAM.Resizable.RData r_ds)) : C.ExecStepsOfFn s [] ν ν 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₀} {stepFn : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn stepFn] {s : D.State} {o : D.Op} {ops : List D.Op} {ν ν_final : PMF (C.Seed × WordRAM.Resizable.RData r_ds)} {μ_step : C.Seed × WordRAM.Resizable.RData r_ds → PMF (C.Seed × WordRAM.Resizable.RData r_ds)} {T_step : C.Seed × WordRAM.Resizable.RData r_ds → ENNReal} {T_rest : ENNReal} : (∀ p ∈ ν.support, WordRAM.Resizable.ExecRCodeDist w P.code (C.prepare o p.2) (PMF.map Prod.snd (μ_step p)) (T_step p) (base + C.peakSpaceBound s o) ∧ ∀ q ∈ (μ_step p).support, C.decode o q.2.regs = some (D.stepFn s o).2 ∧ C.rep q.1 (D.stepFn s o).1 q.2 ∧ ∀ addr < base, q.2.mem addr = p.2.mem addr) → C.ExecStepsOfFn (D.stepFn s o).1 ops (ν.bind μ_step) ν_final T_rest → C.ExecStepsOfFn s (o :: ops) ν ν_final (∑' (p : C.Seed × WordRAM.Resizable.RData r_ds), ν p * T_step p + T_rest)
Project a relational ExecSteps derivation onto ExecStepsOfFn when ν_rel is concentrated
on a single abstract state s ([D.HasStepFn stepFn]).
Trajectory-relative expected-amortized telescope for functional specifications
(steps_expected_amortized_ofFn).
ExecStepsOfFn preserves caller memory [0, base) across all support states.
End-to-end expected-amortized sequence theorem for functional specifications
(seq_expected_amortized_ofFn).
Compilation to flat ExecRProgramDist and .halt rejection #
Relational multi-operation flat-RProgram execution relation over ExecRProgramDist.
- 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} (ν : PMF (CoupledRState C.Seed D.State r_ds)) : C.ExecProgramSteps p_op out [] ν ν 0 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} {o : D.Op} {ops : List D.Op} {ν ν_final : PMF (CoupledRState C.Seed D.State r_ds)} {μ_step : CoupledRState C.Seed D.State r_ds → PMF (CoupledRState C.Seed D.State r_ds)} {T_step : CoupledRState C.Seed D.State r_ds → ENNReal} {T_rest C_rest : ENNReal} : (∀ t ∈ ν.support, WordRAM.Resizable.ExecRProgramDist w p_op out (C.prepare o t.data) (PMF.map CoupledRState.data (μ_step t)) (T_step t) (base + C.peakSpaceBound t.state o) ∧ ∀ q ∈ (μ_step t).support, ∃ (a : D.Result o), D.step t.state o q.state a ∧ C.decode o q.data.regs = some a ∧ C.rep q.seed q.state q.data ∧ ∀ addr < base, q.data.mem addr = t.data.mem addr) → C.ExecProgramSteps p_op out ops (ν.bind μ_step) ν_final T_rest C_rest → C.ExecProgramSteps p_op out (o :: ops) ν ν_final (∑' (t : CoupledRState C.Seed D.State r_ds), ν t * T_step t + T_rest) (∑' (t : CoupledRState C.Seed D.State r_ds), ν t * ↑(C.charge t.state o) + C_rest)
Functional multi-operation flat-RProgram execution relation over ExecRProgramDist.
- 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₀} {stepFn : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn stepFn] {p_op : WordRAM.Resizable.RProgram B r_ds} {out : Fin r_ds} (s : D.State) (ν : PMF (C.Seed × WordRAM.Resizable.RData r_ds)) : C.ExecProgramStepsOfFn p_op out s [] ν ν 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₀} {stepFn : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn stepFn] {p_op : WordRAM.Resizable.RProgram B r_ds} {out : Fin r_ds} {s : D.State} {o : D.Op} {ops : List D.Op} {ν ν_final : PMF (C.Seed × WordRAM.Resizable.RData r_ds)} {μ_step : C.Seed × WordRAM.Resizable.RData r_ds → PMF (C.Seed × WordRAM.Resizable.RData r_ds)} {T_step : C.Seed × WordRAM.Resizable.RData r_ds → ENNReal} {T_rest : ENNReal} : (∀ p ∈ ν.support, WordRAM.Resizable.ExecRProgramDist w p_op out (C.prepare o p.2) (PMF.map Prod.snd (μ_step p)) (T_step p) (base + C.peakSpaceBound s o) ∧ ∀ q ∈ (μ_step p).support, C.decode o q.2.regs = some (D.stepFn s o).2 ∧ C.rep q.1 (D.stepFn s o).1 q.2 ∧ ∀ addr < base, q.2.mem addr = p.2.mem addr) → C.ExecProgramStepsOfFn p_op out (D.stepFn s o).1 ops (ν.bind μ_step) ν_final T_rest → C.ExecProgramStepsOfFn p_op out s (o :: ops) ν ν_final (∑' (p : C.Seed × WordRAM.Resizable.RData r_ds), ν p * T_step p + T_rest)
Compile a structured C.ExecSteps derivation to C.ExecProgramSteps (P.opProg out) out,
charging + 1 instruction per operation for the trailing halt out.
Compile a structured C.ExecStepsOfFn derivation to
C.ExecProgramStepsOfFn (P.opProg out) out.
End-to-end flat-RProgram expected-amortized theorem (seq_toExecRProgramDist).
End-to-end flat-RProgram expected-amortized theorem for functional specifications
(seq_toExecRProgramDist_ofFn).
.halt-rejection soundness check (not_execProgramSteps_halt): [.halt out] cannot
satisfy C.ExecProgramSteps [.halt out] out on (o :: ops) whenever some t ∈ ν.support has no
valid post-outcome (θ', s', a) represented by C.prepare o t.data.
.halt-rejection soundness check (not_execProgramStepsOfFn_halt) for HasStepFn.