Pure Metadata Layer for the k-Kick Tree Dynamic Dictionary #
This module formalizes the pure metadata building blocks for the STOC 2022 k-kick tree dynamic
dictionary of Bender, Farach-Colton, J. Kuszmaul, W. Kuszmaul, and Liu
([BFCK+22], arXiv:2111.00602v2, Section 4, pp. 24–26, and
Section 5.1, pp. 27–28):
- Four-Russians Bit-Table Specifications (
FourRussians) (Section 4.1, p. 24): abstract specifications for bit-parallel operations on small bit-vectors of widthB(popcount,rank1,rank0,select1,select0,firstZeroBit,firstSetBit), proving rank complementation, rank/select bounds, soundness theoremsselect1_soundandselect0_sound, rank-select inversionrank1_select1andrank0_select0, and domain completenessselect1_isSome_iffandselect0_isSome_iff. TheTablestructure formalizes specification agreement; physical precomputed Word-RAM lookup tables are deferred to Stage A4. - Mini-Array (
MiniArray) (Section 4.2, pp. 24–25): abstract array specification supporting point-update semantics and unary delimiter bitmap sizing with exact bit-length theoremdelimiters_length_eq_totalBitsmatching total bits $K + \sum_i s_i$; physical bit-packed Word-RAM representation is deferred to Stage A4. - Local Query Router (
LocalQueryRouter/PrefixTrie) (Section 4.3, pp. 25–26): binary prefix-trie router (adapting Lemma 15 for prefix-free key sets: callers supply prefix-free keys andinsert?rejects collisions instead of extending stored prefixes via oracle $g$), with exact roundtrip decoding theoremdecode_encode, collision-preventing insertioninsert?, frame theoremquery_insert_of_diverge, key preservationquery_insert_two_distinct, and key extension routingquery_insert_prefix. - Free-Slot Tree (
FreeSlotTree) (Section 5.1, pp. 27–28): constant-depth $B$-ary bitmap tree over $[0, B^{h+1})$ for depth-0 free-slot allocation and deallocation, with full-tree soundnessfindFree?_soundand completenessfindFree?_completeacross all heights, semantic bridgehasFree_iff_exists_isFree, full-height update/frame theoremsisFree_setSlot_selfandisFree_setSlot_of_ne, and preservation of structural validityValid.
Source attribution #
- [BFCK+22] (
arXiv:2111.00602v2):- Section 4.1 (printed p. 24 / PDF p. 25): Method of Four Russians lookup tables on machine words.
- Section 4.2 (printed pp. 24–25 / PDF pp. 25–26): mini-array of variable-size values in $O(K + \sum_i s_i)$ space with $O(1)$ updates and queries.
- Section 4.3 (printed pp. 25–26 / PDF pp. 26–27): local query router over stored prefixes with DFS tree-shape encoding $E_1$ and leaf-value encoding $E_2$.
- Section 5.1 (printed pp. 27–28 / PDF pp. 28–29): $O(1)$-depth free-slot tree with uniform fanout for depth-0 free-slot location.
Main definitions #
FourRussians.popcount,FourRussians.rank1,FourRussians.rank0,FourRussians.select1,FourRussians.select0,FourRussians.firstZeroBit,FourRussians.firstSetBit: bit-parallel operations over small wordsFin (2 ^ B).FourRussians.Table: Four-Russians precomputed lookup table specification structure.FourRussians.popcountTable: table specification for population count.MiniArray: abstract sequence model supporting point updates and unary delimiter sizing.PrefixTrie: canonical binary prefix trie over prefix-free keys.PrefixTrie.query,PrefixTrie.insert?,PrefixTrie.delete,PrefixTrie.pruneBranch: prefix-free routing, collision-rejecting insertion, and branch contraction.PrefixTrie.encodeE1,PrefixTrie.encodeE2,PrefixTrie.decode: DFS serialization into binary tree shape and values.FreeSlotTree: $B$-ary constant-depth bitmap tree for free-slot management.FreeSlotTree.hasFree,FreeSlotTree.isFree,FreeSlotTree.findFree?,FreeSlotTree.setSlot,FreeSlotTree.allocSlot,FreeSlotTree.freeSlot,FreeSlotTree.Valid: operations and structural validity for free-slot trees.
Main results #
FourRussians.popcount_eq_length_bitIndices,FourRussians.popcount_eq_sum_testBit,FourRussians.popcount_eq_spec: population count characterizations.FourRussians.rank0_add_rank1,FourRussians.rank1_le,FourRussians.rank0_le: rank complementation and bounds.FourRussians.select1_sound,FourRussians.select0_sound: selection soundness.FourRussians.rank1_select1,FourRussians.rank0_select0: rank-select inversion theorems.FourRussians.select1_isSome_iff,FourRussians.select0_isSome_iff: domain completeness.MiniArray.delimiters_length_eq_totalBits,MiniArray.delimiters_count_delimiters: exact bit length and delimiter count for mini-array packed representations.PrefixTrie.query_insert_prefix,PrefixTrie.query_insert_of_diverge,PrefixTrie.query_insert_two_distinct: prefix trie routing correctness and framing.PrefixTrie.decode_encode: roundtrip DFS trie deserialization.FreeSlotTree.isFree_setSlot_self,FreeSlotTree.isFree_setSlot_of_ne,FreeSlotTree.allocSlot_self,FreeSlotTree.freeSlot_self,FreeSlotTree.allocSlot_of_ne,FreeSlotTree.freeSlot_of_ne: full-height update and framing.FreeSlotTree.setSlot_preserves_valid,FreeSlotTree.allocSlot_preserves_valid,FreeSlotTree.freeSlot_preserves_valid: validity preservation across all levels.FreeSlotTree.hasFree_iff_exists_isFree: semantic bridge between summary and leaves.FreeSlotTree.findFree?_sound,FreeSlotTree.findFree?_complete: full-tree soundness and completeness across all tree heights.
References #
- [M. A. Bender, M. Farach-Colton, J. Kuszmaul, W. Kuszmaul, M. Liu, Dynamic Dictionaries with Worst-Case Optimal Operations and Space] [BFCK+22], arXiv:2111.00602.
1. Four-Russians Bit-Table Specifications (arXiv:2111.00602 §4.1, p. 24) #
Population count matches the length of the set-bit index list w.val.bitIndices.
Population count matches the sum of individual bits via
Nat.sum_testBit_eq_length_bitIndices.
Population count matches the BitString.weight semantic specification.
Specification of a Four-Russians bit-parallel lookup table of block size B.
Direct table lookup function over
Fin (2 ^ B).Table correctness: the table evaluation matches the semantic specification.
Four-Russians lookup table for population count with verified specification equivalence.
2. Mini-Array (arXiv:2111.00602 §4.2, pp. 24–25) #
Abstract mini-array sequence model (arXiv:2111.00602 §4.2, pp. 24–25): sequence of K
items of type α supporting point updates and unary delimiter bitmap sizing for packed sequence
representations. This represents the functional specification of the $K$-item array; physical
bit-packing into machine words is addressed in Stage A4.
- data : Fin K → α
The
Kitems stored in the mini-array.
Initialize a mini-array with a uniform default value.
Delimiter count: the total number of delimiter 1-bits across all K items is exactly K.
3. Local Query Router (arXiv:2111.00602 §4.3, Lemma 15, pp. 25–26) #
Binary prefix trie for local prefix routing (arXiv:2111.00602 §4.3, Lemma 15).
In the terminology of Bender et al. (Lemma 15), this is an uncompressed binary trie where each
leaf stores its payload value and internal nodes branch on successive bits of the key.
Adaptation: in place of the paper's oracle $g$ dynamically extending prefixes during insertion,
the formal router operates on prefix-free key sets, where insert? rejects collisions and
returns none (zero silent drops or overwrites). Once a leaf is reached, its stored payload is
returned for any key extension. Bit-packed Four-Russians decoding subroutines on Word-RAM belong
to Stage A4.
- empty {α : Type u_1} : PrefixTrie α
Empty trie.
- leaf {α : Type u_1} (val : α) : PrefixTrie α
Leaf storing routed payload value
val. - branch {α : Type u_1} (left right : PrefixTrie α) : PrefixTrie α
Branch node with left (0-bit) and right (1-bit) subtrees.
Instances For
Total number of nodes in the prefix trie.
Route a bit-sequence through the prefix trie.
Once a leaf is reached (corresponding to the stored prefix), its stored
payload is returned for any key extension (arXiv:2111.00602 §4.3, p. 25).
Insert a stored prefix and value into the prefix trie.
Returns none if a prefix collision occurs (a leaf already exists at or above k,
or branch subtrees already exist below k), ensuring zero silent drops or overwrites.
Routing a query through pruneBranch l r is semantically equivalent to routing
through .branch l r.
Delete a prefix from the prefix trie, removing the target leaf and contracting
empty branches back to .empty.
Querying a deleted prefix returns none.
General frame theorem for insertion: inserting a key does not alter queries for any key that diverges from it at some bit position.
Key-preservation for distinct prefix-incomparable keys: inserting two divergent keys preserves the retrieval of both payloads.
Deleting from the left branch does not alter queries routed to the right branch.
Deleting from the right branch does not alter queries routed to the left branch.
DFS tree-shape encoding $E_1$ (arXiv:2111.00602 §4.3, p. 25): preorder sequence
encoding node types ([false, false] for empty, [false, true] for leaf,
true :: (encodeE1 l ++ encodeE1 r) for branch), adapting the binary tree shape for
unambiguous DFS reconstruction.
Leaf payload encoding $E_2$ (arXiv:2111.00602 §4.3, p. 25): list of leaf values in
DFS traversal order (List α).
Reconstruct a prefix trie from its $(E_1, E_2)$ DFS encodings.
Exact DFS roundtrip decoding theorem for prefix tries.
Local query router alias for the prefix trie.
4. Free-Slot Tree (arXiv:2111.00602 §5.1, pp. 27–28) #
Constant-depth $B$-ary bitmap tree over $[0, B^{h+1})$ for depth-0 free-slot allocation.
- leaf {B : ℕ} (freeBits : Fin B → Bool) : FreeSlotTree B 0
Leaf node (height 0) storing a bitmap over
Bslots. - node {B : ℕ} (h : ℕ) (summary : Fin B → Bool) (children : Fin B → FreeSlotTree B h) : FreeSlotTree B (h + 1)
Internal node (height
h + 1) storing a summary bitmap andBchildren.
Check whether the tree has at least one free slot.
Test whether a slot is free in the tree.
Find the first free slot index in the tree, if one exists.
Set the occupancy of a slot in the tree (b = true for free, b = false for allocated).
Mark a slot as occupied (allocated).
Mark a slot as free (deallocated).
Bitmap tree structural validity invariant: summary bits accurately reflect child occupancy.
Setting a slot preserves structural validity across all tree levels.
Allocating a slot preserves structural validity across all tree levels.
Freeing a slot preserves structural validity across all tree levels.
Full-tree semantic completeness: if any slot in the tree is free, findFree? succeeds.
Allocating slot idx preserves the status of any distinct slot j ≠ idx.
Freeing slot idx preserves the status of any distinct slot j ≠ idx.