Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctSlabBijection

Pure Slab Bijection Preservation (gmPushSlab, gmPopSlab) #

This module defines the pure GlobalMeta slab-stack updates (gmPushSlab, gmUnlinkTopSlab, gmCompactSlab, gmPopSlab) and proves that they preserve SlabBijection and TailBijection when promoting or demoting a full slab of K = slabSize n_max items.

Main definitions #

Main results #

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.slabPtrOf_inj {n_max : ℕ} {gm q_fn : ℕ → ℕ} {n_slabs : ℕ} (hslab : SlabBijection n_max gm q_fn n_slabs) {b₁ : ℕ} (hb₁ : b₁ < FeistelQuotient.numBuckets n_max) {s₁ : ℕ} (hs₁ : s₁ < q_fn b₁) {b₂ : ℕ} (hb₂ : b₂ < FeistelQuotient.numBuckets n_max) {s₂ : ℕ} (hs₂ : s₂ < q_fn b₂) (heq : slabPtrOf n_max gm b₁ s₁ = slabPtrOf n_max gm b₂ s₂) :
b₁ = b₂ ∧ s₁ = s₂

Section 1: Pure gmPushSlab and SlabBijection preservation #

Pure GlobalMeta update allocating a new full slab p_new = gm 0 as the new top slab s_new = gm (gmQIdx b) of bucket b.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.gmPushSlab_fields {n_max : ℕ} (gm : ℕ → ℕ) {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) :
gmPushSlab n_max gm b 0 = gm 0 + 1 ∧ gmPushSlab n_max gm b 1 = gm 1 ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmPushSlab n_max gm b (gmRIdx b') = gm (gmRIdx b')) ∧ (∀ (idx : ℕ), gmTailPtrBase n_max ≤ idx → idx < gmSlabMetaBase n_max → gmPushSlab n_max gm b idx = gm idx) ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmPushSlab n_max gm b (gmQIdx b') = if b' = b then gm (gmQIdx b) + 1 else gm (gmQIdx b')) ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmPushSlab n_max gm b (gmSlabTopIdx b') = if b' = b then gm 0 else gm (gmSlabTopIdx b')) ∧ (∀ b' < FeistelQuotient.numBuckets n_max, ∀ s < SuccinctBucket.dirSlabsPerBucket n_max, gmPushSlab n_max gm b (gmSlabDirIdx n_max b' s) = if b' = b ∧ s = gm (gmQIdx b) then gm 0 else gm (gmSlabDirIdx n_max b' s)) ∧ (∀ (p : ℕ), gmPushSlab n_max gm b (gmSlabOwnerBIdx n_max p) = if p = gm 0 then b else gm (gmSlabOwnerBIdx n_max p)) ∧ (∀ (p : ℕ), gmPushSlab n_max gm b (gmSlabOwnerSIdx n_max p) = if p = gm 0 then gm (gmQIdx b) else gm (gmSlabOwnerSIdx n_max p)) ∧ (∀ (p : ℕ), gmPushSlab n_max gm b (gmSlabBelowIdx n_max p) = if p = gm 0 then gm (gmSlabTopIdx b) else gm (gmSlabBelowIdx n_max p)) ∧ ∀ (p : ℕ), gmPushSlab n_max gm b (gmSlabAboveIdx n_max p) = if 0 < gm (gmQIdx b) ∧ p = gm (gmSlabTopIdx b) then gm 0 else gm (gmSlabAboveIdx n_max p)

Field-by-field description of gmPushSlab across all GlobalMeta sub-arrays.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.tailBijection_gmPushSlab {n_max : ℕ} {gm : ℕ → ℕ} {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) (htail : TailBijection n_max gm (fun (b' : ℕ) => gm (gmRIdx b')) (gm 1)) :
TailBijection n_max (gmPushSlab n_max gm b) (fun (b' : ℕ) => gmPushSlab n_max gm b (gmRIdx b')) (gmPushSlab n_max gm b 1)

gmPushSlab preserves TailBijection.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.slabBijection_gmPushSlab {n_max : ℕ} {gm : ℕ → ℕ} {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) (hp_lt : gm 0 < SuccinctBucket.maxFullSlabs n_max) (hslab : SlabBijection n_max gm (fun (b' : ℕ) => gm (gmQIdx b')) (gm 0)) :
have gm' := gmPushSlab n_max gm b; (∀ b' < FeistelQuotient.numBuckets n_max, ∀ s < gm' (gmQIdx b'), slabPtrOf n_max gm' b' s = if b' = b ∧ s = gm (gmQIdx b) then gm 0 else slabPtrOf n_max gm b' s) ∧ SlabBijection n_max gm' (fun (b' : ℕ) => gm' (gmQIdx b')) (gm' 0)

gmPushSlab assigns physical slab gm 0 to (b, gm (gmQIdx b)) and preserves SlabBijection.

Section 2: Pure gmUnlinkTopSlab, gmCompactSlab, gmPopSlab and SlabBijection #

Stage A of slab pop: unlink the top slab p_del = gm (gmSlabTopIdx b) of bucket b by setting gmSlabTopIdx b ↦ gm (gmSlabBelowIdx n_max p_del) and decrementing gmQIdx b.

Stage B of slab pop: compact the physical slab pool by relocating p_last = gmA 0 - 1 into the vacated physical slab p_del (when p_del < p_last) and decrementing gmA 0.

Pure GlobalMeta update popping the top slab of bucket b and compacting the physical slab pool.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.gmUnlinkTopSlab_fields {n_max : ℕ} (gm : ℕ → ℕ) {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) :
gmUnlinkTopSlab n_max gm b 0 = gm 0 ∧ gmUnlinkTopSlab n_max gm b 1 = gm 1 ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmUnlinkTopSlab n_max gm b (gmRIdx b') = gm (gmRIdx b')) ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmUnlinkTopSlab n_max gm b (gmQIdx b') = if b' = b then gm (gmQIdx b) - 1 else gm (gmQIdx b')) ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmUnlinkTopSlab n_max gm b (gmSlabTopIdx b') = if b' = b then gm (gmSlabBelowIdx n_max (gm (gmSlabTopIdx b))) else gm (gmSlabTopIdx b')) ∧ (∀ (idx : ℕ), gmSlabDirBase n_max ≤ idx → gmUnlinkTopSlab n_max gm b idx = gm idx) ∧ ∀ (b' s : ℕ), slabPtrOf n_max (gmUnlinkTopSlab n_max gm b) b' s = slabPtrOf n_max gm b' s

Field-by-field description of gmUnlinkTopSlab (Stage A of slab pop).

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.gmCompactSlab_fields_lt {n_max : ℕ} (gmA : ℕ → ℕ) {p_del : ℕ} (hlt : p_del < gmA 0 - 1) (hb_last : gmA (gmSlabOwnerBIdx n_max (gmA 0 - 1)) < FeistelQuotient.numBuckets n_max) :
have p_last := gmA 0 - 1; have b_last := gmA (gmSlabOwnerBIdx n_max p_last); have s_last := gmA (gmSlabOwnerSIdx n_max p_last); have bel_last := gmA (gmSlabBelowIdx n_max p_last); have abv_last := gmA (gmSlabAboveIdx n_max p_last); have q_last := gmA (gmQIdx b_last); gmCompactSlab n_max gmA p_del 0 = p_last ∧ gmCompactSlab n_max gmA p_del 1 = gmA 1 ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmCompactSlab n_max gmA p_del (gmRIdx b') = gmA (gmRIdx b')) ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmCompactSlab n_max gmA p_del (gmQIdx b') = gmA (gmQIdx b')) ∧ (∀ (idx : ℕ), gmTailPtrBase n_max ≤ idx → idx < gmSlabMetaBase n_max → gmCompactSlab n_max gmA p_del idx = gmA idx) ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmCompactSlab n_max gmA p_del (gmSlabTopIdx b') = if b' = b_last ∧ s_last + 1 = q_last then p_del else gmA (gmSlabTopIdx b')) ∧ (∀ b' < FeistelQuotient.numBuckets n_max, ∀ s < SuccinctBucket.dirSlabsPerBucket n_max, gmCompactSlab n_max gmA p_del (gmSlabDirIdx n_max b' s) = if b' = b_last ∧ s = s_last then p_del else gmA (gmSlabDirIdx n_max b' s)) ∧ (∀ (p : ℕ), gmCompactSlab n_max gmA p_del (gmSlabOwnerBIdx n_max p) = if p = p_del then b_last else gmA (gmSlabOwnerBIdx n_max p)) ∧ (∀ (p : ℕ), gmCompactSlab n_max gmA p_del (gmSlabOwnerSIdx n_max p) = if p = p_del then s_last else gmA (gmSlabOwnerSIdx n_max p)) ∧ (∀ (p : ℕ), gmCompactSlab n_max gmA p_del (gmSlabBelowIdx n_max p) = if p = p_del then bel_last else if s_last + 1 < q_last ∧ p = abv_last then p_del else gmA (gmSlabBelowIdx n_max p)) ∧ ∀ (p : ℕ), gmCompactSlab n_max gmA p_del (gmSlabAboveIdx n_max p) = if p = p_del then abv_last else if 0 < s_last ∧ p = bel_last then p_del else gmA (gmSlabAboveIdx n_max p)

Field-by-field description of gmCompactSlab when p_del < gmA 0 - 1 (Stage B of slab pop).

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.gmPopSlab_preserves_tail {n_max : ℕ} {gm : ℕ → ℕ} {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) (hslab : SlabBijection n_max gm (fun (b' : ℕ) => gm (gmQIdx b')) (gm 0)) :
gmPopSlab n_max gm b 0 = gm 0 - 1 ∧ gmPopSlab n_max gm b 1 = gm 1 ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmPopSlab n_max gm b (gmRIdx b') = gm (gmRIdx b')) ∧ (∀ b' < FeistelQuotient.numBuckets n_max, gmPopSlab n_max gm b (gmQIdx b') = if b' = b then gm (gmQIdx b) - 1 else gm (gmQIdx b')) ∧ ∀ (idx : ℕ), gmTailPtrBase n_max ≤ idx → idx < gmSlabMetaBase n_max → gmPopSlab n_max gm b idx = gm idx

gmPopSlab decrements gm 0 and gm (gmQIdx b) while preserving all tail fields.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.tailBijection_gmPopSlab {n_max : ℕ} {gm : ℕ → ℕ} {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) (hslab : SlabBijection n_max gm (fun (b' : ℕ) => gm (gmQIdx b')) (gm 0)) (htail : TailBijection n_max gm (fun (b' : ℕ) => gm (gmRIdx b')) (gm 1)) :
TailBijection n_max (gmPopSlab n_max gm b) (fun (b' : ℕ) => gmPopSlab n_max gm b (gmRIdx b')) (gmPopSlab n_max gm b 1)

gmPopSlab preserves TailBijection.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.slabBijection_gmPopSlab {n_max : ℕ} {gm : ℕ → ℕ} {b : ℕ} (hb : b < FeistelQuotient.numBuckets n_max) (hq_pos : 1 ≤ gm (gmQIdx b)) (hslab : SlabBijection n_max gm (fun (b' : ℕ) => gm (gmQIdx b')) (gm 0)) :
(∀ b' < FeistelQuotient.numBuckets n_max, ∀ s < gmPopSlab n_max gm b (gmQIdx b'), slabPtrOf n_max (gmPopSlab n_max gm b) b' s = if slabPtrOf n_max gm b' s = gm 0 - 1 then gm (gmSlabTopIdx b) else slabPtrOf n_max gm b' s) ∧ SlabBijection n_max (gmPopSlab n_max gm b) (fun (b' : ℕ) => gmPopSlab n_max gm b (gmQIdx b')) (gmPopSlab n_max gm b 0)

gmPopSlab relocates the last physical slab gm 0 - 1 into gm (gmSlabTopIdx b) and preserves SlabBijection.