Documentation

CslibFrontier.DataStructure.Dictionary.SubconstantRedundancy.TreeModel

Pure Multi-Level Subconstant-Redundancy Dictionary Tree Model #

This module serves as the top-level entry point for the pure multi-level dictionary tree of Tianxiao Li, Jingxun Liang, Huacheng Yu, and Renfei Zhou, Dynamic Dictionary with Subconstant Wasted Bits per Key ([LiLiangYuZhou2024, Section 5, Sections 5.1–5.6]; arXiv:2310.20536v1, PDF pp. 25–36 / printed pp. 24–35).

It publicly re-exports the parameter schedule and infoBits + O(R) bit budget (Params.lean), pure node-level storage structures and Section 5.6 metadata separation (StorageNode.lean), sentinel-padded routing (TreeRouting.lean), tree invariants and Section 5.6 DFS subtree metadata (TreeCore.lean), canonical tree construction and good-seed existence (TreeBuild.lean), root-to-leaf query and rawOverwrite (TreeQuery.lean), normal-path insertion (TreeInsert.lean), Algorithm 3 (deleteAndGetQuotient, PDF p. 31 / printed p. 30, TreeDelete.lean), and the pure reconstruction/local-splice step of Algorithm 4 under supplied validated seeds (rehashSubtree, PDF p. 34 / printed p. 33, TreeRehash.lean).

In addition, this file provides:

  1. Internal single-key padded updates rawInsertFresh and rawDeleteMem combining localized subtree reconstruction (TreeState.rehashSubtree, exists_allGoodSeeds_localized_pair) with the normal O(depth) update path (normalInsertFresh, normalDeleteMem) under their fresh-key / member-key raw contracts.
  2. The external dictionary interface TreeSchedule.initTree, TreeState.insert, and TreeState.delete maintaining sentinel padding (|S_padded| ∈ {cap - 1, cap}, Section 4, Footnote 5, PDF p. 12 / printed p. 11; Section 5, PDF p. 26 / printed p. 25) and satisfying the exact Dictionary.State Function.update laws (query_initTree, query_insert, query_delete). On valid (WellFormed) states, absent external delete and capacity-rejected fresh external insert are guarded no-ops; arbitrary malformed states and raw-helper calls carry no blanket no-op guarantee.

Formalization adaptations and explicit scope boundaries #

Main definitions #

Main results #

References #

Section 1: Internal padded updates with localized subtree seed repair #

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.not_isGoodNodeSeed_at_changed {P : TreeSchedule} {seeds : P.SeedAssignment} {S_cur S' : Finset (Fin P.paddedUniv)} {z : Fin P.paddedUniv} (hgood : seeds.AllGoodSeeds S_cur) (hdiff_z : ∀ (y : Fin P.paddedUniv), (y ∈ S' ↔ y ∈ S_cur) ∨ y = z) {ℓ₀ : ℕ} (hℓ₀ : ℓ₀ ≤ P.depth) {w_bad : Fin (P.numNodes ℓ₀)} (hw_bad : ¬P.IsGoodNodeSeed ℓ₀ (seeds.seed ℓ₀ hℓ₀ w_bad) (seeds.primSetAt S' ℓ₀ hℓ₀ w_bad)) :
¬P.IsGoodNodeSeed ℓ₀ (seeds.seed ℓ₀ hℓ₀ (seeds.nodeAt ℓ₀ hℓ₀ z)) (seeds.primSetAt S' ℓ₀ hℓ₀ (seeds.nodeAt ℓ₀ hℓ₀ z))

Internal fresh-key insertion on st (contract: WellFormedPadded, x ∉ paddedDom d, and #S' ∈ [nLow 0, nHigh 0]): runs normalInsertFresh when st.seeds stays good on Insert.insert x S, and otherwise invokes st.rehashSubtree (the pure reconstruction/local-splice step of Algorithm 4) at the highest failing node (ℓ₀, nodeAt ℓ₀ x) using Classical.choose to supply validated replacement seeds, followed by normalInsertFresh. Carries no blanket no-op guarantee on arbitrary malformed states.

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.wellFormedPadded_rawInsertFresh {P : TreeSchedule} (hcr : P.ConcentrationReady) {scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)} {st : P.TreeState} {d : P.PaddedDict} {storeLvl : Fin P.paddedUniv → ℕ} (hwf : WellFormedPadded scheme st d storeLvl) {x : Fin P.paddedUniv} (hx_fresh : x ∉ P.paddedDom d) (v : Fin P.valBound) (hcard' : P.nLow 0 ≤ (Insert.insert x (P.paddedDom d)).card ∧ (Insert.insert x (P.paddedDom d)).card ≤ P.nHigh 0) :
have st' := rawInsertFresh hcr scheme st x v; st'.sentCount = st.sentCount ∧ (st'.seeds = st.seeds ∨ ∃ (ℓ₀ : ℕ) (hℓ₀ : ℓ₀ ≤ P.depth), ¬P.IsGoodNodeSeed ℓ₀ (st.seeds.seed ℓ₀ hℓ₀ (st.seeds.nodeAt ℓ₀ hℓ₀ x)) (st.seeds.primSetAt (Insert.insert x (P.paddedDom d)) ℓ₀ hℓ₀ (st.seeds.nodeAt ℓ₀ hℓ₀ x)) ∧ ∀ (j : ℕ) (hj : j ≤ P.depth) (w : Fin (P.numNodes j)), ¬P.InSubtree ℓ₀ (st.seeds.nodeAt ℓ₀ hℓ₀ x) j w → st'.seeds.seed j hj w = st.seeds.seed j hj w) ∧ ∃ (storeLvl' : Fin P.paddedUniv → ℕ), WellFormedPadded scheme st' (Function.update d x (some v)) storeLvl'

Internal member-only deletion on st (contract: WellFormedPadded, z ∈ paddedDom d, and #S' ∈ [nLow 0, nHigh 0]): runs normalDeleteMem (Algorithm 3) when st.seeds stays good on S.erase z, and otherwise invokes st.rehashSubtree (the pure reconstruction/local-splice step of Algorithm 4) at (ℓ₀, nodeAt ℓ₀ z) using Classical.choose to supply validated replacement seeds, followed by normalDeleteMem. Because the AllGoodSeeds S' branch runs normalDeleteMem by compressed ID without checking membership or WellFormedPadded, this raw helper is not a no-op on absent keys or malformed states (external TreeState.delete guards exact membership first).

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.wellFormedPadded_rawDeleteMem {P : TreeSchedule} (hcr : P.ConcentrationReady) {scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)} {st : P.TreeState} {d : P.PaddedDict} {storeLvl : Fin P.paddedUniv → ℕ} (hwf : WellFormedPadded scheme st d storeLvl) {z : Fin P.paddedUniv} (hz : z ∈ P.paddedDom d) (hcard' : P.nLow 0 ≤ ((P.paddedDom d).erase z).card ∧ ((P.paddedDom d).erase z).card ≤ P.nHigh 0) :
have st' := rawDeleteMem hcr scheme st z; st'.sentCount = st.sentCount ∧ (st'.seeds = st.seeds ∨ ∃ (ℓ₀ : ℕ) (hℓ₀ : ℓ₀ ≤ P.depth), ¬P.IsGoodNodeSeed ℓ₀ (st.seeds.seed ℓ₀ hℓ₀ (st.seeds.nodeAt ℓ₀ hℓ₀ z)) (st.seeds.primSetAt ((P.paddedDom d).erase z) ℓ₀ hℓ₀ (st.seeds.nodeAt ℓ₀ hℓ₀ z)) ∧ ∀ (j : ℕ) (hj : j ≤ P.depth) (w : Fin (P.numNodes j)), ¬P.InSubtree ℓ₀ (st.seeds.nodeAt ℓ₀ hℓ₀ z) j w → st'.seeds.seed j hj w = st.seeds.seed j hj w) ∧ ∃ (storeLvl' : Fin P.paddedUniv → ℕ), WellFormedPadded scheme st' (Function.update d z none) storeLvl'
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.WellFormedPadded.withSentCount {P : TreeSchedule} {scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)} {st : P.TreeState} {d : P.PaddedDict} {storeLvl : Fin P.paddedUniv → ℕ} (hwf : WellFormedPadded scheme st d storeLvl) (sc : ℕ) :
WellFormedPadded scheme { topSeed := st.topSeed, roots := st.roots, inner := st.inner, leaves := st.leaves, sentCount := sc } d storeLvl

Section 2: External Dictionary Interface (initTree, insert, delete) #

Initialize an empty external dictionary (Dictionary.empty P.univ) padded with P.cap sentinel keys (Section 4, Footnote 5 & Section 5).

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.MatchesExternal.insert_fresh_lt {P : TreeSchedule} {d : P.PaddedDict} {sc : ℕ} {dict : State P.univ} (hm : P.MatchesExternal d sc dict) {u : Fin P.univ} (hx_fresh : P.embedReal u ∉ P.paddedDom d) (hlt_pad : (P.paddedDom d).card < P.cap) (v : Fin P.valBound) :
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.MatchesExternal.insert_fresh_full {P : TreeSchedule} {d : P.PaddedDict} {sc : ℕ} {dict : State P.univ} (hm : P.MatchesExternal d sc dict) {u : Fin P.univ} (hx_fresh : P.embedReal u ∉ P.paddedDom d) (hnot_lt : ¬(P.paddedDom d).card < P.cap) (hsc : 0 < sc ∧ sc ≤ P.cap) (v : Fin P.valBound) :
have s_last := P.sentinelKey ⟨sc - 1, ⋯⟩; P.MatchesExternal (Function.update (Function.update d s_last none) (P.embedReal u) (some v)) (sc - 1) (Function.update dict u (some ↑v))
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.MatchesExternal.delete_lt {P : TreeSchedule} {d : P.PaddedDict} {sc : ℕ} {dict : State P.univ} (hm : P.MatchesExternal d sc dict) {u : Fin P.univ} (hx_dom : P.embedReal u ∈ P.paddedDom d) (hnot_ge : ¬P.cap ≤ (P.paddedDom d).card) (hsc_lt : sc < P.cap) :
have s_new := P.sentinelKey ⟨sc, hsc_lt⟩; P.MatchesExternal (Function.update (Function.update d s_new (some ⟨0, ⋯⟩)) (P.embedReal u) none) (sc + 1) (Function.update dict u none)

Insert or overwrite external key u : Fin P.univ with bounded value v : Fin P.valBound, maintaining sentinel padding in {cap - 1, cap} (Section 5.3). On valid (WellFormed) states, fresh insertion at full capacity ((dom dict).card = P.cap, where sentCount = 0 and #(paddedDom d) = P.cap) is a guarded no-op via the final else branch; arbitrary malformed states have no blanket no-op guarantee. Uses Classical.choose inside rawInsertFresh / rawDeleteMem to select validated replacement seeds on subtree-reconstruction branches.

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.wellFormed_insert {P : TreeSchedule} (hcr : P.ConcentrationReady) {scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)} {st : P.TreeState} {dict : State P.univ} (hwf : WellFormed scheme st dict) (u : Fin P.univ) (v : Fin P.valBound) (hcap : u ∈ dom dict ∨ (dom dict).card < P.cap) :
WellFormed scheme (insert hcr scheme st u v) (Function.update dict u (some ↑v))

External insert preserves WellFormed (either overwriting an existing key u ∈ dom dict or inserting a fresh key when (dom dict).card < P.cap).

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.query_insert {P : TreeSchedule} (hcr : P.ConcentrationReady) {scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)} {st : P.TreeState} {dict : State P.univ} (hwf : WellFormed scheme st dict) (u : Fin P.univ) (v : Fin P.valBound) (hcap : u ∈ dom dict ∨ (dom dict).card < P.cap) (u' : Fin P.univ) :
query scheme (insert hcr scheme st u v) u' = Function.update (query scheme st) u (some ↑v) u'

Lookup after insert satisfies Function.update.

Delete external key u : Fin P.univ, maintaining sentinel padding in {cap - 1, cap} (Section 5.3 & Algorithm 3). On valid (WellFormed) states, deleting an absent key is a guarded no-op via the exact rawQuery membership check before invoking member-only rawDeleteMem; arbitrary malformed states have no blanket no-op guarantee. Uses Classical.choose inside rawInsertFresh / rawDeleteMem to select validated replacement seeds on subtree-reconstruction branches.

External delete preserves WellFormed.

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.query_delete {P : TreeSchedule} (hcr : P.ConcentrationReady) {scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)} {st : P.TreeState} {dict : State P.univ} (hwf : WellFormed scheme st dict) (u u' : Fin P.univ) :
query scheme (delete hcr scheme st u) u' = Function.update (query scheme st) u none u'

Lookup after delete satisfies Function.update.