Core and Pre-Tick Fast-Mode Invariants for SuccinctWhpModel #
This module defines the intermediate fast-mode invariants (CoreFastInv, PreOvermarsBucketInv,
ValidEpochStagePreTick) shared across overmarsStep, fastDelete, fastInsert, and
epochTick, together with conversion and field-congruence lemmas.
Main definitions #
Cslib.DataStructure.Dictionary.SuccinctWhp.CoreFastInv: all fields ofValidFastStateexceptovermars_validandstage_valid.Cslib.DataStructure.Dictionary.SuccinctWhp.PreOvermarsBucketInv: relaxed per-bucket Overmars invariant immediately prior toovermarsStep.Cslib.DataStructure.Dictionary.SuccinctWhp.ValidEpochStagePreTick: relaxed epoch-stage invariant betweenfastDelete/fastInsertandepochTick.
Main results #
Cslib.DataStructure.Dictionary.SuccinctWhp.ValidFastState.toCore,CoreFastInv.toValidFastState,OvermarsBucketInv.toPre,ValidEpochStage.toPreTick: conversions between full and pre-step invariants.Cslib.DataStructure.Dictionary.SuccinctWhp.fpAt_lt,keyValAt_eq_of_fields,fpAt_eq_of_fields,rKeyAt_eq_of_fields,OvermarsBucketInv.of_eq_on,OvermarsBucketInv.of_eq_lt: field-congruence helpers forFastState.
structure Cslib.DataStructure.Dictionary.SuccinctWhp.CoreFastInv (c U V n_max : ℕ) (θ : SeedWhp c U n_max) (fs : FastState) (dict : State U) :
Core fast-state invariant (all fields of ValidFastState except overmars_valid and
stage_valid), shared across intermediate pre-overmarsStep and pre-epochTick states.
- hth : whpThreshold c ≤ n_max
- rebCollision_zero : fs.rebCollision = 0
- active_item (b : ℕ) : b < numBucketsWhp n_max → ∀ loc < fs.bktCount b, let kv := FastState.keyValAt c U n_max θ.1 fs b loc; kv < U ∧ FeistelQuotient.feistelBucket (bWhp n_max) (bktHash c U n_max θ.1) kv = b ∧ FeistelQuotient.keyQuotient (bWhp n_max) kv = fs.quotArr (FastState.physSlot n_max fs b loc) ∧ fs.valArr (FastState.physSlot n_max fs b loc) < V
- quot_inj (b : ℕ) : 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₂
- dict_map (u : Fin U) : let b := FeistelQuotient.feistelBucket (bWhp n_max) (bktHash c U n_max θ.1) ↑u; let q := FeistelQuotient.keyQuotient (bWhp n_max) ↑u; (dict u = none ↔ ∀ loc < fs.bktCount b, fs.quotArr (FastState.physSlot n_max fs b loc) ≠ q) ∧ ∀ (v : ℕ), dict 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
- backPtr_valid (b : ℕ) : 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
- backPtr_inj (b₁ : ℕ) : 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₂
- freeStack_inj (j₁ : ℕ) : j₁ < fs.poolFreeTop → ∀ j₂ < fs.poolFreeTop, fs.poolFreeStack j₁ = fs.poolFreeStack j₂ → j₁ = j₂
- back_free_disj (b : ℕ) : b < numBucketsWhp n_max → ∀ k < fs.bktCount b - capFrontWhp n_max, ∀ j < fs.poolFreeTop, fs.backPtr b k ≠ fs.poolFreeStack j
- pool_conservation : fs.poolFreeTop + ∑ b ∈ Finset.range (numBucketsWhp n_max), (fs.bktCount b - capFrontWhp n_max) = poolSizeWhp n_max
- roles_valid (b : ℕ) : b < numBucketsWhp n_max → fs.liveRole b < 3 ∧ fs.overmarsRole b < 3 ∧ fs.liveRole b ≠ fs.overmarsRole b
- live_fp_inj (b : ℕ) : b < numBucketsWhp n_max → ∀ l₁ < fs.bktCount b, ∀ l₂ < fs.bktCount b, inLiveTree fs.rebStage fs.oldEp (fs.rebDoneFlag b) (fs.locState b l₁) = true → inLiveTree fs.rebStage fs.oldEp (fs.rebDoneFlag b) (fs.locState b l₂) = true → FastState.fpAt c U n_max θ fs (fs.bktSalt b) b l₁ = FastState.fpAt c U n_max θ fs (fs.bktSalt b) b l₂ → l₁ = l₂
- live_valid (b : ℕ) : b < numBucketsWhp n_max → ∃ (liveMap : ℕ → Option ℕ), ValidWhpSlice n_max (fs.liveInsCount b) (fs.slices (fs.liveSliceIdx b)) liveMap ∧ SliceMapRel (FastState.fpAt c U n_max θ fs (fs.bktSalt b) b) (fun (loc : ℕ) => inLiveTree fs.rebStage fs.oldEp (fs.rebDoneFlag b) (fs.locState b loc) = true) (fs.bktCount b) liveMap
- rKey_buf_inj (b₁ : ℕ) : b₁ < numBucketsWhp n_max → ∀ l₁ < fs.bktCount b₁, ∀ b₂ < numBucketsWhp n_max, ∀ l₂ < fs.bktCount b₂, 2 ≤ fs.locState b₁ l₁ → 2 ≤ fs.locState b₂ l₂ → FastState.rKeyAt c U n_max θ fs b₁ l₁ = FastState.rKeyAt c U n_max θ fs b₂ l₂ → b₁ = b₂ ∧ l₁ = l₂
- bufCur_valid : (fs.buf fs.curEp).itemAlloc ≤ 2 * sMaxWhp c n_max ∧ (fs.buf fs.curEp).nodeAlloc ≤ 1 + cTabWhp c * (fs.buf fs.curEp).itemAlloc ∧ ∃ (curMap : ℕ → Option (ℕ × ℕ)), ValidBufTrie (cTabWhp c) (bCharWhp n_max) (fs.buf fs.curEp) curMap ∧ BufMapRel (numBucketsWhp n_max) (2 + fs.curEp) fs.bktCount fs.locState (FastState.rKeyAt c U n_max θ fs) curMap
- bufOld_valid : 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
def Cslib.DataStructure.Dictionary.SuccinctWhp.ValidEpochStagePreTick (c U n_max : ℕ) (θ : SeedWhp c U n_max) (fs : FastState) :
Stage invariant between fastDelete and epochTick (relaxing rebScanCursor < bktCount b_cur
to ≤ and removing the + 16 slack in 16 * rebInsCount ≤ 17 * rebScanCursor until epochTick
scans the next 16 slots).
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ValidFastState.toCore {c U V n_max : ℕ} {θ : SeedWhp c U n_max} {fs : FastState} {dict : State U} (hv : ValidFastState c U V n_max θ fs dict) :
CoreFastInv c U V n_max θ fs dict
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.CoreFastInv.toValidFastState {c U V n_max : ℕ} {θ : SeedWhp c U n_max} {fs : FastState} {dict : State U} (hc : CoreFastInv c U V n_max θ fs dict) (hom : ∀ b < numBucketsWhp n_max, OvermarsBucketInv c U n_max θ fs b) (hst : ValidEpochStage c U n_max θ fs) :
ValidFastState c U V n_max θ fs dict
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.OvermarsBucketInv.toPre {c U n_max : ℕ} {θ : SeedWhp c U n_max} {fs : FastState} {b : ℕ} (h : OvermarsBucketInv c U n_max θ fs b) :
PreOvermarsBucketInv c U n_max θ fs b
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.ValidEpochStage.toPreTick {c U n_max : ℕ} {θ : SeedWhp c U n_max} {fs : FastState} (h : ValidEpochStage c U n_max θ fs) :
ValidEpochStagePreTick c U n_max θ fs
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.fpAt_lt {c U n_max : ℕ} (θ : SeedWhp c U n_max) (fs : FastState) (salt b loc : ℕ) :
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.OvermarsBucketInv.of_eq_on {c U n_max : ℕ} {θ : SeedWhp c U n_max} {fs fs' : FastState} {b : ℕ} (h : OvermarsBucketInv c U n_max θ fs b) (hfp : FastState.fpAt c U n_max θ fs' (fs'.bktSalt b) b = FastState.fpAt c U n_max θ fs (fs.bktSalt b) b) (hst : fs'.rebStage = fs.rebStage) (hep : fs'.curEp = fs.curEp) (hdn : fs'.rebDoneFlag b = fs.rebDoneFlag b) (hls : fs'.locState b = fs.locState b) (hcnt : fs'.bktCount b = fs.bktCount b) (hlic : fs'.liveInsCount b = fs.liveInsCount b) (hoa : fs'.overmarsActive b = fs.overmarsActive b) (hoc : fs'.overmarsCursor b = fs.overmarsCursor b) (hoi : fs'.overmarsInsCount b = fs.overmarsInsCount b) (hsl : fs'.slices (fs'.overmarsSliceIdx b) = fs.slices (fs.overmarsSliceIdx b)) :
OvermarsBucketInv c U n_max θ fs' b
theorem Cslib.DataStructure.Dictionary.SuccinctWhp.OvermarsBucketInv.of_eq_lt {c U n_max : ℕ} {θ : SeedWhp c U n_max} {fs fs' : FastState} {b : ℕ} (h : OvermarsBucketInv c U n_max θ fs b) (hsalt : fs'.bktSalt b = fs.bktSalt b) (hfp :
∀ loc < fs.bktCount b,
FastState.fpAt c U n_max θ fs' (fs.bktSalt b) b loc = FastState.fpAt c U n_max θ fs (fs.bktSalt b) b loc) (hst : fs'.rebStage = fs.rebStage) (hep : fs'.curEp = fs.curEp) (hdn : fs'.rebDoneFlag b = fs.rebDoneFlag b) (hls : ∀ loc < fs.bktCount b, fs'.locState b loc = fs.locState b loc) (hcnt : fs.bktCount b ≤ fs'.bktCount b) (hlic : fs'.liveInsCount b = fs.liveInsCount b) (hoa : fs'.overmarsActive b = fs.overmarsActive b) (hoc : fs'.overmarsCursor b = fs.overmarsCursor b) (hoi : fs'.overmarsInsCount b = fs.overmarsInsCount b) (hsl : fs'.slices (fs'.overmarsSliceIdx b) = fs.slices (fs.overmarsSliceIdx b)) :
OvermarsBucketInv c U n_max θ fs' b