Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctDeleteOps

Bucket-Level Dictionary Deletion (deletePrepProg, deleteFinishProg) in Memory.Prog #

This module realizes the two-phase bucket-level deletion of the fixed-capacity succinct dictionary in Memory.Prog via realize:

Main definitions #

Main results #

Section 1: deletePrepProg via realize #

Parameter-free Phase 1 of delete (d = (dp, (((base, b), q_target), m))): searches bucket b for q_target; if found (searchResFound res = 1), resolves the last slot phys_last of bucket b, reads its quotient q_last, and returns (res, q_last); otherwise returns (((0, 0), 0), 0).

Phase 1 of delete (d = (((base, b), q_target), m)): searches bucket b for q_target; if found (res.1.1 = 1), resolves the last slot phys_last of bucket b, reads its quotient q_last, and returns (res, q_last); otherwise returns (((0, 0), 0), 0).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.deletePrepGenProg_mk (U V w n_max h_space : ℕ) (d : ((ℕ × ℕ) × ℕ) × ℕ) :
deletePrepGenProg (mkDictParams U V w n_max h_space, d) = deletePrepProg U V w n_max h_space d
@[reducible, inline]

Search header (found, j_del) in a deletePrepProg result (((found, j_del), phys_del), q_last).

@[reducible, inline]

Found flag (1 if found, 0 otherwise) in a deletePrepProg result (((found, j_del), phys_del), q_last).

@[reducible, inline]

Bucket-local slot index j_del in a deletePrepProg result (((found, j_del), phys_del), q_last).

@[reducible, inline]

Physical slot phys_del in a deletePrepProg result (((found, j_del), phys_del), q_last).

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.deletePrepProg_bucket_spec {U V w₀ n_max h_space w base b q_target m : ℕ} {mOf : ℕ → ℕ} {L : ℕ → ℕ → List ℕ} {B : ℕ → ℕ → Option ℕ} {s : Memory.State} (hinv : BucketStateInv U V w₀ n_max h_space base mOf L B s) (henv : DictEnvGen w (mkDictParams U V w₀ n_max h_space) base) (hb : b < FeistelQuotient.numBuckets n_max) (hm_eq : m = mOf q_target) (hm_lt : m < SuccinctBucket.numMicroPerBucket n_max) :
have gm := gmAt base U V w₀ n_max h_space s.mem; have d := (((base, b), q_target), m); have prog := deletePrepProg U V w₀ n_max h_space d; have prep := (Memory.spec 0).clientResult s prog; (Memory.spec 0).clientState s prog = s ∧ WordRAM.Realization.memoryCost prog s ≤ 16 + 8 * (L b m).length + 6 * (bCount n_max gm b - SuccinctBucket.effBucketCap n_max) ∧ prep.2 < 2 ^ FeistelQuotient.quotientBits U n_max ∧ if ∃ j < bCount n_max gm b, quotAt base U w₀ n_max h_space s.mem (slotOf n_max gm b j) = q_target then deletePrepFound prep = 1 ∧ deletePrepIdx prep < bCount n_max gm b ∧ quotAt base U w₀ n_max h_space s.mem (slotOf n_max gm b (deletePrepIdx prep)) = q_target ∧ deletePrepPhys prep = slotOf n_max gm b (deletePrepIdx prep) ∧ prep.2 = quotAt base U w₀ n_max h_space s.mem (slotOf n_max gm b (bCount n_max gm b - 1)) else deletePrepFound prep = 0 ∧ prep.2 = 0

Specification of deletePrepProg under BucketStateInv when m = mOf q_target.

Section 2: deleteSwapProg, deleteFoundProg, and deleteFinishProg via realize #

@[reducible, inline]

Logical index j_del of the deleted slot in ((((base, b), j_del), phys_del), extra).

@[reducible, inline]

Physical slot phys_del of the deleted slot in ((((base, b), j_del), phys_del), extra).

@[reducible, inline]

Target slot descriptor (((base, b), j_del), phys_del) in a delete-slot input.

@[reducible, inline]

Micro-bucket m_last of the relocated last slot in a deleteSwapProg input.

@[reducible, inline]

Logical index j_last of the relocated last slot in a deleteSwapProg input.

Parameter-free swap helper for delete when j_del < j_last (d = (dp, ((((base, b), j_del), phys_del), (m_last, j_last)))).

Swap helper for delete when j_del < j_last (d = ((((base, b), j_del), phys_del), (m_last, j_last))): unlinks j_last from (b, m_last) (if indexed), copies (q_last, v_last) into phys_del, and prepends j_del to (b, m_last) (if indexed).

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.deleteSwapGenProg_mk (U V w n_max h_space : ℕ) (d : (((ℕ × ℕ) × ℕ) × ℕ) × ℕ × ℕ) :
deleteSwapGenProg (mkDictParams U V w n_max h_space, d) = deleteSwapProg U V w n_max h_space d

Precondition for deleteSwapProg in Realizes.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.deleteSwapGenPre_mk (U V w₀ n_max h_space w : ℕ) (d : (((ℕ × ℕ) × ℕ) × ℕ) × ℕ × ℕ) (s : Memory.State) :
DeleteSwapGenPre w (mkDictParams U V w₀ n_max h_space, d) s ↔ DeleteSwapPre U V w₀ n_max h_space w d s
@[reducible, inline]

Micro-bucket m of the deleted slot in a deleteFoundProg input.

@[reducible, inline]

Micro-bucket m_last of the bucket's last slot in a deleteFoundProg input.

Parameter-free found-branch helper for delete (d = (dp, ((((base, b), j_del), phys_del), (m, m_last)))).

Found-branch helper for delete (d = ((((base, b), j_del), phys_del), (m, m_last))): unlinks j_del from (b, m), reads c_b, runs deleteSwapProg if j_del < c_b - 1, and calls popBackSlotProg.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.deleteFoundGenProg_mk (U V w n_max h_space : ℕ) (d : (((ℕ × ℕ) × ℕ) × ℕ) × ℕ × ℕ) :
deleteFoundGenProg (mkDictParams U V w n_max h_space, d) = deleteFoundProg U V w n_max h_space d

Precondition for deleteFoundProg in Realizes.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.deleteFoundGenPre_mk (U V w₀ n_max h_space w : ℕ) (d : (((ℕ × ℕ) × ℕ) × ℕ) × ℕ × ℕ) (s : Memory.State) :
DeleteFoundGenPre w (mkDictParams U V w₀ n_max h_space, d) s ↔ DeleteFoundPre U V w₀ n_max h_space w d s
@[reducible, inline]

Base address base in a deleteFinishProg input (((((base, b), (found, j_del)), phys_del), m), m_last).

@[reducible, inline]

Base-and-bucket pair (base, b) in a deleteFinishProg input.

@[reducible, inline]

Found flag found in a deleteFinishProg input.

@[reducible, inline]

Logical index j_del in a deleteFinishProg input.

@[reducible, inline]

Physical slot phys_del in a deleteFinishProg input.

@[reducible, inline]

Micro-bucket m in a deleteFinishProg input.

@[reducible, inline]

Extract the deleteFoundProg input ((((base, b), j_del), phys_del), (m, m_last)) from a deleteFinishProg input.

Parameter-free Phase 2 of delete (d = (dp, (((((base, b), (found, j_del)), phys_del), m), m_last))).

Phase 2 of delete (d = ((((base, b), (found, j_del)), phys_del), m), m_last): if found = 1, calls deleteFoundProg; otherwise returns ().

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.deleteFinishGenProg_mk (U V w n_max h_space : ℕ) (d : ((((ℕ × ℕ) × ℕ × ℕ) × ℕ) × ℕ) × ℕ) :
deleteFinishGenProg (mkDictParams U V w n_max h_space, d) = deleteFinishProg U V w n_max h_space d

Precondition for deleteFinishProg in Realizes.

@[simp]
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.deleteFinishGenPre_mk (U V w₀ n_max h_space w : ℕ) (d : ((((ℕ × ℕ) × ℕ × ℕ) × ℕ) × ℕ) × ℕ) (s : Memory.State) :
DeleteFinishGenPre w (mkDictParams U V w₀ n_max h_space, d) s ↔ DeleteFinishPre U V w₀ n_max h_space w d s
theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.deleteFinishProg_bucket_spec {U V w₀ n_max h_space w base b q_target m : ℕ} {mOf : ℕ → ℕ} {L : ℕ → ℕ → List ℕ} {B : ℕ → ℕ → Option ℕ} {s : Memory.State} (hw : 0 < w₀) (hinv : BucketStateInv U V w₀ n_max h_space base mOf L B s) (henv : DictEnvGen w (mkDictParams U V w₀ n_max h_space) base) (hb : b < FeistelQuotient.numBuckets n_max) (hm_eq : m = mOf q_target) (hm_lt : m < SuccinctBucket.numMicroPerBucket n_max) (hmOf_lt : ∀ q < 2 ^ FeistelQuotient.quotientBits U n_max, mOf q < SuccinctBucket.numMicroPerBucket n_max) :
have gm₀ := gmAt base U V w₀ n_max h_space s.mem; have prep := (Memory.spec 0).clientResult s (deletePrepProg U V w₀ n_max h_space (((base, b), q_target), m)); have m_last := mOf prep.2; have d_fin := (((((base, b), deletePrepHdr prep), deletePrepPhys prep), m), m_last); have s' := (Memory.spec 0).clientState s (deleteFinishProg U V w₀ n_max h_space d_fin); have gm' := gmAt base U V w₀ n_max h_space s'.mem; have B' := Function.update B b (Function.update (B b) q_target none); DeleteFinishPre U V w₀ n_max h_space w d_fin s ∧ s'.frontier = s.frontier ∧ (∀ (a : ℕ), ¬(base + offQuot h_space ≤ a ∧ a < base + totalSpace U V w₀ n_max h_space) → s'.mem a = s.mem a) ∧ (∃ (L' : ℕ → ℕ → List ℕ), BucketStateInv U V w₀ n_max h_space base mOf L' B' s') ∧ (totalSlots n_max gm' = if (B b q_target).isSome = true then totalSlots n_max gm₀ - 1 else totalSlots n_max gm₀) ∧ WordRAM.Realization.memoryCost (deleteFinishProg U V w₀ n_max h_space d_fin) s + 66 * slotPotential n_max gm' ≤ 66 * slotPotential n_max gm₀ + 240

Pure state effect, BucketStateInv preservation, and amortized memoryCost bound of deleteFinishProg following deletePrepProg under BucketStateInv.