Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.ResizableSuccinct.Migration.Exec.MigrateFinish

Post-Resample Streaming Rebuild and Compaction (migrateFinishCode) #

Internal deterministic finish half of migrateActiveCode after resampleHashCode: clears resample scratch registers, initializes the new epoch's tables/metadata at mNewMeta, streams all n entries from the right-aligned old item suffix (streamAllItemsProg), and compacts back to base.

Deterministic finish half of migrateActiveCode after resampleHashCode.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.migrateFinishCode_exec {U V w N_old n base : ℕ} {θ_old : Succinct.QuotHashSeed U N_old} {θ_new : Succinct.QuotHashSeed U (targetCap U n)} {s_abs : State U} {x y_set y_rs : WordRAM.Resizable.RData rResize} (hn : 1 ≤ n) (hev : EpochValid U n N_old) (hcard : (dom s_abs).card = n) (hvals : ValuesBounded V s_abs) (hfit_peak : WordRAM.Fits w (base + migratePeakWords U V w N_old n)) (hy_set_b : WordRAM.Resizable.RData.Bounded w y_set) (hy_set_fr : y_set.frontier = base + migratePeakWords U V w N_old n) (habi_set : abiPreserved x y_set) (hbelow_set : ∀ addr < base, y_set.mem addr = x.mem addr) (hhdr_set : RootHeaderValid U V w (targetCap U n) n n (base + offCompItems U w N_old) y_set.mem) (hpar_set : EpochParamsStored U V w (targetCap U n) (base + offCompItems U w N_old) y_set.mem) (hrep_old : HashFamily.WordRAM.ReducedKWise.Rep (base + epochHdrWords) w (Succinct.qBits U N_old) (Succinct.hashB N_old) (SuccinctBucket.totalMicroBits N_old) 3 θ_old y_set.mem) (hcpl_old : ∃ (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 base U w N_old y_set.mem) = n ∧ FixedCoupled base (base + offCompItems U w N_old + offCompItems U w (targetCap U n) + (migrateArenaWords U V w N_old (targetCap U n) n - compactedItemWords U V w N_old n)) U V w N_old s_fix_old { mem := y_set.mem, frontier := y_set.frontier }) (hr_base : y_set.regs mBase = base) (hr_cnt : y_set.regs mCnt = n) (hr_fr : y_set.regs mFr = base + migratePeakWords U V w N_old n) (hr_nm : y_set.regs mNewMeta = base + offCompItems U w N_old) (hr_off : y_set.regs mOffNew = offCompItems U w (targetCap U n)) (hr_iwn : y_set.regs mIwNew = compactedItemWords U V w (targetCap U n) n) (hr_ar : y_set.regs mArena = base + offCompItems U w N_old + offCompItems U w (targetCap U n)) (hr_pf : y_set.regs mPeakFront = base + migratePeakWords U V w N_old n) (hr_oid : y_set.regs mOldItemDst = base + offCompItems U w N_old + offCompItems U w (targetCap U n) + (migrateArenaWords U V w N_old (targetCap U n) n - compactedItemWords U V w N_old n)) (hr_ohp : ∀ (i : Fin 19), y_set.regs (mOldHp i) = HashFamily.WordRAM.RuntimeReducedKWise.mkHashParams w (epochQBits U N_old) (epochHashB N_old) (SuccinctBucket.totalMicroBits N_old) 3 i) (hr_ocp : ∀ (i : Fin 36), y_set.regs (mOldCp i) = mkCompParams U V w N_old i) (hr_nhp : ∀ (i : Fin 19), y_set.regs (mNewHp i) = HashFamily.WordRAM.RuntimeReducedKWise.mkHashParams w (epochQBits U (targetCap U n)) (epochHashB (targetCap U n)) (SuccinctBucket.totalMicroBits (targetCap U n)) 3 i) (hr_ncp : ∀ (i : Fin 36), y_set.regs (mNewCp i) = mkCompParams U V w (targetCap U n) i) (hrs_fr : y_rs.frontier = y_set.frontier) (hrs_seed : HashFamily.WordRAM.ReducedKWise.SeedRep (base + offCompItems U w N_old + epochHdrWords) (Succinct.qBits U (targetCap U n)) (Succinct.hashB (targetCap U n)) (SuccinctBucket.totalMicroBits (targetCap U n)) 3 θ_new y_rs.mem) (hrs_mem : ∀ (a : ℕ), a < base + offCompItems U w N_old + epochHdrWords ∨ base + offCompItems U w N_old + epochHdrWords + HashFamily.WordRAM.ReducedKWise.seedWords (Succinct.qBits U (targetCap U n)) (Succinct.hashB (targetCap U n)) (SuccinctBucket.totalMicroBits (targetCap U n)) 3 ≤ a → y_rs.mem a = y_set.mem a) (hrs_reg : ∀ j ∉ [mCur, mIdx, mK, mOne, mRes], y_rs.regs j = y_set.regs j) :
let N_new := targetCap U n; have peakF := base + migratePeakWords U V w N_old n; ∃ (z : WordRAM.Resizable.RData rResize) (steps_clean : ℕ), (WordRAM.Resizable.RDemonicExec w peakF migrateFinishCleanCode (((((y_rs.set mCur 0).set mIdx 0).set mK 0).set mOne 0).set mRes 0) steps_clean fun (x : WordRAM.Resizable.RData rResize) => x = z) ∧ WordRAM.Resizable.RData.Bounded w z ∧ z.frontier = base + compactedEpochWords U V w N_new n ∧ CompactedSplitRep base (base + offCompItems U w N_new) U V w N_new n n θ_new s_abs { mem := z.mem, frontier := z.frontier } ∧ abiPreserved x z ∧ (∀ addr < base, z.mem addr = x.mem addr) ∧ 5 + steps_clean + inEpochPotential U w N_new base z ≤ (93500 * migFactor + 10000) * n