Documentation

CslibFrontier.DataStructure.Dictionary.SuccinctWhpModelStep.DeleteHelpers

Shared Deletion, Relocation, and Pre-Tick Stage Helpers for SuccinctWhpModelStep #

This internal helper module (imported privately by DeleteLast and DeleteReloc, so none of its declarations enter the public export closure of SuccinctWhpModelStep) factors the shared combinators for fastDelete:

theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.rebRole_props {r₁ r₂ : ℕ} (hr₁ : r₁ < 3) (hr₂ : r₂ < 3) (hne : r₁ ≠ r₂) :
3 - r₁ - r₂ < 3 ∧ 3 - r₁ - r₂ ≠ r₁ ∧ 3 - r₁ - r₂ ≠ r₂
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.lt_of_lt_update_le {cnt : ℕ → ℕ} {b k b' loc : ℕ} (hk : k ≤ cnt b) (h : loc < Function.update cnt b k b') :
loc < cnt b'
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.sliceMapRel_delete_last {f : ℕ → ℕ} {P : ℕ → Prop} {X : ℕ} {m : ℕ → Option ℕ} (hrel : SliceMapRel f P (X + 1) m) (_hp : P X) (hinj : ∀ loc < X, P loc → f loc ≠ f X) :
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.sliceMapRel_skip_last {f : ℕ → ℕ} {P : ℕ → Prop} {X : ℕ} {m : ℕ → Option ℕ} (hrel : SliceMapRel f P (X + 1) m) (hnp : ¬P X) :
SliceMapRel f P X m
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.sliceMapRel_relocate_full {f f' : ℕ → ℕ} {P P' : ℕ → Prop} [DecidablePred P] {loc_del loc_last : ℕ} {m0 : ℕ → Option ℕ} (hrel : SliceMapRel f P (loc_last + 1) m0) (hlt_del : loc_del < loc_last) (hinj : ∀ l₁ < loc_last + 1, ∀ l₂ < loc_last + 1, P l₁ → P l₂ → f l₁ = f l₂ → l₁ = l₂) (hf_pres : ∀ loc < loc_last, loc ≠ loc_del → f' loc = f loc) (hf_del : f' loc_del = f loc_last) (hP_pres : ∀ loc < loc_last, loc ≠ loc_del → (P' loc ↔ P loc)) (hP_del : P' loc_del ↔ P loc_last) :
have m1 := if P loc_del then Function.update m0 (f loc_del) none else m0; (P loc_last → (m1 (f loc_last)).isSome = true) ∧ SliceMapRel f' P' loc_last (if P loc_last then Function.update m1 (f loc_last) (some loc_del) else m1)

Relocating loc_last into loc_del < loc_last across a full slice 0 .. loc_last (loc_last + 1 → loc_last).

theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.sliceMapRel_relocate_prefix {f f' : ℕ → ℕ} {P P' : ℕ → Prop} [DecidablePred P] {loc_del cur loc_last : ℕ} {m0 : ℕ → Option ℕ} (hrel : SliceMapRel f P cur m0) (hlt_cur : loc_del < cur) (hinj_cur : ∀ l₁ < cur, ∀ l₂ < cur, P l₁ → P l₂ → f l₁ = f l₂ → l₁ = l₂) (hno_coll : P loc_last → ∀ l < cur, l ≠ loc_del → P l → f l ≠ f loc_last) (hf_pres : ∀ loc < cur, loc ≠ loc_del → f' loc = f loc) (hf_del : f' loc_del = f loc_last) (hP_pres : ∀ loc < cur, loc ≠ loc_del → (P' loc ↔ P loc)) (hP_del : P' loc_del ↔ P loc_last) :
have m1 := if P loc_del then Function.update m0 (f loc_del) none else m0; SliceMapRel f' P' cur (if P loc_last then Function.update m1 (f loc_last) (some loc_del) else m1)

Relocating loc_last into loc_del < cur ≤ loc_last across a prefix 0 .. cur - 1, assuming no collision between f loc_last and any remaining active item < cur \ {loc_del}.

theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.bufMapRel_delete_last {M tag b₀ loc_last : ℕ} {bktCnt : ℕ → ℕ} {locSt locSt' rKeyOf rKeyOf' : ℕ → ℕ → ℕ} {m0 : ℕ → Option (ℕ × ℕ)} (hrel : BufMapRel M tag bktCnt locSt rKeyOf m0) (_hb₀ : b₀ < M) (hcnt₀ : bktCnt b₀ = loc_last + 1) (hinj : ∀ b < M, ∀ loc < bktCnt b, locSt b loc = tag → locSt b₀ loc_last = tag → rKeyOf b loc = rKeyOf b₀ loc_last → b = b₀ ∧ loc = loc_last) (hst_pres : ∀ b < M, ∀ loc < Function.update bktCnt b₀ loc_last b, locSt' b loc = locSt b loc) (hrk_pres : ∀ b < M, ∀ loc < Function.update bktCnt b₀ loc_last b, rKeyOf' b loc = rKeyOf b loc) :
BufMapRel M tag (Function.update bktCnt b₀ loc_last) locSt' rKeyOf' (if locSt b₀ loc_last = tag then Function.update m0 (rKeyOf b₀ loc_last) none else m0)

Deleting loc_last when bktCnt b₀ = loc_last + 1 shrinks to loc_last.

theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.bufMapRel_relocate_last {M tag b₀ loc_del loc_last : ℕ} {bktCnt : ℕ → ℕ} {locSt locSt' rKeyOf rKeyOf' : ℕ → ℕ → ℕ} {m0 : ℕ → Option (ℕ × ℕ)} (hrel : BufMapRel M tag bktCnt locSt rKeyOf m0) (hb₀ : b₀ < M) (hcnt₀ : bktCnt b₀ = loc_last + 1) (hlt_del : loc_del < loc_last) (hinj : ∀ b₁ < M, ∀ l₁ < bktCnt b₁, ∀ b₂ < M, ∀ l₂ < bktCnt b₂, locSt b₁ l₁ = tag → locSt b₂ l₂ = tag → rKeyOf b₁ l₁ = rKeyOf b₂ l₂ → b₁ = b₂ ∧ l₁ = l₂) (hst_pres : ∀ b < M, ∀ loc < Function.update bktCnt b₀ loc_last b, ¬(b = b₀ ∧ loc = loc_del) → locSt' b loc = locSt b loc) (hst_del : locSt' b₀ loc_del = locSt b₀ loc_last) (hrk_pres : ∀ b < M, ∀ loc < Function.update bktCnt b₀ loc_last b, ¬(b = b₀ ∧ loc = loc_del) → rKeyOf' b loc = rKeyOf b loc) (hrk_del : rKeyOf' b₀ loc_del = rKeyOf b₀ loc_last) :
have m1 := if locSt b₀ loc_del = tag then Function.update m0 (rKeyOf b₀ loc_del) none else m0; (locSt b₀ loc_last = tag → m1 (rKeyOf b₀ loc_last) = some (b₀, loc_last)) ∧ BufMapRel M tag (Function.update bktCnt b₀ loc_last) locSt' rKeyOf' (if locSt b₀ loc_last = tag then Function.update m1 (rKeyOf b₀ loc_last) (some (b₀, loc_del)) else m1)

Relocating (b₀, loc_last) into (b₀, loc_del) (loc_del < loc_last) in BufMapRel.

theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.buf_del_at_ep {c n_max st rKey ep : ℕ} (buf : ℕ → BufTrie) (hep : ep = 0 ∨ ep = 1) :
(if st = 2 then Function.update buf 0 (bufDelete (cTabWhp c) (bCharWhp n_max) (buf 0) rKey) else if st = 3 then Function.update buf 1 (bufDelete (cTabWhp c) (bCharWhp n_max) (buf 1) rKey) else buf) ep = if st = 2 + ep then bufDelete (cTabWhp c) (bCharWhp n_max) (buf ep) rKey else buf ep
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.buf_ins_at_ep {c n_max st rKey b loc ep : ℕ} (buf : ℕ → BufTrie) (hep : ep = 0 ∨ ep = 1) :
(if st = 2 then Function.update buf 0 (bufInsert (cTabWhp c) (bCharWhp n_max) (buf 0) rKey b loc) else if st = 3 then Function.update buf 1 (bufInsert (cTabWhp c) (bCharWhp n_max) (buf 1) rKey b loc) else buf) ep = if st = 2 + ep then bufInsert (cTabWhp c) (bCharWhp n_max) (buf ep) rKey b loc else buf ep
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.pool_release_last {c U V n_max b loc_last : ℕ} {θ : SeedWhp c U n_max} {fs fs' : FastState} {dict : State U} (hc : CoreFastInv c U V n_max θ fs dict) (hb : b < numBucketsWhp n_max) (hcnt : fs.bktCount b = loc_last + 1) (hbkt' : fs'.bktCount = Function.update fs.bktCount b loc_last) (hbp' : fs'.backPtr = fs.backPtr) (hown' : fs'.poolOwner = fs.poolOwner) (htop' : fs'.poolFreeTop = if capFrontWhp n_max ≤ loc_last then fs.poolFreeTop + 1 else fs.poolFreeTop) (hstk' : fs'.poolFreeStack = if capFrontWhp n_max ≤ loc_last then Function.update fs.poolFreeStack fs.poolFreeTop (fs.backPtr b (loc_last - capFrontWhp n_max)) else fs.poolFreeStack) :
fs'.poolFreeTop ≤ poolSizeWhp n_max ∧ (∀ b' < numBucketsWhp n_max, ∀ k < fs'.bktCount b' - capFrontWhp n_max, fs'.backPtr b' k < poolSizeWhp n_max ∧ fs'.poolOwner (fs'.backPtr b' k) = b' * capBackWhp n_max + k) ∧ (∀ j < fs'.poolFreeTop, fs'.poolFreeStack j < poolSizeWhp n_max) ∧ (∀ b₁ < numBucketsWhp n_max, ∀ k₁ < fs'.bktCount b₁ - capFrontWhp n_max, ∀ b₂ < numBucketsWhp n_max, ∀ k₂ < fs'.bktCount b₂ - capFrontWhp n_max, fs'.backPtr b₁ k₁ = fs'.backPtr b₂ k₂ → b₁ = b₂ ∧ k₁ = k₂) ∧ (∀ j₁ < fs'.poolFreeTop, ∀ j₂ < fs'.poolFreeTop, fs'.poolFreeStack j₁ = fs'.poolFreeStack j₂ → j₁ = j₂) ∧ (∀ b' < numBucketsWhp n_max, ∀ k < fs'.bktCount b' - capFrontWhp n_max, ∀ j < fs'.poolFreeTop, fs'.backPtr b' k ≠ fs'.poolFreeStack j) ∧ fs'.poolFreeTop + ∑ b' ∈ Finset.range (numBucketsWhp n_max), (fs'.bktCount b' - capFrontWhp n_max) = poolSizeWhp n_max

Releasing loc_last (fs.bktCount b = loc_last + 1) preserves all backyard-pool invariants.

theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.dict_map_after_delete {c U V n_max b loc_del loc_last : ℕ} {θ : SeedWhp c U n_max} {fs fs' : FastState} {dict : State U} {u : Fin U} (hc : CoreFastInv c U V n_max θ fs dict) (hb_eq : FeistelQuotient.feistelBucket (bWhp n_max) (bktHash c U n_max θ.1) ↑u = b) (hcnt : fs.bktCount b = loc_last + 1) (hld_lt : loc_del < loc_last + 1) (hq_del : fs.quotArr (FastState.physSlot n_max fs b loc_del) = FeistelQuotient.keyQuotient (bWhp n_max) ↑u) (hbkt' : fs'.bktCount = Function.update fs.bktCount b loc_last) (hother : ∀ b' < numBucketsWhp n_max, b' ≠ b → ∀ loc < fs.bktCount b', fs'.quotArr (FastState.physSlot n_max fs' b' loc) = fs.quotArr (FastState.physSlot n_max fs b' loc) ∧ fs'.valArr (FastState.physSlot n_max fs' b' loc) = fs.valArr (FastState.physSlot n_max fs b' loc)) (hfwd : ∀ loc' < loc_last, ∃ loc < loc_last + 1, loc ≠ loc_del ∧ fs'.quotArr (FastState.physSlot n_max fs' b loc') = fs.quotArr (FastState.physSlot n_max fs b loc) ∧ fs'.valArr (FastState.physSlot n_max fs' b loc') = fs.valArr (FastState.physSlot n_max fs b loc) ∧ ∀ l₂ < loc_last, fs'.quotArr (FastState.physSlot n_max fs' b loc') = fs'.quotArr (FastState.physSlot n_max fs' b l₂) → loc' = l₂) (hbwd : ∀ loc < loc_last + 1, loc ≠ loc_del → ∃ loc' < loc_last, fs'.quotArr (FastState.physSlot n_max fs' b loc') = fs.quotArr (FastState.physSlot n_max fs b loc) ∧ fs'.valArr (FastState.physSlot n_max fs' b loc') = fs.valArr (FastState.physSlot n_max fs b loc)) :
(∀ b' < numBucketsWhp n_max, ∀ l₁ < fs'.bktCount b', ∀ l₂ < fs'.bktCount b', fs'.quotArr (FastState.physSlot n_max fs' b' l₁) = fs'.quotArr (FastState.physSlot n_max fs' b' l₂) → l₁ = l₂) ∧ ∀ (u' : Fin U), have b' := FeistelQuotient.feistelBucket (bWhp n_max) (bktHash c U n_max θ.1) ↑u'; have q' := FeistelQuotient.keyQuotient (bWhp n_max) ↑u'; (Function.update dict u none u' = none ↔ ∀ loc < fs'.bktCount b', fs'.quotArr (FastState.physSlot n_max fs' b' loc) ≠ q') ∧ ∀ (v : ℕ), Function.update dict u none u' = some v ↔ ∃ loc < fs'.bktCount b', fs'.quotArr (FastState.physSlot n_max fs' b' loc) = q' ∧ fs'.valArr (FastState.physSlot n_max fs' b' loc) = v

Abstract dictionary-map and quotient-injectivity preservation under deleting (b, loc_del) and relocating (b, loc_last) (when loc_del < loc_last).

theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.buf_valid_after_delete {c U V n_max b loc_del loc_last ep : ℕ} {θ : SeedWhp c U n_max} {fs fs' : FastState} {dict : State U} {rKey_u : ℕ} (hc : CoreFastInv c U V n_max θ fs dict) (hb : b < numBucketsWhp n_max) (hcnt : fs.bktCount b = loc_last + 1) (hld_lt : loc_del < loc_last + 1) (hrk_del : FastState.rKeyAt c U n_max θ fs b loc_del = rKey_u) (hbuf0 : (fs.buf ep).itemAlloc ≤ 2 * sMaxWhp c n_max ∧ (fs.buf ep).nodeAlloc ≤ 1 + cTabWhp c * (fs.buf ep).itemAlloc ∧ ∃ (m0 : ℕ → Option (ℕ × ℕ)), ValidBufTrie (cTabWhp c) (bCharWhp n_max) (fs.buf ep) m0 ∧ BufMapRel (numBucketsWhp n_max) (2 + ep) fs.bktCount fs.locState (FastState.rKeyAt c U n_max θ fs) m0) (hbkt' : fs'.bktCount = Function.update fs.bktCount b loc_last) (hpres_eq : loc_del = loc_last → ∀ b' < numBucketsWhp n_max, ∀ loc < fs'.bktCount b', fs'.locState b' loc = fs.locState b' loc ∧ FastState.rKeyAt c U n_max θ fs' b' loc = FastState.rKeyAt c U n_max θ fs b' loc) (hpres_lt : loc_del < loc_last → (∀ b' < numBucketsWhp n_max, ∀ loc < fs'.bktCount b', ¬(b' = b ∧ loc = loc_del) → fs'.locState b' loc = fs.locState b' loc ∧ FastState.rKeyAt c U n_max θ fs' b' loc = FastState.rKeyAt c U n_max θ fs b' loc) ∧ fs'.locState b loc_del = fs.locState b loc_last ∧ FastState.rKeyAt c U n_max θ fs' b loc_del = FastState.rKeyAt c U n_max θ fs b loc_last) :
have tr1 := if fs.locState b loc_del = 2 + ep then bufDelete (cTabWhp c) (bCharWhp n_max) (fs.buf ep) rKey_u else fs.buf ep; have tr' := if loc_del < loc_last then if fs.locState b loc_last = 2 + ep then bufInsert (cTabWhp c) (bCharWhp n_max) tr1 (FastState.rKeyAt c U n_max θ fs b loc_last) b loc_del else tr1 else tr1; tr'.itemAlloc = (fs.buf ep).itemAlloc ∧ tr'.nodeAlloc = (fs.buf ep).nodeAlloc ∧ (∃ (m' : ℕ → Option (ℕ × ℕ)), ValidBufTrie (cTabWhp c) (bCharWhp n_max) tr' m' ∧ BufMapRel (numBucketsWhp n_max) (2 + ep) fs'.bktCount fs'.locState (FastState.rKeyAt c U n_max θ fs') m') ∧ (∀ (id : ℕ), bufCheckSlot (fs.buf ep) id = none → bufCheckSlot tr' id = none) ∧ ∀ (id b' loc' : ℕ), bufCheckSlot tr' id = some (b', loc') → ∃ (loc₀ : ℕ), bufCheckSlot (fs.buf ep) id = some (b', loc₀)

Parametric epoch-buffer preservation across fastDelete (applicable to both curEp and oldEp when rebStage ≤ 3).

theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.bufOld_valid_after_delete {c U V n_max b loc_del loc_last : ℕ} {θ : SeedWhp c U n_max} {fs fs' : FastState} {dict : State U} {rKey_u : ℕ} (hc : CoreFastInv c U V n_max θ fs dict) (hb : b < numBucketsWhp n_max) (hcnt : fs.bktCount b = loc_last + 1) (hld_lt : loc_del < loc_last + 1) (hrk_del : FastState.rKeyAt c U n_max θ fs b loc_del = rKey_u) (hbkt' : fs'.bktCount = Function.update fs.bktCount b loc_last) (hrs_eq : fs'.rebStage = fs.rebStage) (ho_eq : fs'.oldEp = fs.oldEp) (hbuf_old : fs'.buf fs.oldEp = have tr1 := if fs.locState b loc_del = 2 + fs.oldEp then bufDelete (cTabWhp c) (bCharWhp n_max) (fs.buf fs.oldEp) rKey_u else fs.buf fs.oldEp; if loc_del < loc_last then if fs.locState b loc_last = 2 + fs.oldEp then bufInsert (cTabWhp c) (bCharWhp n_max) tr1 (FastState.rKeyAt c U n_max θ fs b loc_last) b loc_del else tr1 else tr1) (hpres_eq : loc_del = loc_last → ∀ b' < numBucketsWhp n_max, ∀ loc < fs'.bktCount b', fs'.locState b' loc = fs.locState b' loc ∧ FastState.rKeyAt c U n_max θ fs' b' loc = FastState.rKeyAt c U n_max θ fs b' loc) (hpres_lt : loc_del < loc_last → (∀ b' < numBucketsWhp n_max, ∀ loc < fs'.bktCount b', ¬(b' = b ∧ loc = loc_del) → fs'.locState b' loc = fs.locState b' loc ∧ FastState.rKeyAt c U n_max θ fs' b' loc = FastState.rKeyAt c U n_max θ fs b' loc) ∧ fs'.locState b loc_del = fs.locState b loc_last ∧ FastState.rKeyAt c U n_max θ fs' b loc_del = FastState.rKeyAt c U n_max θ fs b loc_last) :
if fs'.rebStage ≤ 3 then (fs'.buf fs'.oldEp).itemAlloc ≤ 2 * sMaxWhp c n_max ∧ (fs'.buf fs'.oldEp).nodeAlloc ≤ 1 + cTabWhp c * (fs'.buf fs'.oldEp).itemAlloc ∧ ∃ (oldMap : ℕ → Option (ℕ × ℕ)), ValidBufTrie (cTabWhp c) (bCharWhp n_max) (fs'.buf fs'.oldEp) oldMap ∧ BufMapRel (numBucketsWhp n_max) (2 + fs'.oldEp) fs'.bktCount fs'.locState (FastState.rKeyAt c U n_max θ fs') oldMap else if fs'.rebStage = 4 then (∀ b' < numBucketsWhp n_max, ∀ loc < fs'.bktCount b', fs'.locState b' loc ≠ 2 + fs'.oldEp) ∧ ClearableBufTrie (fs'.buf fs'.oldEp) ∧ (fs'.buf fs'.oldEp).nodeAlloc ≤ 1 + cTabWhp c * (2 * sMaxWhp c n_max) else (∀ b' < numBucketsWhp n_max, ∀ loc < fs'.bktCount b', fs'.locState b' loc ≠ 2 + fs'.oldEp) ∧ (ValidBufTrie (cTabWhp c) (bCharWhp n_max) (fs'.buf fs'.oldEp) fun (x : ℕ) => none) ∧ (fs'.buf fs'.oldEp).nodeAlloc = 1 ∧ (fs'.buf fs'.oldEp).itemAlloc = 0

Unified preservation of CoreFastInv.bufOld_valid across both loc_del = loc_last and loc_del < loc_last deletion cases.

theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ModelStepAux.preTick_after_delete_of_stage2 {c U V n_max b loc_del loc_last : ℕ} {θ : SeedWhp c U n_max} {fs fs' : FastState} {dict : State U} {rKey_u : ℕ} (hc : CoreFastInv c U V n_max θ fs dict) (hpre0 : ValidEpochStagePreTick c U n_max θ fs) (hb : b < numBucketsWhp n_max) (hcnt : fs.bktCount b = loc_last + 1) (hld_lt : loc_del < loc_last + 1) (hrk_del : FastState.rKeyAt c U n_max θ fs b loc_del = rKey_u) (hbkt' : fs'.bktCount = Function.update fs.bktCount b loc_last) (hrs_eq : fs'.rebStage = fs.rebStage) (ho_eq : fs'.oldEp = fs.oldEp) (hsc_eq : fs'.stageCursor = fs.stageCursor) (hdc_eq : fs'.dirtyCount = fs.dirtyCount) (hdb_eq : fs'.dirtyBuckets = fs.dirtyBuckets) (hdi_eq : fs'.dirtyIdx = fs.dirtyIdx) (hrq_eq : fs'.rebQueued = fs.rebQueued) (hdn_eq : fs'.rebDoneFlag = fs.rebDoneFlag) (hbuf_old : fs'.buf fs.oldEp = have tr1 := if fs.locState b loc_del = 2 + fs.oldEp then bufDelete (cTabWhp c) (bCharWhp n_max) (fs.buf fs.oldEp) rKey_u else fs.buf fs.oldEp; if loc_del < loc_last then if fs.locState b loc_last = 2 + fs.oldEp then bufInsert (cTabWhp c) (bCharWhp n_max) tr1 (FastState.rKeyAt c U n_max θ fs b loc_last) b loc_del else tr1 else tr1) (hpres_eq : loc_del = loc_last → ∀ b' < numBucketsWhp n_max, ∀ loc < fs'.bktCount b', fs'.locState b' loc = fs.locState b' loc ∧ FastState.rKeyAt c U n_max θ fs' b' loc = FastState.rKeyAt c U n_max θ fs b' loc) (hpres_lt : loc_del < loc_last → (∀ b' < numBucketsWhp n_max, ∀ loc < fs'.bktCount b', ¬(b' = b ∧ loc = loc_del) → fs'.locState b' loc = fs.locState b' loc ∧ FastState.rKeyAt c U n_max θ fs' b' loc = FastState.rKeyAt c U n_max θ fs b' loc) ∧ fs'.locState b loc_del = fs.locState b loc_last ∧ FastState.rKeyAt c U n_max θ fs' b loc_del = FastState.rKeyAt c U n_max θ fs b loc_last) (hstage2 : fs.rebStage = 2 → fs'.dirtyCount ≤ 2 * sMaxWhp c n_max ∧ fs'.dirtyIdx < fs'.dirtyCount ∧ (∀ j < fs'.dirtyCount, fs'.dirtyBuckets j < numBucketsWhp n_max) ∧ (∀ j₁ < fs'.dirtyCount, ∀ j₂ < fs'.dirtyCount, fs'.dirtyBuckets j₁ = fs'.dirtyBuckets j₂ → j₁ = j₂) ∧ (∀ j < fs'.dirtyCount, (j < fs'.dirtyIdx → fs'.rebDoneFlag (fs'.dirtyBuckets j) = 1) ∧ (fs'.dirtyIdx ≤ j → fs'.rebDoneFlag (fs'.dirtyBuckets j) = 0)) ∧ (∀ b' < numBucketsWhp n_max, ∀ loc < fs'.bktCount b', fs'.locState b' loc = 2 + fs.oldEp → ∃ j < fs'.dirtyCount, fs'.dirtyBuckets j = b') ∧ (fs'.rebCandSalt < sMaxWhp c n_max → have b_cur := fs'.dirtyBuckets fs'.dirtyIdx; (fs'.rebScanCursor = 0 ∧ fs'.rebInsCount = 0 ∨ 16 ≤ fs'.rebScanCursor ∧ fs'.rebScanCursor ≤ fs'.bktCount b_cur ∧ 16 * fs'.rebInsCount ≤ 17 * fs'.rebScanCursor) ∧ (∀ l₁ < min (fs'.bktCount b_cur) fs'.rebScanCursor, ∀ l₂ < min (fs'.bktCount b_cur) fs'.rebScanCursor, fs'.locState b_cur l₁ = 1 ∨ fs'.locState b_cur l₁ = 2 + fs.oldEp → fs'.locState b_cur l₂ = 1 ∨ fs'.locState b_cur l₂ = 2 + fs.oldEp → FastState.fpAt c U n_max θ fs' fs'.rebCandSalt b_cur l₁ = FastState.fpAt c U n_max θ fs' fs'.rebCandSalt b_cur l₂ → l₁ = l₂) ∧ ∃ (rebMap : ℕ → Option ℕ), ValidWhpSlice n_max fs'.rebInsCount (fs'.slices (fs'.rebSliceIdx b_cur)) rebMap ∧ SliceMapRel (FastState.fpAt c U n_max θ fs' fs'.rebCandSalt b_cur) (fun (loc : ℕ) => fs'.locState b_cur loc = 1 ∨ fs'.locState b_cur loc = 2 + fs.oldEp) (min (fs'.bktCount b_cur) fs'.rebScanCursor) rebMap)) :
ValidEpochStagePreTick c U n_max θ fs'

Discharges Stages 0, 1, 3 (and ≥ 4) of ValidEpochStagePreTick uniformly across both fastDelete branches, leaving only Stage 2 for the caller.