Documentation

CslibFrontier.DataStructure.Dictionary.KickTree.Facility

Multi-Tier Facility Layer for the k-Kick Tree Dynamic Dictionary #

This module formalizes the multi-tier facility architecture and cubby layout of the STOC 2022 k-kick tree dynamic dictionary of Bender, Farach-Colton, J. Kuszmaul, W. Kuszmaul, and Liu ([BFCK+22], arXiv:2111.00602v2, Section 5.2, pp. 30–32):

  1. Multi-tier full cubbies (Section 5.2, pp. 30–32): $j$-tiered 100% full cubbies with tier capacities $r_j$ and target ratios $t_j \cdot r_j = r_{j+1}$ for $0 \le j < k_{\text{eff}}$, with capacity arithmetic behind tier merging merge_tier_length (§5.2, p. 31; compare Lemma 19, p. 29 for $O(K)$ cubby construction).
  2. Single tail cubby and saturation architecture: all non-tail cubbies are strictly 100% full (zero empty slots, statically enforced via FullCubby), while a single partially filled base tail cubby of capacity $r_1$ (TailCubby) absorbs insertions, with full-tail promotion step promoteFullTail opening a fresh empty tail.
  3. Non-hash tail replacement on deletion (Section 5.2, p. 31): deletion from a full cubby is refilled by popping an element from the tail cubby (in the full algorithm, drawn with fresh per-operation non-hash randomness independent of hash seed $\theta$), maintaining full-cubby 100% saturation with item count conservation theorem totalItems_tailReplace. Note: deletion directly from the tail cubby and full tail elimination (when the tail is empty) are deferred to subsequent stages.
  4. Tracked extensions: dynamic resizing, deamortization, physical Word-RAM slab directories (SlabDirectory), background fallback healing (FallbackHealer), and remaining §5.2 distribution invariants ($t_j / 2 \le \text{count} \le 3 t_j$, $j$-creation/destruction rebuilds) are tracked in issue #5186.

Source attribution #

Main definitions #

Main results #

References #

1. Multi-Tier Facility Configuration #

Multi-tier facility configuration parameters. Tiers are 0-indexed $0 \le j \le k_{\text{eff}}$ (corresponding to paper tiers $1 \le j \le k_{\text{eff}} + 1$, with index $j$ corresponding to paper tier $j + 1$), where index 0 has base capacity r1 := r 0 and adjacent tiers satisfy $t_j \cdot r_j = r_{j+1}$.

  • kEff : ℕ

    Largest tier index $k_{\text{eff}} \ge 1$ (providing $k_{\text{eff}} + 1$ total tiers).

  • kEff_pos : 0 < self.kEff

    Effective depth positivity.

  • r : Fin (self.kEff + 1) → ℕ

    Capacity of a tier-$j$ cubby $r_j > 0$ for $0 \le j \le k_{\text{eff}}$.

  • r_pos (j : Fin (self.kEff + 1)) : 0 < self.r j

    Tier capacity is positive.

  • t : Fin self.kEff → ℕ

    Target ratio $t_j$ of tier-$j$ cubbies forming a tier-$(j+1)$ cubby.

  • t_mul_r (j : Fin self.kEff) : self.t j * self.r ⟨↑j, ⋯⟩ = self.r ⟨↑j + 1, ⋯⟩

    Target ratio equation $t_j \cdot r_j = r_{j+1}$.

2. Cubby Representation #

Full cubby storing exactly cfg.r tier elements (100% full, zero empty slots).

  • tier : Fin (cfg.kEff + 1)

    Tier index $0 \le \text{tier} \le k_{\text{eff}}$.

  • items : List α

    Stored items.

  • hlen : self.items.length = cfg.r self.tier

    Exactly full: length matches tier capacity cfg.r tier.

Instances For
    @[instance_reducible]
    instance Cslib.DataStructure.Dictionary.KickTree.instReprFullCubby {cfg✝ : FacilityConfig} {α✝ : Type u_1} [Repr α✝] :
    Repr (FullCubby cfg✝ α✝)

    Tail cubby of capacity cfg.r1 with items.length ≤ cfg.r1.

    • items : List α

      Stored items.

    • hle : self.items.length ≤ cfg.r1

      Tail capacity bound: length at most base capacity cfg.r1.

    Instances For
      @[instance_reducible]
      instance Cslib.DataStructure.Dictionary.KickTree.instReprTailCubby {cfg✝ : FacilityConfig} {α✝ : Type u_1} [Repr α✝] :
      Repr (TailCubby cfg✝ α✝)

      Initial empty tail cubby.

      3. Facility State and Item Count Conservation Theorems #

      Pure multi-tier facility state. Statically enforces the saturation invariant: all cubbies in fullCubbies are strictly 100% full (FullCubby), and tail is a valid bounded tail cubby (TailCubby).

      • fullCubbies : List (FullCubby cfg α)

        Ordered list of 100% full cubbies (across all tiers).

      • tail : TailCubby cfg α

        Single designated tail cubby of capacity $r_1$.

      Instances For
        @[instance_reducible]
        instance Cslib.DataStructure.Dictionary.KickTree.instReprFacility {cfg✝ : FacilityConfig} {α✝ : Type u_1} [Repr α✝] :
        Repr (Facility cfg✝ α✝)

        Total number of items stored across the entire facility.

        Insert an item into the facility tail.

        theorem Cslib.DataStructure.Dictionary.KickTree.Facility.totalItems_insertIntoTail {cfg : FacilityConfig} {α : Type u_1} (F : Facility cfg α) (item : α) (F' : Facility cfg α) (hins : F.insertIntoTail item = some F') :

        Inserting into tail increments the total item count by 1.

        Promote a saturated full tail cubby to a tier-0 full cubby and open a fresh empty tail.

        Promoting a full tail preserves the total item count.

        theorem Cslib.DataStructure.Dictionary.KickTree.Facility.merge_tier_length {cfg : FacilityConfig} {α : Type u_1} (j : Fin cfg.kEff) (cubbies : List (List α)) (hcount : cubbies.length = cfg.t j) (hall : ∀ l ∈ cubbies, l.length = cfg.r ⟨↑j, ⋯⟩) :
        cubbies.flatten.length = cfg.r ⟨↑j + 1, ⋯⟩

        Capacity arithmetic behind tier merging in the $j$-destruction rebuild (arXiv:2111.00602 §5.2, p. 31; compare Lemma 19, p. 29 for linear-time cubby construction): merging t_j full cubbies of tier j forms a valid full cubby of tier j + 1. Full dynamic ratio maintenance and deamortization across dictionary operations are tracked in issue #5186.

        4. Non-Hash Tail Replacement on Deletion (arXiv:2111.00602 §5.2, p. 31) #

        def Cslib.DataStructure.Dictionary.KickTree.Facility.tailReplace {cfg : FacilityConfig} {α : Type u_1} (F : Facility cfg α) (cubbyIdx slotIdx randIdx : ℕ) :
        Option (Facility cfg α)

        Non-hash tail replacement: when deleting element at slotIdx from full cubby cubbyIdx, refill the hole by popping a caller-selected item at randIdx from the tail cubby, keeping the full cubby 100% full. Returns none if cubbyIdx is out of bounds, slotIdx is out of bounds, or randIdx is out of bounds (e.g. if the tail cubby is empty). Note: deletion directly from the tail cubby and full tail elimination (underflow handling) are deferred to subsequent stages.

        theorem Cslib.DataStructure.Dictionary.KickTree.Facility.totalItems_tailReplace {cfg : FacilityConfig} {α : Type u_1} (F : Facility cfg α) (cIdx sIdx rIdx : ℕ) (F' : Facility cfg α) (hrep : F.tailReplace cIdx sIdx rIdx = some F') :

        Tail replacement decrements the total item count by 1 (the deleted element is removed, and the hole in the full cubby is filled from the tail).