Documentation

Mathlib.Data.Tree.Get

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 {α : Type u_1} (lt : ααProp) [DecidableRel lt] (x : α) :

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.

Equations
Instances For
    @[reducible, inline, deprecated BinaryTree.indexOf (since := "2026-06-07")]
    abbrev Tree.indexOf {α : Type u_1} (lt : ααProp) [DecidableRel lt] (x : α) :

    Alias of BinaryTree.indexOf.

    Equations
    Instances For
      def BinaryTree.get {α : Type u_1} :
      PosNumBinaryTree α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
      Equations
      Instances For
        @[reducible, inline, deprecated BinaryTree.get (since := "2026-06-07")]
        abbrev Tree.get {α : Type u_1} (n : PosNum) (t : Tree α) :

        Alias of BinaryTree.get.

        Equations
        Instances For
          def BinaryTree.getOrElse {α : Type u_1} (n : PosNum) (t : BinaryTree α) (v : α) :
          α

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

          Equations
          Instances For
            @[reducible, inline, deprecated BinaryTree.getOrElse (since := "2026-06-07")]
            abbrev Tree.getOrElse {α : Type u_1} (n : PosNum) (t : Tree α) (v : α) :
            α

            Alias of BinaryTree.getOrElse.

            Equations
            Instances For