Shuffle-like operations on ω-words

28

Transcript of Shuffle-like operations on ω-words

Shu�e-like operations on !-wordsAlexandru MateescuDepartment of Mathematics, University of Bucharest, Romaniaand Department of Mathematics, University of Turku, FinlandGeorge Daniel MateescuDepartment of Mathematics, University of Bucharest,Academiei, 14, sector 1, 70109 Bucharest, RomaniaGrzegorz RozenbergDepartment of Computer Science, Leiden University,P.O.Box 9512, NL-2300 RA Leiden, The NetherlandsArto SalomaaAcademy of Finland and Department of Mathematics,University of Turku, 20014 Turku, FinlandTurku Centre for Computer ScienceTUCS Technical Report No 61November 1996ISBN 951-650-884-7ISSN 1239-1891

AbstractWe introduce and investigate some shu�e-like operations on !-words and!-languages. The approach is applicable to concurrency, providing a methodto de�ne the parallel composition of processes. It is also applicable to parallelcomputation.The operations are introduced using a uniform method based on the no-tion of an !-trajectory. As a consequence, we obtain a very intuitive ge-ometrical interpretation of the parallel composition operation. Our mainresults concern associativity. A rather surprising interconnection betweenassociativity and periodicity will be exhibited.TUCS Research GroupMathematical Structures of Computer Science

1 IntroductionParallel composition of words and languages appears as a fundamental oper-ation in parallel computation and in the theory of concurrency. Usually, thisoperation is modelled by the shu�e operation or restrictions of this operation,such as literal shu�e, insertion, left-merge, in�ltration product, etc.However, no such operations have been de�ned or studied for !-wordsand !-languages.The shu�e-like operations considered below are based on syntactic con-straints on the !-shu�e operation. The constraints are referred to as syntac-tic since they do not concern properties of the !-words shu�ed, or propertiesof the letters that occur in these !-words. Instead, the constraints describethe general strategy to switch from one !-word to another !-word. Oncesuch a strategy is de�ned, the structure of the !-words that are shu�ed doesnot play any role.The syntactic constraints that we consider here are based on the notion ofan !-trajectory. Roughly speaking, an !-trajectory is a line in plane, startingin the origin and continuing parallel with the axis Ox or Oy. The line canchange its direction only in points with nonnegative integer coordinates.An !-trajectory de�nes how to move from an !-word to another !-wordwhen carrying out the shu�e operation.2 Basic de�nitionsThe set of nonnegative integers is denoted by !. If A is a set, then the setof all subsets of A is denoted by P(A).A closure operator on A, see [2], is a function ' : P(A) �! P(A) suchthat, (i) for all B � A, B � '(B), (ii) if B1 � B2, then '(B1) � '(B2),where B1; B2 � A, and (iii) for all B � A, '('(B)) = '(B).Let � be an alphabet, i.e., a �nite nonempty set of elements called letters.The free monoid generated by � is denoted by ��. Elements in �� are referredto as words. The empty word is denoted by �.If w 2 ��, then jwj is the length of w. Note that j�j = 0. If a 2 �and w 2 ��, then jwja denotes the number of occurrences of the symbol ain the word w. The mirror of a word w = a1a2 : : : an, where ai are letters,1 � i � n, is mi(w) = an : : : a2a1 and mi(�) = �. A word w is a palindromei� mi(w) = w. A weak coding is a morphism that maps each letter into aletter or into �. 1

For all other notions and results concerning formal languages that areused in this paper we refer the reader to [10].Let � be an alphabet. An !-word over � is a function f : ! �! �.Usually, the !-word de�ned by f is denoted as the in�nite sequencef(0)f(1)f(2)f(3)f(4) : : :An !-word w is ultimately periodic i� w = �vvvvv : : :, where � is a (�nite)word, possibly empty, and v is a nonempty word. In this case w is denotedas �v!. An !-word w is referred to as periodic i� w = vvv : : : for somenonempty word v 2 ��. In this case w is denoted as v!. The set of all!-words over � is denoted by �!. An !-language is a subset L of �!, i.e.,L � �!. The set of all words and !-words over an alphabet � is denoted by�1, that is �1 = �� [ �!.The notation \9!n" stands for \there exist in�nitely many n", whereasthe notation \9<!n" stands for \there are only �nitely many n".Let � be an alphabet and let � = a0a1a2a3 : : : be an !-word over �,where ai 2 � for all i 2 !. The following notations will be used: �(i; j) =aiai+1 : : : aj, where i � j, and �(i; !) = aiai+1ai+2 : : :, where i � 0. Moreover,In(�) denotes the set of those letters from � that occur in�nitely many timesin �, i.e., In(�) = f� 2 � j 9!n such that an = �g:If L � �� is a language, then L! denotes the the following !-language:L! = f� 2 �! j � = w0w1w2 : : : ,where wi 2 L; i � 0g:Assume that � and � are two alphabets. Let ' : � �! �� be a morphismand let � = a0a1a2 : : : be an !-word over �, where ai 2 �, for all i � 0. Theimage by ' of � is the !-word over � de�ned as:'(�) = �0�1�2 : : : ;where �i = '(ai) for all i � 0.Analogously, if � : � �! P(��) is a substitution, then�(�) = f 0 1 2 : : : j i 2 �(ai) for all i � 0g:A B�uchi automaton is a quintuple A = (Q;�; q0; �; F ), where Q is a �niteset of states, � is the input alphabet, q0 2 Q is the initial state, � is thetransition relation, � � Q� ��Q, and F � Q is the set of �nal states.Let � be an !-word over �, � = a0a1a2 : : :, where ai 2 �, for all i � 0.A run of A on � is a sequence of states s = s0s1s2 : : :, such that s0 = q0 and2

(si; ai; si+1) 2 �, for all i � 0. The run is successful i� In(s) \ F 6= ;. � isaccepted by A i� there exists a successful run of A on �.The !-language recognized by A is:L(A) = f� 2 �! j � is accepted by Ag:An !-language L is referred to as !-regular or B�uchi recognizable i� thereexists a B�uchi automata A such that L(A) = L. The reader is re�ered to[11] or [9] for a survey on !-languages and automata.We now recall some operations for formal languages that simulate theparallel composition of words.For general results concerning the theory of concurrency the reader mayconsult [8], [1] or [4].The shu�e operation, denoted by tt, is de�ned recursively by:(auttbv) = a(uttbv) [ b(auttv);and (utt�) = (�ttu) = fug;where u ,v 2 �� and a ,b 2 � .The shu�e operation is extended in a natural way to languages :the shu�e of two languages L1 and L2 is:L1ttL2 = [u2L1;v2L2 uttv:Example 2.1 abttbc = fabbc; abcb; babc; bacb; bcabg:The literal shu�e, denoted by ttl, is de�ned as:a1a2 : : : anttlb1b2 : : : bm = � a1b1a2b2 : : : anbnbn+1 : : : bm; if n � m;a1b1a2b2 : : : ambmam+1 : : : an; if m < n;where ai; bj 2 �: (uttl�) = (�ttlu) = fug;where u 2 ��.Example 2.2 abattlbc = fabbcag: 3

3 !-TrajectoriesIn this section we introduce the notions of the !-trajectory and shu�e on!-trajectories. The shu�e of two !-words has a natural geometrical in-terpretation related to lattice points in the plane (points with nonnegativeinteger coordinates) and with a certain \walk" in the plane de�ned by each!-trajectory.Let V = fr; ug be the set of versors in the plane: r stands for the rightdirection, whereas, u stands for the up direction.De�nition 3.1 An !-trajectory is an element t, t 2 V !. A set T , T � V !,is called a set of !-trajectories.Let � be an alphabet and let t be an !-trajectory, t = t0t1t2 : : :, whereti 2 V; i � 0. Let �; � be two !-words over �, � = a0a1a2 : : : ; � = b0b1b2 : : :,where ai; bj 2 �; i; j � 0.De�nition 3.2 The shu�e of � with � on the !-trajectory t, denoted �ttt�,is de�ned as follows:�ttt� = c0c1c2 : : :, where, if jt0t1t2 : : : tijr = k1 and jt0t1t2 : : : tiju = k2,then ci = � ak1�1; if ti = r;bk2�1; if ti = u:Remark 3.1 The shu�e on (�nite) trajectories of (�nite) words is investi-gated in [7]. In this case a trajectory is an element t, t 2 V �.Let � be an alphabet and let t be a trajectory, t = t0t1 : : : tn, where ti 2V; 1 � i � n. Let �; � be two words over �, � = a0a1 : : : ap; � = b0b1 : : : bq,where ai; bj 2 �; 0 � i � p and 0 � j � q.The shu�e of � with � on the trajectory t, denoted �ttt�, is de�ned asfollows:if j�j 6= jtjr or j�j 6= jtju, then �ttt� = ;, else�ttt� = c0c1c2 : : : cp+q+2, where, if jt0t1 : : : tijr = k1 and jt0t1 : : : tiju = k2,then ci = � ak1�1; if ti = r;bk2�1; if ti = u:4

Observe that there is an important distinction between the �nite case,i.e., the shu�e on trajectories, and the in�nite case, i.e., the shu�e on !-trajectories: sometimes the result of shu�ing of two words � and � on atrajectory t can be empty whereas the shu�e of two !-words over an !-trajectory is always nonempty and consists of only one !-word.Now we give a recursive de�nition of the operation ttt, where t 2 V !. Itwill lead to the same notion of ttt as De�nition 3.2.De�nition 3.3 Let � be an alphabet and let ai; i � 0 be letters from �.Consider the functions first and last! de�ned as:first(a0a1a2 : : :) = a0 and last!(a0a1a2 : : :) = a1a2 : : :The operation ttt, where t 2 V !, d 2 V is de�ned as follows:�ttdt� = � first(�)(last!(�)ttt�); if d = r;first(�)(�tttlast!(�)); if d = u:If T is a set of !-trajectories, the shu�e of � with � on the set T of!-trajectories, denoted �ttT�, is:�ttT� = [t2T �ttt�:The above operation is extended to !-languages over �, if L1; L2 � �!,then: L1ttTL2 = [�2L1;�2L2�ttT�:Notation. If T is V ! then ttT is denoted by tt!.Example 3.1 Let � and � be the !-words � = a0a1a2a3a4a5a6a7 : : :, � =b0b1b2b3b4 : : : and assume that t = r2u3r5uru : : :. The shu�e of � with � onthe trajectory t is:�ttt� = fa0a1b0b1b2a2a3a4a5a6b3a7b4 : : :g:5

The result has the following geometrical interpretation (see Figure 1):the trajectory t de�nes a line starting in the origin and continuing one unitright or up, depending of the de�nition of t. In our case, �rst there are twounits right, then three units up, then �ve units right, etc. Assign � on theOx axis and � on the Oy axis of the plane. The result can be read followingthe line de�ned by the trajectory t, that is, if being in a lattice point of thetrajectory, (the corner of a unit square) and if the trajectory is going right,then one should pick up the corresponding letter from �, otherwise, if thetrajectory is going up, then one should add to the result the correspondingletter from �. Hence, the trajectory t de�nes a line in the plane, on whichone has \to walk" starting from the origin O. In each lattice point one hasto follow one of the versors r or u, according to the de�nition of t.Assume now that t0 is another trajectory, say:t0 = ur5u4r3 : : : :The trajectory t0 is depicted in Figure 1 by a much bolder line than thetrajectory t. Observe that:�ttt0� = fb0a0a1a2a3a4b1b2b3b4a5a6a7 : : :g:Consider the set of trajectories, T = ft; t0g. The shu�e of � with � onthe set T of trajectories is:�ttT� = fa0a1b0b1b2a2a3a4a5a6b3a7b4 : : : ; b0a0a1a2a3a4b1b2b3b4a5a6a7 : : :g:-

6O xy

a0 a1 t0a2 a3t a4 a5 a6 a7 : : :b0b1b2b3b4...

Figure 16

The following two theorems are representation results for !-languages ofthe form L1ttTL2.Observe that we are using here the obvious associativity of the operationtt!. We will return to this matter in Section 4.Theorem 3.1 For all !-languages L1 and L2, L1; L2 � �!, and for all setsT of !-trajectories, there exist a gsm M and two letter-to-letter morphismsg and h such that L1ttTL2 =M(h(L1)tt!g(L2)tt!T ):Proof. Let �1 = fa1 j a 2 �g and �2 = fa2 j a 2 �g be two copiesof � such that �1, �2 and V are pairwise disjoint alphabets. De�ne themorphisms: g : � �! ��1, g(a) = a1, a 2 � and h : � �! ��2, h(a) = a2,a 2 �.Now consider the gsm M = (Q;�0;�; q0; �; F ), where Q = fq0; q1; q2g,�0 = �1 [ �2 [ V , � = �, F = fq0g and�(q0; r) = (q1; �), �(q0; u) = (q2; �);�(q1; a1) = (q0; a) and �(q2; a2) = (q0; a);for all a1 2 �1 and a2 2 �2.One can easily verify thatL1ttTL2 =M(h(L1)tt!g(L2)tt!T ):The next theorem shows that the gsm-mapping M of Theorem 3.1 is ofa particular type.Theorem 3.2 For all !-languages L1 and L2, L1; L2 � �!, and for allsets T of !-trajectories, there exist a morphism ' and two letter-to-lettermorphisms g, h and a regular !-language R, such thatL1ttTL2 = '((h(L1)tt!g(L2)tt!T ) \R):Proof. Let �1 and �2 be as before. De�ne the morphisms: g : � �! ��1,g(a) = a1, a 2 � and h : � �! ��2, h(a) = a2, a 2 �. Let R be the regular!-language, R = (r�1 [ u�2)!. 7

Now consider the morphism:' : (�1 [ �2 [ V ) �! ��;de�ned as: '(a1) = a, '(a2) = a and '(r) = '(u) = �.It is easy to see that:L1ttTL2 = '((h(L1)tt!g(L2)tt!T ) \R:Theorem 3.3 If L1 and L2 are regular !-languages, then L1tt!L2 is a reg-ular !-language.Proof. Without loss of generality we can assume that L1 and L2 are overthe same alphabet �. Let Ai = (Qi;�; qi0; �i; Fi) be B�uchi automata suchthat L(Ai) = Li, i = 1; 2. We de�ne a B�uchi automaton A = (Q;�; q0; �; F )such that L(A) = L1tt!L2 as follows. Q = Q1 �Q2� f0; 1; 2g. Elements inQ are denoted as [q1; q2; k], where qi 2 Qi; i = 1; 2 and 0 � k � 2. The initialstate is q0 = [q10; q20; 0], the �nal states are F = Q1�Q2�f2g. The transitionfunction � is de�ned in such a way that it simulates nondeterministicallyon the �rst component the automaton A1 or on the second component theautomaton A2. The third component of the states is used to record anoccurrence of a �nal state from F1 (by storing the value 1). The value 2 isstored if at some stage later a �nal state from F2 does occur. The value 0is stored in the third component whenever the �rst two components are not�nal states.Formally, the de�nition of � is:�([q1; q2; 0]; a) = f[�1(q1; a); q2; 0]; [q1; �2(q2; a); q2; 0]g if �1(q1; a) 62 F1;�([q1; q2; 0]; a) = f[�1(q1; a); q2; 1]; [q1; �2(q2; a); 0]g if �1(q1; a) 2 F1;�([q1; q2; 1]; a) = f[�1(q1; a); q2; 1]; [q1; �2(q2; a); 1]g if �2(q2; a) 62 F2;�([q1; q2; 1]; a) = f[�1(q1; a); q2; 1]; [q1; �2(q2; a); 2]g if �2(q2; a) 2 F2;�([q1; q2; 2]; a) = f[�1(q1; a); q2; 0]; [q1; �2(q2; a); q2; 0]g if �1(q1; a) 62 F1;�([q1; q2; 2]; a) = f[�1(q1; a); q2; 1]; [q1; �2(q2; a); q2; 0]g if �1(q1; a) 2 F1:8

Clearly, L(A) = L1tt!L2.The following theorem provides a characterization of those sets of !-trajectories T for which L1ttTL2 is a regular !-language, whenever L1, L2are regular !-languages.Theorem 3.4 Let T be a set of !-trajectories, T � fr; ug!. The followingassertions are equivalent:(i) for all regular !-languages L1, L2, the !-language L1ttTL2 is a regular!-language.(ii) T is a regular !-language.Proof. (i) ) (ii) Assume that L1 = r! and L2 = u! and note thatL1ttTL2 = T . It follows that T is a regular !-language.(ii)) (i) It follows from Theorem 3.2, Theorem 3.3 and from the closureproperties of regular !-languages under intersection and morphisms.4 Commutativity and AssociativityDe�nition 4.1 A set T of !-trajectories is referred to as commutative i�the operation ttT is commutative, i.e., �ttT� = �ttT�, for all alphabets �and for all �; � 2 �!.Example 4.1 Note that !-shu�e is a commutative set of trajectories, whereasfor instance, the literal !-shu�e, i.e., the shu�e over the set of !-trajectoriesconsisting of only one !-trajectory t,t = (ru)! = rururu : : :is noncommutative.Notation. The morphism sym : fr; ug �! fr; ug� is de�ned by sym(u) = rand sym(r) = u. 9

Remark 4.1 A set T of !-trajectories is commutative i� T = sym(T ).Proposition 4.1 If T is a regular set of !-trajectories, then it is decidablewhether or not T is commutative.Proof. If T is a regular !-language, then sym(T ) is also a regular !-language. Hence, the equality T = sym(T ) is decidable.Notation. Let C be the family of all commutative sets of !-trajectories.Proposition 4.2 If (Ti)i2I is a family of commutative sets of !-trajectories,then T 0, T 0 = \i2I Ti ,is also a commutative set of !-trajectories.Proof. Let � and � be !-words over �. Assume that w 2 �ttT 0�. Itfollows that for all i, i 2 I, w 2 �ttTi�. But, each Ti is commutative, hencew 2 �ttTi�, for all i, i 2 I. Therefore, w 2 �ttT 0�. Thus,�ttT 0� = �ttT 0�:This implies that T 0 is a commutative set of !-trajectories.De�nition 4.2 Let T be an arbitrary set of !-trajectories. The commutativeclosure of T , denoted �T , is �T = \T�T 0;T 02C T 0:Observe that for all T; T � fr; ug! , �T is an commutative set of !-trajectories and, moreover, �T is the smallest commutative set of !-trajectoriesthat contains T .Remark 4.2 The function �, � : P(V !) �! P(V !) de�ned as above is aclosure operator. 10

Remark 4.3 One can easily verify that:�T = T [ sym(T ):� AssociativityThe main results in this paper deal with associativity. After a few generalremarks, we restrict the attention to the set V !+ of !-trajectories t such thatboth r and u occur in�nitely often in t. (It will become apparent below whythis restriction is important.) It turns out that associativity can be viewed asstability under four particular operations, referred to as 3-operations. Thischaracterization exhibits a surprising interconnection between associativityand periodicity, which in our opinion is of direct importance also for the basictheory of !-words.De�nition 4.3 A set T of !-trajectories is associative i� the operation ttTis associative, i.e., (�ttT�)ttT = �ttT (�ttT );for all �; �; 2 �!.The following sets of !-trajectories are associative:1. T = fr; ug!.2. T = ft 2 V ! j jtjr <1g.3. T = frkt j t 2 V ! and k � k0g, where k0 � 0 is a �xed integer.4. T = f�0�0�1�1 : : : j �i 2 r�, �i 2 u� and, moreover, �i and �i are of even length, i �0g.Nonassociative sets of !-trajectories are for instance:1. T = (ru)!.2. T = ft 2 V ! j t is a Sturmian !-word g.3. T = fw0w1w2 : : : j wi 2 Lg, where L = frnun j n � 0g.11

De�nition 4.4 Let D be the set D = fx; y; zg. De�ne the substitutions�, � : V �! P(D�); as follows:�(r) = fx; yg , �(u) = fzg;� (r) = fxg , � (u) = fy; zg:Consider the morphisms ' and , ' , : V �! D�; de�ned as:'(r) = x , '(u) = y; (r) = y , (u) = z:Proposition 4.3 Let T be a set of !-trajectories. The following conditionsare equivalent:(i) T is an associative set of !-trajectories.(ii) �(T ) \ ('(T )ttz!) = � (T ) \ ( (T )ttx!):Proof. (i) ) (ii): Assume that T is an associative set of !-trajectories.Consider w such that w 2 �(T )\ ('(T )ttz!). It follows that there exists t1,t1 2 T , such that w 2 �(t1) and there exists t, t 2 T , such that w 2 '(t)ttz!.Assume that t1 = ri0uj1ri1 : : : ujnrin : : : ;for some nonnegative integers ig; jh , 0 � g; 1 � h. From the de�nition of �we conclude that w 2 fx; ygi0zj1fx; ygi1 : : : zjnfx; ygin : : : :Since w 2 '(t)ttz!, it follows that t = s0s1 : : : sn : : :, such that sk 2 V � andjskj = ik for all k , 0 � k. Therefore,w 2 (x!ttty!)ttt1z!:Because T is associative, there are t0 and t01 in T such that(x!ttty!)ttt1z! = x!ttt0(y!ttt01z!):Hence, we obtain that w 2 x!ttt0(y!ttt01z!), for some t0 and t01 in T . Now,it is easy to observe that this implies that w 2 � (T ) \ ( (T )ttx!). Thus,12

�(T )\('(T )ttz!) � � (T )\( (T )ttx!): The converse inclusion is analogous.Therefore, the equality from (ii) is true.(ii)) (i): Let � be an alphabet and let �; �; be !-words over �. Con-sider an !-word w, such that w 2 (�ttT�)ttT . There exist t and t1 in Tsuch that w 2 (�ttt�)ttt1 . Let v be the !-word obtained from w by re-placing each letter from � by x, each letter from � by y and each letterfrom by z. Observe that v is in �(t1) and also in '(t)ttz!. There-fore, v 2 �(T ) \ ('(T )ttz!). By our assumption, it follows that v 2� (T ) \ ( (T )ttx!). Hence, there are t0 and t01 in T such that v 2 � (t0) \( (t01)ttx!). Note that this means that v 2 x!ttt0(y!ttt01z!). Hence, itis easy to see that w 2 �ttt0(�ttt00 ), i.e., w 2 �ttT (�ttT ). Thus,(�ttT�)ttT � �ttT (�ttT ). The converse inclusion is analogous. There-fore, for all �; �; 2 �!,(�ttT�)ttT = �ttT (�ttT ):Thus, T is an associative set of !-trajectories.Proposition 4.4 If T is a regular set of !-trajectories, then it is decidablewhether or not T is associative.Proof. Observe that if T is a regular !-language, then the languages�(T )\ ('(T )ttz!) and � (T ) \ ( (T )ttx!) are regular !-languages. Hence,the equality (ii) from the Proposition 4.3 is decidable.Notation. Let A be the family of all associative sets of !-trajectories.Proposition 4.5 If (Ti)i2I is a family of associative sets of !-trajectories,then T 0, T 0 = \i2I Ti ,is an associative set of !-trajectories.Proof. Analogous to Proposition 4.2.13

De�nition 4.5 Let T be an arbitrary set of !-trajectories. The associativeclosure of T , denoted T , is T = \T�T 0;T 02A T 0:Observe that for all T; T � fr; ug� , T is an associative set of !-trajectoriesand, moreover, T is the smallest associative set of !-trajectories that containsT .Remark 4.4 The function �, � : P(V !) �! P(V !) de�ned as above is aclosure operator.Notation. Let V !+ be the set of all !-trajectories t 2 V ! such that tcontains in�nitely many occurrences both of r and of u.Now we give another characterization of an associative set of !-trajectoriesfrom V !+ . This is useful in �nding an alternative de�nition of the associa-tive closure of a set of !-trajectories and also to prove some other propertiesrelated to associativity.However, this characterization is valid only for sets of !-trajectories fromV !+ and not for the general case, i.e., not for sets of !-trajectories from V !.De�nition 4.6 Let W be the alphabet W = fx; y; zg and consider the fol-lowing four morphisms, �i, 1 � i � 4, where�i :W �! V !+ , 1 � i � 4;and �1(x) = � , �1(y) = r , �1(z) = u;�2(x) = r , �2(y) = u , �2(z) = u;�3(x) = r , �3(y) = u , �3(z) = �;�4(x) = r , �4(y) = r , �4(z) = u:Next, we consider four operations on the set of !-trajectories, V !+ .14

De�nition 4.7 Let 3i, 1 � i � 4 be the following operations on V !+ .3i : V !+ � V !+ �! V !+ , 1 � i � 4;Let t; t0 be in V !+1. 31(t; t0) = �1((x!ttty!)ttt0z!);2. 32(t; t0) = �2((x!ttty!)ttt0z!);3. 33(t0; t) = �3(x!ttt0(y!tttz!));4. 34(t0; t) = �4(x!ttt0(y!tttz!)):De�nition 4.8 A set T � V !+ is stable under 3-operations i� for all t1; t2 2T , it follows that 3i(t1; t2) 2 T , 1 � i � 4.Proposition 4.6 Let T be a set of !-trajectories, T � V !+ . The followingassertions are equivalent:(i) T is an associative set of !-trajectories.(ii) T is stable under 3-operations.Proof. The idea of the proof is that for two !-trajectories t, t0 and for the!-words x!, y! and z!, the operation 31 applied to t and t0 computes the(unique) trajectory t01 that occurs in the equality:(x!ttty!)ttt0z! = x!ttt1(y!ttt01z!):The operation 32 computes the (unique) !-trajectory t1 that occurrs in theabove equality. Analogously, 33 applied to t1 and t01 computes the (unique)trajectory t whereas 34(t1; t01) = t0.(i) =) (ii) Assume that T !+ is an associative set of !-trajectories. SinceT is associative, there are t1 and t01 in T such that(x!ttty!)ttt0z! = x!ttt1(y!ttt01z!):15

Hence, 31(t; t0) = �1((x!ttty!)ttt0z!) = �1(x!ttt1(y!ttt01z!)) == r!ttt01u! = t01 2 T:Thus T is stable for 31.Analogously,32(t; t0) = �2((x!ttty!)ttt0z!) = �2(x!ttt1(y!ttt01z!)) == r!ttt1u! = t1 2 T:Hence T is stable for 32.A similar proof shows that T is also stable for 33 and 34.(ii) =) (i) Now assume that T � V !+ is a set of !-trajectories stableunder 3i, 1 � i � 4.Let � be an alphabet and consider �; �; 2 �! and t; t0 2 T .Note that 31(t; t0) = t01 and 32(t; t0) = t1, for some t1, t01 2 T .Now it is easy to see that(�ttt�)ttt0 = �ttt1(�ttt01 ):Thus, we obtain that(�ttT�)ttT � �ttT (�ttT ):For the converse inclusion, the proof is similar, but using this time thefact that T is stable under 33 and 34.Remark 4.5 Here we like to point out why we restricted our attention tothe set V !+ and not to the general case V !. The operation 31 is de�ned toproduce the !-trajectory t01 (see the above proof). However, if T contains atrajectory t that is not in V !+ , then 31(t; t) is not necessarily in V !. Forinstance t = rur!, then 31(t; t) = ur 62 V !. Thus the operation 31 is notwell de�ned. A similar phenomenon happens with the operation 33.Comment. Observe that D = (P(V !+ ); (3i)1�i�4) is a universal algebra. IfT is a set of !-trajectories, then denote by �T the subalgebra generated by Twith respect to the algebra D. 16

Proposition 4.7 Let T � V !+ be a set of !-trajectories.(i) �T is an associative set of !-trajectories and, morover,(ii) �T= T , i.e., the associative closure of T is exactly the subalgebragenerated by T in D.Proof. (i) �T is stable under the operations 3i, 1 � i � 4 and thus, byProposition 4.6, �T is an associative set of !-trajectories.(ii) Observe that T ��T and that �T is associative, hence T ��T . For theconverse inclusion, let T 0 � V !+ be an associative set of !-trajectories suchthat T � T 0. Note that by Proposition 4.6, T 0 is stable under the operations3i, 1 � i � 4 and thus �T� T 0. Therefore �T� T .Proposition 4.8 Let T � V !+ be a set of !-trajectories.(i) If each t 2 T is a periodic !-word, then the associative closure of T ,T , has the same property, i.e., each !-trajectory in T is periodic.(ii) if additionally, each t 2 T has a palindrome as its period, then theassociative closure of T , T , has the same property.(iii) If T is a set of ultimately periodic !-trajectories, then the associa-tive closure of T , T , has the same property, i.e., each !-trajectory in T isultimately periodic.Proof. (i) Note that the morphisms �i, 1 � i � 4; preserve the periodicity.Now consider the operation 31. Let t1 = s! and t2 = s0!. De�ne p and q byp = jsjr and q = jsju. Observe that x! = (xp)! and y! = (yq)!. Let v bethe unique word xpttsyq (note that this is the shu�e over a �nite trajectory,see Remark 3.1). Obseve that x!ttt1y! = v! is a periodic !-word for somenonempty word v that contains both r and u (T � V !+ ).Now assume that i = js0jr, j = js0ju and k = jvj. Let n be the smallestcommon multiple of i; j; k. Assume that n = ii0 = jj 0 = kk0 for some positivenonzero integers i0; j 0; k0. Note that(x!ttt1y!)ttt2z! = v!tts0!z! = (vi0)!tts0j0! (zk0)! = �!;where � is the unique word vi0tts0j0 zk0.Hence 31(t1; t2) is a periodic !-word. Similarly, 3i(t1; t2) is a periodic!-word, 2 � i � 4.(ii) Observe that the morphisms �i, 1 � i � 4, are weak codings andhence they preserve the palindromes. The proof now proceeds as above. Theresulting periods are palindromes. 17

(iii) The proof is similar with the proof of (i).The above proposition yields:Corollary 4.1 The following sets of !-trajectories are associative:(i) the set of all periodic !-trajectories from V+!.(ii) the set of all periodic !-trajectories from V+! that have as their perioda palindrome.(iii) the set of all ultimately periodic !-trajectories from V+!.The next theorem provides a characterization of those !-trajectories thatare periodic. As such it is also a direct contribution to the study of !-words, exhibiting an interconnection between periodicity and associativity.The theorem gives also a concrete example of a calculation of the associativeclosure of a set of !-trajectories.Theorem 4.1 Let t be an !-trajectory such that t 6= r! and t 6= u!. Thefollowing assertions are equivalent:(i) t is a periodic !-word.(ii) t is in the associative closure of (ru)!.Proof. (ii) =) (i) It follows from Proposition 4.7, (ii) and Proposi-tion 4.8, (i).(i) =) (ii) Let A be the associative closure of the !-trajectory (ru)!.Assume that w is a nonempty word from V �, w = dj1i1dj2i2 : : : djkik , where dip 2fr; ug, 1 � jp, for all 1 � p � k and, moreover, diq 6= diq+1 , for all 1 � q < k.The degree of w, denoted deg(w), is by de�nition k. Note that for eachnonempty word w over V , deg(w) is a unique integer greater than 1. Let tbe a periodic !-word over V such that t 6= r! and t 6= u!. It follows thatt = w! for some nonempy word w. Clearly, deg(w) � 2.We prove by induction on deg(w) that t = w! is in A. First we prove twoclaims:Claim A. For all i; j � 1, the !-trajectories t = w!, where w = riu orw = urj, are in A.Proof of Claim A. Note that 31((ru)!; (ru)!) = (uru)!. Moreover,33((uru)!; (ru)!) = (ur)!. Hence we obtain that (ur)! 2 A.Assume now that w = riu, i � 1. We show by induction on i thatt = w! 2 A. For i = 1, obviously t 2 A. Assume the statement true for allw = riu with i � k and consider w = rk+1u. If k is an even number, say18

k = 2j, then let t1; t2 be the !-trajectories t1 = (ru)! and t2 = (rju)!. Bythe inductive hypothesis t2 is in A. Now observe that:34(t1; t2) = �4(x!ttt1(yjz)!) = �4((xy)jxz)!) = (r2j+1u)! = (rk+1u)!:Consider now the other case, i.e., k is an odd number, say k = 2j � 1. Lett1; t2 be the !-trajectories t1 = (rju)! and t2 = (ur)!. By the inductivehypothesis t1 is in A. Now observe that:33(t1; t2) = �3(x!ttt1(zy)!) = �3((xjzxjxy)!) = (r2ju)! = (rk+1u)!:Therefore (riu)! 2 A for all i � 1.A similar proof shows that (ujr)!; (urj)!; (ruj)! 2 A for all j � 1.Claim B. For all i; j; p; q � 1, the !-trajectories t = w!, where w = riujor w = uprq, are in A.Proof of Claim B. First assume that w = riuj, i; j � 1. The proof is byinduction on the number i + j. Obviously, if w = ru, then t = w! 2 A.The inductive step: let t1 = (riuj)! be in A. By Claim A it follows thatt2 = (ri+ju)! 2 A. Observe that:32(t1; t2) = �2((xiyj)!ttt2z!) = �2(xiyjz)!) = (riuj+1)!:Hence Claim B is true also for w = riuj+1.Note that the !-trajectory t3 = (rui+j)! is also in A, see Claim A. More-over, 34(t1; t3) = (ri+1uj)!. Therefore, for all words of the form w = riuj,i; j � 1; w! 2 A.A similar proof shows that for all words of the form w = uprq, p; q � 1;w! 2 A.We are now ready to prove Theorem 4.1, (i) =) (ii). Let t = w! be aperiodic !-word such that t 6= r! and t 6= u!. The proof is by induction onk = deg(w). The case k = 2 follows from Claim B. Assume the implicationtrue for words w with deg(w) � k. Let w be an word with deg(w) = k + 1,say w = ri1ui2ri3 : : : rikuq. Denote w1 = ri1ui2ri3 : : : rik and note that bythe inductive hypothesis the !-trajectory t1 = (w1)! is in A. Consider alsothe !-trajectory t2 = (rsuq)!, where s = jw1j and note that t2 is also in A.Observe that:32(t1; t2) = �2((xi1yi2 : : : xik)ttt2z!) = �2((xi1yi2 : : : xikzq)!) = t:Ifw = ri1ui2ri3 : : : uikrp, then denote w1 = ri1ui2ri3 : : : uik and note that againby the inductive hypothesis the !-trajectory t1 = (w1)! is in A. Consider19

also the !-trajectory t2 = (usrp)!, where s = jw1j and note that t2 is also inA. Moreover, it is easy to see that: 34(t2; t1) = t.The situation when w begins with u is similar.Comment. Theorem 4.1 provides another proof of Corollary 4.1. Thetheorem can also be used for calculations of the associative closure of othersets of !-trajectories. For instance let T = ft1; t2g, where t1 = (r2u)! andt2 = (r3u)!. In order to compute T observe that 31(t1; t2) = (ru)!. There-fore T is the set of all periodic !-trajectories, except r! and u!.� DistributivityObserve that for each set of !-trajectories, T , the operation ttT is dis-tributive over union both on the right and on the left side. Moreover, weadjoin to V ! a unit element with respect to each ttT , denoted 1. Note that 1is not an !-word. Hence, we obtain the following mathematically importantresult:Proposition 4.9 If T is an associative set of trajectories, then for any al-phabet �, S = (P(��);[;ttT ; ;; 1)is a semiring.Proof. One can easily verify the axioms of a semiring, see [3].5 FairnessFairness is a property of the parallel composition of processes that, roughlyspeaking, means that each action of a process is performed with not too muchdelay with respect to performing actions from another process. That is, theparallel composition should be \fair" for both processes performed.De�nition 5.1 Let T � fr; ug! be a set of !-trajectories and let n be aninteger, n � 1. T has the n-fairness property i� for all t 2 T and for allt0 2 V � such that t = t0t00 for some t00 2 V !, it follows that:j jt0jr � jt0ju j� n:20

This means that all !-trajectories from T are contained in the region ofthe plane bounded by the line y = x� n and the line y = x + n, see Figure2, for n = 4.Example 5.1 The !-literal shu�e, i.e., T = (ru)! has the n-fairness prop-erty for all n, n � 1.De�nition 5.2 Let n be a �xed number, n � 1. De�ne the language Fn as:Fn = ft 2 V !j j jt0jr�jt0ju j� n; for all t0 such that t = t0t00; t0 2 V �; t00 2 V !g:Remark 5.1 Note that a set T of trajectories has the n-fairness property ifand only if T � Fn.-

6O xy

����������������������������

��44 Figure 221

Proposition 5.1 For every n, n � 1, the language Fn is a regular !-language.Proof. We omit the straightforward construction of a B�uchi automatonfor Fn.Corollary 5.1 If T is a regular set of !-trajectories and n is �xed, n � 1,then it is decidable whether or not T has the n-fairness property.Proof. Note that the inclusion problem for regular !-languages is decid-able. Hence, this corollary follows from Proposition 5.1.Proposition 5.2 The fairness property is preserved by the commutative clo-sure.Proof. Assume that T has the n-fairness property for some n, n � 1.This means that:for all t 2 T and for all t0 such that t = t0t00 for some t00 2 V !, it followsthat: j jt0jr � jt0ju j� n:Obviously, j jt0jr � jt0ju j=j jsym(t0)jr � jsym(t0)ju j :Proposition 5.3 The fairness property is not necessarily preserved by theassociative closure.Proof. Consider the set of trajectories T = (ru)!. Using Theorem 4.1 weinfer that the associative closure of T does not have the fairness property.22

6 ConclusionsShu�e on trajectories provides a useful tool for the study of a variety ofproblems in the theory of !-words as well as in connection with parallel com-putation and the theory of concurrency. Besides, it opens a new view on thegeneral theory of !-words, as shown by our exhaustive characterization of theperiodicity of !-words. At the time of this writing, a similar characterizationfor the ultimate periodicity of !-words remains an open problem.Other aspects from the theory of concurrency and parallel computationsuch as priorities, the existence of critical sections, communication and theuse of re-entrant routines are studied using semantic constraints on the shu�eoperation. Indeed, these aspects are more related to the inner structure ofthe words that are shu�ed and cannot be investigated using only syntacticconstraints. We like to emphasize that perhaps the most useful and realistictypes of constraints are mixed, i.e., both syntactic and semantic.Of a special interest is to extend these operations to more complex objectssuch as graphs and networks or di�erent types of automata. In this way onecan obtain a more general framework to study the phenomena of parallelismand of concurrency.References[1] J. C. M. Baeten and W. P. Weijland, Process Algebra, Cambridge UniversityPress, 1990.[2] P. M. Cohn, Universal Algebra , D. Reidel Publishing Company, New York,1980.[3] J. S. Golan, The Theory of Semirings with Applications in Mathematics andTheoretical Computer Science, Longman Scienti�c and Technical, Harlow,Essex, 1992.[4] M. Hennessy, Algebraic Theory of Processes, The MIT Press, Cambridge,Massachusetts, London, 1988.[5] W. Kuich and A. Salomaa, Semirings, Automata, Languages, EATCS Mono-graphs on Theoretical Computer Science, Springer-Verlag, Berlin, 1986.[6] A. Mateescu and A. Salomaa, \Formal Languages: an Introduction and aSynopsis", Chapter 1, in Handbook of Formal Languages, eds. G. Rozenbergand A. Salomaa, Springer-Verlag, to appear.23

[7] A. Mateescu, G. Rozenberg and A. Salomaa, \Shu�e on Trajectories: Syn-tactic Constraints", Technical Report 96-18, University of Leiden, 1996.[8] R. Milner, Communication and Concurrency, Prentice Hall International,1989.[9] D. Perrin and J. E. Pin, Mots In�nis, Report LITP 93.40, 1993.[10] A. Salomaa, Formal Languages, Academic Press, New York, 1973.[11] W. Thomas, \Automata on In�nite Objects", in Handbook of TheoreticalComputer Science, Volume B, ed. J. van Leeuwen, Elsevier, 1990, 135-191.

24

Turku Centre for Computer ScienceLemmink�aisenkatu 14FIN-20520 TurkuFinlandhttp://www.tucs.abo.�University of Turku� Department of Mathematical Sciences�Abo Akademi University� Department of Computer Science� Institute for Advanced Management Systems ResearchTurku School of Economics and Business Administration� Institute of Information Systems Science