Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.ResizableSuccinct.Compaction

Circular Tail-to-Dense Compaction Bijection, Key Reconstruction, and CompactedRep #

This module defines the circular tail-to-dense bijection (denseOfCirc, WindowInv, TailDenseInv), direct $O(1)$ owner-bucket and logical-slot recovery on dense slots d ∈ [0, n) (ownerBucketOfDense, logicalIdxOfDense), and the array-coupling invariants (WindowCoupled, FixedCoupled) for the resizable succinct dynamic dictionary of Bender, Farach-Colton, J. Kuszmaul and W. Kuszmaul, SOSA 2024.

Design #

  1. Circular [b_win, b_win + n_win) tail window (denseOfCirc, WindowInv): Active full-slab slots phys < gm 0 * slabSize N map directly to dense index d = phys. Active tail slots phys = N - 1 - t (t < gm 1) store a circular residue c = td t < M (M = maxTailItems N) and resolve to d = denseOfCirc M b_win c ∈ [b_win, b_win + n_win), with inverse dt (d % M) = t. Shifting b_win by ± 1 (winGrowLeft, winShrinkLeft) or resizing n_win by ± 1 (winGrowRight, winShrinkRight) updates only $O(1)$ entries of (td, dt) without reindexing untouched tail items.
  2. Array-level coupling (WindowCoupled, FixedCoupled): WindowCoupled separates metaBase from itemBase so both resting in-epoch states and single-tape epoch migration (Zone 1 metadata + Zone 3 shared item arena) couple directly to the fixed-capacity Succinct array extractors (gmAt, lmAt, quotAt, valAt).

Main definitions #

Main results #

References #

Section 1: Circular Tail-to-Dense Window Bijection (denseOfCirc, WindowInv) #

Recover the unique d ∈ [base_tail, base_tail + M) with d % M = c (for 0 < M, c < M).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.denseOfCirc_mod {M base_tail c : ℕ} (hM : 0 < M) (hc : c < M) :
denseOfCirc M base_tail c % M = c
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.denseOfCirc_mod_self {M base_tail d : ℕ} (hM : 0 < M) (hlo : base_tail ≤ d) (hhi : d < base_tail + M) :
denseOfCirc M base_tail (d % M) = d
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.denseOfCirc_eq_self_iff {M b c d : ℕ} (hM : 0 < M) (hc : c < M) (hlo : b ≤ d) (hhi : d < b + M) :
denseOfCirc M b c = d ↔ c = d % M
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.denseOfCirc_succ_of_ne_mod {M b c : ℕ} (hM : 0 < M) (hc : c < M) (hhi : denseOfCirc M b c < b + M) (hne : c ≠ b % M) :
denseOfCirc M (b + 1) c = denseOfCirc M b c
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.denseOfCirc_pred_of_lt {M b c : ℕ} (hM : 0 < M) (hc : c < M) (hhi : denseOfCirc M (b + 1) c < b + M) :
denseOfCirc M b c = denseOfCirc M (b + 1) c ∧ c ≠ b % M

Circular tail-to-dense bijection invariant on [b, b + n) modulo M.

  • td_lt (t : ℕ) : t < n → td t < M
  • dense_lt (t : ℕ) : t < n → denseOfCirc M b (td t) < b + n
  • dt_td (t : ℕ) : t < n → dt (td t) = t
  • owner_valid (d : ℕ) : b ≤ d → d < b + n → dt (d % M) < n ∧ td (dt (d % M)) = d % M

Specialization of WindowInv to the resting tail window [n_slabs * slabSize N, +n_tails).

Canonical td mapping (b + t) % M for initial / rebuilt epochs.

Canonical dt mapping (c + M - b % M) % M for initial / rebuilt epochs.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.windowInv_canon {M b n : ℕ} (hn : n ≤ M) :
WindowInv M b n (canonTD M b) (canonDT M b) ∧ (∀ (i : ℕ), canonTD M b i < max M 1) ∧ ∀ (i : ℕ), canonDT M b i < max M 1

Map a physical slot phys < N to its dense index d < n: when bucketBits N = 0, phys; else phys on full slabs < gm 0 * slabSize N and denseOfCirc (maxTailItems N) (gm 0 * slabSize N) (td (N - 1 - phys)) on tail slots.

Physical slot of dense item d parameterized by tail window base b_tail.

Resting specialization physByBase N (gm 0 * slabSize N) dt.

Grow the circular window [b, b + n) on the right by 1 to [b, b + (n + 1)).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.winGrowRight_spec {M b n : ℕ} {td dt : ℕ → ℕ} (hw : WindowInv M b n td dt) (hM : n + 1 ≤ M) (htd_b : ∀ (i : ℕ), td i < M) (hdt_b : ∀ (i : ℕ), dt i < M) :
match winGrowRight M b n (td, dt) with | (td', dt') => WindowInv M b (n + 1) td' dt' ∧ (∀ (i : ℕ), td' i < M) ∧ ∀ (i : ℕ), dt' i < M

Grow the circular window [b + 1, b + 1 + n) on the left by 1 to [b, b + (n + 1)).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.winGrowLeft_spec {M b n : ℕ} {td dt : ℕ → ℕ} (hw : WindowInv M (b + 1) n td dt) (hM : n + 1 ≤ M) (htd_b : ∀ (i : ℕ), td i < M) (hdt_b : ∀ (i : ℕ), dt i < M) :
match winGrowLeft M b n (td, dt) with | (td', dt') => WindowInv M b (n + 1) td' dt' ∧ (∀ (i : ℕ), td' i < M) ∧ ∀ (i : ℕ), dt' i < M

Shrink the circular window [b, b + (n + 1)) on the right by 1 to [b, b + n).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.winShrinkRight_spec {M b n : ℕ} {td dt : ℕ → ℕ} (hw : WindowInv M b (n + 1) td dt) (hM : n + 1 ≤ M) (htd_b : ∀ (i : ℕ), td i < M) (hdt_b : ∀ (i : ℕ), dt i < M) :
match winShrinkRight M b n (td, dt) with | (td', dt') => WindowInv M b n td' dt' ∧ (∀ (i : ℕ), td' i < M) ∧ ∀ (i : ℕ), dt' i < M

Shrink the circular window [b, b + (n + 1)) on the left by 1 to [b + 1, b + 1 + n).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.winShrinkLeft_spec {M b n : ℕ} {td dt : ℕ → ℕ} (hw : WindowInv M b (n + 1) td dt) (hM : n + 1 ≤ M) (htd_b : ∀ (i : ℕ), td i < M) (hdt_b : ∀ (i : ℕ), dt i < M) :
match winShrinkLeft M b n (td, dt) with | (td', dt') => WindowInv M (b + 1) n td' dt' ∧ (∀ (i : ℕ), td' i < M) ∧ ∀ (i : ℕ), dt' i < M
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.physByBase_winGrowRight {N b n : ℕ} {td dt : ℕ → ℕ} (hb_pos : 0 < FeistelQuotient.bucketBits N) (hM : n + 1 ≤ SuccinctBucket.maxTailItems N) :
match winGrowRight (SuccinctBucket.maxTailItems N) b n (td, dt) with | (fst, dt') => physByBase N b dt' (b + n) = N - 1 - n ∧ ∀ d < b + n, physByBase N b dt' d = physByBase N b dt d
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.physByBase_winGrowLeft {N b n : ℕ} {td dt : ℕ → ℕ} (hb_pos : 0 < FeistelQuotient.bucketBits N) (hM : n + 1 ≤ SuccinctBucket.maxTailItems N) :
match winGrowLeft (SuccinctBucket.maxTailItems N) b n (td, dt) with | (fst, dt') => physByBase N b dt' b = N - 1 - n ∧ ∀ d < b + 1 + n, d ≠ b → physByBase N b dt' d = physByBase N (b + 1) dt d
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.physByBase_winShrinkRight {N b n : ℕ} {td dt : ℕ → ℕ} (hb_pos : 0 < FeistelQuotient.bucketBits N) (hw : WindowInv (SuccinctBucket.maxTailItems N) b (n + 1) td dt) (hM : n + 1 ≤ SuccinctBucket.maxTailItems N) :
match winShrinkRight (SuccinctBucket.maxTailItems N) b n (td, dt) with | (fst, dt') => have d_last := denseOfCirc (SuccinctBucket.maxTailItems N) b (td n); d_last < b + n + 1 ∧ physByBase N b dt' d_last = physByBase N b dt (b + n) ∧ ∀ d < b + n, d ≠ d_last → physByBase N b dt' d = physByBase N b dt d
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.physByBase_winShrinkLeft {N b n : ℕ} {td dt : ℕ → ℕ} (hb_pos : 0 < FeistelQuotient.bucketBits N) (hw : WindowInv (SuccinctBucket.maxTailItems N) b (n + 1) td dt) (hM : n + 1 ≤ SuccinctBucket.maxTailItems N) :
match winShrinkLeft (SuccinctBucket.maxTailItems N) b n (td, dt) with | (fst, dt') => have d_last := denseOfCirc (SuccinctBucket.maxTailItems N) b (td n); b ≤ d_last ∧ d_last < b + n + 1 ∧ (b < d_last → physByBase N (b + 1) dt' d_last = N - 1 - dt (b % SuccinctBucket.maxTailItems N)) ∧ ∀ d < b + 1 + n, d ≠ b → d ≠ d_last → physByBase N (b + 1) dt' d = physByBase N b dt d

Section 2: Direct $O(1)$ Bucket-Owner and Logical-Slot Inversion on Dense Indices #

Recover the owning Feistel bucket b < numBuckets N of dense index d < totalSlots N gm from GlobalMeta (gm) and DenseToTail (dt).

Recover the logical within-bucket slot index j < bCount N gm b of dense index d.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.physOfDense_denseOfPhys_tail {N : ℕ} {gm td dt : ℕ → ℕ} (htd : TailDenseInv N (gm 0) (gm 1) td dt) (hb : 0 < FeistelQuotient.bucketBits N) (hSN : gm 0 * SuccinctBucket.slabSize N + gm 1 ≤ N) {t : ℕ} (ht : t < gm 1) :
physOfDense N gm dt (denseOfPhys N gm td (N - 1 - t)) = N - 1 - t
@[reducible, inline]

Active slot count (= Succinct.totalSlots N gm).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.ownerBucketOfDense_lt_and_slotOf {N : ℕ} {gm td dt : ℕ → ℕ} (hslot : Succinct.SlotStoreInv N gm) (htd : 0 < FeistelQuotient.bucketBits N → TailDenseInv N (gm 0) (gm 1) td dt) {d : ℕ} (hd : d < epochTotalSlots N gm) :
have b := ownerBucketOfDense N gm dt d; have j := logicalIdxOfDense N gm dt d; b < FeistelQuotient.numBuckets N ∧ j < Succinct.bCount N gm b ∧ denseOfPhys N gm td (Succinct.slotOf N gm b j) = d

Under SlotStoreInv N gm and TailDenseInv N (gm 0) (gm 1) td dt, every dense index d < epochTotalSlots N gm maps via (ownerBucketOfDense, logicalIdxOfDense) to a valid active bucket slot (b, j) with denseOfPhys N gm td (slotOf N gm b j) = d.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.physOfDense_denseOfPhys_slotOf {N : ℕ} {gm td dt : ℕ → ℕ} (hslot : Succinct.SlotStoreInv N gm) (htd : 0 < FeistelQuotient.bucketBits N → TailDenseInv N (gm 0) (gm 1) td dt) {b j : ℕ} (hb : b < FeistelQuotient.numBuckets N) (hj : j < Succinct.bCount N gm b) :
physOfDense N gm dt (denseOfPhys N gm td (Succinct.slotOf N gm b j)) = Succinct.slotOf N gm b j
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.denseOfPhys_slotOf_lt_and_inv {N : ℕ} {gm td dt : ℕ → ℕ} (hslot : Succinct.SlotStoreInv N gm) (htd : 0 < FeistelQuotient.bucketBits N → TailDenseInv N (gm 0) (gm 1) td dt) {b j : ℕ} (hb : b < FeistelQuotient.numBuckets N) (hj : j < Succinct.bCount N gm b) :
have d := denseOfPhys N gm td (Succinct.slotOf N gm b j); d < epochTotalSlots N gm ∧ ownerBucketOfDense N gm dt d = b ∧ logicalIdxOfDense N gm dt d = j

Section 3: Fixed-Capacity Array Coupling Invariants (WindowCoupled, FixedCoupled) #

Ghost word width w + 16 used for the mathematical fixed-capacity reference state s_fix, ensuring Fits (ghostW w) (Succinct.space U V (ghostW w) N) for all N ≤ U ≤ 2 ^ w.

structure Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.WindowCoupled (metaBase itemBase U V w N b_win n_win m_items : ℕ) (s_fix s : Memory.State) :

Coupling invariant between a fixed-capacity state s_fix (at base = 0, ghostW w) and a compacted state s at (metaBase, itemBase) over window [b_win, b_win + n_win).

Resting window coupling (b_win = gm 0 * slabSize N, and n_win = gm 1 when 0 < bucketBits N).