Documentation

CslibFrontier.DataStructure.Dictionary.SubconstantRedundancy.TreeRouting

Sentinel Padding and Bijective Multi-Level Coordinate Routing #

This file formalizes the sentinel-padded key space (Section 4, Footnote 5, PDF p. 12 / printed p. 11; Section 5, PDF p. 26 / printed p. 25), forest node ancestry, and bijective level-by-level (node, id, quot) coordinate pipeline (Sections 5.1 & 5.4, PDF pp. 27, 32 / printed pp. 26, 31) for the subconstant-redundancy dictionary tree of Tianxiao Li, Jingxun Liang, Huacheng Yu, and Renfei Zhou, Dynamic Dictionary with Subconstant Wasted Bits per Key ([LLYZ24]).

Main definitions #

Main results #

References #

Section 1: Sentinel-padded key universe and external dictionary correspondence #

Embed an external dictionary key u : Fin P.univ into Fin P.paddedUniv.

i-th sentinel padding key P.univ + i in Fin P.paddedUniv (Section 4, Footnote 5, arXiv:2310.20536v1, PDF p. 12 / printed p. 11).

@[reducible, inline]

Internal padded dictionary mapping Fin P.paddedUniv to bounded values Fin P.valBound.

Correspondence between an internal sentinel-padded dictionary d, active sentinel count sentCount ≤ P.cap, and external dict : Dictionary.State P.univ.

Canonical empty-dictionary padded state containing all P.cap sentinel keys with value 0.

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.paddedDom_eq_disjUnion (P : TreeSchedule) {d : P.PaddedDict} {sentCount : ℕ} {dict : State P.univ} (hm : P.MatchesExternal d sentCount dict) :
P.paddedDom d = Finset.map { toFun := P.embedReal, inj' := ⋯ } (dom dict) ∪ Finset.map { toFun := fun (i : ↥(Finset.range sentCount)) => P.sentinelKey ⟨↑i, ⋯⟩, inj' := ⋯ } (Finset.range sentCount).attach
theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.card_paddedDom_eq (P : TreeSchedule) {d : P.PaddedDict} {sentCount : ℕ} {dict : State P.univ} (hm : P.MatchesExternal d sentCount dict) :
(P.paddedDom d).card = (dom dict).card + sentCount

Section 2: Forest node indexing and ancestor topology #

Equivalence (parent, branch) ≃ child between level ℓ and level ℓ + 1.

Parent node of u : Fin (P.numNodes (ℓ + 1)) at level ℓ.

Branch index b ∈ Fin (2 ^ branchBits ℓ) of u : Fin (P.numNodes (ℓ + 1)) under its parent.

Ancestor of a level-ℓ node u at any level j ≤ ℓ.

theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.ancestorAt_trans (P : TreeSchedule) {i j ℓ : ℕ} (hij : i ≤ j) (hjℓ : j ≤ ℓ) (u : Fin (P.numNodes ℓ)) :
P.ancestorAt hij (P.ancestorAt hjℓ u) = P.ancestorAt ⋯ u

Node (ℓ, u) lies in the subtree rooted at (ℓ₀, u₀) iff ℓ₀ ≤ ℓ and ancestorAt u = u₀.

Instances For
    @[instance_reducible]
    instance Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.instDecidableInSubtree (P : TreeSchedule) (ℓ₀ : ℕ) (u₀ : Fin (P.numNodes ℓ₀)) (ℓ : ℕ) (u : Fin (P.numNodes ℓ)) :
    Decidable (P.InSubtree ℓ₀ u₀ ℓ u)
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.not_inSubtree_ancestor_of_not_inSubtree (P : TreeSchedule) {ℓ₀ : ℕ} {u₀ : Fin (P.numNodes ℓ₀)} {j ℓ : ℕ} (hj : j ≤ ℓ) {u : Fin (P.numNodes ℓ)} (hnot : ¬P.InSubtree ℓ₀ u₀ ℓ u) :
    ¬P.InSubtree ℓ₀ u₀ j (P.ancestorAt hj u)
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.inSubtree_step_iff (P : TreeSchedule) {ℓ j : ℕ} (u : Fin (P.numNodes ℓ)) (v : Fin (P.numNodes j)) :
    P.InSubtree ℓ u j v ↔ (∃ (h_eq : ℓ = j), h_eq ▸ u = v) ∨ ∃ (b : Fin (2 ^ P.branchBits ℓ)), P.InSubtree (ℓ + 1) ((P.childNodeEquiv ℓ) (u, b)) j v

    Section 3: Seed assignments and bijective coordinate pipeline #

    @[reducible, inline]

    Level-ℓ routed (node, primitiveId) coordinate (0 ≤ ℓ ≤ depth).

    @[reducible, inline]

    Level-ℓ routed (node, compressedId, quotient) coordinate (1 ≤ ℓ ≤ depth).

    @[reducible, inline]

    Node component of c : P.LevelCoord ℓ.

    @[reducible, inline]

    Compressed-ID component of c : P.LevelCoord ℓ.

    @[reducible, inline]

    Quotient component of c : P.LevelCoord ℓ.

    Full-forest hash seed assignment storing g_u : P.NodeSeed ℓ at every node 0 ≤ ℓ ≤ depth.

    Child-routing bijection (u_m, x_id_m) ≃ (u_{m + 1}, prim_{m + 1}) on edge m → m + 1 (1 ≤ m < depth).

    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.routeIdToPrimEquiv_congr {P : TreeSchedule} {s₁ s₂ : P.SeedAssignment} {m : ℕ} (h1 : 1 ≤ m) (hm : m < P.depth) (p : Fin (P.numNodes m) × Fin (2 ^ P.idBits m)) (hs : s₁.seed m ⋯ p.1 = s₂.seed m ⋯ p.1) :
    (s₁.routeIdToPrimEquiv h1 hm) p = (s₂.routeIdToPrimEquiv h1 hm) p

    Level-(m + 1) ID compression bijection PrimCoord (m + 1) ≃ Fin (numNodes (m + 1)) × Fin (2 ^ idBits (m + 1)) × Fin (2 ^ remBits m).

    Quotient-remainder merge equivalence Fin (quotUniv m) × Fin (2 ^ remBits m) ≃ Fin (quotUniv (m + 1)) for 1 ≤ m.

    Single-edge coordinate bijection LevelCoord m ≃ LevelCoord (m + 1) (1 ≤ m < depth, Section 5.1 & Algorithm 3 Line 14).

    @[simp]
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.stepCoordEquiv_apply {P : TreeSchedule} (seeds : P.SeedAssignment) {m : ℕ} (h1 : 1 ≤ m) (hm : m < P.depth) (c : P.LevelCoord m) :
    (seeds.stepCoordEquiv h1 hm) c = have prim_next := (seeds.routeIdToPrimEquiv h1 hm) (c.node, c.id); match (seeds.primSuccToIdRemEquiv h1 hm) prim_next with | (u_next, id_next, rem_m) => (u_next, id_next, (quotMergeEquiv h1) (c.quot, rem_m))

    Multi-level coordinate bijection Fin P.paddedUniv ≃ P.LevelCoord ℓ for 1 ≤ ℓ ≤ depth.

    Routed (node, primId) coordinate of x : Fin P.paddedUniv at level 0 ≤ ℓ ≤ depth.

    Node reached by x : Fin P.paddedUniv at level 0 ≤ ℓ ≤ depth.

    noncomputable def Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.idAt {P : TreeSchedule} (seeds : P.SeedAssignment) (ℓ : ℕ) (h1 : 1 ≤ ℓ) (hℓ : ℓ ≤ P.depth) (x : Fin P.paddedUniv) :
    Fin (2 ^ P.idBits ℓ)

    Compressed I_ℓ-bit ID of x : Fin P.paddedUniv at level 1 ≤ ℓ ≤ depth.

    Quotient x_quot^[ℓ] of x : Fin P.paddedUniv at level 1 ≤ ℓ ≤ depth.

    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.levelCoordEquiv_fst {P : TreeSchedule} (seeds : P.SeedAssignment) {ℓ : ℕ} (h1 : 1 ≤ ℓ) (hℓ : ℓ ≤ P.depth) (x : Fin P.paddedUniv) :
    ((seeds.levelCoordEquiv ℓ h1 hℓ) x).1 = seeds.nodeAt ℓ hℓ x
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.idAt_succ_eq_idCompressorHead {P : TreeSchedule} (seeds : P.SeedAssignment) {k : ℕ} (hk : k + 1 ≤ P.depth) (x : Fin P.paddedUniv) :
    seeds.idAt (k + 1) ⋯ hk x = FeistelPerm.idCompressorHead (P.idBits (k + 1)) (P.idCompRightUniv (k + 1)) (P.idSeedOfNodeSeed (seeds.seed (k + 1) hk (seeds.nodeAt (k + 1) hk x))) (seeds.primCoordAt (k + 1) hk x).2

    Section 4: Routed key sets, ancestor-only dependence, and AllGoodSeeds invariants #

    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.ancestorAt_nodeAt {P : TreeSchedule} (seeds : P.SeedAssignment) {j ℓ : ℕ} (hjℓ : j ≤ ℓ) (hℓ : ℓ ≤ P.depth) (x : Fin P.paddedUniv) :
    P.ancestorAt hjℓ (seeds.nodeAt ℓ hℓ x) = seeds.nodeAt j ⋯ x

    Subset of S : Finset (Fin P.paddedUniv) routed to node u at level ℓ.

    @[simp]
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.mem_activeAt_iff {P : TreeSchedule} {seeds : P.SeedAssignment} {S : Finset (Fin P.paddedUniv)} {ℓ : ℕ} {hℓ : ℓ ≤ P.depth} {u : Fin (P.numNodes ℓ)} {x : Fin P.paddedUniv} :
    x ∈ seeds.activeAt S ℓ hℓ u ↔ x ∈ S ∧ seeds.nodeAt ℓ hℓ x = u
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.activeAt_subset_ancestor {P : TreeSchedule} (seeds : P.SeedAssignment) {S : Finset (Fin P.paddedUniv)} {j ℓ : ℕ} (hjℓ : j ≤ ℓ) (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) :
    seeds.activeAt S ℓ hℓ u ⊆ seeds.activeAt S j ⋯ (P.ancestorAt hjℓ u)

    Primitive-ID finset S_prim arriving at node u at level ℓ (Section 5.5).

    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.primCoordAt_congr_ancestors {P : TreeSchedule} {s₁ s₂ : P.SeedAssignment} {ℓ : ℕ} (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) (hanc : ∀ (j : ℕ) (hj : j < ℓ), s₁.seed j ⋯ (P.ancestorAt ⋯ u) = s₂.seed j ⋯ (P.ancestorAt ⋯ u)) (x : Fin P.paddedUniv) :
    (s₁.nodeAt ℓ hℓ x = u ↔ s₂.nodeAt ℓ hℓ x = u) ∧ (s₁.nodeAt ℓ hℓ x = u → s₁.primCoordAt ℓ hℓ x = s₂.primCoordAt ℓ hℓ x)

    Ancestor-only dependence (Section 5.5 crucial property for Claim 5.4 & Lemma 5.3): if two seed assignments s₁, s₂ agree at all strict ancestors (j, ancestorAt hj u) (j < ℓ) of u, then s₁ and s₂ route the exact same keys to u with the exact same primitive IDs.

    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.primSetAt_congr_ancestors {P : TreeSchedule} {s₁ s₂ : P.SeedAssignment} (S : Finset (Fin P.paddedUniv)) {ℓ : ℕ} (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) (hanc : ∀ (j : ℕ) (hj : j < ℓ), s₁.seed j ⋯ (P.ancestorAt ⋯ u) = s₂.seed j ⋯ (P.ancestorAt ⋯ u)) :
    s₁.primSetAt S ℓ hℓ u = s₂.primSetAt S ℓ hℓ u
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.levelCoordEquiv_congr_ancestors {P : TreeSchedule} {s₁ s₂ : P.SeedAssignment} {ℓ : ℕ} (h1 : 1 ≤ ℓ) (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) (hanc : ∀ (j : ℕ) (hj : j ≤ ℓ), s₁.seed j ⋯ (P.ancestorAt hj u) = s₂.seed j ⋯ (P.ancestorAt hj u)) (x : Fin P.paddedUniv) (hnx : s₁.nodeAt ℓ hℓ x = u) :
    (s₁.levelCoordEquiv ℓ h1 hℓ) x = (s₂.levelCoordEquiv ℓ h1 hℓ) x

    Level-ℓ coordinate congruence when s₁, s₂ agree along (0 .. ℓ) of u's path.

    Global seed-goodness invariant on an active padded set S: #S ∈ [nLow 0, nHigh 0] and every node (ℓ, u) (0 ≤ ℓ ≤ depth) satisfies IsGoodNodeSeed on primSetAt S ℓ hℓ u.

    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.ancestorsGood_invariants {P : TreeSchedule} (seeds : P.SeedAssignment) {S : Finset (Fin P.paddedUniv)} (hcard0 : P.nLow 0 ≤ S.card ∧ S.card ≤ P.nHigh 0) (ℓ : ℕ) (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) :
    (∀ (j : ℕ) (hj : j < ℓ), P.IsGoodNodeSeed j (seeds.seed j ⋯ (P.ancestorAt ⋯ u)) (seeds.primSetAt S j ⋯ (P.ancestorAt ⋯ u))) → Set.InjOn (fun (x : Fin P.paddedUniv) => (seeds.primCoordAt ℓ hℓ x).2) ↑(seeds.activeAt S ℓ hℓ u) ∧ (P.nLow ℓ ≤ (seeds.activeAt S ℓ hℓ u).card ∧ (seeds.activeAt S ℓ hℓ u).card ≤ P.nHigh ℓ) ∧ (P.IsGoodNodeSeed ℓ (seeds.seed ℓ hℓ u) (seeds.primSetAt S ℓ hℓ u) → ∀ (h1 : 1 ≤ ℓ), Set.InjOn (seeds.idAt ℓ h1 hℓ) ↑(seeds.activeAt S ℓ hℓ u))

    Ancestor-local routing invariants at (ℓ, u): whenever #S ∈ [nLow 0, nHigh 0] and every strict ancestor j < ℓ of u satisfies IsGoodNodeSeed, (primCoordAt ℓ hℓ ·).2 is injective on activeAt S ℓ hℓ u, nLow ℓ ≤ #(activeAt S ℓ hℓ u) ≤ nHigh ℓ, and (if u's seed is good) idAt ℓ is injective on activeAt S ℓ hℓ u.

    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.allGoodSeeds_invariants {P : TreeSchedule} (seeds : P.SeedAssignment) {S : Finset (Fin P.paddedUniv)} (hgood : seeds.AllGoodSeeds S) (ℓ : ℕ) (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) :
    Set.InjOn (fun (x : Fin P.paddedUniv) => (seeds.primCoordAt ℓ hℓ x).2) ↑(seeds.activeAt S ℓ hℓ u) ∧ (P.nLow ℓ ≤ (seeds.activeAt S ℓ hℓ u).card ∧ (seeds.activeAt S ℓ hℓ u).card ≤ P.nHigh ℓ) ∧ ∀ (h1 : 1 ≤ ℓ), Set.InjOn (seeds.idAt ℓ h1 hℓ) ↑(seeds.activeAt S ℓ hℓ u)
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.card_primSetAt_eq {P : TreeSchedule} (seeds : P.SeedAssignment) {S : Finset (Fin P.paddedUniv)} (hgood : seeds.AllGoodSeeds S) {ℓ : ℕ} (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) :
    (seeds.primSetAt S ℓ hℓ u).card = (seeds.activeAt S ℓ hℓ u).card
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.load_bounds_of_allGoodSeeds {P : TreeSchedule} (seeds : P.SeedAssignment) {S : Finset (Fin P.paddedUniv)} (hgood : seeds.AllGoodSeeds S) {ℓ : ℕ} (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) :
    P.nLow ℓ ≤ (seeds.activeAt S ℓ hℓ u).card ∧ (seeds.activeAt S ℓ hℓ u).card ≤ P.nHigh ℓ
    theorem Cslib.DataStructure.Dictionary.SubconstantRedundancy.TreeSchedule.SeedAssignment.injOn_idAt_activeAt {P : TreeSchedule} (seeds : P.SeedAssignment) {S : Finset (Fin P.paddedUniv)} (hgood : seeds.AllGoodSeeds S) {ℓ : ℕ} (h1 : 1 ≤ ℓ) (hℓ : ℓ ≤ P.depth) (u : Fin (P.numNodes ℓ)) :
    Set.InjOn (seeds.idAt ℓ h1 hℓ) ↑(seeds.activeAt S ℓ hℓ u)