Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpFastBaseProg.Frame

Fast-Mode Transition Frame Invariant (FastStateStep) and Large-Regime Bounds #

This module defines the compositional transition invariant FastStateStep for fast-mode Memory.Prog subroutines on FastMemRep, together with:

  1. Large-regime index and capacity bounds (large_index_bounds, bufTrie_caps_of_bounds).
  2. FastStateStep reflexivity/transitivity, bTreeSliceMemRep_congr, and FastMemRep slice/buffer projections (FastMemRep.slice_rep, FastMemRep.buf_rep).
  3. CostBoundedStep, the final state, result, cost bound and validity of one run of a Memory.Prog, with its pure/bind/if composition rules.

Main definitions #

Main results #

Section 1: Segment and Index Bounds #

Section 2: FastStateStep and FastMemRep Projections #

Bundled transition invariant for fast-mode Memory.Prog substeps: preserves frontier, SeedWhpMemRep, FastMemRep for fs', and all memory words outside [base, base + largeSpaceWhp c U V w n_max).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.FastStateStep.refl {base c U V w n_max : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
FastStateStep base c U V w n_max θ fs s s
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.FastStateStep.trans {base c U V w n_max : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs₁ fs₂ : SuccinctWhp.FastState} {s₀ s₁ s₂ : Memory.State} (h₁ : FastStateStep base c U V w n_max θ fs₁ s₀ s₁) (h₂ : FastStateStep base c U V w n_max θ fs₂ s₁ s₂) :
FastStateStep base c U V w n_max θ fs₂ s₀ s₂
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bTreeSliceMemRep_congr {base c U V w n_max sIdx : ℕ} {sl : SuccinctWhp.BTreeSlice} {mem₁ mem₂ : ℕ → ℕ} (hw : 0 < w) (hsIdx : sIdx < 3 * SuccinctWhp.numBucketsWhp n_max) (hbm : BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w mem₂ (16 * (sIdx / 3) + 10 + 2 * (sIdx % 3)) = BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w mem₁ (16 * (sIdx / 3) + 10 + 2 * (sIdx % 3)) ∧ BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w mem₂ (16 * (sIdx / 3) + 11 + 2 * (sIdx % 3)) = BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w mem₁ (16 * (sIdx / 3) + 11 + 2 * (sIdx % 3))) (hbt : ∀ (a : ℕ), base + offBtMeta c U V w n_max ≤ a → a < base + offTrieChild0 c U V w n_max → mem₂ a = mem₁ a) (hrep : BTreeSliceMemRep base c U V w n_max sIdx sl mem₁) :
BTreeSliceMemRep base c U V w n_max sIdx sl mem₂

BTreeSliceMemRep invariance when offBktMeta ([10..15]) and [offBtMeta, offTrieChild0) are unchanged.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.FastMemRep.slice_rep {base c U V w n_max sIdx : ℕ} {fs : SuccinctWhp.FastState} {mem : ℕ → ℕ} (hsIdx : sIdx < 3 * SuccinctWhp.numBucketsWhp n_max) (hrep : FastMemRep base c U V w n_max fs mem) :
BTreeSliceMemRep base c U V w n_max sIdx (fs.slices sIdx) mem
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.FastMemRep.buf_rep {base c U V w n_max ep : ℕ} {fs : SuccinctWhp.FastState} {mem : ℕ → ℕ} (hep : ep = 0 ∨ ep = 1) (hrep : FastMemRep base c U V w n_max fs mem) :
BufTrieMemRep base c U V w n_max ep (fs.buf ep) mem

Section 3: Cost-Bounded Steps #

CostBoundedStep w F s p s' r C: running the memory program p from state s ends in state s' with result r, issues at most C memory operations (memoryCost), and produces a valid memory history at word size w whenever s is well formed with frontier at least F (ValidProg).

A run that leaves the state unchanged at exact cost C is a cost-bounded step.

Pure return takes zero memory operations and leaves the state unchanged.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.CostBoundedStep.bind {α : Type} {w F : ℕ} {s : Memory.State} {β : Type} {C₁ C₂ : ℕ} {s₁ s₂ : Memory.State} {f : Memory.Prog α} {g : α → Memory.Prog β} {x : α} {y : β} (hf : CostBoundedStep w F s f s₁ x C₁) (hg : CostBoundedStep w F s₁ (g x) s₂ y C₂) :
CostBoundedStep w F s (f >>= g) s₂ y (C₁ + C₂)

Sequential composition sums cost bounds and threads the intermediate state and result.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.CostBoundedStep.mono {α : Type} {w F C C' : ℕ} {s s' : Memory.State} {p : Memory.Prog α} {r : α} (h : CostBoundedStep w F s p s' r C) (hC : C ≤ C') :
CostBoundedStep w F s p s' r C'

Relax the memory-operation upper bound of a cost-bounded step.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.CostBoundedStep.ite {α : Type} {w F C : ℕ} {s s' : Memory.State} {c : Prop} [Decidable c] {p₁ p₂ : Memory.Prog α} {r₁ r₂ : α} (h₁ : CostBoundedStep w F s p₁ s' r₁ C) (h₂ : CostBoundedStep w F s p₂ s' r₂ C) :
CostBoundedStep w F s (if c then p₁ else p₂) s' (if c then r₁ else r₂) C

Conditional execution with matching final state and cost bound across both branches.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.CostBoundedStep.if_pos {α : Type} {w F C : ℕ} {s s' : Memory.State} {c : Prop} [Decidable c] {p₁ p₂ : Memory.Prog α} {r : α} (hc : c) (h : CostBoundedStep w F s p₁ s' r C) :
CostBoundedStep w F s (if c then p₁ else p₂) s' r C

Positive branch of a conditional cost-bounded step.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.CostBoundedStep.if_neg {α : Type} {w F C : ℕ} {s s' : Memory.State} {c : Prop} [Decidable c] {p₁ p₂ : Memory.Prog α} {r : α} (hc : ¬c) (h : CostBoundedStep w F s p₂ s' r C) :
CostBoundedStep w F s (if c then p₁ else p₂) s' r C

Negative branch of a conditional cost-bounded step.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.CostBoundedStep.elim {α : Type} {w F C C' : ℕ} {s s' : Memory.State} {p : Memory.Prog α} {r : α} {P : Memory.State → Prop} (h : CostBoundedStep w F s p s' r C) (hC : C ≤ C') (hP : P s') :

Read a cost-bounded step off as a cost bound, validity and a property of the final state.