# Explanation

Why patrun picks the match it picks, how its tree finds it, and what the two ports share.

These pages discuss patrun's design: the reasons behind its rules, and what they cost. They are for reading away from the code.

- [Why the most specific pattern wins](https://rjrodger.github.io/patrun/explanation/two-rules.html): The two rules that decide every match, why they give one answer for every query, and what the alphabetical order costs.
- [How the tree finds a match](https://rjrodger.github.io/patrun/explanation/the-tree.html): How a router stores its patterns as a tree of keys and values, why a lookup follows only the branches a query matches, and what the skip paths are for.
- [Why every value is a string](https://rjrodger.github.io/patrun/explanation/strings-and-maps.html): Why patrun stores and matches values as text, takes only maps, and holds a Go pattern's data as a pointer to a string.
- [The definition](https://rjrodger.github.io/patrun/explanation/definition.html): The Lean 4 definition of what a router answers, the proofs that the answers are unique, and how it keeps the two ports in step.
