Post-Rebuild Leftward Compaction and Tail Shrink (migrateCompactBackCode) #
Internal second half of migrateFinishCleanCode: copies the rebuilt metadata and item regions
leftward from (mNewMeta, mArena) back to (base, base + offNew) and shrinks [frNew, peakF).
noncomputable def Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.migrateCompactBackCode :
Second half of migrateFinishCleanCode: copies (mNewMeta, mArena) leftward to
(base, base + offNew) and shrinks [frNew, peakF).
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.migrateCompactBackCode_exec {U V w N_old N_new n base : ℕ} {θ_new : Succinct.QuotHashSeed U N_new} {s_abs : State U} {z₄ : WordRAM.Resizable.RData rResize} (hw : 0 < w) (hn : 1 ≤ n) (hev : EpochValid U n N_old) (hNU_new : N_new ≤ U) (hN_new_2n : N_new ≤ 2 * n) (hcard : (dom s_abs).card = n) (hvals : ValuesBounded V s_abs) (hfit_peak : WordRAM.Fits w (base + migratePeakWords U V w N_old n)) (hpeak_eq :
base + migratePeakWords U V w N_old n = base + offCompItems U w N_old + offCompItems U w N_new + migrateArenaWords U V w N_old N_new n) (hz₄b : WordRAM.Resizable.RData.Bounded w z₄) (hz₄f_eq : z₄.frontier = base + migratePeakWords U V w N_old n) (hz₄_fr_reg : z₄.regs mFr = base + migratePeakWords U V w N_old n) (hz₄_nm : z₄.regs mNewMeta = base + offCompItems U w N_old) (hz₄_base : z₄.regs mBase = base) (hz₄_off : z₄.regs mOffNew = offCompItems U w N_new) (hz₄_ar : z₄.regs mArena = base + offCompItems U w N_old + offCompItems U w N_new) (hz₄_iwn : z₄.regs mIwNew = compactedItemWords U V w N_new n) (hz₄_pf : z₄.regs mPeakFront = base + migratePeakWords U V w N_old n) (hhdr_z₄ : RootHeaderValid U V w N_new n n (base + offCompItems U w N_old) z₄.mem) (hpar_z₄ : EpochParamsStored U V w N_new (base + offCompItems U w N_old) z₄.mem) (hrep_z₄ :
HashFamily.WordRAM.ReducedKWise.Rep (base + offCompItems U w N_old + epochHdrWords) w (Succinct.qBits U N_new)
(Succinct.hashB N_new) (SuccinctBucket.totalMicroBits N_new) 3 θ_new z₄.mem) (hcpl_z₄ :
∃ (s_fix' : Memory.State),
Succinct.DictStateInv U V (ghostW w) N_new 0 θ_new s_abs s_fix' ∧ FixedCoupled (base + offCompItems U w N_old) (base + offCompItems U w N_old + offCompItems U w N_new) U V w N_new
s_fix' { mem := z₄.mem, frontier := base + migratePeakWords U V w N_old n }) :
have peakF := base + migratePeakWords U V w N_old n;
∃ (z : WordRAM.Resizable.RData rResize) (steps_back : ℕ),
(WordRAM.Resizable.RDemonicExec w peakF migrateCompactBackCode z₄ steps_back
fun (x : WordRAM.Resizable.RData rResize) => x = z) ∧ steps_back ≤ (1900 * migFactor + 9620) * n ∧ 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 } ∧ compGmAt base U w N_new z.mem = compGmAt (base + offCompItems U w N_old) U w N_new z₄.mem ∧ abiPreserved z₄ z ∧ ∀ addr < base, z.mem addr = z₄.mem addr