Slab Promotion Loop in Memory.Prog #
This module implements the K-step (K = slabSize n_max) slab promotion (promoteStepProg,
promoteLoopProg, and promoteSlabProg) in Memory.Prog, proves that it preserves
SlotStoreInv, bCount, and all logical (quotAt, valAt) entries via slotOf, and certifies
its Word-RAM realization via realize and Realizes.iterate₀. Slab demotion (demoteSlabProg)
is implemented in CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctSlabDemote.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.Succinct.promoteStepProg: single stepk < slabSize n_maxof slab promotion.Cslib.DataStructure.Dictionary.WordRAM.Succinct.promoteLoopProg:K-step iteration ofpromoteStepProg.Cslib.DataStructure.Dictionary.WordRAM.Succinct.promoteSlabProg: complete slab promotion (promoteLoopProgfollowed bygmPushSlabProg).Cslib.DataStructure.Dictionary.WordRAM.Succinct.PromoteSlabInv: entry invariant forpromoteSlabProg(gm (gmRIdx b) = 2 * slabSize n_max).
Main results #
Cslib.DataStructure.Dictionary.WordRAM.Succinct.promoteStepProg_effect,Cslib.DataStructure.Dictionary.WordRAM.Succinct.realizes_promoteStepGen: single-step invariant preservation andRealizescertificate forpromoteStepProg.Cslib.DataStructure.Dictionary.WordRAM.Succinct.promoteSlabProg_effect,Cslib.DataStructure.Dictionary.WordRAM.Succinct.realizes_promoteSlabGen: full-slab promotion invariant preservation,O(K)memoryCost, andRealizescertificate forpromoteSlabProg.
Section 1: Single step of slab promotion (promoteStepProg) #
Parameter-free single step k < slabSize n_max of slab promotion for
x = ((dp, (base, b)), k).
One step k < slabSize n_max of slab promotion for x = ((base, b), k):
- Reads the payload
(q_u, v_u)at low tail itemu = (slabSize n_max - 1) - kand the payload(q_top, v_top)at the last tail itemr_top = slabSize n_max + u = gm (gmRIdx b) - 1. - Copies
(q_top, v_top)into tail itemu. - Calls
removeLastTailItemProg (base, b)to compact and remove tail itemr_top. - Writes
(q_u, v_u)into physical slab slotgm 0 * slabSize n_max + kand returnsk + 1.
Pure state invariant for step k (k < slabSize n_max) of promoteStepProg.
Precondition for promoteStepProg in Realizes.
Parameter-free precondition for promoteStepGenProg.
Under PromoteStepInv U V w n_max h_space base b k s (k < slabSize n_max,
gm (gmRIdx b) = 2 * slabSize n_max - k), promoteStepProg returns k + 1 in memoryCost = 66
(memoryCost_promoteStepProg). It preserves frontier, lmAt, and memory outside
[base + offQuot h_space, base + totalSpace U V w n_max h_space). It moves tail item
u = (slabSize n_max - 1) - k of bucket b to physical slab slot gm 0 * slabSize n_max + k,
compacts the last tail item r_top = slabSize n_max + u into u, and updates gmAt to
gmRemoveTail n_max gm b.
Section 2: PromoteArrInv, PromoteLoopInv, and promoteSlabProg #
Array payload invariant at iteration k ≤ slabSize n_max of the slab-promotion loop.
- low_tail (u : ℕ) : u < SuccinctBucket.slabSize n_max - k → arr (slotOf n_max gm b (gm₀ (gmQIdx b) * SuccinctBucket.slabSize n_max + u)) = arr₀ (slotOf n_max gm₀ b (gm₀ (gmQIdx b) * SuccinctBucket.slabSize n_max + u))
- high_tail (u : ℕ) : u < SuccinctBucket.slabSize n_max - k → arr (slotOf n_max gm b (gm₀ (gmQIdx b) * SuccinctBucket.slabSize n_max + (SuccinctBucket.slabSize n_max + u))) = arr₀ (slotOf n_max gm₀ b (gm₀ (gmQIdx b) * SuccinctBucket.slabSize n_max + (SuccinctBucket.slabSize n_max + u)))
- shifted_tail (u : ℕ) : SuccinctBucket.slabSize n_max - k ≤ u → u < SuccinctBucket.slabSize n_max → arr (slotOf n_max gm b (gm₀ (gmQIdx b) * SuccinctBucket.slabSize n_max + u)) = arr₀ (slotOf n_max gm₀ b (gm₀ (gmQIdx b) * SuccinctBucket.slabSize n_max + (SuccinctBucket.slabSize n_max + u)))
- new_slab (k' : ℕ) : k' < k → arr (gm₀ 0 * SuccinctBucket.slabSize n_max + k') = arr₀ (slotOf n_max gm₀ b (gm₀ (gmQIdx b) * SuccinctBucket.slabSize n_max + (SuccinctBucket.slabSize n_max - 1 - k')))
Loop invariant at step k ≤ slabSize n_max of promoteLoopProg.
- b_lt : b < FeistelQuotient.numBuckets n_max
- k_le : k ≤ SuccinctBucket.slabSize n_max
Parameter-free wrapper for iterate promoteStepGenProg with signature
(((dp, (base, b)), k), m) → Memory.Prog ℕ matching Realizes.iterate₀.
Parameter-free Memory.Prog operation promoting K = slabSize n_max tail items of bucket
b = d.2.2 at base = d.2.1 into a new full slab.
Memory.Prog operation promoting K = slabSize n_max tail items of bucket b = d.2 at
base = d.1 (gm (gmRIdx b) = 2 * K) into a new full slab via promoteLoopProg followed by
gmPushSlabProg.
Pure entry invariant for promoteSlabProg.
Precondition for promoteSlabProg in Realizes.
Parameter-free precondition for promoteSlabGenProg.
Under PromoteSlabInv U V w n_max h_space base b s (gm (gmRIdx b) = 2 * slabSize n_max),
promoteSlabProg runs in memoryCost ≤ 66 * slabSize n_max + 38 and preserves frontier, lmAt,
and memory outside [base + offQuot h_space, base + totalSpace U V w n_max h_space). It restores
SlotStoreInv n_max gm' with gm' (gmQIdx b) = gm₀ (gmQIdx b) + 1,
gm' (gmRIdx b) = slabSize n_max, and unchanged (gmQIdx b', gmRIdx b') for b' ≠ b. It also
preserves bCount and every logical (quotAt, valAt) entry at slotOf across all buckets.