Theory Trie_Map
section "Tries via Search Trees"
theory Trie_Map
imports
Tree_Map
Trie_Fun
begin
text ‹An implementation of tries for an arbitrary alphabet ‹'a› where
the mapping from an element of type ‹'a› to the sub-trie is implemented by a binary search tree.
Although this implementation uses maps implemented by red-black trees it works for any
implementation of maps.
This is an implementation of the ``ternary search trees'' by Bentley and Sedgewick
[SODA 1997, Dr. Dobbs 1998]. The name derives from the fact that a node in the BST can now
be drawn to have 3 children, where the middle child is the sub-trie that the node maps
its key to. Hence the name ‹trie3›.
Example from @{url "https://en.wikipedia.org/wiki/Ternary_search_tree#Description"}:
c
/ | \
a u h
| | | \
t. t e. u
/ / | / |
s. p. e. i. s.
Characters with a dot are final.
Thus the tree represents the set of strings "cute","cup","at","as","he","us" and "i".
›