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 #
Cslib.DataStructure.Dictionary.WordRAM.Succinct.gmQIdx,gmRIdx,gmSlabTopIdx,gmSlabDirBase,gmSlabDirIdx,gmTailPtrBase,gmTailPtrFlatIdx,gmTailPtrIdx,gmTailOwnerBase,gmTailOwnerIdx,gmSlabMetaBase,gmSlabOwnerBIdx,gmSlabOwnerSIdx,gmSlabBelowIdx,gmSlabAboveIdx: index map of per-bucket, per-tail, and per-slab fields insideGlobalMeta.Cslib.DataStructure.Dictionary.WordRAM.Succinct.bCount,slabPtrOf,slotOf: bucket item count, physical slab lookup, and logical-to-physical slot map(b, j) ↦ g < n_max.Cslib.DataStructure.Dictionary.WordRAM.Succinct.TailBijection,SlabBijection,SlotStoreInv: bijection invariants for the tail pool, full-slab pool, and overallGlobalMetaslot store.Cslib.DataStructure.Dictionary.WordRAM.Succinct.slotPotential: table-wide hysteresis potential∑_{b < numBuckets n_max} bucketPotential (slabSize n_max) (gm (gmQIdx b)) (gm (gmRIdx b)).
Main results #
slotStoreInv_of_zero: an all-zeroGlobalMetaarray satisfiesSlotStoreInvwithbCount = 0andslotPotential = 0.slotOf_lt_and_injective: underSlotStoreInv,slotOfmaps every active(b, j)into[0, n_max)and is injective across all active(b, j).bCount_le_n_max: underSlotStoreInv, every bucket contains at mostn_maxitems.
GlobalMeta layout, SlotStoreInv, and physical slot injectivity #
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.
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.
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.
- ntails_eq : gm 1 = n_tails
- ntails_le : n_tails ≤ SuccinctBucket.maxTailItems n_max
- r_le (b : ℕ) : b < FeistelQuotient.numBuckets n_max → r_fn b ≤ SuccinctBucket.tailCapPerBucket n_max
- ptr_lt (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ r < r_fn b, gm (gmTailPtrIdx n_max b r) < n_tails
- owner_ptr (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ r < r_fn b, gm (gmTailOwnerIdx n_max (gm (gmTailPtrIdx n_max b r))) = b * SuccinctBucket.tailCapPerBucket n_max + r
- owner_valid (t : ℕ) : t < n_tails → let d := gm (gmTailOwnerIdx n_max t); d / SuccinctBucket.tailCapPerBucket n_max < FeistelQuotient.numBuckets n_max ∧ d % SuccinctBucket.tailCapPerBucket n_max < r_fn (d / SuccinctBucket.tailCapPerBucket n_max) ∧ gm (gmTailPtrFlatIdx n_max d) = t
Pointwise algebraic bijection between active logical slabs (b, s) (b < numBuckets n_max,
s < q_fn b) and physical slabs 0 .. n_slabs - 1.
- nslabs_eq : gm 0 = n_slabs
- nslabs_le : n_slabs ≤ SuccinctBucket.maxFullSlabs n_max
- ptr_lt (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ s < q_fn b, slabPtrOf n_max gm b s < n_slabs
- ownerB_ptr (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ s < q_fn b, gm (gmSlabOwnerBIdx n_max (slabPtrOf n_max gm b s)) = b
- ownerS_ptr (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ s < q_fn b, gm (gmSlabOwnerSIdx n_max (slabPtrOf n_max gm b s)) = s
- owner_valid (p : ℕ) : p < n_slabs → let b := gm (gmSlabOwnerBIdx n_max p); let s := gm (gmSlabOwnerSIdx n_max p); b < FeistelQuotient.numBuckets n_max ∧ s < q_fn b ∧ slabPtrOf n_max gm b s = p
- dir_eq (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ s < q_fn b, s < SuccinctBucket.dirSlabsPerBucket n_max → gm (gmSlabDirIdx n_max b s) = slabPtrOf n_max gm b s
- top_eq (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ s < q_fn b, s + 1 = q_fn b → gm (gmSlabTopIdx b) = slabPtrOf n_max gm b s
- below_eq (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ s < q_fn b, 0 < s → gm (gmSlabBelowIdx n_max (slabPtrOf n_max gm b s)) = slabPtrOf n_max gm b (s - 1)
- above_eq (b : ℕ) : b < FeistelQuotient.numBuckets n_max → ∀ s < q_fn b, s + 1 < q_fn b → gm (gmSlabAboveIdx n_max (slabPtrOf n_max gm b s)) = slabPtrOf n_max gm b (s + 1)
Full invariant of the slab/tail slot store in GlobalMeta.
- multi_tail : 0 < FeistelQuotient.bucketBits n_max → TailBijection n_max gm (fun (b : ℕ) => gm (gmRIdx b)) (gm 1)
- multi_slab : 0 < FeistelQuotient.bucketBits n_max → SlabBijection n_max gm (fun (b : ℕ) => gm (gmQIdx b)) (gm 0)
- multi_r_bounds : 0 < FeistelQuotient.bucketBits n_max → ∀ b < FeistelQuotient.numBuckets n_max, gm (gmRIdx b) < SuccinctBucket.tailCapPerBucket n_max ∧ (0 < gm (gmQIdx b) → 1 ≤ gm (gmRIdx b))
- multi_total_le : 0 < FeistelQuotient.bucketBits n_max → gm 0 * SuccinctBucket.slabSize n_max + gm 1 ≤ n_max
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.
An all-zero GlobalMeta array satisfies SlotStoreInv with bCount = 0 and
slotPotential = 0.
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).
The flat descriptor owning an active tail offset t < n_tails is a valid index into the tail
tables.
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.
slabPtrOf reads gm only through the slab count gm 0 and the per-slab metadata above
gmSlabMetaBase n_max.
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.
The physical slab holding an active logical slab is below the slab-pool capacity.
The top slab of a bucket with at least one full slab is an active physical slab.
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.