Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpTickHealProg.HealRt

Runtime Bundle, Capacity Bounds, and Monadic Step Combinators for SuccinctWhp Self-Healing #

This internal support module provides the 16-word HealRt runtime parameter bundle, bucket/pool conservation bounds under GoodSeedOnState, clampSubProg, stateless loop-safety induction iterationSafe_of_stateless_step, and bundled StepSpec monadic bind/read/write combinators shared across the parallel csrToFastGenProg phase modules.

Main definitions #

Main results #

Pure Capacity Bounds #

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.backPrefix_spec (M cf : ℕ) (fbStart : ℕ → ℕ) :
have bp := SuccinctWhp.buildBackPrefix M cf fbStart; bp 0 = 0 ∧ (∀ b < M, bp (b + 1) = bp b + (fbStart (b + 1) - fbStart b - cf)) ∧ (∀ k ≤ M, bp k = ∑ b ∈ Finset.range k, (fbStart (b + 1) - fbStart b - cf)) ∧ ∀ (x y : ℕ), x ≤ y → y ≤ M → bp x ≤ bp y

Recurrence, summation, and monotonicity properties of buildBackPrefix.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.csrToFast_bounds_of_good {c U V n_max : ℕ} (hth : SuccinctWhp.whpThreshold c ≤ n_max) {θ : SuccinctWhp.SeedWhp c U n_max} {csr : SuccinctWhp.CsrState} {dict : State U} (hcsr : SuccinctWhp.ValidCsrState U V n_max (SuccinctWhp.bktHash c U n_max θ.1) csr dict) (hgood : SuccinctWhp.GoodSeedOnState c U n_max θ dict) :
have M := SuccinctWhp.numBucketsWhp n_max; have cf := SuccinctWhp.capFrontWhp n_max; have cb := SuccinctWhp.capBackWhp n_max; have bp := SuccinctWhp.buildBackPrefix M cf csr.fbStart; (∀ b < M, csr.fbStart (b + 1) - csr.fbStart b - cf < cb ∧ csr.fbStart (b + 1) - csr.fbStart b ≤ SuccinctWhp.totalLocalCoordsWhp n_max) ∧ bp M ≤ SuccinctWhp.poolSizeWhp n_max

Under GoodSeedOnState, every bucket's backyard overflow fits within capBackWhp n_max, total bucket load fits within totalLocalCoordsWhp n_max, and total backyard occupancy fits within poolSizeWhp n_max.

HealRt 16-Word Runtime Bundle #

@[reducible, inline]

Compact 16-word runtime bundle for csrToFastGenProg array phases: ((((base, w), (nMax, M)), ((cf, cb), (totalLoc, poolSize))), ((gBits, tcEntries), ((offBm, offFb), ((offBp, offPs), (offPo, offLs))))).

Bucket count numBucketsWhp n_max in HealRt.

Front-yard capacity capFrontWhp n_max in HealRt.

Backyard pointer capacity capBackWhp n_max in HealRt.

Per-bucket coordinate limit totalLocalCoordsWhp n_max in HealRt.

Backyard pool size poolSizeWhp n_max in HealRt.

Global pointer bit-width globalPtrBits n_max in HealRt.

Trie child-entry count trieChildEntriesWhp c n_max in HealRt.

Construct HealRt for (c, U, V, w, n_max, base).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.hlBase_mk (c U V w n_max base : ℕ) :
hlBase (mkHealRt c U V w n_max base) = base
@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.hlW_mk (c U V w n_max base : ℕ) :
hlW (mkHealRt c U V w n_max base) = w
@[simp]
@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.hlOffBm_mk (c U V w n_max base : ℕ) :
hlOffBm (mkHealRt c U V w n_max base) = offBktMeta c U V w n_max

Shared precondition for per-bucket outer loops over HealRt × ℕ.

@[irreducible]

Assemble HealRt from (WhpCoreParams, base) in zero memory steps.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.mkHealRtGenProg_spec {c U V w n_max base : ℕ} (hth : SuccinctWhp.whpThreshold c ≤ n_max) (s : Memory.State) :
have prog := mkHealRtGenProg (mkWhpCoreParams c U V w n_max, base); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = mkHealRt c U V w n_max base ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog

Exact specification of mkHealRtGenProg in the large regime.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.hl_bounds {c U V w n_max base : ℕ} (henv : WhpLargeEnv c U V w n_max w base) :

Parameter and bit-width bounds implied by WhpLargeEnv.

@[irreducible]

Saturating subtraction p.1 - p.2 as a zero-memory Memory.Prog subroutine.

Exact specification of clampSubProg when tb ≤ ps.

Shared Loop-Safety & Monadic StepSpec Combinators #

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.iterationSafe_of_stateless_step {Cfg : Type} (step : Cfg × ℕ → Memory.Prog ℕ) (Pre : ℕ → Cfg × ℕ → Memory.State → Prop) {w N : ℕ} {cfg : Cfg} (hpre : ∀ i < N, ∀ (s : Memory.State), Pre w (cfg, i) s) (hres : ∀ i < N, ∀ (s : (Memory.spec 0).State), (Memory.spec 0).clientResult s (step (cfg, i)) = i + 1) (rem i₀ : ℕ) (s : Memory.State) :
i₀ + rem ≤ N → WordRAM.Realization.iterationSafe step Pre w cfg rem i₀ s

Generic iterationSafe induction for counter-incrementing loops Cfg × ℕ → Memory.Prog ℕ whose step precondition holds for every i < N independently of memory state.

Bundled clientState, clientResult, and ValidProg specification for Memory.spec 0, allowing monadic do-blocks to be discharged in a single pass instead of three separate passes.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.StepSpec.bind {α β : Type} {w F : ℕ} {s s₁ s₂ : Memory.State} {f : Memory.Prog α} {g : α → Memory.Prog β} {x : α} {y : β} (hf : StepSpec w F s f s₁ x) (hg : StepSpec w F s₁ (g x) s₂ y) :
StepSpec w F s (f >>= g) s₂ y
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.StepSpec.write {w F a v : ℕ} {s : Memory.State} (ha : a < F) (hfit : WordRAM.Fits w v) :
StepSpec w F s (Memory.write a v) { mem := Function.update s.mem a v, frontier := s.frontier } ()
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.StepSpec.readPackedGen {N w F base off k idx : ℕ} {s : Memory.State} (hw : 0 < w) (hidx : idx < N) (hbnd : base + off + BitPackedArray.packedWords N k w ≤ F) :
StepSpec w F s (BitPackedArray.readPackedGenProg (((base, off), k, w), idx)) s (BitPackedArray.readPacked (base + off) k w s.mem idx)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.StepSpec.readPackedGen_eq {N w F base off k idx val : ℕ} {s : Memory.State} (hw : 0 < w) (hidx : idx < N) (hbnd : base + off + BitPackedArray.packedWords N k w ≤ F) (heq : BitPackedArray.readPacked (base + off) k w s.mem idx = val) :
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.StepSpec.writePackedGen {N w F base off k idx v : ℕ} {s : Memory.State} (hw : 0 < w) (hk : k ≤ w) (hidx : idx < N) (hbnd : base + off + BitPackedArray.packedWords N k w ≤ F) :
StepSpec w F s (BitPackedArray.writePackedGenProg ((((base, off), k, w), idx), v)) { mem := BitPackedArray.writePacked (base + off) k w s.mem idx v, frontier := s.frontier } ()