Binary tree #
Provides binary tree storage for values of any type, with O(lg n) retrieval.
See also Lean.Data.RBTree
for red-black trees - this version allows more operations
to be defined and is better suited for in-kernel computation.
We also specialize for Tree Unit
, which is a binary tree without any
additional data. We provide the notation a △ b
for making a Tree Unit
with children
a
and b
.
TODO #
Implement a Traversable
instance for Tree
.
References #
https://leanprover-community.github.io/archive/stream/113488-general/topic/tactic.20question.html
Equations
- instDecidableEqTree = decEqTree✝
Makes a Tree α
out of a red-black tree.
Equations
- Tree.ofRBNode Batteries.RBNode.nil = Tree.nil
- Tree.ofRBNode (Batteries.RBNode.node _color l key r) = Tree.node key (Tree.ofRBNode l) (Tree.ofRBNode r)
Instances For
A node with Unit
data
Equations
- Tree.«term_△_» = Lean.ParserDescr.trailingNode `Tree.term_△_ 65 66 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " △ ") (Lean.ParserDescr.cat `term 65))
Instances For
def
Tree.unitRecOn
{motive : Tree Unit → Sort u_1}
(t : Tree Unit)
(base : motive Tree.nil)
(ind : (x y : Tree Unit) → motive x → motive y → motive (Tree.node () x y))
:
motive t
Equations
- Tree.unitRecOn t base ind = Tree.recOn t base fun (_u : Unit) => ind