AUTOMATA, LANGUAGES, A N D MACHINES VOLUME A
Pure and Applied Mathematics A Series of Monographs and Textbooks
Editors Paul A. Smith and Samuel Eilenberg Columbia University, N e w York
R E C E N T TITLES
ERNST AUIXSTBEHRENS. Ring Theory hioRRIs N E W M A NIntegral . Matrices Introduction . to Compact Transformation Groups GLENE. B I ~ E M N WERNER GIIEUB,STEPHI:N IIArmi1
80)
and
~=Q,,u...uQ~
If n
=
card Q, then since the sets Qi arc disjoint we must have Qn =
0.
23
4. Accessibility
Thus k n, and we have an a priori bound on the length of the proced u re. There is a set of notions dual to the above. These are best obtained by applying the definitions above to the reversed automaton d~ as defined in Section 3. For A c 9and A' c 0 the set X A in JY'Q will be denoted by Y24 Thus we have
YA
=
 + p with p
{ q 1 there exists a path c: q
E
.Y and I c I
E
A}
We let the rrader record the analogs of (4.1)(4.4) for this new operation. We further have
T h e automaton &' is said to be coaccessible if deis accessible, i.e.,
if
T;"
0
I 
Removing all the states in Q ~ TL" yields a s before a coaccessible automaton d bwith 1 d "I = 1 w ,' 1 . T h e automaton d is said to be trim if it is both accessible and coaccessible. T h e proof of the following proposition is left to the reader:
For any automaton d the following properties
PROPOSITION 4.1.
are egiiizialent : (i)
d is trim.
(ii) Every state is a vertex in some successjid path, (iii) Every path in d is a segment of some successful path. [Hint:
Prozw the implications (i) * (iii) 3 (ii) * (i).]
It is clear that for any automaton d ' a trim automaton d tis obtained by removing all states for which (ii) fails. Further the resulting trim automaton satisfies I ,Cy" I = 1 cd1. T h e reader will also notice that d t may be obtained by first passing from d to its accessible part and thcn taking the coaccessible part of T h e two steps may be reversed, i.e., one can first pass to the coaccessible part &'I' of d and then take T h u s in formulas we have the accessible part of d
'
j
.
(d")" =d t
Y
(,d'1)h.
II. Automata and Recognizable Sets
24
T h e notion of a trim automaton provides a simple proccdurc for deciding whethcr 1 1 == @. Indeed if this is the case, then the trim automaton d tassociated with ,iy' must be cmpty (i.e., Q = 0) and vice versa. EXERCISE 4.1. Let ,d = (0,I , 7') be a coarcessil,le Oautomaton. Show that the behavior .f the nutonraton (0,I , Q ) is the set of all initial segments of the elements of the set I d 1. Dually show that i f ,d is accessible, then the behavior of ( Q , 0, 7')is the set of all terminnl segnierits of the elements of 1 ,d I. Conrlude from the above that f o r any rerognizable subset A of S*, the sets I n A , 'rcr A , Seg 14 of all initial segments, terminal segments, and segments of elements of A , are rerogniznhle. 5. Finiteness and Iteration
Given a 2automaton &' = (Q, I , T ) , we shall now test the set A = 1 d I for finiteness. Without loss of generality we may assume that M is trim. Let n = card Q. We assert that A is finite 18d has no closed paths of length .,0. Indeed, assume C
44
is a closed path with 1 c path
1
=s f
1. By assumption there is a successful
. d
c
z  q 4 t Let
I d I = u, 1 e 1
=
v. Then us*zj c
A
so that A is infinite.
Conversely, assume A is infinite. T h e n A contains a word s with
1 s 1 2 n. T h e successful path c in d such that I c 1 = s will then involve a repeated state and thus cdwill have a closed path. A refinement of the argument above leads to the following very useful
PROPOSITION 5.1. If A is a recognizable subset of P, there exists an integer n such that i f s E A and 1 s I 2 n , then s admits a factorization uwv with w # 1 such that uw*v c A
5. Finiteness and Iteration
25
Furthermore, w can be chosen as u subsegment of n. I n particular, I zu I 5 n.
m7y
segment of s of length
Proof. 1,ct 4 = 1 Ld1 where d is a Yautomaton with n states. s and let c' be a segment of c of L e t c be a successful path with I c 1 length exactly n. Since c' must contain a repeated vertex, there results a factorization of c ~
11
iLppt
b
with d a subsegment of c' and with 1 d I f 1. Setting u I b 1, and zu = 1 d 1, it follows that uw*v c A I
=
I a I,
2' =
COROLLARY 5.2, If A is an infinite recognizable subset of S", then c A f o r some 14, w,z1 E 2*,with w 7 1 I
UW*F
T h e corollary just stated permits us to show that various sets are not recognizable. EXAMPLE 5.1.
Let
X=
( 0 , T}.
l ' h e set
is not rccognizable. Indeed, were .1 to be recognizable, it would have to contain I I W * Z ~for some u , zu, 21 E I*, w z 1. Clearly w cannot contain T as a letter since all words of A have only a single T . T h u s zu  0" for some n 0. Either u o r v (but not both!) must contain T . T h u s assume 71 = ap, ZJ = CT~TU".'I'hen
'I'o be in .1 we must have p 4kn + Y = s for all k z 0. T h i s is impossible since n t 0. Similarly the possibility u = U'TC', ZJ = 01' is excluded. EXAMPLE 5.2.
Let .Y
= ( 0 , T}.
'l'he set
*4 = {.W' I p 1O} is not recognizable. ?'he argument is very similar to the above and is left to t h e reader. Note that this example duplicates Example 2.8.
II. Automata and Recognizable Sets
26
EXAMPLE 5.3.
Let E =
(0,T } .
A
= (
T h e set 0
I p ~5 q }
is not recognizable. Indeed if A is recognizable, then so is the set
B
= {gW
I 5p}
obtained from A by reversal and interchanging the roles of c and z. Therefore A n B is recognizable. However, A n B is the set of Example 5.2. EXAMPLE 5.4. Let E = (0,T } . For every word s E E" let I s lo denote the number of 0's in s. Similarly let I s IT = I s I  I s I n . T h e set C=
($1
Islo=
ISl?)
is not recognizable. Indeed, intersecting C with the recognizable set O*T* (Example 2.7) we obtain the set A of Example 5.2. Similarly the set defined by the condition I s ,I 5 I s Ir is not recognizable.
1 , d = ( Q , I , T ) , and n = card Q. EXERCISE 5.1. Let A = I Show that A is finite iff I s I < n for all S E A. Show that A is infinite z f f n 5 I s I i 211 f o r some s E A . EXERCISE 5.2. Let JV' = ( Q , I , T ) be a Eautomaton such that = ( E p ) * where p 2 0 is an integer. Show that card Q 2 p .
I ,d I
EXERCISE 5.3. Rework Examples 5.1, 5 . 3 , and 5.4 by the method of Example 2.8. 6. Local Sets
Let d = (0,I , T ) be a 2'automaton and let Q set of edges in JV'. We define the set
#dc Q* called the graph of the automaton d as follows:
#d= AQ* n f.*B  Q"CQ"
=
{ ( p , 0,q ) } be the
6. Local
27
Sets
where the sets
A c Q,
B c Q,
C c Qe
are defined as
We also consider the very fine morphism
f: sz*
+
z*,
(p, G, q ) f
=G
Let c E #d. From (6.3) we deduce that c is a path in .d. From (6.1) and (6.2) we deduce that c is a successful path in &' and that 1 c 1 # 1. Further cf = 1 c 1 . Conversely, every nontrivial successful path c in Ld is an element of #d. This implies
#df=1&'1nS+
(6.4) and if I n T
=
0, then #df= I d 1
Subsets L of Z* of the form (6.5 1
L
=
AZ* n Z"B
 S"CZ"
with (6.6)
A , B c 1,
C c Z2
will be called local sets. T h e term "local" derives from the observation that local scanning of the word s E Z* suffices to determine whether or not s E L. is an example of a local subset T h e graph #&' of an automaton of a". Thus the fact established above yields: THEOREM 6.1. Let S be a finite alphabet and A a recognizable subset of S+. There exists then a finite alphabet Q, a very fine morphism f: sZ* + Yr", and a local subset B of Q* such that Bf = A I
Local sets play a considerable role in the subsequent development. We shall therefore establish some of their properties here.
II. Automata and Recognizable Sets
28 PROPOSITION 6.2.
The intersection of two local subsets of 2" is a
local set.
Observe that the union of two local sets need not be local ; for instance, aJ" n P a , and a 2 P n P a , are local sets while their union is not if a1 f (T, , al, a2 E 2. PROPOSITION 6.3. If f: 1'" +.P is a very fine morphism and L is a local subset of S", then L f  I is a local subset of rx. Proof. If L is defined by the sets A , B , C as in (6.5) and (6.6), then L f l is defined by Af', B f  I , and Cf  l I
Note that the conclusion of the proposition fails i f f is only assumed to be fine. Indeed let Z = {a}, r = { t ,y } , t f = a,yf = 1. T h e subset a of .P is then local (take A = B = a,C = a2).Howcver, of' = y * t y " is not local. Indeed, assume y%y" is local and is given by A , B c r, C c T".Since t , y t y and y 2 t y 2 are in y % y X it follows that A = B = 1', and that y ~ , t yand y 2 are not in C. T h u s C = @ or C = t2.This gives a contradiction since y%yM f rfand y%y* f r+ r"t2r". PROPOSITION 6.4. Let Z c T.If L is a local subset of Z*, then L is also a local subset of l'" Proof. Let L be given by the subsets A , B c 2, C c Z2. T h e n L as a subset of rx is given by the sets A , B, C' where C' = C u (r2  2 2 )
r 2
I
PROPOSITION 6.5.
Every local set is yecognixable.
Let L be a local subset of 2" given by (6.5) and (6.6). Consider the Sautomaton ,d= (2 u 1, 1, B ) Proof.
with edges t 4 , a
if
1 L a
if
ta$C U E A
29
References
If s = 01. .
[email protected],> E L , then c1 E A , o,?E B, u i o i t l4 C for all 1 5 i < n. This means exactly that
is a successful path in A ? ' with label s. T h u s 1 JY'
1
=
L
I
EXERCISE 6.1. Let &' = (Q, I , T )be a Sautomaton with I n T = 0, let #d be its graph, and let d'be the automaton constructed in the proof of Proposition 6.5 for L = #d.Show that if d i s accessible, then so is G d Show t . that if ,d is trim, so is d t . EXERCISE 6.2. Prove the conclusion of Proposition 6.3 under the assumption that f: r" 4Z" is a morphism such that 1 = If  l . References
See the References list at the end of Chapter 111.
111
CHAPTER
Deterministic Automata
‘The notions of a deterministic and of a complete automaton bring the subject of automata closer to abstract algebra. T h e notion linking the two subjects is that of a “module.” Thus, gradually, algebraic concepts, methods, and techniques are introduced and brought to bear upon the theory of automata.
1. Basic Definitions
A Zautomaton &‘ = (Q, I , T ) is said to be deterministic if it satisfies the following two conditions: (1.1)
Ldhas at most one initial state
(1.2)
For q
E
Q and
CT
E
L‘ there is at most one edge
CT:
y
+
p in d.
‘rhe deterministic automaton &‘is said to be complete if in (1.1) and (1.2) we can replace “at most one” by “exactly one.” T h e adjective “complete” will be used so as to include “deterministic.” Thus we shall say “complete automaton” rather than “complete deterministic automaton.” EXAMPLE 1.1 T h e automaton constructed in the proof of Proposition II,6.5 is deterministic, and is complete iff L = Q*B, i.e., A = 2,
c = a.
30
1. Basic Definitions
31
Following the notation introduced in II,4 we shall write go = p whenever an edge (r: q 4 p exists in &'. If no edge starting at q and carrying the label a exists, then we write pa = We thus obtain a partial function
a.
(1.3)
QXxrQ
which determines the edges in d. If &'is complete, then (1.3) is a function. Purely algebraically we may extend (1.3) to a partial function
satisfying the following conditions 1)e = 4
(4, 0)0
=
qa
( ( 9 , s ) k t)o
=
(9,
(1.5)
Usually 0 is not named and qs is written instead of ( q , s)B. T h u s the conditions above become (1.6)
ql
=
9,
(QS)t = q(st)
Whenever a partial function (1.3) or equivalently a partial function (1.4) satisfying (1.6) is given, we say that Q is a right Xmodule with (1.4) or (1.6) as action. If (1.3) is a function or equivalently if (1.4) is a function, then the module is said to be complete. If Q is the set of states of a deterministic automaton d, then qs is the end of the unique path starting at q and having label s, if such a path exists. If not, then qs = (3.In particular,
Id1
=
{s 1 is
E
T}
'l'he distinction between deterministic automata and complete automata is very slight. Given a deterministic automaton &'= ((3, i, T ) , a coniplete automaton & = (p, i', 7') called the completion of d is defined as follows. If JY' is complete, then & = d. If d i s not complete, then either i = 3 or qa = 3 for some pair q E Q, a E 2, or both. We adjoin to Q a new state denoted by T h u s 0. = Q u 0. If i = g , then 'i = 0, otherwise 'i : i. T h e action of X on ,O. is given by
n.
qa
if
qo F v3 in Q
q.a=n
if
q(r=(3 i n Q
q .a
=
.a=o
I l l . Deterministic Automata
32
We use the "dot" to differentiate between the action of 2 on Q and that on Q". The resulting automaton ,dUis complete. Since 0 is not terminal it will not lie on any successful path in ,dC and therefore
1
,dC
I
=
1 ,d I
If ,d is a deterministic automaton, then so are the accessible part ,da, the coaccessible part ,@", and the trim part ,dt of d. If ,d is complete, then dii also is complete, however, LdcO and d tneed not be complete. If &'is accessible, then so is its completion ,dr.
Let A be a complete and accessible automaton. Show is not coaccessible, then the coaccessible part of ,dis not complete. that if Give examples. EXERCISE 1.1.
EXERCISE 1.2. Show that if ,dis a trim deterministic automaton which is not complete, then ,dCis accessible but not coaccessible. EXERCISE 1.3. Show that a recognizable subset '4 of 2" is the behavior of a complete coaccessible automaton $f each word s in C* is an initial segment of some word in A. 2. The Subset Construction
Let ,d= (0,I , T ) be a 2automaton (not necessarily deterministic). In I I , 4 we defined for X c 0, s E C"
Xs
=
{q I there exists a path c: p
3
q with p
E
X and I c I = s}
and we have verified the rules
X1
=
x,
X(s2) = ( X S ) t
Thus, de facto, we have converted the set Q of all subsets of Q into a complete right 2module. We have also shown [formula 11,(4.6)] that
I ,QI I = {s I Is n T # 0} If we therefore define
2. The Subset Construction
33
and consider the complete Zautomaton
*d= (Q, I , T ) then
I dl
= {S
I IS
T I = {S
11s
n T f U} = 1 ,d
I
T h e complete automaton .d is said to be obtained from ,dby the subset construction. This construction implies : THEOREM 2.1. Each recognizable strbset of complete Eautomaton I
X* is the behavior
of a
As an application we prove: PROPOSITION 2.2. The complement .Y* A of L* is recognizable. Proof.
A
=

A of a recognizable subset
Let ,d=(Q, i, 7’) be a complete :automaton such that Consider the automaton d‘ = (0,i , Q T ) . Then
I ,d 1.
~
We shall use the above to answer the following decision question: PROPOSITION 2.3. Ciuen two recognizable sets A , B in Z*, it is decidable whether B c A . It is important to understand properly the phrase “given two recognizable sets A , B in Z*.” This means that automata L d a n d 2 are given such that 1 ,d I = A , 1 3’ I = B. ‘l‘he question must then be answered in terms of effective and explicit constructions on ,dand 2.I n view of the subset construction we may assume that d is complete. Using the proof of Proposition 2.2 we construct an automaton d ’such that IA ! ‘ ‘ 1 = L* A. Now the product construction of I I , 3 yields an aux 3? with behavior tomaton d = d ’
the trimming procedure of II,4we can find out whether Applying to ‘6 or not 1 ’ 8 1 = g. T h u s we can decide whether or not B c A I
Ill. Deterministic Automata
34
I n practice, the subset construction is quite inefficient. Indeed, if the automaton &’= ( Q ,I , T ) has n states, then the automaton d” has 2’b states. Many of these will be inaccessible. A more efficient construction would aim directly at the accessible part d* of d: T h e procedure given in II,4 for the construction of the accessible part of &can also be used to give a direct construction of dAa. This will be illustrated in Section 5. This modified procedure will be called the accessible subset construction. Note that the empty set (3 may or may not be a state of d”*. If it is, then it is not a terminal state. Omitting B as a state, we obtain a deterministic automaton (which is no longer complete) with unchanged behavior. I n practice (as we shall see in Section 7) we shall always use the accessible subset construction with omitted. EXERCISE 2.1. Let &’ and 8 be deterministic 1automata witlz m and n states, respectively, and with d complete. Show that if
sE
I A I

sE
I ,dI
whenever
I s I < mn
EXERCISE 2.2. Let d a n d 3’be (nondeterministic) Sautomata with m and n states, respectively. Show that if I
sE
I R I
3
sE
I ,dI
whenever
I s I < 2”n
EXERCISE 2.3. Show that the following question is decidable for given recognizable subsets A , B of .F:
( A  B ) u ( B  A ) is finite 3. The Division Calculus Let M be a monoid. For each a
E
M the function
L,: M + M called left multiplication by a is defined by
bL,
=
ab
3. The Division Calculus
35
Similarly, right multiplication by n
R ~i ~w + : '12 is defined by
bR,
=
ba
If A is a subset of M , we define the relations
I t follows that for any B c M
BL,
=
AB,
BRA,= B A
where
AB
=
{ab I u
E
A, b E B )
We shall also be interested in the inverse relations
L;', Lj', R;', R j ' : A!l
+
M
We have
I s E hi', U S = b } bR,' = {,x 1 x E M , X U b} BLjl = {x I x E M, A x n B f BR,' = {x I x E M , x,4 n B f bL;'
= {X
:
@}
@}
Observe that if M is a group, then BL;' = a'b and bR;' Because of this we adopt the notation
BL,'
=
k ' B,
BR,'=
=
ba'.
BA'
even in the case when M is not a group. Observe that if Ad is a free monoid, then L;' is a partial function; indeed, for any b E J!l there is at most one x E M such that ax = b. T h u s a'b = bL;' is at most one element. If M is a group, L;' = is a function. In an arbitrary monoid M , the equation ax = b may have any number of solutions and L;' is a relation.
36
Ill. Deterministic Automata
The associativity formula
(AB)C= A(BC) for A , B , C c icI is equivalent with each of the following three identities
Taking inverses we obtain the identities
RzIRjj'
=
Rz'L,'
R&,
=
L'A B
LA'RE',

LA'LS'
which may be rewritten as follows:
(3.1)
(AC')B'
=
A (BC)l
(Ap'B)Cp'
=
A'(BC')
(AB)'C = B'(A'C) T h e formalism described above may be extended to modules, and in this form is extremely useful. Let Q be a right 2module. For each a E L'* we then have the partial function
R,: Q + Q defined by qR,
=
qa. For each q E Q we have the partial function
L,]: I* + Q given by
a L , = qa As before we obtain relations
LAY:2" + Q ,
Q
R AQ ~
defined for X c Q , A c S* by setting
Thus
AL,
=
XA
=
A7R21
where
XA
=
{qa I q E X , a
E
A)
3. The Division Calculus
37
As before we are interested in the inverse relations. W e denote
X'Y
=
YLJi?= {a I a
E
{q I q
E
XA' = XR;'
=
L'", X a n Y f a} Q, qA n S f a)
for X , I' c Q, A c L'". T h e associativity formula ( X B ) C = X ( B C )for X c Q and B, C c L'+ yields RfjRcY == RNp, LsR, RpLs, L s n = LnLs I n the middle formula the R,. on the left is a relation Q + Q while on the right it is a relation Z" 4S". Similarly L,] on the righthand side of the third formula is a relation L,: Z" + 1". T h e three identities above are best expressed by the commutative diagrams
Q R B \
5 / c
Q
Q
1%
I
A0
Rcl
1"
Lx
A
~JX\
L'+
/x
Q
L'"Q 1.X
T h e inverses of the three identities above yield the identities
(34
(XC')R'
=
X(BC)'
(X*r')c
=
*U'(Ic')
=
Bl(LYllr)
(XB)ll'
for X, Y c Q and B, C c Z*. Observe that with this notation the behavior of a deterministic automaton ,d= (Q, i, 7')is
(3.3)
1dI
=
i'T
As an application of this formula we prove: PROPOSITION 3.1. If A is a recognizable subset of L'", then f o r any subset B of S" the sets BlA and ABI are recognizable.
i, T ) be a deterministic automaton recognizing Proof. Let ,d=(0, A. Then by (3.3) the behavior of the automaton (0, i, TBI) is i1(
TB1)
38
Ill. Deterministic Automata
it follows that AB' is recognizable. I f s E Z* and q = is E Q, then the behavior of the automaton 4, = (Q, q, T ) is
1 dq1 = q1T
=
( i s )  ' T = s'(i'T)
= s'A
Thus
and B'A is recognizable
I
Given subsets A, B of Z* show that
EXERCISE 3.1. {S
{S
I AS c B } = S*  &'(P  B1 I sA c B } = Z*  (I* B),4' ~
Verifr the following inclusions
EXERCISE 3.2.
for X , Y c Q, y E Q, A c
C*,a
E
Z*.
4. StateMappings
Consider deterministic Zautomata
a'=(Q, i, T ) ,
d'= (Q',i ' , T ' ) .
A morphism (or a statemapping)
M'
$9: .ti?+
4. StateMappings
39
is a partial function
p?:
Q + Q' satisfying,
i'
(4.1)
c ip
From condition (4.2) we derive (4.4)
for all s E Z*
(qp)s c (qs)F
Indeed (4.4) holds for s = 1 trivially, and for s = a by (4.2). Assuming (4.4) for s, we prove it for sa as follows: (QPb
= (P)rPO = ( W ) P
This proves (4.4) by induction with respect to 1 s 1. Conversely (4.4) implies (4.2) by taking s = a. Observe that (4.1), (4.2), and (4.4) may be reformulated as follows
0, then i' = ip. (4.2') If (qcr)a f d,then (qp?)O = (qa)p?. (4.4') If (qp?)s f 3, then (qy)s = (qs)y.
(4.1')
If i'
T h e composition of two statemappings
dz
d
l
d
l
l
is again a statemapping
&"": d " This follows directly froin the definitions. If $': d"+ d'" is another statemapping, then the associativity (Q'Y')?~''= p(p'p?'')is obvious. Also the identity mapping of C, into Q is a statemapping 1 , J : d4d. T h u s deterministic 5automata and their statemappings form a category that we shall denote by A ( 2 ) . T h e statemapping 7' is said to be proper if the following conditions hold : (4.1~)i #
implies i'
f
(3.
' imply 44" (4.211) qu f @ and qp f 43 ( 4 . 3 ~ ) Tcp c T ' .
z ,7i.
Ill. Deterministic Automata
40
Condition ( 4 . 2 ~implies ) (and is implied by)
(4.413) qs # 0 and qv f 65 imply qys f 3. Note that conditions (4.3) and ( 4 . 3 ~jointly ) assert that
(4.3') T'ypl = T n Dom y. If &'' is complete, then conditions ( 4 . 1 ~and ) ( 4 . 2 ~ [and ) (4.4p)l hold automatically. T h e composition of two proper statemappings is again proper. Since the identity statemapping 1,d : d d is proper, it follows that proper statemappings define a subcategory AD(L') of A(Z'). Another subcategory CA(2) of A(X) is obtained by restricting the automata to be complete. Another subcategory is f
CAp(S) = CA(S) n AI'(Z') obtained by considering complete automata and proper statemappings. Let d =(Q, i , 7') be a deterministic Zautomaton and let Q' be any subset of Q. T h e automaton EXAMPLE 4.1.
d I Q'
=
(Q', i ' , T ' )
called the restriction of d to Q' is defined as follows:
i'
=
i n Q',
7"
=
T n Q'
and Q' is regarded as a right Lmodule by defining the action
q'

(T
= ($0) n Q'
T h e surjective partial function E:
Q 4 Q',
q E = q n Q'
is then a statemapping E:
d 4 d I Q'
called the restriction niupping. T h e statemapping E is proper iff the following conditions hold
(4.5)
i c Q',
Q'Z c Q'
4. StateMappings
41
a,
These conditions signify that if i f then i E Q' and if q qa f then qu E Q'. T h e inverse of E is the inclusion function
a,
E
Q' and
This is a statemapping 1 : d I Q' +diff E is proper, i.e., iff conditions (4.5) hold. If this is the case, then i is a proper statemapping, called the inclusion. EXAMPLE 4.2.
Let 2 =
(0,T )
and consider the Xautomata

which are deterministic and trim. T h e function p: Q Q' given by iy
=
i',
q,y = q2p = q',
t y = t'
is then a proper statemapping p: d+d', PROPOSITION 4.1. If I d' I c I d 1. If, further,
' = Proof, Let a T h e n i's E T ' . Since
d+d'is a statemapping, then y 2s proper, then I d' I = 1 S' I.
yi:
(0,i, T ) , d' (Q', i', T ' ) , and ~
c j ~z
let s E 1 d" I.
i's c i g s c ( i s ) y
it follows that is E T'p I . l'hus by (4.3) is E T and s E I JP' 1. Now assume that p is proper and let s E 1 ,d I. T h e n is E T . Since i f it folloMs from ( 4 . 1 ~ )and (4.1) that i' f @ and thus i' = ip. Since is f @ and ip f 3 we have, by ( 4 . 2 ~ and ) (4.2), iys = isg, f @. T h u s i's = ( i s ) v f @ and therefore, by (4.3p), i's E T ' . Consequently S E l d ' I
I
Ill. Deterministic Automata
42
PROPOSITION 4.2.
1 LY' 1
=
I Lw" I. Let
parts of ,u/ and JW' that the diagram
I .
Let y: ,d d" be a statemapping and assume dt= 1 Qt and SY''~ = ,3' 1 Q't be the trim There is then a statemapping yt : Ld such f
It
d'
commutes, where F and F' are the restriction statemappings of Example 4.1. The statemapping pt is unique (i.e., independent of y), piPoper, and is n surjectiue function.
i, T ) and d ' = (Q', i', T ' ) . T h e proof rests Proof, Let d = ((2, on the following two statements: (4.6) If is E Qt, then (is)p = i's E (4.7) If i's E Q't, then is E Qt.
Qlt.
Indeed if is E Qt, then isv E T for some PI E P". T h u s sa E I ,3 I and therefore also sel E I 1. 'Thus i'sv E T' and therefore i's E Q". Since
i's c iys c (is)p it follows that i's = (is)y. This proves (4.6). Next assume i's E Q't. T h c n i'sv E T ' for some a E S" and thus sv E I Ld'I = I ,dI. T h u s isv E T and is E Qt. This proves (4.7). Statements (4.6) and (4.7) imply that y: Q + 0' defines a surjective function pt : Qt + such that T F ' : ~y~and that this function is defined in a unique manner by (4.6) and is independent of y. I t remains to prove that yt is a proper statemapping p t : d t+ dft. From (4.6) and (4.5) with s = 1 we deduce that 1' E Qt iff i' E Q" and if this is the case, then ip?' = i'. This proves (4.1) and ( 4 . 1 ~ )Next . let is, iso E 0'. T h c n by (4.6), i's, i'so E Qt and (is)p i's, (iso)y = i'sa. Thus (iscy)a = (1'sa)cy. This proves (4.2) and ( 4 . 2 ~ )Finally . note that is E Qt n T if€ s E I LdI = I ,d' I iff i's E Q ' I n T' iff ( i s ) p E Q't n T ' . This proves (4.3) and ( 4 . 3 ~for ) yt Qlt
Let d and d ' be trim deterministic Sautomata 1 d ' 1, There is then at most one statemapping q ~ :
COROLLARY 4.3.
such that
1 ,d 1
:
L d 4d ' .This statemapping is proper and is a surjective function
I
5. Minimal Automata
43
EXERCISE 4.1. In Example 4.1 choose Q' = i2* = pa to be the accessible part of Q. Thus in this case both e : d + and i : d~ ,J are proper statemappings. Show by e.raniples that the corresponding statements are false. for the coaccessible or trim part of , J c 1
f
EXERCISE 4.2. Let Q : M" be CI statemapping where ,u/ = ( Q , i, T ) and d = = (Q', i', T ' ) are deterministic Eautomata. Let D and I be
Show that the domain and the image of the partial function Q : 0 + 0'. the inclusion 1 : d ' I I + d ' is a statemopping. Show that y admits a factoriratioiz
~ ' ,d 12 D".
d'11'.
d'
where F and 1 m e restriction and inclusion while i/1 is a uniquely dejined statemapping. Show that y : I1 + I is a surjective function. Show that y is proper iff both e and y are proper. EXERCISE 4.3. Show that a statemapping is an isomorphism in the category A ( S ) iff it is proper and is a bijective function.
5. Minimal Automata
Let A be a recognizable subset of X* and let At(A) be the subcategory of A(Z) obtained by considering all the trim deterministic automata d s u c h that I Ldl = A. Corollary4.3 implies that all morphisms in A ' ( A ) are proper and are surjective functions. Further if &'and d' are objects in At(A), there exists at most one statemapping qr: ,df d'. If we write JY" 5 whenever such a statemapping exists, we obtain a preorder on the set of all trim deterministic automata with behavior A. We show that if d 5 d'and SY" 5 d, then d and d' are isomorphic. Indeed, if y : d+d' and y :''A d a r e statemappings, then so is yyi: d+ d. T h u s by Corollary 4.3, py = l., . Similarly y y = 1 ,. T h u s qr is an isomorphism with y~as inverse. T h e isomorphism classes of trim deterministic automata with behavior 4 thus form a partially ordered set. 'The natural question to be asked is whether this ordered set has a minimal element. An equivalent question is to ask about the existence of a trim deterministic automaton do with behavior A such that for any other such automaton jY' a statemapping ,d+ do exists. T h e automaton #', with such a property is then determined uniquely up to an isomorphism, and it will be appropriate to call it minimal. f
,,
I l l . Deterministic Automata
44
T h e existence of such a minimal automaton for any given recognizable subset A of Z* can be established in two different ways. T h e first method consists of considering an arbitrary trim deterministic automaton &' with behavior A , defining an appropriate equivalence relation E on its set of states and constructing a quotient automaton ,d/E for this equivalence relation. One then proves that up to an isomorphism this quotient &'/E is independent of the choice ofdna& ' thus is a minimal automaton for the set A. T h e second method, more elegant and algebraic, consists of a direct construction of an automaton d., for the given set A , and of showing its minimality. This method will bc followed here, and incidentally, as a byproduct of the proof, the main facts of the first method will also be obtained. It is useful at this stage to consider deterministic automata which are not finite. Observe that nowhere in Section 4 did the finiteness of the set of states of automaton intervene. Thus an (possibly infinite) automaton is a triple ,d= (Q, i, T ) with T c Q, i c Q, card i 5 1 together with a partial function Q x S + Q which converts Q into a right Zmodule. The behavior is the set I Q , ' I = ill' = { s I is E 7').T h e set I , d I need not be recognizable unless Q is finite. In the construction of the minimal automaton for a set A , the subsets of X* of the form slA with s E Z* intervene. This is justified by the following:
Let d'=( Q , i, T ) be a deterministic (possibly infinite) Zautomaton with behavior A. If is = q E Q , then PROPOSITION 5.1.
q'T
=
I (Q, 4, T ) I
=
s~A
Further q is coaccessible i j and only ;f s'A f sZ* n A # Proof.
8, i.e., i j and only if
(2
We have
q1T
z
(is)'T =
('2 1 T ) = s'A
Further the state q is coaccessible iff qlT f @3
I
I,et Q" be the set of all subsets of 1*. We convert Qo into a (infinite) right 1module by setting
x
*
s = s'X
5. Minimal Automata
45
for X c Z", s E S". Since
X . 1 = l'X
=
x,
X .
( s t ) = (st)'S =
t1 (s'X)
=
( X * s) . t
it follows that Qo is indeed a Zmodule. I n Qo we consider the subset
TO = { X I X
E
QO,
1E X )
We note that in the Smodule Q O we have
YlTO
(5.1)
=
1 for all X
E
Qu
Indeed
1 X s E TO} = {S I SK'XE T " } = {s 1 1 E s'*Y}
P'TO
= {S
=
*
{sIs€X}=Y
For any subset ,4 of Z* we may consider the (infinite) complete 2automaton d . 4 "
=
( Q O , A , TO)
Then by (5.1)
I LdAdo I =A Let = (Q, i, T) be any deterministic 2automaton with behavior A. Consider the function
Q+QO q'p = q'T p:
We assert that
(5.2)
p':
d+ Ld2,0 is a statemapping.
This follows from the following three calculations :
ic~,= i  ' T = I ,d I (qs)cC, = (4s)'T q E
=
=
A
s1 (q'T) = s'(qp) = (qp)
.s
T u l E q  ' T u l E q p u q p E TO
Indeed, since d', is"complete, the last line shows that the statemapping rp is proper; however, this fact will not be used.
Ill. Deterministic A u t o m a t a
46
Let Ldl = dltbe the trim part of d ' , O . Applying Proposition 4.2 we find that y defines a proper statemapping 9':
, J t
+
Ld.l
Thus, in particular, if &'= d'is trim, we have a statemapping d + dl. This proves that d I is a minimal automaton for the set A. In the automaton Ldd,O a state S is accessible iff X = A . s = s ' A for some s E 2. T h e state 1is coaccessible iff X . ZL E T o for some u E L'*. This is equivalent with 1 E 1 zi, i.e., with 1 E u  * X , i.e., with u E X . T h u s X is coacccssible iff S f m. We thus obtain the following description of d ~ ,

T h e last line stems frorn the fact that 1 E srlA iff s E A . Note that is empty if A = Summarizing we obtain:
a.
is minimal. THEOREM 5.2. For any subset A of Ir*, the automaton LdA4 I f &'= ( Q , i, T ) is any trim deterministic Irautomaton with behavior A , then the unique statemapping c p : A + d4
is given by qp
=
q'T
for q E Q. Further, cp is proper and is a surjective function
I
We shall refer to d', as the minimal automaton of A ; any automaton will be called "a" minimal automaton for A. isomorphic with ,dA, T h e kernel of thc function cp: Q + Q,, defined in Theorem 5.2 is the equivalence relation
q1  q 2
iff
q;lT
=
q;'T
If this equivalence relation is the identity, we say that the automaton A ! ' is reduced. T h u s d is reduced if q;'T
=
qilT
implies
q1 = q 2
5. Minimal Automata
47
T h u s d i s reduced iff Q is injective. Since 'I is proper and is a surjective function we obtain (see Exercise 4.3): COROLLARY 5.3. A deterministic automaton ,d with behavior A is minimal $ and oiily $ ,ij/ is trim and reduced PROPOSITION 5.4.
For aiiy subset .I of 2'" the following conditions
aye equiz>alent: Ez7er.y s E S* is the initial segment of some element of A . sC* n A 12for all s E 2. (iii) s ' A f !3for all s E S*. (iv) AS*'= 5'". Every deterministic accessible automaton &' such that 1 ,dI (v) is complete. (vi) The minimal automaton Ld,is complete. (vii) A is the behazior of a complete coacessible automaton d. (i) (ii)
=
A
Proof, Conditions (i)(iv) are just algebraic reformulations of each other. (i) => (v). Let d =(0,i, T ) , q E 0 and t E Z*. Since XV' is accessible we have is = q for some s E 1". Since there exists u E L'* such that stir E A , we have istu E T and thus qt = ist f Since A f @ it also follows that i f ~2and thus LY' is complete. (v) = (vi). Obvious. (vi) (vii). Obvious. is complete (vii) 3 (i). Let ,d=(Q, i, 2') and s E P. Since we have is f Q.Since is is coaccessible, we have iszt E T for some u E C".T h u s su E A I
a.
T h e subset A of L* will be called complete if the conditions (i)(vii) of Proposition 5.4 hold. If Ld, is not complete, then s*A = for some s E 2". T h e completion d,Lc of is then obtained by adjoining a sink state 0. If we take of S* to bc this sink state, we obtain the subset
a
&', iz
LJ.1"
Q.('
=
(Q IC, i.4 T.1)
=
(s',4
7
1 s E I")
'The only difference with Ld.l is that the condition s'A # (3is no longer imposed. We shall call L ~ . , c the complete minimal automaton of A.
I l l . Deterministic Automata
48
We let the reader verify the following analogs of Theorem 5.2 and Corollary 5 . 3 . THEOREM 5.5.
For any complete accessible Zautomaton ' A
=
(Q,
i, T ) with behavior A , there exists a unique statemapping p: Ld+ d . , c
This statemapping is proper and is a surjective firnetion. If q qp = 911'
E
Q, then
COROLLARY 5.6. A complete automaton ,w' with behaaior A is cornplete minimal $ and only ;f it is accessible and reduced !
As an application we prove: PROPOSITION 5.7.
If ,d= ((2, i, T ) is a complete minimal automaton (0,i, (2  1') is a complete minimal autom
of a set A c I", then d' = aton of the set L'*  A .
Proof. Clearly I sd' I = L'*  I a 'I Since the condition sible, so is d'.
is equivalent to
'(0
41

=
T) = q'@
it also follows that ,d' is reduced
S"


A. Since ,u/ is acces
T)
1
EXERCISE 5.1. Show that for any subset A of erties are equivalent:
P the following prop
If st E A , then s E A . (i) all states are terminal. (ii) I n the niininzal automaton .d, A is the belzavior of a deterministic automaton in which all states are (iii) t er in ina 1. Show that this class of sets i s closed under intersection. EXERCISE 5.2. For each (nondeterministic) 2automaton let d ' denote the result I$ the accessible (zerofree) subset construction, let d " be the completion of d', and let be the reversal of d. Show that ;f
6. A Decision Problem
49
is deterministic and accessible, then ,\.J = d', mid ,JQ' is minimal. Show that if ,li/ is complete and accessible, then ,J= d"and Liy'~"is complete minimal. Deduce that for any automaton d,the aiitomaton d ' e ' is minimal and L d " ~ is 'its ' completioti. Dediice that d ' e ' e ' is minimal with the same behavior as d and that L l i / " ~ " e " is its completion. 6. A Decision Problem
I n practice the construction of the minimal automaton Ld.l will proceed in a manner quite different from that given in Section 5. W e shall assume that a trim deterministic automaton ,M'= (Q, i, T ) with behavior A is given. T h e n we define the equivalence relation
between states of d ' t o hold whenever
Equivalent states are merged and the resulting quotient automaton is both trim and reduced. T h u s c\.J, is obtained. I t is therefore important to be able to decide for any t\vo states q , , q2 of Q whether or not q 1 E 4.. T o do this we first observe that q , E q. holds iff 4,s E T 3q2s E T for all s E L" W e now define approximating equivalence relations E,l ( p 2 0) by setting ql Ep qz whenever q l s E T .aq2s E
7'
for all
s E
V",
1 s1 5p
We have the inclusions
with E
=
n E,.
We first s h o ~
(6.1) qI El,, q2 iff q1 E, q, and qln Ell q2c for all
E
1.
Indeed q1 E, q2 signifies that qls E 7' o q2s E T for all s E Sx such that 1 s 1 5 p 1. It thus suffices to consider separately t h e cases s = 1 and s = nt with I t I s p .
+
111. Deterministic Automata
50
F r o m (6.1 ) we deduce :
(6.2)
If E,,,
=
E , , then E,,,
=
E,,,
.
Therefore:
(6.3) If El,+,= E , , then E
=
E,.
Now let e p denote the number of equivalence classes of t h e equivalence relation E , . T h e n eo<el 5 ... <en
1) is not recognizable. Indeed let sl, s2 E S with I s1 I = I s2 I = n, s1 # s 2 . Then slsl@E P,
slspe cf
P
and therefore
s,'P # s,'P It follows that the k" sets
I
{SKIP s E Z",I s I
=
n)
are distinct. Since k > 1 and n can be chosen arbitrarily large, it follows that {slP} is infinite. When trying to use the quotient criterion in a positive way to prove recognizability, some questions of effectiveness and decidability arise. Indeed, suppose that a subset A of 2" is given and that the set
is finite. We then know that the complete minimal automaton of A is finite and thus A is recognizable. However, can we effectively construct
57
8. The Quotient Criterion
this automaton ? Certainly we cannot on the basis of the data as given. From the point of view of effective computation, the information that a set is finite is useless unless an upper bound is explicitly given. T h u s we shall assume that an integer n is given so that
Secondly, in constructing .dIr we shall have to perform some operations on elements of A. T h u s it is important to know how the set A is given. We shall assume:
(8.3) T h e set A is given together with an effective procedure that will permit us to decide for each element s E S" whether or not s E A. THEOREM 8.3. tinder conditions (8.2) and (8.3), the complete minimal automaton LdA,c can effectively be constructed.
For the purpose of this theorem it is not necessary to describe too closely what is meant in (8.3) by "effective procedure." T h e question is relative: the construction of Ld,,c will be as effective as the procedure given in (8.3). We first list some easy consequences of (8.2): there exists t (8.4) For each s E I*, s'A = r ' d .
(8.5) If s, t
E
E
1" such that 1 t 1 i n and
.F are such that
su
E
'4
0
tu
E
'4
whenever
I u I < n

1
Both statements follow from the consideration of the complctc minimal automaton d =(0,i, T ) and the assumption that card Q 5 n. Indeed, if s  ' A is the state q, then is = q. T h u s there is a path c : i + q in 3y' with label s. If we choose a path c ' : i + q without repeated vertices, then it = q where t = 1 c' I and I t I I.n. T h e equation it q signifies that s ' A = q = t  ' A . Statement (8.5) is a rephrasing of Proposition 6.1, in the language of the automaton M',~.
Ill. Deterministic Automata
58
may now be given. We first T h e procedure for constructing Ld.,c consider the sets s'A for all s E Z*, I s I < n. These sets are pairwise tested for equality using (8.5) and (8.3) and repetitions are eliminated. We thus arrive at a list
where by (8.4) each set s'A appears exactly once. Those are the states of We may further assume that s, = 1 and thus s7'A is the initial state. 'The terminal states are those sr1A for which 1 E s;'A, i.e., s, E '4. These can be determined by (8.3). Finally to determine the edges, we consider the set ( ~ ~ ' 1 .4 a) = a's;'A = (s~o)'A This set must appear in our list and using (8.5) we can effectively determine its place. If (s,o)'A = sylA, then we have the edge a: s;'A s;'A. T h e construction of ,dALC is now complete I f
S* + T* is a inorphism and B is a recognizable subset of T*,then iz = Bf' is a recognizable subset of L* and PROPOSITION 8.4. I f f :
rrA 5 aB. Proof.
T h e following identity is used
Indeed, u E s'A iff su E A , i.e., ( s u ) f ~B. Since ( s u ) f = ( s f ) ( u f ) , it follows that zi E sIA if€ uf E (sf )lB. T h e identity above implies that card{s'A} 5 card{(sf)'B} Also note that membership s E A is decidable since the membership is decidable and f is assumed to be effectively given I
sf E R
EXERCISE 8.1.
Show that the following subsets of {a, r}* aye not
recognizable
I
A
= (oVit" n E
B
=
{aVttait 1n
where X is any infinite subset of N .
X}
E
X}
9. Right Congruences
59
EXERCISE 8.2. Use the method of Propositions 8.2 and 5.4 to show that q.4 and B are recognizable subsets of 7*, then so are '4 v B, A n B, and S"  '4. Derive bounds for u ( A u B ) , (*(A n B ) , and u(S*  A ) . EXERCISE 8.3. Show that for any subset B of S +one has
B
Use this device to show that so is A B .
=
U a(u'B).
if A , B
are recognizable subsets of S", then
This is part of Kleene's Theorem that will be established in Chapter VII in a broader setting. EXERCISE 8.4. Show that a subset A of exist integers 0 5 q < Y such that for all s, t s1A n Jq
=
X* is recognizable if there E S* the condition
t1A n 21
implies
$'A n z Show that
r
t  ' A n 21
if this is the case, then
implies
SP'A= tl4 and therefore
where k
=
card 2.
EXERCISE 8.5.
Show that f A is a recognizable subset of u(ABl) 5 cxA,
for any B c E* and any s
E
Ir", then
a(s'A) 5 r*A
2".
9. Right Congruences
Let &'= ( Q , i, T ) be a deterministic (not necessarily finite) Zautomaton with behavior A . T h e development presented in Sections 58 was based on the study of the sets q'T for the various states q E 0.
Ill. Deterministic Automata
60
There is a "dual" treatment which concentrates on the sets i'q
I s E Z+, is = q }
= {s
These sets are mutually disjoint. This approach is particularly effective if we assume that si& ' complete and accessible. In this case the sets i'q are not only mutually disjoint, but are nonempty and their union is all of Z+. Thus the sets ik'q are the equivalence classes of an equivalence relation in L'* that we shall denote by ,d. Explicitly (9.1)
iff
s1  , d s ,
is,
=
is,
'The following properties are clear: (94 (9.3)
implics
s1 ds, s1  , d ~ , and
s, E A
slg ds,o
implies
s, E
A
We express condition (9.2) by saying that wLdis a right congruence in Ex, while condition (9.3) is expressed by saying that A is closed with respect to w d . We can also proceed in the opposite direction and start out with a right congruence in Z+ with respect to which A is closed. For each s E 2*,let [s] denote the equivalence class under containing s. Consider the complete Zautomaton d = (Q, i, 2") given by


Q
[S]O =
i
T
I s E Z"}
= {[s]
=
=
Pi
[so]
[l]
= {[s]
I S E A}
Then d is complete, accessible, and & = . In the special case when d i s the complete minimal automaton u/.,c of A the right congruence ~dis denoted by Thus definition (9.1) becomes in this case A,.
(9.4)
s,
.,
s,
iff
s;'A
=
s;'A
PROPOSITION 9.1. Let il be a subset of L'+ and in Z* with respect to which A is closed. Then

a right congruence
61
10. The Syntactic Monoid
or equivalently s1

s,
iniplies
s1
s2

s, we have s,t s2t. Proof, Let t E s;lA, i.e., s,t E A. Since s1 Consequently s,t E .4 and t E s;'A. T hus s;'A c s;'A and by symmetry s;'A = s;'A. Hence s, s2 I
,
PROPOSITION 9.2. For any subset '4 of L'* the following conditions
are equivalent: (i) (ii) (iii)
A is recognizable. The right congruence ., is jinite. There exists a j n i t e right congruence in 2 * with respect to which A is closed.
(i) = (ii). Since A is recognizable the family of sets {s'A} is finite. Th u s the finiteness of follows from (9.4). (ii) = (iii). Obvious. is (iii) * (i). T h e automaton ,dconstructed above starting with then finite I Proof.
.,

Note also that the implication (iii)
(ii) follows from Proposition 9.1.
10. The Syntactic Monoid
Let Q be a right 2module. For each word s E L'*, the partial function 4 Q which maps q into qs will be denoted by su. There results a morphism (1: L'* 4P F ( Q )
Q
where P F ( Q ) is the monoid of all partial functions Q + Q. T h e image M of the morphism cz is called the action monoid of the right 'module Q. Clearly M is the submonoid of P F ( Q ) generated by the partial functions q + qo for the various letters o E 1.T h e surjective morphism (1:Z* M f
accompanies the action monoid. If ,3= (9,i, T ) is a deterministic Zautomaton, then Q is a right 2module and the action monoid of Q is denoted by Mc,. This is the action monoid of the automaton d. replaced We assert that the action monoid remains unchanged if by its completion d r .If ,3is complete, then , x' = and there is
Ill. Deterministic Automata
62
nothing to prove. If d i s not complete, then Q' = 0 u 17,where 0 is the sink state. T h e nionoid P F ( Q ) is then isomorphic with the monoid of all functions + Q" which map 0 into 0. T h u s the action monoid remains unchanged (except that instead of being a submonoid of P F ( Q ) it becomes a submonoid of the monoid F ( P ) of all functions + 9). Let dAI ( Q A 1i ,A lT, A l )be the minimal automaton of a subset A of Z". T h e action monoid of ,dA, is denoted by M,, and is called the syntactic monoid of A. T h e accompanying surjective morphism :
pa(: ,r*+ M.1
is called the syntactic morphism of A. Observe that if dAl is replaced by its completion Ld.lc, the syntactic monoid remains unchanged. PROPOSITION 10.1.
For any subset A of Z* the following properties
are equivalent : (i) A is recogniznble. (ii) The syntactic monoid M.I is jinite. (iii) There exists a .finite monoid M , a morphism y : 1" B of M s ~ that h A = Bp'.
f
M , and a subset
(i) => (ii). If (i) holds, then the minimal automaton dAl is finite and thus M A ,is finite. (ii) => (iii). This is clear since M , , the syntactic morphism p.,: L'* + M A , , and the subset AeAlof MA,satisfy the conditions of (iii), (iii) (i). Consider the Zautomaton Proof.

d =( M , 1, B ) with M converted into a complete right Lmodule by setting for m wE m w = nt(wp).
z*
E
M,
Then
I &' 1
= {W
[ 1* w
I
= {W ~ p E?
EB) B } = By'
=
A
and thus '4 is recognizable PROPOSITION 10.2. Let A be a subset of Z* and Q , , : L'* 4MAiits syntactic morphism. Then for any s, t E P the following conditions are equivalent :
10. The Syntactic Monoid
63
(i) SQ.1 = k.4. (ii) ( Z L S )  ' ~ ~= (ut)'A for all u E s". (iii) usv E A o utv E A for all 11, v E 2%. Proof. (i) u (ii). From the definition of MA4as a monoid of functions ,O.lc 4 Q.,c it follows that
(ulA)(sp.1) = ( K I A ) . s = s'u'A
=
(us)'A
T h u s (i) and (ii) are equivalent. (ii) o (iii). This follows directly from the definition of (us)'A
I
We define an equivalence relation in S" by setting
whenever (iii) holds. I t follows from (iii) that =., is a congruence in P (see 1,5 for a definition). We call =., the syntactic congruence of A. T h e equivalence of (i) and (iii) shows that this congruence is the kernel of the morphism PA,. Since e.., is surjective it follows that M, may be identified with the quotient monoid P/=, and pAi may be identified . + Z/ with the natural factorization morphism 2% We observe that (iii) implies:
(10.1) If s =.,t and s E A , then t to Ma,.
E
A , that is, A is closed with respect
This can be restated as
(10.1')
AQ~~Q =; A '
and also as
(10.1")
A
=
for some B c M ,
Bpl
A consequence of the discussion above is the identity
(10.2)
M.4
= MZ*d
Indeed, A and 2*  A have the same syntactic congruence. If we compare the equivalence relation =A4 with M  ~ Q , we find s
t o Se
=.,e tQ
Ill. Deterministic Automata
64
This implies that the syntactic monoids MAland M.,e are antiisomorphic, i.e., there exists a bijection p: ML1 + M.,e such that ( x y ) p = ( y p ) ( x p ) for all x , y E M A , . I n other words, M ~ , emay be obtained from M., by reversing the multiplication in M . 4 . T h u s we may write MAlc = (M.,)Q. T h e definition (iii) of the syntactic congruence can be extended to subsets A of an arbitrary monoid M . Consequently we may define the syntactic monoid Madas M/=.l and the syntactic morphism PA,: M +M A , as the natural factorization morphism. EXERCISE 10.1. Let QJ: M + Ad' be a morphism of monoids and let A be a subset of M such that A = Aqy'. Show that cp admits a unique factorization
MedM,,LM' where q' is a morphism of monoids. Show that the above properly characterizes Ad., (up to an isomorphism). EXERCISE 10.2. Show that if q : M + Ad' is a surjective morphism of monoids and if A c M ,A' c M ' are such that A' = AT, A = Alp', then M.l M A I t .

Let A be a subset of a monoid ICI, and let B = iZpAt be the image of A in the syntactic monoid M.d.Show that the syntactic congruence of B (in M,,l)is the identity, i.e., M A is , the syntactic monoid of B. EXERCISE 10.3.
EXERCISE 10.4.
Using Exercise 10.3 show that the monoid U , with
elements 1,
211
, u2,
u3
and ni u ltiplica t ion u 1u1. = uj is not a syntactic monoid. EXERCISE 10.5. Show that the syntactic monoid M d of a subset A of a monoid M has a zero (i.e., an element 0 such that ML10= 0 = Oa1M)zff there exists an element n2 E M such that either M m M c A or MmM nA =
a.
11. Examples of Syntactic Monoids
65
11. Examples of Syntactic Monoids
In calculating the syntactic monoid SA1 of a subset A of Z* we usually first compute the minimal automaton 3,and then tabulate the relations that the partial functions Q.l + Q.l given by the elements u E Z satisfy. Thus, de facto, M , has S as a set of generators and a number of relations between these generators is given. EXAMPLE 11.1.
Let A
=
B" with B
c
L'. T h e automaton d,lis
Then if B = 2, SA4 = 1. If B f 2, then M A {has two transformations; the element 1 E Exand each element of B yield the identity transformation, while each element of X  B yields the empty transformation. T h u s M A ,has two elements 1, 0 with 00 = 0. This monoid is called U , . If B = S, the automaton above is complete. If B # 2, then d I is c
and the same monoid is obtained. EXAMPLE 11.2. Consider the set A = S"otE* (with 2 = {o, r } ) studied in Example 7.1, I n the notation of this example Q&4 = { 1, 2, 3). T h e actions of CT and T may be described as follows
123 2 2 2 3 , meaning that lo = 2, 20 relations are computed 0 2
= 0,
=
72
123
133
2, 30 = 3 , etc. From this the following
= 7,
U7U
= 07= ZUZ
T h e monoid M,, has thus five elements
1,
U,
7, U T ,
70
T h e multiplication table is completely given by the above relations.
Ill. Deterministic Automata
66
EXAMPLE 11.3. T h e syntactic monoid MAlof the set A sed in Example 7.2 has the relations
= Z+ discus
a=t=g,
and thus the monoid has only two elements
1,
(7
with the idempotency relation u2 = (T. This is the monoid U , . T h e syntactic monoid MA,of the set A Example 7.3 has the relations EXAMPLE 11.4.
=
to* of
t3 is
a zero
Thus the elements of M , , are
1,
T2.
5,
(T,
Note that t2:QA,+ Q., is the empty partial function. T h u s for the monoid M., , i.e., tZM,, = t9 = M.,?. For the set A = 0% the relations are 0'
EXAMPLE 11.5.
=
If A
T = (Tt,
(T,
=
T'
=
to.
as in Example 7.4, the relations in
L'*T.!,'*
lMA1are
1,
=
(7
t2 = t.
T h u s the monoid has elements
1, with r2 = t. Thus M., EXAMPLE 11.6.
U,.
:
If A
=
2%
as in Example 7.5, the relations in MaI
are (T2
=
(T
=
z2 = 7
5(T.
= gt.
T h u s M A ,has threc elements
1,
0,
2.
This monoid has the name U,. T h e set AQ= tX* is obtained from the above by reversal. T h u s M,,o = U p . This monoid has the name I,,.
11. Examples of Syntactic Monoids EXAMPLE 1I.7.
67
Consider the nonrecognizable subset
.il
1 n 2 0)
= {dJ7”
of Sx with S = {a, 7}. T h e n
At”
3
if s = a!?, n 2 0 if s = aJ17~, 0 < p 5 n in all other cases
Consequently the infinite minimal automaton A’, is
with p i = A t i , qi and that
= T ~ It .
follows that the syntactic monoid has a zero
These are the defining relations for M.l. T h e elements of and atJ,t”,a117azlifor n > 0.
MA, are 1,0,
EXERCISE 11.I. Compute the syntactic monoid M A 4of A that M , has six elements (one of which is a zero).
(or)+.Show
EXERCISE 11.2.
Show that
if A
=
=
(SP)*, then
where Z , is the cyclic group of order p . Here p 2 1 is any integer and the alphabet S # @ is arbitrary. EXERCISE 11.3. Let A consist of a single element s of 2”.Show that the syntactic monoid Mad consists of all segments of s and a zero. The product of 11 and v in MAIis lit! if uzj is a segment of s and is 0 otherwise. EXERCISE 11.4. Let 0 be any Jinite set with a chosen element i. Consider the monoid PF@) of all partial functions, and let S be an alphabet equipped with a surjective function (1: S + P F ( 0 ) . Extend (2 to a morphism
Ill. Deterministic Automata
68
a : C"
+
PF(Q), and define A
= (s
J i = i(scx)}
Show that P F ( Q ) is the syntactic monoid M A ,of the set A. 12. Generalization to Arbitrary Monoids PROPOSITION 12.1. For any nionoid ICI and any subset A of M the following properties aye equivalent :
(i)
The family of sets
{nz'A 1 nz
E
M>
is finite. (ii) The syntactic monoid M., is fiiiite. (iii) There exists a finite nionoid M ' , a niorphism p: M + M ' , and a subset B of M ' such that A = Bp". (iv) There exists a finite Tight congruence in M with respect to which A is closed. m2 i f m;'A = m;'A is (v) The right congruence ., defined by m , finite.
.,
Proof, T h e easy proof is left as an exercise for the reader
I
We shall say that the subset A of M is recognizable if conditions (i)(v) above hold. One could engage in the exercise of generalizing the notion of an automaton (nondeterministic, deterministic, and complete) by suitably replacing 2'* by an arbitrary monoid M . This is not very productive since all the known properties of recognizable sets already follow from the definition adopted above. In particular, the definition easily implies that the class of recognizable sets is closed under Boolean operations and the operation p' where Q': M + M ' is a morphism of monoids. Also, if A is a recognizable subset of M , then A also is recognizable when viewed as a subset of the reversed monoid Me. This implies that the family of sets {Am' I m E M } also is finite. PROPOSITION 12.2. Let M , and M , be monoids and let A be a subset of the direct product M , x M 2 . Then A is recognizable i f and only $ A is the
12. Generalization t o A r b i t r a r y Monoids
69
Jinite union of sets of the f o r m B x C where B is a recognizable subset of M I and C is a recognizable subset of M,. Proof. Then
Let
7ci:
A,!
Y h12+ M i ( i =
1, 2) be the natural projections.
B x C = ( B x M , ) n ( M , x C ) = Bn;’ n Cn;l T h u s if B and C are recognizable, so is B X C. This proves the implication in one direction. Conversely, assume that A is recognizable. There exist then a finite monoid M , a morphism p: ill, ,< M 2 + M , and a subset D of M such that A = D9l. Consider the morphisms y h :M ( + M defined by
I n M x M consider the set
E
= {(sl
, sg) I sIs2E D}
it follows that ( m , , ma)E rZ iff ( m ,, m , ) y E E. We have thus proved that A = EyrI. I t follows that
Since the sets sly;’ are recognizable subsets of A l l (i = 1, 2), the required decomposition of A is obtained I
A subset ,4 of a monoid M is recognizable if and only i f subsets B , , . . . , B,, , C , , . . . , C,, of M exist such that PROPOSITION 12.3.
and such that whenever st
E
A then s E B i, t E C , f o r some 1 5 i 5 71.
70
Ill. Deterministic Automata
Proof. Assume that '4 is given as above. T h e n for each s E M we have $'A = ci
u
the union extending over all indices i for which s E B , . T h u s the family of sets {s',4} is finite and A is recognizable. Conversely assume that ,4 is recognizable. There exist then a finite monoid M', a morphism 7 : M 4 M ' , and a subset D of M' such that A = L ) p .  l . Let ( B , , c l ) , . . . , ( b , t ,c , ~ )be all the pairs of elements in S such that b,c, E D. Setting B , = b,ryl, C , = the required conclusion is easily verified I EXERCISE 12.1. Let M be a monoid satisfying x y = y i f y f 1. Show
that er)ery subset of 44 is recognizable. EXERCISE 12.2. Given a monoid M , let MI be the monoid obtained from M by adjoining a new unit element. Show that n subset A of M r is recognizable if A n M is a recognizable subset of M. State and prove a similar result for the monoid Mnobtained from M by adjoining a zero. EXERCISE 12.3. Show that in the free commutatiz~emonoid 11.1 with generators o, t all finite sets are recognizable. Show that o+, tf, ax, T* are recognizable but the sets (or)+ and (or)* are not recognizable. Use this to construct an example that a movphism f : M + M' of monoids need not carry recognizable sets into recognizable sets.
Let f : 111 + M ' be a relation satisfying
EXERCISE 12.4.
Establish the identity ml(Alfl) = ( ( m f )  ' A ' ) f  l for A' c M' and in Alf1.
E
M. Deduce that if A ' is recognizable, then so is
EXERCISE 12.5. Show that if A is a recognizable subset of a monoid M , then so is the set
B
=
{ ( x , Y ) I XY
E
A} c MxM
12. Generalization t o Arbitrary Monoids
71
Show that if B is recogni:able, then ,4 is a finite union of sets of the f o r m C D with C, D c 11.1 recognizable. EXERCISE 12.6.
Given an element
ni E
A4 define the conjugate of m
to be the set mc
=
{uu I v u = ni}
Show that f o r anv recognizable subset A of M the set Ac is a j n i t e union (J C , D , with C, and D , recognizable. (Hint: Use Exercise 12.5.) EXERCISE 12.7.
Show that if A f i s an infinite monoid, then the diagonal J =
{(ni, m )
I m EM}
is not a recognizable subset of A f x M . EXERCISE 12.8. Let A be a subset of a group G. Show that A is recognizable i f f there exists an invariant subgroup H of G of finite index such that d is the finite union of cosets of H . Dpduce that if G is injnite and A f 3 is jinite, then A is not recognizable. EXERCISE 12.9. Let Z be the cyclic infinite group written multiplicatively. Adjoin to Z three elements e, a, b and define a commutative monoid structure on ill = Z v {e, a , b } 0v extending the niultiplication table in Z as follows:
a z =    bz, ex
aa
=
a,
bb = b,
for all
=x
ab
=
1
xEM
Show that a subset A of 114 i s recognizable iff A n Z is a recognizable subset of Z. Use this to show that the set .I = ( a , 6 ) is recognizable, while the sets A A , A', and .4" are not. EXERCISE 12.10.
'4 monoid A l is said to haee the subdivision property
if wheneaer m1m2= nln2
for
m, , ni, ,n, ,n,
then there exists 1 E M such that either m,l
n,l
n, ,
In?
=
niz
m, ,
Im,
=
n,
=
E
h i '
Ill. Deterministic Automata
72
Establish the following properties of subdivision monoids: (i)
Given sequences m,, . . . , m k ,
n,,
. . . , nl
in M such that m, . . . mk = n,
. . . nl
there exists an integer r 2 k , 1 and a sequence
in AT such that m , , . . . , ink are products of consecutive blocks of p , , . . . , p , and similarly for n , , . . . , n L . Thus p , , . . . , p , is a common subdivision of the sequences m, , . . . , m k and n, , . . . , n l . (ii)
For any two subsets A and B of M and for any m
m'(AB)
=
E
M
(m'A)B u (A'm)'B
m'(A+) = [(AX'm)'A]AX (iii) If A and B are recognizable subsets of 44, then so are A B and A+.
Let Z be a possibly infinite alphabet. Show that a subset A of X" is recognizable zJf there exists a jinite alphabet T,a recognizable subset B of P , and a very fine niorphism f : Z X r Xsuch that A = Bf'. EXERCISE 12.11.
f
13. Automata of Type
(p,r)
A natural generalization of the notion of a deterministic 2automaton will now be considered. Given a pair ( p , r ) of integers p 2 0, r 2 0 , a deterministic 2'automaton d =((2, i, T ) of type ( p , r ) is given by a right Zmodule 0,a vector i = (i,, . . . , i p )of subsets of Q each of cardinality 5 1, and a vector T = ( T , , . . . , T,) of subsets of Q. For p = r = 1 this reduces to the case considered in the body of this chapter. T h e behavior I &' I of LY' is a p x r matrix of subsets of S"
I
Lf
Ilk =
I
(0, i, , Tk) I = V
T k
A state of q E Q is said to be accessible if ijs = q for some 1 5 j 5 p and some s E .Y* ; q is said to be coaccessible if qs E Tk for some 1 2 k 5 r and some s E 1".We let the reader carry out the generalization of the
13. Automata of Type ( p , Y )
73
contents of Section 4 and we proceed directly with the description of the "minimal" automaton diof type ( p , Y ) for a prescribed behavior matrix A . T h e construction is a direct generalization of that carried out in Section 5. We denote by Po the set of all vectors
of subsets of P.T h e set by setting
0" is converted into a (infinite) right 2module
(XI, . . . ,S r ) s
=
(sr'X,, . . . , sLX,)
T h e vector
T" = (T,O, . . . , T,O) of terminal sets is defined by
Tk0 = {(X, , . . . , S,) 1 1 E S,} 'The vector io = (ilO, . . . , i,O)of initial states is given by the rows of the matrix A. T h u s i,o = (A], , . . . , A , r ) There results a complete (infinite) Zautomaton
of type
(p,Y).
Since
1
d A , 0 Ij,.
=
{s I ( A j , , . . . , Ajr)sE
=
{s I 1 E s'Ajn}
=
{s I s E
Aj,.}
=
TkO}
dj,.
we have 1 , d , O 1 = A. T h e accessible states of dAlo have the form
(13.1)
(S+Ajl,
. . . , s'Ajr)
for some s E 9, 1 < j 5 p . T h e only noncoaccessible state is
T h u s the trim part of ./';In consists of all states (13.1) which are not (3.
I l l . Deterministic Automata
74
This yields the minimal automaton
C d I
=
( Q l , i l , TA)
We leave it to the reader to show that this automaton is indeed minimal in the sense analogous to that of Section 5. T h e j t h component of the vector iAl is empty whenever the j t h row of the matrix A is zero. T h e form (13.1) of the states of Q , implies that Q , is finite iff the family { S  ~ AI s~E ~L’*, 1 5 j 5 p , 1 5 k 5 r } is finite, i.e., iff all the sets .4,1 are recognizable. We thus see that the matrix A is recognizable [i.e., is thc behavior of a finite L’automaton of type ( p , r ) ] iff all its entries AJnare recognizable. We thus see that thc notion of an automaton of type ( p , Y ) does not yield any new notion of recognizability. All this notion supplies is a convenient method for simultaneously recognizing all the sets {A,n}by means of a single automaton. We shall see in XI,5 that the notion of an automaton of type (1, r ) will be convenient for the study of sequential machines and sequential functions. EXERCISE 13.1. Give necesscwy and sirficierit conditions f o r the azrtornaton Q,, to be rornplete. Show thnt ;f Q.4 is not complete, then its completion 0 , c is obtnined by taking the accessible pavt of Q.ro,i.e., bv adjoining the state to Q.I. h
.
EXERCISE 13.2. Establish the equivcrlence of the pairs of statements:
References M . 0. Rabin and D . Scott, Finite automata and their decision problems, I B h l J . Res. mid Dezielop. 3 (1959), 114125. Reprinted in “Sequential hlachines” (E. F. Moore, ed.), pp. 6391, AddisonWesley, Reading, Massachussetts, 1964.
This papcr is the first systematic presentation of the theory of automata, and contains virtually everything known up to 1959. Most of the contents of Chapters I1 and I11 are a modcrnized version of this paper. We refcr the reader to this paper for all references prior to 1959.
References
75
F. S. Ikckman, Categorical notions and duality in automata theory, I B b l Research Report RC2977 (1970).
This paper contains an elegant discussion of minimization of automata based on a categorical approach. I t also is the source of Exercise 5.2. R. hlcNaufihton and S. Papert, T h e syntactic monoid of a regular event, in “Algebraic Theory of Machines, Languages and Semigroups” (M. A. Arbib, ed.), pp. 297312, Academic Press, New York, 1068.
This paper contains the first clearcut and systematic exposition of the syntactic monoid. S. Ginshurg and G. F. Rose, A characterization of machine mappings, Cattad. J . Moth. 16 (1966), 381383.
This is the source of Proposition 12.3. T h e following papers deal with the “subdivision property” defined in Exercise 12.10: F. Lrvi, On semigroups, Bull. Culcrrtta Math. SOC.36 (1944), 111146 and 38 (1946), 1231 24. J. D. McKnight Jr. and A . J. Storey, Equidivisible semigroups, J . Algebra 12 (1969), 2448.
Proposition 12.2 is by G. Mezei (unpublished). Exercise 12.9 is by S. Winograd (unpublished). Exercises 11, 6.36.5 are by M. P. Schutzenberger (unpublished).
CHAPTER
Iv Structure of RecognizaMe Sets
In this chapter the notions of a unitary set, unitary monoid, and prefix are introduced. Using these concepts a decomposition algorithm for recognizable sets is developed. 1. Unitary Sets
A subset A of Z" is said to be unitary if s;'A
=
s;'A
for all
s,, s, E
s'A
=
A 'A
for all
sE A
A
or equivalently
Observe that the empty set @ is unitary. T h e notion of a unitary set becomes more transparent when interpreted by means of automata. All automata considered are deterministic, not necessarily complete, and not necessarily finite. PROPOSITION 1.1.
For any subset A of L'" the following conditions
are equivalent:
A is unitary und nonempty. (i) of A has a single terminal state. (ii) The minimal automatoti dA, A is the behavior of a deterministic (possibly injinite) automaton (iii) ,w' = (Q, i, t ) with a single terminal state t that is accessible. 76
77
1. Unitary Sets
Proof. (i) 3 (ii). Sincc the terminal states of iJ, are the sets of the form s"4 with s E A , it follows that d., has a single terminal state. (ii) * (iii). Obvious. (iii) * (i). Let .4 = I ,dI with d =(p,i, t ) and t accessible. T h u s A f @. Let s E A . T h e n is = t and s',4 = s ' ( i  l t ) = (is)'t : tlt. T h u s s ' A is independent of the choice of s E ,4 and consequently A is unitary I
, w ' ,
Given a recognizable subset =1 of S" consider the minimal automaton = (0, i, T ) . Let t , , . . . , t,, be the elements of T. Define 14,
=
I
1 cjI
(0, i, t,) I ,
T h e following properties of the sets A, are clear.
(1.1)
A , is unitary.
(1.2) A, n A L = 3,
1 l j : lz 5 n.
II
(1.3)
A
=
(JA,. 3=1
(1.4) c d , 5 rxA, Lvhere a 4 is the number of states of the minimal automaton d, of A. T h e sets A, are called the unitary compoizents of A. From the definition of the minimal automaton it follows readily that the unitary components of A are simply those equivalence classes under the right congruence which are contained in A.
,
EXAMPLE 1.1. Let .Y consist of a single letter
4
=
1
u 02 v
0
and let
dfT"
T h e minimal automaton is
03.
 0 ~ O ~ O ~ 0 1
and thus the unitary components arc 1, d,and d o * . However, we also have the decomposition ,.1 =
(g')"
u
.y,y
into two disjoint unitary sets. T h e minimal automata are
i
I
IV. Structure of Recognizable Sets
78
This shows that the unitary components do not necessarily give thc “smallcst” decomposition. EXERCISE 1.I. Show that the intersection of two unitary subsets of C” again is unitary. 2. Prefixes
the following conditions PROPOSITION 2.1. For any subset A of I*, are equivalent: (i) slA = 1 for all s E A . (ii) A n .45+ = 63. (iii) If s, st E A , then t = 1. (iv) If s,t, = sat, with sl, s, E A , then s, = s,, t ,
If A (v)
f @,
A1A
Proof,
=
t,.
then also the following cotidition is equivalent to the above:
=
1.
T h e verifications are immediate and are omitted
I
A subset A of 1” satisfying conditions (i)(iv) above is called a prefix. T h e following properties of prefixes are clear :
(2.1) Each prefix is a unitary set. (2.2) fl is a prefix. (2.3) If A is a prefix and 1 E A , then .4 (2.4) Any subset of a prefix is a prefix.
=
1.
EXAMPLE 2.1. For each integer k 3 1 the set Ckis a prefix. Further S’ is a maximal prefix, i.e., no subset A of 2%properly containing Zkis a prefix. EXAMPLE 2.2.
With L = {cr,
A
=
T }
{C’Y
consider the set
I ?I 2 l }
It is a prefix. PROPOSITION 2.2. For any subset A of Sx, the following properties are equivalent:
2. Prefixes
79
4 is a prefix. (ii) The ?iiinimal automaton d,is enipty or has the form ( Q , i, t ) with t a single state and tl: = 0. (iii) A is the behavior of a deterministic (possibly infinite) automaton ,u/ = ( Q , i, T ) with T L = 3. (i)
Proof. (i) = (ii). Assume A f @. Since slA = 1 for all s E A , it follows that 1 is the terminal state of dA,. Since o'1 = for all B E S it follows that 1 . S = (ii) 3 (iii). Obvious. 3 we have TL'+ = It follows that if (iii) = (i). Since TZ s E A and t E ST, then is E T , ist = @, and therefore st $ A. T h u s A n A S += and thus A is a prefix I
a.
a.
PROPOSITION 2.3.
If .4, u A , is a prefix in 3,then .4,B n A,B
=
( A l n A,)B
for an)' subset B of L*. I n particular, (f A , and A , are disjoint, then A,B and A,B are disjoint. T h e inclusion ( A , n A,)B c A,B n A,B is clear. Assume A,B n A,B. Then s = alb, = a&, with a , E A , , a, E A,, b, , b, E B. Sincc A , u A , is a prefix we must have n, = a2 and b, = 0,. T h u s S E ( A , n A2)B I Proof,
s
E
PROPOSITION 2.4. For u~zysubset R of
A,>= '4

I*the set
'4Zf
is a prefix and '4 itself is a prefix i f and only i f .4 = .dl>. I f A is no?iempty, then so is A I , . If A is recognizable, then so is A,, and cxA, 5 (1'4 Proof. Since , 4 1 L + c A S * it follows that AP n ApZ+= @ so that dIJis a prefix. If A f D, then the shortest word s in A is not in .4Zj and thus s E A,,. Let ,CJ = (Q, i, T ) be any deterministic automaton such that be removing I SY' I = A. Let d;. denote the automaton obtained from all edges t + q with t E T. T h e n it is manifest that
I
d,,1 = RI,
IV. S t r u c t u r e of Recognizable Sets
80
Taking d to be the minimal automaton of A , the last conclusion of the proposition follows I EXERCISE 2.1. Show that a subset A of Z* is a prefix iff wheneaer B,, B , are disjoint subsets of Z*, the sets AB, and A B , are disjoint. EXERCISE 2.2. Let A be a nonempty prefix. Show that A B is a prefix (vesp. is unitary) i f f B is a prefix (resp. is unitary). EXERCISE 2.3. Assume that P,C, = P,C, where P,, P, are nonempty prefixes in I*and C , , C2are subsets of Z* containing 1. Show that P , = P , , C , = C , . Give a counterexample $ 1 $ C,.
let 0: Z* + M be EXERCISE 2.4. Let A be a nonempty subset of 9, the syntactic morphism of iZ with A = Be,, B c M . Show that A is a prefix iff 1el = 1 and BIB = 1. EXERCISE 2.5. Let 4. c EXERCISE 2.6.
X+.Show that (At),,
=
A,,
Show that 1 E ,4 iff AF> = 1.
Let P , , Qi be prefixes in Z* for i = 1, 2. Show that P;'P, = @ and Pg'P, = (3,then PIQ,* u P,Q,* is a prefix and P,Q,* n P,&* = 0. EXERCISE 2.7.
if
Show that the class V+ is the least class such that: EXERCISE 2.8.
of all recognizable prefixes
i72
(i) k;? E 7'. u E 3 for each u E .Y. (ii) I f P , P' E P' and u  ~ P=' [3, then P' u UPE 2'. (iii) If P, P' E y' and PIP' #, then P*P' E '9. (iv) 1
3. Unitary Monoids
A unitary monoid is a subset of I*which is unitary and is a submonoid of Z*. PROPOSITION 3.1. For any nonempty subset A of P,the following conditions aye equivalent:
3. Unitary Monoids
(i) (ii) (iii) (iv)
81
A is a unitary monoid. A is unitary and 1 E A. s'A = A for all s E A. I f s E A , then st E A q and only (f t
E
A.
T h e implication (i) 3 (ii) is trivial. (ii) implies s'A 1lA = A for all s E A thus proving (iii). Statement (iv) is simply a reformulation of (iii). Assume (iv). Clearly A is closed under multiplication. Since A is not empty we deduce that 1 E A. T h u s A is a submonoid of 1". Since s'A = A for all s E A , it follows that A is unitary. T h u s (i) holds I Proof,
=
PROPOSITION 3.2.
For any subset A of S", the following conditions
are equivalent:
A is a unitary monoid. The minimal automaton LdA, has a single terminal state which coincides with the initial state. (iii) A is the behavior of a deterministic (possibly infinite) automaton d = (0,i, i ) with a single terminal state i which is also initial. (i) (ii)
This is an immediate consequence of Proposition 1.1 and the fact that any one of the conditions (i)(iii) implies 1 E iZ I EXAMPLE 3.1. Let S = {a, T } . For each s E S" let I s lo and I s I r . denote the number of times a and T appear in s. T h u s I s I = I s lu I s IT. T h e set
+
M=
{SIS€S",
/SI,=
ISIT}
is then a unitary monoid. Similarly unitary monoids are obtained by imposing the condition k I s lo = 11 s IT for some integers k 2 0, 12 0. Condition (iv) of Proposition 3.1 is the most convenient one to verify. PROPOSITION 3.3.
If A is a prefix and a unitary monoid, then A
=
1.
Indeed, since A is a submonoid it follows that 1 E '4. Since .4 is a prefix, it follows that A = 1 I PROPOSITION 3.4.
For any nonempty unitary subset A of L'* the
set
A.1,
=
A'A
IV. Structure of Recognizable Sets
82
is a unitary monoid, and
A
=
ApAAII.
I f , further, A is recognizable, then so are AIJ and AAIland uA,, 5 (LA, aALlf5 uA. Proof. Let &'= (Q, i, t ) be the minimal automaton of A. Then A = iIt and iA = t. Therefore
I (Q, t , t ) I = t It
=
(iA)'t
=
A  l ( i  l t ) = A'A
=
This shows that Anf is a unitary monoid. If A is recognizable, then Q is finite and thus A, is recognizable. Further (*A, 5 card Q = (LA.T h e inequality " A p 5 aA has been proved in Proposition 2.5. Each successful path c : i + t in a ' admits a unique factorization
i  tP t with p shortest possible. Then I p A = A141 I PROPOSITION 3.5.
in L'*, then the set A
1%
1
E
AP and 1 m I
E
A.3I. This implies
If P is a prefix in Sx and M is a unitary monoid PM is unitary and P = A!, , M = A J I .
=
Proof. Let a E A and let t E aIA. Then a = p m with p E P , m E M , and at E A. Since pmt E PM and P is a prefix it follows that mt E M . Since M is a unitary monoid, this is equivalent with t E M . Conversely if t E M , then nit E M and at = pmt E PM = A. T h u s a'A = M . This proves that A is unitary and that A 'A = M . T h u s M = A.,f. Let p E P. Since 1 E M it follows that p E A . If p E AS+ = P M P , then p E PS+ which is impossible since P is a prefix. T h u s p E A  AZ+ = A p . Conversely let p E A  AL'+. Since p E PM, it follows that p = p ' m with p' E P c A. However p $ AS+. T h u s m = 1 and p = p'. T h u s pEPandP=A, I EXERCISE 3.1.
Show that the intersection of two unitary monoids is
a unitary monoid. EXERCISE 3.2.
Let A be a subset of Zx with minimal automaton = I ( Q , t , t ) I. Show that for each
d =( Q , i, T ) . Let t E T and let M s E A such that is = t we have M
=
{ m I sm
s>
4. The Decomposition Algorithm
83
Show that a unitary set A is a unitary monoid z f f AA,[and z f f A p = 1 .
EXERCISE 3.3.
A
=
EXERCISE 3.4.
Let M be a unitary submonoid of 2". Define
U = { s E S " I S ( M  1) c M  l }
v = {s E z'" I s(2"

M ) c 2"

M}
Show that U and V are submonoids satisfying
M = U n V
u'V EXERCISE 3.5.
c
v,
V1U c
u
For any subset A of 1" define
M = {sEz'"Is'A=AJ B
=
A

( M  1)A
Establish the following facts:
M is a unitary monoid. (i) (ii) s'B = B s = 1. (iii) A = MB. (iv) A is recognizable iff M and B are. a M 5 uA, aB 5 (LA. (17)
4. The Decomposition Algorithm
THEOREM 4.1.
Each recognizable subset A of 2%admits a decompo
sition
(4.1)
A
=
P,M, u . . . u P,%M,,
(4.1)
where, for 1 5 j 5 n, P j M j are the unitary components of A , Piare nonempty prefixes, and M j are unitary monoids such that
This is an immediate consequence of the definition of the unitary components and of Proposition 3.4 I
IV. Structure of Recognizable Sets
84
Observe that pj = 1 or M j = 1 or P j = M j = 1 are not excluded. In order to push the decomposition of A further, we consider any subset A of Z+. Then we have the partition
with some of the sets Ao' possibly empty. PROPOSITION 4.2. If A is a recognizable subset of Z*, then Aol is
recognizable and a(An') 5 crA
(4.3)
If further '4 is a nonempty prejix, then a(Ao') < uA
(4.4) Proof,
Let d
=
((3, i, T ) be the minimal automaton of A. Define Ldol =
((3, i, To')
where Ta' = {q I q E (3, qn E T } . The fact that I I = An' is clear and this implies (4.3). If A is a nonempty prefix, then, by Proposition 2.2, T = t is a single state and there are no edges issuing from t. Consequently in the automaton &'o' the state t is no longer coaccessible and can be removed. This implies (4.4) I T h e decomposition algorithm started in Theorem 4.1 now continues as follows. In each of the components P j M j for which P, f 1 the prefix Pj is partitioned Pj = (J AJog U€Z
where Aj, = P j r l . There results a decomposition
PjM,
=
(J AjooMj "€Z
in which, by Proposition 2.3, the summands are disjoint. Since the sets Ajuare recognizable the process may be repeated for each of the factors A j u . Since by (4.2) and (4.4) a A J o< rxA
the process will terminate after at most rxA steps.
4. The Decomposition Algorithm
85
T o conveniently formulate the final outcome we introduce the notion of a unitaryprejix monomial (upmonomial for short). A upmonomial of degree k is a recognizable set of the form
U = MkakMkp,akp., . . . alMo
(4.5)
in which M k , . . . , M , are unitary monoids and each of the sets
Mka, . . . M i a i , is a prefix. If k
=
15i 5k
0, then U = M,. If k > 0, denote
U' Then
=
Mkak . . , a,M,
u = U'o,Mo
Since U'u, is a prefix and Mo is unitary, Proposition 3.5 asserts that U is unitary and that
U'a,
= up,
M, =
u,,,
while Proposition 3.4 asserts that U'u, and AT, are recognizable and "(U'O,) 5 (XU,
CLM,
5 (XU
From Proposition 4.2 it then follows that U' is recognizable and
CrU' < uu It follows that U' is a upmonomial of degree k  1. It also follows that the representation (4.5) of U is unique and that k < uU. Combining the above remarks with the decomposition procedure we obtain: THEOREM 4.3. Each recognizable subset A of .P admits a disjoint decomposition A = U , u . . . v U,,
where U, (1 5j 5 n ) is a upmonomial of degree < U A
I
The decomposition of A obtained by applying the algorithm above is called the unitaryprefix decomposition (updecomposition for short) of A. T h e updecomposition does not attempt to dismember the unitary monoids that are produced on the way. This will be done in Section 6.
IV. Structure of Recognizable Sets
86 EXAMPLE 4.1.
Consider the set
A
= S"Z
with Z = {a, t}. T h e minimal automaton &is'
Thus A is unitary. T o obtain the decomposition
A=PM where P is a prefix and M is a unitary monoid we follow the procedures of the proofs of Proposition 2.4 and 3.4. If we remove all edges issuing from t , we obtain the automaton
and thus
P T o obtain M we consider &'but
M
= a*t
with t as both initial and terminal. Thus
1 u S"t = (a".)"
=
Thus A is a single upmonomial of degree 1
A
= M'tM
EXAMPLE 4.2.
with
With Z =
A
M'
{gl t}
= a*l
M
of Z*. T h e minimal automaton of A is
T h e decomposition of A into its components is = A,
(a".)"
consider the submonoid
= {a, U G T , TCT, zt}"
A
=
v A, u A,
87
4. The Decomposition Algorithm
where A i (i = 1, 2, 3 ) are the unitary sets whose minimal automata are
We notice that A , = M , already is a unitary monoid. The decomposition algorithm applied to A , yields
with M , and M , given by the minimal automata
L
l2
./l,
The algorithm applied to A , gives A ,
A,
=
=
A,oL'*. Thus
M,oM,oL'*
Conscquently the updecomposition of A is
A
=
M I v M20M, v M20A!13aL'*
IV. Structure of Recognizable Sets
88 5. Bases of Unitary Monoids
A subset B of Z" is called a base if whenever
b,
. . . b k = b,' . . . bin
with b , , . . . , b k , bl', . . . , bk' E B, then k = k' and bi = bi' for all 1 5 i 5 k . Clearly if B is a base, then B c L'+.A submonoid M of Z* is free if there exists a base B such that M = B". Such a base is unique since B = ( M  1)  ( M  1)(M  1) and we call B the base of M . In particular, if M = L'",then B = Z. T h e base B is said to be maximal if it is not a proper subset of any other base in Z". PROPOSITION 5.1. A unitary submonoid M of Z" is free and its base is the prefix ( M  l ) I J .Conuersely any prefix B f 1 is a base and B" is a unitary monoid.
Proof.
Given M , define
B = ( M  1 )  ( M  1)(M 1) We assert that B" = M . Since B c M we have B" c M . Assume s E M  B" and let s be shortest possible. Since s @ B and s E M  1 it follows that s E ( M  1)2 so that s = s,s, with s,, s, E M  1. Consequently sl, s, E B* and thus s = s,~, E B" contrary to assumption. Now assume that M is unitary. Then m, mt E M implies t E M and therefore
B
=
( M  1)  ( M  1)2
=
( M  1)  ( M  1)Z+= ( M  I),,
This shows that B is a prefix and B f 1. The fact that M = B" is free follows from the next argument. Conversely assume that B f 1 is a prefix. We first show that B is a base. Indeed if b, . . . bk = b,' . . . bi, with b , , . . . , b,, b,', . . . , bi, E B, then since B is a prefix it follows that b, = b,'. Consequently b, . . . bk = b,' . . . b;, and the argument continues by induction. Next we show that M = B" is a unitary monoid. Let s, s t E M . Then s E B" and st E B" for some integers n, m E N . If n = 0, then s = 1
5. Bases of Unitary Monoids and t
E
89
M . Assume n > 0. Then m > 0 and s = b,
. . . b,, ,
st
=
c1 . . . c,,,
with b,, . . . , b,, , cl, . . . ,c,,, E B. Since B is a prefix it follows that n 5 rn and b i = c i for i = 1, . . . , n. T h u s t = c , + ~. . . c,,, E M and M is a unitary monoid I Observe that the case B = 1 was excluded, since 1 is not in the base of any free submonoid of 2'". However, B = @ is permissible, since B" = M = 1 is a unitary monoid and is free with an empty base. EXAMPLE 5.1. T h e monoid M = {a, or}" is free with base = {a, o r } which is not a prefix. Therefore M is not unitary. However, the reversal Me is free with base Be = {u, ~ u which } is a prefix. T h u s &I@ is unitary.
B
EXAMPLE 5.2. Let 9:S* + G be a morphism where G is a monoid. T h e n the kernel M = 19l of pl is a unitary monoid. If G is a group and pl is surjective, then the base B of A2 is a maximal base. Indeed, let s E L'*  M . T h u s scp f 1 and there exists a t E 2" such that (sp)' = t p . Setting m, = st, m 2 = ts we have m l , m, E M . Since m,s = sts = sm, it follows that s v B is not a base.
Free monoids may be used for coding purposes as follows. Let W be the set of all words in a language. T h e n the messages to be transmitted are elements of W". Given a free submonoid M of Sx with base B, a code is an injective function y ~ :TY + B. This function extends to a unique morphism 9'": W" + M . T h e fact that B is a base for M implies that 9" is injective, and this means that the coded message can be decoded in a unique way. However, unless A4 is unitary the decoding cannot start until the entire message has been received. If, however, M is unitary, i.e., B is a prefix, the initial segments of the coded message may be decoded as they are received. PROPOSITION 5.2. Let M be a unitary monoid in L'" and let B be its base. Then M is recognizable ;f and only ij B is recognizable. Further if M f 1, then rrn4 5 lrB 5 I r x ~ ~
+
IV. Structure of Recognizable Sets
90
Proof. Let &’ = (Q, i, i) be a deterministic automaton accepting M . We define the “unfolding” dv of d a s
d”= (Q u t , i, t ) where t is a state not in Q and where each edge q 5 i in d is replaced by an edge q 2 t in do. There are no edges issuing from t. T h e n dv is deterministic and from the construction it is clear that I &’v I = B. If d“ is chosen to be the minimal automaton of A , then card Q = (xM and thus aB 5 1 cwM. Next let B be a prefix and let 3’ = (0,i, t ) be a deterministic automaton such that tZ = 0 and I ~2’I = B. Since B # 1 we have i f t. Consider the automaton @‘ = (Q, t , t ) where for each edge i”. q a new edge t % q is added in g.T h e n ‘8is deterministic and I G‘ I = B*. If B f 0 and 9 is the minimal automaton of B, then card Q = cwB and thus crM 5 aB
+
EXAMPLE 5.3. Let 11.1 = S*.Clearly M is a unitary monoid with = 1. T h e base of M is B = Z which is a prefix with U B = 2. T h u s aB = 1 cxM in this case.
cwM
+
EXAMPLE 5.4. With 2’= automaton &‘of M is
{(T, T
}
let M
=
1 u Z*T. T h e minimal
“CY+i‘3.
T h u s M is a unitary monoid with cxM = 2. Since M may also be written as M = (o*T)* and B = a*t is a prefix, it is the base of M . T h e minimal automaton of B is
uEo2o+ so that irB = 2. T h u s in this case trB do of d is
=
uM. Note that the unfolding t+
a+
This automaton is not reduced since the states i and q are equivalent.
6. Iterated UpDecomposition
91
The unfolding d vdefined in the proof of Proposition 5.2 may be called the "terminal unfolding of A?." There is a dual notion of an initial unfolding = (0 u i ' , i', i ) EXERCISE 5.1.
where i' is a new initial state with edges i' q added for each edge i 2 q in d. Verqy that 1 &'* 1 = M1 and therefore IA,,'& I = ( M  l ) p = B. Use this construction to show that the equality uB = a M holds zff the minimal automaton S ' = (Q, i, i ) of M contains a state q such that I (Q, 9, i ) I = M  1. EXERCISE 5.2. Show that a submonoid M of Z* is free iff
MlM n M W 1 c M Since the opposite inclusion is clear, the inclusion may be replaced by an equality. Apply this to prove that the intersection of any family of free submonoids of Z* is again a free submonoid of P. 6. Iterated Up Decomposition
Propositions 5.1 and 5.2 may be used to push the updecomposition of a recognizable set further, by decomposing the bases of the unitary monoids appearing in the decomposition. Thus (4.1) will be replaced by
(6.1)
A
=
P,B,* u . . . u P,,B,,"
where each B, is the base of M , of (4.1). In the updecomposition of A , the sets M , = B," were left alone and the algorithm continued to dismember the sets P,. Once this is done we can return to the sets M , and apply the updecomposition to each of the prefixes B,. In iterating this procedure we encounter a curious problem of convergence that we shall now discuss. We have the inequalities
cxB, 5 1
+ (xM, 5 1 + rxA
Since B, is a prefix and B, f 1 the next step in the updecomposition of B, is B, = (J (B,'T~)'T nE.E
Since
a(B,a') < uB,
IV. Structure of Recognizable Sets
92
we obtain
cx(Bjo') 5 nA Since equality in this formula is a distinct possibility, we must look for some other way of expressing the fact that Bjo' is "smaller" than A. Otherwise there is a possibility that the algorithm becomes circular and does not terminate. Let d =(Q, i, T ) be the minimal automaton of A. If P j M j is the unitary component corresponding to some state t j E T , then
and
M j = I 'gj1
with
Fj = ( Q , t j , t j )
T o obtain an automaton for Bj the unfolding 'gjV
=
(Q u t , t j , t )
is constructed. Each edge q A t j in 'gj is replaced by an edge q 5 t. An automaton for B j o  l is then
q?'
=
(Q u
2,
tj,
tr')
The state t may now be removed since it is not coaccessible. We note that tap' in qv coincides with tjo' in T h u s removing t we obtain the automaton 9 Y j , = (Q, t j , t j a  ' )
q.
derived from &' by removing all the edges q t t j . Thus even though it is possible that u(Bjo') = u A , the minimal automaton of Big' will have fewer edges than that of A. This suffices to ensure the convergence of the algorithm. EXERCISE 6.1.
Iterate the decompositions of Examn$les 4.1 and 4.2.
7. Maximal Prefixes
A prefix A in .Y* is maxiiiial if it is not a proper subset of any other prefix in Z*. PROPOSITION 7.1.
A pre$x A in 2" is maxiwid
L* = AS*' u AS"
and only ;f
7. Maximal Prefixes
93
i.e., and only if each s E 1%either is an initial segment of a word in A or has a word of iz as an initial segment. Proof.
Let s E L'"  A. Then clearly A u s is a prefix iff s E S"  (AS"'
This yields the conclusion
uA P )
I
PROPOSITION 7.2. If A is a complete subset of S",then the prejix A,, is maximal.
We recall that A is a complete subset of Z" iff the minimal automaton .y'., is complete or equivalently if AL'"' = 2". Let s E 2". Then s is an initial segment of some a E A. Some initial segment p of a is in A ,,. It follows that either s is an initial segment of p or vice versa. Thus s E u AIL'* and the conclusion follows from Proposition 7.1 I Proof.
PROPOSITION 7.3. A prejix B f 1 is maximal i f and only i f the unitary monoid M = B" is complete. Proof. If M is complete and M f 1, then so is M  1. Since B = (M it follows from Proposition 7.2 that B is a maximal prefix. Conversely, assume that B is a maximal prefix and that M is not complete. Let s E S" be a shortest word such that M n sL'" = 0. Since B is a maximal prefix we have by Proposition 7.1
s E BE"'
u RS"
If s E B P  I , then since B c M it follows that s E M P  ' contrary to the assumption ill n s S + = (2. Thus s E BE*, i.e., s = bt with b E B and t E S". Since B f 1, we have b E Z + .Consequently I t I < I s 1 . Therefore M n t S * @, and thus tu E M for some u E 2". This implies su = btu E B M c iVl
+
contrary to assumption
I
Observe that 1 is a maximal prefix and the conclusion of Proposition 7.3 is valid for B = 1 ; however, B is then not the base of M = B".
IV. Structure of Recognizable Sets
94
We shall say that a subset A of S* is dense if Y+IA\‘xl
I
= 2”
or equivalently if any word in C+ is a segment of some word in A , i.e., if A n Z+sC* f @ for all s E C*. THEOREM 7.4. (Schutzenberger) Let M be a free submonoid of 2‘” with base B. If B is a maximal base, then M is dense. If M is recognizable and dense, then B is a maximal base.
Proof. Assume that M is not dense, i.e., that
M n PsC* = @
(7.1)
for some s E 2+.We shall prove that there exists t E P s Z * such that B u t is a base. If Z has a single letter, then (7.1) implies M = 1, i.e., B = 0. Thus B u t = t is a base. Thus we may assume that s = au and that C has at least one letter z f c. Let
This word cannot “overlap” with itself, i.e., t 2 + n X+t = tZ*t
(7.2)
Since s is a segment of t it follows that
M nC*tP
(7.3) and in particular t
E
a,,
=
0
C+  B. T o prove that B u t is a base, assume
. . . ,a,,,
b,, . . . , b,, E B u t a1
f b,
a, . . . a,,= b,
. . , b,
Since B is a base, all these elements cannot be in B. Thus we may assume that a j = t and that J is smallest possible. Because of (7.3) it also follows that one of the elements b, , . . . , b,,, is t. Then let b, = t with k
7. Maximal Prefixes
95
smallest possible. If a, . . . a j = b ,
. . . bk
then since a j = b, = t it follows that a , . . . ajl = b, . . . b,l contrary to the assumption that B is a base. Thus we may assume that l a , . . . ajl < Ib,
. . . bkl
We thus have a , . . . aj_,tu = b, . . . bkp,t
for some u E Ci. From (7.2) it then follows that u = vt for some z, This implies a , . . . ajltv = 6, . . . bRpl
E
C*.
contrary to ( 7 . 3 ) . Now assume that M is recognizable and dense and let &' = ( Q , i, T ) be a complete automaton such that I LP' I = M . Since M is recognizable, we may assume that Q is finite. Let
n
=
inf card(Qu)
with u ranging over 2" and choose u
n
=
E
Z* so that
card(Qu)
Since M is dense, we have vuw = m E M for some v,w E 2*. Since Qvu c Qu, it follows that card Qm 5 card Qu. Thus by minimality it follows that card Qm = n. Let Q' = p m . Since Q'm = Qmm c Qm = Q', it follows from the minimality of n that Q'm = Q' and thus m defines a permutation of Q'. Thus replacing m by a suitable power we may assume that q'm = q' for all q' E Q'. Let s E C*  B and let t = msm. Again we have Qt c Qm and thus Qt = Q' = Q't. Thus again for some power tP, p 2 1, we have q'tp = q' for all q' E Q'. T o prove that B u s is not a base it suffices to show that
tp = (msm)P E B* and for this it suffices to show that qtp = qm for all q E Q. Since qmm = qm, it follows that qt = qmsm = qmmsm = qmt and therefore that qtp = qmtp. Since qm E Q', we have qmtp = qm. Thus qtp = qm, as required I
IV. Structure of Recognizable Sets
96 PROPOSITION 7.5.
If B is a recognizable maximal p r e j x in Z+, then
B is a maximal base. Let M = B + . Then M is a recognizable unitary monoid with base B. Since B is a maximal prefix Proposition 7.3 implies that M is complete, i.e., M F  ' = Z+. Consequently L'+'MZ+' = S* and the conclusion follows from Theorem 7.4 I Proof,
Let M be a recognizable free submonoid of P. Then the following conditions are equivalent: PROPOSITION 7.6.
(i) M is complete. (ii) M is unitary and complete. (iii) M is unitary and dense. Let B denote the base of M . (i) => (ii). Let B , = ( M  l)!,. Clearly B , c B. Since M is complete, it follows from Proposition 7.2 that the prefix B , is maximal. Since M is recognizable, so is B,. Thus by Proposition 7.5, B = B,. Thus M = B+ is unitary. (ii) 3 (iii). Obvious. (iii) 3 (i). Since M is unitary, B is a prefix. Since L'+'MZ*' = Z* it follows from Theorem 7.4 that B is a maximal base and therefore also a maximal prefix. Thus by Proposition 7.3 the monoid M = B* is complete I Proof.
EXAMPLE 7.1.
With 2'
B
= {a, T }
consider the nonrecognizable set
I
= {T'"~s sE
L'+}
Clearly B is a prefix and 2 *  L B= P . Consequently M = B* is a unitary monoid and L""'M = Z*. Thus L*lML'+l = Z+, but M is not complete ( M n az" = 0) and this negates the implication (iii) * (i) in Proposition 7.6. Since B u a is a prefix and thus also a base, B is not a maximal base and this negates Theorem 7.4. Since M is free with base B, the reversal Me is free with base Be, and MeZ*l = Z+. Thus Me is complete, but Be is not a prefix since BeZ+* = P. Thus Me is not unitary and this negates the implication (i) => (ii) in Proposition 7.6. This example shows that the assumption of recognizability is essential in Theorem 7.4 and Proposition 7.6.
8. Recurrent States
EXERCISE 7.1.
97 With S = { a , T } consider a subset A of 2+and write
A
=
u A , u TA,
Show that A is a prefix zff both A , and A , are prefixes. Show that A is maximal ifJ both A , and A , are maximal prefixes. EXERCISE 7.2.
Let A be a prefix in S". Define
A' Show that A n A' EXERCISE 7.3.
=
= @
[S"

(AZ"p' u AS")],,
and that A u A' is a maximal prefix.
Given two bases A and B in 2" define
A 0B
= base
of A* n B X
(see Exercise 5.2). Show that the set of all bases in 2" is thus converted into a commutative monoid with S as unit element and @ as zero. Show that prefixes, recognizable bases, and recognizable prefixes form submonoids. Verifr that ZP0 2 q = Zr, where r is the least common multiple of p and q. Show that if A' c A , then A' 0 B c A 0 B. EXERCISE 7.4.
Show that a subset A of Z* is a maximal prefix
2 .
the sets
AZ 1
~
l,
A , AS+
form a (disjoint)partition of 2'". 8. Recurrent States
Let Q be a right Zmodule. An element q E Q is said to be recurrent if for each u E 2" there exists v E 2" such that quv = q. Equivalently q is recurrent if (8.1)
qZ+ = quS"
for all
u
E
S*
In particular, qu f @, i.e., qS" is a complete right Zmodule. Let d '= ( Q , i, T ) be a finite, complete, coaccessible Zautomaton and let Tcecdenote the set of all states in T that are recurrent. Then the automaton ( Q , i, Tree) also is coaccessible. PROPOSITION 8.1.
IV. S t r u c t u r e of Recognizable Sets
98
Proof. Let q be any state in M and let Q' be a minimal nonempty submodule of qZ*. Since M i s coaccessible Q' must contain a terminal state t . Let u E 2". Since is complete we have @ f tu2" c tZ" c
Qt
and thus by the minimslity of Q' we must have tZ* recurrent. Since t E qZ# the conclusion follows I
=
tuC". T h u s t is
PROPOSITION 8.2. Let A be a recognizable subset of C x .If A is not complete, then:
(i)
there exists s E 2" such that
l s J ( M A A n sCx = 0 If A is complete, then: (ii) for any s, s'
E
Z x , there exist u, 14' E Zx such that
I u I < aA, su .,
I u' I < rxA sus'u'
su(s'u')+ c
A
Proof, Let d '= (Q, i, T ) be the minimal automaton of A . First consider the case A = 0. T h e n (i) holds with s = 1. Assume now that A f 0 and that A is not complete. Then qa = 0 for some q E Q, a E 2. Since q is accessible we have iu = q for some u E Z". Further u may be chosen so that the path i + q with label u has no repeated vertices, and thus 1 u 1 txA. Setting s = ua we have isC* = and thus A n sZx = @. Next consider the case when A is complete. Let s, s' E 2" be arbitrary. By Proposition 8.1, there exists a recurrent terminal state t such that is is coaccessible from t , i.e., such that isu = t for some u E C x . Further u may be chosen so that I u I < U A .Since t is recurrent there exists u' E Z* such that ts'u' = t and again u' may be chosen so that I u' I < aA. I t follows that su ., sus'u' and that su(s'u')P E A for all K 2 0 /
PROPOSITION 8.3. For any unitary submonoid M of properties are equivalent:
(i)
M is complete.
P the following
99
References
(ii) The base B of M is a maximal prejix. (iii) The minimal automaton of M is complete. (iv) In the minimal automaton of M all states are recurrent. (v) In the minimal automaton of M the initial state is recurrent. (vi) M is the behavior of a deterministic automaton d = ( Q , i, i ) with i a recurrent state. (i) e (ii). Proposition 7.3. (i) + (iii). Proposition IIIJ.4. (iii) 3 (v). Since is complete and coaccessible, it follows from Proposition 8.1 that .dtf has a recurrent terminal state. Since in dAr the initial state is the only terminal state it follows that the initial state is recurrent. (v) o (iv). Since dA, is accessible and i is recurrent, all states in M',, must be recurrent. (v) => (vi). Obvious. (vi) 2 (i). Since i is recurrent it follows that for each s E 2" there exists t E Z" such that ist = i. Thus st E M , and s E Mt' c ML'"' I Proof.
EXERCISE 8.1. Let A be a subset of 2". A n element a E A will be called recurrent if the terminal state a  l A of the minimal automaton is recurrent. Let Arc"be the set of all recurrent elements of A. Show that (Arec)rec = Arec
Show that if A is recognizable and complete, then so is A'"".
References
T h e notion of a prefix is well known in coding theory. T h e idea of the updecomposition grew out of conversations of the author with C. C. Elgot. B. Tilson, T h e intersection of free submonoids of a free monoid is free, Semigroup Forum 4 (1972), 346350.
This is the source of Exercise 5.2. 'The first statement of Exercise 5.2 was already known to M. P. Schutzenberger ("Une theorie algkbrique du codage," Seminaire DubreilPisot, Paris, 1955/56). Schutzenberger's Theorem 7.4 appears here for the first time.
CHAPTER
v The Integers
I t is natural to expect that the integers, and particularly the set N of nonnegative integers, play an important role in computing. This chapter deals with the integers, the various ways of writing them, and the related notions of recognizability. 1. The Monoid N
+
We denote by N the monoid of all integers n >_ 0 with as monoid operation. T h e unit element of this monoid is the integer 0. T h e monoid N clearly is isomorphic with Z* with Z consisting of the single letter u. T h e unique isomorphism N = Z* assigns to each integer n E N the word s = un of length n. A complete accessible Zautomaton d must have the following form
with qo as initial state and with the set of terminal states T to be chosen arbitrarily. T h e integers s 2 0 and p > 0 are called the stem and the period of .d. It is understood that if s = 0, then ro is the initial state. Thus
Q = Q' u Q" 100
1. The Monoid N
101
T h e terminal set T breaks up accordingly
T
=
T' v TI',
T'
=
T n Q',
T"
=
T n Q"
c
With each recognizable subset A of N we may thus associate the pair
( p , s) indicating the period and the stem of its complete minimal automaton d.lc. T h e (not necessarily complete) minimal automaton ,d., coincides with d.lC except when A is finite. I n the latter case Ld, has the form
is with qsl (and possibly other states) terminal, while dAtc
with r0 a nonterminal sink state. ' is easily calculated. Each state Y T h e behavior A of the automaton L qi E T ' contributes a single element, namely 4, while each state r i E T" contributes the set as+i(up)*. We thus find
A
=
B u C(O~)'
with
Transcribing this from the multiplicative notation in L'" to the additive notation in N we have
PROPOSITION 1.I. For any subset A of N the following conditions are
equivalent : (i) (ii)
A is recognizable. A is ultimately periodic, i.e., there exist integers n o , p nEAn+pEA
f o r all
n2no
E
N such that
V. The Integers
102
(iii) A is the union of a finite set and of a finite number of arithmetic progressions all of which have the same period (i.e., increment). (iv) A is the finite union of arithmetic progressions. Proof. (i) 3 (ii). This follows from formula (1.1) if we choose no so that b < no for all b E B. (ii) * (iii). Define
B= {nInEA, n<no} C
=
{n I n
E
A , n, 5 n < no +p.}
Then (ii) implies that
A = B u (C+p") Thus (iii) holds. (iii) * (iv). Obvious. (iv) => (i). An arithmetic progression in N has the form c p" and is recognizable by one of the automata described above. Thus as a finite union of recognizable sets A is recognizable I
+
Since N is commutative, the right congruence ;I of A and the syntactic congruence of A coincide. Both are given by
nmS4m
iff
n+iEAcm+iEA
for all i E N . T h e syntactic monoid M., of a recognizable subset A of N can easily be read from the automaton d =dAc. It is the cyclic monoid with a single generator c and a single relation
T h e monoid has s
+ p elements 1,
(T,
(Tz,
. . . , c a + p 1
and is denoted by Z(p,y,. If s = 0, then Z ( p , s is , the cyclic group Z, of order p. If s > 0, then, in addition to the unit element, Z,,,,, contains one idempotent element, namely i = us+l, where 0 5 15 p and s 1 3 0 modp. T h e elements us, . . . , as+p* then form a cyclic group
+
2. Integers a t Base k
103
p with i as unit element. If p
1 , this group is trivial and C T ~= osfl is a zero for the monoid Z ( l , y )It . is worth mentioning that the monoid Z ( p , s may , be viewed as a submonoid of the direct product
of order
if we identify CT with the pair is the generator of Z(l,s).
(t,y )
=
where
t
is the generator of 2, and y
EXERCISE 1.I.Show that any finite monoid M that is cyclic (i.e., is ) described above. generated by a single element) has the form Z ( p , sas
Let A l be a nontrivial submonoid of N and let p be the greatest common divisor of all the nonzero elements of M . Show that M c pN and the dtgeerence pN  M is a finite set. Deduce that M is recognizable. Deduce that M is finitely generated, as a monoid. Construct examples showing that the minimal number of generators for M may be arbitrarily large. EXERCISE 1.2.
+
Let A be a subset of N such that n A c A for some integer n E N , n # 0. Show that A is recognizable and that A = C n" for some jinite subset C of N . [Hint: Consider the sets Dk = {iI 0 2 i < n, k n i E A } for k E N . ] EXERCISE 1.3.
+
+
EXERCISE 1.4.
Show that in (ii) of Proposition 1.1 the weaker condition
n E A s n + p E A
for all n L n ,
suffices. 2. Integers a t Base k
T h e method of recording integers as elements of 2" with Z consisting of one letter CT,has the property that for each integer n the corresponding word s E 2" has length n. This amounts to recording the number 15 by making fifteen vertical strokes. For practical reasons it is useful to increase the size of the alphabet 2 and in return reduce the length of the word representing any given integer. T h e usual way of doing this is to use expansions at some base k > 1.
V. The Integers
104
Given an integer k 11 we consider the alphabet
k = {0,1, . . . , k  l } the elements of which will be called digits at base k . I n order not to confuse the digit 1 E k (if k > 1) with the unit element of k", the latter will be denoted by A . For k > 1, the function v p : k"
+
N
is defined by setting
if
s=do
... dn,
d , E k for O s i s n
This function satisfies
Av,
(2.2)
=
dvp = d
0,
+ tvp
(st)vp= klll(svp)
for for
s,
d
E
k
t
E
k"
T h e integer svp is called the standard interpretation of the word s E k". T h e function v, is surjective but not injective. Indeed we have
(2.31
(Os)vp = s v p
T h e words in the set
Pp
=
k'
 Ok"
are called proper; they do not start with a zero. T h e function vk maps Pp bijectively onto N . For each integer n E N the word s E Pp such that svp = n is called the expansion of n at the base k and is denoted by [ n I k . This is the shortest s E k" with svp = n. T h e description given above to expansions at base k differs from the usual one in only one respect: the expansion of 0 E N is A E k* and not 0 E k as is customary. T h e notation svp will frequently be replaced by the shorter notation ( s ) ~ ,or even still shorter notation (s) if there is no doubt as to what the I 1 is. Similarly we shall write [n] instead of [.Ip. base K '
2. Integers at Base k
105
T h e following description of k" by means of pairs of integers is frequently useful. Since each element s E k" is uniquely described by the pair of integers ( % , I s I) and since
< kl*l
svk
we can identify k* with the set of all pairs
satisfying x < k.!'
Multiplication in k" is then given by the formula (2.4)
(x, y)(.',
y')=
(WX
1. x', y
+y')
T h e above representation of k" will be called the standard pairrepresentation. PROPOSITION 2.1. Let 2 a morphism
=kp
rp:
with k > 1, p
I"
+
0. There exists then
k"
such that the triangle
1"
k*
commutes. The morphism is injective. Proof, Using the notation ( X , Y ) ~for the elements of the pair representation of k" and similarly for I" we define
V. The Integers
106
T h e inequality .r: < 1" then implies x < kp!'. T h e facts that yj is a morphism and that the triangle commutes are clear I T h e formalism described in this section fails for k formula (2.1) should be replaced by
sv1
=
=
1. In this case
IsI
and consequently
[n],= 0" This is the expansion at base 1. In this case v , is bijective and
P,
=
O*.
Several interpretations other than the standard one will be discussed in Section 6. EXERCISE 2.1.
Show that the morphism asserted in Proposition 2.1 is
unique. EXERCISE 2.2. For each s E k*
(k > 1) define the matrix
kl.1
sA =
[l,,,
0 11
Show that iis an injective morphism
of k* into the monoid of 2 x 2matrices with entries in N . 3. kRecognizable Sets PROPOSITION 3.1. Let k > 1. For any subset A of N the following properties are equivalent :
The set A Avi' is recognizable. [ A ] , = A^ n Pk of all the expansions of elements of A is The set (ii) recognizable. (iii) There exists a recognizable subset A' of k" such that A'vk = A. (i)
Proof. (i) 3 (ii), Since Pk is recognizable, this follows from the fact that the intersection of two recognizable sets is recognizable.
3. kRecognizable Sets
107
(ii) 3 (iii). This is clear since vk maps [A],.onto A . (iii) = (i). We observe the identity
Since A' is recognizable, the bracketed set is recognizable by Proposition III,3.1, and thus 4 is recognizable by Exercise III,8.3 or Kleene's Theorem of VII,6
If the conditions (i)(iii) of Proposition 3.1 are satisfied, we say that the subset A of N is krecognizable. COROLLARY 3.2. The class of krecognizable subsets of N is closed under Boolean operations I PROPOSITION 3.3. A subset A of N is krecognizable the equivalence relation
n,
.i,t
n,kr
+i
nl , n,
n2,
E
if and onZy if
N
dejined by the condition
for all r E N , 0 5 i
E
A
0
+i E A
npkr
< kr, i s j n i t e .
Proof. Let j , and j p be integers such that nl /:kil for 1 = 1, 2. T h e n in the pair notation ( n l , j l )are elements of k". Further
( i , r ) ( n , ,j , ) = (nlkr
+ i , r +j , )
Consequently
(i, r ) E ( a , i  * A 9
holds iff
(nlkr
+ i, r + j l ) E
or equivalently iff ntk'
+i
E
A
T h u s the finiteness of the equivalence relation  A , , k is equivalent to the finiteness of the family of sets { ( n , j )  I A } , i.e., to the recognizability of A I
V. The Integers
108
PROPOSITION 3.4. If A is a recognizable subset of N , then A is also krecognizable for all k , 1.
Proof. By Corollary 3.2 the union of two krecognizable sets is krecognizable. Also if A is a single element of N , then [ A ] is a single element of k". T h u s A is krecognizable. In view of Proposition 1.1, it suffices to consider the case when A is the arithmetic progression
A=c+P" for fixed c , p E N , p > 0. For any r E N , 0 5 i, we have nk7
+iE A
iff the following two conditions hold nkr
+i 2c
nk'f i = c modp Thus if n, , n, satisfy
n, 2 c,
n, = n2 m o d p
n2 2 c,
n2. Consequently the equivalence relation then n, wad,, and thus A is a krecognizable by Proposition 3 . 3 fl EXAMPLE 3.1.
is finite
Consider the subset of N
A = {k" I n E N ) with k > 1, an integer. This set is not recognizable, since it does not contain any arithmetic progressions. However, [k"]k
=
10"
so that
[ A ] ,= l(0") and thus [Alpis recognizable. Thus A is krecognizable. EXAMPLE 3.2. Let s be any element of k" recognizable subset of kX. Since
~
Ok". Then
sX
is a
3. &Recognizable Sets
109
Thus if s 11, the gaps in the sct . , s " ) ~ increase in a manner sufficient to ensure that <s*)* contains no arithmetic progression. Since :s+),. is infinite, it follows that the set < s * ) ~is not recognizable. It is, however, krecognizable.
Let 1 = kp with k > 1, p >; 0. A subset A of N is krecognizable ;f and only if it is Irecognizable. PROPOSITION 3.5.
Proof. Consider the morphism q ~ :1"
4
k+ of Proposition 2.1. Since
it follows from Proposition 11,3.2, that if Avil is recognizable, then so is Av;'. Next observe that
[AILPJk = A If A is Irecognizable, then [ A ] ,is recognizable. Since p is injective it iollows from Proposition II,3.3 that A' = [AIlpis a recognizable subset of k + . Since A'vk = A it follows from Proposition 3.1 that A is krecognizable I We shall say that the integers k > 0 and I > 0 are multiplicatively dependent if lq = kp for some integers q >: 0, p > 0. Otherwise, k and I are said to be ntiiltiplicatively independent. A consequence of Proposition 3.5 is:
If k and 1 are multiplicatively dependent, then every krecognizable set is also Irecognizable I C O R O L L A R Y 3.6.
This corollary has a remarkable counterpart which we state without proof. T H E O R E M 3.7. (Cobham) If k and I are multiplicatively independent, then every set which is both k and Irecognizable is recognizable I
110
V. The Integers
4. Iteration PROPOSITION 4.1. Let A be an infinite krecognizable subset of N with k > 1. There exist then integers a, b, c, d E N with b > 0, d > 0 such that knd  1 en = aknd b kd  1 + c
+
is in A for all n E N . Proof. Let B = [ A ] ,c k*. Since A is krecognizable and infinite it follows that B is recognizable and infinite. Then, by Corollary 113.2, there exist elements u, w , v E Z* such that w 1 > 0 and uw"v E B for all n E N. Let el, = (uw'lv). Then ell = aknd with d
=
+ b(l + K" + . . + k",+'jd)+ c
1 w 1, a = (u)k("), b = (w)k("),and c = ( v ) I
COROLLARY 4.2. Let A be an injinite krecognizable subset of N with k > 1. There exist then rational numbers a , b and an integer d E N such that a > 0, d > 0 , and
+bEA
e,L= akTId for all n E N
I
PROPOSITION 4.3. Let A be a krecognizable subset of N consisting entirely of prime numbers. Then A is finite.
Proof. Indeed, assume that A is infinite. With the notation of Proposition 4.1 we have e n f r= e,
+ akd(kTd 1) + bknd
krd  1 kd  1
Choose n so that kd and kd  1 are not divisible by the prime e n . Then choose Y E N so that Krd = 1 mode, With these choices, it follows that en+?is divisible by e,l. Thus entr is not a prime, contrary to assumption I
111
5. Gap Theorems COROLLARY 4.4.
k>1
The set of all primes is not krecognizable f o r any
I Give examples in which b < 0, b
EXERCISE 4.1.
=
0, b > 0 in Cor
ollary 4.2. 5. Gap Theorems
Let A be an infinite subset of N , and let
ao 1. Then for any E > 0, ai+l > a i ( l E ) holds for infinitely many indices i. Thus a j + ] ai > &ai for infinitely many indices i. Therefore lim sup(ai+] a i ) = 00. PROPOSITION 5.1.
If A is recognizable, then R,
=
1 and D A < 00.
Proof. Since A contains an infinite arithmetic progression, Thus R.4 = 1 by (5.1) I
D d < 00.
PROPOSITION 5.2. If A is an injnite krecognizable for k > 1, then A contains an injinite subset
A'
= (ao'
< a,' < . . . < ai'< . . . }
V. The Integers
112
such that a:+, = kd lim ai
(5.2)
n+m
for some integer d > 0. Proof.
= e,, =
Let a,'
4 + 1 
aknd 
a,'
with lim c, = 1
+ b be as in
Corollary 4.2. Then
akOl+l)d + b = kdC, ak"" b
+
I
PROPOSITION 5.3.
If A is krecognizable for some k > 1, then
R;! < 00. Proof, Consider the subset A' of A given by Proposition 5.2. For all i sufficiently large we must have
ail 5 a i < a i t l I for some j
E
N . Since Ui,.l/Ui
I Uj+l/Uj'
and since j approaches infinity as i approaches infinity, it follows that lim sup a i + l / a i5 ki i+m
EXAMPLE 5.1.
I
If a, = i ! , then the set A is not krecognizable for
any k > 1. Indeed a i + l / a i= i } 1
and thus R.,
= 00.
THEOREM 5.4.
T h e same argument applies if ai
=
ii.
If A is krecognizable for some k > 1, then either
or
(5.4) The two possibilities are mutually exclusive.
5. Gap Theorems
113
T h e last statement follows from (5.1). Define
Proof,
R
=
[ A ] u Ok"
and consider the following condition :
(5.5) For each
s E Z*
there exists an integer
p,
E
N such that
sIB n k p # @ for all
p 2 p,.
Assume that (5.5) does not hold. Then for some s E Z* the set
D
{ p I s'B n kp = 0)
=
is infinite. T h e complement of D is the image of slB under the very fine morphism k" + N given by t + I t I. Thus D is a recognizable subset of N and since it is infinite it must contain an arithmetic progression {a rq I q E N } , with Y : , 0. Replacing s by st with I t I = a Y we obtain s E Z+ and s'B n krq = @
+
for all q
+
E
N , or equivalently
B n skrq =
(ZI
for all q E N . Since Ok" c B it follows that s E k"  Ok*, and thus [n] for some n E N , n > 0. Consider any integer of the form
s =
s = nkrq
+ c,
0 5 c < krq
Since [x] E skrq it follows that [x] 4 B and thus .r: 4 A . Consequently A has no elements in the interval
Thus for sufficiently large aj
Y
we must have
< nk'" < ( n
+ l)W 5
for two consecutive elements a i , ai Qi+lbi
which proves ( 5 . 3 ) .
> (n
ai+l
of A. Consequently
+ 1)in
V. The Integers
114
Next assume that (5.5) holds. Since B is a recognizable subset of k*, the family of sets {sr’B} is finite. Thus, in (5.5), p o may be chosen uniformly for all s E k*. Now let n E N , n > 0 be arbitrary and let s = [ n ] . T h e n st E B for some t E k”0. Since s .f A and s 4 OK*, it follows that st 4 Ok* and thus st E [ A ] . Consequently ( s t ) E A and thus
nk”0
+ (t)
E
A
where 0 5 t < k”0. Thus A has at least one element in each interval
nkPo 5 x < ( n
+ l)kPn
for all n > 0. T h u s lim ~ u p ( a ~ +ai) ~ 5 2kP0 COROLLARY 5.5.
I
If lim aitl/ui = 1 lI+cu
and lim sup(aitl

ai) = 00
ii+m
then the set A is not krecogniza6le f o r any k > 1 EXAMPLE 5.2. Let a i = it’ where 6 > 1 is a fixed integer. Then A is not krecognizable for any k > 1. Indeed, ai+,/ai = [l (1 /i)I6while ai+, a i > i6.
+
EXAMPLE 5.3. Let a ibe the ith prime number p i (counting 1 as the 0th prime po). Sincc for any integer n > 1, the sequence
n ! + 2 , . . . ,n ! + n contains no primes, it follows that lim sup(pi+]  pi)= )7
00
+a
T h e fact that pi+l/pj+ 1 is a wellknown consequence of the Pritne Number Theorem. Consequently A is not krecognizable for any k > 1. T h e proof given in Proposition 4.3 is preferable because it proves a stronger result by more elementary means.
6. O t h e r I n t e r p r e t a t i o n s
115
EXERCISE 5.1. Let k and I be multiplicatively independent integers, k > 1, 1 > 1. Show that the set A = {ki 1 i E N } is krecognizable but not Irecognizable. [Hint: Use Proposition 5.2. Note that this i s a special case of the (unproved) Theorem 3.7.1 6. Other Interpretations
I n addition to the standard interpretation v : k" * N (k > 1) used in the earlier sections other interpretations can and sometimes should be used. One of these is the reversed interpretation VQ:
k"
f
N
defined as the composition
T h e explicit definition of
VQ
is I1
S V ~=
1 d,ki i=O
if s = do . . . d , , di E k for 0 5 i 5 n. T h e reader should have no trouble in transcribing the formalism of Section 2 for the reversed interpretation. I t should be noted that since the reversal of a recognizable subset in k" is recognizable, the reversed interpretation does not lead to a new notion of krecognizability. It will be seen in XI,4 that for certain problems in digital computation, the use of the reversed interpretation is quite essential. I n some situations (e.g., in the theory of recursive functions) it is advantageous to use the bijective interpretation
which is closely related to v. We observe that v maps the set krof all words in k" of length r bijectively onto the interval 0 5 n < 'k of N . Consequently the formula
will define a bijection. Explicitly if s
=
do . . . d,, d i E k for 0 5 i 5 n,
V. The Integers
116
then
n
sv
C dzkFLpi
=
i=o n ST
(di
=
+ l)k"'
i=O
If in the formula above we replace knpi by k' we obtain the reversed bijective interpretation rp. I t will be shown in XI,8 that the use of the interpretations 77 or leads to the same notion of krecognizability as v. T h e Russian interpretation Y:
k'+Z
where 2 is a set of all integers is defined for k odd, k SY =
=
2p
+ 1, p 2 1 as
C ( d ,  P )k"
i=O
This is equivalent with using
p,p+
1,
...,1,0,1,..., p
for digits at the base k rather than the usual digits 0, 1, . . . , k 'I'h e Polish intelpet ation

1.
p : k'+Z is given by the formula
Show that the bijective interpretation may be dejined inductively by the formulas EXERCISE 6.1.
ill/
=
0,
dt7
=
( s d ) v = (srl)k for d
E
E
+1
+ dy
k, s E k', and that ( s t ) q = (srj)k"l
for t
d
+ t?]
k'.
EXERCISE 6.2. Derive for.rnulris similar to those of Exercise 6.1 for the Russian and Polish interpretations.
117
7. Coding 7. Coding
r*
An injective function f:2" + is frequently referred to as a coding. We usually expect that for each s E S" the value sf should be effectively calculable and similarly for each g E P, the value of gf' should be effectively calculable. If sf = g, then g is called the coding of s while s is the decoding of g. An example of such a coding is the injective function N + k" which to each n E N assigns its expansion at the base k (using either the standard or the reversed interpretation). T h e decoding is then achieved by ( 5 ) r . Another example of a coding N + k" is given by the inverse of the bijection rj: k" N of Section 6. A very useful coding
LI.[
f
k" + 2"
T ~ :
sterns from the observation that the elements {Odl I d _> 0 } are the basis of the free submonoid A u 2"1 = 2*  (2*)0 of 2". 'Thus T~ is defined by
d t k = Oil
for
dEk
A variant of this coding is obtained by sending d into lod. T h e usefulness of tt stems from the fact that being an injective morphism, both tkand T ~ transform I recognizable sets into recognizable sets (Propositions III,3.3 and 3.4). T h e composite injective function
satisfies
if s
If we allow k
=
do . . . d,,,
= 00, we
di E k for
05i5n
obtain the bijection
given by the same formula as above. Here N X is the free monoid with base 0, 1, . . . , n, . . . . T h i s bijection is useful in the theory of recursive functions.
V. The
118
Integers
Another bijection useful in the theory of recursive functions concerns the sets N and N x N . Using the methods of this chapter we can define a family of such bijections. We choose a base k = k,k, with k, > 1, k, > 1. T h e integer n is expanded at the base k using, say, the standard interpretation. In this expansion each digit d E k is replaced by the pair (b, c) E k,x k, with d = bk, c . There result elements of k," and k," which by application of the standard interpretations yield a pair of integers (n,, n,) E N X N . Thus the bijection N 4N X N is defined using the commutative diagram
+
k"

NEXERCISE 7.1.
k," x k,"
NX.N
Show that the diagram above does dejine a bijection
NtNxN. References R. W. Ritchie, Finite automata and the set of squares,]. Assoc. Cornput. Mach. 10 (1963),
528531.
This paper proves that the set of all squares is not 2recognizable (see Example 5.2). This seems to be the first result in this direction. M. I,. Minsky and S. Papert, Unrecognizable sets of numbers, J . Assoc. Cornput. Mach. 13 (1966), 281286.
This paper, motivated by Ritchie's paper cited above, proves a theorem similar, but somewhat different from Theorem 5.1. While in Theorem 5.1 the two cases correspond to condition (5.5) holding or not holding, the MinskyPapert theorem deals with the condition slB f 0 for all s E 2'". Theorem 5.1 was obtained by M. P. Schutzenberger and the author (unpublished). A. Cobham, On the basedependence of sets of numbers recognizable by finite automata, Math. Systems Theory 3 (1969), 186192.
This paper contains the proof of Theorem 3.7. T h e proof is correct, long, and hard. It is a challenge to find a more reasonable proof of this fine theorem.
References
119
Z . Pawlak and A. Wakulicz, Use of expansions with a negative basis on the arithmometer of a digital computer, Bull. Acnd. Polon. Sci. CI. III, 5 (1957), 233236.
This is the source for the Polish interpretation. T h e Russian interpretation is hearsay.
CHAPTER
VI Multiplicity
T h e phenomenon of multiplicity appears whenever any fact takes place for several reasons and we wish to study not only the fact itself but also the reasons for which it takes place. For instance, the fact may be s E I d I with s E L’*and &’an automaton. The reason for this is the existence of a successful path c in &’with s as label. T h e objective of this chapter is to lay down a general theory and to apply it to automata. Numerous other applications will be made later in this work. 1. Multiplicity in Automata Let d b e a (nonnecessarily deterministic) Xautomaton. T h e behavior
1 &’ 1 was defined as the set of all labels of successful paths. Each successful path c with label s E Z+constitutes a “computation” for s or a “proof” that s E 1 d 1. There may be more than one such path c with a given label s. If the number of such paths is n (it is necessarily finite), it is appropriate to say that s belongs to 1 a ‘ 1 with multiplicity n. Writing s Id[ instead of n we obtain a function (1.1)
I&’):
Z*+N
and we may wish to call this function “the behavior of d.” Observe that s I d I = 0 corresponds to the case when s 4 I &’ I in the earlier notation. We give a number of examples where 1 &’ 1 regarded as a function (1.1) is calculated. 120
1. Multiplicity in Automata
1 21
EXAMPLE 1.1. Let z'be a finite alphabet and let the automaton ,d 2'
Every successful path in 'VL
t E
Z. Consider
Ei2+t3 z
admits a unique decomposition c
iitt
r
d
where I c 1 and I d I are arbitrary elements of P . Thus as an ordinary subset 1 LY' 1 = .Y+zz'*. T h e multiplicities are
where
I s It
is the number of appearances of
t
in s.
EXAMPLE 1.2. As in the previous example consider sider the automaton
t l ,t2E
Th en s I ,d 1 is the number of occurrences of the word in s.
t,tZ as
2. Con
a segment
EXAMPLE 1.3. Consider
Then for s E 1"
EXAMPLE 1.4. Let S = {c} and consider the automaton
aGJJ U Aq n
Let
d
VI. Multiplicity
122
Then clearly
Every successful path c of length n into either
1
a, =
a, = 1,
2 2 admits a unique factorization
pZp’qAp or
p 5 p L p with
I c‘ I = anp2and I c“ I = an’. This a, = aa]
+ u,~
implies
for
n 22
Th u s a,, is the nth Fibonacci number. This example will be reexamined in VIII,2.
An ordinary subset A of z’* (without any multiplicity considerations) may be regarded as a function (1.2)
A: F  9
where = (0, l } and the value sA is 1 or 0 depending on whether s E A or s 4 A. We are thus confronted with two kinds of “subsets” of Sx, 9  s u b s e t s and Nsubsets. Other kinds of “subsets” will have to be considered in the sequel. T h e purpose of this chapter is to study these phenomena in some detail and to set up a framework within which the various types of “subsets” can be studied side by side without discomfort. T h e unifying concept is that of a semiring K (the sets 9and N considered above are converted into such semirings). A Ksubset A of set X is then a function
A:X+K With proper terminology and notation, such “subsets” can be handled just like ordinary subsets. 2. Semirings
A semiring K is a set equipped with two operations: addition and multiplication. With respect to addition K is a commutative monoid with
2. Semirings
123
0 as a unit element. Thus
With respect to multiplication K is a monoid with 1 as a unit element. Thus
T h e two structures are connected by the following axioms
+
+
x ( y 2) = xy X" (x y)" = xu" + y z
+
xo
=
0 = ox
Clearly any ring is a semiring. We list a number of semirings that will be of interest to us and that are not rings. They are all commutative (i.e., satisfy xy = yx).
9:This semiring has two elements 0 and 1. Addition is given by l + l = l
Note that the remaining rules of addition
o+o=o,
1+0=0+1=1
are forced by the requirement that 0 is a unit element for the addition. T h e multiplication is entirely forced by the axioms and is 11=1, 10=01=00=0 the semiring of all integers n 2 0 with the usual addition and multiplication ; J'": the semiring N completed by the adjunction of an element 00. Addition and multiplication are extended by the rules
N:
n+oo=m+n=cx3+m=co
nco=mn=m moo =
00,
if
EN, n > O
o m = coo = 0
VI. Multiplicity
124
the semiring of all real numbers s >_ 0 with the usual addition and multiplication; the semiring R , with 00 adjoined. T h e operations are extended 9+: exactly as in the case of the passage from N to J”; Q+: the subsemiring of R , consisting of all nonnegative rational numbers.
R,:
Consider an indexed family
{xiI i E Z} of elements of the semiring K. Such a family is nothing but a function X:
I
+
K
with the value of the function at i E I written as xi instead of ix. If I is finite, then the sum
is defined and is an element of K . This sum has the following properties:
(2.5) If I has a single element i, then
(2.6) If Z =
UjeJI j
is a disjoint partition of Z, then
(2.9) If I = 0, then CieIx i = 0.
+
One could adopt (2.4) as a basic notion in place of the addition x y, and treat (2.5)(2.8) and (2.2) as axioms. One can then define x, x2 as CiElxi with I = (1, 2} and define 0 by (2.9). Axioms (2.1) follow from (2.6) and (2.5) (see Exercise 2.1) and (2.3) follows from (2.7) and (2.8). In all this it was assumed that I in (2.4) was finite. If we drop this assumption and assume that (2.4) is a welldefined element of K for
+
125
2. Semirings
any indexing set I , then with (2.5)(2.8) and (2.2) as axioms, we obtain the notion of a complete semiring. Each complete semiring also is a semiring. In the semirings (%', X, and .!Z+the definition of addition can be extended to define (2.4) for any indexing set I so that they become complete semirings. Using the obvious orderings in .%', X, and 9+ one can define (2.4) as the least upper bound of the elements zit,, xi where J ranges over all the finite subsets of I . Given two semirings K , K' a morphism p: K + K' is a function satisfying
From this we easily deduce (2.10c) for I finite. For a morphism of complete semirings (2.10) is replaced by ( 2 . 1 0 ~ )for an arbitrary I . A semiring K is said to be positive if it satisfies the following three conditions: (2.12)
0 # 1.
(2.13) If x (2.14)
+ y = 0, then x = 0
= y.
If xy = 0, then x = 0 or y
=
0.
Given such a positive semiring define the function
by setting
0t
=
0
xt=1
if
xfO
I t is then easy to see that iis a morphism of semirings, and if K is complete, then t is a morphism of complete semirings. Conversely if t is a morphism, then K is positive. All the examples of semirings listed above are positive.
126
VI. Multiplicity
Show as a consequence of (2.6) and (2.5) that i f q : I is a bijection, then
EXERCISE 2.1.
J
f
EXERCISE 2.2.
Show that in any semiring
provided I and J arejnite. In a complete semiring I and J can be arbitrary. EXERCISE 2.3.
Show that a ring can never be positive.
EXERCISE 2.4.
Show that i f 0
=
1 in K , then 0 is the only element
of K. EXERCISE 2.5. Show that for any semiring K there is a unique mor
phism y : N
f
K.
3. KSubsets I t will be assumed throughout that K is a semiring which is not trivial, i.e., such that 0 f 1. Equivalently, it will be assumed that K contains at least two elements. Also, unless otherwise stated, K will be assumed to be commutative. Let X be a set. A Ksubset A of X is a function
A: X + K . For each x E X the element
xA of K is called the multiplicity with which x belongs to A . If the only values that xA takes are 0 and 1, we say that the Ksubset A of X is unambiguous. Since we assume that 0 f 1 in K , the unambiguous subset A of X may be identified with the subset
{x I xA
=
l}
3. KSubsets
127
of ;’iin the usual sense. In particular, if K = 9all Ksubsets of X are unambiguous and every .%‘subset may also be viewed as an unambiguous Ksubset. Examples of unambiguous subsets are X , 0, and x for each x E X , defined by XX5 1 for all x E X
x@= 0
for all X E X
1 0
Y”
if y = x otherwise
The unambiguous subsets x will be called “singletons.” Whenever A is an unambiguous subset of X , the notations x E A and x A = 1 are synonymous. If A is a Ksubset of X and y,: K 4 K‘ is a morphism of semirings, then the composition
x
d
KL K‘
is a K’subset Ay, of X . In particular, if K is positive, we may consider the morphism t: K 4 9. T h e :%’subset A t is called the support of A. Viewed as an ordinary subset of X it is At
=
{ x I XA f O }
We now turn our attention to operations on Ksubsets. T h e first operation to be considered is the union or the sum, denoted either by U or by C depending on whether we wish the notation to resemble set theory or algebra. For any indexed family { A i , i E I } of Ksubsets of X we define
The definition requires no comment if K is a complete semiring. If K is just a semiring, we must assume that the family { A j , i E I } is locally jinite, i.e., that for each x E X we have x A , = 0 for all but a finite number of elements i E I. This is always true when I is finite. If I = (1, . . . , n}, then we may use the notation
A , u ... instead of U A j or C A , .
uA,
or
A,+
. . . +A ,
VI. Multiplicity
128
T h e second operation that we consider is the multiplication of a Ksubset A by an element k E K. T h e result is a Ksubset k A defined by x(kA) = k(xA) T h e following formal rules are clear
1A
=
A,
OA = 0, (kIk2)A = kL(k2A)
T h e intersection A n B of two Ksubsets is defined by x(A n B ) = (xA)(xB) This formula also applies if B is a Ksubset and A is a .%'subset, by simply regarding A as an unambiguous Ksubset. Thus in this case X(A
nB)=
{ :B
if if
X E A x@A
For each Ksubset A of X we have
(3.1)
A
1 (xA)x
=
X t S
Note that the family ( x A ) x is locally finite since if y = x otherwise
y ( ( x A ) x )=
T h e righthand side of (3.1) is called the expansion of A (in terms of singletons). It is a useful formal device in manipulating Ksubsets. For instance, we have
A nB
=
C (xA)(xB)x X € S
Let A be a Ksubset of X and let X ' be aqsubset of X . If xA = 0 for all x E X  X', then we may regard A also as a Ksubset of X ' . We shall write A c X ' . Note that A c X ' iff A n X ' = A. Establish the formal properties of the operations C A I , kA, and A n B. Examine their behavior under a morphism p: K 4K'. EXERCISE 3.1.
129
4. Relations and Functions
In particular, if K is positive, show that
4. Relations and Functions
In 1,2 a relation f : X + Y was described as a function f : X + P, where P stood for the set of all subsets of Y. T o define a Krelation f: X + Y we shall proceed similarly but will replace P by the set KY of all Ksubsets of Y. Thus a Krelation
is defined as a function
(4.2)
f: X + K’
We shall assume throughout, when dealing with relations, that either K is complete or else the family
{xfl x E X ) is locally finite. With this assumed, the function (4.2) can be extended to a function
(4.3)
f: KS + K’’
by setting
Af
=
c (xA)(xf)
xt.r
Defined in this fashion, the function (4.3) satisfies
(4.4) (kA)f= W A f ) Thus (4.3) is the linear extension of (4.2). This gives us the second definition of a relation (4.1) namely as a function (4.3) which is linear [i.e., satisfies (4.4)]. If K is not complete, then one must verify that conditions (4.4) when properly interpreted imply that the family {xf I x E X } is locally finite.
VI. Multiplicity
130
T h e second formalization of the definition of a relation leads directly to the notion of the composition of relations, as the composition of two linear functions
KI' 5 K Z
KS is again a linear function
f g : K"
+
KZ
I t is easy to see that sets and Krelations form a category. T h e graph #f of a Krelation f : X + Y is the Ksubset of X x Y defined by
(X,Y)#f = y ( x f ) T h e inverse relation f
l:
Y
+
X is given by
4yfl) =y(xf) This definition is legitimate when K is complete. If not, the relationf' may not be well defined since the family { y f l 1 y E Y }need not be locally finite. I n the set of all Krelations X Y we may define the linear operations of addition (with any indexing set) and multiplication by an element of K . This is best seen by applying them to the graphs that are Ksubsets of f
X x Y. EXAMPLE 4.1.
Let B be a Ksubset of X . Define the relation
ne: X + X by setting
x ( n B )= ( x B ) x T h u s nl? satisfies the local finiteness condition. For any Ksubset A of X we then have
T h e graph of this relation is
4. Relations and Functions
131
and the relation n B is its own inverse. If C is another Ksubset of X, then the associativity formula
A n (B n C)= (A nB) n C implies that n ( B n C) is the composition of the relations nB
xXLX.
nc
T h e completeness of K was not required. For a Krelation f: X
4
Y the following definitions are made: {x I xf f @ }
Domain o f f :
Domf
Image o f f :
.f Imf= Y
=
C.r xf.
XE
Observe that Domf is a 23’9subset while I mf is a Ksubset. A Krelation f : X + 1’ is said to be unambiguous if for each x E X the Ksubset xf of 1’ is unambiguous, or equivalently if the graph #f is an unambiguous subset of X X 1’. A function (or a partial function)f: X + Y is a special case of a .&’relation such that xf is always a singleton (or is a singleton or 0). If K is a complete semiring, thenfalso defines a Krelationf: X 4 Y denoted by the same symbol. If K is not complete, then local finiteness of the family {xf I x E X} is required. This is equivalent with the following condition :
(4.5) yf’ is finite for all y
E
Y.
T h e relation f’always satisfies the local finiteness condition (because the sets yf’ are mutually disjoint) and therefore f  l : Y + X is a Krelation for any K. Note that
Indeed, since
VI. Multiplicity
132
T h e only nonzero term in this summation will be when y which case x ( y f  l ) = 1 and y B = ( x f ) B . This proves (4.6).
in
X + Y and any Ksubset B
For any function f :
PROPOSITION 4.1.
= xf
of Y the diagrams
commute, where B' Proof.
YYnn
xxnw
xxnw
Y
= Bf
Indeed, let y
Similarly for x
E
'E
I.
E
Y.Then
X we have
(x n B ' ) f
COROLLARY 4.2.
of
nu
=
[ ( x B ' ) x ]f
=
( x f ) B ( x f )= xf n B
=
xB'(xf) = x(Bf')(xf)
For any function f :
X+
I 1' and any Ksubsets A
X and B , C of Y we have (C n l3)fI
=
Cfl n BfI
( A n Bfl)f
=
Af nB
Let f : X subset A of X the relation COROLLARY 4.3.
+
I
Y be a function. Then for any KY
n ( A f ): 1'is the composition f' n4 YxxY
f
I
5.
133
Monoids and Matrices
EXERCISE 4.1. Let f:A‘ + E’, g : I’+ Z be Krelations. Show that ( f g )  ’ = gtfI. Show that the graphs # f , #g, and #( f g ) are related by the convolution formula
EXERCISE 4.2. Verify that the conclusions of Proposition 4.1 remain valid i f f is a partial function, provided we interpret @ B as 0. EXERCISE 4.3. Give examples showing that the composition of two unambiguous relations need not be unambiguous. 5. Monoids and Matrices
Let S be a semigroup and let A and B be Ksubsets of S. Our first aim is to define the Ksubset A B of S. If A and B are the singletons x and y , then xy is defined by the multiplication in S. Since we expect AB to be bilinear and since
A
(~A)x, B
=
=
C (yB)y ycs
XES
the calculation
suggests the “convolution formula”
(5.1)
z(AB)=
c (.rA)(y B )
.cy=z
Formula (5.1) may certainly be used as a definition of A B when K is complete. Cases when A B is defined even when K is not complete will be discussed later. With A B defined by (5.1), we have the desired bilinearity, to wit:
( C A,)B ie I
=
C A,B itI
( k A ) B = k ( A B )= A ( k B )
VI. Multiplicity
134
Further A B is associative. Thus if M is a monoid, then K." is a (not necessarily commutative) semiring. We now reexamine formula (5.1). In general, there may be infinitely many pairs (x,y ) such that xy = z with z E S fixed. Because of this it is necessary to assume that the semiring K is complete. There are, however, important cases when this is not needed. Indeed, suppose that S = X+ is a free semigroup with a base 2 (not necessarily finite). Then the number of factorizations xy = z is exactly I z I  1. Thus the summation in (5.1) is finite and the assumption that K is a complete semiring is not needed. T h e same argument applies if S is a free monoid S = L"3C or if S is a product of a finite number of free monoids. Let P and Q be finite sets. A Ksubset A of P X Q will frequently be regarded as a matrix with the rows indexed by the elements of P, the columns indexed by the elements of Q, and with entries in K. When this is done, then instead of writing ( p , q)A we shall write A,, and the matrix will be recorded as A = [A,,]. Addition of matrices is defined using addition of Ksubsets. Thus if B E Kz'xQis another P XQmatrix, then ( A B),, = A,, 4 1 ,
+
+
A new operation is matrix multiplication. Given matrices A
E
B
K'xQ,
E
KQxR
the product
A B E Kpxrz is defined by
T h e usual properties of matrix multiplication are easily established. For P = Q, the matrices Kt'Xp form a semiring in which the unit l p is the matrix
If A is a P XQmatrix and P is a single element, then A is called a row vector. Similarly if Q is a single element, A is called a column vector. D e j k e the product K , x K , of two semirings and also of two complete semirings. Show that if S is a semigroup, then EXERCISE 5.1.
( K ,x K,)"

K ISx K,"
135
6. KSAutomata
EXERCISE 5.2. Dejne the Krelations L ,: S + S and RAi:S S where A is a Ksubset of S. Derive the formalproperties following the pattern of III,3. Dejne the Ksubsets AlB and AB' and establish their formal properties in the manner of III,3. Consider the cases when K is complete or S is free. +
6. K  Z  A u t o m a t a
Let Z be a finite alphabet and K a commutative semiring. A K2automaton d =(P,1,T ) is given by a finite set
0 with Ksubsets I and
T and by a Ksubset E of
If then we say that the edge ka
pq is in d a n d that ka is the label of the edge. As in the case of 2automata, paths c:
p+q
are considered. If c is the path
pq,' kiai
I
.
 4111
.
knon
q
then its label is
IcI
=
with
ks
k
=
k, . . . k,,, s = a1 . . .
0,
and its length 11 c 11 is n = I s I. T h e behavior of JP' is the Ksubset of Z* defined by
I
Sd
I
=
c c (PI>I c I ( q T )
P,FQ
0
with c ranging over all paths c: p q. Since for each s E L'* there is only a finite number of paths with label ks, k E K , the summation is j
VI. Multiplicity
136
locally finite and 1 M‘l is well defined, without assuming that K is a complete semiring. T h e only paths of length 0 are the trivial paths q + q with label 1, and therefore
where I T is the product of the row vector I with the column vector T. T h e Ksubset E of QxL’xQ is a function
E : QxL‘xQK Thus writing
( P , 0,9 ) E = CE,, we find that EPqis a Ksubset of 2‘ so that E may be viewed as a matrix
E: Q x Q + K 2
(6.1)
called the transition rnatrk of Ld.Each Ksubset of 2‘ may be viewed as a Ksubset of Z*(with value 0 on each s 4 2) and therefore E may also be viewed as a function
i.e., as a 0 x Qmatrix with values in k”*.Since K’* is a semiring, matrix multiplication can be used. T h u s for n E N the matrices
may be defined with EO
=
l,, El = E. Since
sEpnq = 0
if
1s1 f n
it follows that the family
{ E & , n E NJ is locally finite and we may define
There results a matrix
(6.3)
(6.4)
E*: Q x Q  K Z * E*=11,+E+E2+
. . . +E n + . . .
137
6. K2Automata
called the extended transition matrix of A . For each s E S" we may consider the matrix
sE"
=
[sE,&]E K QxQ
If s = o1 . . . o r i ,then
sE" = sE"= (o,E) . . . (o,,E) = (a,E") . . . (o,,E") It follows that E" may also be viewed as a matrixvalued morphism
PROPOSITION 6.1. For anv p , q E Q the Ksubset E& is the sum of all the labels of paths c : p + q in d. Proof. I t suffices to show that for each n E N , the Ksubset E& is the sum of all the labels of paths c : p 4q of length n. For n = 0 this is clear since E,O, = 1 if p = q and E& = 0 otherwise. For n = 1 this follows from the fact that I?;,* = E,, and from thc dcfinition of E p g . For n > 1 this follows inductively from the formula
COROLLARY 6.2.
The behavior of d i s
with Z regarded as a row vector and T as a column vector
I
We shall now join up with the module notation used informally in 11,4, and more formally (in the deterministic case) in I I I , l . Let X be a Ksubset of Q. We may regard A' as a row vector (i.e., a 1 x Qmatrix of elements of K ) . For each s E Z*, the matrix sE" is a Q X Qmatrix of elements of K and therefore we may denote
X S = X(sE") This is again a row vector, and
VI. Multiplicity
138 T h e formal rules
X(st)= (Xs)t,
x1 = x
( k X ) s = k(Xs) are then clear. If X is regarded as a column vector, we may write
s x = (sE”)X so that
and
(st)X = s(tX),
1x = x
k(sX) = s(kX) In particular, in the automaton s‘, I is regarded as a row vector and T as a column vector. From Corollary 6.2 we thus deduce: COROLLARY 6.3.
For eack s
E
2’”
s I d I = (Zs)T = I ( s T )
Indeed, s I d
I
= I(sE”)T
I
A K2automaton d = (Q, I, T ) is said to be normalized if I T = t are distinct singletons and if further there are no edges ka
929
.
=
i and
kn
t9
(with k f 0). Clearly for such an automaton we have
I &’ I
c Z+.
PROPOSITION 6.4. For any K2automaton d there exists a nornialized KSautomaton A?” such that
7. Recognizable KSubsets Proof.
139
Let A?'= ( Q ,I , T ) . Define
Q'=Q u i u t where i and t are two distinct new states. Define the new transition matrix E' as follows
E L = E,, EL, = 1 IpEpp PE Q
E,; where I ,
= pI
=
Eli= E,,
=0
and T , = qT. A simple calculation then shows that
Elt"
= IE+T
where
E f = E f E 2 + . . . f El'+ . . .
=
EE"
T h e automaton d' = (Q', i, t ) is normalized and
T h e construction of A?'' from &'described as the normalization procedure.
above will be referred to
7. Recognizable KSubsets Let K be a (commutative) semiring and 2 a finite alphabet. A Ksubset A of Z" is said to be recognizable if there exists a K  2  a u t o m a t o n d s u c h ' I = A. that I a We first tabulate those properties of recognizable Ksubsets which are the analogs of properties of recognizable .%'subsets established in II,3. T h e proofs will not be repeated since the constructions defined in I I , 3 apply with trivial modifications, due to the presence of the elements of K in the labels.
140
VI. Multiplicity
PROPOSITION 7.1. The class of recognizable Ksubsets of 2 7 is closed under jinite union, intersection, and reversal. This is an analog of Proposition II,3.1. We must note that the reversal Ae of a Ksubset A of C* is the composition
PROPOSITION 7.2. I f f : r*+ C* is a fine morphism and A is a recognizable Ksubset of P, then Af is a recognizable Ksubset of P . This is an analog of Proposition II,3.2 I PROPOSITION 7.3. Let f : r" Z* be a morphism such that 1 = 1f I. If A is a recognizable Ksubset of 11*,then Af is a recognizable Ksubset of C*. f
We first note that the condition 1 = If' is equivalent with the condition that sf l is finite for all s E s*. This is precisely what is needed to define Af, without assuming that K is complete [see (4.5)]. T h e conclusion now follows by a slight modification of the construction used to prove Proposition II,3.3 I Let C and P be disjoint alphabets and let
be Ksubsets of L'* and P , respectively. For x E T* and y E P , the shuffle product x LLJYis a finite subset of (S u I')". Further the sets x UJ y and x' w y' are disjoint except when x = x' and y = y ' . This iiiipIies that the summation
A
LL
B
=
c ( x A ) ( y B ) ( xw y )
ztZ"
?/€I,*
is well defined, yielding the shuffle product A LU B of two Ksubsets. T h e construction given in the proof of Proposition I I , 3 . 4 then yields: PROPOSITION 7.4. If C and r are disjoint alphabets, A is a recognizable Ksubset of Z", and B is a recognizable Ksubset of P, then A w B is a recognizable Ksubset of (Z u T)* I
141
7. Recognizable KSubsets T h e passage from the shuffle product
LL
to the internal shuffle product
A u B of two Ksubsets of L'" is handled exactly as in II,3. T h e analog of Proposition II,3.5 is:
If A and R are recognizable Ksubsets of 2",
PROPOSITION 7.5.
then so is A u B
I
We shall now establish a number of propositions for which no analog in II,3 has been stated.
Let A be a recognizable Ksubset of 2" and let K . Then k A is a recognizable Ksubset of S".
PROPOSITION 7.6.
k
E
Proof. Let SY' = (0,I , T ) be a K2automaton recognizing A. Then k A is recognized by either one of the K2automata
k d = ( Q , kI, T ) , with the transition matrix unchanged PROPOSITION 7.7.
q the
Ksubset A'
=
d k
=
(0,I , AT)
I
A Ksubset A of 2" is recognizable A n I+is recognizable.
q and
only
Proof. If A is recognizable, then A' is recognizable by Proposition 6.4. Another way to see this is to use Proposition 7.1 and the obvious fact that L+ is recognizable. Conversely, assume that A' is recognizable. Since .4 = kl A'
where k = 1A and since 1 is recognizable, it follows from Propositions 7.6 and 7.1 that A is recognizable I PROPOSITION 7.8.
I f A and B are recognizable Ksubsets of X",
then so is AB. Proof.
Let
4 with A'
=
'4 n Z+,B'
kl =
+ A',
I3 = 11
+ B'
B n X+.'Then
A B = k l l 4kB' + IA' $ A'B'
VI. Multiplicity
142
Thus by Propositions 7.1, 7.6, and 7.7 it suffices to show that A'B' is recognizable. Let L d=
(Qi
9
ii
1
ti
),
.z = ( Q 2 ,i,, 2 , )
be normalized K2automata recognizing A' and B'. Consider the normalized KSautomaton '8 = (Q, i,, t , ) where Q is obtained from the disjoint union Q1 u Q2 by merging t , with i,. T h e edges of $5' are those of &' and those of 9?. Clearly
PROPOSITION 7.9. Let A be a recognizable Ksubset of 2f. Then the
Ksubsets
A+=A+A'+
. . . +A " +
...
A*= 1 + A + A 2 + . . . + A " + . . . are recognizable. First we must observe that the family of sets {A" I n E N ) is locally finite, so that A+ and A" are welldefined Ksubsets. Indeed, since A c Z'f we have sAJJ= 0 whenever I s I < n. Let & = (Q, i, t ) be a normalized K2automaton recognizing A. Then merging the two states i and t into a single state which is both initial and terminal we obtain a KSautomaton &' * (no longer normalized). It is clear that I & " I = A*. Thus A" is recognizable. Since A t = A" n Zf, the same follows for A+ 1 Proof.
THEOREM 7.10. (Schutzenberger) A Ksubset A of Zfis recognizable if and only if there exists an integer n > 1 and an nxnmatrix E of Ksubsets of Z such that A = E:l.
Proof, Assume that A is recognizable and let & = (Q, i, t ) be a normalized K2automaton recognizing A. Without loss we may assume that Q = (1, . . . , n} with i = 1, t = n. Since i f t it follows that n > 1. By Corollary 6.2, I & I = E& = Et,l. Conversely, assume that A = Ef,t, where E is an n x nmatrix of Ksubsets of .Z and n > 1. Then setting Q = (1, . . . , n } we obtain a KZautomaton M = (Q, 1, n ) with transition matrix E. As above Idq=E;,=A I
8. The Equality Theorem
143
As a byproduct of the argument above we obtain COROLLARY 7.11. If E is a n x nmatrix of Ksubsets of L', then for any 1 5 i, j 5 n the Ksubsets E$ and E$ are recognizable I PROPOSITION 7.12. Let p: K + K' be a morphism of semirings. Zf A is a recognizable Ksubset of P, then A p is a recognizable K'subset of 2".
Let d =(Q, I , T ) be a K2automaton with transition matrix E, such that I ,d I = A. Then the K'2automaton d p = (Q, Ip, T y ) with transition matrix Ep, satisfies I d p I = I d I p = Ap I Proof,
COROLLARY 7.1 3. If K is a positive semiring and A is a recognizable Ksubset of S*,then A t is a recognizable 9subset of L'* I PROPOSITION 7.14. Let A be a recognizable 93'subset of 2*. Then A viewed as an unambiguous Ksubset of Z* is recognizable. Proof. Let &' be a deterministic 2automaton with behavior A. If we view d as a KSautomaton, then its behavior is A regarded as a Ksubset
Corollary 7.13 and Proposition 7.14 jointly show that for unambiguous subsets of Z*, the notion of recognizability is independent of the choice of the semiring K. EXERCISE 7.1. Make explicit the constructions of the automata required to prove Propositions 7.17.4. 8. The Equality Theorem
In this section it will be assumed that K is a subsemiring of a (commutative) field F. This includes the semirings N , R,, and Q+ but excludes 9, ,F, and 9+. It also includes those commutative rings which are integral domains, e.g., the ring 2 of all integers. THEOREM 8.1. (The Equality Theorem). Let A , and A , be recognizable Ksubsets of Z* and let di = (Pi, Zi,Ti)be K2automata such that I di I = A i for i = 1, 2. If ni = card Q i and
sA,
= sA,
VI. Multiplicity
144
for all s E Z* such that Is1 0 we have
vo c . . . ‘The cases I = 0 or T (Is)T = 0. Therefore dim I/,
=
c V,, c
W
0 may be ruled out since then obviously
=
1,
It follows that for some 0 5 k < n
dim W 
=n 
1
1
v, = v,,, Since V,,, is generated by all the vectors X and XG with X E V,,, , it follows that V,+, = V,,, and thus by induction V , = V k + pfor , all p 2 0. This implies V , c W for all K E N . T h u s for any s E Z*we have Is E W , i.e., (Is)T = 0 COROLLARY 8.3.
i j and only i j s I d I
If.#= (Q,I, T ) is a KEautomaton, then I d 1= 0 0 for all s E S* such that 1 s I < card Q I
=
T h e following example shows that the numerical bound in Theorem 8.1 is the best possible.
VI. Multiplicity
146
EXAMPLE 8.1. Let 0 . I n1 5 n2 be integers. Consider the alphabet L consisting of a single letter (r. Let dlbe the deterministic automaton with n , states represented symbolically by the path
T h u s A , = a’+’. Let d2be the deterministic complete automaton with n2 states represented symbolically by the loop
with t
=
i(r’211
as terminal state. Then
However, for all lower exponents k we have & E A , iff
(rt
E
A,
An important consequence of Theorem 8.1 is: THEOREM 8.4.
G i w n any two recognizrrble Ksubsets A, I
I”, it is decidable whether or uot A ,
;2,
and ‘3, of
:
This statement requires several caveats. First thc word “given” should be interpreted to mean that K:automata d, = (Q,, I , , T , ) such that I dt I = A , for i 1, 2 arc cxplicitly provided. Then, of course, all the card Q, can be enumerated and paths of length less than n = card Q, thus s I dl1 and s I d2 1 can be computed for I s I < n. W e must then 1 for all 1 s 1 ;n. be able to decide ahether or not s I dl1 = s 1 d2 This means that the semiring A’ must be known well enough to permit such decisions. T h u s we see that Theorcm 8.4 silently assumes that a number of other facts are decidable.
+
EXERCISE 8.1. Let A , , A, be recognizable .8’subsets of 2” and let dibe autotrwt(z wit12 ni states sirrh that 1 di1 = A , for i = 1, 2. Show
that if S E
A,
~
S
A ,E
9. The Case K = N
147
OPEN PROBLEM. cise 8.1 ? 9. The Case K
=
IC'limt is the best possible bound f o r
Is1
in Exer
N
In this and the subsequent sections of this chapter we shall concentrate on thc casc K = N . W e recall that an NIautomaton
two Nsubsets I and T of 0, and an Nsubset E consists of a finite set 0, of ,O < 1:Y 0. If the subsets I , T , and E are unambiguous, then the automaton ,iJ is said to be iincrinb/'gitozrs. l'he unambiguous N1automata are exactly the 1automata of Chapter 11. Note that if ,Jis unambiguous, then for each o E L,the niatris oE has 0 and 1 as its only entries.
Let 2 = (0, I , T ) be an NLautomaton such that .I = I 3 1. T h e Nsubsets Z and T of 0 may be written as finite sums of unambiguous subsets (e.g., singletons) Proof,
I=Z, r 7
+ ... +Ii,
T = T,
+ . . . + TA
Ihen = LA,,nith 1 5 i 5 I , 1 ( j 5 k and A,, = 1 ( Q , Z L , T ) )1. If for each A ( , n e can construct an unambiguous automaton d I , such I, then the union of the automata dL, provides an that A,, = 1 dl1 unambiguous automaton L.u/'such that d = 1 d 1. Consequently it suffices to consider the case whcn Z and T are unambiguous subsets of Q. Each edge of 4' has a label of the form no nit11 n 2 1 and o E 1. Let k be the largest integer n thus obtained. Consider the unambiguous automaton d =( Q X k , I x O , T x k )
VI. Multiplicity
148 with edges defined as follows. For each edge
.>
introduce the edges
(P, L+ (4,
(9.2) provided u v z
1 mod k
0 5 1 < n.
with
We shall say that the edge (9.2) coeiers (9.1). For each edge (9.1) there are exactly nk edges covering it. However, there are exactly n edges covering (9.1) if the start state ( p , u ) of the edge (9.2) is specified. A path c' in &is said to cozier a path c of 9' if the j t h edge of c' covers t h e j t h edge of c for 0 < j 5 11 c 11. From the observation made above we deduce (by an easy induction on the length):
q with label ns, there are exactly n paths c': (9.3) For every path c: p ( p , 0) 4 (9, z)), v E k , covering c. Each of these paths has the f
label s. T h e path c' is successful iff the path c is. T h u s a simple count shows that I 3' I and therefore I I = A. If A is in L", then 29 = (0,i, t ) may be chosen to be normalized. In the resulting unambiguous automaton
s I LdI = s
, d =(Q> 0 be an integer. Every integer x E N may then be written uniquely in the form
x = p(x.)
+ xp
with 0 5 x/" < p and 0 5 xrx. Consequently for every Nsubset A of a set S we have
(10.1)
A
= p(Arx)
+ A/3
10. The Division Theorem
151
where An is an Nsubset and '41 is an Nsubset satisfying x(AP) < p for every .T E S.
p
THEOREM 10.1. Ldet A be a recognizable Nsubset of Y*, and let , 0 be an integer. Then in the decomposition (10.1 ) the Nsubsets Ars and
'411 are recognizable. Further, f o r every 0 5 k ': p the 3subset A,
= {s
I sA
k modp}
i s recognizable. Proof. Without any loss of generality we may assume that A c Ti. By Corollary 9.2, A is then the behavior of an unambiguous 2automaton d =(Q, I , t ) with a single terminal state t. For each function r: Qp
we introduce a new state . r ) . Let R be the set of states thus obtained. We shall construct a new automaton .iA with Q u R as the set of states. T h u s if d h a s n states, then A will have n p" states. Every Nsubset of Q will also be viewed as an Nsubset of Q u R. Note that Y above is an Nsubset of Q and thus also of Q u R. However, r ) is a single element of R. For every s E S" and every Nsubset B of Q, Bs is again an Nsubset of Q. We now extend this action to the set R by setting
+
r ) s = (rs)cI
If s r)l
=
+
(rs)P)
1, then Y S = Y , ( Y S ) ~= ru = 0, and (rs)/3 = r/3 = For v E L'* we verify that
= (r).
(10.2) Indeed, setting C
.'Y)(SU) =
= YS
we have
(V)P
[(CPbIP
as required. Next, if I is the set of initial states of d, we may regard I as an N subset of Q and thus ( I ) E R. We take I) as the initial state of the automaton 3'.With the terminal state t unchanged, we have s
I 29 I
=
t(/l)s)
=
t[(ls)u
=
t[(Is)a]= [t(Is)]rx= (si4)cx= s ( A a )
+
(Is)B>I
I 23' j = Au. Thus Au is recognizable. To prove the second part of the theorem we choose 0 5 k < p . We as before, but with the set of terminal states T L define the automaton
so that
TL = (i~) J tr = k} where t is the unique terminal state of d.Then s E I gn I iff ( 1 ) s n TI.# 0. Since ( 1 ) s = ( 1 s ) ~+ i(Is)P), this is equivalent tvith t((Is)B) = k
i.e., with
t(Is)= K
modp
or still with s l d J = k modp
Thus
I .a9, I = A, and A, is recognizable.
11. The Subtraction Theorem
153
T o conclude the proof we note that
AP
=
A,
+ 2 4 + ... + (p

l)Ap,
I
so that the Nsubset i3B is recognizable
COROLLARY 10.2. If A is an Nsubset of S" and p A is recognizable f o r some p >* 0, then '4 is recognizable I COROLLARY 10.3. For any recognizable Nsubset '4 of 3,the following conditions are equivalent:
(i) (ii)
There exists an integer p 2 0 such that s.4 5 p f o r all s E L'*. A is the finite union of unanibigiioits recognicable Nsubsets of Sx
I
11. The Subtraction Theorem
Let A and B be Nsubsets and assume that
B I A i.e., that sB 5 s A for all s E Sx. 'I'he difference '4 defined by s ( A  B ) == s.4  SB More generally, without assuming B
EXAMPLE 11.1. Ex given by
With 1:=
{G, T }

B is the Nsubset
5 A , we may define A
B by
1
consider the Nsubsets C, D of
1 s + I s IT2 = 2 I s 1" I s IT
sc
=
S D
Then C and D are recognizable, since
C
=
(4n A )
+ ( B n B),
D
=
2AB
where A and B are the sets given by Example 1.1. Clearly D However, s(C  D )= (I s lo  I s I r ) 2 and thus
( C  D)t
=
{s
IIs
I0
f I s 1),
5 C.
VI. Multiplicity
154
This is the complement of a nonrecognizable set (Example II,S.4). 'Thus the Nsubset C'  I1 of L'" is not recognizable. Let A and 13 be recognizable Nsubsets .f L" nrid assiime thnt B is boiiiided, i.e., sB 5p for nll s E .Y* and some jixed integer p 2 0. Then A B is recogriizmDIe. THEOREM 11.1.
Proof. T h e proof depends upon a "cross section" thcorern that nil1 be proved in IX,7. B y Corollary 10.3 we niay assiiiiie that B is the finite union Bl 4 . . . 1 B, of recognizable unainbiguous subsets of S".Since
4
B ' ) L B,
I1 = ( A
:
with B' = H, 1 . . . 1 B,, , it suffices to prove the theorem when B is unambiguous. '3'ince
.
'4
B
=
(A
,4t)
~
+ (.4?
L
B)
and A t A B, as the difference of unambiguous recognizable sets, is recognizable, it suffices to prove that A ' = il  .+It(i.e., .4 1L'*) is recognizable. Without loss of generality, we niay assunie that 1'4  0. By 'Theorem 9.3 there exists a finite alphabet l', a very fine Inorphisin f : 1'" + L", and a local set 13 in TI such that Bf A . I k . More exactly, for each factor
into nontrivial paths the inequality I < k must hold. Let Bjf) be the sum of the labels of the paths in Cg). We have
B!?’ = E.. 11
Bit’ = j 3  I ’
+Bik
(k1’
B‘k1) +B‘kI’
( k k
)
kj
,
O 1. Write the nth equation as
it follows from Propositions 6.1 and 6.2 that Since En, c 2+
Substituting this into the first n
of n  1 equations with n


1 equations we obtain the system
1 unknowns with
Thus the system (6.8) still satisfies condition (6.5) and (6.4), and thus by the inductive hypothesis its unique solution X , , . . . ,X,, is in RatK 2". Substituting in (6.6) we obtain C E Rat, 2". Thus (6.7) yields X,, E RatK 2". Since S,, . , . , X,,clearly solves (6.2), the conclusion follows I T h e procedure of the proof gives a definite algorithm for expressing the solutions X , , . . . , X , , as rational expressions in the coefficients Eij, Ti.These expressions will depend upon the numbering of the equations. Now let d =(0,I , T ) be a K2automaton and assume that Q = (1, . . . , n } . Let E be the transition matrix of d. Define
Then by Corollary V1,6.2
Xi
=
(E"T),
so that
X = E"T
VII. Rational Sets
182
Since E i j c Z, condition (6.4) is satisfied and thus X is the unique solution of the system of equations
X = EX+ T Since all the coefficients are in Ratli Z", it follows that X , , in Ratli Z". Since
. . . , X n are
where I i = il is the value of I at the state i, it follows that
As a byproduct we obtain: Let d =( Q , I , T ) be a KZautomaton with (1, . . . , n } and with transition matrix E. Then (6.9) holds with ( X , , . . . , X,,) the unique solution of the system of equations
THEOREM 6.4.
Q X
= =
X = EX+ T
I
7. Examples EXAMPLE 7.1.
Consider the automaton
T h e equations are
x, = a x , + TX,
x,= (.
+ ")X,+ 1
Solving the second equation yields
x, = .(
+ T)"
Thus the first equation becomes
X I = GY' ,
+ z(a + T)"
so that
X,
= u*t(.
+ T)"
7. Examples
183
This is the behavior of the automaton. It is the unambiguous set of all words in {a, z } * which contain at least one letter z. EXAMPLE 7.2. Consider the automaton
T h e equations are
x,= ax, + T X , + 1 x,= zx,+ ax,
From the second equation we obtain
Th u s the first equation becomes
x,= ( 0 + to%)X, + 1 and therefore
x,= (a + T&)*
This is the behavior of the automaton. It is the unambiguous subset of those words in { G , T } * which contain an even number of T ' S . If we first solve the first equation, we obtain
x,= a*(tS, + 1) Th u s the second equation becomes
x,= (a + t a " t ) X , + za* Consequently
x,= (a +
and therefore
XI = a*t(o
+
TfJ*T)*T(T*
TU*T)*TB*
+ 0%
Th u s the second procedure yields a considerably more involved rational TO*T)*. expression for the set (a If we retain 1 as an initial state but regard both 1 and 2 as terminal states, the behavior of the automaton should be {a, t}*, as the automaton is complete, deterministic, and all its states are terminal. T h e
+
VII. Rational Sets
184
equations however are
x,= ox,+ tx,+ 1 x,= t X , + ax, + 1 T h e second equation yields
x,= a"(tx,+ 1 ) so that the first equation becomes
x,= (a + ta*t).Y, + TO* + 1 Consequently
This indeed is the set {a, t}" represented as the union of the set of words having an odd number of t ' s and the set of words having an even number of t's. EXAMPLE 7.3. We propose to find a rational expression representing the unambiguous set
A = Z*

Z"ataZ+,
Z
{a, t}
=
We start with the nondeterministic automaton a
0 0
+1"2L3"4+ T
a
0 0
whose .2?behavior is Z*ataL'*. Applying the subset construction we obtain the table
l a = 12, 12a = 12, 130 = 124, 1 2 4 ~= 124, 1 3 4 ~= 124, 1 4= ~ 124,
It= 127 = 13t = 124t = 134t = 14t =
1 13 1 134 14 14
7. Examples
185
which leads to the complete automaton n
U
in which 1, 2, 3, 4, 5, 6 replace 1, 12, 13, 124, 134, 14. T h e state 1 is initial and 4, 5, 6 are terminal. 'I'he behavior is the unambiguous set given by S"~TGL'". T o obtain a complete automaton ,u/ with I ,w' I = A we must replace the terminal states 4, 5, 6, by 1, 2, 3. In this automaton the states 4, 5 , 6 are no longcr coaccessible and thus may be omitted. This leaves the deterministic automaton
T h e equations are
s,= T S , + us, + 1
x,= ox, + tX;,+ 1 x,= tX, + 1 Eliminating X, we obtain
x,= LY, + o x 2 k 1 'Y, = O X , + ?XI + 1 + t. Thus
x,= O " ( t ~ X ,+ 1 + t)
and the first equation becomes
VII. Rational Sets
186 8. Unambiguous Rational Sets
Let M be any monoid. We shall consider the unambiguous subsets of M and will restrict the rational operations in such a way that only unambiguous subsets can be obtained. This means that the union A u B can be formed only if A and B are disjoint. Similarly the product A B can be formed only if 4 6 , = a,b, with a,, a, E A , b , , 6 , E B implies a, = a 2 , 6 , = 6,. I n order to form A 1 we require that each All, n > 1 can be formed and further that the resulting sets A , A2, . . . , A", . . . are disjoint. This is easily seen to be equivalent with the following condition: If a, . . . a,, = a,' . . . a;,, with a , , . . . , a,,, a,', . . . , E A , then n = n' and a, = ai' for all 1 5 i 5 n. Such sets were considered in IV,5. We called such a set a base because the submonoid A" of M is free and has .4 as its base. Since the unit element 1 of M cannot then belong to A , the condition is equivalent with A + being a free subsemigroup of M with A as base. T h e three operations A u B, AB, and A +just described, with the restrictions concerning their applicability, will be called the unambiguous rational operations. T h e class URat M of the unambiguous rational subsets of hf is the smallest class '$ of unambiguous subsets of M such that :
(8.1) all singletons (8.2) E 'if,
712
are in 'fi,
a
(8.3) '6is closed under the unambiguous rational operations. PROPOSITION 8.1. Let A be an unanzbiguous subset in a monoid M . E Rat.v M if and only A E URat M .
Then A
Proof, Clearly if A E URat M , then also A E Rat, M . To prove the opposite implication, denote by d the class of all Nsubsets of M that are not unambiguous and define
9 = '6u URat Ad Clearly all singletons are in 9. We propose to show that 9 is rationally closed. Assume A , B E 9.If A u B is not unambiguous, then A u B E '6 c 9.If A u B is unambiguous, then A and B must be unambiguous and A n B = (2. Since A , B E 9 it follows that
8. Unambiguous Rational Sets
187
A , B E URat A2 and thus A u B E URat Ai' c 9.T h u s in all cases '4 u B E 3.If A R is not unambiguous, then rZB E 6'.If A B = (i.e., A = ~4 or B ,I), then AB E URat M . If A B f (3 and A R is unambiguous, then ;2 and B must be unambiguous and thus A , B E URat h2, \$hich implies .4B E URat M . 'l'hus in all cases A B E 9.Let k E N . If k = 0 or A = (23, then k A = (3and thus k A E URat M . If k = 1, then k,4 A E A. If k 7 0, 1, A f @, then k A E 6'.'l'hus in all cases k.4 E 2'. If A + is not unambiguous, then A + E 6.If A+ is unambiguous, then A also must be unambiguous and thus A E URat IIf. Consequently A1 E LJRat M . T h u s in all cases A+ E 9. :
~
Having shown that
$1
is rationally closed we deduce that
Rat, hi' c '8' u URat ICZ This is precisely the desired conclusion THEOREM 8.2. Let A be a recognizable zmambiguous subset of 3". E URat Z",
Then A
Proof. By Proposition VI,7.14 and by Kleene's Theorem we have E Rat, S". Since A is unambiguous the conclusion follows from Proposition 8.1 I
'4
Another way of verifying Theorem 8.2 without using Proposition 8.1 is as follows. We apply to A the iterated updecomposition of Chapter IV, and verify that all the operations applied are unambiguous rational operations. T h u s the iterated updecomposition effectively shows that
.4 COROLLARY 8.3.
E
URat 1"
Rat,, 1%= URat 1".
We quote without proof the following: THEOREM 8.4.
monoid, then Rat
(EilenbergSchutzenberger) = URat M I
If M is a commutative
M
T h c conclusion fails when M is the product monoid {a, t
} "{ q ~} " .
EXERCISE 8.1. Let '3 be an uizanzbiguous subset of the free monoid Z". Show that the following conditions are eqitiualent :
VII. Rational Sets
188
(i) A is a base. (ii) A+is unambiguous. (iii) A* is unambiguous. (iv) a,A" A a2A" = @ f o r a , , a? E A , a , # u2 EXERCISE 8.2. Consider the Nsubset A = {a,TC, at}* of {(T, T } " . Exhibit an element s E {a, r}" such that sA = 2. Show that a,T ( T , (TT form a unique minimal generating subset for the submonoid A of {a,T}". EXERCISE 8.3.
Show that in a commutative monoid M an YIrsubset
A is rational ifJ
,4
1
(JC'Bi"
where the union i s j n i t e , ci E M , and B iare$nite subsets of M. What conditions must be imposed in order to ensure that A is unambiguous? 9. The Semirings N and ./r
Next to the semiring /A the semirings N and !/'are the ones that are most important for us here. In fact, the introduction of a general semiring K was mainly a device for not having to mention constantly a, N , or L YT h e semiring N comes up most naturally when we consider multiplicity in automata. T h e semiring N" will similarly appear in more evolved machines that will be considered later. T h e simplest way in which the semiring JPappears is when we consider a morphism f: C" + P which erases a letter (T, E Z (i.e., such that cr, f = 1). Then a,+fif interpreted with multiplicity must be the element 1 of P with multiplicity 00. In view of the inclusion N c J e a c h Nsubset A of a set X may also be regarded as an &subset. W e shall then say that A is a nonsingular J"subset. T h u s an ,Ysubset A of X is nonsingular if x A f 00 for all x E X.
Let M be a locally finite monoid and let 1. For any Nsubset A of M the following conditions are
PROPOSITION 9.1.
M
=M

equivalent : (i) (ii) (iii) (iv)
A E Rat,. M . A n M  E RatAvM. A E Rat M . A n M  E R a t r M. fp
9. The Semirings N and JT
189
Proof. T h e equivalences (i) c (ii) and (iii) c(iv) and the implication (ii) 3 (iv) are clear. T h u s only the implication (iv) 3 (ii) needs to be proved, and thus we may assume that A c 111. Let '6 be the class of all . Ksubsets of M that are singular and define
9 = '6u Rat, A!T h e class P clearly contains all the singletons in M . I t is also easy to verify that 9 is rationally closed. Consequently Rat ) . M  c '6'u Rat, M n u t this signifies that a nonsingular subset in Rat, M  is in Rat.v M  I For each /"subset A of I' we define the Ksubsets A,, , A , as follows zzz
{ 0xA
xA
if
:
0 and all 11, v, w E 1" lini sup )I + c a
(uvvlw)A =0 (1 E ) "
+
10. Generalized Automata
Let IC.1 be a monoid. A generalized Mautomaton is the triple L Y ' = (0, I , T ) where Q is a finite set and I and T are unambiguous subsets of Q, together with a finite number of edges 111
P4
VII. Rational Sets
192
with p , q E Q, m E M . Thus the set of edges is a finite (unambiguous) subset of Q x M X Q. Paths, successful paths, and their labels are defined l is an .&'subset of M ; x I in the usual fashion. T h e behavior I d is the number of successful paths c in .13with label I c I = x. Since there is no a priori limit on the length of such paths this number may be infinite and that is why I d l is an uFsubset and not just an Nsubset as in the case of Zautomata. THEOREM 10.1. A n uFsubset of a monoid M is rational i f and only i f it is the behavior of a generalized Mautomaton.
A n JFsubset of a locally Jinite monoid M is rational and nonsingular if and only i f it is the behavior of a generalized Mautomaton with labels in M  1. THEOREM 10.2.
Proof. Let d =(Q, I, T ) be a generalized Mautomaton. For each m E M occurring as a label of an edge of d, introduce a letter o J a ,and let Z be the alphabet thus obtained. Let f: Z* + M be the morphism given by gJnf = m, and let .2? be the Zautomaton obtained from d be replacing each label m by CT,,.Then I ."A If = I d 1 . Since I 93' I E RatN Z* c Ratf. Z* it follows from Proposition 2.4 that I j3 I E Raty Z*. If M is locally finite and d h a s labels in M  1, then If' = 1. From Exercise 4.5 it then follows that f is locally finite. Thus I d I E RatA$,M by Proposition 4.4. An alternative argument appeals directly to the local finiteness of M . Since no edge of JY' has label 1, there can only be a finite number of paths in d with a given label x. Thus I d I is nonsingular and by Proposition 9.1, I &' I E Rats M . This proves both theorems in one direction. For the other direction consider A E Rat,' M . By Proposition 9.5, there exists a finite alphabet Z, a morphismf: Z* + M , and a rational set B E Rat, S* such that A = Bf. If further M is locally finite and A E RatAvM , then Proposition 4.5 can be used instead so that f can be assumed to be locally finite. If for two distinct letters C T ~ o2 , E Z we have o,f = C T ,then ~ , the letters ( T ~and C T ~can be merged and the morphism f can be factored into
Z* t L"* + M
where S' is a smaller alphabet than Z. Thus there is no loss is assuming that f is injective on the set S.
10. Generalized Automata
193
Since B E Rats S",Kleene's Theorem yields a Lautomaton 9 such that I 29 I = B. Further by Theorem VI,9.1 it may be assumed that 29 is unambiguous. Replacing each label u of 9 by af we obtain a generalized Mautomaton d s u c h that I ,3 1 = I R I f . T h u s '4 = I d I. If M and f a r e locally finite, then crf f 1 for all u E S a n d thus , d h a s labels inM1 I I t should be noted that the assumption that &'has no unit edges (i.e., edges with label 1) is quite essential. Indeed the automaton
has behavior 1 with multiplicity
00.
C O R O L L A R Y 10.3. An Jrsii6set of a locally$nite monoid 111 is rational if and only if it is the behavior of a generalized Mautomaton with labels in I
(M hP) u 1. Since each element of 111  1 is a product of elements in M  M2, the corollary follows from Theorem 10.1 by subdivision of edges I C O R O L L A R Y 10.4. An Ysubset of S" is rational if and only the behavior of a generalized L"automaton with labels in Z u 1
if
it is
I
C O R O L L A R Y 10.5. An 4"subset of a locally JSnite monoid M is rational and nonsingular ;f and only if it is the behavior of a generalized Mautomaton with labels in M  W . I
This follows from Theorem 10.2 by subdivision of edges
I
In the definition of a generalized Mautomaton we insisted that I and T be unambiguous subsets of Q and that the set E of edges be a finite unambiguous subset of Q X M X 0. T h e method of Theorem VI,9.1 shows that there is no harm in permitting finite multiplicities. T h u s we may permit I , T , and E to be finite . Ysubsets (i.e., Nsubsets with finite support).
194
VII. Rational Sets
References
There is a considerable amount of literature related to matters discussed in Section 3. T h e following three references treat some of these questions (in the case K = 2? only). A. Ginzburg, “Algebraic Theory of Automata,” Chapter 4, Academic Press, New York, 1968. A. Salomaa, “Theory of Automata,” Perganion Press, Oxford, 1969.
Chapter 3 contains the proof that the set A, defined in Section 3 has height exactly h. J. €1. Conway, “Regular Algebra and Finite Machines,” Chapters 3, 4, 12, and 1 3 , Chapman and Hall, London, 1971.
Theorem 3.1 is on p. 118. S. C. Kleene, Representation of events in nerve nets and finite automata, “Automata Studies” (C. E. Shannon and J. McCarthy, ed.), pp. 342, Princeton Univ. Press, Princeton, New Jersey, 1956.
This is the original reference to Kleene’s Theorem. J. M c l h i g h t , Kleene’s quotient theorems, Pacific J . Math. XIV (1964), 134352.
Contains Proposition 5.4. S. Eilenberg and M . P. Schutzenherger, Rational sets in commutative monoids, J . Algebra 13 (1969), 173191.
Contains a proof of Theorem 8.4.
CHAPTER
vlll An Excursion into Analysis
This chapter establishes a connection between the rational subsets of 2%and rational functions in the sense of algebra and analysis. This provides analytic methods for solving various “counting problems” and establishes mild connections with probability theory. 1. Generating Functions
We consider an alphabet S consisting of a single letter a. With each Ksubset A of a*, where K is any commutative semiring, we may associate the formal power series m
a,, =
a“,4
If K is a subsemiring of the field C of complex numbers, the formal power series becomes a genuine power series in the complex variable z . Note that as a concession to the usual notation in functiontheory we . T h e radius of convergence of the power write f . , ( z ) instcad of zf,, series f.l is denoted by Q., . T h u s the series 2 a,2znconverges absolutely for all x such that 1 I1 < p., and diverges for all x such that 1 z 1 > e  4 . Note that 0 I :p.l 5 00. We recall the wellknown result pL4= lim inf I a,,
195
VIII. An Excursion into Analysis
196
or equivalently (if
Q..,
> 0) 1 = lim sup I an Illn eA
Thus for any
E
> 0 the inequality
holds for all n sufficiently large. Let K c C. T h e Ksubset A of a* is said to be analytic if p.4 > 0. T h e analytic function fA represented by the power series is called the generating function of A. EXAMPLE 1.1.
T h e Nsubset A of a* given by
anA = n ! is not analytic. Indeed the power series m
C n!zn n=O
has radius of convergence zero. We shall now consider the behavior of the generating functions under various operations on subsets. Clearly if k E K , then fkA = k f 4
Thus if K c C, then @ k A == @ A
f 0
if
Let
f.d(z) = C anzn,
fIj(X)
Since @ ( A u B ) = onA it follows that
=
C bnx"
+ onB
+ b,,)z'*
f L l d z )= C (atl
1. Generating Functions
197
Consequently f.,uu e.tut{
=f.,
+fil
L We., , e B )
Since u ” ( A B )=
K cC
if
c (aPA)((TQB) c upb, =
p i q=n
ptq=n
it follows that
f.,n e.40
=f.1
2 We.,,e d
fu
if
K
=C
Since
d i ( A n B ) = (atiA)(a”B) = a,,b,, it follows that f;rne(n)=
c a,b,r4’’
This operation on power series is known as the Hadumardproduct. If we use the symbol n to denote this product, then f.4nu =
f., (3 fI3
If K c C, then lim sup I a,,b,, l * l n 5 lim sup I a,, Illrrlim sup I bn
For the internal shuffle product we have
where
( p , q ) is the binomial coefficient ( p + q ) ! / p ! q !Thus .
This operation on power series is called the Hurwitzproduct. If we denote this product by the symbol u,then fAun
=fA U f B
VIII. A n Excursion into Analysis
198
It is known that if K c C, then
Since we shall not use this result we leave it without a proof. Assume that A c Z+, i.e., a, = 0, and consider
A+ = A v A' v . . . v A" u Thus (1.1)
f.t+(z> = f.l(.)
+ [f.1(z)l2 + + [fn(z)I"+ . . . * * *
This yields a formal power series expansion =
fA+(X)
c b,zn
Since a, = 0, only terms with k 5 n contribute to the summation, so that b,, is well defined. I < 1. Consequently Assume K c C. Then (1.1) converges iff
ear+= sup{r In particular, if
Ir < edi,
~ f ( zI )< 1 for all I z
I
=
r>
eAI> 0, then 0
e.4. 5 e.1
As a function, f A l + is given by the formula
Since A*
=
1 v A+ we have
e.1.
=
e.I+
Since each formal power series f is of the form f =f., for a unique Ksubset of (s*, the constructions described above may be viewed as operations on formal power series. Thus we may denote f + = f a t + and f * = fAI. provided f(0) = 0. In the exercises below we assume K c C.
2. KRecognizable Power Series
199
Show that ;f '4 is an infinite unamblguous subset of o*, then Q . ~= 1. Deduce that p.4 5 1 whenever A is the$nite union of products of Nsubsets of o* with bounded ambiguity. EXERCISE 1.2.
2. KRecognizable Power Series
A formal power series
c a,,=" M
f ( x >=
,r=o
over a semiring K is said to be Krecognizable if the corresponding Ksubset A of O* (i.e., the subset satisfying f = f . 4 ) is recognizable. Since the formal power series fA4 is just a different way of writing the subset A , Kleene's Theorem and its various consequences apply and need not be restated. If K is a subsemiring of the field C of complex numbers, then each Krecognizable formal power series f is also Crecognizable. PROPOSITION 2.1.
Each Crecognizable subset of o* is analytic.
Proof. This follows directly from the fact that the class of analytic Csubsets of o* is closed under rational operations I
As a consequcnce of the above, each recognizable Ksubset A of 0 * , has, in the case K c C , a generating function fA4 that is analytic. We shall now give some examples which show how this analytic function can be calculated. EXAMPLE 2.1.
If
A
= cTycT
+ + cT2
63)*
+ (20)"
then
T h e radius of convergence is
since z
+ z2 + x3 < 1 for z = t .
VIII. An Excursion into Analysis
200 EXAMPLE 2.2.
Let A be defined by the automaton
of Example VI,1.4. Clearly A
=
(a
+
a2)*
and thus fii =
1 1  ( z + 9)
T o find the radius of convergence we solve the equation 1  ( z
+ z 2 )= 0
and find
T o find the coefficients in the power series expansion
we note that
(1  z
 z”fil(z) =
1
Equating coefficients on both sides we find
a,
=
1,
a,  a, = 0,
an+2 
a,.,,  a,, = 0
for n > 1. Thus a, = a , a, =
+ an.2
=
1
for
n >1
These are the recursion formulas for the Fibonacci numbers. A more formal way of computing A is to set u p the system of equations
X=oX+uY+l
Y=aX T o pass to generating functions all that needs to be done is to replace o by z . Thus z X f zY 1
x=
Y=zX
+
2. KRecognizable Power Series
201
Consequently
A = z.Y
+ zzx + 1
Thus (1

z  Z”’Y
=
1
and
A = EXAMPLE 2.3.
1 1z2,
Let A be defined by automaton
with all edges carrying the label
0. T h e
equations are
x,= zs,+ 2 X , + zx3+ 1 x,= zx,t zx, + zx, x,= :xl + ZX, + zx, Thus X ,
=X
, and the equations become
Y,= zx,+ 2zxz + 1
x, = zx,+ 2zx, T h e second equation gives
x,= ____ x, 1  22 Substituting we obtain
x,= zx, + and upon calculation
222 ~
1  22
X,= fA4(z)becomes
x, + 1
VIII. An Excursion into Analysis
202 Thus e.4
EXAMPLE 2.4.
=
4
Let D be the subset defined by the automaton
It is clear that D has the value n on u” and thus
c nzn OD
f&)
=
n=o
T o obtain a closed formula we note that
and therefore
Alternatively (and more formally) we may consider the equations
X=zX+zY
I’=zY+I T h e second equation yields
T h u s the first becomes
x = zx +
z ~
1z
so that
s=
z (1  z)Z
Note that if cfl
is any formal power series over a semiring K , then (g nf,,)z =
c na,,z”
2. KRecognizable Power Series
Thus if g
=f
203
B , where R is a Ksubset o f c*, then r l ( B n D)
yields the formal power series g’(z) =
C na,,zn* 11=1
which is the formal derivative of g. Consequently if g is Krecognizable, then SO is g’. EXERCISE 2.1. Let f ( z ) = Cr=oa # ’ be a formal power series over a semiring K , and let r E N . Show that f is Krecognizable zfJ the formal power series
c co
g(z)=
t1=O
is Krecognizable, If K c C , then show also that eJ = p u . Give two proofs; one using automata and another one using rational operations. a,,zJ1 be a Krecognizable formal power EXERCISE 2.2. Let f ( z ) = xTxo series and let p 2 1 be an integer. Show that
is Krecognizable. If K c C, then show also that p9 2 (p,)”. [Hint: Given a Kaautomaton d recognizing f , construct an automaton whose edges are the paths of length p in d . 1
a,,z” = be a Krecognizable ;”= formal power , EXERCISE 2.3. Let f ( z ) = I: series and let k E K. Show that the formal power series
c a,k”z” cn
g ( z ) =f ( k z ) =
n =o
is Krecognizable. If K c C , also show that pu = 1 k interpreted as 00 (f k = 0.
‘@J,
with
k
I’
Let f(z)= a,,z”, g ( z ) = C b,$’ be formal power series over the semiring K . Assuming that b, = 0 , define the composition EXERCISE 2.4.
(g o
f
=f(g(x))
VIII. An Excursion into Analysis
204
by formal substitution. Show that i f f and g are Krecognizable, then so is g o f . [Hint; With g $xed consider the class of all f ' s for which the conclusion is valid.] EXERCISE 2.5. Let ?k be the class of all Krecognizable formal power series f ( z ) = C a,,zn such that a,, = 0. Show that 8 is the smallest class containing the series
and
z
zn n=l
and is closed under the operations kf, f
+ g , f g , and g
of,
where k
E
K.
EXERCISE 2.6 Show that for any formal power series f ( z ) = Z&, a,@
with coeficients in a semiring K the following conditions are equivalent: (i)
The sequence a,, is ultimately periodic, i.e., there exist integers m 2 0,
p > 0 such that a,, = an+pfor n 2 m. (ii) f ( z ) = r(z)(zp)", where r is a polynomial and
p > 0.
3. The Case When K I s a Ring
We shall now assume that K is a commutative ring. T h e formal power series M
f ( z )=
C
a,,zl'
n=o
will be called rational if there exist polynomials p and q with coefficients in K such that qf = P, do) = 1 The polynomial q will be called a denominator off. We show that this notion of rationality coincides with the inductive one defined using rational operations. With p and q as above, write r = 1  q. Then r is a polynomial, r(0) = 0 and q = 1  r . Thus
r*q
= r* 
r+ = 1
Consequently
r#p
= r*qf = f
T o prove the converse, let 8 denote the class of all rational formal power series with coefficients in K. Clearly all polynomials are in %.
3. The Case When K Is a Ring
Let f,f' E @ and let q f
=
205
p , qlf = p', q(0) = q'(0) = 1. T h e formulas
show that kf, f+f', and ff' are in '8. Next assume that f ( 0 ) = 0 or equivalently that p ( 0 ) = 0. Define q = q  p . Then q(0) = 1 and
Consequently, proved
fj
E
@. Thus 8'is rationally closed. We have thus
THEOREM 3.1. A formal power series with coefficients in a commutative ring K is Krecognizable if and only if it is rational I PROPOSITION 3.2. Let K be a subring of a commutative ring L, such that K is a direct summand of L as a Kmodule. Then any formal power series f with coefficients in K which is rational over L is also rational over K.
Proof. T h e hypothesis implies (and is actually equivalent to) the existence of a Kmorphism p: L + K such that ~ ( 1 = ) 1. Since f is rational over L, we have
where q and p are polynomials over I,. Applying rp to the coefficients we obtain polynomials q' and p' over K , such that q ' f = p', q'(0) = 1 I Note that the hypothesis of the proposition always holds if K is a field. PROPOSITION 3.3.
Let f
and let q(z) = 1
=
C
be a formal power series over K
+ c,z + . . . + c,,z"',
c, f 0
be a polynomial of degree m over K. Then f is rational and has q as a denominator if and only if the following "recursion formula" holds
(3.1)
at+,i,
+ cla/+f,'l+ . . . + c,i,a,
for all t sujiciently large.
=
0
VIII. An Excursion into Analysis
206
Proof. Equation (3.1) is simply a restatement of the fact that the coefficient of z 1 + ’in l Lthe power series expansion of qf is zero. T h u s (3.1) holds for all t sufficiently large iff qf = p is a polynomial I
T h e argument above shows that formula (3.1) holds as long as
t>O
and
t+m>degp
Thus if deg p < r then (3.1) holds for all t 2 0. This is the “normalized” case in which qf = p with d e g p < deg q. Observe that if the recursion formula (3.1) holds for all t >_ s, then the coefficients of the formal power series m
g(z) =
C
an+szlz
ll=O
+
satisfy (3.1) for all I2 0. Since f ( z ) = ~ ( z ) g ( z ) z 5 with deg u < s, any denominator o f f also is a denominator of g . Thus if we replace f by g , we are in the normalized case. Symbolically we can write
with deg u < s, d e g p < deg q. T h e following theorem will not be used in the sequel and is stated without proof. T h e proof is rather difficult. (SkolemMahlerLech) Let K be a field of chara,,z” be a formal power series rational acteristic zero and let f ( z ) = CT=‘=, over K. Then the subset A = ( n 1 a , = 0} THEOREM 3.4.
of N is recognizable
I
‘The following example shows that the hypothesis that K has characteristic zero is essential. EXAMPLE 3.1. Let p > 1 be a prime and let K be the field obtained from the prime ficld 2, by adjoining a single indeterminate x. Define
a,, = (1
Then a ,
=
+ x)”  1

x”
O iff n is a power of p and thus the set A is not recognizable.
4. The Case K = 2
207
However, the recursion formula
+ .v)a,_,  ((1 + x)* + x)a,, + x ( l + x ) a L P g
a , = 2(1
holds for all i 2 0. T h u s the formal power series f ( z ) = xT=o a,@ is rational over K . 4. The Case K
=Z
Let 2 be the ring of all integers, and Q the field of rational numbers. Proposition 3.2 then has an analog with h‘, L replaced by Q, Z .
If a power series f is rational over Q and has coefficients in Z, then f is rational over Z. Further the lowest denominator o f f over Q has its coefficients in Z. THEOREM 4.1.
This is a reformulation of the socalled “Lemma of Fatou.” I n XVI, 10 we shall state a considerably stronger theorem. We therefore omit the proof of Theorem 4.1. THEOREM 4.2. For any power series .f(z) = ~ ~ = o a , , with s n integer coefficients the following conditions are equivalent :
(i) f is rational and the sequence I a,, 1 is bounded. (ii) There exist integers m 2 0, p > 0 such that a,,+, = a,,for all n 2 m. (iii) There exists apolynomial r and an integerp > 0 such that f = (zP)*r.
I f the above conditions hold and $further a,, E N for all n Nrecognizable.
E
N , then f is
Proof. (i) (ii). Since f is rational we may assume that the recursion formula (3.1) holds. Since the coefficients a,, are integers and 1 a,LI is bounded, the coefficients a,, take on only a finite number of values. Consequently with n fixed there is a finite number of distinct sequences ak 9 att1,
Then let m
...
9
%+,11
2 0, p > 0 be integers such that a i= a p t i
if
nr
cism +n
It then follows from the recursion formulas (3.1) that a , = i 2 m. This proves (ii).
for all
208 (ii)

VIII. An Excursion into Analysis
(iii).
Define
+
+
+ +
q ( x ) = a, a,x . . a/,6~lZm1 s(z) = a,z* a n l + l ~ m + l. . . a,n+plx m f p  l
+
*
+
Then (4.1) This implies
+
s(x). with ~ ( z=) q(z)(l  xp) (iii) 3 (i). Obvious. If the coefficients a, are all in N , then the polynomials q ( z ) and s(z) defined above have coefficients in N and thus formula (4.1) shows thatf is Nrecognizable I COROLLARY 4.3. An unambzguous subset A of N is recognizable if and only if its generating function fa,,is rational.
Indeed, if f..,is rationaI, then by (ii) A is ultimately periodic and vice versa I 5. Positive Analytic Functions
T h e results in the case when K is a ring are fairly complete. When we pass to the cases K = N o r K = R , which are more important from the point of view of automaton theory, the algebraic methods of the last two sections break down and in fact the main conclusions are false. Indeed, in Example 6.1 a rational functionf(z) = C unz” with coefficients in N will be constructed which is not Nrecognizable. T h u s the key theorem, 3.1, fails to generalize. There are however some compensating advantages to be derived from the assumption K c R+. They are analytic in character, and will be investigated in this section.
5. Positive Analytic Functions
209
We shall consider analytic functions given by a power series m
with a radius of convergence
Such a function will be called positive if
arrE R,
for all
n 1 0
Clearly all H+recognizable functions are positive. We shall examine here some of the consequences of positiveness. T h e basic tool is the study of the singularities o f f on its circle of convergence I z I = Q ~ .A point z,, on this circle is said to be regular iff admits an analytic continuation with center at x o . Otherwise zo is said to be singular. If for some integer n > 0, zo is a regular point for the function (2  z,,)"f(z)but is a singular point for the function (2  zo) I i ' f ( z ) ,then zo is said to be a pole of order n for f. If n = 1, then the pole is called simple. Iff is rational, then it is known that all the singularities off are poles. W e emphasize that we only discuss the singularities o f f on its circle of convergence. Singularities that may be encountered further out, when f is continued analytically, are of no concern to us here. T h e period of the function f is the highest common factor of the set of integers n > 0 such that a,, f 0. T h u s if f has period p , then
c anpz~'P "3
f ( z )=
n=O
and p is the largest integer for which this is true. If unity, then
E
is any pth root of
f ( Z E ) = f(Z>
EXAMPLE 5.1.
fk)= has period
p.
T h e function 1
00
C
znp  ,l=o
with
p~ N , p > 0
VIII. An Excursion into Analysis
210
Let f be a positive analytic function. For each z
PROPOSITION 5.1.
such that I z
I < ef we have
with equality holding
if and
If(.>
I L j I x I)
only
if
z = Iz where
E
&
is a p t h root of the unity and I is the period o f f .
and this holds iff
Let z
=
1 z 1 E with I E 1
=
1. Equation (5.1) is then equivalent with
a , ( ~ 1) = 0
for all n E N
or equivalently cn = 1
From the definition of
if a, f 0
p , this is equivalent with
THEOREM 5.2. Let f be a positive rational function which is not a polynomial. Then ef < 00, ej is a pole for j , and for any other pole zofor f such that I zo I = er, the multiplicity of the pole zo does not exceed that of ef.
Proof. Let n be the multiplicity o f a pole zo o f f (with I zo I Then the rational function
=
er).
21I
5. Positive Analytic Functions
is regular at zo and further g(zo)1 0 , since otherwise ( z  z0)”’f(z) would already be regular. Consequently
By Proposition 5.1, the same inequality must hold with zo replaced by I zo I = e f . Consequently, the rational function
does not vanish at z = el. If h has a pole at er, then f has a pole at of order > n. If h is regular at er, then f has a pole at ef of order n
ef I
We note that Theorem 5.2 is a counterpart for rational functions of Pringsheim’s Theorem asserting that iff is positive analytic with Q, < 00, then Q, is a singular point for f. Pringsheim’s Theorem itself will not be used. PROPOSITION 5.3.
Let
m
f(z)=
C a,xn,
a, =
0, a,
E
R+, ef > 0
n=o
and let
Then 0 < er* I @f
The equality
e r = er holds if and only if
er < 00 and
If efl < ef (i.e., if 1 < C;=o anern),then: (i)
pf.
=
r is the unique solution of the equation
VIII. An Excursion into Analysis
212
The singularities o f f * on the circle I z I = r are simple poles located at rE where E ranges over all the pth roots of unity and p is the period off. (iii) lim,+w cnprnp = p / r f ' ( r ) , where f ' is the derivative off.
(ii)
The same conclusions hold for the function
Since f(0) = 0 it follows that) . ( f I I < 1 for I z small. This implies 0 < ef.. Since a, 5 c , it follows that Next observe that for any r < ef we have Proof.
Thus if
I sufficiently 6 pf.
CEOanern 5 1, then f ( r ) < 1 for all r < ef and therefore
equivalently er = pf*. If Cr=n > 1, then the same holds already for some r < e f . Thus f ( r ) > 1 and by (5.2), pf* 5 r. Consequently er* < ef. Now assume that ef* < ef or equivalently that C,"==,anern > 1. Since for 0 < Y < er the function f ( r ) is continuous and ascending and since f ( 0 ) = 0 and f ( r ) > 1 for r sufficiently near to ef it follows that the equation f ( r ) = 1 has a unique solution. It then follows from (5.2) that eft = r if r is this solution.
ef 5 el*, or
T o prove (ii) and (iii) it is convenient to replace the function f ( z ) by the functionf(rz) where r = ere. After this change we may assume that
er > 1,
@f*
=
1,
f(1)
=
I
T h e singularities off*(.) are the zeros of the functiong(z) = 1  f ( z ) . Clearly g( 1) = 0. Sincef( 1) = C a, = 1 it follows thatf '( 1) = C nu,, 2 1. Thus g'(1) f 0 and therefore 1 is a simple zero for z. If E is a primitive pth root of 1, then g(xE) = g(z). Consequently, (1 5 i 5 p ) are simple zeros for g. For all other z on the disk I z I 5 1, Proposition 5.1 implies If(%) 1 < 1 and thus g(z) f 1. This proves (ii). Since the functions g(x) and 1  zp have the same zeros (with the same multiplicity) on the disk I x 1 5 1, the same holds on a larger disk
5. Positive Analytic Functions
I z I < 1+q
213
for some q > 0. Thus the function
h(z) = has no zeros for Since
~
1  zp g(4

(1

z")f"(z)
I z I < 1 + 11. m
we have m
f"(z)=
1 c,pz"p n=O
Let
Comparing coefficients we obtain
c , , ~ c(nl)p= bnp
for
n >0
and
cO= bo = 1 This implies n
c*p
=
1 bi,
i=O
and therefore lim cnp = h( 1) n+M
Since
h(z)= if
1zp 1f(z)

1zp 1z
I z 1 < 1 + q, a passage to the limit with z
127
1f(z) +
h(1) = P / f ' ( l ) as required. T h e conclusion for f
+
follows from the identity
1 yields
VIII. An Excursion into Analysis
214 COROLLARY 5.4.
I f f is a positive rational function, f(0) = 0, and
f f 0, then 0 < ef* < er and
f(Qf*) = 1 Further (ii) and (iii) hold.
Indeed, either pf = 00 and f is a polynomial, or else is a pole for f. T h u s in either case
er < 00
and
ef
I t is worth observing that conclusion (iii) of Proposition 5.3 holds also a,,ejn = 1 provided f ' ( r ) is replaced by in the case xF=O M
(5.3) and suitable conventions if (5.3) is infinite. This is with r = ern = Feller's Tauberian Theorem. EXAMPLE 5.2.
Let f(z)= 2.Then m
1
Thus in this case
p
=
2, r
=
1, and lim cr,prnp= 1. Since f ' ( r ) = 2
we have p / r f ' ( r ) = 1. EXAMPLE 5.3.
Consider the function of Example 2.2. We have
).(g
Here p have
=
1 and r
=
(45

=
z
+
272
1)/2. Since g ' ( r ) = 1
+ 2r = 47 we
6. R+Recogn izable Fu nc t ions
215
Consider
EXAMPLE 5.4.
f ( z ) = 1  dTzF Clearly f is not rational, f ( 0 ) = 0, and pr
1. Since
=
we also have pr* = 1. PROPOSITION 5.5. Let f and g be positive functions. Then Qf+g
=
inf(er, e,)
Also i j neither f nor g is identically zero, then
Proof.
erg
=
2w e / ,
Qg),
inf(e,f, e,)
T h e inequalities ertg
erg
2
w e / , e,)
hold trivially (and without the positiveness assumption). T o prove the opposite inequalities let
f ( z ) = C a,$#,
g(z) =
C b,zn
+
+
+
Then the coefficients o f f g are a,, b,,. Since 0 5 a, 5 a,, b, it 5 er. Similarly Q , + ~ I eo. Let { c n } be the coefficients follows that , ,@+, in the expansion of f g , and let bi f 0. Then
0I a,,& 5 c,,+i and therefore
0 5 a,, I c,+ilbi
6. I?+Recogniza ble Functions
THEOREM 6.1.
(Berstel)
Let f be an R+recognizable function. I f such that
er < 00, then pr is a pole for f and $ zo is any other pole for f I zo I = e , then zo = efrE where E is a root of unity.
VIII. An Excursion into Analysis
21 6
Proof. Let 8 denote the class of R+recognizable functions for which the conclusion of Theorem 6.1 holds. I f f is a polynomial, then er = 00 and therefore f E @. Suppose f , g E 8. Since by Proposition 5.5
efg= ef t U = inf(er eg>
+
and since each pole of fg or off g must be a pole of either f or g, it follows that fg and f g E @. If Y E R+ , r > 0, and f E i?, then clearly rf E.'?!it Finally assume that j E @, f f 0, f(0)= 0, and consider f+. If ef = 00, then f is a polynomial and f(r) 00 as r 00. If er < 00, then pf is a pole for f and f ( r ) + 00 as r + p,. Thus in either case the hypotheses of Proposition 5.3 are satisfied and thus f + E k?. Having shown that 8 is closed under rational operations, it follows that all R+recognizable functions are in 8 I
+
+
+
From Theorem 6.1 and Corollary 5.4 we deduce: COROLLARY 6.2. Let f be an R+recognizable function with f(0)= 0 and f # 0. Then p f , < ef and conclusions (i)(iii) of Proposition 5.3 hold with r = pf, I EXAMPLE 6.1.
Consider the function
c (cos2nt3)zn m
f(x)
=
n=O
with 0 i t3 < 2n. Clearly
er = 1. We
assert that:
(6.1) j is rational and its poles are 1, eZio,eczi0. Indeed we have cos no and therefore ~
Consequently
0
=
nfJ ~ =2 a
B(ein0
$in0
+ eino)
+ $ e2in0

4
217
6. R+Recognizable Functions
This proves (6.1). From Berstel’s Theorem it now follows that (6.2)
If eiO is not a root of unity, then f is not R+recognizable.
Next consider integers
O t a t c and define 8 by the conditions cos 0
=
0 < 8 in/2
a/c,
Since cos nU is a polynomial of degree n in cos 8, it follows that cn cos n8 is an integer and thus c“’ cosa nU E N This yields:
Next we prove: (6.4)
If c # 2a, then eiO is not a root of unity, or equivalently e/z is irrational.
Thus eiOsatisfies the equation a c
=
1 2
(z +1 )z
or equivalently 2 2
2a z C
+l=O
Consequently the degree of the field Q(eio) over the field of rational numbers is at most 2. On the other hand it is known that for a primitive
VIII. An Excursion into Analysis
218
nth root of unity the degree is p?(n) where
p?
is the Euler function defined
by
d n m ) = p?(n)gs(m)
n and m are relatively prime
if
dp')= (P  l)Prl
if p is a prime
T h e condition p ( n ) 5 2 thus yields n = 1 , 2, 3,4, or 6. These possibilities are however ruled out by the assumptions 0 < 0 < n/2, cos 0 rational, and cos 0 # 6 . Summing u p we see that if c f 2a, then the power series h ( z ) has coefficients in N , is a rational function, but is not R+recognizable.
PROPOSITION 6.3. Let f ( z ) = C a,,z" be a rational function with coeficients a , in R (or Q or Z ) . Then
f
= f t
f
where f and f  are R,recognizable (or 8,recognizable or Nrecognizable). Further, either sup(ef+ Q J = ~ er or Qf, =
Proof.
and g
==
= er
e,_
T h e conclusion is clear if f is a polynomial. Also i f f g ,  g, then
fg
=
( f + g ++ f  g  )

= f+  f
(fg, +ftg)
Since f = p / q with p and q polynomials and q(0) = 1 it suffices to consider f = l / q with q(0) = 1. Let then
q=lqfq, where q+ and q  are polynomials with positive coefficients and such that q + ( 0 )= 0 = q  ( O ) . Then with q+ y = 1  qwe have r ( 0 ) = 0 and the identity
1 q
1 1 lqq_lrr"
1 r 1qq1r2
yields the required decomposition o f f = l / q . T h e assertion concerning the radii of convergence is clear
I
7. Behavior
21 9
of Coefficients
EXERCISE 6.1.
Let f be an R ,recognizable fiinction such that eS < 00.
Show that
I(.)
1
(p?

z')'h(=)
for suitable integers k 2 1, 12 1, and a rational function h such that 0. p h > pf and h(Q,) EXERCISE 6.2. Let f be an Nrecognizable function such that p, = 1.
Show that
f(~) = (1  =')'h(Z) for suitable integers k 2 1, 1 2 1, and a polynomial h with integer coefficients. 7. Behavior of Coefficients
Let
be an R+recognizable function. We shall establish some properties of the sequence a,, a,, . . . , a,,, . . . of the coefficients off. PROPOSITION 7.1.
There exist integers k and p and a real number
> 0 such that p > 0 and attip 2
V I >
for all n 2 k. If further f is Nrecognizable, the conclusion holds with 71 =
1.
Proof. Without loss of generality we may assume that a, = 0. Therefore by Proposition VI,6.4,f is computed by a R+aautomaton N'= (Q, i, t ) , where i and t are singletons. Let no be the number of states in d. Let c: i t be a successful path in d o f length 1) c 1) = n 2 n o . Then a state in c must be repeated so that c admits a factorization +
.
c,
1qqt
d
ca
VIII. An Excursion into Analysis
220
with 11 d 11 = 1 > 0. We choose this factorization so that I is the smallest possible, and then we choose it so that /I c1 11 also is the smallest possible. Then 0 < 1 5 no. Let p be the least common multiple of all the numbers 1 that arise in this fashion when c ranges through all the successful paths in & + w i t h11 c 1) 2 n o . Clearlyp 5 n o ! . With the path c thus decomposed we may associate the path e = cld'+P/lc,. Then e is a successful path and
If
where 11 is the smallest of the finite set of numbers u1+P/I involved. Next we observe that the function which to c assigns e is injective. Thus summing (7.1) over all the successful paths c in A of length n we obtain CPIPA2 V ( O " A ) and consequently an+p 2 Tall I f f is Nrecognizable, then A may be taken to be a Noautomaton. Then u are integers and thus q 2 1 I (Limit Theorem). If pf 2 1, then there exists an 2 1 such that the limits
THEOREM 7.2.
integer
p
ri = lim n+cu
exist for 0 5 i < p . Further, if F is a suhjield of R such that a,, E F n R , for all n then ri E F for all 0 5 i < p.
E
N,
7. Behavior of
221
Coefficients
T h e proof is inductive. We denote by '@' the class of all R+recognizable functions with a,, E F n R , such that either p, < 1 or else the limits y i exist for some integer p 2 1. Clearly f E 8 i f f is a polynomial. Next assume that Proof.
are nonzero and are in We propose to show that f ' $ f " and f 'f" are in 8. Since by Proposition 5.5 .@ I'
ca ,+,,
=
inf(e,. , eft,) =
pfjJ,s
we may assume Q,, 2 1 and pr., 2 1. Therefore integers p' 2 1 and p" 2 0 exist such that the limits ri' = lim a i L p , + i , rj" = lim
exist for 0 5 i < p ' , 0 5 j < p". Replacing p' and p" by their least common multiple we may assume that p' = p" = p. Since ri'
it follows that f '
+f
"
+ r;' = lim(a;p.+i + u ; ; ~ + ~ )
E
@'.Next setting
we easily calculate lim b n p f i=
1
Y~~Y;!,
n +w
the summation extending over all pairs (i', i") such that
0 5 i' < p, Thus f 'f" E '8. Finally assume that f
0 5 i" < p,
E
(@ and f(0)
i' =
c
+ i"
= i modp
0. Consider
m
f + ( z )=
c,zn
n=O
If pr+ < 1, then f + E & by the definition of 8'.If pf+ > 1, then and thus lim c,, = 0 so that again f +E g.If pf+ = 1, then by Corollary 5.4, p, > 1 and
C c, < 00
lim c n p 11 +cu
=P/f'(l>
VIII. An Excursion into Analysis
222
where p is the period of f. Since p also is the period o f f + it follows that C n p t i = 0 for 0 < i < p. Thus the required limits exist for f +. Further since a,, E F n R , for all n E N , the same holds for c,, . T h e functionf is, by Proposition 3.3 and Theorem 3.1, rational over the field F. Thus the same holds for the derivative f ' and consequently f ' ( 1 ) E F. Thus f + E @
I
EXERCISE 7.1.
Show that ;f Oln is irrational and a,, = cZlrcos2 nO,
then antp lim inf 0
a11
n+m
for all integers p > 1. Thus the function h of Example 6.1 violates the conclusion of Proposition 7.1. EXERCISE 7.2. =
1/[1  f ( z ) ]
=
EXERCISE 7.3.
Let f = C a,z", a , E R,, a,, = 0 and let f " ( z ) 2 c,,zn. Show that cntm2 c,,c,,~. Using Exercise 7.2 give an inductive proof of Proposi
tion 7.1. EXERCISE 7.4.
Show that the function
is Q+ recognizable zfs the function m
g(z)=f(pz)
=
C anpnzw n=O
is Nrecognizable for some integer p > 0. [Hint: Consider the automaton p L d where ,dis a Q+aautomaton recognizing f . ] EXERCISE 7.5.
Let f(z)= Crzoa,,z" be R+recognizable. Show that
the set
B
=
{n I a,, = O }
is a recognizable subset of N. [Hint: Consider the support A t of the R+subset A of 0" given by f. Note that this exercise is a special case of the SkolemMahlerLech Theorem.]
223
8. Bernoulli Distributions
This concludes our discussion of the Krecognizable subsets of cr* and of the related function theory. We list a number of open problems that deserve consideration. PROBLEM 7.1. Let f = p / q be a rational function where p and q are explicitly given polynomials with real coefficients and q(0) f 0. Is there an egective procedure for deciding when :
(a) (b) (c) (d)
f f f f
is positive? is R,recognizable? is Q+recognizable? is Nrecognizable?
PROBLEM 7.2.
Let f ( z )=
x;P=oa,$’
be a power series with coefficients
in R L . (a)
Iff is R,recognizable and the coeficients are in Q+, is f Q+recognizable ?
(b) Iff is Q,recognizable and the coefficients are in N , is f Nrecognizable ?
8. Bernoulli Distributions
Let 2 be an alphabet with k letters. A Bernoulli distribution is a function
such that crn > 0
for
c r L’ ~
co7c=1 acl’
T h e function
7z
is extended to a morphism
inductively by the formulas In = 1,
(so)n = (sn)(an)
VIII. An Excursion into Analysis
224
Given any R+subset A of Z* we define
c
m
eA radius Note that frequently J A
=
of convergence of 00.
a,, =
J
fat
However ~n
n A < 00.
If A is unambiguous, then
~ ,  S Z ' "J Z~~A= I< In particular,
1
fE*=
l + z + X 2 + . . G 
J
Z"=
oo,
&*=
1
T h e Bernoulli distribution n is assumed to be fixed. It plays an auxiliary role and is not displayed in the notation. An important special case is the unzyorm distribution ~ n l=/ k where k = card Z. T h e assumption that n is positive (i.e., that un > 0 for all u E 2) is convenient and harmless. If we allow mz 2 0, then setting
r = { o ~ u E ~c,n > o ) B = A ~ P we find that fA4 = fs and J A = J B . Thus there is no loss in assuming that n is positive. PROPOSITION 8.1. Proof.
If A is an unambiguous subset of Z", then pit L 1 .
This follows from the inequality p.,z 2 pz*
=
1
I
8. Bernoulli Distributions
225
PROPOSITION 8.2. If A is an R+recognizable subset of Z*, then f.l is R,.recognizable. More generally $ A is Krecognizable, where K is a subsemiring of R , , then f.l is K[n] recognizable, where K[n] is the subsemiring of R , generated by K and the numbers on for c E 2.
Proof, Let ,d be a K2automaton recognizing A . Consider the alphabet consisting of a single letter t. Let be the K[n]tautomaton obtained from LY’ by replacing all the edges
p%q by a single edge
Then
( P ) B = C (sA)(sn)= a,, h€2”
and thus f A l
=f
B . Consequently
PROPOSITION 8.3.
f.4
is K[n]recognizable
I
If p., > 1, then
If A is R,recognizable and J A < 00, then
> 1.
Proof, ’The first assertion is clear since f ( 1) = Czp=, Assume that A is R+recognizable and that J A < 00. Since Cz=P=oa,l < 00 it follows 2 1. If, however, ear= 1, then by Theorem 6.1, 1 is a pole for f, that contradicting 2 a,, < 00. Thus Q , ~> 1 I
As an application we prove a curious property of krecognizable sets. Let A be a subset of N . For each n > 0 we define
1 i 1, then since ftl(l)= 1 it follows from Proposition 5.3 that = 1. If e n = 1, then Q.,~ 5 O R = 1. Since M is = 1. unambiguous it follows from Proposition 8.1 that If ew = 1, then M is dense by Theorem 9.3. Assume now that B is recognizable and that M is dense. Since M = B" is recognizable and unainbiguous it follows from Theorem 9.3 that P.lr = 1. Then 1 = < pIi andf,,(l) =fIj(p.lf) = 1 by Proposition 5.3. Thus J B = f n ( l ) = 1 I
s
Examples 9.2 and 9.3 that follow show that all the inverse implications fail if thc assumption of recognizability is dropped. EXAMPLE 9.2.
Consider the set
A
I
= { T ' ~ ' u ss E
Z+}
VIII. An Excursion into Analysis
232
with 2 = { a , T } . Clearly A is a prefix and A is dense; in fact, 2"'A = Z". T h e generating function of A is M
where q = tn, p vergence is
=
on = 1

q with 0 < q < 1 . T h e radius of con
@a =
q1'2
>1
Thus the assumption of recognizability in Theorem 9.3 is essential. We also have fA(1) =  q) = 4 < 1 and therefore @A*
>1
Now consider the set
B
=
A  2+A
Both B and Be are prefixes. Further B is dense; indeed, if s E Z+, then t2181a~tlXI E B. Let M be the (nonrecognizable) unitary monoid B". Then M also is dense. However, B is not a maximal base since B f A. Further ear 2 @.I* > 1 This shows that the implications
B is a maximal base
of Theorem 9.4 fail if B is not recognizable.
EXAMPLE 9.3. Consider the nonrecognizable submonoid of 2" = {a, T}" given by m
M= Uanutn fl=O
Thus M consists of all words in 2" which have the same number of as T ' S . Clearly M is a unitary monoid and m
(J'S
233
9. Prefixes and Bases
where (n,n) is the binomial coefficient ( 2 n ) ! / n ! i z ! and , q = 1 q, 0 < q 1. A calculation shows that ~
=
m, p
=
an
6 :
f.&)
=
1/ 2/ 1  4PP2
Let B be the base of M . Since
it follows that
and therefore
f&)
=
1  2/ 1  4pqz2
=
en
This implies
1 / 2 62 1
with equality holding only if p = q. Next observe that h i' is the kernel of the surjective morphism L'" 4 2 such that B 4 1, z 4 1. Thus, by Example IV,5.2, B is a maximal base. Taking q f 4 we find that the implication
J
B
=
1 2 B is a maximal base
does not hold in the absence of recognizability. Next define = B'" B' = B n tz:", Since B' is a prefix, M ' is a (nonrecognizable) unitary monoid. T h u s M ' is free. W e have f w = Pfil and therefore
1
VIII. An Excursion into Analysis
234 Thus
Since B’ is a proper subset of B we have
jB’ < jB = 141 4pq 
T h u s for
p
=q =
we have
negating the implication nizability.
ens= 1

JB
=
1 in the absence of recog
EXERCISE 9.1. Let {ariI n > 0 } be a sequence of elements of N , and let Z be an alphabet with k letters. Show that the following conditions are equivalent ;
(i) (ii)
m Cn=, a,,/k”I 1.
There exists a prejix A in L’” with
as generating function, relative to the unqorm distribution on S. (iii) There exists a prejix A in .Psuch that
a,,
=
card(A n Pi)
EXERCISE 9.2. Let P be a prejix in 2” such that
c = /y”

pz+
Show that ec
1fp(Z)
If, further, el. > 1 , then
= @I>
=
(1  .)fc(.)
sP
=
1. Dejine
235
References
Let ‘4 nnd B be unand~igi~oirs secogniznble siihsets of P . = i ?,then .4 u R is dense iff either il or B is dense. Show that f A B is unambiguous, then AH is dense iff either A or B is dense. EXERCISE 9.3.
Show that if A n B
EXERCISE 9.4.
Show that
if
B is
n
recognizable base in I* then B ,
is not dense, References C. I,ech, A note on recurring series, Ark. Mot. 2 (1953), 4 1 7 4 2 1 .
Contains Theorem 3.4, Example 3.1 and references to earlier work by Skolem and Mahler. J. 13erste1, S u r les poles et le quotient de Hadamard de series Nrationelles, C.R. Acad. Sci. Paris 272 (1971), 10791081.
Contains ‘l’heorem 6.1. W. Faller, “An Introduction to Probability Theory and its Applications,” Vol. I, 3rd Ed., Wiley, New York, 1967.
Chapter XI11 is relevant to the topics discussed here. I n particular the Tauberian Theorem mentioned after Corollary 5.4 is proved on pp. 335338. A. Cobham, Uniform tag sequences, Math. Systems Theory 6 (1972), 164192.
Theorem 8.4 is stated on p. 180. R. A. Sittlcr, Systems analysis of discrete Markov processes, I R E Trans. Circuit Theory CT3 (1956), 257266.
Contains an elementary discussion of matters related to Sections 8 and 9 as viewed by an electrical engineer. M. 0. Kabin helped with Example 6.1. Proposition 6.3 is by Schutzenberger (unpublished). T h e same applies to Theorem 9.3. Theorem 9.4 and the examples that follow were obtained by Schutzenberger and the author (unpublished).
CHAPTER
Ix Rational Relations
In Chapter VII we studied rational sets in an arbitrary monoid, but the main results were confined to finitely generated free monoids. In this chapter we consider rational relations f:S + S‘, i.e., relations whose graphs are rational subsets of the product monoid SXS‘. Since this product is not free (unless S = 1 or S’ = l), most of the results of Chapter VII (in particular, Kleene’s Theorem) do not apply and new methods must be developed. Rational relations form one of the cornerstones of the structure of the theory. 1. Definitions and Examples
Let S, and S , be monoids. A relation f:S , + S , is called rational if the graph #f is a rational subset of the product monoid S , x S,. We must specify what kind of subsets and relations are being considered. In principle, the definition can be made for Ksubsets and Krelations where K is any complete semiring. Actually we shall be interested only in the cases K = ~3’ or K = JF. By considering ,Ksubsets and Xrelations that are nonsingular, we obtain indirectly a way of treating Nsubsets and Nrelations. It follows from Corollary VII,2.2 that for each rational .%‘relation f: S , + S,, there exists a rational Xrelation g: S, S , such that gt = f.This observation allows us to derive results for .2relations from those for Xrelations. In all the interesting cases S , and S , will be either free monoids or finite direct products of free monoids. Thus, in practice, 236
1. Definitions and Examples
237
S , , S,, and S , x S , will always be locally finite, in the sense of VII,4. In this case the relation g above may be chosen to be an Xrelation or equivalently a nonsingular Nrelation. As a result of the above discussion, we can restrict our attention to Xrelations and when appropriate make statements about nonsingular ,Frelations. They will then automatically also apply to 8relations. Our notation will thus be geared to the case K = X I
PROPOSITION 1.I.If f: S , + S , is a rational relation, then so is the
relation f': S ,
f
S1 '
Proof, T h e set #( f  l ) c S,X S , is obtained from the rational set c S , x S , by the isomorphism h : S , x S , + S , x S , given by (s, , s,)h
#f =
(s,,
s,).
Thus #( f')is rational
I
PROPOSITION 1.2. If A i is a rational subset of Si ( i = 1, Z), then A , x A , is a rational subset of S , x S , and the relation f:S , + S , defmed by
is rational.
Proof. Since A , x A , = ( A , x 1)(1 x A,) it suffices to show that A , x 1 is rational. This, however, is the image of A , under the morphism S , + S , x S , given by s1 + (s,, 1). T h e relation f is rational since its graph is A , x A , I PROPOSITION 1.3.
Let 5' be a jinite alphabet and S a monoid. If
f: .Z* + S is a rational substitution, then f is a rational relation. Proof. For each CT E Z, of is a rational subset of S and therefore by Proposition 1.2 the subsets
of Z * X S are rational. Since
it follows that f is rational
I
IX. Rational Relations
238
Every morphism f : L'*
COROLLARY 1.4.
+ S
is rational
1
PROPOSITION 1.5. For any subset A of S the relation ( ) A : S + S dejined by X ( n A ) = X n A is rational if and only if A is a rational subset of S.
Let A : S 4 S X S be the diagonal morphism s/l = (s, s). T h e graph of the relation n A is then the set An. Thus if A is rational, so is All by Corollary V,2.3, and thus n A is a rational relation. Since A is the image of Ail by either of the two projections S X S + S, it follows that if n A is rational, so is A I Proof,
I f f l ,f 2 : S , uf2.
PROPOSITION 1.6.
the relation f Indeed #f
=f
=
+ S'
are rational relations, then so is
I
#fi u # f 2
PROPOSITION 1.7. I f f , : S , 4S1', f , : S , 4 S,' are rational relations, then so is the relation
f
=f , x f , :
s,xs,~s,'xs,'
dejined by (s1
9
szlf
= (Slf,
1x ( S J  2 )
Proof, The graph # f is a subset of S , x S, x S,' x S,' and is obtained from the subset #fl x # f 2 of S , x S,' x S , x S,' by an interchange of the middle coordinates. Since # f l x # f , is rational by Proposition 1.2, it follows that # f is rational I PROPOSITION 1.8. I f 2 is a jinite alphabet, then the function
f: C"XZ"+Z" given by multiplication (or concatenation) (s, t ) f
=
st
is rational. Indeed #f
= ((0,
1, u)}*{(l,
t,t)}"
where
u,
tE
Z
I
1. Definitions and Examples
239
PROPOSITION 1.9. If E is a finite alphabet and A is a rational subset of
La,then the relation f : E"
+
~
sf
1"given by
=
AS c Z"
is rational. Indeed
#f (1 xA){(a, (r) 1
fJ
E
El*
I
EXERCISE 1.1. Let f : Ela*+ E2* be a relation and let t be a letter not in .Zl nor in S,. Dejine Z1= Sl u T , 2, = L', u t, and consider the relation
j :T1* &* f
dejined for s
with so, . . . , s,
E
= SOTS1
9
. . S,p,TS,2
Zl * by
Show that i f f is rational, then f is rational. EXERCISE 1.2.
relations Z*
+ E*
Show that for every Jinite alphabet L' the following are rational
s(1Seg) = { u I s
E
UP}
1 s E S*u} s(Seg) = { u I s E Sr+uEr+} s(SWd) = { u I u is a subword
s(TSeg)
= {u
of s}
The last relation may be defined inductively as follows 1(SWd) = 1 (as)(SWd) = (1 u o)[s(SWd)]
Thus if s
=
(r,
. . . crl,, then s(SWd)
(1 u a,) . . . (1 u a,)
Show that SWd is a rational substitution.
IX. Rational Relations
240 2. First Factorization Theorem
T h e following purely “set theoretic” lemma is useful. LEMMA 2.1. Let
f: X+Y,xY,,
fi: X+Yi,
i= 1,2
be relations such that
xf = (Xf1)X (xf2) for all x
E
X. Let A be a subset
of X and let g be the relation
fi’ nA Y,XXY,
j8
Then #g Proof.
Let Y
=
Af
Y,xY,. Consider the projections
=
ni: Y
f
Yi, i = 1, 2
Since fi= fni the composition g is
 xx
Y,
ni 1
Y
nd
fl
f
Y 2Y,
By Corollary VI,4.3, this composition is
Y,
with B
=
nil
Y
ns
Y””. Y,
Aj. T h e graph of this relation is B as is clearly seen by taking B
to be a singleton
I
THEOREM 2.2. (First Factorization Theorem) A relation f:S , +S, is rational if and only i f f admits a factorization (2.1 1
s, q’ z* d
.z* nA
n
2s,
where S is a jinite alphabet, gj:L’++ Siare morphisms (i = 1, 2 ) , and A is a rational subset of Z* I COROLLARY 2.3. If riis a generating subset f o r Si(i = 1, 2), then gl and g , may be chosen so that .zgi c 1 u ri for i = 1, 2. I n particular, if Siis free, then g i may be chosen to be fine
I
2. First Factorization Theorem
241
The set A may be chosen to be an unambiguous local
COROLLARY 2.4. subset of Z+.
Proof. Assume first that f is the composition (2.1). Then by Lemma 2.1 we have #f = Ag whereg: 1"4 S , Y S, is defined by sg = (sg, , sg,). Since A is rational, so is Ag and thus f is a rational relation. Conversely, assume that f is a rational relation, i.e., #f is a rational subset of S , x S,. Let I', (i = 1, 2 ) be generating subsets for Si.Then
r
(1 u r 1 ) x ( iu
r,)
is a generating subset for S , x S,. Ry Proposition VII,9.4, there exists a finite alphabet S, a morphism g : 2" + S , x S,, and a local subset A of Z +such that Zg c r, A g = #f Defineg,: S' + S , (i = 1, 2) so that sg = (sg,, sg2). Then Zg, c 1 and f is the composition (2.1) by Lemma 2.1 I
u I',
There is a variant of Theorem 2.2 valid if S , and S , are free monoids. Consider two disjoint alphabets Zl and S, and define the canonical projections x i : (2,u Z,)* + ZiX, i = 1, 2 by setting for
0,
E
X,,6, E Z2 O17cL = fJ,,
1,
61n2 =
fJ2n1 = 1 6,7c2= 62
Then define the canonical morphism 32:
( 2 ,u &)*
4
Zl"XZ,*
so that
sn
=
(sn, , sn,)
Thus c7,n
= (c7,
, l),
(T,n
=
(1, ),.
THEOREM 2.5. Let Z,and Z,be disjoint alphabets. A relation Z,* + Z2*is rational (f and only (f f admits a factorization
2,"
n;'
(XI
nA u Z2)*+ (1, u Z,)" 5 Z,"
where A is a rational subset of (Z1u Z,)*.
f:
242
IX. Rational Relations
Assume that f has the form above. Then by Lemma 2.1 we have #f= An. Since A is rational and n is a morphism it follows that #f is rational. Conversely assume that #f is a rational subset of 2," x Zi*since n is a surjective morphism, Proposition VII,2.4 implies the existence of a rational subset A of (C1u Xz)*such that #f = An. T h u s by Lemma 2.1, f factors as above I Proof.
COROLLARY 2.6. I n Theorem 2.5, the relation f is nonsingular if and only (f the subset A of (El v Xi)*is nonsingular. Indeed, for each (s, t ) E XIax Z2"the set ( s , t)n' is finite. This readily implies that #f = An is nonsingular if and only if A is I EXERCISE 2.1. Show that every rational relation f:S,"+ S,"is the is a nonsingular rational relation union f = f i u fi where f i : 2," + 1," while fi:S,",Zz" is a purely singular rational relation (i.e., #f, is a purely singular rational set). [Hint: Use Proposition VII,9.2.] EXERCISE 2.2. Let A be a rational 0 such that if
If k > 1, then upon calculation we find
where
Similarly if 1 > 1, then ( U ~ W , ~ V ,= ) ~ a,
+ bSc2P
T h u s if k > 1 and 1 > 1, we must have
(9.1)
(al
+ b , ~ , p ==) ~ a2 + bZc2P
for all p
20
263
9. Iteration
+ I wz I
Since cI = klu'll, c, = I 1 u ' z l , and 0 < 1 w1 I cI = c2 = 1. T h u s (9.1) implies that either (9.2)
b,
=
b, = 0
we cannot have
aL2= a,
and
or
b12 = 6, f 0
(9.3) If b,
=
c l P= c2 f 0
and
0, then ( w , ) = ~ (v,)
I u, I 5 n this would imply
= 0 so that ( s ) = ~ ( u , ) , and since (s)~ < k". This is a contradiction since the
pair (s, t ) may be chosen with (s)~ arbitrarily large. If (9.3) holds, then (9.1) becomes a12 2a,b1c,p = a2 and since 6, # 0, c, # 0, 1, this can take place only if a , = a, = 0. If a, 0, then (ul) kl'll(wI) = k ( u , ) or equivalently ( U ~ W = (Ou,),. This is possible only if ulwl E 0". Similarly a2 = 0 implies uzw2E 0". Since 0 < I u , I I w , I 1 uz I I wz I it follows that either s or t (or both) must begin with a zero. T h u s either (s), is divisible by K or ( t ) l is divisible by 1. However, the pair (s, t ) may be chosen so that this is not the case. If k > 1 and l = 1, then (u2w2*v2)= I u2 1 p I w z 1 1 v z 1 and (9.1) is replaced by
+
+
+
+
+
+
(a,
+
b,Clp)3 =
I u2 I
+P I w, I + I
+
W,
I
Since c1 = k'u'll and 0 < I w , I + 1 wz I this is possible only if b, T h u s as before we have a contradiction. If k = 1 and 1 > 1, then (9.1) becomes
(I
UI
I
+ P I w1 I + I
Ul
I),
=
a2
=
0.
+ b&zP
and this is possible only if b, = 0. T h u s we obtain a contradiction as above. If K = l = 1, (9.1) becomes ( I . l r + P I ~ l I + I ~ 1 1 ) 2 = I ~ 2 1 + P I W 2 1 + I ~ z I
and this is impossible since 0 I: w 1I
+ I w, I I
We shall usc the same method to prove: PROPOSITION 9.3.
A rational relation
f: k*
j
1"
~ ) ~
IX. Rational Relations
264
for k 2 1, 12 1 such that the composition
and o n b if
is the identity exists
for some integers x > 0, y > 0. In particular, i f k vice versa.
=
1, then 1 = 1 and
Proof. T h e proof proceeds exactly as in the previous proposition except that (9.1) is replaced (in the case k > 1, 1 > 1) by
(9.1')
a,
+ blclP = a , + b2c,7'
for all p 2 0
with c1 = c2 = 1 excluded. This implies either b, = 0 or b, = 0 or c1 = c,. As before b, = 0 or b, = 0 lead to contradictions while c1 = c, gives klqoll= Z I W a l as required. If k > 1 and 1 = 1, then (9.1') becomes 01
+
blClP
=
I u2 I
+P I
WE
I
+I
%I
+
which gives a contradiction since c1 = kl"ll' and 0 I w , I 1 w , 1. T h e case k = 1, 1 > 1 is handled symmetrically. Suppose now that kz = l g for some integer x > 0, y > 0. Let m = Kz = lv. Consider the morphisms :
1 the function vk@: k"
f
N is not ra
tional. Proof,
Indeed, assume that vk is rational. Let f be the composition VK@
"81
k"NLl"
References
265
Then f is rational and the composition v f  y v , ~ is the identity. This contradicts Proposition 9.3 I EXERCISE 9.1. Let C be an Nsubset of S*. Show that f C regarded as a function C : Z*+ N is rational, then C is a rational Nsubset of Z*. Show that the converse is not true by taking Zto be a single letter alphabet and setting 0°C = n2. EXERCISE 9.2. Show that i f f : L’* P is a rational relation then so is the relation fe: L‘* + P dejined as the composition f
5p
~31:
L,
p 5p
Deduce that the conclusion of Propositions 9.29.4 remain valid with the reversed interpretation ve replaced by the standard one v. References C. C. Elgot and G. Mezei, On relations defined by generalized finite automata, IBM J . Res. Deuelop. 9 (1965), 4765.
This paper introduces rational relations (called “transductions” by the authors) and proves most of their properties. T h e paper is rather hard to read and this is perhaps why it received much less attention than it deserves. M. Nivat, Transductions des languages de Chomsky, Ann. Inst. Fourier (Grenoble) 18 (1968), 339455.
This paper reproves some of the results of ElgotMezei and continues with applications to algebraic sets (i.e. context free languages) that will be treated in Volume C. Theorem 6.1 can be deduced from the results of ElgotMezei. T h e proof given here was found by the author jointly with M. P. Schutzenberger (unpublished). Theorem 7.1 appears to be new.
CHAPTER
x Machines
T h e notion of a “machine” as presented here is closely related to that of an automaton. T h e “type” of a machine is the class of relations (usually partial functions) that constitute the elementary operations or moves that the machine is capable of performing. A variety of such types is considered. Many more types will be considered in Volumes C and D to describe progressively richer families of sets, functions, and relations. 1. Basic Definitions
I,et S be an arbitrary set and let @ be a family of relations y : A’ + X. An Xmarhine .&of type @ is simply a @automaton (Q, I , T ) . Here @ is viewed as an abstract alphabet. Since @ may be infinite, we must remember that, in accordance with the remark made at the end of VII,5, a @automaton is a @,automaton for some finite subset of @. This ensures that .Ahas a finite number of edges, despite the infinite number of available labels. T h e distinction between an automaton and a machine lies in the definition of the behavior. This shows up first when we define the label of a path. Let r:
PI
40
ql.
c”2
P’n d
4 1 1
be a path in A of length n 2 1. While in an automaton the label I c 1 of c is the “formal product” or “word” q, . . . p,! treated as element of the free monoid @* with base @, in a machine the label 1 c 1 is the composi
266
1. Basic Definitions
267
tion cy, . . . cy,, viewed as a relation
X +X .
Thus
Consistent with this, the trivial path 1,: q + q of length zero, will have as its label the identity transformation 1,: X + X. T h e behavior of /G is the relation 1 . A q :
xx
defined as
Id1=
u
I C I
with the union extending over all the successful paths c in .A’. I n addition to X and @ two other sets Y and Z and relations
called the input code and the output code will be given. T h e composite relation
will be called the relation computed by A‘ (using the given input and output codes (I and w ) . Before proceeding any further with more definitions, we shall describe a general class of esamples which are quitc typical for what will actually take place later. We let Y = P, Z = P,where .Y (input alphabet) and (output alphabet) are finite alphabets. T h u s relations f: L’*+ will be computed. T h e set X w i l l have the form
r
r*
where M is a monoid referred to usually as “storage” or “memory.” I n practice M will usually be a product R,* x . , . x Rr* where Q, , . . . , Qt. are finite alphabets; in this case we shall say that A has r 2 registers of which one (the last one) is the input register, one (the first one) is the output register, and the intermediate Y registers are memory registers. T h e input and output codes
+
X. Machines
268
may be defined by SIT
(g,m,s)w
=
=
(1, 1, s) if m = l , otherwise
{$
s=l
With X , Y , 2, 01 and o fixed, the class of relations Y + 2 computed by (1.1 ) will depend upon the type @ and may be denoted by Comp( a). In general, the larger @, is the larger Comp(@). Given two such types @, CD', we shall write @I
’f’,* with Y, and I’, finite subsets of L’ a n d I’, respectively. ~
I
EXERCISE 3.1. In the situation of Theorem 3.2, show that the inverse relation f I : ‘I‘+ S is conipiited hy tfie S < Ttransducer N  I obtainedfrom // by reziersing the direction of all the edges, repliring all labels R , Y L;’ by R, x L;I, mid interchanging the roles of the initial and terminal sets.
X. Machines
276 4. Accelerated Transducers THEOREM 4.1.
For any relation f : Z"
+
r" the following properties
are equivalent : (i) f is rational and lengthpreserving. (ii) f is computed by a F" x 2:"transducer A! of type
RYXLi1, I X I y € r , f J € Z Further f is nonsingular if and only if
may be chosen of type

Proof, (i) (ii). Let A = #f be the graph off. Since f is lengthpreserving A may be viewed as a subset of the submonoid ( Z X ~ )of" Z " x r " . By Theorem IX,6.1, since A is a rational subset of Z * X P it is also a rational subset of ( C x r ) " . Thus by Corollary VII,10.4, A is the behavior of a generalized ( Z ~ r ) "  a u t o m a t o n d with labels in Z x T u (1, 1). Thus the replacement procedure yields the transducer d of type (4.1). If, further, f is nonsingular, then A is a nonsingular Then the automaton d can be chosen and rational subset of (L'xT)*. with labels in Z x I' and thus &will be of type (4.2). (ii) 2 (i). That f is rational follows from Theorem 3.2. If c is a successful path in A,then its label must have the form I c 1 = R,x L;' with 1 g I = I s I. Thus the relation a I c I w is lengthpreserving. Consequently f = a I dl w also is lengthpreserving. If, further, has no unit edges, then we also have I/ c I/ = I g 1 = I s I. Consequently, for a given pair ( g , s), there is only a finite number of successful paths with label t , x L;l. Thus f is nonsingular
A transducer A! of type (4.2) is called accelerated because the length of any successful path computing sf is of length I s I. One also uses the phrase that A?' "operates in real time." For the next type of transducer we need thexrelation
R,: defined for any 4'subset
r*+r*
D of F* by setting gRD
=g D
4. Accelerated Transducers
277
THEOREM 4.2. For any relation f: L'" ru; satisjying If some k E N the following properties are equiualent : f
=
k1 f o r
(i) f is rational. (ii) f is computed by a I'" x 2"transducer A? of type
(4.3) Further f is nonsingular ;f and only ;f P can be chosen so that all the sets D occuring in its labels are nonsingular.
Proof. (i) a (ii). Without loss we may assume that If f admits a factorization Theorem IX,5.1,
=
0.By
where 1 is a nonsingular lengthpreserving rational relation and h is a rational substitution, which may be chosen to be nonsingular i f f is nonsingular. By Theorem 4.1, 1 is computed by a Q* x Z"transducer A'of type R,x L;' with w E Q, G E Z. Replacing each label R,x L;' by R,,x L;' we obtain the desired P x Z*transducer Jfcomputing lh = f. (ii) (i). For each D occurring in a label of the transducer ..&choose a letter and let Q be the finite alphabet thus obtained. Let h : Q" + be the substitution wI,h = D. Let A?' be the Q* x Ptransducer obtained from ddby replacing each label Rr,x L;' by RUD x L;'. By Theorem 4.1, the transducer computes a nonsingular rational lengthpreserving relation 1: Z+4P . T h e equation lh =f is clear. Thusf is rational. If, further, the sets D are nonsingular, then h is nonsingular and so is f = lh, since sl is finite for every s E Z* I

r*
THEOREM 4.3. For any relation f: 2" + r* the following conditions are equivalent : (i)
f is rational, If = kl for some k E N and card(sf) < 00 f o r all s E Z".
(ii) f is computed by a
(4.4)
I'" x Ptransducer
R,X L;'
g
E
A? of type
r*, a E Z
278
X. Machines
(i) 3 (ii). By Theorem 4.2, f is computed by a Z'* x 9of type (4.3). Edges with labels R x L;' may be omitted transducer and A may be assumed to bc trim. Let c be a successful path in .Iof length n > 0. T h e label I c I of c has then the form K,,x L;' where D = D , . . . D,,are the sets occuring on the successive edges of c and s E L'", I s 1 = n. T h e n Proof.
s((x
1 c I tt))
D
Since card(sf) 00 it follows that D is finite, and thus the sets D,, . . . , are finite. Since 4 is trim, each edge appears in a successful path and thus all the sets D occurring in the labels of 4 are finite. Consider an edge y ,
P
RnxL,,'
4
and let I,
D
=
n , E N , g , E r*
2 n,gL, ,=1
'The edge may separate into k edges
P
n&,xLiL
4
We thus obtain a transducer of the required type but in which the edges may have finite multiplicity. T h e procedure of Theorem VI,9.1 can now be applied to obtain an unambiguous transducer. (ii) 3 (i). T h a t f is rational follows from Theorern 3.2. For each s E C* a successful path c with label R, x L;' must have length 1 s 1 and thus there can be only a finite number of such paths. T h u s sf is finite. Further, if s = 1, then necessarily g = 1 and thus If is an integer multiple of l I As an application of Theorem 4.2 we prove an iteration property for rational relations, that is somewhat different than that stated in Proposition IX,9.1. PROPOSITION 4.4. Let A be a rational .%'subset of Z* x exists then an integer n > 0 such that if
( s , g )E A ,
Is
I Ln
then s and g have factorizations s = U,WlVI,
g
=
u,w,v,
r*.There
5. Positive Rational Relations and Transducers
279
such that
f 1 ( z L , w , ~ vupwaPv2) ,, E A f o r all k 2 0 WI
Further w , can be chosen to be a subsegment of any segment of s of length n. In particular, I w , I 5 n. Proof. Let f : S" + T* be the rational relation with A as its graph. Without loss, we may assume that If = g.By Theorem 4.2, f is computed by a x Y"transducer A of type
r"
I
H,,x La1 D
E
Rat P ,
(T
E
2.
Let n be the number of states of A. I x t (s, g) E A , I s I 2 n and let s' be any segment of s of length n. Since g E sf there is a successful path c in A with label R,,x L;' and with g E D. T h e length of c is precisely I s I and further the segment s' of s determines a segment of c' of length n. It follows that c' must contain a loop. T h e rest of the argument is clear I
Given a finite alphabet L, define the augmented alphabet 2 = 1 v ci where 6 is a letter not in 1.Denote by ?I: 2% 2* the jine morphism given by rin = 1 and cin = (T for G E 2. Show that every rational relation f : Z* + P admits factorizations EXERCISE 4.1.
f
p h 5%
z* 2 n1
L+ p* >I'"
ri nl_ 2"
h
I'"
,,
111
I;"
p
where f ' , f " , f " ' are nonsingular rational relations and f " ' is lengthpreserving. [Hint: Use the new letters to eliminate undesirable labels from the transducer ~i of Theorem 3.2.1 5. Positive Rational Relations and Transducers THEOREM 5.1.
For any relation f : Ex +
r* the following
conditions
are equivalent : (i)
and If I is ajinite multiple f is rational, gf I isjinite for each g E P, of 1.
X. Machines
280 (ii)
f is computed by a
r*x Ptransducer R,XL;'
S E
of type
z*,g E r+
r*x Ptransducer
(iii) f is computed by a
R,XL;~
I
(iv) f is the composition
SEz*, y E r
sz*
z*+on. O R h1
(v)
of type
1
+
r*
where Sz is a j n i t e alphabet, R is a nonsingular rational subset of Sz", h : Q* + Z* is a morphism, and I: Sz* + l'* is a very$ne morphism. f is the composition
z+=sz*r* m
where m is a rational nonsingular lengthpreserving relation and h : 9" + Z* is a morphism. (vi) f is rational and nonsingular, and there exists an integer k > 0 such that g(sf ) > 0 implies I s 1 'klgl
Proof. (i) (ii). Condition (i) implies that f is nonsingular. Since f is rational and nonsingular it follows from Corollary 3.7 that f is computed by a transducer A' = (Q, I , T ) of type R, x I , I x Lzl. Since If is
a finite multiple of 1, we may assume without any loss of generality that If = @, i.e., that I n T = 0. By Proposition VI,6.3, the machine d may be normalized so that I = i, T = t , and no edges issue from t or enter i. Also superfluous states can be removed so that .I may be assumed to be trim. Let n be the number of states of .k.We assert:
(5.1)
Each path in R,x r.
A of length 2 n has at least one edge with label
Indeed, suppose that a path of length 2 n exists without labels R,x I. Since this path has repeated vertices, we obtain a path C
44 with label I x L;I,
s E
Zf. Since A? is trim this path may be completed
5. Positive Rational Relations and Transducers
281
to a successful path .
a
r
Zqqrt
b
Let the labels of a and b be R, x L;' and R,, x L;l. T h e successful paths ac'b, i 2 0 show that (gh)f' is infinite, contrary to (i). T h i s proves (5.1). Every successful path in & may be factored uniquely into
with c l , . . . , cp of length n and d of length 5 n. A transducer .&of the type required in (ii) is now constructed. T h e states, initial states and terminal states, of .&are the same as those of A? Let p and q be states and let g E T+,s E S", I g I I s I = n. I,et k be the number of paths
+
c: p + q
with labels I c
I
=
in ,I
R, x L;'. If k > 0, then we create the edge kR, x I.;'
pq
in
.d
If q
=
t is terminal, we have additional edges obtained by allowing
p
=
i and q = t , additional edges are obtained by allowing
If
I g l + I s 1 .=n

There results a transducer .,&of type (ii) (with multiple edges). I t is clear that I .XI = I k l. (ii) (iii). This follows from Corollary 1.2. (iii) (iv). For each label R, x L;' occurring in .A?introduce a letter w of a finite alphabet 0.Replacing the label R,x L;' by Q we obtain an 0automaton whose behavior is a nonsingular rational set R. Consider the morphisms
defined by wh = s, wl = y. T h e n the graph o f f is R(h, 1) and therefore (Lemma IX,2.l) f is the composition k ' ( n R ) l as required.
282
X. Machines

(iv) (v). I t suffices to define m = ( n R ) l . (v) = (vi). T o show that f is nonsingular, it suffices to show that g f I is finite for each g E l'*. Since gf  l = (gm')h it suffices to show that gm' is finite. This is clear since m is nonsingular and lengthpreserving. Next define k >: 0 so that I ruh I 5 k for each (I) E 9. T h e n 1 o ~ hI 5 k I OJ I for all (11 E 9. Since m is lengthpreserving the inequality required by (vi) follows. (vi) (i). Obvious I Relations satisfying conditions (i)(vi) of Theorem 5.1 will be called positive rational. Using condition (i), the following properties of positive rational relations are easily obtained. PROPOSITION 5.2. A morphism Z* 4 I'* where X i s a .finite alphabet, is a positive rational relation if and only if it is locally finite I
I*, where PROPOSITION 5.3. For each morphism h : 1'" jinite alphabet, 121 is a positive rational relation I f
r
is a
PROPOSITION 5.4. For each nonsingular rational subset R of Z* the 4 I * is positive rational I
relation OR: S*
PROPOSITION 5.5.
is positive rational
The composition of two positive rational relations
I

PROPOSITION 5.6. Zf f : S* T* is a positive rational relation, then for any nonsingular subset A of P,Af is a nonsingular subset of I'" I
6. Twoway Automata
T h e discussion is restricted to .%subsets (i.e., multiplicities are ignored). Let S be a finite alphabet. Define
6 . Twoway Automata
283
just as for 9x S+transducers. T h e type is
R;’~L,, I X I
R,,XL;~,
I aEz.
Observe that if c: p + q is a path in a machine either above, then for each (s, t ) E 3 x 1+ ($9
t)I c
I
=
of the type described
.3
or (s, t ) I c
I
=
with
(s’, t ’ )
st
=
s’t’
Such a machine will be called a twoway automaton. It is convenient to adopt the following phraseology. Call st the “input” and call the integer I s I the “position of the reading head,” i.e., the position of the comma. Then during a computation the input does not change but the reading head may move in either direction (or remain stationary). T h e definitions of u and r o show that a successful computation begins with the reading head in the leftmost position and ends with the reading head in the rightmost position. If c: i + t is a successful path, then the partial function u I c 1 t o : S*
+
z+
satisfies s(u
I c I).C
=
{&
if (1, s) I c 1 otherwise
= (s,
1)
Consequently the partial function
also satisfies s(u
I dd I
to) =
If A is the domain of A = {s I (1,
s)
if (1, s) I c otherwise
{
CI
1 = (s, 1) for
some c
I ,,,dto, l then
IcI
=
(s, 1 )
for some successful path c}
We then say that ‘4 is the set computed by the twoway automaton k. A successful path c such that (1, s) 1 c I = (s, 1) is called a computation for s. 4n ordinary 1automaton d =(Q, I , 7’)may be converted into a twoway automaton d by replacing each label cr by the label R,x L i l .
X. Machines
284
Thus in A?’the reading head moves only to the right. This justifies the term “twoway automaton” as opposed to “oneway automaton.” I t is clear that A? above computes the set 1 d I. The objective here is to prove the converse. Let A= (Q, I , T ) be a twoway automaton computing the set A c 2”.Then: T H E O R E M 6.1.
has cardinality 5 2m‘m+1), where (6.1) The family of sets {s+A I s E P } m = card Q.
(6.2) There exists an effective procedure which for each s E 2* decides whether s E: A or not. Combining this with Theorem III,8.3 we obtain: C O R O L L A R Y 6.2. The set A is recognizable and the minimal Zautomaton dAmay effectively be constructed. I t will have at most 2m(m+l) states I
We begin the proof with : LEMMA 6.3.
Every path e : i + t such that ( 1 , su) I e
I = (su, 1 ) admits
a decomposition
(6.31
e
=
a: i+pl,
d:
Pntl
+t,
ab,c,
. . . bnc,d (1,
s)
Ia I
= (s, 1)
( 1 , u ) I d I = (u, 1 )
Conversely for any product (6.3) satisfying (6.4) the equality ( 1 , su) I e = (SU,1 ) holds.
1
Proof. Let k = I s I. The proof is obtained by watching the position of the reading head and noting when it crosses k. Thus a is defined as the largest initial segment of e such that during the computation given by a the reading head remains in positions 5 k . Thus (s, u ) = (1, su) I a I, but since the reading head is always in a position 5 k , the word u plays no role in the computation and thus (s, 1) = ( I , s ) I a I. Let e = ae’. Then (s, u ) I e‘ I = (su, 1). Two possibilities may now take place. If the
6. Twoway Automata
285
reading head remains now in positions 2 k, then we set e' = d and have (1, u ) I d I = ( u , 1). If the reading head during the computation given k, then we denote by b, the largest by e' ever returns to a position initial segment of e' such that during the computation given by b, the reading head is in positions 2 k. Then (s, u ) I b, I = (s, u ) and (1, u ) 1 b, I = (1, u ) . T h e continuation of the argument is clear. T h e converse part of the lemma is obvious. We are now ready to establish the inequality
.:
For each s E
L'* define the relation sp: Q  Q
and the subset se
=Q
as
I = (1, s) for some path c : p q } { q I (1, s) I c I = (s, 1) for some path c: i + q with i E I }
p ( s p ) = { q I (1, s) I c sp
=
4
T h e total number of possible pairs (sp, sg) being 27n(m+1), formula (6.5) is proved if we show (6.6)
sp
=
t p and
se = tp
imply
srlA
=
t'A.
Indeed assume u E srlA, i.e., su E A. Let e : i + t be a successful path such that (1, su) I e 1 = (su, 1) and consider the decomposition of e as given in Lemma 6.3. Since sp = t p the path a : i + p l may be replaced by a path a': i' PI such that (1, t ) 1 a' 1 = ( t , 1). Since sq = tp for each of the paths c j : qj pj+, there exists a path c j r :qj + p j , such that ( t , 1) I cj' I = ( t , 1). Consequently the path e = a'blc,' . . . b,,c,'d satisfies the conditions of Lemma 6.3 with s replaced by t. Therefore (1, t u ) I e' I = (tu, 1) and thus tu E A , i.e., u E t'A. This proves (6.6), and with it (6.5). T h e proof of (6.2) follows from: LEMMA 6.4.
Each s E A is calculated by a successful path c such that
X. Machines
286
Let c: i t be a successful path in , I such that (1, s) I c I 1) and assume that 1) c 1) > m(l s 1 1). For each 0 C j 5 II c /I decompose c into Proof.
f
+
= (s,
.
"I
bj
11
qJ A t 7
A
11 = j
' J
Then
(l, ') I ' J I ($I>
1,)
=
('JY
I 6, I =
($9
t))
1)
s = S,tJ
Consider the pairs (I sJ 1, qJ) for 0 5 j 5 I/ c a repetition must occur and thus we have
(1
'J
1,
9,) =
(1
'1
11. Since I/ c II > m(I s I
+ 1)
1, q k )
for some 0 c j < k 5 11 c 11. Since both sj and sk are initial segments of s, it follows that sj = sk and consequently also t j = t k . Thus we see that
.
al
z * qj
=
qk

is a shorter successful path calculating s
bt
t
1
7. Other Machines
We shall rapidly list a number of important types of machines. Most of these will be studied in Volumes C and D. This section is mainly addressed to the reader who has already encountered some of these machines presented in a different manner. A rapid preview might serve to eliminate terminological and notational misunderstandings.
A. Pushdown
Let
automata:
I (7.1)
XL,'
a € _r
R ~ X I?
RY'xI y
E . r
E
I'
287
7. Other Machines
Using either the terminal set X,,, or X,,, the machines of this type compute the class of contestfree languages in V". T h e register T* plays the role of a memory (pushdown store) and the class of sets computed is independent of T as long as card T > 1. If card I' = 1, then a smaller class of sets, called counter languages is obtained. In an accelerated pushdown automaton the type is replaced by
(7.2)
R,R;~x L;'
(T
E
s,
u,
E
r*
This type computes the nonsingular contextfree languages in C*. If to the type (7.1) we adjoin I x L , , we obtain machines of the same strength as Turing machines. They will compute all the recursively enumerable subsets of S". T h e same phenomenon takes place if we adjoin a second pushdown register, i.e., set X = I'* x r*x C", with a, X,", and the type suitably modified. B . Stack automata: We define the partial function
E: 1'*4T*,
1E= 1,
8
gE=
if g f l
This partial function "checks" whether the register Now consider
I'* is "empty."
x =rvr*xz*
*,'
a:
3 X )
sc;l = (1,
1, s)
x, = r * x x * x 1 T h e type is given by
I x I x L;'
R, x L;' x I
R,xExI
R;I x L, x I
R;'xExI
T h e third register L'* is the input register. On the input register only reading and erasing is permitted. T h e first two registers jointly (i.e., I'*xI'*) are called the stack; an element ( g , h ) of the stack may be viewed as a single element gh E r" equipped with a pointer. The second and third partial functions in the type allow this pointer to move to the right or to the left. T h e last two rules permit erasing and printing on the right of the stack, but only if the pointer is in the utmost right position (this is the role of E ) . We described a oneway stack automaton. In a twoway stack automaton 2" is replaced by L'* x 3 exactly as when passing from a ,'automaton to a twoway Vautomaton (see Section 6).
X. Machines
288
C. Turing machines (one of many possible models):
Let
x = Z"xZ+ a: Z"+X,
X,
sa= ( 1 , s ) =
(1, 1)
T h e type is given by
R,x I , RilxI,
I x L, I x L;'
for u E Z. Machines of this type compute all the recursively enumerable subsets of 2". T h e list of examples could be continued indefinitely.
8. Deterministic Machines
T h e aim of defining deterministic machines is to compute partial functions rather than relations. I n the case of machines with an accepting set (instead of an output code), the aim is to compute unambiguous sets. The following preliminary conditions are assumed : (8.1)
All elements p: X t X of the type @ are partial functions.
(8.2) a : Y + X is a partial function. (8.3) w : X + 2 is a partial function. Note that condition (8.3) is automatically satisfied if an (unambiguous) accepting subset X , of X is given, as then Z is a single point and w is the unique partial function X + 2 with domain X,,,. A machine A = (Q, I , T ) of type @ is called deterministic if it satisfies the following two conditions:
(8.4) card I < 1. (8.5) If p p12

=
Vl
q1 and
p
2 q2 are distinct edges, then Dom p 1 n Dom
0.
These conditions will frequently (but not always) ensure that
f = a I 4I o is a partial function. However we have:
289
8. Deterministic Machines
PROPOSITION 8.1. If R is a deterministic machine in which no nontrivial p a t h connects two terminal states, then &computes a partial function
f: Y z.
Conditions (8.1)(8.3) ensure Proof. Let c be a successful path in 1. Notations introduced in IV,2 and IV,6 will be used. T h e first example that we shall consider is the function
x,y
Max(x,y),
E
N
Let s and t be the expansions of x and y at base k. T h e usual way to decide which of the two integers x and y is the larger one is to compare corresponding digits in the expansions s and t. Two facts emerge: (1) since the more significant digits must be compared first and since our sequential machines read the input from left to right, the standard interpretation vk: k* + N should be used; (2) pairs of digits will be compared, thus the words s and t of k* should be of equal length (i.e., of the same format). This can be achieved by writing a sufficient number of zeros at the left end of the shorter one. T h e pair s, t E k* such that I s I = I t I is now treated as an element of (kx k)* and a complete sequential machine
A:k x k  k is constructed such that
T h e machine .kis given by the diagram (d,d)/d
(d,d')/d'
c
0
Its functioning is clear
(d,d')ld' d 0. If this is the case, then f may be chosen to be a morphism.
f o r all s E k", then k
EXERCISE 4.3.
1"
+
Let k
=
6 with r > 0. Construct a gsfunction f :
k" such that (sf
for all s E
(P)",i.e.,
EXERCISE 4.4.
>k =
all s E 1" such that I s I is divisible by r .
Let k, = 1'1, k, = P a . Construct a gsfunctionf: k,"
+
k," such that
(sf >k2 = ( s > k l for all s E k," with 1 s 1 divisible by r 2 . 5. StateDependent Sequential Machines
Let A= ( Q , i, A ) : C* t P be a gsmachine. We shall say that A? is statedependent if there exists a
5. StateDependent Sequential Machines
31 3
function (not just a partial function!)
Equivalently, A? is statedependent iff
Since 1 and ,8 mutually determine each other we shall write ,A'= (Q, i , ,8). I n the graphical representation of d, whenever we have
dui
41
4
02/02 f
42
then g , = g z . It is therefore appropriate to remove the output label from the edges and transfer it to the state which is the end of the edge, thus obtaining (TI
g
41 __+ 4
where g
a2
42
=g, =g2.
r*
PROPOSITION 5.1. For each gsmachine (resp. smachine) .d: Z* + there exists a statedependent gsmachine (resp. smachine) .,A'': Z* r* such that fl=fa,. f
Proof, I n view of Proposition 3.6 (or rather the construction in its proof), it suffices to consider the case when
d = (Q, i, A): S is a sequential machine. Consider the machine
We claim that for all s
E
Z*
+
r
XI. Sequential Machines
31 4
For I s I 5 1, this is clear. Arguing by induction we have
This proves (5.1). From (5.1) we deduce =
f.W
f.,,
Observe that if in Proposition 5.1 LT is complete, then so is the statedependent machine d” constructed above. ~
6. Recognition of gspFunctions
be an initial segmentpreserving partial function. T h e dzflerential of f is the partial function y : z+ r* defined by the condition
m.
Observe that from the differential y we and (w)y = @ if ( s o ) f = may reconstruct f as follows
1
~
f
{ (u,y)(olu2y).. . (ol.. . =
a,Lp)
if s = l if s = ol. . . g , ! , n > 0
Clearly y is a function iff f is a function. If f is lengthpreserving and initial segmentpreserving, then
6. Recognition of gspFunctions
31 5
and vice versa. For each y E F, we have
This follows from (6.1). Let y l , . . . , y, be an enumeration of the letters of vector A = (A,, . . . ,A,) A k =
of (unambiguous) subsets of
(r"yk)f'
I+. T h e following facts are clear:
(6.3)
T h e sets A , , . . . , A, are disjoint.
(6.4)
If s E St and
(6.5) Ilom f
=
1
SZL E
I', and consider the
iz, u . . . u A,, then s E A , u . . . u A,.
u A , u . . , u A,.
Note that (6.4) follows from (6.5) since f is initial segmentpreserving. Conversely given a vector A = ( A , , . . . , A,) of subsets of L'+satisfying (6.3) and (6.4), formulas lf=1 ( S C T ) ~=
(sf )y,
if
sf f
0,so E Ak
define inductively a unique length and initial segmentpreserving partial function f for which (6.2) and (6.5) hold. We thus have a bijection between length and initial segmentpreserving partial functionsf: 2" + F" and vectors A = ( A , , . . . , iZ,) of subsets of I satisfying +(6.3) and (6.4). Clearly f is a function iff A, u . . . u A , = Zi. * + I'* be a lengthpreserving and initial THEOREM 6.1. Let f : I segmentpreserving partial function and let A = ( A , , . . , , A,) be the corresponding vector of subsets of I+wtiere r = card r. TJzen f is sequential if and only $ the sets A , , . . . , A, are rational. Proof. I f f is sequential, then by Proposition 3.1, f is rational. Therefore the sets A , = ( I ' * y k ) f  l are rational. Conversely assume that A , , . . . , A, are rational. If A = @ (i.e., A, = . . . = A, = then Dom f = 1 and f is sequential. T h u s we may assume A f Let
a), a.
31 6
XI. Sequential Machines
be the minimal automaton of type (1, r ) such that I I = A , as constructed in III,13. We recall that the states in QLiare the nonzero vectors of the form
AS = (s'Al,
(6.6)
. . . , s'A,)
and that
T = ( T , , . . . , T,) each T, being the set of all states (6.6) for which 1 E slA,, i.e., s E A,. Since the sets A, are unambiguous and rational, they are recognizable by Kleene's Theorem. I t follows that QL4is finite. Since As E T, iff s E A k , the disjointness of the sets A , , . . . , A, implies :
(6.7) T I , . . . , T, are disjoint. We assert QAC= T , u
(6.8)
. ..
u T,
First observe that if As E T,, then s E Ak and thus s E C+ since Ak c L'+.Consequently, Tl u . . . u T, c QA4Z. T o prove the opposite inclusion assume As E QA4Z with s E C+. Since &', is coaccessible we have Asu E T, for some u E Z* and 1 5 k 5 r . Thus su E A,. Since s E L'+ it follows from (6.4) that s E A,, for some 1 5 k' 5 r . Thus As E T,,. This proves (6.8). We may now define the function
1: Q , X C  t r
(9, o)l = Yk
if
qa E
Tk
and consider the statedependent gsmachine J.4
Assume
= (Q1
A, A)
sf+ 0.Then (self =
(sf )Yk
holds iff so E A, , i.e., iff Aso E T,, i.e., iff (As, o ) l = y,. Thus we have =
( d ) ( A s ,a)J
and this proves that f is computed by the machine
I
6. Recognition of gspFunctions
31 7
Observe that since A , , . . . , A , are subsets of Z+ the state A of is not in T , u . . . u T,. Consequently Q.1
QA4
A v T , v . . . u T,
is a partition of THEOREM 6.2. For any lengthpreserving and initial segmentpreserv
in, partial function f: Z*+ r* the following conditions are equivalent: (i) f is rational. (ii) For each rational subset B of P,the set Bf (iii) ( r * y ) f  l is rational for each y E IT. (iv) f is a sequential partial function.
is rational.

T h e implications (i) => (ii) (iii) are clear. T h e implication (iii) = (iv) follows from Theorem 6.1. T h e implication (iv) = (i) follows from Proposition 3.1 Proof.
For partial functions f which are initial segmentpreserving but are not assumed to be lengthpreserving, the situation is considerably more complex. Condition (i) is not sufficient to ensure that f is a gspfunction (see Example 6.1 below). (GinsburgRose) For every initial segmentpreserving partial function f:zT* + r*the following conditions are equivalent. THEOREM 6.3.
(i)
f is rational and there exists an integer M 2 0 such that
Z+ such that (su)f f 0. For each rational subset B of P,the set Bf is an integer M 2 0 such that
for all su
(ii)
E
p1
is rational and there
for all sa E Z+such that (sa)f # @. +I '* o f f has a finite codomain and gv' is (iii) The dzfferential p: Z+rational for every g E P. (iv) f is a gspfunction.
XI. Sequential Machines
318
Proof. (i) => (ii). Since f is rational so is f  l : r*+ Z". Thus BjI is a rational set for every rational subset B of f*. (ii) * (iii). T h e inequality of (ii) implies
I say I = I sufl

I sfl I
and therefore y has a finite codomain. If g E f" and I g I > M , then gy' = 0. Thus we may assume that I g I 5 M . Define
Bi= { g I g E P , Igl  i m o d M + l} for 0 5 i
5 M . T h e sets B i are rational. Consequently the sets
are rational for every 0 5 i 5 M and every cr it suffices to verify the identity
gp'
(6.9)
=
E
Z. Thus to prove (iii)
U V,i,a
the union extending over all 0 5 i 5 M and all CT E Z. Assume t E gpl. Thus t = sa and say = g. Consequently tf = (sf )g. Since 1'" = B, u . . . u B,, we must have sf E B , for some 0 5 i 5 M . Consequently t f B,g ~ and t E (B,g)fI. Further since s f ~B , we have s E B ,f' and thus t E ( B , f  ' ) a . We have thus shown that t E V,,". Conversely assume t E Vi,a. Then t E (B,f')a and thus t = so with s f B~ , . This implies
tf = (salf = (sf )(sa)rp Since also t
E
E
BL(tP))
(Big)f' we have
+
It follows that I g I = I tp, I mod M 1. Since however I g I 5 111 and I ty I I M we must have I g I = I t y I. Since both g and t y are terminal segments of tf it follows that g = tp, and thus t E gy'. (iii) * (iv). Let g , , . . . ,g, be an enumeration of the elements of the codomain of y . Consider an alphabet Q with letters w , , . . . , (or and let y : Q* + P be the morphism satisfying w,y = g, for 1 k 5 r . Consider the subsets
6. Recognition of gspFunctions
31 9
These are disjoint subsets of L". T h u s condition (6.3) is satisfied. We assert that (6.4) also holds. Indeed, s E A , u . . . u A, is equivalent to sq f Since ( s u ) f ~ ~3and s E .L'+implies sp # condition (6.4) follows. Since the sets .4,, . . . , A, are rational by assumption, Theorem 6.1 may be applied to yield a sequential partial function h : 2" L P such that A,. = ( Q " O J ~ ) ~  ' or , equivalently
a.
a
f
if sh f
(sa)h = ( s h ) ~ , .
and
su E Al
Applying the morphism y we have
if shy f 8 and su E A,
(sa)hy = (shy)g,
This shows that f = h y and thus f is a gspfunction. (iv) (i). This follows from Proposition 3.1 I Let 1 = {a, T } , r = {a}. Consider the initial segmentpreserving function f: S* 4T" defined by EXAMPLE 6.1.
a!f=
for all s E L'*
d t s f = cZk
Then f is rational as indeed its graph is (a,a)"
u
( 0 , a2)*(t,
l)(Z*X 1)
However,
I
(a")f
I

I ay1 = k
so that the "Lipschitz condition" of (i) in Theorem 6.3 is not satisfied. T h u s this condition in (i) and (ii) of Theorem 6.3 is not redundant.
Theorems 6.2 and 6.3 imply: COROLLARY 6.4.
The composition
of twogspfunctions (or spfunctions) is a gspfunction (or an spfunction)
I
XI. Sequential Machines
320
This corollary follows much more naturally from the properties of composition of machines defined in XII,8. 7. Sequential Bimachines
T h e theorems of Section 6 relating rational functions and gsmappings, were restricted to functions that are initial segmentpreserving. We shall now show that this very restrictive condition may be dispensed with if we introduce a “twosided” version of the notion of a sequential machine. A bimachine A:
z+r
where Q and P are finite sets equipped with partial functions
qo and p , are elements of
Q and P , respectively, and 1 is a partial function
called the “output”. No conditions are imposed on the domains of (7.1)(7.3). If (7.1)(7.3) are functions, then ..&is called a complete bimachine. In a generalized bimachine A?:2*+ r*,the output il is allowed to be a partial function
As usual the partial function (7.1) converts Q into a right 2module. The partial function (7.1) is extended to a partial function Q X Z* + Q satisfying q l = q, q ( s t ) = (qs)t. Dually the partial function (7.2) is used to convert P into a left 2module; this partial function is extended to a partial function 2*x P + P satisfying lp = p and (st)p = s(tp). T h e output (7.3) [or (7.3g)I is extended to a partial function
7. Sequential Bimachines
321
defined inductively as
for s E I",0
E
E. T h e more general identity
for all s, t E I*is now proved by induction on I t I. If I t I 5 1, then (7.7) follows from (7.5) and (7.6). If t = uo, then inductively
as required. T h e result of A" is the partial function
This is the only occasion where the initial states q o , p o are used. If A'is a bimachine (rather than a generalized bimachine), then
and thus j K is lengthpreserving. If .,His complete, then (7.4) is a function and thus alsof8 is a function. I t should be noted that bimachines do not fit into the general definition of machines of Chapter X. If, however, P = Po reduces to a single state and (7.2) is the (unique) function, and if further (7.1) and (7.3) have the same domain (where Q x Z and 0 x Z XP are identified), the bimachine becomes a sequential machine in the usual sense. THEOREM 7.1. Let f : L'* + P be a partial function such that If Then the following conditions are equivalent:
=
1.
322
XI. Sequential Machines
(i) f is rationd. (ii) f is the result of a generalized bininchine
9+ l’*.
Further f is lengthpreserving ;f and only iff is the result .f a himachine ./A?: X + 1: Also f is a function if und only if . //‘ can Be chosen to be complete T h e proof is given in Section 9. We only note here that in the gcncralized bimachine /i‘= (Q, q,, P, p , , 1)that will bc constructed, the right Smodule Q and the left Xmodule P are complete and only 1 is a partial function. If, however, f is a function, then 1 as constructed also will be a function and thus R will be complete. 8. Examples of Bimachines EXAMPLE 8.1. tion
Let .Y
=
{o},1’= { y o , y , } , and consider the funcf :
x* r*
{$
(T,lf=
if n is even if n is odd
This function is rational and a bimachine computing it will be constructed. We choose Q = P = 2 with 0 as initial state for both P and 0. T h e right action of a on 0 and thc left action of CT on P are given by
io=ci=Ii
for
i=O,1
T h e output function is y: QXZXPI’
(i, .,j)y
y,
=
{ yo
if if
i + j is even i + j is odd
We claim that a’lf = (0, a”, O)y
Indeed (0, 8, 0 ) y is the product of terms of thc form (Oak,
o, o)1PlO)y,
If n is even, then k  {  ( n  k If n is odd, then k 4 ( n k ~
~
0 5 k < n
1 ) is odd and thus each term gives y o . 1 ) is even and all the terms are y , .
8. Examples of Bimachines
323
EXAMPLE 8.2. M’e return to the sequential inachinc .//
d,
=
(0, ( t l , t z ) ) ~ ( o ( ttz), l , dl >
=
(0, s 1 , S Z ) l E
9
= (Sl
9
9
9
O h
, sz)h
as required. I t should be noted that if it were only a question of showing that the function g is rational, then this could be achieved easily by modifying the sequential machine ,d to become a transducer A?' by ( 1 ) regarding 0 as a terminal state, and (2) introducing a new state t that is terminal and introducing an edge IXI 1t whose label is the identity function. As an application of Example 8.2, we prove: PROPOSITION 8.1. Let the function g :
%
=
k" + k" be dejined by
[srl
where q : kX + N is the reversed byective interpretation of V,6 and [rp] is the reversed expansion at base k . The function g is rational. Proof,
If s=dO
then
. . . dn,
n
sv =
C (di + l ) k i i=O
and [sq] is the expansion of sq at base k . I t is clear from this description that sg is the digital sum of s and of a string of 1's of length I s 1. Thus
sg = (s, 1'")h and this proves the rationality of g
I
EXERCISE 8.1. Show that the subset A of N is krecognizable zfl q~IA is a recognizable subset of k" where q is the bijective interpretation.
9. Proof of Theorem 7.1
325
9. Proof of Theorem 7.1
T h e following fact, derived from (7.2) and ( 7 . 3 ) by induction will be useful :
w h e r e n = I s l andfor l < i < n
(ii) => (i). Assumef = .fa where R: L'++ f is a gsbimachine. Let .R = (0, qo , P, p,, A). We generalize the construction of the graph of an automaton as given in II,6. For this we consider the alphabet I
S=
+
Q X Z X P
and define the morphisms
Next we define the local set
Assume u E L and uh B, and C imply that
= s = c1
. . . on with n > 0. T h e definitions of A ,
Conversely if u has this form, then u E L and uh = s. Further, (9.1) implies sffl = ( q o ,s, po)A = ( W J ) . . . ( W n Z ) = ul
XI. Sequential Machines
326 I t follows that f l y is the composition
and thus ff is rational. (i) (ii). We first consider the case when f is lengthpreserving. Let f ' be the composition nsi 1" I 1'" 2" d __c
T h e n since f is rational, so is f' and further I f ' VI,6.3, f ' admits a factorization h1 171, 2" d 0"d R"
I __+
= @.
T h u s by Theorem
1'"
r*
where h : Q* + S* and I: Q* are very fine morphisms and I, is a local subset of SZ". Since I f = 1 it follows that f is the composition f
ZR* a* A(lUL)
1"
I
r*
Let
L
=
AR" n Q*B
A , B c Q,

Q*CP
C c sz'
Let D consist of all the finite subsets of f2 and of the element 1. We convert D into a right Zmodule by the formulas
10
=
da
=
I (oh = I T , (0 E A } {Q I wh = I T , do)  C # ((1)
a}
for d E D, d f 1 . Similarly we convert D into a left 2module by the formulas IT^ = { ( I ) I (oh = I T , (o E B }
ad Setting qo = p ,
=
= {(u
I wh = CT, rod
~
C f @]
1 we define
T h u s Q is an accessible complete right 2module, while P is an accessible complete left 1module. To complete the definition of the sequential bimachine Jd= ( Q , q 0 , P , p o , A ) :
zjr
9. Proof of Theorem 7.1
327
we define the output
1: Q x Y x P 4 r by setting (4, .,P)A
q
=
=
p
q,s,
=
( 4 0 n op)l
tp,,
s, t
S"
E
We claim (9.2)
Let sot
E
Yk. Then (sot)f # @ iff
qoso n olp,
f
(4
If this is the case, then (qoso n otp,)Z is the nth letter in (sat)f where n = I s I 1.
+
Taking (9.2) for granted for the moment we continue the proof. I t follows from (9.2) that A is a partial function. T h u s the sequential bimachine . k': 1: 1' is well defined. Observe also that i f f is a function, then (9.2) implies that (q, o, p ) A f 0. T h u s in this case .R is complete. Next consider s = (T, . . . o,#E S+ and let sf = y1 . . . y,{. Then (9.2) implies ( 4 0 S L > 0 , t,P,V = Yb f
Y
where for 1
5i 5n s
=
i = I s, I
s,o,t,,
+1
Therefore by (9.1) (40,
s, P 0 ) A = sf
This proves that f c f {,. T o prove equality assume sfa f (4 for some s E Xi,and let s = at. 'Then SfR. =
(Q" s, P o V 7
=
(40,
at, P")A
=
( 4 0 , 0,
tPo)440a, 4
1 herefore ( q o , a, tp,)1 # @ and thus, by (7.2), proves f = fa. Before proving (9.2) we prove:
I ,
(9.3) If
E
Q and s
E
L",then (11
iff there exists
zi E
E 40s
Q* such that u(u E
An"

Q"CQ*
sf=
P O V
((~t)f+
0.This
XI. Sequential Machines
328
We prove (9.3) by induction on I s 1. If s = a, then we must have u = 1 and (9.3) is in this case a direct consequence of the definition of qoa. Now proceed by induction and assume that s = t a with t E Z+.By definition of (q,t)a, the condition o E q,ta is equivalent to coh = u together with the existence of an w' E qot such that o ' w E C. By induction, the condition w' E qot is equivalent to the existence of u' E 0" such that (u'w')h = t and u'w' E AS"  sZ"CS". Since wh = u and w'w E C these conditions are equivalent to (u'w'w)h= t a = s and u'w'w 4 AS"  sZ"CsZ". Thus the conclusion of (9.3) holds with u = u'w'. T h e argument being reversible, (9.3) is established. Symmetrically to (9.3) we have: (9.4) If w
E
S and s E Z+, then 0
sp,
E
iff there exists v E S* such that (Uv)h = s wv
E
S"B
 S"CS"
We can now prove (9.2). Assume ( s a t ) j f 0. There exists then w E L such that wh = sat. Then w admits a decomposition w = uv such that (9.5)
(uw)h = ~ a , ( w v ) h = at
Further the condition w (9.6)
UQ E
AS"
E I,
implies uv E S"B  S"CS*
 sZ"CS",
Thus by (9.3) and (9.4) (9.7)
w E q,so
n atp,
Conversely assume (9.7). Then by (9.3) and (9.4) there exist elements S" such that (9.5) and (9.6) hold. From (9.5) we deduce that (uwv)h = sat while (9.6) implies UQV E L. Therefore (sat) = (uwv)l and thus ( s a t ) j # 0. Further since I s 1 = 1 u I it follows that wl is the nth letter in (sat)f where n = I s I 1. This concludes the proof in the case when j is lengthpreserving. T o consider the case when j is rational but not necessarily lengthpreserving we use Theorem IX,8.4 to obtain a factorization u, v E
+
z*2
r* h
9. Proof o f Theorem 7.1
329
where 9 is a finite alphabet, g is a lengthpreserving rational partial function, and h is a morphism. By the above there exists a sequential bimachine 1, then q1 E,,, q2 iff q1 E l qe and qlu El, qau for all u E 2 such that qlo f rZ, f q 2 0 . We conduct the proof for E = c ,the other two cases being quite I t 1 = p 1. similar. We must prove that (ql , t ) A c ( q 2 ,t ) A if t E I*, Let t = us. T h e n (q, t)A = (4, o)A(qo,s)A for q = q1 or q = q 2 . Since ( q , , o)A = ( q 2 ,u)A and (qIo,s)A c (q20,s ) A it follows that (ql , t ) A c ( q 2 ,t)n. T h e implication in the other direction is proved similarly. From (5.1) we deduce:
+
(5.2) If E,,
=
E, , then El,,,
=
E,
I.
XII. Operations on Sequential Machines
342
From ( 5 . 2 ) it follows that:
(5.3) If E,,,
=
E,, then E
=
E,.
Next we prove:
(5.4)
Let n
= card
Q. Then E,+,
= E.
Indeed consider the properly descending chain of relations
(5.5)
E,
3
E,
=I . . .
2
Ep
and let ci be the cardinality of the graph of E i for 0 5 i 5 p . Then
n2=c,>cl>
... > c p 2 n
and thus p 5 n2  n. Consequently if p = n2  n, then E p = E,,, and thus E p = E. Since for any fixed p the relation E, is computable in a finite number of steps it follows from (5.4) that the relation E is computable in a finite number of steps I I t should be noted that the numerical bound ng  n was obtained using only the fact that the relations Ei are reflexive. Much finer bounds are obtained if we consider the three cases for E separately. If E = , then E i are equivalence relations. If d i is the number of equivalence classes of Ei, then we have
l=d, 2
... > e , > 0
Thus p 5 n(n  1 ) / 2 so that En(n1),2 = E in this case.
6. The Strong Minimization Problem
343
T he relations q1 E q2 we defined for q1 and q2 belonging to the same gomodule M . If q, and q, belong to different gomodules M , and M , , then the disjoint union M of Ml and M 2 may be formed and thus q1 and q, may be viewed as belonging to the same gomodule. Essentially the same argument that was used to prove (5.1) also proves: PROPOSITION 5.2. If q1 E q, and qla f (21 # q,a, then qla E q,a
I
6. The Strong Minimization Problem
Let f = ( fi,. . . ,f n ) be an ntuple of gspfunctions f k : L'* P, 1 5 k 5 n. I n Section 4 we solved the problem of finding an nfold, gsmachine .Asatisfying f
f =fa and having the smallest possible number of states. T h e solution was unique up to an isomorphism. T he situation changes radically if the equality above is replaced by the inclusion
f Cfa If df = (Qf, f , I f )is the minimal machine off, then f l , . . . ,f n are the initial states of Af. If i = (i,, . . . , in) are the initial states of A , the inclusion above becomes
fk c ik and implies
for all s E
for
fk
1 5k 5n
s c iks
L'". Since df is accessible we find that for each state
q, of
df there exists a state q of J&? such that qo c q. This observation permits us to dispense with initial states and thus reformulate the problem in terms of gomodules. We consider a fixed gomodule Ma = (Po,A,) and consider all gomodules M = (Q, A) such that:
(6.1) For each q, E Qo there exists q QoAo = qA)*
E
Q such that qo
c
q (i.e.,
XII. Operations on Sequential Machines
344
In order to keep this class of gomodules reasonably small we shall also assume: (6.2)
If M‘ is obtained from M by the removal of a single edge, then (6.1) no longer holds for M , and M‘.
Clearly condition (6.2) can be arrived at by removing a number of edges from any M satisfying (6.1). If (6.1) and (6.2) hold, we shall write
We shall be interested in those solutions M = (0, A) of (6.3) for which card Q has the lowest possible value n,. Such solutions of (6.3) will be called extremal. It is clear that extremal solutions are reduced. Since M , satisfies condition (6.1) with respect to itself, it follows that M , < M where M is obtained from M , by the removal of edges. Consequently I card Qo Since we have an upper bound for n o , it is clear that the problem of determining the exact value of n, and of enumerating all the extremal solutions is a finite one. We shall give here a procedure which is a little more systematic than ordinary “trial and error.” T h e procedure is broken up into short steps and simple propositions. These will be explicitly stated and the proofs are left as cxercises for the reader. T h e procedure in question consists of a particular method for constructing a family of extremal gomodules for Mo and then of a proof that all extremals for M , are thus obtained. T h e construction of the particular family involves a good deal of trial and error. Let @‘ be a family of subsets of Q,; thus each element C E ‘&7is a subset of Q,. T h e following properties of these subsets are postulated: (6.4) T h e sets in @ are nonempty. (6.5)
T h e union of the sets in ‘8 is Q,.
(6.6) Any two elements of C (6.7)
E %
are compatible.
For each CE@ and each a~ Zthere exists C’E‘&such that Ca c C‘.
6 . The Strong Minimization Problem
3 45
I t will be shown that the lowest possible cardinality for such a family @' is exactly n, and thus we can restrict our attention to families satisfying = n, card '8
(6.8)
W e now convert '8into a right 2module by defining C CEgand uEZas:
. IJ
for each
Because of (6.7) we can always achieve (6.10). I n fact this may involve a choice for C . 0,and thus several right Sactions on fl may be obtained. Having converted '6into a right 2module the output
A:
cgy
z + I'"
is defined by setting
(6.1 1)
(C, I
J ) ~1
U (qn,
u)An
rl0'C
E C are compatible (C, o)A is at most one element. Further (C, a)A f @ iff (q,, IJ)A" 7 for some q, E C. This holds iff q,o f @ for some qo E C, i.e., iff Co f ~3. T h u s by (6.9) we find that (C, I J ) A f @ iff C . CT f @ as it should be. We thus obtain a gomodule A2 = (C, A )
Since all q,
[actually several gomodules may thus be obtained due to the choice in (6.1O)]. I t is now easy to prove that if q, E C, then q,A, c CA, i.e., qo c C. T h u s condition (6.1) holds for M o and A!I. Consequently, by removing redundant edges in M , gomodules Ill' are obtained which are extremal for M,. This, in particular, shons that card 6 2 n,. We first show that some of the gomodules M defined above may be rejected. Indeed suppose that for each C E 6 we can find a subset C0 c C such that UC" = QO and that Coo c (C . IJ),.If, further, Cnf C for at least one C E '6 then , we say that the right 2module 6' is shrinkable. I n this case the family Go = {C"} leads to a gomodule Illn = (@, An) which is obtained from h!I by removing edges. Since condition (6.1) still holds for M , and M", me may eliminate the gomodule M . Next we show that all the gomodules extremal for M , will thus be be the obtained. Indeed let M = (Q, A) be such a gomodule. Let
XII. Operations on Sequential Machines
346
family of all sets
c, = { q o
I40 E
Qo,
40
41
for all q E Q. I t is easily seen that t5' satisfies (6.5)(6.7). If, further, any one of the sets C, is empty or if C,, = Cq2for some q l , q2 E Q with q1 # q 2 , then a family 8'satisfying (6.4)(6.7) will be obtained satisfying card @' < no. Since this is impossible, we conclude that the sets C, are nonempty and distinct and thus card 8 = no. If we now define C, . (T = C,, whenever qa # 0, we obtain gomodule (@, A ) which coincides with M except that the states q E Q are replaced by C , E @. is a shrinking of @, then If the right 2module $3' is shrinkable and go [with the output always defined by (6.11)] also gives a gomodule coinciding with M. Thus 6? may be replaced by a shrinking 8,which itself is no longer shrinkable. This shows that all the extremal gomodules for M , are obtained by the procedure described above. It is a byproduct of the discussion above that if M , is an omodule (rather than a gomodule), then all its extremals also are omodules.
EXAMPLE 6.1.
Consider the omodule M , 1
2
OfO
3 Here ,Z
=
r = {a, r } . The compatibility 1 /I 2,
conditions are
2 II 3
However, 1 and 3 are incompatible. The families 8satisfying (6.4)(6.7) and of lowest cardinality are =
For
{1,23},
8  (12, 3},
@3
=
{12,23}
MIwe have no choice in the module structure. We must set 1*~=23,
l.t=@,
This yields the gomodule
which is extremal for M,.
23
*
a = 1,
23
*
t=23
'
6 . The Strong Minimization Problem
3 47
For 8,we similarly have no choice of module structure and the results are the gomodule
For 'F3the following actions are forced
However, for 12
.
(T
we have the following two choices
12.0=23
or
12a=12
Thus two module structure on result. However, both of them are shrinkable, the first one can be shrunk to %, while the second one can be shrunk to g2.Consequently there are only two extremals for M,. EXAMPLE 6.2. Consider the omodule M
2
with Z = T =
(0,r } .
T h e compatibility relations are
1 II 2,
2 II 3,
3 /I 4,
4 II 1
There are two families of lowest cardinality satisfying (6.4)(6.6) namely
8, = (12, 34},
@ = ', (14,23}
T h e module structures are forced in both cases and the resulting omodules are
Note that both extremals obtained are complete.
XII. Operations on Sequential Machines
348
Note that in both examples considered above the coverings 8,and LF2 of Q are partitions of Q into disjoint sets. For such a covering B‘ of Q [satisfying (6.4)(6.7)] the following facts are clear: (i) T h e Zmodule structure on ($7 is unique. (ii) T h e resulting Zmodule @ is unshrinkable. (iii) If M = (@, A) is the gomodule obtained, then defining p: Q, + 8 by setting gop = C whenever go E C, a statemapping p: M , + M is obtained. Further p: Q, + $7 is a surjective function. Let M , = (Q,, A,) be a gomodule in which all states are mutually incompatible. Show that M , is its own unique extremal. EXERCISE 6.1.
EXERCISE 6.2. Let M , = (Q,,, Ao) be a gomodule and let go, 4,’ be a pair of distinct states which are compatible. Show that there exists a gomodule M = (Q, A ) and a state mapping p: M , + M which is a surjective function, such that q,,p = qo’p.Conclude that no < card Q,. [Hint: Keep adjoining edges to M , until the states go and 9,’ become equivalent.]
Show that if in M ,
(Q,, A,) all states are compatible, then no = 1 and there exists a morphism f: Z* + r* such that q0A, c f f o r all go E Q,. EXERCISE 6.3.
=
7. The Synthesis Problem
Let fi,
. . . ,fn: z*
r*
be lengthpreserving partial functions. T h e synthesis problem consists of the finding of an omodule M = (Q, A): 2 + r such that
fi c qiA for some states g l , . . . , qn in Q. Further it is required that card Q should be as small as possible. We shall solve this problem under the assumption that the partial functions f i , . . . ,fn are rational. PROPOSITION 7.1. For any lengthpreserving partial function f: 2% + r* the following properties are equivalent:
(i)
There exists a lengthpreserving and initial segmentpreserving partial function g : 2* + r* such that f c g.
8. Composition of Sequential Machines
3 49
Let A = I)om f and k t be the set of all initial segments of A. There exists a lengthpreserving and initial segmentpreserving partial function .f: V" + 1'" with D0m.f = '4. (iii) I f uv, uw E A (where A = Domf ), then (uv)f = zi'zl', (uw)f = u'w' with I u 1 = I u' I . (ii)
Proof, (i) = (ii). If g is initial segmentpreserving and f c g , then necessarily A c I l o m g . Then f can be taken to be the restriction of g to A. (ii) 3 (iii). This is clear since u' = uf. (iii) 3 (ii). .f is defined by setting u' = uf I I f f satisfies (iii), then we say that f is extendable. T h e extensionfof f is called the closure off; it is uniquely defined and its domain is the set of all initial segments of the set A = Domf. PROPOSITION 7.2. Let the partial function f: V" + I'" be lengthpreserving, extendable, and rational. Then f : P 4P is an spfunction.
Proof. I n view of Theorem XI,5.2, it suffices to prove that f is rational. Let B be the graph off. Since f is lengthpreserving, we may regard B as a subset of (L'x1')". Sinccf is rational B is a rational subset of L ' " x P and thus by Theorem V11,6,1, B is also a rational subset of ( L ' X I ' ) " . T h u s by Kleene's Theorem B is a recognizable subset of (L'x1')". T h e set B of all initial segments of B is then, by Exercise 11,4.1, also recognizable. T h u s again by Kleene's Theorem B is rational. Since B is the graph of .f it follows that .f is rational I We now return to the synthesis problem. T h e problem clearly has no solution unless f l , . . . ,f n are extendable. Assume then that f l , , . , ,f,, are extendable. I n the synthesis problem we may then replace f l , . . . ,f I L by their closurcs.fl , . . . If, further, f l , . . . ,f,, are rational, then, by Proposition 7.2, f l , . . . , J 1are spfunctions. T h u s the problem becomes the Strong Minimization Problem considered in Section 6.
,XI.
8. Composition of Sequential Machines
Consider output modules
zr+n31 ' '11
XII. Operations on Sequential Machines
350 T h e composition
will now be defined as follows: If M
MM’
=
=
(Q, A), M‘
=
(Q’, A‘), then
(Q‘ x Q , 21‘)
with
If M “ : SZ
f
0 is a third output module, then the associativity
(8.3 1
(MM”,”
=
M(M‘M“)
holds. Indeed, the associativity (AA’)A’’ we compute
((q’’,
4)a = ((4”, =
A(1‘A’‘) is easily checked. Next
QO(%
40)
(q”(q’, (4, a)A)1’, q‘(4, G)A qo)
(Q”, (q‘, 4 ) b = (4”(4‘, =
=
(I,
o)(Al’),(Q‘,Q)U)
(q”(q’, 4, .)(An’),
q ‘ k , o)J, P)
T h e agreement of the two results shows that (q”, q‘, q)o is defined without ambiguity and this proves (8.3). Now assume that card Q = 1, i.e., the output module M has a single state. Then Q x 2’ and Z may be identified and the output 1 becomes a function A: 2’ I‘,and we may identify M with A. If we further identify Q‘x Q with Q‘, then we find that the composition f
Z’%Q
is given by
AM‘ = (Q’, 1A‘) q’0 (41,
=
q’(aA)
o)(AA‘)= (q’, 0A)A’
If Z = r a n d 1is the identity, then the above formulas imply AM‘ = M’. Assume that card Q’ = 1. We then identify Q‘ x I’ with r so that M‘ is identified with the output A’: I’ + SZ. If we further identify Q‘ x Q
8. Composition of Sequential Machines
351
with Q, we find that the composition 2%. is given by
MA'
=
(Q, LA')
( 4 , c)(AA')= ( ( q , 0)A)A'
and with action of 2 on Q unchanged. Again if r = Q and A' is the identity, then MA' = hf. If both card Q = card Q' = 1, then M = A and M ' = A' are both functions A: Z + r a n d A': r 4Q. T h e composition M M ' then coincides with the composition Ail' of functions. T h e facts listed above imply that output modules form a category that we shall denote by OM, and that the category of finite sets with functions as morphisms, is a subcategory of OM. Definitions (8.1) and (8.2) of the action and output in M M ' may be extended as (8.1')
(Q', q)s = (4'(4, s v , 4 s )
(8.2')
(q', 4, s)(AA') = (q', (4, s)A)A'
The easy proofs that (8.1) and (8.2) imply (8.1') and (8.2') (by induction on I s I ) are omitted. Observe that in the variable free notation introduced in Section 3, equation (8.2') may be rewritten as (8.2")
k ' l
Q)(AA') = ( d ) ( 4 ' A ' )
If initial states i E Q, i' E Q' are selected, then M and M ' become sequential machines 4 and ..X'. We then convert M M ' into a sequential machine A d ' by choosing (i', i) as an initial state. There results the category SM of sequential machines. Taking ( q ' , q ) = (i', i) in (8.2') we obtain the formula for the results (8.4)
&fnn.= & f & fn
This furnishes an algebraic and constructive proof that the composition of two spfunctions is again an spfunction. This fact has already been noted earlier (Corollary XI,6.4) as a consequence of Theorem XI,6.3. In a similar manner one defines the composition of generalized output modules and generalized sequential machines. Formulas (8.1) and (8.2)
XII. Operations on Sequential Machines
352
may be used as definitions, however, since (q, a)A E r”,in the expression (q’, (q, a)A)A’, 1’ should be the extended output of .d’. A more elegant procedure is to deal entirely with extended behaviors using formulas (8.1‘) and (8.2’). One then proves by easy inductions that (8.1’) indeed converts Q‘ x Q into a right Z’*module and that 11‘ is an extended output. Formula (8.4) remains valid since it follows from (8.2’). T h e categories obtained are denoted by GOM and GSM. I t should be noted that if card Q = 1, then the gomodule M or the gsmachine is identified with the extended output 1: Z‘* + P,which is a morphism. T h u s the category of finitely generated free modules becomes a subcategory of both GOM and GSM. 9. 2Categories
T h e category OM of output inonoids defined in Section 8 is for the moment unrelated to the categories OM(Z, r ) defined in Section 1 except for the fact that the objects of O M ( 1 , I ’ ) are morphisms in OM. T o complete the algebraic picture of the situation we need one more operation called horizontal composition. T o describe this composition it will be convenient to picture a statemapping Q1:
M + M ~ :2 j
by the diagram
‘2
Now given
we define
31
I’
r
9. 2Categories
353
where q’, q are states of Ad’ and h,f.T h e verification that ip x Q“ so defined is a statemapping is routine and is left to the reader.
To find the properties of the horizontal composition we consider the following five diagrams
(9.3)
(9.4)
(9.5)
From these diagrams we read of the following properties of the
XII. Operations on Sequential Machines
354
horizontal composition, which we leave for the reader to verify
(9.1’)
(a, x a,’) x a,’’
= ql x
(9.2‘)
11,w = a,
(9.3‘)
a,x 11,
(9.4‘)
1,x
(a,’ x a,”)
= a,
I h P = 1M.W
(a,xa,’)(wxw’)= (a,Y)X (v’w’)
(9.5‘)
T h e algebraic structure thus obtained is called a 2category (also called a hypercategory). T h u s OM is now a 2category. In the sequel the horizontal composition will be used only very modestly and thus the fact that OM is a 2category remains essentially a curiosity for the time being. T h e definition of the horizontal composition given above applies equally well to sequential machines and to generalized output modules and generalized sequential machines. Thus SM, GOM, and GSM become 2categories. Similarly, 2categories OM’, SM’, GOM’, GSM’ can be obtained by considering only proper statemappings. 10. Parallel Products
Given lengthpreserving partial functions fj:
Zj* + Ti*,
j = 1, 2
the function
f = fl xf,:
(El x &I*

(FI
x TZ)*
is defined as follows. Let s E (Elx Z,)*. Then we can write s = (sl, s2) where s1 E Zl*, s, E Z,*, and I s1 I = I s, I. Then
sf = ( S l f i If ,Zl
=
9
s,fA
Z, = 2, then we also define the partial function s(f1 V
f z )=
($1
7
$2)
Note that Dom(flVf,) = Domf, n Domf,. We now carry over these operations to sequential machines. Given sequential machines
Ej+rj, Jj
j = 1, 2
= (Qj, ij, lj)
10. Parallel Products
355
we define the sequential machine
d =u d l ~ Z,X ~ 2z2 :+ r l x r 2 by setting
(Qix Qz (ii > i z ) , 1)
=
9
(41 > 4 2 ) ( ~ 1 ! 0 2 )
(41 9 42 9
=
01 9
= (4101 > 4 2 a 2 )
((41>G l ) A l > (42 %)&) 1
Clearly ffl=
hlx h ,
If Zl= Z2= Z, then we also define the product
AP = ,dlv L ~z:+ rlx r2 by setting A ?
= (419
(Q, x Q 2 , (il,i 2 ) ,1') 42)a =
(QlC,
42a)
(41, 42 > a)l' = ((41, a)11, ( 4 2 9
0)12)
Clearly =iff1
V h 2
T h e two products are not independent and indeed each can be defined using the other one. Let 6: Z* + (ZxZ)* be the very fine morphism defined by ad = (a, a). Then for any Lztfl: Z + rl,dd2:Z 4r2we have (10.1)
Al v .d2= d(Jdlx A2)
Let nj:(Z,x 2,)" + Zj*, j = 1, 2, be the canonical projections. Then for any dj: Zj+Fi, j = 1,2 we have (10.2)
dlx A. = (nldl)v
(7c2d2)
There is a multitude of formal rules that the operations x and V obey with respect to themselves, each other, and the various other operations in the 2category SM. We only note the following one: If
ZjTjQj, 45 .r5
j = 1,2
356
XII. Operations o n Sequential Machines
If further Zl = Z2= Z,then
T h e above definitions apply equally well to output modules by omitting all mention of initial states. They do not apply to generalized sequential machines and generalized output modules. EXERCISE 10.1. Tabulate the formal properties of x product and Vproduct within the 2category SM.
References S. Ginsburg, “An Introduction to Mathematical Machine Theory,” AddisonWesley, Reading, Massachusetts, 1962.
This is the first treatment of sequential machines in book form, and contains a good bibliography up to 1962 and historical remarks. T h e topics covered correspond to roughly Sections XI,13 and XI1,l7. I n defining a (noncomplete) sequential machine Ginsburg and other authors do not assume that the two partial functions Q x Z Q and Q x 2 + I‘ have the same domain. This has no effect on the essential results, but produces considerable complications. f
S. Ginsburg and G. F. Rose, A characterization of machine mappings, CanadianJ . Math. 18 (1966), 381388.
Contains the main results of XI,6. M. P. Schiitzenberger, A remark on finite transducers, Information and Control 4 (1961), 1851 96.
Contains the definition of bimachines. T h e subject is also discussed by Nivat in the reference listed in Chapter IX. G. N. Raney, Sequential functions, J . Assoc. Comput. Mach. 5 (1958), 177180.
References
357
Contains the main substance of XII,34, for complete sequential machines. This is a remarkable paper since its precision and mathematical clarity are outstanding when compared with the level of writing in this subject in 1958. I t has been inexplicably ignored. Some of the concepts (the “Nerode congruence”) are usually attributed to A. Nerode, Linear automaton transformations, Proc. Amer. Muth. S o r . 9 (1958), 541544.
CHAPTER
Infinite Words
This chapter is concerned with infinite sequences of letters or digits and their interpretation as real numbers. This leads to some rather amusing contacts with topology. 1. The Sets 2~~
Given a finite alphabet 2, we shall consider the set Ev of all functions x: N  2
Such a function is nothing but a sequence Ox, lx, . . . , nx,
. ..
of elements of L' indexed by N . Omitting the commas, we shall write such a sequence as an infinite word
(Ox)(l x ) . . . ( n x ) ,
or when it is more convenient as XOXl.
Given n
E
. .x,,. . .
N , we denote by x["] the element X [ n ~= X O X I . .
.x,1
E
27
We call x [ " ]the initial segment of length n of x . If n
358
= 0,
then x[O1= 1.
1. The Sets
F'
359
I t will be useful to introduce the notation
whenever s' is an initial segment of s E Z", and to write s' < s whenever 5 s and s' f s. Given a sequence
s'
. . . <s,,< . . .
s,<s,
"
+
pv
is obtained, called the prolongation off. We assert that
(1.3)
(sf", tf")p I (s, t ) e
Indeed if (s, t ) ~: l / n , then dJi1= t [ l 1 1 . Therefore ( s f v ) [ J j l = (tf")'"] by (1.2), and thus (sf", tf"') < ljn. T h e inequality (1.3) implies that f" is continuous. I n particular, every sequential machine d': S + T yields a function fg." : S L Y

I
]'.V
Functions obtained in this fashion will be called sequential. Let 12 2 1 be an integer. Any element s of P' yields an element s' of (2)" obtained from s by partitioning it into blocks of length k . T h i s defines a bijection (1.4)
(2L)N
S A
This bijection does not preserve the distance, however, the inequality (3,
q e < l/kn
1. The Sets
361
is equivalent to the inequality ( s ' , t')? < l / n This proves that both functions s + s' and s' (1.4) is a homeomorphism.
+
s are continuous and thus
EXERCISE 1.1. Show that .Y." is a compact topological space, i.e., each injinite sequence of elements of S.\' contains a comergent subsequence. Show given by the distance coincides with the "Cartesian that the topology of .YA~ product" topology of .Y' tiewed as a product of a sequence of copies of the discrete space L.
Show that the function ,f,y': Z.' + P' can be deJined f o r any gsmachine Y : S* + IT* which is alniost positiae in the sense of Exercise XI,3.1. EXERCISE 1.2.
EXERCISE 1.3.
Given a function f : 'S f
. u:
1.y

andgiven u
+ l'y
E
Sx deJne
p
by setting s(f . u) =
(I1S)fT"L'
Show that: f . 1 f. f . (uv) = (f u ) . v. (ii) (i)
+
(iii) I f f is continuous, then so is f . 21. EXERCISE 1.4.
Call the functiotz f: .Y."
+
Pyfinitary if the family of
functions { f ~ ~ L ~ u E . Y * }
$finite. Show that f is sequential (1.5)
(sf,
iff
tf )"
f is jinitary and
5 (s, t)"
for all s, t E .Y.v, [Hint: Show that under the conditions above f is the prolongation of an initial segment and Iengtlzpreserving function g : .Y* + f*;then show that g is sequential by the methods of XII,4.] Show that f is the prolongation of a uerjl .fine morphisni g : L* f * z$f (1.5) holds and f . ii = .f f o r all 11 E S*.

XIII. Infinite Words
3 62
EXERCISE 1.5. Show that f o r any function f : Ev + Pvthe following properties are equivalent:
f is jinitary and continuous. f is jinitary and there exists an integer k 2 1 such that (s, t ) < l / ( n k ) implies (sf, tf) < I / n . (iii) f = g t k where g : EV4 P is sequential and k 2 1 is an integer. (i) (ii)
+
2. Ultimately Periodic Sequences
A sequence
x: N + Z is said to be periodic if there exists an integer
+ p ) x = nx
(n
p > 0 such that nEN
for all
If we denote s = x[p1 E Zf, then x = lim sn n+m
and we shall write x=s"
A sequence x E P' is said to be ultimately periodic if there exist integers p > 0 and no 2 0 such that (n
+ p ) x = nx
for all n
2 no
Equivalently x is ultimately periodic if
x = ts" for some t
E
Z", s
E
PROPOSITION 2.1.
and only i f for each u
Zf.
The sequence x: N S, the set
f
S is ultimately periodic
E
A,
=
is a recognizable subset of N.
ml
=
{ n I nx
=
u}
if
3. Expansion of Real Numbers
363
Proof. Assume x is ultimately periodic and let p > 0 and no 2 0 be integers such that ( n , p ) x = nx for n 2 no. It follows that
+
(2.1)
n+pEA,onEA,
for n > n o
Thus the sets A , are ultimately periodic and thus are recognizable (Proposition V,l.l). Conversely, assume that each of the sets A, is recognizable, i.e., ultimately periodic. There exist then integers p , > 0 and nu 2 0 such that n p , E A, o n E A, for n 2 nu
+
Taking p to be least common multiple of the integers p , and no to be the largest of the integers nu we have (2.1) for all 0 E Z. Equivalently ( n p ) x = nx for n 2 no. T h u s x is ultimately periodic I
+
+ P7 be a sequential function. If x THEOREM 2.2. Let f : is ultimately periodic, then so is xf E P.
E
ZaV
r
Proof. Let JH = (0,i, A): Z + be a complete sequential machine computing f , and let x = uvw with u E Z*, v E Z+. Consider the state q = iu and let n = card Q. Among the states 9, qv, qv2, . . . , 9vu"
there must be a repetition. T h u s q d Then x f = u1vIWwhere
u1 = (i, u d ) A ,
= qd+l
for some 0 5 j < j
v1 = (iuvj, v2)A
+ 1 5 n.
I
3. Expansion of Real Numbers
For any integer h > 1 the function pk: k"
+
[0, 13
is defined by the formula m
i=o
where si is the ith digit of s E kV. Since 0 5 si 5 h  1 we have
1
3 64
XIII. Infinite Words
Therefore n1
si
1 kn
(1
O l iZ =O Kif'
T h u s the series converges and spk is a real number in the closed interval [0, 11. If x E [0, 11, s E kN and x = spk,then x is called the interpretation of s and s is called an expansion of x at the base k. If s = sOsI...s,. . . , then it will be appropriate to write
x=
.SOS1.
. .s,. . .
T h e following formal rule is useful
for all s E k*, t E k". Another way of expressing the same fact is
where Ow is the function N + k with constant value 0. I n the statements that follow we denote by [XI the integer part of the real number x.
Each real number 0 5 x 5 1 has an expansion
THEOREM 3.1.
x
= .S"SI.
. .s,. . .
with so = [ k ~ ]
(3.3)
si =
[ki+lx]

k[kix]
if
i >0
This expansion is unique, except when x
=
u/k"
with u, n E N ,
0 < u < k",
u not divisible by
In this case there are exactly two expansions
(3.4)
x
=
.sdOm,
x
=
.s(d  1)(k

1 ) ~
k
3. Expansion of Real Numbers
365
with s E k",
d
E
k,
I sd I = n,
d .f 0 ,
(sd)vk = u.
The j r s t of these expansions satisjes (3.3). T h e first of the expansions in (3.4) is called the terminating expansion, while the second one is called the nonterminating one. Note that both of them are ultimately periodic. Proof.
From formulas (3.3) we deduce
Since 0<x=
[knx] kn
knx  [knx] kn
1
0 , q > 0.
Let s = uvm. If I v I = p is smallest possible, and ;f further, assuming I v I = p , I u I is smallest possible, then we say that uv" is the minimal representation of s. Show that ;f uv" is the minimal representation of s and ;f s = u'vfm,then I u I 5 I u' 1. I f , further, I u I = I u' I, then v' E v x . [Hint: Use Exercise 3.1.1 EXERCISE 3.2.
XIII. Infinite Words
368 EXERCISE 3.3.
Given any unambiguous subset A of N and given any
k > 1 consider the element
Show that s.,~is ultimately periodic zf A is ultimately periodic. Deduce that I . .A is a rational set. Show that ;f f 2 i is the generating function of A, then 1
sA4pU,, is a rational number
sAPU, = k f A ( i )
4. Infinite Digital Computation
The function
PROPOSITION 4.1.
p k : kLV+ [0, 11
is continuous and surjective. Proof.
Theorem 3.1 implies that pk is surjective. If s, t (s, t ) e
n such that an 5 C n < a p

Let d = ai'a, so that a, = a,,d. Since t,, 5 d and arltn= c,, t , , it follows that u p = and d. Since up E A+ it follows that d E A+. Thus for each n we have up E a,Af for some p > n. Since a,, E A+ it follows readily that x E A w .

3 84
XIV. Infinite Behavior of Finite Automata
T o prove (2.5) consider
x
(2.7)
=
aOal.. .a,.
..
with
a,, E A+
Suppose for the moment that the sequence {a,,} satisfies also
a,,a,,,
(2.8)

for all n > 0
a,+,
Then by iteration we have (2.9 1

a,* . .an+, a,, t~
From the definition of the set C it then follows that there exist c,, E C such that a,. . .a,, 5 c,, I a,. . .a,+,

Setting c = lim c,, we have c E C and c = a 1 a 2 . ..a,,. . . . Thus x = a,c E A+C. We must now show that given (2.7), the sequence {a,,} can be chosen so that (2.8) also holds. Given integers n, m E N , define n = m if there exists an integer p 2 n, m such that
a,,. . . a p p l
(2.10) or equivalently if

a,,, , . .appl

a[~llla[Pl a[~nlla[pl
(2.11)


Since is a finite equivalence relation in Z*, it follows that is a finite equivalence relation in N . Indeed let uA+ be the cardinality of Z*/and let n,. . .nl be integers with k = 1 uA+. Then for p 2 n , for all 1 5 i 5 k the congruence classes of the elements a[n+la[pl cannot be all distinct. Thus card N /  5 nA’. Since N / = is finite, one of the equivalence classes S of N mod must be infinite. Let k , < k, be the smallest elements in S. Assuming that the elements k, < k, < . . , < k, of S are already defined for some n > 0 define k,,,, as the smallest element of S for which (2.10) [or (2.11)] holds with n, m,p replaced by klIpl, k, , k, t l . Then setting
+
a,.
. .ako, = d k u I
b,
=
6,
= aln, . . . aEnpl=
we have b,,b,,+,

b,,,
u[knllla[knl
for all n > 0 as required.
if
n >0
2. An Auxiliary Proposition
385
I t remains to be shown that C is recognizable. T o do this we employ a general method which may be called "separation of variables." T h e essence of this method is the use of any number of disjoint alphabets El, X,,. . . each of which is in a fixed 11 correspondence with L'. For each subset S of Z*, X iwill denote the corresponding subset of Xi*. Given a factorization s = at of an element s E
Z*, we consider the element ZL =
T h e condition a
E
a,t,
.Zl*.Y2*c (2,u 2,)*
E
A+ then translates into
and this determines a recognizable subset of (XI u S,)". T o express the condition at t in terms of u we proceed as follows: Let ,3 = (Q, i, T ) be the minimal automaton of A+. T h e n the sets

[ql
= i'g,
q6
Q
are the equivalence classes of the relation . T h e condition at may now be written as

t
E
[q]
u E Z,*[ql, n ([4197+)
where p: (El u 2,)" 4 Z*is the very fine morphism which maps each letter of .XI u 1,into the corresponding letter of Z.T h u s we are lead to consider the set
D
=
u Al+[4l, n ([qlp') f/
This is the set of elements zi = a,t, with a E A+, at Condition (2.2) may be reformulated as follows:
(2.2') If t
=
bt', ab
E
A+, and t

t ' , then t
=

t.
t' and b
=
We are thus led to consider factorizations
s = abt' and corresponding elements v
= a,b,t,'
E
Z,*Z,*E,* c (El u Z3u Z2)*
1.
XIV. Infinite Behavior of Finite Automata
386 The conditions
ab E A+,
b # 1,
bt‘

t’
determine a recognizable subset E of (Zl u 1,LJ Z,)*. Imposing condition (2.2) amounts to replacing the set D by
C
 Ey
where y : (Zl u 2, u Z2)+4 (Z, LJ Z2)* is the very fine morphism, replacing each letter of 2, by the corresponding letter of Zl, and leaving alone the letters of Zland C,. Condition (2.3) is handled in the same manner. As a result we find that the set of all elements u = a$, corresponding to elements s = at E C given in a principal factorization is a recognizable subset F of (Zl v Z2)*.Since C = F ~itI follows that C is recognizable I 3. Proof of Theorem 1.4
T h e proof follows the following pattern (i)
(iv)

0 All
(ii) => (iii)
(v)
(vi) => (ii)
(i) o (ii). Let R denote the class of subsets A of Z* for which (ii) holds. We first show that G c c R. Let A E G. By Theorem 1.3, there exists a deterministic 1automaton &’= (Q, i, T ) such that A = 11 &’ 11. Define
T={XIXcQ, X n T f @ ) and let d’ = (Q, i, T). Then I/ d 11 = I d’ I and thus A E R. To prove that K c U c R it suffices to show that R is closed under complementation and intersection. Then let A = I d I with d =(Q, i, T)be a complete (deterministic) automaton with a family T of terminal sets. Let T‘ be the complement of T viewed as a subset of 29. Then setting d’ = (Q, i, T’) we find that I &’’ I is the complement Z*  A of A. Thus 2+ A E R.
3. Proof of Theorem 1.4
387
Let A , , A , E R and let
Aj
I
=
d
I,
j
d
where dj are deterministic for j
=
j
=
( Q j , ij, Tj)
1, 2. Then
=
I dI
x Q 2 , (ii
iz), T)
A, n A, with J/ =
(Qi
9
T = ( X X Y I X E T ~ , YET^} Thus A , n A , E R. To show that R c L c B consider A = I d I with d = (Q, i, T) deterministic. We note the following formulas
A = (J I ( Q , i, T)I TET
I (Q, i, T ) I where
BT =
BT  CT
u 11 (Q, i, t ) 11
te T
CT = 11

=
(Q, i, Q  T )
Thus by Theorem 1.3, A E K c ” . (ii) (iii). Obvious. (iii) (v). Let A = I d I with A = (Q, i, T) deterministic. Let T E T and let t , , . . . , t, be an enumeration of the states in T. Define
BT = I
(Q, i, t n ) I
CT = I ( T , t n , ti)
I
I ( T ,t n  1 , t,) I
Then it is easy to see that
I (Q, i, T ) I = BTC?TW and consequently
uYzl
BiCiWwhere B iand Ci are recognizable (v) =+ (iv). Let A = subsets of 2*. Without any loss we may assume that Cic Z+. Then be replacing B iby B,$( we may also assume that B i c Z+. Let 9i, normalized (not necessarily deterministic) &automata such that I gi1 = B i , I gi I = Ci for 1 5 iC n.
XIV. Infinite Behavior of Finite Automata
388
Construct the automaton &' by the scheme

with T = { t l , . . . , t , } as terminal set. Then JJd 11 = U BiCim= A as required. (iv) (iii). Let A = Jj &' )I with d =(Q, i, T ) . Define
T={XIXcQ, X n T f 0 } Then

I ( Q , i, T ) I = 11
I(
=
A
as required. (vi). This follows from Proposition 2.1. (v) (vi) * (ii). Let A = Ur=l B,C, with B , , C, recognizable subsets of S+.Since the class of sets for which (ii) holds is closed under union, it suffices to consider the case n = 1. Thus A = BC with B and C recognizable subsets of C",and with B c Z+. Let ,9?= (P ,P o , S ) , @ = (Q, 4 0 1 T ) be complete (deterministic) automata such that
I ,9I = B ,
1'8 =C
We shall consider words v in Q*, Such a word v is called simple if no letter in it is repeated. Thus there are exactly 2cardQ simple words. With ant v E Q* we associate the simple word [a]obtained from a by keeping only the leftmost appearance of any letter a appearing in v. Let v = q l . . .q,&be a simple word in Q*. Given a E Z we define
This word need not be simple and therefore we may have I [va] I < n. Let K be the largest integer 5 n such that qla, . . . , qka are distinct. This integer K will be called the index of the transition v + v o and will
3. Proof of Theorem 1.4
389
be denoted by I,,,,. Observe that 1 5 Zv,, 5 I z, I if I z, I f 0. If z, = 1 we define lu,, = 0. We now define a complete 1automaton a’= (R, r o , T) with a family of terminal sets. T h e states are triples
where p E P, v is a simple word in Q*, and 0 5 1 5 I z’ 1 is an integer. T h e initial state is ro = ( P o , 1 , O ) T h e action of Z is defined by
( P , 2.’, 1).
=
{
lu,,)
(P.9
[7301,
(P.3
[(~a>sol, 4p)
if P O $ S if Pa E s
T o define the family of sets T we consider any integer 1 5 k 5 card Q and define
D, = { ( p , z,, I )
E
R I 1 > 0 and kth letter of
z,
is in T }
{(PI 1) E R I k I I} T k = { X l X c E,, X n D k # @} T = T , u ... uT,, n = cardQ Ek =
Q,
To conclude the proof it suffices to show that
(3.1)
I LdI = Bzc
Consider a sequence x: N + 2 and let r : R + Z be the corresponding ‘ and with r i f l == r i x i . To prove sequence with ro the initial state of a equality (3.1) we must prove:
(3.2) x E BC iff there exists an integer k such that r i E E, for all i sufficiently large, and r i E D, for infinitely many indices i E N.
c.
Let ri = (pi, v i , li). Assume that x = by with b E B and y E Let = j . Since B c .2+we have j > 0. I t follows that p j E S and therefore qo is a letter of vj. Consequently qoy[)ilis a letter v ; + ~ ,say the d,th letter counting from the left. Since d,, 2 d,,,, 2 dn+, 2 . . ., it follows that there exist integers k and no such that d,, = k for all n 2 no. From the definition of the action in a’it follows that I,, 2 k for all n > no. T h u s rj+, E Ek for all n > n o . Since, further, y E C it follows that
IbI
XIV. Infinite Behavior of Finite Automata
390
qoy[nlE T for infinitely many indices n 2 no. Thus y j + , , E D, for infinitely many indices n. Conversely assume that an index i , is given such that r i E Ek for all i 2 in and that y i E Dk for infinitely many indices i. Let q be the kth letter in v i , . From the description of the automaton &' it follows that there is a factorization x = a y with I a I = J, 0 < j 5 k such that p j E S and q = q,,y[iOil. I t follows that a E A. For n 2 i,  J , qoy["1is the kth letter of vj,+,. Since infinitely many of these letters are in T it follows that y E c I Show that the construction given in the proof of (ii) applies also in the case B c 2" (rather than B c Z+)provided (vi) the initial state of A is defined as r, = ( p , , q,, 1) whenever 1 E B. EXERCISE 3.1.
4. Examples and Exercises EXAMPLE 4.1.
With C = {a, r } consider the subset
A
=
Z:"ato
of ,ZN.This is the set of all sequences x in ZNin which a appears a finite but nonzero number of times. If we consider the nondeterministic automaton
d : u , r E i ~ . t 3 r then
A
I &' I = 11 d . 1 1 =

Thus by Theorem 1.4,A E Rec". We shall now show that A is not in Rec. This will prove that the class Rec is not closed under Boolean operations. In fact we shall prove that there is no subset B of C" (recognizable or not) such that A = B. Indeed, assume that A = B . For any 0 E C we have sat* E A , and therefore sai? E B for infinitely many integers i. Let (s) be the smallest such n. Consider the elements so = 1,
sntl= ~ , a t ( ' n )
E
B
and let s = limn+ s,. Then s E B, but s E A since s has infinitely many a's. We now proceed to construct a deterministic automaton A?= ( R ,
4. Examples and Exercises yo,
T) such that A A
=
391
I d I. We utilize the representation
=
BC,
and apply the method given in the proof of (vi) complete deterministic automata are .g:
r
E
@:
T
E
j
q
+
L
P
S
3
3

C=
B = Z”O,
T*
(ii). T h e appropriate
o
0
.
T
Note that s is a nonterminal sink state; its presence is needed since 8 should be complete. From the automata R and L? the automaton a’is constructed by the method of Section 3. Only the accessible part of &’is exhibited. +
(i,1 , 0 1 3
l‘
( P , Q, 0)
This gives the following four terminal sets
XIV. Infinite Behavior of Finite Automata
392
T h e terminal sets T,', Ti', and Ti'' contribute nothing since after the states ( p ,sq, 1) or (i,sq, 2) have been reached a return to the state (i,q, 1) is impossible. T h u s T = ( T , , T 2 ) .T h e terminal set T , will yield all sequences containing exactly one (T, i.e., the set z*azw. T h e terminal set T , will yield the set ( t Q o ) ( t * a ) + t w . EXAMPLE 4.2.
Consider the deterministic automaton ,dgiven by
. C P + q 3 r with the family T consisting of the two singletons p and q. T h e n
I ,31 = P z I " This is the set of all words in Z.vin which (T appears only a finite number of times. This differs from the preceding example only by the fact that there (T had to appear at least once. EXERCISE 4.1. Show that for any subset A of S.v the following conditions are equivalent:
(i) A is an open subset of Z.+' (in the topology defined in XII1,l). (ii) A =/ B E v for some B c 1". (iii) A = BEv for some prejix H c 3.
Show that A is open and closed zff in either (ii) or (iii) B may be chosen to be jinite. EXERCISE 4.2.
Assume
A,
=3
A,
3
are open subsets of Ev and let B,,
A,
. ..
3
A,,
for all n E N
Consider the set =
(J B,Z" nsN
and brove that
...
. . . , B,, , . . . be prejixes such
= BJN
C
3
that
393
References
Use Exercises 4.1 and 4.2 to prove that a subset A of is a Gb (i.e., an intersection of a sequence of open sets) zff A = f o r some C c S*. EXERCISE 4.3.
c
References R. McNaughton, Testing and generating infinite sequences by a finite automaton, Information and Control 9 (1966), 521530.
This paper contains the main definitions and results of this chapter, as well as references to earlier work at Biichi (1962) and Muller (1963). T h e history of the subject is neatly outlined. McNaughton did not have Proposition 2.1 and thus had to prove the implication (v) (ii) directly [rather than in steps (v) (vi) (ii)]. This put very heavy demands on the proof. T h e argument given by McNaughton is very informal and to some extent inaccurate (but repairable).


M. 0. Rabin, Automata on infinite objects and Church’s problem, Anrer. Math. Sor. Regional Conference Series in Mothenintics 13 (1972), 122.
Correct proofs of the implication (v) = (vi) 3 (ii) are given and are credited to Y. Choueka (unpublished). ’I’he proofs are virtually identical with those in this chapter that were found independently by M. P. Schutzenberger jointly with the author. €I. I,. Landweber, Decision problems for 0)automata, Math. Svstems Theory 3 (1969), 376384.
This is the source for Exercises 4.14.3.
CHAPTER
xv kRecognizable Sequences
T h e study of krecognizable sets started in Chapter V is continued here. In addition to the notion of a krecognizable subset A of N , the closely related notion of a krecognizable sequence x: N + Z is introduced where 2 is a finite alphabet. 1. kRecognizable Sequences
We shall relate the sequences x : N .Z with the notion of krecognizable sets studied in V,3. A sequence f
x : N+.Z
is said to be krecognizable, where k > 1 is an integer, if for each the set A, = 0xl = {n I nx = CT}
0E
2
is krecognizable. An analogous definition was made in XII1,2 with “krecognizable” replaced by “recognizable.” Proposition XI1 I,2.1 then asserted that the class of ultimately periodic sequences was obtained. EXAMPLE 1.1. Let A bc a subset of N and let x : N acteristic function, i.e., 1 if X E A nx={ if x $ A
+
2 be its char
Then A is krecognizable iff x is a krecognizable sequence. 394
1. kRecognizable Sequences
With each x E relation in N
395
P' (and with k > 1 fixed) we define the equivalence nNZm,
n,mE N
by the condition
(krn +j)x
=
(krm +j)x
for all r
E
0 < j < kr
A',
PROPOSITION 1.1. The sequence x: N Z is krecognizable if and only if the equivalence relation mr in N is finite, i.e., if the quotient set N / w Xis finite. f
Proof. For each u
E
2 define the equivalence relation in n, m
n N,m,
N
N
E
by the condition
(krn +j)x
= uo
(k'm
+ j)x = c
for all r
E
N , 0 < j 5 kr
Then n w Xm holds iff n w0m for all u E 2. Consequently the equivalence wZis finite iff the equivalences o are finite for all u E 2. However, the finiteness of w , is exactly the condition for the krecognizability of the set A, = axI (see Proposition V,3.3) I
A krecognizable sequence x: jective and if for all n, m E N nx
N
= mx
f
Z will be called generic if it is sur
2
n
m
NZ
T h e opposite implication holds for all x E it is surjective and
nx
=
mx

(kn
E".Note that x is generic iff
+ j)x = ( k m + j)x
T H E O R E M 1.2. A sequence x: N i f it admits a factorization
+
for all 0 i j < k
Z is krecognizable
if and only
N L r A Z where T is finite, y is a generic krecognizable sequence, and
CI
is a function.
XV. k Recognizable Sequences
3 96
Proof. Assume that such a factorization is given. Since n u m holds iff ny = my it follows that the equivalence relation n N u m is finite and thus y is krecognizable. Since
ax1
=
aaly1
z
uw  I
a=ya
it follows that x = y a is krecognizable. Conversely assume that x is krecognizable. Then the equivalence relation wZ is finite. Let T = N / w Z and let y: N + be the natural factorization function. Since n mZm implies nx = mx it follows that there is a unique function 01: r 2 such that x = ya. T h e verification that y is generic is left to the reader I
r
f
A generic krecognizable sequence will be called a “kgeneric sequence” for short. They will be studied more intensively in the next section. EXERCISE 1.1. Given a sequence x : N + Z dejine the truncation N + Z by setting nxr = ( n + 1)” for all n E N . Show that is krecognizable zff x is.
XI:
X I
EXERCISE 1.2.
Given sequences xl: N + Z , ,
x2: N + Z z
dejine x: N
+
nx
( n x l , nx2)
Show that x is krecognizable
iff
=
L’,xZ2
both x1 and x2 are krecognizable.
EXERCISE 1.3. Modify the dejinition of the equivalence relation wZ so as to apply to the case of recognizable sequences. Obtain the analogs of Proposition 1.1 and Theorem 1.2.
2. kGeneric Sequences
There are two methods (in addition to the basic definition) of describing kgeneric sequences and a skillful manipulation of these descriptions can be used to prove many properties. Let x: N  2
397
2. kGeneric Sequences
be kgeneric. We convert S into a complete right kmodule by setting
aj = ( k n
+ j)x
for
a
E
S, j E k
provided a = nx
Such an n exists since x is surjective and the choice of n is immaterial since nx = mx implies (kn + j ) x = ( k m j)x. If we set a. = Ox, then we find
+
We assert that S as a kmodule is accessible from
(2.2)
a&"
=
go,
i.e., that
,r
Indeed, let a E Z. Since x is surjective we have a = nx for some n E N . Assume n > 0 and write n = n'k j with n' E N and 0 5j < k and let a' = n'x. Then a'j = a. Since n' < n the argument can be continued by induction. Since j is the last digit in the standard expansion of n at the base k, the same argument also proves
+
(2.3 1
0"s =
( s Y ) ~
for all s E k"
where v : k" + N is the standard interpretation defined in V,2. Conversely if S is given as a complete right kmodule and a. E Z is such that (2.1) and (2.2) hold, then (2.3) can be used to define x: N 4 2. I t is easily seen that x is kgeneric which yields the same kmodule structure on S as the one given at the start. As an application of this module language we prove: PROPOSITION 2.1. For each kgeneric sequence x: N p 2 1 szich that
an integer
(nkp)x = (nk")x for all n Proof.
E
N. We have
(nx)O = ( n k ) x and therefore (nx)Or= (nkr)x
4
S, there exists
XV.
3 98
kRecogn izab le
Seq uences
Since the function f:Z + Z defined by uf = (TO is an element of the finite monoid of all functions Z + Z it must have an idempotency exponent, i.e., an integer p 2 1 such that f p = f 2 p T o introduce the next method for treating kgeneric sequences we consider the morphism
(2.4)
w : Z*+Z"
defined by
(2.51
(nx)w = (kn)x(kn
+ 1)x.. .(kn + k

1)x
= (X[knl)lX[k(n+l)l
or in module notation (TW
=
u01.. .(k  1)
T h e following properties of w are clear
For the iterates of w we then obtain u0wn =
Consequently (To
x[k"l
< (Tow < . . . < (Town < * . .
and
(2.8)
x = lim n+w
dkn] =
lim(uown) n+m
T h e fact that x is surjective implies:
(2.9) There exists an integer n 2 1 such that cown contains all the letters of Z. Conversely, given a morphism (2.4) satisfying (2.6), (2.7), and (2.9),
3. Examples and Exercises
399
formula (2.8) defines a kgeneric sequence x for which ( 2 . 5 ) holds. Thus w and x mutually determine each other. T h e morphism w will be called the generator of x. As a consequence of this discussion we obtain: PROPOSITION 2.2. Each kgeneric sequence x: N + 2 is also kqgeneric for all q > 1. If w is the generator of x as a kgeneric sequence, then wq is the generator of x as a bgeneric sequence I
3. Examples and Exercises EXAMPLE 3.1.
k
=
2, 2 = 2, o0 = 0, o w = 01,
Then
owz
= 0110,
l w = 10 oW3=
oiioiooi
T h e 2sequence x = limOwn = 0110100110010110..
.
nfcu
is known as the “Thue sequence.” An alternative description may be obtained as follows. Let 1: 2” + 2” be the very fine morphism defined by jn = 1  j for j = 0, 1. Then x is defined by the conditions
ox = 0,
X[2n+11
= x[zn~(x[zn~)~
EXAMPLE 3.2. If in the example above we replace lw by 01 (instead of lo), we obtain the sequence x = 010101..
. = (0l)W
Thus x is the characteristic function of the set of all odd numbers in N . EXAMPLE 3.3. Let k > 1 and define x: N 4k by setting nx to be the first digit in the expansion of n at the base k. Thus nx = j iff n = jkp 1 with 0 5 1 < kp. Define w: k + kk by
+
Ow=Ol,..(k1), Then x
=
lim,,,,
jw=jk
Ow” so that x is kgeneric.
for
O<jo,q 2 0
Thus composition of K[[x]]morphisms can be expressed equivalently by multiplication of power series. 2. Linear Sequential Machines
Let &: A
+B,
A = (Q, i, A)
2. Linear Sequential Machines
409
be a complete sequential machine defined without any finiteness conditions on A, B, and Q. We shall now assume that A, B, and Q are modules over a given commutative ring K, that the functions (2.1) and (2.2) are Kmorphisms (i.e. are Klinear) and that the initial state i is the element 0 of Q. Subject to these assumptions we shall say that . X is a linear sequential machine (or more precisely a Klinear sequential machine). With the assumptions above, (2.1) and (2.2) yield
qa
=
qF
(9, a>A = qff
+ aG
+ aJ
for some Kmorphisms
F: Q+Q, H: QB,
G: A + Q
J: AB
We may combine the functions (2.1) and (2.2) into a single function
and this leads to the notation
for a linear sequential machine. This notation will be favored in the sequel. T h e result of the linear machine is the function
which may be describcd as follows using the sequence notation. Given an input sequence
a
=
( u o , a1, . . . , a , , , . . .)
there corresponds a state sequence
XVI. Linear Sequential Machines
410
and an output sequence b
=
af
=
(b,), b , , . . . , b,, . . .)
given by the formulas
We now prove that
f
(2.5)
is a K[[z]]morphism. T h e fact that f is a Kmorphism is clear from formulas (2.4). We must show that f commutes with the shift, i.e. that (az)f = ( a f ) z . T o see this observe that if we replace a by
az
=
. . .)
(0, a,, a,, . . . , a,,
then it follows from formulas (2.4) that the state sequence is replaced by 91,
('9
' " 9
qJ19
"')
and the output sequence by
bz
(0, b,, b , , . . . , b,, . . .)
=
as required.
We now evaluate f for the special input sequence
a
=
( a , 0, . . . , 0, . . .)
T h e state sequence becomes q
=
(0, aG, aGF, . . . , aGFn,,
. . .)
and the output sequence is
af
=
(aJ, aGH, aGFH, . . . , aGFnlH, . . .)
T h u s in the power series representation off
2 m
f
=
fnz71
ll=O
we have
(2.7)
fo = J ,
f J ,
=
GF"'H
for n > 0
2. Linear Sequential Machines
41 1
Observe that if Q = 0 (the trivial Kmodule, not the empty set!), then automatically F = 0, G = 0, and N = 0. T h e K[[z]]morphism f : A[[z]] + B[[z]] is then the coordinatebycoordinate extension of J : A + B. Thus with the convention of Section 1, we have f = J . T h e machine with Q = 0 will be simply denoted by J : A + B. For any linear sequential machine A: A + B as above, it will be convenient to refer to the Kmorphism J : A 4B (involved in the definition of &) as the direct part of d. T h e machine A is said to be jinite if [Q:K] < 00
I f f : A[[z]] + B[[z]] is the result of a finite Klinear machine A, then we say that f is Ksequential. For any Kmorphism f : A 4 B, the coordinate by coordinate extension f: A[[z]] + B[[z]] is sequential, Indeed, the requisite machine A has Q = 0, J = f. Let Qi
B
be two linear sequential machines with the same direct part J . A staterelation v: Al +A2 is given by a relation P:
Qi
+
Q,
satisfying the following conditions
(2.8) (2.9)
G2
= GlV,
PF2
41P
+ 41'P
= Fly, PH2 = Hl = (Q1+ Q1')Y'
Stated in terms of the graph # y , conditions (2.8) and (2.9) may be rewritten as follows
XVI. Linear Sequential Machines
412
This alternative form of the definition makes it clear that the inverse pl of a staterelation also is a staterelation. It is also clear that the
composition of staterelations is a staterelation. PROPOSITION 2.1. If a staterelation cp: A,+ d2exists, then A1 and k2 haae the same result. Conversely, i f d, and k2 have the same result, there is a maximal staterelation y : Al + d2containing all others. + A2is a staterelation. Since Proof, Assume that cp: d, d2have the same direct part it suffices to show that
(2.10)
G,F,"'H,
=
G2F,"lH2
Aland
for all n > 0
Since these are functions it suffices to show
GaF;;lIHZc GIF;'Hl This follows from (2.8). Indeed,
Conversely, assume (2.10) and define y : Ql + Q2 by setting #y = {(q,, qa) I q l F , i t l l = q2FZiH2
for all i 2 O}
Conditions (2.8.2), (2.8.3), and (2.9') are then clearly satisfied. Condition (2.8.1) follows from (2.10). + A2is any other staterelation, and if ( q l , qz) E #p, then If q : kl it follows from (2.8.2) and (2.8.3) that q l F l i H l = q2F2'H2for all i 2 0. Thus ( q l , Q%)E # y and cp c y as required 1 Note that the maximal staterelation y also satisfies
Note also that condition (2.9) did not yet intervene. It will however be needed in Section 5. T h e staterelation p: A', +=d2 will be called a statemapping if p: Q1 + Q2 is a partial function. If further p is a function (i.e. if Don1 cp = Ql), then we shall say that cp is a complete statemapping.
3. The Free Case; Comparison w i t h Automata
41 3
3. The Free Case; Comparison with Automata
We shall now concentrate on the case when both Kmodules ‘4 and B are finitely generated and free. Thus we may assume that

KP,
A
B
Kr
A Kmorphism y: A B may then be viewed as a pxrmatrix of elements of K, i.e. as a single element of K P X r . A K[[z]]morphism

f : A“,]]
B“z1l
c fnz’l m
f
=
rr=l
may then be regarded as an element of K ~ ~ . ~ [ [ z i.e. ] l , as an infinite sequence of pxrmatrices. However, we shall prefer to regard f as a pxrmatrix of elements of K[[a]]. ‘The components of this matrix will be denoted by f u g for , 1 5 u S p , 1 5 v 5 r. PROPOSITION 3.1. I f f is sequential, then it is the result of a jinite machine in which the state module is free.
Proof. Let KP k” be a finite sequential machine with state module Q and data F , G, H , J . Suppose that [Q:K] = 7n. There is then a surjective Kmorphism pi: KiIL 9. Since Ksf is free and y is surjective, the diagram f


may be completed to a commutative square by some Kmorphisln
F ‘ : A”” Krif.For the same reason we can find G : KP 4 Kr” so that G = G’p. Finally define fZ‘ = FZZ: k”“ + K r . T h e data F ‘ , C‘, H ’ , J yield a sequential machine .A’’: KI1+ k” with KitLas state modules. Clearly p: %,H’+ J?’ is a complete state mapping. ’Thus by Proposition 2.1, JH and 4’ have the same result I Let us now consider a linear sequential machine
.A:KT’

K‘
XVI. Linear Sequential Machines
414
with state module Kmand without a direct part (i.e. with J = 0). T h e data G , F and H of ~d' may thus be regarded as matrices in K of sizes p x m, m x m, and m x r . Consider an alphabet S consisting of a single letter a and define a Kaautomaton d of type ( p , Y) (see III,13 and VI,6) as follows. T h e states of JY' are (1, . . ., m } = Q', and the transition matrix is E = Fa. If we write G as a column
then each row G , E K"1 (1 5 u 5 p ) may be viewed as a Ksubset of Q'. Those are the initial states. Similarly H is written as a row
. . . , H,]
H = [H,,
with each column HI,E Km(1 5 u 5 r ) . These are the terminal states. T h e behavior I d I is a matrix [A,,,]where A,,,,is the behavior of the automaton (Q', G,, H,) and is a Ksubset of as. Let A,,, be the same . Ksubset regarded as an element of K [ [ z ] ]Thus m
Juv =
C
auonzn
n=O
where aur,nis the value of A,,, on an. We have by Corollary VI,6.2
A,,
=
G,EsHv =
2 G,EnH,
n=o m
=
C
G,FnH,a*
n=O
and therefore
aulln= G,F"H,, Since this is the coefficient of znfl of f f L lwe , obtain
(3.1)
fuv =
Auvz
T h e above construction establishes a 11 correspondence between Kaautomata ,d of type ( p , Y) and sequential machines ./& KP Kr without a direct term and with a finitely generated free state module. As a corollary of the above discussion we obtain f
4. Duality
415
PROPOSITION 3.2. A function
viewed as a matrix j = [ fiL,,]of elements of K[[z]] is sequential if each f,L7,is Krecognizable.
if and only
For the proof we only need to observe that A,,, is Krecognizable iff is Krecognizable, and that the matrix f = [ f,,,] is Krecognizable by an automaton of type ( p , Y ) iff each j u tis, Krecognizable 1
a,,,,
We recall that the Krecognizability of j,,, E K[[z]] is equivalent with the rationality of f u r in the sense of Kleene and also with its rationality in the sense of algebra (see VII,3). We shall return to this matter in Section 9 where the questions of rationality will be studied in greater detail. 4. Duality
Given a Kmodule A we shall denote by A^ its dual, i.e. the Kmodule of all Kmorphisms u : A + K. For a Kmorphism p: A + B, the morphism
p: B  A is defined by setting
BQ, = 9iB for each
E
8.Clearly
if p is surjective, then 47 is injective. Also if
w?4, then 9" = p i 2 p i 1 ' If A is a Kfree with a finite basis v l , . . . , v P ,then with a dual basis 8,, . . . , 8, defined by 4p =
V.V.= 1
J
{i
if if
i = j i+j
PROPOSITION 4.1. If K is noetherian and
then so is
A^ also is Kfree
A^ is jnitely Kgenerated,
A.

Since A is finitely generated there exists a surjective morphism A , for some p 2 0. Then y': A^ + I?. KP is injective. Since K is noetherian and is a submodule of a finitely generated Kmodule, it follows that A^ itself is finitely generated 1 Proof.
p:
KP
4
a
XVI. Linear Sequential Machines
41 6
PROPOSITION 4.2.
Let Q
B
be a Ksequential machine with result
M
Then the Ksequential machine
If further K is noetherian and .X is finite, then T h e first part follows from the observation that second part follows from Proposition 4.1 I
is finite.
f,l = I?PnIC. T h e
T h e assumption that K is noetherian is not needed when A = K P , = K7, and Q = Km. If relative to given bases in A , B, and Q we express G, H , and F as matrices, then with respect to the dual bases in A, B, &, the morphisms I?, and P are simply the transposed matrices. Th u s each f , Lalso will be the transpose of fn, when both f n and f,l are treated as matrices.
B
e,
5. Minimization
Given a Kmodule B we consider the Kmorphisms

zl: B[[z]J B[[z]]
nn: B [ [ z ] + ] B
for
0 5n
5. Minimization by setting for b
41 7 =
xzob,,a"
c bn+p, Do
bz1
=
bn,, = b/,
/1=0
We note the following identities
Since the operator z was called the right shift, the operator be called the lejt shift. Let
Q
zl
should
B
be a Ksequential machine. We consider the Kmorphisms
G:
A[a]
+
Q,
Ej: Q
+
B[[z]]
defined by
(az")G= aCF"
a
E
A
all q
E
Q
for all
qR = C qF"Hztl
for
T h e machine . // is said to be accessible (the term reachable also is used) if _C is surjective. T h e machine . J is said to be reduced (the term observable also is used) is €7 is injective. If / i is both accessible and reduced, then ./2 is said to be minimal. These notions require some explanation and amplification. Let 0.l be the image of G. Clearly 0.l is the Ksubmodule of Q generated by the Ksubmodules I
AG, AGF, L4CF2, . . . , AGF", . . . We call Qzi, the accessible part of Q . Since Q;'F c AG c Q:', there results a sequential machine
B

0;i F;l H." : A  B A GiL J
Ql1
and since
XVI. Linear Sequential Machines
418
with F i ,Ga, H'l defined by F , G, H . T h e machine Ail is accessible and is called the accessible part of d. If d is reduced, then A is both accessible and reduced and thus is minimal. Since the inclusion Qll c Q defines a state mapping .&;14A (and the inverse of this inclusion defines a state mapping A + &:I), it follows that .Xa and d have the same result. If d is finite, i.e. if [Q:K] < 00,then it is not necessarily true that [ Q * : K ]< 00. If however K is noetherian, then [Q:K] < 00 implies [ Q " : K ]< 00. Summarizing we obtain For each Klinear sequential machine A the accessible part is an accessible machine with the same result as A. If & is reduced, then A:1 is minimal. Ifd is finite and K is noetherian, then d" is jinite I PROPOSITION 5.1.
Let R
=
Kernel
R
R, i.e. =
{q I qF"H
=
0 for all n 2 0 }
If we replace Q by p = Q I R and define F', G', H r appropriately, we obtain the reduced sequential machine
dd' =
p
Fr H r
: A+B
T h e natural factorization morphism called the reduced quotient of ,d. Q Qr defines a complete statemapping d + d rand we have f
PROPOSITION 5.2. For each Klinear sequential machine A, the re
duced quotient &' is a reduced machine with the same result at d . If & is accessible, then d'is minimal. If Ji is finite, then so is d r I
We shall now consider two Klinear sequential machines Aland .A2 with the same result. By Proposition 2.1 there exist then staterelations
We conserve the notations of Section 2 and denote by staterelation.
ly
the maximal
5. Minimization
419
PROPOSITION 5.3.
Q,*
c Dom p.
Proof. From (2.8.1) it follows that AG, c Dom p. Further (2.8.2) implies that
AC,FlrEc Dom p
for all n 2 0
Condition (2.9) (used here for the first and only time!) implies that
AG,
+ AG,F + . . . + AG1Fr1c Dom p
for all n 2 0. Thus Ql* = I m _Gl c Dom p COROLLARY 5.4.
I
If Al is accessible, then Q1= Dom p I
PROPOSITION 5.5. If =A?.. is reduced, then p is a statemapping (i.e. p: Ql + Qz is a partial function). Proof. Assume q 2 , qzrE qlp, or equivalently ( q l , q2), (ql, q Z r )E #p. From (2.8.2) and (2.8.3) we deduce
q2FziHz= qlFliHl = qztFZiHz Thus (qz  qZr)n2 = 0 and since Azis reduced, qz = qzr
I
is reduced, then p is unique THEOREM 5.6. If A, is accessible and k2 and p: Q, + Q z is a Kmorphism. If, further, ,dl is minimal, then 4p is injective and if Azis minimal, then p is surjective. If both ,dl and =A?.. are minimal, then p is an isomorphism. Proof, By Proposition 5.5, p is a partial function and by Corollary 5.4, Dom p = Q,. Thus p: Q1 + Q2is a function. Since the same holds for the maximal staterelation y and since p c y , it follows that p = y. Since y satisfies [see (2.9) and (2.11)] QlY
+ QZY = + 4Z)YY (Q1
it follows that
and thus p is a Kmorphism.
(QlYP =
(41+fJ
420
XVI. Linear Sequential Machines
If LK?l is minimal, then, by Proposition 5.5, p' is a partial function and thus p is injective. If .d2is minimal, then, by Corollary 5.4, Dom ~ 1  l= Q, and thus rp is surjective 1 C O R O L L A R Y 5.7. Two minimal Klinear sequential machines with the same result are isomorphic I
We now turn our attention to the question of existence of a minimal Klinear sequential machine. We start with an arbitrary K[[z]]morphism
f: A"z1l

f = nc= O
B"z1l
m
We define the Kmorphism
3: A[zI
fizzn

B"xl1
by setting
for all a
E
(5.1)
A. Clearly azf=
afz1
for all a
E
A[z].
Let
Qr = I m a g e r Equation (5.1) implies Qrz' c Q f . We now define the machine
by setting qFf = q2I
for all q
E
Qf
co
aGr = a f =
C
af,1+lz71 for all
a
n=O
qHr
=
qn,,
for all q
Jr = f o
E
Qf
E
A
421
5. Minimization THEOREM 5.8.
..Hfisa mininzal Klinear sequential machine with result f .
Proof. Since qH, sequently, for n 2 1
=
qno, it follows that a”H, = u” ”n,, = x,,.Con
( , ~ ( a f i + l z L ) ) n l ,  ,afn c.0
aG,F;’H,
= aG,z”’~’n,, = u G , ~ ~ ,= ,,
=
k=O
and thus ./, has f as result. ‘The function G,: A[.] 0, coincides with the function f: A[,] B [ [ z ] ]and since Q, = ImageJ it follows that G, is surjective. T h u s .,Hf is accessible. Assume q E 0,is such that qn, = 0. T h u s qFf”11, = 0 for all n 2 0. Since F/”€lf= z”Hf = 7c,, it follows that q7cn = 0 for all n 2 0 and thus q = 0. Consequently d, is reduced I f
f
COROLLARY 5.9. If K is noetherian and f : A [ [ z ] + ] B [ [ z ] ]is sequential, then d, is jinite. I
Indeed, let .dbe a finite machine with result f. Then, by Proposition 5.1, ,&:*is accessible and finite. Thus, by Proposition 5.2, kar is finite. Since A,, Kf is finite I EXERCISE 5.1. I n the machine A? assume that a state q,, E Q rather than the state 0 is chosen as initial state. Show that the output sequence corresponding to a single input a E A is given by
Use this observation to show that the reduced machine coincides with that considered in Chapter LYII. EXERCISE 5.2. Let
as defined here,
dbe a Klinear machine with result
Show that if FP = 0 , then f I l = 0 for all n > p . Show that the converse also holds if ~ 6 is ? minimal.
422
XVI. Linear Sequential Machines
EXERCISE 5.3. Show that the Kmorphisms characterized by the following conditions aG = aG
G, R
a n d f are completely
for all a E A
z_G = G F
qRn, = qH Fly
for all q
Q
= Rzl
af = (a&’
zf
E
for all
aEA
=fz1
6. Parallel Composition
Ai =
Fi H,. ’ : A+B, Gi Ji
QL
A
Qi
Fi 0 Hi Fz H2
.A?= Qz 0
T h e Kmorphisms G: A
G = [Gi, Gz]: A
f
+
i=l,2
:
AB
Q and H : Q + B are given by QlxQ2,
H=
:I[
Q1xQ2+B
Clearly, if Al and d. are finite, then so is A. If f i and fzare the rethen f i f z is the result of A. This implies sults of dland d.,
+
6. Parallel Composition PROPOSITION 6.1.
423
If
f i : A[[z]]

i = 1, 2
B[[z]],
are Ksequential functions, the so is f i + f2
1
The state module Q of a sequential machine comes equipped with a Kendomorphism F : Q Q. It will be convenient to regard Q as a K[z]module by setting q z = qF. I n this sense the state module of the machine dl A, is 0, x Q 2 , a direct product of K[z]modules. Using this notion, the construction of dl d2 may be inverted. +
+
PROPOSITION 6.2.
+
Let I
Q
B
be a Ksequential machine and assume that
+
is a direct product of K[z]modules. Then d = Al A, where d, and .d2 have state modules Q1 and Q 2 . Further, ;f d is accessible or reduced, then the same holds for dl and dz. Proof, Since Q = Q l x Q Z as a K[z]module, the morphisms F , G, H , of the machine ~ z have f the form
A with Fi:Q i Q i , Gi: suffices to define +
+
Q i ,Hi: Qi
B Fi Hi

B for i = 1, 2. Thus it Qz
Qi
B

If A i s accessible, then G: A[z] + Q is surjective. Since G = [G1, G2], it follows that Gi: A[z] + Qi are surjective and thus dland A. are accessible. If .Iis reduced, then f7:Q + B[[z]] is injective and the same holds for Ri: Qi B[[z]], i = 1,2. Thus dland A, are reduced 1

XVI. Linear Sequential Machines
424 COROLLARY 6.3.
Assume that K is noetherian. Let

f : "I1
mz11
be a Ksequential function and let Q f = QixQz
be a direct product decomposition of Qfas a K[z]module.Then f = f i where f i : mz11 B"zl1

+f z
are Ksequential functions, such that QJ,
for i = 1, 2
Qi
I
7. Series Composition
Let
be Ksequential machines. T h e sevies composition or simply composition = Al J 2is defined as follows
A?
Qz
QI
C
F, 0 Hz H,G, F, H,J,: A + C A?= Q1 Qz
7. Series Composition
425
Clearly if .A', and tY2 are finite, then so is T h e reader mill easily verify that this definition of composition agrees with the definition given in XIII,8 for sequential niachines. This iniplies that the result
.f: "I1
+
C",Il
is the composition
(7.1)
A"z]]
L R"s]] & C"Z]]
of the results of A, and .A2. This can also be checked by an explicit calculation. This implies PROPOSITION 7.1.
I f f l (2nd f 2 in (7.1) are Ksequential, then so is
f =f,fi I T h e state module of A?' = d l,,ff2 is
when viewed as a Kmodule. Its endomorphism I: is however given by the matrix
I:= [ F z
H,G,
"J F,
T h u s viewed as K[z]modules, Q2 is a submodule of Q while Ql is a quotient module. In other words we have an exact sequence
0 +Q2+ Q
+
0, t o
of K[,]modules. This exact sequence splits when regarded as a sequence of Kmodules. These remarks show how to invert the construction of
.&TI..y,. PROPOSITION 7.2.
Let
Q
be a Ksequential machine over and let
C
XVI. Linear Sequential Machines
426
be an exact sequence of K [ z ]  m o d ~ ~ l esplit s , over K. Then H . d'; /i'i where d',:A B, .//;: B + C have state modules 0, , Q2. Further, d is accessible or reduced, theii the same holds for //, and . /LL. :
~
f
~
Proof. Since the csact sequence splits over K , we may assume that
Q = Q2XQI as a Kmodule. T h e Kendomorphisin F of Q then takes the form
where F,, F , are Kendomorphisms of Q Z , Q, while I,: Ql Kmorphism. Explicitly, F is given by (42,
4,)F
=
(q2F2
4QIL, q , F d
I t follows that 11.1may be written as Q2
QI
C
We now consider the machines
Q, F , H ,
A;= Qi L
H , : Qlx A
+
C
+
0, is
a
8. T h e Case W h e n K Is a Field COROLLARY 7.3.
427
Assume that K is noethevian. Let f : A".]]

C".]]
be a Ksequential function and let
Be an exact sequence of K[,]modides split over K. Then f is the composition A".]]
5 B".]]
11,C[[z]]
wheve g and h are Ksequential and
EXERCISE 7.1.
Cavvy ouer the formalisms of XII,9 and 10 to thepres
ent situation. 8. The Case When K I s a Field
So far finiteness assumptions have played a rather secondary role in our discussion. We shall consider questions in which finiteness is quite basic. We shall assume in this section that K is a field. Let Q be a K [ z ] module such that [ Q : K ]..: 00. Consider a direct product decomposition
p5.0, M
(8.1)
' . . M Q,,
of Q as a K[r]module. Assume that none of the modules Q,, . . . , Q,, is trivial and that n is largest possiblc. It follows that each Q , , . . . , Q,, is an indecomposable K[,]modulc, i.e. admits no direct product decomposition 0, = Q,' x 0," in which 0,' and 0,"are nontrivial. Since [Q:K] 00, it is clear that such a optimal decomposition (8.1) exists. I t is also known (this is the RemakKrullSchmidt theorem) that, except for the order of factors, it is unique. T h e structure of an indecoinposable K[z]module Q is completely K[.] which is ruled out by the assumption known. Either Q [ Q : K ].00 or else < _

Q = K[zll(P")
XVI. Linear Sequential Machines
428
where p is an irreducible rnonic polynomial in K[z], u is a positive integer, and (p") is the principal ideal in K [ z ] generated by p7'. If u = 1, then the module K [ z ] / ( p )is simple, i.e. it has no K[z]submodules except itself and zero. If u > 1, then we have in K [ x ] / ( p " ) the chain of submodules
T h e consecutive quotients are for 0 5 k
(1 I .2) * (1 1.3) are clear. T h e implication (1 I .3) 3 (11.1) follows easily from Proposition 10.1. If conditions (11.1)( 11.3) hold, then 1 is said to be integral over K. The elements of L that arc integral over K form a subring K L of L and
T h e ring K L is called the integral closiire of K in L. I n the rest of this section we shall assume that the ring K is entire (i.e. is a commutative ring in which u / ! = 0 implies a = 0 or 0 = 0). We donote by 0,the field of quotients of K . T h e integral closirve of K in 0,; is dcnoted by 1.We say that K is intepally closed if K = R . PROPOSITION 11.I. Let K be integrally closed and let p , q E Qli[z] be irioriic polytionzials. I f p y E K [ 2 ] ,then p , q E K [ z ] . Proof.
Let n
d e g p and let I, be an extension field of Q!; in which
7 .
p splits. Since p is monic, we h a w p(.)
= (z

I , ) . . . ( z  1,J
XVI. Linear Sequential Machines
438
with I , , . . . , l,, E Z,. Since 11, . . . , I,, are also roots of the polynomial pq E K [ z ] ,it follows that I , , . . . , 1,, are integral over K. T h u s the elementary symmetric functions of I , , . . . , I,, are integral over K and consequently the Coefficients of p are integral over K. However they are in QKand since K is integrally closed, they must be in K. T h u s p E K [ z ] COROLLARY 11.2. Let K be integrally closed and let p , q E $Il;[.] be polynomials such that p ( 0 ) = q(0) = 1. Zf pq E K [ z ] , then p , q E K [ z ] .
Apply Proposition 11.1 to the nionic polynomials
fi
and @ noting that
P@=E € Let
PROPOSITION 11.3.
II E
(11.4)
Q,. The condition CI
E
R
implies (11.5)
There exists d
E
K

0 such that du"
E
K for all n 2 0.
If K is noetherian, then (1 1.5) inzplies (1 1.4). Proof. Assume iL E R. Then for some integer m > 0, urnis a linear combination with coefficients in K of 1, ( x , . . . , ixlnl . It follows that d Lfor any n 2 0 is a linear combination with coefficients in K of 1, (1, . . . , (x7tL 1. Let u = a/b with a, b E K and let d = bnh l . T h e n (11.5) holds. Now assume that K is noetherian and that (1 1.5) holds. Let V = d'K be the least Ksubmodule of Q, containing &I. Since (x" E V for all n 2 0, it follows that K[ix] c V . Since K is noetherian, it follows that [ K [ u ] : K< ] 00, and thus rx E R
T h e entire ring K is called completely integrally closed if conditions d E K 0, da"
E
K
U E Q ~ ;
for all n 2 0
imply a E K. Proposition 11.3 implies PROPOSITION 11.4. Each comnpletelv integrally closed ring K is integrally closed. The converse also holds ;f K is noetherian €
12. The Main Rationality Theorems
439
12. The Main Rationality Theorems
With the preparation of Section 11 the main results concerning rationality may now be stated. THEOREM 12.1 (KalmanRouchaleauWyman) Let K be an entire noetlzerian ring, let a E K[[z]] be a formal power series rational over QK and let q E Q,[z]be its lowest denominator. Then a is rational over K and
q E R[z]. THEOREM 2.2 (Chabert) Let K be a completely integrally closed ring, let a E K[[z]] be a formal power series rational ooer QK and let q E Q,i(z) be its lowest denominator. Then a is rational over K and q E K [ z ] . T h e proofs of both theorems are deferred until the next section. If K is noetherian and integrally closed, then both theorems yield the same conclusion. In particular, if K = 2, they yield the Lemma of Fatou mentioned in VIII,4. Note the subtle difference in the conclusions of the two theorems. I n the second theorem q E K [ z ] and thus q is necessarily the lowest denominator of a . In the first case q E I[ and , thus if K is] not integrally closed q need not be in K [ z ] .T h u s the lowest denominator of a over K may have a degree higher than that of q. We shall show that this indeed takes place whenever K is not integrally closed. We now show that both theorems are, each in its own way, the best possible ones. For this assume
dEK duil E

K
0,
11
E PI;
for all
n
20
Consider the formal power series
Since
(1

ux)a
=
d
it follows that a is rational over Q,< and that q = 1  uz is its lowest denominator. Assume that the conclusion of Theorem 12.2 holds. Then q E K[z] i.e. rx E K . T h u s K is completely integrally closed.
XVI. Linear Sequential Machines
440
Now assume that K is noetherian but not integrally closed. Choose R  K. Then by Proposition 11.3, d as above exists. Theorem 12.1 ensures that IX is rational over K . However q = 1  uz is not in K [ z ] and thus the lowest denominator of a over K will have to have degree > 1 and will be a multiple of q.
cx
E
A D D E N D U M TO THEOREMS 12.1 AND 12.2. Both theorems remain
valid for a
E
K"[[z]].
For v = 1, the statement reduces to Theorems 12.1 and 12.2. We now assume v > 1 and proceed by induction. T h e power series a defines two power series a' E K [ [ c ] ]and a" E K"'[[Z]], both of which are rational over &. Let q, q', q" be the lowest denominators of a, a', a". Since q'q" is a denominator of a, it follows that q divides q'q". T h u s qt = q'q" for some t E Qli[z]. Since q(0) = q'(0) = q"(0) = 1 it follows that t(0) = 1. By the inductive hypothesis q', q" E R[z]and thus qt E R[z].Corollary 11.2 now implies q E R[z] I Proof.
13. Proof of Theorems 12.1 and 12.2
We consider the formal power series M
a =
C
aizi E K [ [ z ] ]
1=U
d=
a, a ,.
a, a,
aml a , is nonzero.
aW1 . * . am s..
azm2
13. Proof of Theorems 12.1 and 12.2
441
0 . Then for some 0 5 zi i m the row a , ) , . . . , ,O,i of earlier rows. We thus obtain a polynomial Indeed assunie d
=
a,,, ,,11 is a linear combination with coefficients in
(13.3)
+ PI."' + . . . t
y
PI>
such that
holds for all 0 5 t < m. However formula (13.2) implies that if (13.4) holds for any m consecutive integers then it also holds for the nest higher one. T h u s (13.4) holds for all t 2 0. Consequently (13.3) is a complete recurrence polynomial of degree zi , m , contradicting the minimality of m. For each i >_ 0, we consider the column vector
so that
We shall consider vectors
made u p of integers
For each such vector we consider the square matrix
obtained from the m x ( m
+ r)matrix
by removing the columns with subscripts
vi=m+riji
XVI. Linear Sequential Machines
442
Note that O