Documentation

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

Hash-Seed Resampling Wrapper and Post-Resample Metadata Initialization #

Internal distributional combinator exec_setup_resample_finish, scratch-clearing stub zeroResampleRegsCode, and shared post-resample initNewEpochMetaProg execution helper exec_postResample_initMeta shared by MigrateFinish, MigrateActive, and InitFirst.

Zero the 5 scratch registers written by resampleHashCode (5 instructions).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.zeroResampleRegsCode_exec {w L_peak w₀ b b' hashBase : ℕ} {θ : Probability.ReducedPolySeed w₀ b b' 3} {x y : WordRAM.Resizable.RData rResize} (hx : WordRAM.Resizable.RData.Bounded w x) (hy_fr : y.frontier = x.frontier) (hL : x.frontier ≤ L_peak) (hw₀ : w₀ ≤ w) (hc_lt : 2 * Probability.reducedChunkBits (Probability.reducedTrinomialStep w₀ b b') < w) (hfr_h : hashBase + HashFamily.WordRAM.ReducedKWise.seedWords w₀ b b' 3 ≤ x.frontier) (hseed : HashFamily.WordRAM.ReducedKWise.SeedRep hashBase w₀ b b' 3 θ y.mem) (hframe_mem : ∀ (a : ℕ), a < hashBase ∨ hashBase + HashFamily.WordRAM.ReducedKWise.seedWords w₀ b b' 3 ≤ a → y.mem a = x.mem a) (hframe_reg : ∀ j ∉ [mCur, mIdx, mK, mOne, mRes], y.regs j = x.regs j) :
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.exec_postResample_initMeta {U V w N metaBase peakF : ℕ} {θ : Succinct.QuotHashSeed U N} {y_set y_rs : WordRAM.Resizable.RData rResize} (rMeta : Fin rResize) (hr_not : rMeta ∉ [mCur, mIdx, mK, mOne, mRes]) (hw : 0 < w) (hU : U < 2 ^ w) (hN_pos : 1 ≤ N) (hNU : N ≤ U) (hfits_U : WordRAM.Fits w U) (hV : V ≤ 2 ^ w) (hy_set_b : WordRAM.Resizable.RData.Bounded w y_set) (hy_set_fr : y_set.frontier = peakF) (hnm_le_peak : metaBase + offCompItems U w N ≤ peakF) (hfit_nm : WordRAM.Fits w (metaBase + offCompItems U w N)) (hr_meta : y_set.regs rMeta = metaBase) (hr_fr : y_set.regs mFr = peakF) (hr_nhp : ∀ (i : Fin 19), y_set.regs (mNewHp i) = HashFamily.WordRAM.RuntimeReducedKWise.mkHashParams w (epochQBits U N) (epochHashB N) (SuccinctBucket.totalMicroBits N) 3 i) (hr_ncp : ∀ (i : Fin 36), y_set.regs (mNewCp i) = mkCompParams U V w N i) (hrs_fr : y_rs.frontier = y_set.frontier) (hrs_seed : HashFamily.WordRAM.ReducedKWise.SeedRep (metaBase + epochHdrWords) (Succinct.qBits U N) (Succinct.hashB N) (SuccinctBucket.totalMicroBits N) 3 θ y_rs.mem) (hrs_mem : ∀ (a : ℕ), a < metaBase + epochHdrWords ∨ metaBase + epochHdrWords + HashFamily.WordRAM.ReducedKWise.seedWords (Succinct.qBits U N) (Succinct.hashB N) (SuccinctBucket.totalMicroBits N) 3 ≤ a → y_rs.mem a = y_set.mem a) (hrs_reg : ∀ reg ∉ [mCur, mIdx, mK, mOne, mRes], y_rs.regs reg = y_set.regs reg) :
have z₀ := ((((y_rs.set mCur 0).set mIdx 0).set mK 0).set mOne 0).set mRes 0; have d_im := ((HashFamily.WordRAM.RuntimeReducedKWise.mkHashParams w (Succinct.qBits U N) (Succinct.hashB N) (SuccinctBucket.totalMicroBits N) 3, mkCompParams U V w N), metaBase); ∃ (z₁ : WordRAM.Resizable.RData rResize) (z₂ : WordRAM.Resizable.RData rResize), (WordRAM.Resizable.RDemonicExec w peakF (WordRAM.Resizable.RCode.op (WordRAM.Op.copy mTmpA rMeta)) z₀ 1 fun (x : WordRAM.Resizable.RData rResize) => x = z₁) ∧ (WordRAM.Resizable.RDemonicExec w peakF (WordRAM.Resizable.RCode.ofCode (wInitNewMeta.code mFr srcInitNewMeta tmpInitNewMeta)) z₁ (migFactor * (WordRAM.Realization.memoryCost (initNewEpochMetaProg d_im) { mem := y_rs.mem, frontier := peakF } + 1)) fun (x : WordRAM.Resizable.RData rResize) => x = z₂) ∧ WordRAM.Realization.memoryCost (initNewEpochMetaProg d_im) { mem := y_rs.mem, frontier := peakF } ≤ 256 * N + 475 ∧ ((Memory.spec 0).clientState { mem := y_rs.mem, frontier := peakF } (initNewEpochMetaProg d_im)).frontier = peakF ∧ WordRAM.Resizable.RData.Bounded w z₂ ∧ z₂.frontier = peakF ∧ z₂.regs mFr = peakF ∧ z₂.mem = ((Memory.spec 0).clientState { mem := y_rs.mem, frontier := peakF } (initNewEpochMetaProg d_im)).mem ∧ HashFamily.WordRAM.ReducedKWise.Rep (metaBase + epochHdrWords) w (Succinct.qBits U N) (Succinct.hashB N) (SuccinctBucket.totalMicroBits N) 3 θ z₂.mem ∧ Succinct.totalSlots N (compGmAt metaBase U w N z₂.mem) = 0 ∧ Succinct.slotPotential N (compGmAt metaBase U w N z₂.mem) = 0 ∧ (∃ (s_fix₀ : Memory.State), Succinct.DictStateInv U V (ghostW w) N 0 θ (empty U) s_fix₀ ∧ FixedCoupled metaBase (metaBase + offCompItems U w N) U V w N s_fix₀ { mem := z₂.mem, frontier := peakF }) ∧ (∀ (reg : Fin rResize), ↑reg < 160 → reg ∉ [mFr, mTmpA, mCur, mIdx, mK, mOne, mRes] → z₂.regs reg = y_set.regs reg) ∧ ∀ (a : ℕ), ¬(metaBase + epochHdrWords ≤ a ∧ a < metaBase + offCompItems U w N) → z₂.mem a = y_set.mem a

Shared post-resample step executing .op (.copy mTmpA rMeta) followed by wInitNewMeta.code from the scratch-zeroed state after resampleHashCode, used by both migrateFinishCode_exec (rMeta = mNewMeta) and initFirstFinishCode_exec (rMeta = mBase).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.exec_setup_resample_finish {U w N_new metaBase base peakF steps_set finBound : ℕ} {setupCode finishCleanCode : WordRAM.Resizable.RCode WordRAM.Basis.exact rResize} {x y_set : WordRAM.Resizable.RData rResize} {P : Succinct.QuotHashSeed U N_new → WordRAM.Resizable.RData rResize → Prop} (hw : 0 < w) (hU : U < 2 ^ w) (hNU : N_new ≤ U) (hex_set : WordRAM.Resizable.RDemonicExec w peakF setupCode x steps_set fun (x : WordRAM.Resizable.RData rResize) => x = y_set) (hy_set_b : WordRAM.Resizable.RData.Bounded w y_set) (hy_set_fr : y_set.frontier = peakF) (hfit_nm : WordRAM.Fits w (metaBase + offCompItems U w N_new)) (hnm_le_peak : metaBase + offCompItems U w N_new ≤ peakF) (hr_hb : y_set.regs mHashBase = metaBase + epochHdrWords) (hr_nhp : ∀ (j : Fin 19), y_set.regs (mNewHp j) = HashFamily.WordRAM.RuntimeReducedKWise.mkHashParams w (Succinct.qBits U N_new) (Succinct.hashB N_new) (SuccinctBucket.totalMicroBits N_new) 3 j) (hfin_spec : ∀ (θ : Succinct.QuotHashSeed U N_new) (y_rs : WordRAM.Resizable.RData rResize), y_rs.frontier = y_set.frontier → HashFamily.WordRAM.ReducedKWise.SeedRep (metaBase + epochHdrWords) (Succinct.qBits U N_new) (Succinct.hashB N_new) (SuccinctBucket.totalMicroBits N_new) 3 θ y_rs.mem → (∀ (a : ℕ), a < metaBase + epochHdrWords ∨ metaBase + epochHdrWords + HashFamily.WordRAM.ReducedKWise.seedWords (Succinct.qBits U N_new) (Succinct.hashB N_new) (SuccinctBucket.totalMicroBits N_new) 3 ≤ a → y_rs.mem a = y_set.mem a) → (∀ j ∉ [mCur, mIdx, mK, mOne, mRes], y_rs.regs j = y_set.regs j) → ∃ (z : WordRAM.Resizable.RData rResize) (stepsClean : ℕ), (WordRAM.Resizable.RDemonicExec w peakF finishCleanCode (((((y_rs.set mCur 0).set mIdx 0).set mK 0).set mOne 0).set mRes 0) stepsClean fun (x : WordRAM.Resizable.RData rResize) => x = z) ∧ P θ z ∧ 5 + stepsClean + inEpochPotential U w N_new base z ≤ finBound) :