Documentation

CslibFrontier.Computability.WordRAM.Resizable.Clocked

Clocked randomized execution and adaptive-adversary expected time on the Resizable Word RAM #

Clocked probabilistic operational semantics, adaptive-adversary fault-freedom, every-step peak hardware-frontier bounds (PeakFrontierLe), ℝ≥0∞-valued expected running time (expectedTimeDemonic), and flat-program halting-distribution specifications (ExecRProgramDist) for the word-granular Resizable Word RAM (Cslib.WordRAM.Resizable).

When a flat program p : RProgram B r executes single-word .grow dst, a time- and state-adaptive adversary adv : RAdv r (ℕ → RState r → ℕ → ℕ), observing the step index t and the full current machine state s : RState r, chooses an arbitrary w-bit initial word at address s.data.frontier (advGrowMem w (advStep s) s.data.frontier 1 s.data.mem). Every flat-program specification quantifies universally (or takes the supremum in ℝ≥0∞) over all adv : RAdv r.

Main definitions #

Main results #

References #

Adaptive adversary and clocked randomized execution #

@[reducible, inline]

Time- and state-adaptive adversary choosing initial word contents on .grow instructions as a function of step index t : ℕ, active machine state s : RState r, and word address a : ℕ.

def Cslib.WordRAM.Resizable.RAdv.shift {r : ℕ} (d : ℕ) (adv : RAdv r) :

Shift an adaptive adversary forward by d execution steps.

@[simp]
theorem Cslib.WordRAM.Resizable.RAdv.shift_zero {r : ℕ} (adv : RAdv r) :
shift 0 adv = adv
theorem Cslib.WordRAM.Resizable.RAdv.shift_shift {r : ℕ} (d₁ d₂ : ℕ) (adv : RAdv r) :
shift d₂ (shift d₁ adv) = shift (d₁ + d₂) adv
def Cslib.WordRAM.Resizable.RAdv.prepend {r : ℕ} (f : RState r → ℕ → ℕ) (adv : RAdv r) :

Prepend a single-step initializer f before adv so (adv.prepend f).shift 1 = adv.

@[simp]
theorem Cslib.WordRAM.Resizable.RAdv.prepend_zero {r : ℕ} (f : RState r → ℕ → ℕ) (adv : RAdv r) :
prepend f adv 0 = f
@[simp]
theorem Cslib.WordRAM.Resizable.RAdv.shift_one_prepend {r : ℕ} (f : RState r → ℕ → ℕ) (adv : RAdv r) :
shift 1 (prepend f adv) = adv
def Cslib.WordRAM.Resizable.advGrowMem (w : ℕ) (init : ℕ → ℕ) (L k : ℕ) (mem : ℕ → ℕ) :
ℕ → ℕ

Adversarial memory initializer for .grow: preserves mem a for a < L, writes init a % 2 ^ w in [L, L + k), and zeroes a ≥ L + k.

theorem Cslib.WordRAM.Resizable.demonicGrow_advGrowMem (w : ℕ) (init : ℕ → ℕ) (L k : ℕ) (mem : ℕ → ℕ) :
DemonicGrow w L k mem (advGrowMem w init L k mem)

Every advGrowMem instance satisfies DemonicGrow.

def Cslib.WordRAM.Resizable.stepRandResizable {B : Basis} {r : ℕ} (w : ℕ) (advStep : RState r → ℕ → ℕ) (p : RProgram B r) :
RCfg r → ProbComp (RCfg r)

Single step of randomized execution of p : RProgram B r at word width w under single-step growth initializer advStep : RState r → ℕ → ℕ. Halted and faulted configurations are absorbing.

theorem Cslib.WordRAM.Resizable.stepRandResizable_halted {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} (v : ℕ) (d : RData r) :
theorem Cslib.WordRAM.Resizable.stepRandResizable_op {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} {o : Op B r} {y : RData r} (hp : p[s.pc]? = some (RInstr.op o)) (he : evalResizable w o s.data = some y) :
stepRandResizable w advStep p (RCfg.running s) = pure (RCfg.running { pc := s.pc + 1, data := y })
theorem Cslib.WordRAM.Resizable.stepRandResizable_jump {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} {t : ℕ} (hp : p[s.pc]? = some (RInstr.jump t)) :
stepRandResizable w advStep p (RCfg.running s) = pure (RCfg.running { pc := t, data := s.data })
theorem Cslib.WordRAM.Resizable.stepRandResizable_branch {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} {c : Cond r} {t : ℕ} (hp : p[s.pc]? = some (RInstr.branch c t)) :
stepRandResizable w advStep p (RCfg.running s) = pure (RCfg.running { pc := if c.Holds s.data.toData then t else s.pc + 1, data := s.data })
theorem Cslib.WordRAM.Resizable.stepRandResizable_branch_pos {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} {c : Cond r} {t : ℕ} (hp : p[s.pc]? = some (RInstr.branch c t)) (hc : c.Holds s.data.toData) :
stepRandResizable w advStep p (RCfg.running s) = pure (RCfg.running { pc := t, data := s.data })
theorem Cslib.WordRAM.Resizable.stepRandResizable_branch_neg {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} {c : Cond r} {t : ℕ} (hp : p[s.pc]? = some (RInstr.branch c t)) (hc : ¬c.Holds s.data.toData) :
stepRandResizable w advStep p (RCfg.running s) = pure (RCfg.running { pc := s.pc + 1, data := s.data })
theorem Cslib.WordRAM.Resizable.stepRandResizable_halt {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} {i : Fin r} (hp : p[s.pc]? = some (RInstr.halt i)) :
theorem Cslib.WordRAM.Resizable.stepRandResizable_rand_of_fits {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} {dst src : Fin r} (hp : p[s.pc]? = some (RInstr.rand dst src)) (hf : Fits w (s.data.regs src)) :
stepRandResizable w advStep p (RCfg.running s) = do let k ← ProbComp.unifFin (s.data.regs src) pure (RCfg.running { pc := s.pc + 1, data := s.data.set dst ↑k })
theorem Cslib.WordRAM.Resizable.stepRandResizable_grow_of_fits {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} {dst : Fin r} (hp : p[s.pc]? = some (RInstr.grow dst)) (hf : Fits w (s.data.frontier + 1)) :
stepRandResizable w advStep p (RCfg.running s) = pure (RCfg.running { pc := s.pc + 1, data := { regs := Function.update s.data.regs dst s.data.frontier, mem := advGrowMem w (advStep s) s.data.frontier 1 s.data.mem, frontier := s.data.frontier + 1 } })
theorem Cslib.WordRAM.Resizable.stepRandResizable_grow_of_not_fits {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} {dst : Fin r} (hp : p[s.pc]? = some (RInstr.grow dst)) (hf : ¬Fits w (s.data.frontier + 1)) :
theorem Cslib.WordRAM.Resizable.stepRandResizable_shrink_of_pos {B : Basis} {r w : ℕ} {advStep : RState r → ℕ → ℕ} {p : RProgram B r} {s : RState r} (hp : p[s.pc]? = some RInstr.shrink) (hk : 1 ≤ s.data.frontier) :
stepRandResizable w advStep p (RCfg.running s) = pure (RCfg.running { pc := s.pc + 1, data := { regs := s.data.regs, mem := clear s.data.mem (s.data.frontier - 1) 1, frontier := s.data.frontier - 1 } })
def Cslib.WordRAM.Resizable.runRandResizable {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) :
ℕ → RCfg r → ProbComp (RCfg r)

Clocked t-step randomized execution of p : RProgram B r under adaptive adversary adv.

@[simp]
theorem Cslib.WordRAM.Resizable.runRandResizable_zero {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (cfg : RCfg r) :
runRandResizable w adv p 0 cfg = pure cfg
theorem Cslib.WordRAM.Resizable.runRandResizable_succ {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (t : ℕ) (cfg : RCfg r) :
runRandResizable w adv p (t + 1) cfg = do let cfg' ← stepRandResizable w (adv 0) p cfg runRandResizable w (RAdv.shift 1 adv) p t cfg'
@[simp]
theorem Cslib.WordRAM.Resizable.runRandResizable_halted {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (t v : ℕ) (d : RData r) :
theorem Cslib.WordRAM.Resizable.runRandResizable_add {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (t₁ t₂ : ℕ) (cfg : RCfg r) :
runRandResizable w adv p (t₁ + t₂) cfg = do let cfg' ← runRandResizable w adv p t₁ cfg runRandResizable w (RAdv.shift t₁ adv) p t₂ cfg'
noncomputable def Cslib.WordRAM.Resizable.evalRandDemonic {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (t : ℕ) (s : RState r) :
PMF (RCfg r)

Configuration distribution after t steps from .running s under adaptive adversary adv.

Set of active (.running) configurations.

Set of cleanly halted (.halted) configurations.

@[simp]
theorem Cslib.WordRAM.Resizable.RCfg.mem_runningSet_iff {r : ℕ} {cfg : RCfg r} :
cfg ∈ runningSet r ↔ ∃ (u : RState r), cfg = running u
@[simp]
theorem Cslib.WordRAM.Resizable.RCfg.mem_haltedSet_iff {r : ℕ} {cfg : RCfg r} :
cfg ∈ haltedSet r ↔ ∃ (v : ℕ) (d : RData r), cfg = halted v d
theorem Cslib.WordRAM.Resizable.evalRandDemonic_halted_mono {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (s : RState r) (v : ℕ) (d : RData r) :
Monotone fun (t : ℕ) => (evalRandDemonic w adv p t s) (RCfg.halted v d)

Pointwise halting probability at .halted v d is monotone in the horizon t.

theorem Cslib.WordRAM.Resizable.iSup_evalRandDemonic_halted_le_of_step {B : Basis} {r w : ℕ} {adv : RAdv r} {p : RProgram B r} {s s' : RState r} (hstep : stepRandResizable w (adv 0) p (RCfg.running s) = pure (RCfg.running s')) (v : ℕ) (d : RData r) :
⨆ (T_hor : ℕ), (evalRandDemonic w (RAdv.shift 1 adv) p T_hor s') (RCfg.halted v d) ≤ ⨆ (T_hor : ℕ), (evalRandDemonic w adv p T_hor s) (RCfg.halted v d)

Any deterministic transition stepRandResizable w (adv 0) p (.running s) = pure (.running s') transports supremum halting probabilities from (adv.shift 1, s') to (adv, s).

Fault-freedom, PeakFrontierLe, expected time, and ExecRProgramDist #

Configuration hardware-frontier upper bound (≤ L_peak).

Joint non-faulting and frontier-bounded configuration invariant.

theorem Cslib.WordRAM.Resizable.RCfg.SafeBounded.ne_faulted {r L_peak : ℕ} {cfg : RCfg r} (h : SafeBounded L_peak cfg) :
theorem Cslib.WordRAM.Resizable.RCfg.SafeBounded.frontierLe {r L_peak : ℕ} {cfg : RCfg r} (h : SafeBounded L_peak cfg) :
FrontierLe L_peak cfg
theorem Cslib.WordRAM.Resizable.RCfg.SafeBounded.mono {r L₁ L₂ : ℕ} {cfg : RCfg r} (hL : L₁ ≤ L₂) (h : SafeBounded L₁ cfg) :
SafeBounded L₂ cfg
def Cslib.WordRAM.Resizable.RDemonicFaultFree {B : Basis} {r : ℕ} (w : ℕ) (p : RProgram B r) (s : RState r) :

Zero-fault invariant across all adaptive adversaries adv : RAdv r and all horizons t : ℕ.

def Cslib.WordRAM.Resizable.PeakFrontierLe {B : Basis} {r : ℕ} (w L_peak : ℕ) (p : RProgram B r) (s : RState r) :

Every-step peak hardware-frontier bound: across every adaptive adversary adv : RAdv r, every horizon t : ℕ, and every reachable configuration cfg (.running or .halted), the active hardware word frontier never exceeds L_peak.

theorem Cslib.WordRAM.Resizable.PeakFrontierLe.mono {B : Basis} {r w L₁ L₂ : ℕ} {p : RProgram B r} {s : RState r} (hL : L₁ ≤ L₂) (h : PeakFrontierLe w L₁ p s) :
PeakFrontierLe w L₂ p s

Almost-sure halting across all adaptive adversaries adv : RAdv r.

noncomputable def Cslib.WordRAM.Resizable.expectedStepsWithinAdv {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (N : ℕ) (cfg : RCfg r) :

Finite-horizon expected active steps under a fixed adaptive adversary adv.

noncomputable def Cslib.WordRAM.Resizable.supExpectedStepsWithin {B : Basis} {r : ℕ} (w : ℕ) (p : RProgram B r) (N : ℕ) (cfg : RCfg r) :

Supremum finite-horizon expected active steps across all adaptive adversaries adv.

noncomputable def Cslib.WordRAM.Resizable.expectedStepsFromAdv {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (cfg : RCfg r) :

Expected remaining active steps from cfg under a fixed adaptive adversary adv.

noncomputable def Cslib.WordRAM.Resizable.expectedStepsFromDemonic {B : Basis} {r : ℕ} (w : ℕ) (p : RProgram B r) (cfg : RCfg r) :

Supremum expected remaining active steps from cfg across all adaptive adversaries adv.

noncomputable def Cslib.WordRAM.Resizable.expectedTimeDemonic {B : Basis} {r : ℕ} (w : ℕ) (p : RProgram B r) (s : RState r) :

Worst-case adaptive-adversary expected running time of p from s at word width w.

@[simp]
theorem Cslib.WordRAM.Resizable.expectedStepsWithinAdv_zero {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (cfg : RCfg r) :
expectedStepsWithinAdv w adv p 0 cfg = 0
@[simp]
theorem Cslib.WordRAM.Resizable.supExpectedStepsWithin_zero {B : Basis} {r : ℕ} (w : ℕ) (p : RProgram B r) (cfg : RCfg r) :
@[simp]
theorem Cslib.WordRAM.Resizable.expectedStepsFromAdv_halted {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (v : ℕ) (d : RData r) :
theorem Cslib.WordRAM.Resizable.expectedStepsWithinAdv_mono {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (cfg : RCfg r) :
Monotone fun (N : ℕ) => expectedStepsWithinAdv w adv p N cfg
theorem Cslib.WordRAM.Resizable.supExpectedStepsWithin_mono {B : Basis} {r : ℕ} (w : ℕ) (p : RProgram B r) (cfg : RCfg r) :
Monotone fun (N : ℕ) => supExpectedStepsWithin w p N cfg
theorem Cslib.WordRAM.Resizable.expectedStepsWithinAdv_running_succ {B : Basis} {r : ℕ} (w : ℕ) (adv : RAdv r) (p : RProgram B r) (N : ℕ) (s : RState r) :

1-step Bellman equation for expectedStepsWithinAdv.

structure Cslib.WordRAM.Resizable.ExecRProgramDist {B : Basis} {r : ℕ} (w : ℕ) (p : RProgram B r) (out : Fin r) (x : RData r) (μ : PMF (RData r)) (T : ENNReal) (L_peak : ℕ) :

Flat Resizable Word RAM Distributional Execution (ExecRProgramDist). Starting at ⟨0, x⟩ at word width w, p : RProgram B r with output register out : Fin r:

  1. never faults under any adaptive adversary (RDemonicFaultFree),
  2. keeps the active hardware frontier ≤ L_peak at every step (PeakFrontierLe),
  3. runs in at most T expected instructions (expectedTimeDemonic w p ⟨0, x⟩ ≤ T), and
  4. reaches halting distribution μ : PMF (RData r) across every adaptive adversary adv.
  • faultFree : RDemonicFaultFree w p { pc := 0, data := x }

    Zero faults across all adaptive adversaries and horizons.

  • peakFrontierLe : PeakFrontierLe w L_peak p { pc := 0, data := x }

    Hardware frontier stays ≤ L_peak across all adaptive adversaries and horizons.

  • expectedTime_le : expectedTimeDemonic w p { pc := 0, data := x } ≤ T

    Supremum expected step count is at most T.

  • halted_le (adv : RAdv r) (y : RData r) : μ y ≤ ⨆ (t : ℕ), (evalRandDemonic w adv p t { pc := 0, data := x }) (RCfg.halted (y.regs out) y)

    Every state y is reached at .halted (y.regs out) y with probability at least μ y.

theorem Cslib.WordRAM.Resizable.ExecRProgramDist.mono {B : Basis} {r w L₁ L₂ : ℕ} {p : RProgram B r} {out : Fin r} {x : RData r} {μ : PMF (RData r)} {T₁ T₂ : ENNReal} (h : ExecRProgramDist w p out x μ T₁ L₁) (hT : T₁ ≤ T₂) (hL : L₁ ≤ L₂) :
ExecRProgramDist w p out x μ T₂ L₂
theorem Cslib.WordRAM.Resizable.ExecRProgramDist.iSup_evalRandDemonic_halted_eq {B : Basis} {r w L_peak : ℕ} {p : RProgram B r} {out : Fin r} {x : RData r} {μ : PMF (RData r)} {T : ENNReal} (h : ExecRProgramDist w p out x μ T L_peak) (adv : RAdv r) (y₀ : RData r) :
⨆ (t : ℕ), (evalRandDemonic w adv p t { pc := 0, data := x }) (RCfg.halted (y₀.regs out) y₀) = μ y₀

ExecRProgramDist implies AlmostSurelyHaltsDemonic and pins the exact limiting halting probability of every y : RData r to μ y under every adaptive adversary adv : RAdv r.

theorem Cslib.WordRAM.Resizable.ExecRProgramDist.almostSurelyHaltsDemonic {B : Basis} {r w L_peak : ℕ} {p : RProgram B r} {out : Fin r} {x : RData r} {μ : PMF (RData r)} {T : ENNReal} (h : ExecRProgramDist w p out x μ T L_peak) :
AlmostSurelyHaltsDemonic w p { pc := 0, data := x }

Every ExecRProgramDist halts almost surely under every adaptive adversary.

theorem Cslib.WordRAM.Resizable.not_execRProgramDist_halt {B : Basis} {r w L_peak : ℕ} {out : Fin r} {x y : RData r} {μ : PMF (RData r)} {T : ENNReal} (hy : y ∈ μ.support) (hne : y ≠ x) :
¬ExecRProgramDist w [RInstr.halt out] out x μ T L_peak

Soundness Check (not_execRProgramDist_halt). A 1-instruction [.halt out] stub cannot satisfy ExecRProgramDist for any target distribution μ whose support contains a state y ≠ x.

theorem Cslib.WordRAM.Resizable.evalResizable_frontier_eq {B : Basis} {r w : ℕ} {o : Op B r} {x y : RData r} (he : evalResizable w o x = some y) :

Every evalResizable step leaves the hardware word frontier unchanged.

theorem Cslib.WordRAM.Resizable.RDemonicExec.exists_post_frontier_le {B : Basis} {r w L_peak n : ℕ} {c : RCode B r} {x : RData r} {P : RData r → Prop} (h : RDemonicExec w L_peak c x n P) :
∃ (y : RData r), P y ∧ y.frontier ≤ L_peak

Every RDemonicExec w L_peak c x n P witnesses at least one reachable post-state y satisfying P y and y.frontier ≤ L_peak.

Compilation of RDemonicExec and ExecRCodeDist to flat RProgram #

def Cslib.WordRAM.Resizable.DemonicSafeWithin {B : Basis} {r : ℕ} (w L_peak T_hor : ℕ) (p : RProgram B r) (s : RState r) :

Horizon-bounded non-faulting and ≤ L_peak frontier invariant on evalRandDemonic.

theorem Cslib.WordRAM.Resizable.DemonicSafeWithin.anti {B : Basis} {r w L_peak T₁ T₂ : ℕ} {p : RProgram B r} {s : RState r} (hT : T₁ ≤ T₂) (h : DemonicSafeWithin w L_peak T₂ p s) :
DemonicSafeWithin w L_peak T₁ p s
theorem Cslib.WordRAM.Resizable.DemonicSafeWithin.mono_peak {B : Basis} {r w L₁ L₂ T_hor : ℕ} {p : RProgram B r} {s : RState r} (hL : L₁ ≤ L₂) (h : DemonicSafeWithin w L₁ T_hor p s) :
DemonicSafeWithin w L₂ T_hor p s
theorem Cslib.WordRAM.Resizable.DemonicSafeWithin.frontier_le {B : Basis} {r w L_peak T_hor : ℕ} {p : RProgram B r} {s : RState r} (h : DemonicSafeWithin w L_peak T_hor p s) :
s.data.frontier ≤ L_peak
theorem Cslib.WordRAM.Resizable.demonicSafeWithin_of_pure {B : Basis} {r w L_peak T_hor : ℕ} {p : RProgram B r} {s : RState r} {s' : (RState r → ℕ → ℕ) → RState r} (hfr : s.data.frontier ≤ L_peak) (hstep : ∀ (f : RState r → ℕ → ℕ), stepRandResizable w f p (RCfg.running s) = pure (RCfg.running (s' f))) (hnext : ∀ (f : RState r → ℕ → ℕ) (k : ℕ), k + 1 ≤ T_hor → DemonicSafeWithin w L_peak k p (s' f)) :
DemonicSafeWithin w L_peak T_hor p s
theorem Cslib.WordRAM.Resizable.demonicSafeWithin_of_rand {B : Basis} {r w L_peak T_hor : ℕ} {p : RProgram B r} {pc : ℕ} {x : RData r} {dst src : Fin r} (hfr : x.frontier ≤ L_peak) (hp : p[pc]? = some (RInstr.rand dst src)) (hfit : Fits w (x.regs src)) (hnext : ∀ (j : Fin (x.regs src + 1)) (k : ℕ), k + 1 ≤ T_hor → DemonicSafeWithin w L_peak k p { pc := pc + 1, data := x.set dst ↑j }) :
DemonicSafeWithin w L_peak T_hor p { pc := pc, data := x }
theorem Cslib.WordRAM.Resizable.supExpectedStepsWithin_le_of_pure {B : Basis} {r w N : ℕ} {p : RProgram B r} {s : RState r} {s' : (RState r → ℕ → ℕ) → RState r} (hstep : ∀ (f : RState r → ℕ → ℕ), stepRandResizable w f p (RCfg.running s) = pure (RCfg.running (s' f))) :
supExpectedStepsWithin w p N (RCfg.running s) ≤ 1 + ⨆ (f : RState r → ℕ → ℕ), supExpectedStepsWithin w p N (RCfg.running (s' f))
noncomputable def Cslib.WordRAM.Resizable.haltedReach {B : Basis} {r : ℕ} (w : ℕ) (p : RProgram B r) (v : ℕ) (d : RData r) (pc : ℕ) (y : RData r) :

Worst-case-adversary supremum halting probability at .halted v d from ⟨pc, y⟩.

theorem Cslib.WordRAM.Resizable.haltedReach_le_of_pure {B : Basis} {r w v : ℕ} {p : RProgram B r} {d : RData r} {s : RState r} {s' : (RState r → ℕ → ℕ) → RState r} (hstep : ∀ (f : RState r → ℕ → ℕ), stepRandResizable w f p (RCfg.running s) = pure (RCfg.running (s' f))) :
⨅ (f : RState r → ℕ → ℕ), haltedReach w p v d (s' f).pc (s' f).data ≤ haltedReach w p v d s.pc s.data
theorem Cslib.WordRAM.Resizable.haltedReach_le_of_const {B : Basis} {r w v : ℕ} {p : RProgram B r} {d : RData r} {s s₁ : RState r} (hstep : ∀ (f : RState r → ℕ → ℕ), stepRandResizable w f p (RCfg.running s) = pure (RCfg.running s₁)) :
haltedReach w p v d s₁.pc s₁.data ≤ haltedReach w p v d s.pc s.data
theorem Cslib.WordRAM.Resizable.haltedReach_le_of_rand {B : Basis} {r w v pc : ℕ} {p : RProgram B r} {d x : RData r} {dst src : Fin r} (hp : p[pc]? = some (RInstr.rand dst src)) (hfit : Fits w (x.regs src)) :
∑' (k : Fin (x.regs src + 1)), (ProbComp.unifFin (x.regs src)).eval k * haltedReach w p v d (pc + 1) (x.set dst ↑k) ≤ haltedReach w p v d pc x
theorem Cslib.WordRAM.Resizable.RDemonicExec.supExpectedStepsWithin_assemble {B : Basis} {r w L_peak n pc N : ℕ} {c : RCode B r} {x : RData r} {P : RData r → Prop} (h : RDemonicExec w L_peak c x n P) {p : RProgram B r} (hp : p.Contains pc (c.assemble pc)) :
supExpectedStepsWithin w p N (RCfg.running { pc := pc, data := x }) ≤ ↑n + ⨆ (y : RData r), ⨆ (_ : P y), supExpectedStepsWithin w p N (RCfg.running { pc := pc + c.size, data := y })
theorem Cslib.WordRAM.Resizable.RDemonicExec.demonicSafeWithin_assemble {B : Basis} {r w L_peak n pc T_hor : ℕ} {c : RCode B r} {x : RData r} {P : RData r → Prop} (h : RDemonicExec w L_peak c x n P) {p : RProgram B r} (hp : p.Contains pc (c.assemble pc)) (hcont : ∀ (y : RData r), P y → DemonicSafeWithin w L_peak T_hor p { pc := pc + c.size, data := y }) :
DemonicSafeWithin w L_peak T_hor p { pc := pc, data := x }