Proofs: Burst trie
These are the human proofs of Burst trie, at full length.
The burst trie operations keep the invariant and implement the symbol table full
This proof shows: correctness.
We use the representation, the invariant (B1) to (B3) and the pseudocode of the page. The place of a key in the current structure is defined by the walk: start at the root with ; while at an access node with whose slot for holds an access node, move to it and add 1 to . The walk stops at an access node with either (the place is ) or with the slot for holding a container or empty (the place is the pair with string in , or the empty slot). By construction .
Lemma 1 (unique place). Under (B1), if is stored, it is stored at its place.
Proof. By (B1), is stored either as for an access node , or as for a container . In the first case, , so lies on the walk of (each ancestor of is an access node whose path is a prefix of , and its slot for the next symbol of leads towards ), and the walk reaches with . In the second case, is a prefix of , of length , and hangs in the slot for of an access node with . The walk reaches (same argument) with and stops there, because the slot holds a container. Its place is the pair with string in .
GET. Lines L1 to L3 perform the walk of the definition. If the walk ends with , line L2 returns ; else line L4 looks up in the container, correctly by (B3) for a binary search, and line L5 returns its value or NIL. By Lemma 1 and (B1), this is the value of or NIL.
PUT. Line L6 performs the walk. If it ends at an access node with , setting stores at its place. Otherwise, lines L7 to L9 put in the container of the slot for , keeping it sorted and without repeats, so by Lemma 1 the key is stored once, with value , and the other keys are untouched. Now (B1) and (B3) hold, and (B2) can fail only at that container, if it has pairs.
BURST. Let hang at path and be replaced by the access node , so . Each pair of stood for the key . Line L11 stores it as if , which stands for ; else as the pair in the container at path , which stands for . So the set of stored keys and their values does not change, and (B1) holds. The strings of are distinct, so at most one has and the new containers have no repeats; appending in the sorted order of keeps each new container sorted, since strings with the same first symbol are ordered by their remainders. So (B3) holds. Line L12 bursts each new container with more than pairs, by the same argument. Each burst at depth moves the pairs one symbol deeper, and the strings are finite, so the bursting ends; at the end every container has between 1 and pairs, and (B2) holds.
DELETE. The walk finds the place of (Lemma 1). Removing the pair or clearing removes exactly the key ; a container that becomes empty is removed from its slot, so (B2) keeps its lower bound of 1.
Prefix queries and order. The keys with prefix are those stored below the place where the walk of stops. If it stops in a container at path , they are the pairs of whose string starts with , which form a contiguous run in sorted order (B3). If it stops at an access node with , they are all keys below . A walk that reports before the children of , takes the slots in increasing order of their symbols, and reports each container in its sorted order, lists keys in lexicographic order: a key is a prefix of every other key below , and keys in different slots of first differ at the symbol of the slot.