Proof. If P is reducible, P can be decomposed into⎡⎤⎡Q K 1 · · · K m0 P 1 · · · 0P = ⎢⎣.. . . . ..⎥. ⎦ and P n = ⎢⎣0 0 . . . P mQ n K 1 ′ · · · K m′0 P1 n · · · 0.. . . . .. .0 0 . . . Pmn⎤⎥⎦C<strong>on</strong>sidering all the paths in G(T ) of length n, starting in the root, the number of pathsending in comp<strong>on</strong>ent S l is N l (n) = d n ∑ i∈S lP1i n. Let us decompose all the paths ending in S linto two sub-paths: <strong>on</strong>e (of length k) before entering S l and <strong>on</strong>e (of length n − k) inside S l , weget from the decompositi<strong>on</strong> of P n , N l (n) = d n ∑ nk=0 (1, 0, . . . , 0)Qk K l u l , where u l is a vectorwhose coordinates are 1 in S l and 0 everywhere else.The number of 1 in the rooted subtree of T of size 2n is the number of <strong>on</strong>es in all the pathsof length n plus the number of <strong>on</strong>es in the sub<strong>trees</strong> of size 1. When n is large, the number of<strong>on</strong>es in the paths can be neglected with respect to the number of <strong>on</strong>es in the end <strong>trees</strong>.Finally, the number of <strong>on</strong>e in a tree of size 2n is the number of <strong>on</strong>es in each possible end-treeof size n times the number of such <strong>trees</strong>, namely N l (n). When n goes to infinity, the density of<strong>on</strong>es goes to ∑ l=1..m α l(1, 0, . . . , 0)(I − Q) −1 K l u l = (α 1 · · · α m )R t , with R l = (1, 0, . . . , 0)(I −Q) −1 K l u l .An example illustrating the computati<strong>on</strong> of the rooted average density of a tree is given inFigure 5. The graph G(T ) has two final comp<strong>on</strong>ents, <strong>on</strong>e aperiodic comp<strong>on</strong>ent with density 1 andanother <strong>on</strong>e with period 2 with average density 1/2. Starting from the root, both comp<strong>on</strong>entsare reached with probability 1/2. Therefore, such a tree has an average rooted density α =1/2(1/2) + 1/2(1) = 2/3.Also, it is not difficult to show that if all final comp<strong>on</strong>ent have a density (rather than anaverage density), then the tree has a rooted density, given by the same formula as in Theorem3.3.Finally, it is fairly straightforward to prove that since the K · K kernel P of the Markov chainassociated with G(T ) has all its elements of the form a/d, then the stati<strong>on</strong>ary probabilities π aswell as the average rooted density α of a rati<strong>on</strong>al tree are rati<strong>on</strong>al numbers of the form c/b with0 ≤ c ≤ b ≤ d K+1 . This fact will be used in the algorithmic secti<strong>on</strong> 5 to make sure that thecomplexity of the algorithms does not depend <strong>on</strong> the size of the numbers.4 Balanced and Mechanical TreesIn this secti<strong>on</strong>, we will introduce our most important definiti<strong>on</strong>s: str<strong>on</strong>gly balanced and mechanical<strong>trees</strong> and explore the relati<strong>on</strong>s between them. In particular we will prove that in the caseof irrati<strong>on</strong>al <strong>trees</strong> they represent the same set of <strong>trees</strong>, giving us a c<strong>on</strong>structive representati<strong>on</strong> ofthis class of <strong>trees</strong>. These results are very similar to the <strong>on</strong>es <strong>on</strong> words, which are summarizedbelow.4.1 Sturmian, Balanced and Mechanical WordsOne definiti<strong>on</strong> of a Sturmian word uses the complexity of a word. The complexity of an <strong>infinite</strong>word w is a functi<strong>on</strong> P w : N → N where P w (n) is the number of distinct factors of length n of theword w. A word is periodic if there exists n such that P w (n) ≤ n. Sturmian words are aperiodicwords with minimal complexity, i.e such that for any n:P w (n) = n + 1. (1)10
If x is a factor of w, its height h(x) is the number of letters equal to 1 in x. A balanced word isa word where the letters 1 are distributed as evenly as possible:∀x, y factors of w, |x| = |y| ⇒ |h(x) − h(y)| ≤ 1. (2)A mechanical word is c<strong>on</strong>structed using integer parts of affine functi<strong>on</strong>s. Let α ∈ [0; 1] andφ ∈ [0; 1). The lower (resp. upper) mechanical word of slope α and phase φ, w = w 1 w 2 . . . (resp.w ′ = w 1w ′ 2 ′ . . . ) is defined by:∀i ≥ 1w i = ⌊(i + 1)α + φ⌋ − ⌊nα + φ⌋,w ′ i = ⌈(i + 1)α + φ⌉ − ⌈iα + φ⌉. (3)These three definiti<strong>on</strong>s represent almost the same set of words. In the case of aperiodic words,they are equivalent: a word is Sturmian if and <strong>on</strong>ly if it is balanced and aperiodic if and <strong>on</strong>ly ifit is mechanical of irrati<strong>on</strong>al slope. For periodic words, there are similar relati<strong>on</strong>s:• A rati<strong>on</strong>al mechanical word is balanced.• A periodic balanced word is ultimately mechanical.A word is an ultimately mechanical word if it can written as xw where x is a finite word and w isa mechanical word. An example of a balanced word which is not mechanical (and just ultimatelymechanical) is the <strong>infinite</strong> word with all letter 0 and just <strong>on</strong>e letter 1. For a more completedescripti<strong>on</strong> of Sturmian words, we refer to [14].4.2 Balanced and str<strong>on</strong>gly balanced <strong>trees</strong>Using the two definiti<strong>on</strong>s of factors of a tree, we define two noti<strong>on</strong>s of balance for <strong>trees</strong>: the first<strong>on</strong>e and probably the most natural <strong>on</strong>e, is what we call balanced <strong>trees</strong> and the other <strong>on</strong>e is calledstr<strong>on</strong>gly balanced <strong>trees</strong>.Definiti<strong>on</strong> 4.1 (Balanced and str<strong>on</strong>gly balanced tree). A tree is balanced if for all n ≥ 0, thenumber of nodes label by 1 in two factors of size n differ by at most 1.A tree is str<strong>on</strong>gly balanced if for all n, k > 0, the number of 1 in two factors of size n andwidth k differ by at most 1.As the name suggests, the str<strong>on</strong>g balance property implies balance (by taking k = 1). Infact this noti<strong>on</strong> is strictly str<strong>on</strong>ger, see secti<strong>on</strong> 7 for an example of balanced tree that are notstr<strong>on</strong>gly balanced.Although the balance property is weaker and seems more natural for a generalizati<strong>on</strong> fromwords, our results will be mainly focused <strong>on</strong> str<strong>on</strong>gly balanced <strong>trees</strong> that have almost the sameproperties as their counterparts <strong>on</strong> words.4.2.1 Density of a balanced treeFor all node v and all size n, we denote by h v (n) the number of 1 in the factor of root v of size nand d v (n) the density of this subtree is the number of <strong>on</strong>es divided by the cardinal S(n) of thefactor: d v (n) def= 1S(n) h v(n).Propositi<strong>on</strong> 4.1.1 (Density of balanced tree). A balanced tree has a density α.Moreover for all node v and for all size n:|h v (n) − ⌊S(n)α⌋| ≤ 1 (4)11