Single-Tape Block Copy, New-Epoch Metadata Initialization, and Streaming Rebuild (Memory.Prog) #
This module implements the deterministic Memory.Prog subroutines (¬ReadsWidth, certified via
RealizesBounded .exact) for single-tape 1 · OPT epoch capacity migration:
- Overlapping-Safe Block Copy (
copyRightwardProg,copyLeftwardProg):copyRightwardProgcopies[srcBase, +len)rightward to[dstBase, +len)(srcBase ≤ dstBase) in reverse index orderlen - 1 .. 0so overlapping ranges never clobber unread words;copyLeftwardProgcopies[srcBase, +len)leftward to[dstBase, +len)(dstBase ≤ srcBase) in forward index order0 .. len - 1.
- New-Epoch Table & Zeroed Metadata Initialization (
initNewEpochMetaProg):- builds the Four-Russians carryless multiplication table via
initTableGenProgand zeros[newMetaBase + offCompLM, newMetaBase + offCompItems), establishingReducedKWise.Rep,DictStateInv ... (Dictionary.empty U),FixedCoupled, andslotPotential = 0.
- builds the Four-Russians carryless multiplication table via
- Old-Item Key/Value Reconstruction & Fresh-Key Streaming Append (
readOldItemKeyValGenProg,streamInsertFreshGenProg,streamAllItemsProg):- reconstructs
(u_i, v_i)from dense sloti < nof the right-aligned old item suffix viarecoverOwnerBucketGenProg,evalHashGenProg, and Feistel inversion; - appends
(u_i, v_i)into[0, i + 1)at(newMetaBase, arenaBase)without duplicate search (valid by injectivity ofreconstructKeyAt_spec), preserving all unread old itemsd > ibynewItemEnd_le_oldItemNextWord.
- reconstructs
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.copyRightwardProg,copyLeftwardProg: overlapping-safe rightward and leftward word-block copy programs.Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.initNewEpochMetaProg: Four-Russians table and zeroed compacted metadata initializer.Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.readOldItemKeyValGenProg,streamInsertFreshGenProg,streamAllItemsProg: single-tape streaming rebuild programs.
Main results #
copyRightwardProg_spec,realizesBounded_copyRightward,copyLeftwardProg_spec,realizesBounded_copyLeftward: correctness andRealizesBoundedcertificates for overlapping-safe word-block shifts.initNewEpochMetaProg_spec,realizesBounded_initNewEpochMeta: empty new-epoch invariant andRealizesBoundedcertificate.streamInsertFreshGenProg_spec,realizesBounded_streamInsertFreshGen: fresh-key append correctness (≤ 45360amortized memory operations) andRealizesBoundedcertificate.streamAllItemsProg_spec,realizesBounded_streamAllItems: fulln-item single-tape streaming rebuild establishingDictStateInvandFixedCoupledfors_absinO(n)deterministic steps.compactedSplitRep_of_reloc: transportsCompactedSplitRepafter leftward relocation tobase.
References #
Section 1: Overlapping-Safe Rightward and Leftward Block Copy (Memory.Prog) #
Copy len words rightward from [srcBase, +len) to [dstBase, +len) (srcBase ≤ dstBase)
in reverse order (¬ReadsWidth).
Entry precondition for copyRightwardProg.
Copy len words leftward from [srcBase, +len) to [dstBase, +len) (dstBase ≤ srcBase)
in forward order (¬ReadsWidth).
Entry precondition for copyLeftwardProg.
Section 2: New-Epoch Four-Russians Table and Zeroed Metadata Initializer #
Build the Four-Russians table at newMetaBase + 225 and zero compacted metadata
[newMetaBase + offCompLM, newMetaBase + offCompItems) (¬ReadsWidth).
Entry precondition for initNewEpochMetaProg.
Section 3: Old-Item (u_i, v_i) Reconstruction (readOldItemKeyValGenProg) #
Reconstruct (u_d, v_d) at dense slot idx_d of the old epoch (¬ReadsWidth).
Entry precondition for readOldItemKeyValGenProg.
Section 4: Fresh-Key Streaming Insertion (streamInsertFreshGenProg) #
Insert a fresh (u, v) pair (¬(s_abs ⟨u, hu⟩).isSome) into (newMetaBase, arenaBase)
without duplicate bucket search (¬ReadsWidth).
Entry precondition for streamInsertFreshGenProg.
Section 5: Full n-Item Single-Tape Streaming Loop and Relocation #
Stream n items starting from index a (0 for a full epoch migration) from
(oldMetaBase, oldItemBase) into (newMetaBase, arenaBase) (¬ReadsWidth).
Entry precondition for streamAllItemsProg.
Single-tape zone and epoch-invariant bundle for streamAllItemsProg_spec.
- pos_w : 0 < w
- pos_n : 1 ≤ n
- le_old : n ≤ N_old
- old_le_U : N_old ≤ U
- le_new : n ≤ N_new
- new_le_U : N_new ≤ U
- fits_U : WordRAM.Fits w U
- vals_lt : ValuesBounded V s_abs
- old_hash_rep : HashFamily.WordRAM.ReducedKWise.Rep (oldMetaBase + epochHdrWords) w (Succinct.qBits U N_old) (Succinct.hashB N_old) (SuccinctBucket.totalMicroBits N_old) 3 θ_old s₀.mem
- old_coupled : ∃ (s_fix_old : Memory.State), Succinct.DictStateInv U V (ghostW w) N_old 0 θ_old s_abs s_fix_old ∧ Succinct.totalSlots N_old (compGmAt oldMetaBase U w N_old s₀.mem) = n ∧ FixedCoupled oldMetaBase (arenaBase + (migrateArenaWords U V w N_old N_new n - compactedItemWords U V w N_old n)) U V w N_old s_fix_old s₀
- new_hash_rep : HashFamily.WordRAM.ReducedKWise.Rep (newMetaBase + epochHdrWords) w (Succinct.qBits U N_new) (Succinct.hashB N_new) (SuccinctBucket.totalMicroBits N_new) 3 θ_new s₀.mem
- new_empty_coupled : ∃ (s_fix₀ : Memory.State), Succinct.DictStateInv U V (ghostW w) N_new 0 θ_new (empty U) s_fix₀ ∧ FixedCoupled newMetaBase arenaBase U V w N_new s_fix₀ s₀
Relocate an active compacted epoch representation from (srcMetaBase, srcItemBase) to
(base, base + offCompItems U w N) after leftward block copy.