Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpTickHealProg.MetaFinalize

Final Bucket Metadata, Trie-Child Zeroing, and Header Finalization for csrToFastGenProg #

This internal module implements Phases F and G of csrToFastGenProg:

Main definitions #

Main results #

Phase F: fillFinalBktMetaLoopProg (write final bucket scalar fields 0, 2..9) #

@[irreducible]

Loop writing final bucket scalar metadata across rem buckets.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.fillFinalBktMetaLoop_safe {c U V w n_max base : ℕ} (henv : WhpLargeEnv c U V w n_max w base) :
have rt := mkHealRt c U V w n_max base; ∀ (rem b₀ : ℕ) (s : Memory.State), b₀ + rem ≤ SuccinctWhp.numBucketsWhp n_max → WordRAM.Realization.iterationSafe fillFinalBktMetaStepProg HealBktStepPre w rt rem b₀ s

Loop-safety invariant for fillFinalBktMetaLoopProg.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.fillFinalBktMetaLoop_spec {c U V w n_max base : ℕ} {fbStart : ℕ → ℕ} {s₀ : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hfb_adj : ∀ b < SuccinctWhp.numBucketsWhp n_max, fbStart b ≤ fbStart (b + 1) ∧ fbStart (b + 1) - fbStart b ≤ n_max) (hfb_mem : ∀ x ≤ SuccinctWhp.numBucketsWhp n_max, BitPackedArray.readPacked (base + offFbStart c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s₀.mem x = fbStart x) :
have rt := mkHealRt c U V w n_max base; have M := SuccinctWhp.numBucketsWhp n_max; have gBits := SuccinctBucket.globalPtrBits n_max; have bm := offBktMeta c U V w n_max; ∀ (rem b₀ : ℕ) (s : Memory.State), b₀ + rem ≤ M → (∀ b < b₀, have cnt := fbStart (b + 1) - fbStart b; BitPackedArray.readPacked (base + bm) gBits w s.mem (16 * b + 0) = cnt ∧ BitPackedArray.readPacked (base + bm) gBits w s.mem (16 * b + 2) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s.mem (16 * b + 3) = cnt ∧ BitPackedArray.readPacked (base + bm) gBits w s.mem (16 * b + 4) = 1 ∧ BitPackedArray.readPacked (base + bm) gBits w s.mem (16 * b + 5) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s.mem (16 * b + 6) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s.mem (16 * b + 7) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s.mem (16 * b + 8) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s.mem (16 * b + 9) = 0) → (∀ idx < 16 * M, idx % 16 = 1 ∨ 10 ≤ idx % 16 → BitPackedArray.readPacked (base + bm) gBits w s.mem idx = BitPackedArray.readPacked (base + bm) gBits w s₀.mem idx) → (∀ (a : ℕ), a < base + bm ∨ base + offFbStart c U V w n_max ≤ a → s.mem a = s₀.mem a) → have prog := fillFinalBktMetaLoopProg ((rt, b₀), rem); have s' := (Memory.spec 0).clientState s prog; s'.frontier = s.frontier ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ (∀ b < b₀ + rem, have cnt := fbStart (b + 1) - fbStart b; BitPackedArray.readPacked (base + bm) gBits w s'.mem (16 * b + 0) = cnt ∧ BitPackedArray.readPacked (base + bm) gBits w s'.mem (16 * b + 2) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s'.mem (16 * b + 3) = cnt ∧ BitPackedArray.readPacked (base + bm) gBits w s'.mem (16 * b + 4) = 1 ∧ BitPackedArray.readPacked (base + bm) gBits w s'.mem (16 * b + 5) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s'.mem (16 * b + 6) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s'.mem (16 * b + 7) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s'.mem (16 * b + 8) = 0 ∧ BitPackedArray.readPacked (base + bm) gBits w s'.mem (16 * b + 9) = 0) ∧ (∀ idx < 16 * M, idx % 16 = 1 ∨ 10 ≤ idx % 16 → BitPackedArray.readPacked (base + bm) gBits w s'.mem idx = BitPackedArray.readPacked (base + bm) gBits w s₀.mem idx) ∧ ∀ (a : ℕ), a < base + bm ∨ base + offFbStart c U V w n_max ≤ a → s'.mem a = s₀.mem a

Exact memory specification of fillFinalBktMetaLoopProg.

Phase G: zeroTrieChildrenLoopProg and writeHealHdrsAndTrieMetaProg #

@[irreducible]

Loop zeroing offTrieChild0 and offTrieChild1.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.zeroTrieChildrenLoop_safe {c U V w n_max base : ℕ} (henv : WhpLargeEnv c U V w n_max w base) :
have rt := mkHealRt c U V w n_max base; have tc0 := offTrieChild0 c U V w n_max; have tc1 := offTrieChild1 c U V w n_max; ∀ (rem i₀ : ℕ) (s : Memory.State), i₀ + rem ≤ trieChildEntriesWhp c n_max → WordRAM.Realization.iterationSafe zeroTrieChildrenStepProg ZeroTrieChildrenPre w (rt, tc0, tc1) rem i₀ s

Loop-safety invariant for zeroTrieChildrenLoopProg.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.zeroTrieChildrenLoop_spec {c U V w n_max base : ℕ} (henv : WhpLargeEnv c U V w n_max w base) :
have rt := mkHealRt c U V w n_max base; have tc0 := offTrieChild0 c U V w n_max; have tc1 := offTrieChild1 c U V w n_max; have tce := trieChildEntriesWhp c n_max; have gBits := SuccinctBucket.globalPtrBits n_max; ∀ (rem i₀ : ℕ) (s : Memory.State), i₀ + rem ≤ tce → (∀ idx < i₀, BitPackedArray.readPacked (base + tc0) gBits w s.mem idx = 0 ∧ BitPackedArray.readPacked (base + tc1) gBits w s.mem idx = 0) → have prog := zeroTrieChildrenLoopProg (((rt, tc0, tc1), i₀), rem); have s' := (Memory.spec 0).clientState s prog; s'.frontier = s.frontier ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ (∀ idx < i₀ + rem, BitPackedArray.readPacked (base + tc0) gBits w s'.mem idx = 0 ∧ BitPackedArray.readPacked (base + tc1) gBits w s'.mem idx = 0) ∧ ∀ (a : ℕ), a < base + tc0 ∨ base + offTrieMeta0 c U V w n_max ≤ a → s'.mem a = s.mem a

Exact memory specification of zeroTrieChildrenLoopProg.

@[irreducible]

Clear root nodeActive flags in offTrieMeta0/offTrieMeta1 and write the 16 fast-mode header words at base .. base + 15.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writeHealHdrsAndTrieMetaProg_spec {c U V w n_max base freeTop : ℕ} (henv : WhpLargeEnv c U V w n_max w base) (hft_fit : WordRAM.Fits w freeTop) (s : Memory.State) :
have rt := mkHealRt c U V w n_max base; have tm0 := offTrieMeta0 c U V w n_max; have tm1 := offTrieMeta1 c U V w n_max; have gBits := SuccinctBucket.globalPtrBits n_max; have prog := writeHealHdrsAndTrieMetaProg ((rt, tm0, tm1), freeTop); have s' := (Memory.spec 0).clientState s prog; s'.frontier = s.frontier ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ s'.mem (base + hdrMode) = 1 ∧ s'.mem (base + hdrPoolFreeTop) = freeTop ∧ s'.mem (base + hdrCurEp) = 0 ∧ s'.mem (base + hdrEpochClock) = 0 ∧ s'.mem (base + hdrRebStage) = 5 ∧ s'.mem (base + hdrStageCursor) = 0 ∧ s'.mem (base + hdrDirtyCount) = 0 ∧ s'.mem (base + hdrDirtyIdx) = 0 ∧ s'.mem (base + hdrRebCandSalt) = 0 ∧ s'.mem (base + hdrRebScanCursor) = 0 ∧ s'.mem (base + hdrRebInsCount) = 0 ∧ s'.mem (base + hdrRebCollision) = 0 ∧ s'.mem (base + hdrBuf0NodeAlloc) = 1 ∧ s'.mem (base + hdrBuf0ItemAlloc) = 0 ∧ s'.mem (base + hdrBuf1NodeAlloc) = 1 ∧ s'.mem (base + hdrBuf1ItemAlloc) = 0 ∧ BitPackedArray.readPacked (base + tm0) gBits w s'.mem 2 = 0 ∧ BitPackedArray.readPacked (base + tm1) gBits w s'.mem 2 = 0 ∧ ∀ (a : ℕ), a < base ∨ base + 16 ≤ a ∧ a < base + tm0 ∨ base + offTrieItems0 c U V w n_max ≤ a → s'.mem a = s.mem a

Exact memory specification of writeHealHdrsAndTrieMetaProg.