Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.trie

The Applied Higher-Order Functions cataloguesrc/rainbow/algorithms/proofs/ahof/trie.clj1 definitions, 3 theorems

AHoF Trie (prefix tree): store a set of strings in a tree keyed by characters, so that insertion and lookup are O(length) regardless of how many words are stored, and every shared prefix is stored once -- the workhorse behind autocomplete, spell-check, IP routing, and dictionary compression. A query string is a stored WORD exactly when walking its characters reaches an existing node AND that node is marked terminal (end-of-word); a prefix query only needs the path to exist: is-word? path-complete? terminal? = path-complete? AND terminal? over booleans. Proved native and axiom-free: word membership as the boolean conjunction of a complete path and a terminal marker (via logic/if-data over Bool); that a complete path ending at a terminal node is a stored word; that a complete path at a NON-terminal node is only a prefix, not a word; and that an incomplete path is neither. The child-map navigation and insertion are executable; what is proved is the word-vs-prefix membership decision. Requires data/Bool, logic/if-data (both in the D63 checkpoint). Scope (measured by the kernel): this module has 3 worked instances (statements about specific values). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.trie` prints this classification.

trie/is-word?

DefinitionSource, line 44

trie/is-word? :
  (x₁ x₂ : data/Bool)
  → data/Bool

trie/complete-terminal-is-word

TheoremWorked exampleNo axiomsSource, line 58

trie/complete-terminal-is-word :
  → boolean/and data/true data/true = data/true

= = equality/Eq

trie/prefix-not-word

TheoremWorked exampleNo axiomsSource, line 65

trie/prefix-not-word :
  → boolean/and data/true data/false = data/false

= = equality/Eq

trie/incomplete-path-not-word

TheoremWorked exampleNo axiomsSource, line 72

trie/incomplete-path-not-word :
  → boolean/and data/false data/true = data/false

= = equality/Eq