Documentation

ArkLib.Data.Tree.General

General Trees with Arbitrary Arities #

This file defines general tree data structures where nodes can have an arbitrary number of children (represented as lists).

We provide two main variants:

Both support arbitrary arities and include helper functions for common operations like finding paths, checking properties, and accessing structure information.

inductive GeneralTree (α : Type u_1) :
Type u_1

A general tree with arbitrary arity where every node (including internal nodes) holds a value. The children are represented as a list, allowing for any number of child nodes.

Instances For
    instance instReprGeneralTree {α✝ : Type u_1} [Repr α✝] :
    Equations
    inductive GeneralLeafTree (α : Type u_1) :
    Type u_1

    A general tree with arbitrary arity where only leaf nodes hold values. Internal nodes are purely structural and do not store values. Used as input to general Merkle tree construction.

    Instances For
      def GeneralTree.getRoot {α : Type u_1} :

      Get the root value of a general tree, if it exists.

      Equations
      Instances For
        def GeneralTree.arity {α : Type u_1} :

        Get the number of children of a node.

        Equations
        Instances For

          Get the children of a node.

          Equations
          Instances For
            def GeneralTree.isLeaf {α : Type u_1} :

            Check if the tree is a leaf.

            Equations
            Instances For
              def GeneralTree.isEmpty {α : Type u_1} :

              Check if the tree is empty.

              Equations
              Instances For
                def GeneralTree.findPath {α : Type u_1} [DecidableEq α] (a : α) :

                Find the path from root to a leaf with the given value. The path is represented as a list of child indices.

                Equations
                Instances For
                  def GeneralTree.findPath.findPathInChildren {α : Type u_1} [DecidableEq α] (a : α) (children : List (GeneralTree α)) (idx : ) :
                  Equations
                  Instances For

                    Get the number of children of a node.

                    Equations
                    Instances For

                      Get the children of a node.

                      Equations
                      Instances For

                        Check if the tree is a leaf.

                        Equations
                        Instances For

                          Check if the tree is empty.

                          Equations
                          Instances For
                            def GeneralLeafTree.findPath {α : Type u_1} [DecidableEq α] (a : α) :

                            Find the path from root to a leaf with the given value. The path is represented as a list of child indices.

                            Equations
                            Instances For
                              def GeneralLeafTree.findPath.findPathInChildren {α : Type u_1} [DecidableEq α] (a : α) (children : List (GeneralLeafTree α)) (idx : ) :
                              Equations
                              Instances For
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For