The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V33. Data structures and computation

Mathlib.Data.Tree.Get

3 declarations and 3 deprecated aliases. Mathlib docs · Source

Binary tree get operation

In this file we define Tree.indexOf, Tree.get, and Tree.getOrElse. These definitions were moved from the main file to avoid a dependency on Num.

References

https://leanprover-community.github.io/archive/stream/113488-general/topic/tactic.20question.html#170999997

def BinaryTree.indexOf E1 #

{α : Type u_1} → (lt : α → α → Prop) → [DecidableRel lt] → α → BinaryTree α → Option PosNum

Finds the index of an element in the tree assuming the tree has been constructed according to the provided decidable order on its elements. If it hasn't, the result will be incorrect. If it has, but the element is not in the tree, returns none.

def BinaryTree.get E1 #

{α : Type u_1} → PosNum → BinaryTree α → Option α

Retrieves an element uniquely determined by a PosNum from the tree, taking the following path to get to the element:

  • bit0 - go to left child
  • bit1 - go to right child
  • PosNum.one - retrieve from here

def BinaryTree.getOrElse E1 #

{α : Type u_1} → PosNum → BinaryTree α → α → α

Retrieves an element from the tree, or the provided default value if the index is invalid. See BinaryTree.get.

Deprecated aliases

NameNew nameSince
Tree.getBinaryTree.get2026-06-07
Tree.getOrElseBinaryTree.getOrElse2026-06-07
Tree.indexOfBinaryTree.indexOf2026-06-07