Documentation

CslibFrontier.DataStructure.Dictionary.SubconstantRedundancy.TreeQuery

Root-to-Leaf Query and In-Place Payload Overwrite #

This file formalizes deterministic root-to-leaf lookup (rawQuery, query) and in-place value overwrite (overwriteAtNode, rawOverwrite) for the subconstant-redundancy dictionary tree of Tianxiao Li, Jingxun Liang, Huacheng Yu, and Renfei Zhou, Dynamic Dictionary with Subconstant Wasted Bits per Key ([LiLiangYuZhou2024, Section 5.3]; arXiv:2310.20536v1, PDF pp. 30–31 / printed pp. 29–30).

Main definitions #

Main results #

References #

Section 1: Iterative root-to-leaf query (rawQuery and query) #

@[irreducible]

Iterative root-to-leaf query loop starting from c : P.LevelCoord ℓ (Section 5.3).

Look up an internal key x : Fin P.paddedUniv along its root-to-leaf coordinate path.

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.nodeQuery_match_iff {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) {ℓ : ℕ} (h1 : 1 ≤ ℓ) (hℓ : ℓ ≤ P.depth) (x : Fin P.paddedUniv) :
(match nodeQuery scheme st ℓ h1 hℓ (st.seeds.nodeAt ℓ hℓ x) (st.seeds.idAt ℓ h1 hℓ x) with | some (q, v) => if (q == st.seeds.quotAt ℓ h1 hℓ x) = true then some v else none | none => none) = if storeLvl x = ℓ then d x else none
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.rawQuery_eq {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) (x : Fin P.paddedUniv) :
rawQuery scheme st x = d x

Internal query correctness: st.rawQuery scheme x = d x for every x : Fin P.paddedUniv (both active and absent, Section 5.3 & Footnote 10, PDF p. 30 / printed p. 29).

Deterministic external dictionary lookup u : Fin P.univ → Option ℕ (Section 5.3).

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.query_eq_apply {P : TreeSchedule} {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) :
query scheme st u = dict u

External query correctness: under st.WellFormed scheme dict, st.query scheme u = dict u for every u : Fin P.univ.

Section 2: Uniform node overwrite and rawOverwrite #

Overwrite (quot, val) of an ID k at (L, uL) (1 ≤ L ≤ depth), acting as identity if k ∉ st.nodeDom L h1L hLL uL.

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.seeds_overwriteAtNode {P : TreeSchedule} (scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)) (st : P.TreeState) {L : ℕ} (h1L : 1 ≤ L) (hLL : L ≤ P.depth) (uL : Fin (P.numNodes L)) (k : Fin (2 ^ P.idBits L)) (qv : Fin (P.quotUniv L) × Fin P.valBound) :
(overwriteAtNode scheme st L h1L hLL uL k qv).seeds = st.seeds
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.sentCount_overwriteAtNode {P : TreeSchedule} (scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)) (st : P.TreeState) {L : ℕ} (h1L : 1 ≤ L) (hLL : L ≤ P.depth) (uL : Fin (P.numNodes L)) (k : Fin (2 ^ P.idBits L)) (qv : Fin (P.quotUniv L) × Fin P.valBound) :
(overwriteAtNode scheme st L h1L hLL uL k qv).sentCount = st.sentCount
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.nodeDom_overwriteAtNode {P : TreeSchedule} (scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)) (st : P.TreeState) {L : ℕ} (h1L : 1 ≤ L) (hLL : L ≤ P.depth) (uL : Fin (P.numNodes L)) (k : Fin (2 ^ P.idBits L)) (qv : Fin (P.quotUniv L) × Fin P.valBound) {ℓ : ℕ} (h1 : 1 ≤ ℓ) (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) :
(overwriteAtNode scheme st L h1L hLL uL k qv).nodeDom ℓ h1 hℓ u = st.nodeDom ℓ h1 hℓ u
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.nodeWait_overwriteAtNode {P : TreeSchedule} (scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)) (st : P.TreeState) {L : ℕ} (h1L : 1 ≤ L) (hLL : L ≤ P.depth) (uL : Fin (P.numNodes L)) (k : Fin (2 ^ P.idBits L)) (qv : Fin (P.quotUniv L) × Fin P.valBound) {ℓ : ℕ} (h2 : 2 ≤ ℓ) (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) :
(overwriteAtNode scheme st L h1L hLL uL k qv).nodeWait ℓ h2 hℓ u = st.nodeWait ℓ h2 hℓ u
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.nodeQuery_overwriteAtNode_same {P : TreeSchedule} (scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)) (st : P.TreeState) {L : ℕ} (h1L : 1 ≤ L) (hLL : L ≤ P.depth) (uL : Fin (P.numNodes L)) (k k' : Fin (2 ^ P.idBits L)) (qv : Fin (P.quotUniv L) × Fin P.valBound) (hk : k ∈ st.nodeDom L h1L hLL uL) :
nodeQuery scheme (overwriteAtNode scheme st L h1L hLL uL k qv) L h1L hLL uL k' = Function.update (nodeQuery scheme st L h1L hLL uL) k (some qv) k'
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.nodeQuery_overwriteAtNode_other {P : TreeSchedule} (scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)) (st : P.TreeState) {L : ℕ} (h1L : 1 ≤ L) (hLL : L ≤ P.depth) (uL : Fin (P.numNodes L)) (k : Fin (2 ^ P.idBits L)) (qv : Fin (P.quotUniv L) × Fin P.valBound) {ℓ : ℕ} (h1 : 1 ≤ ℓ) (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) (k' : Fin (2 ^ P.idBits ℓ)) (hdiff : ∀ (h_eq : ℓ = L), h_eq ▸ u ≠ uL) :
nodeQuery scheme (overwriteAtNode scheme st L h1L hLL uL k qv) ℓ h1 hℓ u k' = nodeQuery scheme st ℓ h1 hℓ u k'
@[irreducible]
noncomputable def Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.rawOverwriteLoop {P : TreeSchedule} (scheme : DynamicMatching.Scheme (2 ^ P.idBits P.depth) (P.nLow P.depth)) (st : P.TreeState) (v_new : Fin P.valBound) (ℓ : ℕ) (h1 : 1 ≤ ℓ) (hℓ : ℓ ≤ P.depth) (c : P.LevelCoord ℓ) :

Overwrite loop scanning root-to-leaf for the stored level of an active key (Section 5.3).

Overwrite an active padded key x ∈ P.paddedDom d with v_new : Fin P.valBound.

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.TreeState.wellFormedPadded_rawOverwrite {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) {x : Fin P.paddedUniv} (hx : x ∈ P.paddedDom d) (v_new : Fin P.valBound) :
WellFormedPadded scheme (rawOverwrite scheme st x v_new) (Function.update d x (some v_new)) storeLvl