Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctSlotInv

Slab/Tail Slot-Store Invariant for Succinct Dictionaries #

This module defines the GlobalMeta index map, the logical-to-physical slot mapping slotOf, the table hysteresis potential slotPotential, and the bijection invariants (TailBijection, SlabBijection, SlotStoreInv) governing physical slot allocation in the fixed-capacity succinct dictionary.

Main definitions #

Main results #

GlobalMeta layout, SlotStoreInv, and physical slot injectivity #

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.max_n_one_lt_two_pow_w {w U n_max : ℕ} (hw : 0 < w) (hnU : n_max ≤ U) (hU : U < 2 ^ w) :
WordRAM.Fits w (max n_max 1)

GlobalMeta index 4 + 3 * b holding q_b (number of full slabs in bucket b).

GlobalMeta index 4 + 3 * b + 1 holding r_b (number of tail items in bucket b).

GlobalMeta index 4 + 3 * b + 2 holding slabTop_b (physical slab index of the top slab s = q_b - 1 of bucket b).

Base index 4 + 3 * numBuckets n_max of the slabDir table in GlobalMeta.

GlobalMeta index of slabDir(b, s) (s < dirSlabsPerBucket n_max).

Base index of the tailPtr table in GlobalMeta.

GlobalMeta index of flat tail descriptor d < maxTailItems n_max.

GlobalMeta index of tailPtr(b, r) (r < tailCapPerBucket n_max).

Base index of the tailOwner table in GlobalMeta.

GlobalMeta index of tailOwner(t) (t < maxTailItems n_max).

Base index of the per-physical-slab metadata table in GlobalMeta.

GlobalMeta index of slabOwnerB(p) (p < maxFullSlabs n_max).

GlobalMeta index of slabOwnerS(p) (p < maxFullSlabs n_max).

GlobalMeta index of slabBelow(p) (p < maxFullSlabs n_max).

GlobalMeta index of slabAbove(p) (p < maxFullSlabs n_max).

The flat tail descriptor b * tailCapPerBucket n_max + r of a bucket b < numBuckets n_max and a position r < tailCapPerBucket n_max indexes the maxTailItems n_max tail tables.

Number of items currently stored in bucket b according to gm : ℕ → ℕ.

Physical slab p < gm 0 owned by (b, s) in gm.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.slabPtrOf_congr {n_max : ℕ} {gm₁ gm₂ : ℕ → ℕ} (h0 : gm₁ 0 = gm₂ 0) (hB : ∀ p < gm₁ 0, gm₁ (gmSlabOwnerBIdx n_max p) = gm₂ (gmSlabOwnerBIdx n_max p)) (hS : ∀ p < gm₁ 0, gm₁ (gmSlabOwnerSIdx n_max p) = gm₂ (gmSlabOwnerSIdx n_max p)) (b s : ℕ) :
slabPtrOf n_max gm₁ b s = slabPtrOf n_max gm₂ b s
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.slabPtrOf_eq_of_owner {n_max : ℕ} {gm : ℕ → ℕ} {b s p : ℕ} (hp : p < gm 0) (hB : gm (gmSlabOwnerBIdx n_max p) = b) (hS : gm (gmSlabOwnerSIdx n_max p) = s) (hinj : ∀ p₁ < gm 0, ∀ p₂ < gm 0, gm (gmSlabOwnerBIdx n_max p₁) = gm (gmSlabOwnerBIdx n_max p₂) → gm (gmSlabOwnerSIdx n_max p₁) = gm (gmSlabOwnerSIdx n_max p₂) → p₁ = p₂) :
slabPtrOf n_max gm b s = p

Physical slot g < n_max of logical bucket index j in bucket b. Within full slabs, intra-slab offsets are reversed (slabSize n_max - 1 - j % slabSize n_max) so that the K-step slab promotion and demotion loops preserve disjointness of active slab and tail slots at every intermediate step even when gm 0 * slabSize n_max + gm 1 = n_max.

structure Cslib.DataStructure.Dictionary.WordRAM.Succinct.TailBijection (n_max : ℕ) (gm r_fn : ℕ → ℕ) (n_tails : ℕ) :

Flat 1-D bijection between active tail descriptors d = b * tailCapPerBucket n_max + r (b < numBuckets n_max, r < r_fn b) and physical tail offsets 0 .. n_tails - 1.

structure Cslib.DataStructure.Dictionary.WordRAM.Succinct.SlabBijection (n_max : ℕ) (gm q_fn : ℕ → ℕ) (n_slabs : ℕ) :

Pointwise algebraic bijection between active logical slabs (b, s) (b < numBuckets n_max, s < q_fn b) and physical slabs 0 .. n_slabs - 1.

Full invariant of the slab/tail slot store in GlobalMeta.

Potential function ∑_{b < numBuckets n_max} bucketPotential (slabSize n_max) q_b r_b controlling amortized slab promotions and demotions (0 in the single-bucket regime), where for K = slabSize n_max, q_b = gm (gmQIdx b), and r_b = gm (gmRIdx b), each per-bucket term is r_b - K if K ≤ r_b, K - r_b if 0 < q_b ∧ r_b < K, and 0 when q_b = 0 ∧ r_b < K.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.slotStoreInv_of_zero (n_max : ℕ) {gm : ℕ → ℕ} (hzero : ∀ (i : ℕ), gm i = 0) :
SlotStoreInv n_max gm ∧ (∀ (b : ℕ), bCount n_max gm b = 0) ∧ slotPotential n_max gm = 0

An all-zero GlobalMeta array satisfies SlotStoreInv with bCount = 0 and slotPotential = 0.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.slotOf_lt_and_injective {n_max : ℕ} {gm : ℕ → ℕ} (hinv : SlotStoreInv n_max gm) :
(∀ b < FeistelQuotient.numBuckets n_max, ∀ j < bCount n_max gm b, slotOf n_max gm b j < n_max) ∧ ∀ b₁ < FeistelQuotient.numBuckets n_max, ∀ j₁ < bCount n_max gm b₁, ∀ b₂ < FeistelQuotient.numBuckets n_max, ∀ j₂ < bCount n_max gm b₂, slotOf n_max gm b₁ j₁ = slotOf n_max gm b₂ j₂ → b₁ = b₂ ∧ j₁ = j₂

Key slot-store theorem: under SlotStoreInv n_max gm, every logical slot (b, j) with b < numBuckets n_max and j < bCount n_max gm b maps to a valid physical slot slotOf n_max gm b j < n_max, and slotOf n_max gm is injective across all active (b, j).

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.r_le_ntails_of_tailBijection {n_max : ℕ} {gm r_fn : ℕ → ℕ} {n_tails : ℕ} (htail : TailBijection n_max gm r_fn n_tails) {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) :
r_fn b ≤ n_tails
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.TailBijection.owner_lt_maxTailItems {n_max : ℕ} {gm r_fn : ℕ → ℕ} {n_tails : ℕ} (htail : TailBijection n_max gm r_fn n_tails) {t : ℕ} (ht : t < n_tails) :

The flat descriptor owning an active tail offset t < n_tails is a valid index into the tail tables.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.TailBijection.congr {n_max : ℕ} {gm gm' r_fn r_fn' : ℕ → ℕ} {n_tails : ℕ} (htail : TailBijection n_max gm r_fn n_tails) (h1 : gm' 1 = gm 1) (hr_fn : ∀ b < FeistelQuotient.numBuckets n_max, r_fn' b = r_fn b) (hmeta : ∀ (idx : ℕ), gmTailPtrBase n_max ≤ idx → idx < gmSlabMetaBase n_max → gm' idx = gm idx) :
TailBijection n_max gm' r_fn' (gm' 1)

TailBijection reads gm only through the tail count gm 1, the per-bucket tail lengths r_fn, and the tailPtr/tailOwner tables, so it transfers to any gm' agreeing with gm there.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.q_le_nslabs_of_slabBijection {n_max : ℕ} {gm q_fn : ℕ → ℕ} {n_slabs : ℕ} (hslab : SlabBijection n_max gm q_fn n_slabs) {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) :
q_fn b ≤ n_slabs
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.slabPtrOf_congr_of_slabMeta {n_max : ℕ} {gm gm' : ℕ → ℕ} (h0 : gm' 0 = gm 0) (hmeta : ∀ (idx : ℕ), gmSlabMetaBase n_max ≤ idx → gm' idx = gm idx) (b s : ℕ) :
slabPtrOf n_max gm' b s = slabPtrOf n_max gm b s

slabPtrOf reads gm only through the slab count gm 0 and the per-slab metadata above gmSlabMetaBase n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.SlabBijection.congr {n_max : ℕ} {gm gm' q_fn q_fn' : ℕ → ℕ} {n_slabs : ℕ} (hslab : SlabBijection n_max gm q_fn n_slabs) (h0 : gm' 0 = gm 0) (hq_fn : ∀ b < FeistelQuotient.numBuckets n_max, q_fn' b = q_fn b) (htop : ∀ b < FeistelQuotient.numBuckets n_max, gm' (gmSlabTopIdx b) = gm (gmSlabTopIdx b)) (hdir : ∀ b < FeistelQuotient.numBuckets n_max, ∀ s < SuccinctBucket.dirSlabsPerBucket n_max, gm' (gmSlabDirIdx n_max b s) = gm (gmSlabDirIdx n_max b s)) (hmeta : ∀ (idx : ℕ), gmSlabMetaBase n_max ≤ idx → gm' idx = gm idx) :
SlabBijection n_max gm' q_fn' (gm' 0)

SlabBijection reads gm only through the slab count gm 0, the per-bucket slab counts q_fn, the slabTop/slabDir entries, and the per-slab metadata above gmSlabMetaBase n_max, so it transfers to any gm' agreeing with gm there.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.bCount_le_n_max {n_max : ℕ} {gm : ℕ → ℕ} (hinv : SlotStoreInv n_max gm) (b : ℕ) :
bCount n_max gm b ≤ n_max
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.SlabBijection.ptr_lt_maxFullSlabs {n_max : ℕ} {gm q_fn : ℕ → ℕ} {n_slabs : ℕ} (hslab : SlabBijection n_max gm q_fn n_slabs) {b s : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) (hs : s < q_fn b) :

The physical slab holding an active logical slab is below the slab-pool capacity.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.SlabBijection.top_lt {n_max : ℕ} {gm q_fn : ℕ → ℕ} {n_slabs : ℕ} (hslab : SlabBijection n_max gm q_fn n_slabs) {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) (hq : 0 < q_fn b) :
gm (gmSlabTopIdx b) < n_slabs

The top slab of a bucket with at least one full slab is an active physical slab.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.SlotStoreInv.tailOffset_lt {n_max : ℕ} {gm : ℕ → ℕ} (hinv : SlotStoreInv n_max gm) (hb_pos : 0 < FeistelQuotient.bucketBits n_max) {b j : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) (hj_bc : j < bCount n_max gm b) (hj_tail : ¬j < gm (gmQIdx b) * SuccinctBucket.slabSize n_max) :

An item index j past the full slabs of bucket b but below bCount lies in the bucket's tail: its tail offset is below the tail length and hence below the per-bucket tail capacity.