Documentation

CslibFrontier.DataStructure.BPlusTree.Basic

B+-trees #

B+-trees in the minimum-degree form of [CLRS09], Chapter 18: the variant of the B-trees of [BMcC72] that keeps every entry in a leaf and uses the interior nodes only to direct the search ([Com79]). A leaf holds a list of entries. An interior node is a first child followed by a list of (separator, child) pairs (BPlusTree.Branch), so a node with m separators has m + 1 children by construction. The tree is a map from keys to values, specified by toList against the sorted association list model List.IsSortedAssoc.

A separator is a key, not an entry. The keys of the child that a separator introduces are at least the separator, and the keys of every child before it are strictly below it (Separated). A separator need not occur as a key in any leaf. The convention with separators bounding their child strictly from below is not the one used here.

leaves lists the entry lists of the leaves from left to right, and toList is its concatenation. leaves stands for the chain that links the leaves of a B+-tree: there are no pointers. height counts the nodes on a root-to-leaf path, so a leaf has height 1; the empty tree is the empty leaf leaf []. The classic Cslib.DataStructure.BTree differs here, since its leaf is the empty tree and has height 0.

Well-formedness at minimum degree t is the hypothesis IsWF t tr, never part of the type: t ≥ 2; every non-root leaf has between t - 1 and 2 * t - 1 entries and every non-root interior node between t - 1 and 2 * t - 1 separators (Occupied); the root has at most 2 * t - 1 entries or separators, and an interior root at least one separator; all leaves are at the same depth (Balanced); the separator convention holds at every interior node (Separated); and toList is key-sorted. width is the number of entries of a leaf or of separators of an interior node, in which the root rule is stated.

induction is the induction principle for the nested type. The Boolean checkers occupied, balanced, separated and isWF decide the predicates, so that well-formedness of concrete trees is checked by decide. The operations and checkers are @[expose]d so that decide and rfl evaluate them from other modules.

Main definitions #

Main results #

References #

inductive Cslib.DataStructure.BPlusTree (α : Type u) (β : Type v) :
Type (max u v)

A B+-tree with keys in α and values in β. A leaf holds entries; an interior node is a first child followed by (separator, child) pairs.

Instances For
    @[reducible, inline]
    abbrev Cslib.DataStructure.BPlusTree.Branch (α : Type u) (β : Type v) :
    Type (max u v)

    A (separator, child) pair of an interior node.

    @[reducible, inline]
    abbrev Cslib.DataStructure.BPlusTree.Branch.child {α : Type u} {β : Type v} (e : Branch α β) :
    BPlusTree α β

    The child of a branch.

    @[simp]
    theorem Cslib.DataStructure.BPlusTree.Branch.child_mk {α : Type u} {β : Type v} (k : α) (c : BPlusTree α β) :
    child (k, c) = c

    The child of a pair is its second component.

    def Cslib.DataStructure.BPlusTree.leaves {α : Type u} {β : Type v} :
    BPlusTree α β → List (List (α × β))

    The entry lists of the leaves, from left to right: the representation of leaf chaining.

    def Cslib.DataStructure.BPlusTree.leavesRest {α : Type u} {β : Type v} :
    List (Branch α β) → List (List (α × β))

    The leaves of the children in a list of branches.

    def Cslib.DataStructure.BPlusTree.toList {α : Type u} {β : Type v} (tr : BPlusTree α β) :
    List (α × β)

    The entries from left to right, which is key order under IsWF.

    Number of nodes on a longest root-to-leaf path: a leaf has height 1.

    Height contribution of the children in a list of branches.

    def Cslib.DataStructure.BPlusTree.map {α : Type u} {β : Type v} {γ : Type w} (f : β → γ) :
    BPlusTree α β → BPlusTree α γ

    Map a function over the values.

    def Cslib.DataStructure.BPlusTree.mapRest {α : Type u} {β : Type v} {γ : Type w} (f : β → γ) :
    List (Branch α β) → List (Branch α γ)

    Map a function over the values of the children in a list of branches.

    def Cslib.DataStructure.BPlusTree.size {α : Type u} {β : Type v} (tr : BPlusTree α β) :

    Number of entries.

    def Cslib.DataStructure.BPlusTree.keys {α : Type u} {β : Type v} (tr : BPlusTree α β) :
    List α

    The keys from left to right.

    def Cslib.DataStructure.BPlusTree.foldl {α : Type u} {β : Type v} {γ : Type w} (f : γ → α × β → γ) (init : γ) (tr : BPlusTree α β) :
    γ

    Fold over the entries from left to right, as in toList; the specification of any direct recursive fold.

    @[instance_reducible]

    An entry belongs to a tree when it belongs to its toList.

    def Cslib.DataStructure.BPlusTree.width {α : Type u} {β : Type v} :
    BPlusTree α β → ℕ

    Number of entries of a leaf, or of separators of an interior node.

    def Cslib.DataStructure.BPlusTree.children {α : Type u} {β : Type v} :
    BPlusTree α β → List (BPlusTree α β)

    Children of the root node; a leaf has none.

    inductive Cslib.DataStructure.BPlusTree.Occupied {α : Type u} {β : Type v} (t : ℕ) :
    BPlusTree α β → Prop

    Every node satisfies the occupancy bounds of a non-root node of minimum degree t: a leaf has between t - 1 and 2 * t - 1 entries, an interior node between t - 1 and 2 * t - 1 separators.

    Instances For
      inductive Cslib.DataStructure.BPlusTree.Balanced {α : Type u} {β : Type v} :
      BPlusTree α β → Prop

      All leaves at the same depth: every child of a node has the height of the first child.

      Instances For
        inductive Cslib.DataStructure.BPlusTree.Separated {α : Type u} {β : Type v} [LinearOrder α] :
        BPlusTree α β → Prop

        The separator convention at every interior node: the keys of the child a separator introduces are at least the separator, and the keys of every child before it are strictly below it. A separator need not occur as a key.

        Instances For
          structure Cslib.DataStructure.BPlusTree.IsWF {α : Type u} {β : Type v} [LinearOrder α] (t : ℕ) (tr : BPlusTree α β) :

          Well-formed B+-tree of minimum degree t: root occupancy, non-root occupancy, equal leaf depth, the separator convention, and key-sortedness of toList.

          • two_le : 2 ≤ t

            The minimum degree is at least 2.

          • width_le : tr.width ≤ 2 * t - 1

            The root has at most 2 * t - 1 entries or separators.

          • width_pos : (∀ (entries : List (α × β)), tr ≠ leaf entries) → 1 ≤ tr.width

            An interior root has at least one separator.

          • occupied_of_mem_children (c : BPlusTree α β) : c ∈ tr.children → Occupied t c

            Every child of the root is occupied.

          • balanced : tr.Balanced

            All leaves are at the same depth.

          • separated : tr.Separated

            The separator convention holds at every interior node.

          • sorted : tr.toList.IsSortedAssoc

            The entries are sorted by strictly increasing key.

          Instances For
            def Cslib.DataStructure.BPlusTree.occupied {α : Type u} {β : Type v} (t : ℕ) :
            BPlusTree α β → Bool

            Boolean check of Occupied t.

            def Cslib.DataStructure.BPlusTree.occupiedRest {α : Type u} {β : Type v} (t : ℕ) :
            List (Branch α β) → Bool

            Boolean check that every child in a list of branches is occupied.

            Boolean check of Balanced.

            def Cslib.DataStructure.BPlusTree.balancedRest {α : Type u} {β : Type v} (h : ℕ) :
            List (Branch α β) → Bool

            Boolean check that every child in a list of branches is balanced and of height h.

            Boolean check that the keys of each child in a list of branches are below every later separator.

            Boolean check of Separated.

            Boolean check that every child in a list of branches is separated.

            def Cslib.DataStructure.BPlusTree.isWF {α : Type u} {β : Type v} [LinearOrder α] (t : ℕ) (tr : BPlusTree α β) :

            Boolean check of IsWF t.

            Equation lemmas #

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.leaves_leaf {α : Type u} {β : Type v} {entries : List (α × β)} :
            (leaf entries).leaves = [entries]

            A leaf is its own only leaf.

            theorem Cslib.DataStructure.BPlusTree.leaves_node {α : Type u} {β : Type v} {first : BPlusTree α β} {rest : List (Branch α β)} :
            (first.node rest).leaves = first.leaves ++ leavesRest rest

            The leaves of a node are those of its first child followed by those of the others.

            An empty list of branches has no leaves.

            theorem Cslib.DataStructure.BPlusTree.leavesRest_cons {α : Type u} {β : Type v} {rest : List (Branch α β)} {k : α} {c : BPlusTree α β} :
            leavesRest ((k, c) :: rest) = c.leaves ++ leavesRest rest

            The leaves of a list of branches start with those of the first child.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.leavesRest_eq_flatMap {α : Type u} {β : Type v} {rest : List (Branch α β)} :
            leavesRest rest = List.flatMap (fun (e : Branch α β) => e.child.leaves) rest

            The leaves of a list of branches are those of its children, in order.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.toList_leaf {α : Type u} {β : Type v} {entries : List (α × β)} :
            (leaf entries).toList = entries

            The entries of a leaf.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.toList_node {α : Type u} {β : Type v} {first : BPlusTree α β} {rest : List (Branch α β)} :
            (first.node rest).toList = first.toList ++ List.flatMap (fun (e : Branch α β) => e.child.toList) rest

            The entries of a node are those of its first child followed by those of the others.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.size_leaf {α : Type u} {β : Type v} {entries : List (α × β)} :
            (leaf entries).size = entries.length

            The size of a leaf is its number of entries.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.height_leaf {α : Type u} {β : Type v} {entries : List (α × β)} :
            (leaf entries).height = 1

            A leaf has height 1.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.height_node {α : Type u} {β : Type v} {first : BPlusTree α β} {rest : List (Branch α β)} :
            (first.node rest).height = max (first.height + 1) (heightRest rest)

            The height of a node is one more than that of its tallest child.

            An empty list of branches contributes no height.

            theorem Cslib.DataStructure.BPlusTree.heightRest_cons {α : Type u} {β : Type v} {rest : List (Branch α β)} {k : α} {c : BPlusTree α β} :
            heightRest ((k, c) :: rest) = max (c.height + 1) (heightRest rest)

            The height contribution of a list of branches.

            theorem Cslib.DataStructure.BPlusTree.heightRest_le_iff {α : Type u} {β : Type v} {rest : List (Branch α β)} {n : ℕ} :
            heightRest rest ≤ n ↔ ∀ e ∈ rest, e.child.height + 1 ≤ n

            A bound on the height contribution of a list of branches is a bound for every child.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.map_leaf {α : Type u} {β : Type v} {γ : Type w} {entries : List (α × β)} (f : β → γ) :
            map f (leaf entries) = leaf (List.map (fun (p : α × β) => (p.1, f p.2)) entries)

            Mapping a leaf maps the values of its entries.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.map_node {α : Type u} {β : Type v} {γ : Type w} {first : BPlusTree α β} {rest : List (Branch α β)} (f : β → γ) :
            map f (first.node rest) = (map f first).node (mapRest f rest)

            Mapping a node maps its children.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.mapRest_eq_map {α : Type u} {β : Type v} {γ : Type w} {rest : List (Branch α β)} (f : β → γ) :
            mapRest f rest = List.map (fun (e : Branch α β) => (e.1, map f e.child)) rest

            Mapping a list of branches maps each child and keeps the separators.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.children_leaf {α : Type u} {β : Type v} {entries : List (α × β)} :
            (leaf entries).children = []

            A leaf has no children.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.children_node {α : Type u} {β : Type v} {first : BPlusTree α β} {rest : List (Branch α β)} :
            (first.node rest).children = first :: List.map Branch.child rest

            The children of a node.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.width_leaf {α : Type u} {β : Type v} {entries : List (α × β)} :
            (leaf entries).width = entries.length

            The width of a leaf is its number of entries.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.width_node {α : Type u} {β : Type v} {first : BPlusTree α β} {rest : List (Branch α β)} :
            (first.node rest).width = rest.length

            The width of a node is its number of separators.

            Induction #

            theorem Cslib.DataStructure.BPlusTree.sizeOf_lt_of_mem_children {α : Type u} {β : Type v} {first c : BPlusTree α β} {rest : List (Branch α β)} (hc : c ∈ (first.node rest).children) :
            sizeOf c < sizeOf (first.node rest)

            A child of a node is smaller than the node: the measure for recursion into a child.

            theorem Cslib.DataStructure.BPlusTree.induction {α : Type u} {β : Type v} {motive : BPlusTree α β → Prop} (leaf : ∀ (entries : List (α × β)), motive (leaf entries)) (node : ∀ (first : BPlusTree α β) (rest : List (Branch α β)), motive first → (∀ e ∈ rest, motive e.child) → motive (first.node rest)) (tr : BPlusTree α β) :
            motive tr

            Induction on B+-trees, with a hypothesis for the first child and for every child among the branches. This replaces the raw nested recursor in proofs.

            Basic API #

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.mem_def {α : Type u} {β : Type v} {tr : BPlusTree α β} {p : α × β} :
            p ∈ tr ↔ p ∈ tr.toList

            Membership in a tree is membership in its entries.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.length_toList {α : Type u} {β : Type v} {tr : BPlusTree α β} :

            The number of entries is the length of toList.

            theorem Cslib.DataStructure.BPlusTree.size_node {α : Type u} {β : Type v} {first : BPlusTree α β} {rest : List (Branch α β)} :
            (first.node rest).size = first.size + (List.map (fun (e : Branch α β) => e.child.size) rest).sum

            The size of a node is the sum of the sizes of its children.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.mem_keys {α : Type u} {β : Type v} {tr : BPlusTree α β} {k : α} :
            k ∈ tr.keys ↔ ∃ (v : β), (k, v) ∈ tr

            A key belongs to keys exactly when some entry of the tree has it.

            theorem Cslib.DataStructure.BPlusTree.height_pos {α : Type u} {β : Type v} {tr : BPlusTree α β} :
            0 < tr.height

            Every tree has positive height: a leaf is a node on its own path.

            theorem Cslib.DataStructure.BPlusTree.height_eq_one_iff {α : Type u} {β : Type v} {tr : BPlusTree α β} :
            tr.height = 1 ↔ ∃ (entries : List (α × β)), tr = leaf entries

            The trees of height 1 are the leaves.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.leaves_map {α : Type u} {β : Type v} {γ : Type w} {tr : BPlusTree α β} (f : β → γ) :
            (map f tr).leaves = List.map (fun (l : List (α × β)) => List.map (fun (p : α × β) => (p.1, f p.2)) l) tr.leaves

            Mapping over values maps the leaves.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.toList_map {α : Type u} {β : Type v} {γ : Type w} {tr : BPlusTree α β} (f : β → γ) :
            (map f tr).toList = List.map (fun (p : α × β) => (p.1, f p.2)) tr.toList

            Mapping over values maps the entries.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.size_map {α : Type u} {β : Type v} {γ : Type w} {tr : BPlusTree α β} (f : β → γ) :
            (map f tr).size = tr.size

            Mapping over values preserves the size.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.keys_map {α : Type u} {β : Type v} {γ : Type w} {tr : BPlusTree α β} (f : β → γ) :
            (map f tr).keys = tr.keys

            Mapping over values preserves the keys.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.height_map {α : Type u} {β : Type v} {γ : Type w} {tr : BPlusTree α β} (f : β → γ) :
            (map f tr).height = tr.height

            Mapping over values preserves the height.

            The entries of a child form a sublist of those of the tree.

            theorem Cslib.DataStructure.BPlusTree.height_succ_le_of_mem_rest {α : Type u} {β : Type v} {first : BPlusTree α β} {rest : List (Branch α β)} {e : Branch α β} (he : e ∈ rest) :
            e.child.height + 1 ≤ (first.node rest).height

            A child among the branches is lower than its node.

            theorem Cslib.DataStructure.BPlusTree.height_first_succ_le {α : Type u} {β : Type v} {first : BPlusTree α β} {rest : List (Branch α β)} :
            first.height + 1 ≤ (first.node rest).height

            The first child is lower than its node.

            theorem Cslib.DataStructure.BPlusTree.height_succ_le_of_mem_children {α : Type u} {β : Type v} {tr c : BPlusTree α β} (hc : c ∈ tr.children) :

            A child is lower than its tree.

            Inversion #

            theorem Cslib.DataStructure.BPlusTree.Balanced.height_of_mem_rest {α : Type u} {β : Type v} {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Balanced) {e : Branch α β} (he : e ∈ rest) :

            The children among the branches of a balanced node have the height of the first child.

            theorem Cslib.DataStructure.BPlusTree.Balanced.height_node {α : Type u} {β : Type v} {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Balanced) :
            (fst.node rest).height = fst.height + 1

            A balanced node is one higher than its first child.

            theorem Cslib.DataStructure.BPlusTree.Balanced.first {α : Type u} {β : Type v} {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Balanced) :

            The first child of a balanced node is balanced.

            theorem Cslib.DataStructure.BPlusTree.Balanced.of_mem_rest {α : Type u} {β : Type v} {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Balanced) {e : Branch α β} (he : e ∈ rest) :

            The children among the branches of a balanced node are balanced.

            theorem Cslib.DataStructure.BPlusTree.Balanced.height_of_mem_children {α : Type u} {β : Type v} {tr c : BPlusTree α β} (h : tr.Balanced) (hc : c ∈ tr.children) :
            c.height + 1 = tr.height

            A child of a balanced tree is exactly one lower.

            theorem Cslib.DataStructure.BPlusTree.Balanced.of_mem_children {α : Type u} {β : Type v} {tr c : BPlusTree α β} (h : tr.Balanced) (hc : c ∈ tr.children) :

            A child of a balanced tree is balanced.

            theorem Cslib.DataStructure.BPlusTree.Occupied.width_le {α : Type u} {β : Type v} {t : ℕ} {c : BPlusTree α β} (h : Occupied t c) :
            c.width ≤ 2 * t - 1

            An occupied tree has at most 2 * t - 1 entries or separators at its root.

            theorem Cslib.DataStructure.BPlusTree.Occupied.le_width {α : Type u} {β : Type v} {t : ℕ} {c : BPlusTree α β} (h : Occupied t c) :
            t - 1 ≤ c.width

            An occupied tree has at least t - 1 entries or separators at its root.

            theorem Cslib.DataStructure.BPlusTree.Occupied.first {α : Type u} {β : Type v} {fst : BPlusTree α β} {rest : List (Branch α β)} {t : ℕ} (h : Occupied t (fst.node rest)) :
            Occupied t fst

            The first child of an occupied node is occupied.

            theorem Cslib.DataStructure.BPlusTree.Occupied.of_mem_rest {α : Type u} {β : Type v} {fst : BPlusTree α β} {rest : List (Branch α β)} {t : ℕ} (h : Occupied t (fst.node rest)) {e : Branch α β} (he : e ∈ rest) :

            The children among the branches of an occupied node are occupied.

            theorem Cslib.DataStructure.BPlusTree.Occupied.of_mem_children {α : Type u} {β : Type v} {tr : BPlusTree α β} {t : ℕ} {c : BPlusTree α β} (h : Occupied t tr) (hc : c ∈ tr.children) :

            A child of an occupied tree is occupied.

            theorem Cslib.DataStructure.BPlusTree.Separated.first {α : Type u} {β : Type v} [LinearOrder α] {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Separated) :

            The first child of a separated node is separated.

            theorem Cslib.DataStructure.BPlusTree.Separated.of_mem_rest {α : Type u} {β : Type v} [LinearOrder α] {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Separated) {e : Branch α β} (he : e ∈ rest) :

            The children among the branches of a separated node are separated.

            theorem Cslib.DataStructure.BPlusTree.Separated.le_of_mem {α : Type u} {β : Type v} [LinearOrder α] {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Separated) {e : Branch α β} (he : e ∈ rest) {p : α × β} (hp : p ∈ e.child.toList) :
            e.1 ≤ p.1

            A separator is at most every key of the child it introduces.

            theorem Cslib.DataStructure.BPlusTree.Separated.pairwise {α : Type u} {β : Type v} [LinearOrder α] {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Separated) :
            List.Pairwise (fun (a b : Branch α β) => ∀ p ∈ a.child.toList, p.1 < b.1) rest

            The keys of each child among the branches are below every later separator.

            theorem Cslib.DataStructure.BPlusTree.Separated.lt_of_mem_first {α : Type u} {β : Type v} [LinearOrder α] {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Separated) {e : Branch α β} (he : e ∈ rest) {p : α × β} (hp : p ∈ fst.toList) :
            p.1 < e.1

            The keys of the first child are below every separator.

            theorem Cslib.DataStructure.BPlusTree.Separated.lt_of_lt {α : Type u} {β : Type v} [LinearOrder α] {fst : BPlusTree α β} {rest : List (Branch α β)} (h : (fst.node rest).Separated) {i j : Fin rest.length} (hij : i < j) {p : α × β} (hp : p ∈ rest[i].child.toList) :
            p.1 < rest[j].1

            The separator convention between two positions of a node: the keys of the child at an earlier position are below the separator at a later one.

            theorem Cslib.DataStructure.BPlusTree.Separated.of_mem_children {α : Type u} {β : Type v} {tr : BPlusTree α β} [LinearOrder α] {c : BPlusTree α β} (h : tr.Separated) (hc : c ∈ tr.children) :

            A child of a separated tree is separated.

            theorem Cslib.DataStructure.BPlusTree.IsWF.sorted_of_mem_children {α : Type u} {β : Type v} {tr : BPlusTree α β} [LinearOrder α] {t : ℕ} {c : BPlusTree α β} (h : IsWF t tr) (hc : c ∈ tr.children) :

            Every child of a well-formed tree has sorted entries.

            theorem Cslib.DataStructure.BPlusTree.Occupied.isWF {α : Type u} {β : Type v} [LinearOrder α] {t : ℕ} {c : BPlusTree α β} (ht : 2 ≤ t) (ho : Occupied t c) (hb : c.Balanced) (hp : c.Separated) (hs : c.toList.IsSortedAssoc) :
            IsWF t c

            An occupied, balanced, separated tree with sorted entries is well-formed when 2 ≤ t: the occupancy of a non-root node implies the root rule.

            theorem Cslib.DataStructure.BPlusTree.IsWF.of_mem_children {α : Type u} {β : Type v} {tr : BPlusTree α β} [LinearOrder α] {t : ℕ} {c : BPlusTree α β} (h : IsWF t tr) (hc : c ∈ tr.children) :
            IsWF t c

            Every subtree of a well-formed tree is well-formed: non-root occupancy implies the root rule when 2 ≤ t.

            Decidability #

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.occupiedRest_eq_all {α : Type u} {β : Type v} {rest : List (Branch α β)} {t : ℕ} :
            occupiedRest t rest = rest.all fun (e : Branch α β) => occupied t e.child

            occupiedRest checks every child among the branches with occupied.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.balancedRest_eq_all {α : Type u} {β : Type v} {rest : List (Branch α β)} {n : ℕ} :
            balancedRest n rest = rest.all fun (e : Branch α β) => e.child.balanced && e.child.height == n

            balancedRest n checks that every child among the branches is balanced and of height n.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.occupied_iff {α : Type u} {β : Type v} {tr : BPlusTree α β} {t : ℕ} :

            occupied decides Occupied.

            @[simp]

            balanced decides Balanced.

            theorem Cslib.DataStructure.BPlusTree.belowLater_iff {α : Type u} {β : Type v} {rest : List (Branch α β)} [LinearOrder α] :
            belowLater rest = true ↔ List.Pairwise (fun (a b : Branch α β) => ∀ p ∈ a.child.toList, p.1 < b.1) rest

            belowLater decides that the keys of each child are below every later separator.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.separatedRest_eq_all {α : Type u} {β : Type v} {rest : List (Branch α β)} [LinearOrder α] :
            separatedRest rest = rest.all fun (e : Branch α β) => e.child.separated

            separatedRest checks every child among the branches with separated.

            @[simp]
            theorem Cslib.DataStructure.BPlusTree.isWF_iff {α : Type u} {β : Type v} {tr : BPlusTree α β} {t : ℕ} [LinearOrder α] :
            isWF t tr = true ↔ IsWF t tr

            isWF decides IsWF.

            @[instance_reducible]
            instance Cslib.DataStructure.BPlusTree.instDecidableOccupied {α : Type u} {β : Type v} (t : ℕ) (tr : BPlusTree α β) :
            @[instance_reducible]
            @[instance_reducible]
            @[instance_reducible]
            instance Cslib.DataStructure.BPlusTree.instDecidableIsWF {α : Type u} {β : Type v} [LinearOrder α] (t : ℕ) (tr : BPlusTree α β) :