Finely homogeneous computations in free Lie algebras Philippe Andary

To cite this version:

Philippe Andary. Finely homogeneous computations in free Lie algebras. Discrete and Theoretical Computer Science, DMTCS, 1997, 1, pp.101-114. ￿hal-00955693￿

HAL Id: hal-00955693 https://hal.inria.fr/hal-00955693 Submitted on 5 Mar 2014

HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Discrete Mathematics and Theoretical Computer Science 1, 1997, 101–114

Finely homogeneous computations in free Lie algebras

Philippe Andary

Universit´e de Rouen, Facult´e des Sciences,Laboratoire d’Informatique de Rouen, F-76821 Mont-Saint-Aignan C´edex, France

E-Mail: [email protected]

Ly (A)

We first give a fast to compute the maximal Lyndon word (with respect to lexicographic order) of

k

N Ly (A)

for every given multidegree in . We then give an algorithm to compute all the words living in for any

k N given in . The best known method for generating Lyndon words is that of Duval [1], which gives a way to go

from every Lyndon word of length n to its successor (with respect to lexicographic order by length), in space and

(n) worst case O . Finally, we give a simple algorithm which uses Duval’s method (the one above) to compute the next standard bracketing of a Lyndon word for lexicographic order by length. We can find an interesting application of this algorithm in control theory, where one wants to compute within the command Lie algebra of a dynamical system (letters are actually vector fields).

Keywords: Lie algebras, finely homogeneous computations

1 Introduction

A = fa a a g k QhAi

2 k

Let 1 be a set with elements, and the associative (non-commutative) algebra

[x y ]= xy yx Q

on A. Defining a Lie bracket ( )onthis -module turns it into a Lie algebra, and we will

(A) A L(A) A QhAi

denote by L its Lie subalgebra generated by (i.e. is the on and its

 A enveloping algebra). A will now be called an alphabet, whose elements are the letters,and is the free

monoid (the set of all words) over A.

(A) Q

We know that L is a graded -module

M

L(A)= L (A)

n (1)

n1

L (A) L(A) n

where n is the submodule of generated by homogeneous components with degree .Further-

k

L (A) L (A) N

more, n is the direct sum of finely homogeneous submodules with multidegree such

j = n

that j . Hence we have

M

L (A) L(A)=

(2)

k

2N

1365–8050 c 1997 Chapman & Hall

102 Philippe Andary

(A) All the classical monomial basis of L are finely homogeneous (see Reutenauer [2], for example, or

Viennot [3]), i.e. their components are finely homogeneous Lie monomials, thus every computation on

(A)

Lie polynomials (the elements of L ) is nothing but a computation in some fine homogeneity class.

(A) We want to emphasize the use of a particular basis of L , the Lyndon basis, introduced by Chen et

al. in the late 1950s [4] (the interested reader can find all the details of its construction in Lothaire [5]).

a a a A

2 k

For this purpose, we choose a total order 1 on , which induces a lexicographic order



on A .Aword is a Lyndon word if it is primitive and minimal in its conjuguacy class. This means that

n 

u A n 2 vu = uv Ly (A) cannot be written as u for given in and ,and whenever .Wedenoteby

the set of Lyndon words over A.

0 00

( )

For every Lyndon word we define its (right) standard factorization as the unique couple of

0 00 00

=

Lyndon words such that and is of maximal length. Moreover, the recursive Lie bracketing of

[]

the standard factorization will be called the (right) standard bracketing of , denoted by .

u v )

It would be convenient to define the left standard factorization ( of as the unique couple of

= uv u

Lyndon words such that and is of maximal length. Then the recursive Lie bracketing of the left

()

standard factorization will be called the left standard bracketing of , denoted by .

Ly (A) [a]= a=(a) a

Note that A is included in and that for every letter .Asanexemple,let

= fa bg = aaabab s

A and ,then is Lyndon because it is primitive and for each of its proper

suffix s. The standard bracketings of are

[] = [a [[a [a b]] [a b]]]

() = [[a [a [a b]]] [a b]]



(A) A [Ly (A)] L(A)

It is well known that Ly is a factorization of and that is a basis of (called the Lyndon

(A) basis of L ).

The paper is organized as follows. First, we give a fast algorithm to compute the maximal Lyndon

k

Ly (A) N

word (with respect to lexicographic order) of for every given multidegree in . We will see that the letters of a Lyndon word which is maximal in its fine homogeneity class are as much ‘regularly

distributed’ as possible.

Ly (A)

In the second part, we give an algorithm to compute all the words living in for any given in k

N . The best known method for generating Lyndon words is that of Duval [1], which gives a way to go

from every Lyndon word of length n to its successor (with respect to lexicographic order by length), in

(n) A = fa bg

space and worst case time complexity O . It is easy to see that in the special case where and

k +3 k 1 k 1

= a ba b k0 2 1 2k +4

( ), there are Lyndon words of length between and its successor

k +2 k

ba b in the same fine homogeneity class (namely a ). Hence, this method has an exponential worst case time complexity for our purpose. Finally, we give a simple algorithm which uses Duval’s method (the one above) to compute the next standard bracketing of a Lyndon word for lexicographic order by length. We can find an interesting appli- cation of this algorithm in control theory, where one wants to compute within the command Lie algebra of a dynamical system (letters actually are vector fields). Standard bracketing are very expansive to compute in this context, and that is why we want to generate them as quickly as possible in the lexicographic order by length. Finely homogeneous computations in free Lie algebras 103 2 Maximal Finely Homogeneous Lyndon Words

2.1 Introduction



k

N Given in , the question is to find a description of the maximal finely homogeneous Lyndon word

with respect to lexicographic order

A maxfLy Ag

(3)

We will merely denote it by when no confusion is possible.

Before answering our question, let us give a short description of the problem’s background. Let be a



k

N

Lyndon word with fine homogeneity ;itiswellknown[5]that

X

w

(4)

w

Of course, if the only Lyndon word appearing in is itself, but the reciprocal may, or may not,

fa bg be true. Anyhow, this led us to an algorithmic answer to our former question, when A in a first time, then for any finite alphabet. Just for fun now, we know that the reciprocal is not true and we were

able to find a lot of counter examples (with the help of computers) for which

supp Ly Afg

(5) aabbabababaabbababababab

For example, each of the following words aabbabaabbabababaabbabab, and

aabbabababababababababab Ly fa bg

12) are in (12 and verify equation (5).

2.2 The Binary Case

A fa bg

Let us consider the case k , thus . We have the following:

n m

Theorem 1 Given any couple of positive integers, the MFHLynd function below returns the max-

Ly fa bg

nm)

imal Lyndon word in ( with respect to lexicographic order:

n m fa bg

function MFHLynd( , )

n m

# Input : is a couple of positive integers.

a bg

# f is the alphabet.

fLy fa bgg

# Output : max .

(nm)

begin

m

if (n )or( )

n m b

then Return(a )

m

else if n

n div m

then q

r n mo d m

if r

q +1 q 1 q m2

ba ba b

then Return(a )

q

rm fa a bg else Return(MFHLynd( ,))

104 Philippe Andary

m div n

else q

r m mo d n

if r

q 1 q +1 q n2

ab ab

then Return(ab )

q q+1

n rr fab ab g else Return(MFHLynd( ,))

end

n m

Proof. Let be any couple of positive integers. We will denote by the result of the MFHLynd

n m A

i i

function. As this algorithm is recursive, we denote by i , and the instances of formal parameters

i n n m m A fa bg

1 1

during the -th function call ( 1 , and ). Note that the algorithm will terminate

p i n m i

in a finite number of steps, say , since through each step the sum i will strictly decrease.

i

i

n m )

Furthermore, let us denote by the word ( at each stage .

i i

p n m m n

If then is a multiple of ,or is a multiple of , and we obviously have 1

fa bg

nm)

( .

p n q m r q r m

1 1 1

So let us consider the case , i.e. either 1 with and ,or

m q n r q r n n m r m n r r

1 1 1 2 2 1 1 1

1 with and .Then is or , depending on

q +1 q q

1 1 1

n m A fa a fab bg ab g

2 1

the value of and ,and 2 is or accordingly. Of course, because

Ly A Ly A 1

2 , and if we prove that



A

1 (6)

2

the previous inequality turns to an equality. Now the end of the proof is trivial: we have p ,but

relation (6) implies

2 p 1 (7)

Finally, for the proof to be complete, we have to justify relation (6). For this purpose, we will first

q

1

bg n q m r A fa a

1 2

suppose that 1 (thus ). We can write

q + q +

1 m 1 1

b ba a

1 (8)

fg q i m

2 1 i 1

and one can easily see that 1 ,and for (since

Ly fa bg h minfi g

i

nm)

( ). Next, the existence of would imply the existence of a Lyndon

Ly fa bg wv v v

1 1 1 2 t

nm)

word in ( which would be greater than . Indeed, let us write ,where

q x q +1 q +

1 1 1 h1

ba b w a ba x j j v

i 1

( h )andthe ’s are defined by the left standard bracketing of

w v v v

1 2 t 1 (9)

Furthermore, we will consider

0 q +1 q + 1

1 1 h1

a ba b

w (10)

00 q x+1

1

a b

w (11)

0

v w w v i

Some i ’s are greater than , some are not, but they are all greater than . So we can split those

0 0 00

w w w w between w and in two words, and apply the same transformation as in . Now construct

Finely homogeneous computations in free Lie algebras 105

0

v w

a sequence of Lyndon words, with those i that are greater than on the one hand, and the splitted ones

00 0

v v

on the other. Then concatenating this reordered sequence will give us a new Lyndon word which

i i

0

w w

is greater than 1 (because the former begins with , and the latter with ). But this fact contradicts the

h

maximality of 1 ,so doesn’t exist.

m n

Now, the second case mn,not a multiple of , is not substantially different from the previous

0 0

A b a A A

one. Let us denote by A the alphabet equipped with the reverse order .Then

 0 

ab b a A A such that and extends to an isomorphism from onto . Moreover, is order

preserving, and we have clearly

fa bg fa bg e

nm) (mn)

( (12)

u u e u u u 2

k k 1 where 1 is the mirror image of the word .

The analysis of this algorithm is trivial, since its recurrence tree is structurally equivalent to that of m

Euclide’s algorithm for computing the greatest common divisor of n and .Sowehave

n m

Theorem 2 For given positive integers , the worst case time complexity for MFHLynd function is

logmaxn m O .

Proof. See Knuth [6] for instance, Theorem 4.5.3-F and Corollary 4.5.3-L, p. 343. 2 2.3 The General Case

In a second time, we were able to generalize the function MFHLynd to any finite alphabet A in the

following manner: A

function MFHLynd(, )

k

k

# Input : 1 is a -tuple of positive integers.

A fa a g

k

# 1 is the (ordered) alphabet.

maxfLy Ag # Output : .

begin

n

1

P

k

m

i

i=2

m

if (n )or( )

2 k n

a a

then Return(a )

1

2

k

m

else if n

n div m

then q

r n mo d m

if r

then if k

q +1 q 1 q

m2

a a a a a a

2 2

then Return( 2 )

1 1 1

q q

fa a a a g

k 2 k

else Return(MFHLynd( 2 , ))

1 1

q q

r fa a a a a g

k 1 2 k

else Return(MFHLynd( 2 , ))

1 1

n

else h

k for i decreasing from downto do

106 Philippe Andary

q div h

i i

r mo d h

i i

h h r

i

i r

if ( i )

q q +1 q q 1 q q

2 2 k 2 k k

n2

a a a a a a a a a

1 1

then Return( 1 )

2 2 2

k k k

else t

k

for i increasing from to do

r

if i

t

then t

i i

t

P

t

n r r r

i i

Return(MFHLynd( i ,

t 1 j

j =1

q +1 q

+1 q q

i 1 i

i i 1 q q q q

2 k k k

1 1

t t

g a a a a a a fa a a a a

1 1

1 ))

i 2 i 1 i i 1

k k k

t t 1 end 1

We can reasonably expect the complexity of such an algorithm to be a function in the size of the alphabet

and in the maximum of the components i , but unfortunately, we were not able to analyse the behaviour of MFHLynd function in this case deeply enough.

3 Fine Homogeneous Generation of Lyndon Words

3.1 Introduction

k



Ly A N

Now the problem is to find all words in ,forevery in . We will need the following well known reducing property (see, for example, Duchamp and Krob [7] for a partially commutative version

of this proposition):

0  0

k Afa a g A Aa a Ly ALy A fa g

k k k

Proposition 1 Let ,1 and .Then .

k

Let us see, with an example, how we will dissect Lyndon words to solve our problem. Suppose

0  0

fa bg k A ab Ly ALy A b B

and A ( ). By proposition 1, if then . Denoting by

0 

A Ly A B

the minimal subset of such that , we mean the code

fa ab abb abbbg

B (13)

B Ly A

We want to find out all Lyndon words on that are in ; we know their fine homogeneity, but we

abbb a ab abb don’t know how they look like: there can be either two a and one , or one , one and one .

(Note that we cannot take three times ab, since Lyndon words are primitive.)

Hence, our initial problem breaks down into two ‘smaller’ subproblems – find all of the words in

Ly fa abbbg Ly fa ab abbg

1) (111) (2 and . These subproblems are smaller insofar as the length of

the involved Lyndon words are smaller over the new alphabets than over the previous one (here, we have

a abbbg fa ab abbg fa bg

to compare f and with ). It is still necessary to detail the way we compute

Ly fa ab abbg A fa ab abbg k B

11)

(1 .Herewehave , ( )and is the code

fa aabb ab ababbg B (14)

Finely homogeneous computations in free Lie algebras 107

Ly (A) B aabb ab a ababb

Every word in is a Lyndon word over , with either one and one , or one and one .

Thus

Ly (fa ab abbg)=Ly (faabb abg) Ly (fa ababbg)

11) (11) (11)

(1 (15)

a bg

Clearly, iterating this process will give, in a finite number of steps, every Lyndon word on f with

3)

fine homogeneity (3 . In fact, our algorithm will ultimately construct all alphabets with only one letter

Ly (fa bg)

3)

which is a word in (3 . For example, the subproblems’ decomposition tree in this case is

Ly (fa bg)

(33)

P

P

P

P

Pq

Ly (fa abbbg) Ly (fa ab abbg)

(21) (111)

H

H

H

Hj

Ly (fa aabbbg) Ly (fa ababbg) Ly (faabb abg)

(11) (11) (11)

Ly (faaabbbg) Ly (faababbg) Ly (faabbabg)

(1) (1) (1)

Ly (fa bg)=faaabbb aababb aabbabg

3) and finally, (3 . 3.2 Translation in Terms of Partition Looking closely at our process gives the feeling that breaking down our problem into smaller ones is

exactly the same as finding a set of partitions under some constraints. For example, in the first stage of our

4

x N x + x + x + x =3

2 3 4

previous computation we have searched for the set of elements in such that 1 ,

x +2x +3x +4x =6 (2 0 0 1) (1 1 1 0)

2 3 4

verifying the constraint 1 . We have accepted and , refused

3 0 0) x

(0 (since Lyndon words are primitive), and thereby found all the solutions in . Next, during



2

2

0

Ly (fa ab abbg) (x x ) N

11) the decomposition of (1 , we have searched for the set of elements in

verifying

x + x = 1

1 2

0 0

x + x = 1

1 2

0 0

x +2x +x +2x = 3

1 2

1 2

0

x x ) ((1 0) (0 1)) ((0 1) (1 0)) Here, again, we have found all the solutions in ( , namely and .

For a good formulation of the problem in terms of composition and partition, we will need some nota-

p N

tions and definitions. For every x in ,wedefine

jxj = x + x + + x

2 p 1 (16)

and

jjxjj = x +2x ++ px

2 p 1 (17)

108 Philippe Andary

p

p p x N jxj = n

A composition of the positive integer n into partsisa -tuple in such that .Furthermore,

jjxjj = n + x (n p) (n p)

when we say that is constrained by . We will denote by (resp. )theset

p

of all compositions of n into parts (resp. the set of all compositions constrained by ).



p

n p p y (N ) jy j = n y

A partition of the positive integer into partsisa -tuple in such that and 1

y 1 (n p) n p (n p)

p . We will denote by the set of all partitions of into parts, and by the set

n p y

of all partitions of into parts whose value does not exceed (thus 1 ).

) x x =(x x i

For consistency with our previous notations, we will call i the composition without

t 1

0 0 1 j t x x B

i x

any ’s (thus, for all , i and every other are zero), and we will denote by the subset

j

B i 1 j t

of elements of at the j -th place for lexicographic order ( ). Here is a trivial property which will be helpful for computing the compositions, since we know a constant worst case time complexity algorithm to derive the successor of a partition (see Nijenhuis and

Wilf [8]).

n p (n + n)

Proposition 2 For given , and , every partition in p is equivalent to a unique composition

(n p)

in .

y (n + n)

Proof. The proof is immediate if we see that, given a partition in p , the corresponding

x (n p) x y i i i

composition in is such that is nothing but the number of parts (in ) equal to (for all in

p] 2

[1 ).

0 0 1)

As an example, all the compositions constrained by 3, of 3 into no more than 4 parts are (2 ,

1 1 0) (0 3 0 0)

(1 and . Proposition 2 says that they are equivalent to the partitions of 6 into 3 parts not

2

1 1) (3 2 1) (2 2 2) 1 4

greater than 4, namely (4 , and ; which will become evident with the notation ,

3

2 y x

123 and . For every partition in this last form, which is equivalent to a composition , we will write

y y = 123 y =(111) x =y  the sequence of non zero exponents (for example, if then ); so that . 3.3 The Algorithm

Now we can state

k



j

k1 A=fa a g =( ) (N ) B := fa a :1

k 1 k i k

Theorem 3 Let ,1 and .Set

ik1 0j g := ( k)  k

k ,and for each in :

( +1) ( +1) X :=

k1 k 1 k

k1 1

Then we have

[ [

Ly (A)= Ly (B )

x (18)

2x2X

=2 A = fa bg =(n m)

Proof. On the one hand, we will study the case k , so we consider , and

m+1

j

= fab :0 j mg m +1 B x N

B .Thereis elements in , and to each composition ,we 

associate the fine homogeneous class of words in B



F = fw B : jw j j = x 0 j mg

x j

ab (19)

F F Ly (B ) x

Since x is never empty, there is at least one Lyndon word in (note that, by Proposition 1,

Ly (A) x F Ly (A) ) and we want to determine those such that x contains a Lyndon word in – thus every

Finely homogeneous computations in free Lie algebras 109

F Ly (A) Ly (A) Ly (B )

x

Lyndon word in x will belong to . Of course, will be the union set of over all

m+1

x N jxj = n jjxjj = n + m

these x. But it is clear that the only criteria for to be choosen are and .

n m +1 m

So x must be a composition of into no more than parts, constrained by , and the theorem is

k =2 = f(m)g X = (n m +1)

m

m)

proved when (with and ( ).

j

k2 B = fa a :1i k

On the other hand, we will now consider the case .Thenwehave i

(1) (k1)

k10j g jB j = k ( +1) x =(x x ) k

k and . Here, the problem is to find all in

k 1

+1 k

N such that

(i)

jx j = 1 i k 1

i ( )

P

1

k (20)

(i)

jjx jj = jj

i=1

Thus we must have, for all i, the inequalities

(i)

jjx jj +

i k

i (21)

( k)

and it is clear now that the set of solutions for system (20) is exactly the union set over k of

B j x

the j -tuple of (non-negative) integers verifying

(i)

jx j =

i (22)

(i)

jjx jj = +

i i

i k 1 2 for all 1 .

From Theorem 3 and Proposition 2, we can deduce the function FHGLynd, which takes as input an

A Ly (A)

alphabet and a multidegree , and outputs the set of elements in A

function FHGLynd(, )

=( ) k

k

# Input : 1 is a -tuple of positive integers.

A = fa a g

k

# 1 is the (ordered) alphabet.

Ly (A) # Output : .

begin

k =2 =1 =1

2

if ( ) and (( 1 )or( ))

1 2

fa a

then Return( g)

1 2

j

B := fa a :1 i k1 0 j g

k k

else i

XP hi := fg

Ly n := fg

( k)

for in k do

X := ( + )

+1 1 1 1

k

2 k 1

for i increasing from to do

X := X ( + )

+1 i i i

k

XP hi := XP hi X XP hi

for x in do

Ly n := Ly n xB FHGLynd( x)

Return(Ly n) end 110 Philippe Andary 3.4 Tests on the Execution Time Except for the FHGLynd function, the only algorithm at hand for computing the homogeneity class of Lyndon words could be one derived from Duval’s method. As we will see in the next section, this method

allows us to go from one Lyndon word to the (lexicographically) next one with the same length. Thus, a

k

new function, say FHGL, is born: given an alphabet A with letters and a homogeneity vector (with

n = jj Ly (A)

), construct the set by iterative application of Duval’s method, picking up those words

whose homogeneity is . However, we have to bear in mind that this is an exponential algorithm, since

n

k

) O (

the number of Lyndon words whose length is n is . We wanted to get a feeling on the complexities n of both methods. For this purpose, both have been implemented in Maple V.3 on an SS10 workstation under Solaris 2.3 operating system. The first time we found out that, for the generation of a given homogeneity class of Lyndon words, the

FHGLynd function is more efficient than FHGL.

k n

The second time, we decided, given a finite alphabet A of size and an integer , to generate all the

Ly (A)

words in n , first in lexicographic order by Duval’s method (algorithm D), and then by homogeneity

classes with our function (algorithm A). Although the average running time of A per homogeneity class n becomes gradually smaller than the running time of D while k and/or grow, algorithm A does not seem

to be linear in n, since algorithm D does, and their execution time ratio increases. Hence, it is obvious that these two algorithms are devoted to different problems: FHGL is well suited for lexicographic enumeration of Lyndon words of given length, whileFHGLynd is just right for homogeneity generation of Lyndon words. 4 Generating the Lyndon Basis 4.1 Introduction We want here to generate the standard bracketing of Lyndon words for lexicographic order by length. We know an efficient algorithm, due to Duval [1], which gives the next Lyndon word for lexicographic order by length with a constant average time complexity [9]. The idea is quite simple: adapt Duval’s method to obtain the index of the standard factorization in addition to the Lyndon word, of course, preserving time complexity; then a convenient tree data structure could be used to recursively store all the standard factorizations.

4.2 Duval's Theorem

We will write ‘’and‘ ’ for lexicographic order and lexicographic order by length, respectively. These 

total orders on A are defined as follows:

8



v uA

<

v

u iff or

:



(rst A )(a b A)(u = r as v = r bt a b)

8

juj jv j

<

v

u iff or

:

juj = jv ju v

S ()

For all Lyndon word , we will denote by , when it makes sense, its successor, for lexicographic

 order, which is not in A . It is computed as follows: remove all terminal maximal letters of ,then

Finely homogeneous computations in free Lie algebras 111

S

replace the last non-maximal letter by its successor in A. Notice that has always a smaller size than

A fa b cg S aaacc aab aabab S aaabb aaabc . For example, on , is (not !), and is . Duval proves

that n

Theorem 4 If is a Lyndon word with length , which is not maximal in its fine homogeneous class ; if

w is the following Lyndon word of for ‘ ’, then we have:

S S j n

if j

w

q q (23)

t 1

u u t

1 otherwise

u

where the i are Lyndon words derived from prefixes of .

u uj u j

More precisely, the i are defined as follows (where is the prefix of , whose length is ):

u S d ju j q n d r n d

1 1 1 1 1 1

1 div mod

d r r d u S u r d ju j q r

2 2 1 2 1 1 2 2 2 1

2 div mod

u Su r d ju j q r d r r d

1 t1 t t t t1 t t t1 t

t div mod

3 10

a bab

Let us have a feeling on the behaviour of the underlying algorithm on the Lyndon word

3 2 2 32

A fa bg a b S ab r

(over ). The first prefix we compute is ,since , and because 1 must

3 2 2 2 3 2 2 2

a b a b S a b a b S a ab

be positive. Then we get since , and finally, we compute giving

3 2 2 2

a b a bab

w .

jj

This algorithm is O in worst case time complexity, and Berstel and Pocchiola [9] have proved it to

k k k be optimal in average time complexity (actually, they give the asymptotic bound ,where is

the cardinal of A). 4.3 Adapted Duval's Algorithm We have seen that Duval constructs the next Lyndon word by computing successive prefixes, thus we had

the natural idea to use the left standard factorization instead of the right one, as usual. So, if we denote by

u u i the index of the left standard factorization of a Lyndon word , and with the notations of Theorem 4,

we have

q

1

u w S iw i w u iw d w

2 1

Theorem 5 If ,then ; otherwise if 1 ,then ,else

q q

t 1

u u iw nd

t t

1 and .

it u S u r

1 i1

Proof. First, we have to notice that, for all , the relation i implies the

d r succ u d u

i1 i i1 i 0

existence of the integer i in and the letter such that (set )

u u d

i1 i i i (24)

So we have

r r

d

i2 i1

d d

i1

1 i

z

u

i

z

u

i1

z

u

1

z 112 Philippe Andary

where grayed zones means the suppression of maximal letters.

S jS j n S

Now we can carry through the proof. If w this is because ,thatis

z iw i succ

n n1 n

1 with . In this case is obviously .

q

1

w u iw u 2

Otherwise, there are two cases left. On the one hand, when 1 we must have

d t t

1because of the preliminary remark. On the other hand, in the general case ( ,or and

q 1 q q

t t1 1

q w u u u

t t1 1

2 ), the longest prefix of which is Lyndon, is at least as long as ,since

u u u

2 t

1 . But according to the preliminary remark, it cannot be longer than this word. Hence

P

t1

q d q d n d iw 2

i t t t

i .

i=1

fa bg n

As an example, let us consider A and . Then we have the following table:

q q

t 1

iw u i w u

t 1

aaaab aaabb

aaabb aabab

aabab aabbb

2

aabbb ab b

2

ababb abbb

iw d t q n d q

2 2 2 for the four first lines is 1 ,since and , but for the fifth it is since .

Now, for the sake of completeness, let us give the slight improvement of Duval’s algorithm

i function NextLynd(, )

# Input : is a Lyndon word which is not maximal in its fine

# homogeneous class.

# i is the index of the standard factorization of . # Output : w , the successor of with same length, for lexicogra-

# phic order by length ; or the empty word if is maximal

# in its fine homogeneous class.

w w

# i , the index of the standard factorization of ; #or if is maximal in its fine homogeneous class.

begin A

let z be the maximal letter of for lexicographic order

n jj

w

k n

k z

while w do

k k

w k k

succ(w )

z if w

then Return(,0) else t

Finely homogeneous computations in free Lie algebras 113

i

d k

knd

while do

j d

for increasing from to do

w k j wj

k k d

6 n

while k do

t t

i k

n k

for j increasing from to do

w k j wj

k n

k z

while w do

k k

k w k

w succ( )

d k i

t

if t

q

then

k  n d

while do

j d

for increasing from to do

w k j wij

k k d

q q

k  n d

else while t do

j d

for increasing from to t do

w k j wij

k k d

t

if t

i

then Return(w , )

t q

else if and

w d

then Return( , )

w n d else Return( , t )

end

th

j j u succ A where u means the letter of ,and is the following letter of in . It is clear that the complexity is the same as for the original algorithm, since we have added only two tests in the function’s body (and also the use of four new integer variables).

References [1] Duval, J.-P. (1988). G´en´eration d’une section des classes de conjuguaison et arbre des mots de Lyndon de longueur born´ee. Theor. Comput. Sci. 60, 255–283. 114 Philippe Andary

[2] Reutenauer, C. (1993). Free Lie Algebras. London Mathematical Society Monographs, new series, Vol. 7. Academic Press. [3] Viennot, X. G. (1978). Alg`ebres de Lie libres et mono¨ıdes libres. Lecture Notes in Mathematics 691. Springer-Verlag. [4] Chen, K. T., Fox, R. H. and Lyndon, R. C. (1958). Free differential calculus, IV. The quotient groups of the lower central series. Ann. Mathematics 68, 81–95. [5] Lothaire, M. (1983). on words. Encyclopedia of Mathematics 17. Addison-Wesley. [6] Knuth, D. E. (1981). The Art of Computer Programming, vol. 2: Semi-numerical algorithms (2nd ed.) Addison-Wesley. [7] Duchamp, G. and Krob, D. (1994). Combinatorics in trace monoids II. In: Diekert and Rozenberg, editors, The Book of Traces. [8] Nijenhuis, A. and Wilf, H. S. (1975). Combinatorial Algorithms. Academic Press. [9] Berstel, J. and Pocchiola, M. (1992). Average cost of Duval’s algorithm for generating Lyndon words. Preprint no. 92-8, Laboratoire d’Informatique de l’Ecole Normale Sup´erieure, Paris.