Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.ResizableSuccinct.MetaSync

Metadata Frame Laws, Circular-Window Effects, and Compacted Slot Resolution #

This module connects the low-level Memory.Prog primitives in WindowOps.lean to the pure metadata and circular-window invariants in Compaction.lean and SuccinctHash.lean:

Main definitions #

Main results #

References #

Section 1: Cross-Region Congruence and Pure Function.update Frame Laws #

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compLmAt_congr {metaBase U w N : ℕ} (hw : 0 < w) {mem₁ mem₂ : ℕ → ℕ} (h : ∀ (addr : ℕ), metaBase + offCompLM U w N ≤ addr ∧ addr < metaBase + offCompGM U w N → mem₁ addr = mem₂ addr) :
compLmAt metaBase U w N mem₁ = compLmAt metaBase U w N mem₂
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compGmAt_congr {metaBase U w N : ℕ} (hw : 0 < w) {mem₁ mem₂ : ℕ → ℕ} (h : ∀ (addr : ℕ), metaBase + offCompGM U w N ≤ addr ∧ addr < metaBase + offTailToDense U w N → mem₁ addr = mem₂ addr) :
compGmAt metaBase U w N mem₁ = compGmAt metaBase U w N mem₂
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compTDAt_congr {metaBase U w N : ℕ} (hw : 0 < w) {mem₁ mem₂ : ℕ → ℕ} (h : ∀ (addr : ℕ), metaBase + offTailToDense U w N ≤ addr ∧ addr < metaBase + offDenseToTail U w N → mem₁ addr = mem₂ addr) :
compTDAt metaBase U w N mem₁ = compTDAt metaBase U w N mem₂
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compDTAt_congr {metaBase U w N : ℕ} (hw : 0 < w) {mem₁ mem₂ : ℕ → ℕ} (h : ∀ (addr : ℕ), metaBase + offDenseToTail U w N ≤ addr ∧ addr < metaBase + offCompItems U w N → mem₁ addr = mem₂ addr) :
compDTAt metaBase U w N mem₁ = compDTAt metaBase U w N mem₂
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.writeCompLM_effect {metaBase itemBase U V w N m_items idx val : ℕ} (c : Fin 9) (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (hidx : idx < SuccinctBucket.totalMicroBuckets N) (hval : val < 2 ^ SuccinctBucket.effBucketPosBits N) (mem : ℕ → ℕ) :
have mem' := BitPackedArray.writePacked (metaBase + offCompLMSub U w N ↑c) (SuccinctBucket.effBucketPosBits N) w mem idx val; compLmAt metaBase U w N mem' = Function.update (compLmAt metaBase U w N mem) (↑c, idx) val ∧ compGmAt metaBase U w N mem' = compGmAt metaBase U w N mem ∧ compTDAt metaBase U w N mem' = compTDAt metaBase U w N mem ∧ compDTAt metaBase U w N mem' = compDTAt metaBase U w N mem ∧ compQuotAt itemBase U V w N m_items mem' = compQuotAt itemBase U V w N m_items mem ∧ compValAt itemBase U V w N m_items mem' = compValAt itemBase U V w N m_items mem ∧ ∀ (a : ℕ), ¬(metaBase + offCompLM U w N ≤ a ∧ a < metaBase + offCompGM U w N) → mem' a = mem a

Updating LocalMeta[c, idx] := val updates compLmAt via Function.update and preserves all other metadata views, dense item views (metaBase + offCompItems ≤ itemBase), and outside memory.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.writeCompGM_effect {metaBase itemBase U V w N m_items idx val : ℕ} (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (hidx : idx < SuccinctBucket.globalMetaLen N) (hval : val < 2 ^ SuccinctBucket.globalPtrBits N) (mem : ℕ → ℕ) :
have mem' := BitPackedArray.writePacked (metaBase + offCompGM U w N) (SuccinctBucket.globalPtrBits N) w mem idx val; compGmAt metaBase U w N mem' = Function.update (compGmAt metaBase U w N mem) idx val ∧ compLmAt metaBase U w N mem' = compLmAt metaBase U w N mem ∧ compTDAt metaBase U w N mem' = compTDAt metaBase U w N mem ∧ compDTAt metaBase U w N mem' = compDTAt metaBase U w N mem ∧ compQuotAt itemBase U V w N m_items mem' = compQuotAt itemBase U V w N m_items mem ∧ compValAt itemBase U V w N m_items mem' = compValAt itemBase U V w N m_items mem ∧ ∀ (a : ℕ), ¬(metaBase + offCompGM U w N ≤ a ∧ a < metaBase + offTailToDense U w N) → mem' a = mem a

Updating GlobalMeta[idx] := val updates compGmAt via Function.update and preserves all other views and outside memory.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.writeCompTD_effect {metaBase itemBase U V w N m_items t val : ℕ} (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (ht : t < SuccinctBucket.maxTailItems N) (hval : val < 2 ^ SuccinctBucket.globalPtrBits N) (mem : ℕ → ℕ) :
have mem' := BitPackedArray.writePacked (metaBase + offTailToDense U w N) (SuccinctBucket.globalPtrBits N) w mem t val; compTDAt metaBase U w N mem' = Function.update (compTDAt metaBase U w N mem) t val ∧ compLmAt metaBase U w N mem' = compLmAt metaBase U w N mem ∧ compGmAt metaBase U w N mem' = compGmAt metaBase U w N mem ∧ compDTAt metaBase U w N mem' = compDTAt metaBase U w N mem ∧ compQuotAt itemBase U V w N m_items mem' = compQuotAt itemBase U V w N m_items mem ∧ compValAt itemBase U V w N m_items mem' = compValAt itemBase U V w N m_items mem ∧ ∀ (a : ℕ), ¬(metaBase + offTailToDense U w N ≤ a ∧ a < metaBase + offDenseToTail U w N) → mem' a = mem a

Updating TailToDense[t] := val updates compTDAt via Function.update and preserves all other views and outside memory.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.writeCompDT_effect {metaBase itemBase U V w N m_items r val : ℕ} (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (hr : r < SuccinctBucket.maxTailItems N) (hval : val < 2 ^ SuccinctBucket.globalPtrBits N) (mem : ℕ → ℕ) :
have mem' := BitPackedArray.writePacked (metaBase + offDenseToTail U w N) (SuccinctBucket.globalPtrBits N) w mem r val; compDTAt metaBase U w N mem' = Function.update (compDTAt metaBase U w N mem) r val ∧ compLmAt metaBase U w N mem' = compLmAt metaBase U w N mem ∧ compGmAt metaBase U w N mem' = compGmAt metaBase U w N mem ∧ compTDAt metaBase U w N mem' = compTDAt metaBase U w N mem ∧ compQuotAt itemBase U V w N m_items mem' = compQuotAt itemBase U V w N m_items mem ∧ compValAt itemBase U V w N m_items mem' = compValAt itemBase U V w N m_items mem ∧ ∀ (a : ℕ), ¬(metaBase + offDenseToTail U w N ≤ a ∧ a < metaBase + offCompItems U w N) → mem' a = mem a

Updating DenseToTail[r] := val updates compDTAt via Function.update and preserves all other views and outside memory.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.writeCompQuot_meta_frame {metaBase itemBase U V w N m_items d q : ℕ} (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (hd : d < m_items) (mem : ℕ → ℕ) :
have mem' := writeCompQuot itemBase U V w N mem d q; compLmAt metaBase U w N mem' = compLmAt metaBase U w N mem ∧ compGmAt metaBase U w N mem' = compGmAt metaBase U w N mem ∧ compTDAt metaBase U w N mem' = compTDAt metaBase U w N mem ∧ compDTAt metaBase U w N mem' = compDTAt metaBase U w N mem

Writing a dense quotient at itemBase (metaBase + offCompItems ≤ itemBase) preserves all metadata views at metaBase.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.writeCompVal_meta_frame {metaBase itemBase U V w N m_items d v : ℕ} (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (hd : d < m_items) (mem : ℕ → ℕ) :
have mem' := writeCompVal itemBase U V w N mem d v; compLmAt metaBase U w N mem' = compLmAt metaBase U w N mem ∧ compGmAt metaBase U w N mem' = compGmAt metaBase U w N mem ∧ compTDAt metaBase U w N mem' = compTDAt metaBase U w N mem ∧ compDTAt metaBase U w N mem' = compDTAt metaBase U w N mem

Writing a dense value at itemBase (metaBase + offCompItems ≤ itemBase) preserves all metadata views at metaBase.

Section 2: Circular-Window State-Transition Specifications #

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.winGrowRightGenProg_effect {metaBase itemBase U V w N m_items b_win n_win : ℕ} (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (hn : n_win < SuccinctBucket.maxTailItems N) (s : Memory.State) :
have s' := (Memory.spec 0).clientState s (winGrowRightGenProg ((mkCompParams U V w N, metaBase), b_win, n_win)); s'.frontier = s.frontier ∧ compTDAt metaBase U w N s'.mem = (winGrowRight (SuccinctBucket.maxTailItems N) b_win n_win (compTDAt metaBase U w N s.mem, compDTAt metaBase U w N s.mem)).1 ∧ compDTAt metaBase U w N s'.mem = (winGrowRight (SuccinctBucket.maxTailItems N) b_win n_win (compTDAt metaBase U w N s.mem, compDTAt metaBase U w N s.mem)).2 ∧ compLmAt metaBase U w N s'.mem = compLmAt metaBase U w N s.mem ∧ compGmAt metaBase U w N s'.mem = compGmAt metaBase U w N s.mem ∧ compQuotAt itemBase U V w N m_items s'.mem = compQuotAt itemBase U V w N m_items s.mem ∧ compValAt itemBase U V w N m_items s'.mem = compValAt itemBase U V w N m_items s.mem ∧ ∀ (a : ℕ), ¬(metaBase + offTailToDense U w N ≤ a ∧ a < metaBase + offCompItems U w N) → s'.mem a = s.mem a
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.winGrowLeftGenProg_effect {metaBase itemBase U V w N m_items b_win n_win : ℕ} (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (hn : n_win < SuccinctBucket.maxTailItems N) (s : Memory.State) :
have s' := (Memory.spec 0).clientState s (winGrowLeftGenProg ((mkCompParams U V w N, metaBase), b_win, n_win)); s'.frontier = s.frontier ∧ compTDAt metaBase U w N s'.mem = (winGrowLeft (SuccinctBucket.maxTailItems N) b_win n_win (compTDAt metaBase U w N s.mem, compDTAt metaBase U w N s.mem)).1 ∧ compDTAt metaBase U w N s'.mem = (winGrowLeft (SuccinctBucket.maxTailItems N) b_win n_win (compTDAt metaBase U w N s.mem, compDTAt metaBase U w N s.mem)).2 ∧ compLmAt metaBase U w N s'.mem = compLmAt metaBase U w N s.mem ∧ compGmAt metaBase U w N s'.mem = compGmAt metaBase U w N s.mem ∧ compQuotAt itemBase U V w N m_items s'.mem = compQuotAt itemBase U V w N m_items s.mem ∧ compValAt itemBase U V w N m_items s'.mem = compValAt itemBase U V w N m_items s.mem ∧ ∀ (a : ℕ), ¬(metaBase + offTailToDense U w N ≤ a ∧ a < metaBase + offCompItems U w N) → s'.mem a = s.mem a
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.winShrinkRightGenProg_effect {metaBase itemBase U V w N m_items b_win n_win : ℕ} (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (hn : n_win < SuccinctBucket.maxTailItems N) (s : Memory.State) (hdt_lt : compDTAt metaBase U w N s.mem ((b_win + n_win) % SuccinctBucket.maxTailItems N) < SuccinctBucket.maxTailItems N) (htd_lt : compTDAt metaBase U w N s.mem n_win < SuccinctBucket.maxTailItems N) :
have s' := (Memory.spec 0).clientState s (winShrinkRightGenProg ((mkCompParams U V w N, metaBase), b_win, n_win)); s'.frontier = s.frontier ∧ compTDAt metaBase U w N s'.mem = (winShrinkRight (SuccinctBucket.maxTailItems N) b_win n_win (compTDAt metaBase U w N s.mem, compDTAt metaBase U w N s.mem)).1 ∧ compDTAt metaBase U w N s'.mem = (winShrinkRight (SuccinctBucket.maxTailItems N) b_win n_win (compTDAt metaBase U w N s.mem, compDTAt metaBase U w N s.mem)).2 ∧ compLmAt metaBase U w N s'.mem = compLmAt metaBase U w N s.mem ∧ compGmAt metaBase U w N s'.mem = compGmAt metaBase U w N s.mem ∧ compQuotAt itemBase U V w N m_items s'.mem = compQuotAt itemBase U V w N m_items s.mem ∧ compValAt itemBase U V w N m_items s'.mem = compValAt itemBase U V w N m_items s.mem ∧ ∀ (a : ℕ), ¬(metaBase + offTailToDense U w N ≤ a ∧ a < metaBase + offCompItems U w N) → s'.mem a = s.mem a
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.winShrinkLeftGenProg_effect {metaBase itemBase U V w N m_items b_win n_win : ℕ} (hw : 0 < w) (hitem : metaBase + offCompItems U w N ≤ itemBase) (hn : n_win < SuccinctBucket.maxTailItems N) (s : Memory.State) (hdt_lt : compDTAt metaBase U w N s.mem (b_win % SuccinctBucket.maxTailItems N) < SuccinctBucket.maxTailItems N) (htd_lt : compTDAt metaBase U w N s.mem n_win < SuccinctBucket.maxTailItems N) :
have s' := (Memory.spec 0).clientState s (winShrinkLeftGenProg ((mkCompParams U V w N, metaBase), b_win, n_win)); s'.frontier = s.frontier ∧ compTDAt metaBase U w N s'.mem = (winShrinkLeft (SuccinctBucket.maxTailItems N) b_win n_win (compTDAt metaBase U w N s.mem, compDTAt metaBase U w N s.mem)).1 ∧ compDTAt metaBase U w N s'.mem = (winShrinkLeft (SuccinctBucket.maxTailItems N) b_win n_win (compTDAt metaBase U w N s.mem, compDTAt metaBase U w N s.mem)).2 ∧ compLmAt metaBase U w N s'.mem = compLmAt metaBase U w N s.mem ∧ compGmAt metaBase U w N s'.mem = compGmAt metaBase U w N s.mem ∧ compQuotAt itemBase U V w N m_items s'.mem = compQuotAt itemBase U V w N m_items s.mem ∧ compValAt itemBase U V w N m_items s'.mem = compValAt itemBase U V w N m_items s.mem ∧ ∀ (a : ℕ), ¬(metaBase + offTailToDense U w N ≤ a ∧ a < metaBase + offCompItems U w N) → s'.mem a = s.mem a

Section 3: Register-Width Bounds (fits_mkCompParams) #

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.fits_of_le_max_N_one {U w N x : ℕ} (hw : 0 < w) (hnU : N ≤ U) (hU : U < 2 ^ w) (hx : x ≤ max N 1) :
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.fits_mkCompParams {U V w N metaBase : ℕ} (hw : 0 < w) (hnU : N ≤ U) (hU : U < 2 ^ w) (hV : V ≤ 2 ^ w) (hfit : WordRAM.Fits w (metaBase + offCompItems U w N)) (i : Fin 36) :

Every entry of mkCompParams U V w N fits in a w-bit word whenever 0 < w, 0 < N, N ≤ U < 2 ^ w, V ≤ 2 ^ w, and Fits w (metaBase + offCompItems U w N).

Section 4: Compacted Slot Resolution, Owner-Bucket Recovery, and Key Reconstruction #

Precondition for reading the count of items in bucket b from compacted metadata.

Recover ownerBucketOfDense N gm dt d in $O(1)$ steps (Memory.Prog, ¬ReadsWidth).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.clientResult_recoverOwnerBucketGenProg {U V w N metaBase d : ℕ} {s : Memory.State} (hslot : Succinct.SlotStoreInv N (compGmAt metaBase U w N s.mem)) (htd : 0 < FeistelQuotient.bucketBits N → TailDenseInv N (compGmAt metaBase U w N s.mem 0) (compGmAt metaBase U w N s.mem 1) (compTDAt metaBase U w N s.mem) (compDTAt metaBase U w N s.mem)) (hd : d < epochTotalSlots N (compGmAt metaBase U w N s.mem)) :
(Memory.spec 0).clientResult s (recoverOwnerBucketGenProg ((mkCompParams U V w N, metaBase), d)) = ownerBucketOfDense N (compGmAt metaBase U w N s.mem) (compDTAt metaBase U w N s.mem) d

Precondition for recovering the owner bucket of dense item d.

noncomputable def Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.reconstructKeyAt (metaBase itemBase U V w N n : ℕ) (θ : Succinct.QuotHashSeed U N) (mem : ℕ → ℕ) (d : ℕ) :

Reconstruct the key u stored at dense index d < n in (metaBase, itemBase).

Section 5: ValidProg w 0 Admissibility for Metadata and Window Primitives #