Construction and Composition of Rooted Trees via Descent Functions

We propose a novel approach for studying rooted trees by using functions that we will call descent functions. We provide a construction method for rooted trees that allows to study their properties through the use of descent functions. Moreover, in this way, we are able to compose rooted trees with each other. Such a new composition of rooted trees is a very powerful tool applied in this paper in order to obtain important results as the creation of new rational and Pythagorean trees.


Introduction
Trees represent one of the most important topics in the combinatorial theory. Generating trees whose nodes are elements of a structure may constitute an important step for studying the properties of the structure itself and for the structure visualization.
In this paper, some structural properties of trees will be dealt in a novel way in order to make easy the tree generation for sets satisfying specific requirements.
One of the main subjects of the present work is the socalled descent functions. Identifying functions of this type allows to reveal a simple and direct technique to the generation of trees on sets equipped with a weight function over a partially ordered set. Furthermore, the introduced technique yields to a substantial simplification of the study of tree levels and easily and directly finds the degree of any node.
Moreover, we introduce a composition of trees, which represents a completely new and very powerful tool for the generation of trees. This operation gives the feasibility of generating a new tree starting from a given pair of trees associated with a generating system once we assign a partition of the system itself. We present some examples to show the power of this tool. In particular, the composition of trees will be used to construct new examples of trees of rational numbers (rational trees) and of trees of primitive Pythagorean triples (Pythagorean trees). These applications are of special interest because nowadays only three examples of the first type [1][2][3][4] and two of the latter are known [5][6][7]. On the other hand, one can observe that the used techniques allow to generate an infinite number of trees of either type, and that the shown applications are merely representative.
The techniques of explicit construction of the trees described here show some features that arise from properties of the algebraic elements involved, making themselves natural and rigorous.

Tree Construction via Descent Functions
In this section, we present a new and useful approach to rooted trees by using particular functions that we will call descent functions. Let us start from the following. Definition 1. A weight function over is a function : → , for any set and , such that (1) is a partially ordered set, where < is the relation of strict total order; (2) ∃ ∈ : ( ) < ( ), for all ̸ = ∈ ; (3) there are no infinite sequences ( ) ∞ =0 , with ∈ , such that for all , ( ) > ( +1 ).

Algebra
It is easy to see that the element is unique. Moreover, if satisfies the descending chain condition for sets, then condition (3) is immediately verified.
Definition 2. Given a weight function over , a descent function is a function : * → , where * = −{ }, such that ( ( )) < ( ) , ∀ ∈ * . (1) In this way, for all ∈ * , there exists an integer such that ( ) = (where = ∘ ⋅ ⋅ ⋅ ∘ ⏟⏟ ⏟⏟⏟⏟⏟ ⏟⏟⏟ ⏟⏟⏟⏟⏟ ⏟⏟). This is sufficient to use the functions and for generating rooted trees. Let us denote by T a rooted tree and by T its th level (T 0 contains only the root). We say that two nodes and are connected if and only if ( ) = or ( ) = . If ( ) = , then is a child node whose parent node is .
Definition 3. Given a rooted tree T, the level of a node is the natural number such that ∈ T .
The tree structure of T is then completely determined by the descent function , by means of and vice versa one has the following: Thus, a node in T belongs to the th level if and only if ( ) = and is the root.
Definition 4. We call descent tree a tree associated with a descent function over a set , as aforementioned, having weight function over . The structure ( , , , ) is the generative tree system.

Remark 5.
The nodes of rooted trees studied in this paper are labeled by the choice of the set ; that is, one and only one element of corresponds to each node of the tree. However, we will not refer in this case to the term label because in the following, we use such a term in order to classify the nodes in some classes.
Example 6. Let us consider the following weight and descent functions: It is straightforward to see that and satisfy Definitions 1 and 2, respectively, for = = N and = 1. Observing that −1 ( ) = { + 1, 2 } , even,  starting from the root 1, it is easy to construct the tree, represented up to the 4th level in Figure 1.

Example 7.
Let be the set of vectors ( 1 , . . . , ) such that ≥ 1, ∈ N 0 for every , and 1 ≥ 2 ≥ ⋅ ⋅ ⋅ ≥ . Moreover, let us consider = N and the weight function : → defined by And thus = (1). Let us use the following descent function: whose inverse is The resulting tree is where the level T contains all the partitions of the integer . Algebra 3 Definition 8. We call natural descent function of a rooted tree T the function ] T such that ] T ( ) is the parent node of , for any node ∈ T.
Definition 10. Let U be a descent tree, whose nodes are labeled by . The structure of U is determined by the following descent function: The tree U is an infinite tree, whose nodes have infinite degree.
Theorem 11. Given any countable rooted tree T, then there exists an injective function : T → U, such that the following diagram is commutative: The function of the theorem can be defined recursively. The idea is to assign an element of ∈ to a node of T that belongs to the th floor, such that the prime is the greatest divisor of . In particular, if is the root of T, then ( ) = 1. Moreover, let us suppose that is defined over all elements of T until the floor T . A node ∈ T +1 is the child of a node ∈ T . If ( ) = 1 1 2 2 . . . and is the th child of , then In this way, any countable rooted tree is contained in the universal tree U. Indeed, given a countable rooted tree T, it is determined by its natural descent function ] T . Furthermore, ] T is the restriction of to T.
Definition 14. Let us consider the rooted tree T, whose nodes are labeled by the set = ; V

=1
(disjoint union). We call types the sets . The fact that ∈ , that is, is a node of the type , determines the number of its children and their type. We call T a typed tree, and if ∈ , we indicate with the number of its children that are in (i.e., the number of its children that have type ).
In a typed tree, any node belongs to a type; that is, the number of children and their type is known. A similar class of tree is studied in [8,9], where the nodes of the tree are labeled considering the number of children and their label.
Remark 15. In the following, we directly use typed trees to derive the order of the levels as recurrent sequences. A sequence ( ) ∞ =0 recurs with characteristic polynomial if ( ) ∞ =0 satisfies the linear homogeneous recurrent relation given the initial conditions 0 , . . . , −1 . We also recall that the ordinary generating function related to a linear recurrent sequence is is determined from initial conditions (see, e.g., [10] for a survey on recurrent sequences).
Using previous notation, we can define the matrix of types as = ( ). Such a matrix easily allows to determine the counting sequence of the levels as a linear recurrent sequence.
=0 is a linear recurrent sequence whose characteristic polynomial is the characteristic polynomial of .
Proof. Let us define ( ) = |{ ∈ T : ∈ }|; then |T | = ∑ V =1 ( ) . Moreover, defining the distribution of the elements of T as it is immediate that It follows that any sequence ( ( ) ) ∞ =0 recurs with the characteristic polynomial of . Since |T | is the sum of the ( ) 's, then it is wellknown that |T | is a linear recurrent sequence with the same characteristic polynomial of the ( ) 's.
Example 17. Let us consider the tree constructed in Example 6. We consider the partition N = 1 ∪ 2 where 1 = { ∈ N : odd} and 2 = { ∈ N : even}. Then = ( 0 1 1 1 ): odd numbers have only one child which is an even number; even numbers have two children (one odd and one even). As a consequence, the sequence of the levels orders of such tree is the Fibonacci sequence. Indeed, the characteristic polynomial of is 2 − −1, and it is straightforward to check that |T 0 | = 1, Example 18. Let us consider the tree constructed in Example 7. This is an example of tree constructed via descent function Algebra 5 which is not a typed tree. By Proposition 16 it follows that in a typed tree the orders of the levels are a linear recurrent sequence. In Example 7, |T | is the number of partitions of the integer , and it is well known that such a sequence is not recurrent. Indeed, it is wellknown that the generating function of the sequence counting the number of partition of the integers is That is not a rational function (see, e.g., sequence A000041 in [11]).
However, it is interesting to see that only changing the set , the descent tree alters its structure and properties. Let us use the same set and functions , of the Example 7, but we change , taking the set of the vectors ( 1 , . . . , ) such that ≥ 1 and ∈ N for every . In this case, the inverse descent function is We easily see that = ( 1 1 1 1 ), whose characteristic polynomial is 2 − 2 . Thus, we have |T | = 2 , for any ≥ 0.
An important consequence of the use of descent functions for constructing trees is the possibility of composing trees to each other in order to obtain new ones. The composition of two descent trees is simple, and it is highlighted in the following.
Definition 19. Let T, be descent trees created by the generative tree systems ( , , , ) and ( , , , ), respectively. Let us consider any partition = ∪ formed by two subsets. We define R = T∘ , S as the composed descent tree whose  It is easy to see that since and are descent functions, the function , is still a descent function, and therefore R is still a descent tree. By Definition 19, it is clear that tree composition depends on the partition of and on the order of the subsets and considered in (19). This means that any partition generates two different trees; that is, In the next sections, we apply these tools to rational trees and Pythagorean trees.

Rational Trees.
A rational tree is a tree such that = Q + , where every positive rational number appears in the tree exactly once and each node generates children following some explicit rule. Actually, only three rational trees are known: the Kepler tree [3], the Calkin-Wilf tree [2], and the Stern-Brocot tree [1,4].
The oldest, but the less famous, is the Kepler tree, introduced by Kepler in Harmonices Mundi in 1619. The Kepler tree is a binary tree, that is; each node has two children by means of the following rule: Remark 20. The fractions / in rational trees are considered with , coprime.
It is easy to see that generates the Kepler tree: We can derive the corresponding generative system tree by means of from which we have the Calkin-Wilf tree: Now, we can apply the composition of descent functions stated in Definition 19 to the generative systems tree ( , , , ) and ( , , , ) obtaining a new generative system tree ( , , , ), where, for example, we can construct as follows: from which we can derive its inverse in order to construct the tree starting from the root 1/1 as follows: The generative system tree ( , , , ) generates the following tree: Such a tree is different from the Kepler, Calkin-Wilf, and Stern-Brocot trees. Moreover, every positive rational number appears exactly once in the tree. Indeed, given any rational number / , there exists a positive integer such that ( / ) = = 1/1, since is a descent function for the system ( , , , ) by construction.
generates a rational tree. Remark 22. Using different partitions of Q + into two subsets, we can apply Definition 19 in order to compose Kepler and Calkin-Wilf trees to obtain a new rational tree. This is a very important result because in this way, we are able to construct infinite rational trees.
Finally, we examine the Stern-Brocot tree from the point of view of the descent functions. The Stern-Brocot tree is a rational tree made up of mediants ( + )/( + ) of two fractions / and / , as described in Figure 2. It is not immediate to obtain the corresponding generative system tree (despite the Kepler and Calkin-Wilf cases). However, if we consider the 2 × 2 invertible matrices with determinant 1, we can find a descent function from which we can derive the Stern-Brocot tree. Precisely, we take the following: It is easy to observe that using the following transformation, We can construct the Stern-Brocot tree by using the generative system tree ( , , , ).
Remark 24. The use of the descent function provides a new explicit representation of the Stern-Brocot tree.
In [12], a method involving continued fractions has been proposed in order to locate the position of any rational number over the Stern-Brocot tree. Here, we highlight an iterative method (involving the generative system tree ( , , , )) to find the path of any rational number over the Stern-Brocot tree.
Given any rational number / in the Stern-Brocot tree (with ̸ = 1), then it is the mediant of the fractions / , / , where Indeed, if / is the mediant of / and / we must have and we obtain 8 Algebra from which We only need to find . Since and are coprime, ∈ Z * and we obtain If the rational number is 1/ the path on the Stern-Brocot tree is trivial to find. Thus, given any rational number / , we are able to construct the corresponding matrix [ ] ∈ (2, N) such that + = and + = . Using the descent function , we have Consequently the parent node of 11/8 is 7/5. Now, we know from (38) that 7/5 is the mediant of 3/2 and 4/3, and and the parent node of 7/5 is 4/3. Again, we have The parent node of 4/3 is 3/2. Similarly, we obtain that the parent node of 3/2 is 2/1, and finally we arrive to the root 1/1. Thus the path from the rational number 11/8 to the root in the Stern-Brocot tree is (  11  8  ,  7  5  ,  4  3  ,  3  2  ,  2  1  ,  1  1 ) .
Clearly, the th level order of PT 1 and PT 2 is the same as follows: The th level order of PT 3 is We observe that the sequence of level orders has ordinary generating function (see [10]) given by Finally, the th level order of PT 4 is The sequence (|PT 4 |) +∞ =0 is surprisingly the sequence A000129 of Pell numbers described in OEIS.