Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpBufferTrieProg.Helpers

Shared Internal BufRt Accessors, Safety Lemmas, and Frame Bridges #

Internal module imported privately by SuccinctWhpBufferTrieProg submodules; never re-exported through the public facade.

Main definitions #

Main results #

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bufWalk_add_off (bChar : ℕ) (child : ℕ → ℕ → ℕ) (rem off r cur : ℕ) :
SuccinctWhp.bufWalk bChar child r rem (off + 1) cur = SuccinctWhp.bufWalk bChar child (r / 2 ^ bChar) rem off cur

Shift-offset invariance of bufWalk: stepping off + 1 is identical to shifting r right by bChar and stepping off.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bufEnsurePath_add_off (bChar rem off r : ℕ) (tr : SuccinctWhp.BufTrie) (cur : ℕ) :
SuccinctWhp.bufEnsurePath bChar r rem (off + 1) tr cur = SuccinctWhp.bufEnsurePath bChar (r / 2 ^ bChar) rem off tr cur

Shift-offset invariance of bufEnsurePath: stepping off + 1 is identical to shifting r right by bChar and stepping off.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.child_idx_eq_iff {bChar v₁ c₁ v₂ c₂ : ℕ} (hc₁ : c₁ < 2 ^ bChar) (hc₂ : c₂ < 2 ^ bChar) :
v₁ * 2 ^ bChar + c₁ = v₂ * 2 ^ bChar + c₂ ↔ v₁ = v₂ ∧ c₁ = c₂

Unique (v, c) decomposition of v * 2 ^ bChar + c when c < 2 ^ bChar.

Global pointer bit-width in BufRt.

Character alphabet size 2 ^ bChar in BufRt.

Character mask 2 ^ bChar - 1 in BufRt.

Constant trie depth cTab in BufRt.

Maximum trie node capacity maxTrieNodesWhp in BufRt.

Parameter-free BufRt envelope in the large regime.

Extract BufRt from ((cp, base), ep) in zero memory operations.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.mkBufRtGenProg_spec {c U V w n_max base ep : ℕ} (hth : SuccinctWhp.whpThreshold c ≤ n_max) (s : Memory.State) :
have prog := mkBufRtGenProg ((mkWhpCoreParams c U V w n_max, base), ep); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = mkBufRt c U V w n_max base ep ∧ WordRAM.Realization.memoryCost prog s = 0 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.rt_child_safe {c U V w₀ n_max w base ep : ℕ} (henv : WhpLargeEnv c U V w₀ n_max w base) (hep : ep = 0 ∨ ep = 1) {idx : ℕ} (hidx : idx < trieChildEntriesWhp c n_max) :
have rt := mkBufRt c U V w₀ n_max base ep; ∃ (N : ℕ), w = brW rt ∧ 0 < w ∧ brGBits rt ≤ w ∧ idx < N ∧ WordRAM.Fits w (brBase rt + brOffChild rt + BitPackedArray.packedWords N (brGBits rt) w)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.rt_meta_safe {c U V w₀ n_max w base ep : ℕ} (henv : WhpLargeEnv c U V w₀ n_max w base) (hep : ep = 0 ∨ ep = 1) {idx : ℕ} (hidx : idx < 6 * SuccinctWhp.maxTrieNodesWhp c n_max) :
have rt := mkBufRt c U V w₀ n_max base ep; ∃ (N : ℕ), w = brW rt ∧ 0 < w ∧ brGBits rt ≤ w ∧ idx < N ∧ WordRAM.Fits w (brBase rt + brOffMeta rt + BitPackedArray.packedWords N (brGBits rt) w)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.rt_items_safe {c U V w₀ n_max w base ep : ℕ} (henv : WhpLargeEnv c U V w₀ n_max w base) (hep : ep = 0 ∨ ep = 1) {idx : ℕ} (hidx : idx < 6 * SuccinctWhp.qEpochWhp n_max + 6) :
have rt := mkBufRt c U V w₀ n_max base ep; ∃ (N : ℕ), w = brW rt ∧ 0 < w ∧ brGBits rt ≤ w ∧ idx < N ∧ WordRAM.Fits w (brBase rt + brOffItems rt + BitPackedArray.packedWords N (brGBits rt) w)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bufEpFrame_write_hdrNA {base c U V w n_max ep val : ℕ} {mem : ℕ → ℕ} (hw : 0 < w) (hep : ep = 0 ∨ ep = 1) :
have rt := mkBufRt c U V w n_max base ep; BufEpFrame base c U V w n_max ep mem (Function.update mem (base + brHdrNA rt) val)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bufEpFrame_write_hdrIA {base c U V w n_max ep val : ℕ} {mem : ℕ → ℕ} (hw : 0 < w) (hep : ep = 0 ∨ ep = 1) :
have rt := mkBufRt c U V w n_max base ep; BufEpFrame base c U V w n_max ep mem (Function.update mem (base + brHdrIA rt) val)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bufEpFrame_writeChild {base c U V w n_max ep idx val : ℕ} {mem : ℕ → ℕ} (hw : 0 < w) (hep : ep = 0 ∨ ep = 1) (hidx : idx < trieChildEntriesWhp c n_max) :
have rt := mkBufRt c U V w n_max base ep; BufEpFrame base c U V w n_max ep mem (BitPackedArray.writePacked (base + brOffChild rt) (SuccinctBucket.globalPtrBits n_max) w mem idx val)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bufEpFrame_writeMeta {base c U V w n_max ep idx val : ℕ} {mem : ℕ → ℕ} (hw : 0 < w) (hep : ep = 0 ∨ ep = 1) (hidx : idx < 6 * SuccinctWhp.maxTrieNodesWhp c n_max) :
have rt := mkBufRt c U V w n_max base ep; BufEpFrame base c U V w n_max ep mem (BitPackedArray.writePacked (base + brOffMeta rt) (SuccinctBucket.globalPtrBits n_max) w mem idx val)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bufEpFrame_writeItems_lt3q {base c U V w n_max ep idx val : ℕ} {mem : ℕ → ℕ} (hw : 0 < w) (hep : ep = 0 ∨ ep = 1) (hidx : idx < 3 * SuccinctWhp.qEpochWhp n_max) :
have rt := mkBufRt c U V w n_max base ep; BufEpFrame base c U V w n_max ep mem (BitPackedArray.writePacked (base + brOffItems rt) (SuccinctBucket.globalPtrBits n_max) w mem idx val)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.bufTrieMemRep_iff_rt {base c U V w n_max ep : ℕ} {tr : SuccinctWhp.BufTrie} {mem : ℕ → ℕ} :
BufTrieMemRep base c U V w n_max ep tr mem ↔ have rt := mkBufRt c U V w n_max base ep; tr.nodeAlloc ≤ SuccinctWhp.maxTrieNodesWhp c n_max ∧ tr.itemAlloc ≤ SuccinctWhp.qEpochWhp n_max ∧ mem (base + brHdrNA rt) = tr.nodeAlloc ∧ mem (base + brHdrIA rt) = tr.itemAlloc ∧ (∀ u < SuccinctWhp.maxTrieNodesWhp c n_max, ∀ ch < 2 ^ SuccinctWhp.bCharWhp n_max, BitPackedArray.readPacked (base + brOffChild rt) (SuccinctBucket.globalPtrBits n_max) w mem (u * 2 ^ SuccinctWhp.bCharWhp n_max + ch) = tr.trieChild u ch) ∧ (∀ (u : ℕ), 1 ≤ u → u < tr.nodeAlloc → BitPackedArray.readPacked (base + brOffMeta rt) (SuccinctBucket.globalPtrBits n_max) w mem (4 * u + 0) = tr.nodeParent u ∧ BitPackedArray.readPacked (base + brOffMeta rt) (SuccinctBucket.globalPtrBits n_max) w mem (4 * u + 1) = tr.nodeChar u) ∧ (∀ u < tr.nodeAlloc, BitPackedArray.readPacked (base + brOffMeta rt) (SuccinctBucket.globalPtrBits n_max) w mem (4 * u + 2) = tr.nodeLeafItem u ∧ (tr.nodeLeafItem u ≠ 0 → BitPackedArray.readPacked (base + brOffMeta rt) (SuccinctBucket.globalPtrBits n_max) w mem (4 * u + 3) = tr.nodeActive u)) ∧ ∀ id < tr.itemAlloc, BitPackedArray.readPacked (base + brOffItems rt) (SuccinctBucket.globalPtrBits n_max) w mem id = tr.itemLeaf id ∧ BitPackedArray.readPacked (base + brOffItems rt) (SuccinctBucket.globalPtrBits n_max) w mem (SuccinctWhp.qEpochWhp n_max + id) = tr.itemBucket id ∧ BitPackedArray.readPacked (base + brOffItems rt) (SuccinctBucket.globalPtrBits n_max) w mem (2 * SuccinctWhp.qEpochWhp n_max + id) = tr.itemLoc id
@[irreducible]

BufRt active-item reader for bufLookup: given (rt, id) (id < qEp), reads (1, (b, loc)).