Overflow-Free Runtime targetCap Evaluator (computeTargetCapProg) #
Provides computeTargetCapProg, a parameter-free (¬ReadsWidth) Memory.Prog evaluator computing
targetCap U n = if n = 0 then 0 else min (2 * n) U from word 0 (U - 1) of the root header in
at most 1 memory operation without intermediate 2 * n word overflow, together with its
RealizesBounded .exact certificate (realizesBounded_computeTargetCap) and functional
specification (computeTargetCapProg_spec).
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.computeTargetCapProg,ComputeTargetCapPre: parameter-freeMemory.Progevaluator fortargetCap U nand its word-width precondition.
Main results #
Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.realizesBounded_computeTargetCap,computeTargetCapProg_spec:RealizesBounded .exactcertificate and functional specification.
Evaluate targetCap U n = if n = 0 then 0 else min (2 * n) U from [hdrBase] (= U - 1)
without intermediate 2 * n overflow (¬ReadsWidth).
Precondition for computeTargetCapProg.
computeTargetCapProg compiles via RealizesBounded .exact without reading w.
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.computeTargetCapProg_spec {w U V N_old n_hdr n_init_hdr hdrBase n : ℕ} {s : Memory.State} (hhdr : RootHeaderValid U V w N_old n_hdr n_init_hdr hdrBase s.mem) (hfr : hdrBase < s.frontier) (hnU : n ≤ U) (hfit1 : WordRAM.Fits w 1) :
ComputeTargetCapPre w (hdrBase, n) s ∧ (Memory.spec w).ValidHistory s ((Memory.spec w).clientHistory s (computeTargetCapProg (hdrBase, n))) ∧ (Memory.spec 0).clientState s (computeTargetCapProg (hdrBase, n)) = s ∧ (Memory.spec 0).clientResult s (computeTargetCapProg (hdrBase, n)) = targetCap U n ∧ WordRAM.Realization.memoryCost (computeTargetCapProg (hdrBase, n)) s ≤ 1
Functional specification and ≤ 1-read cost bound for computeTargetCapProg.