Amortized O(1) Slot Allocation and Deallocation in Memory.Prog #
This module combines the tail-item operations (appendTailItemProg, removeLastTailItemProg) and
the K-step slab promotion/demotion loops (promoteSlabProg, demoteSlabProg) into the high-level
bucket-local slot operations:
lastSlotOfProg: resolves the last logical slotbCount n_max gm b - 1of a non-empty bucketbinO(1)worst-case memory accesses;pushBackSlotProg: appends(q_val, v_val)at logical slotbCount n_max gm bof bucketb, promotingKtail items into a full slab whenr_b + 1 = 2 * K, withO(1)amortized cost against66 * slotPotential n_max gm;popBackSlotProg: removes the last logical slotbCount n_max gm b - 1of bucketb, demoting the top full slab intoKtail items whenr_b' = 0 ∧ 0 < q_b, withO(1)amortized cost against66 * slotPotential n_max gm.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.Succinct.totalSlots: total active slots across all buckets (gm 0in the single-bucket regime,gm 0 * slabSize n_max + gm 1in the multi-bucket regime).Cslib.DataStructure.Dictionary.WordRAM.Succinct.lastSlotOfProg:Memory.Progoperation resolvingslotOf n_max gm b (bCount n_max gm b - 1).Cslib.DataStructure.Dictionary.WordRAM.Succinct.pushBackSlotProg:Memory.Progoperation appending(q_val, v_val)to bucketbwith hysteresis promotion.Cslib.DataStructure.Dictionary.WordRAM.Succinct.popBackSlotProg:Memory.Progoperation removing the last item of bucketbwith hysteresis demotion.
Main results #
Cslib.DataStructure.Dictionary.WordRAM.Succinct.slotPotential_pushBack_le,Cslib.DataStructure.Dictionary.WordRAM.Succinct.slotPotential_popBack_le: global hysteresis potential bounds underpushBackCountsandpopBackCounts.Cslib.DataStructure.Dictionary.WordRAM.Succinct.totalSlots_eq_sum_bCount:totalSlotsequals the sum ofbCountacross all buckets.Cslib.DataStructure.Dictionary.WordRAM.Succinct.pushBackSlotProg_effect,Cslib.DataStructure.Dictionary.WordRAM.Succinct.realizes_pushBackSlotGen: effect, amortizedmemoryCostbound, andRealizescertificate forpushBackSlotProg.Cslib.DataStructure.Dictionary.WordRAM.Succinct.popBackSlotProg_effect,Cslib.DataStructure.Dictionary.WordRAM.Succinct.realizes_popBackSlotGen: effect, amortizedmemoryCostbound, andRealizescertificate forpopBackSlotProg.
Section 1: totalSlots, hysteresis potential bounds, and lastSlotOfProg #
Global potential bound when bucket b transitions according to pushBackCounts.
Global potential bound when bucket b transitions according to popBackCounts.
Under SlabBijection, n_slabs equals the sum of per-bucket slab counts q_fn b.
Under TailBijection, n_tails equals the sum of per-bucket tail counts r_fn b.
In the multi-bucket regime (0 < bucketBits n_max), the total active slot count
gm 0 * slabSize n_max + gm 1 equals the sum of per-bucket item counts bCount n_max gm b.
Under SlotStoreInv n_max gm, totalSlots n_max gm equals the sum of bCount n_max gm b
over all buckets b < numBuckets n_max.
promoteSlabProg preserves gm 0 * slabSize n_max + gm 1.
demoteSlabProg preserves gm 0 * slabSize n_max + gm 1.
Parameter-free Memory.Prog operation resolving the physical slot
slotOf n_max gm b (bCount n_max gm b - 1) of the last item in a non-empty bucket b = d.2.2
at base = d.2.1 (1 ≤ bCount n_max gm b).
Memory.Prog operation resolving the physical slot slotOf n_max gm b (bCount n_max gm b - 1)
of the last item in a non-empty bucket b = d.2 at base = d.1 (1 ≤ bCount n_max gm b).
Parameter-free precondition for lastSlotOfGenProg.
Specialize a packed bucket guard together with its decision instance.
Section 2: pushBackSlotProg via realize #
Parameter-free helper Memory.Prog for the multi-bucket prefix of pushBackSlotGenProg.
Helper Memory.Prog for the multi-bucket prefix of pushBackSlotProg: appends one tail item
to bucket b = d.1.1.2 at base = d.1.1.1, writes (q_val, v_val) = (d.1.2, d.2) into its
physical slot, and returns the updated tail count r_b_new = gm' (gmRIdx b).
Pure state effect and return value of pushBackTailWriteProg.
Precondition for pushBackSlotProg in Realizes.
Parameter-free precondition for pushBackSlotGenProg.
Parameter-free precondition for pushBackTailWriteGenProg.
Parameter-free Memory.Prog operation appending (q_val, v_val) = (d.1.2, d.2) at logical
slot bCount n_max gm b of bucket b = d.1.1.2.2 at base = d.1.1.2.1.
Memory.Prog operation appending (q_val, v_val) = (d.1.2, d.2) at logical slot
bCount n_max gm b of bucket b = d.1.1.2 at base = d.1.1.1, promoting K tail items into a
new full slab when r_b + 1 = 2 * K.
Pure state effect and amortized memoryCost bound of pushBackSlotProg.
Section 3: popBackSlotProg via realize #
Parameter-free Memory.Prog operation removing the last logical slot bCount n_max gm b - 1
of a non-empty bucket b = d.2.2 at base = d.2.1.
Memory.Prog operation removing the last logical slot bCount n_max gm b - 1 of a non-empty
bucket b = d.2 at base = d.1, demoting the top full slab into K = slabSize n_max tail items
when r_b - 1 = 0 ∧ 0 < q_b.
Precondition for popBackSlotProg in Realizes.
Parameter-free precondition for popBackSlotGenProg.
Pure state effect and amortized memoryCost bound of popBackSlotProg.