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 IIArmi
W. Vrcrc. Homology Theory : Ail Introduction to Algebraic Topology JAMES E. R. KOLCHIN. Differential Algebra and Algebraic Groups GERALD J . J A N U S ZAlgebraic . Number Fields A . S. B. Hior.i.ANu. Introcluction to the Theory of Entire Functions A N U DALEVARUKIIG. Convex Functions W A Y N EROBERTS A. h4. O s ~ r a o w s ~Solution r. of Equations i n Euclidean and Banach Spaces, Third Edition of Solution of Equations and Systems of Equations SAMUEL EILENBERG. Automata, Languages, and Machines : Volume A H. M. EDWARDS. Riemann's Zeta Function I I I freparatiorr WILHELMMAGNUS. Non-Euclidean Tesselations and Their Groups J . D I E L T D O Nl rNe a~t.i s e on Analysis, Volume IV bfcmws HIIISCH A X I I S n i r J i i r i N SMALE. Differential Equations, Dynamical Systems, and Linear Alg-ebra
AUTOMATA, LANGUAGES, A N D MACHINES VOLUME A
Samuel Eilenberg COLl~MI3I.A IINIVEI<SI'I'Y
NEW Y O R K
ACADEMIC PRESS New York and London A Sirbsidinry of Hnrcoitrf Brnce J o z m w v i c l i , Piiblisliers
1974
COPYRIGHT 0 1974, BY ACADEMIC PRESS. INC. ALL RIGHTS RESERVED. NO PART O F THIS PUBLICATION MAY BE REPRODUCED OR TRANSMIlTED IN ANY FORM OR BY ANY MEANS, ELECTRONIC OR MECHANICAL, INCLUDING PHOTOCOPY, RECORDING, OR ANY INFOR hlATlON STORAGE AND RETRIEVAL SYSTEM, WITHOUT PERMISSION IN WRITING FROM THE PUBLISHER.
ACADEMIC PRESS, INC.
I 1 1 Fifth Avenue, New York, New
York
10003
United Kingdom Edition published b y ACADEMIC PRESS INC. (LONDON) LTD. 24/28 Oval Road, Londo; N W I
LJBRARY OF CONGRESS CATALOG CARDNUMBER:72-88333 AMS (MOS) 1970 Subject Classifications: 94A25 94A30, O2Fl0 PRINTED IN THE UNITED STATES OF AMERICA
This P a ge Intentionally Left Blank
Contents
PREFACE
...
. . . . .
Xlll
. . .
. . . . . . . . .
1
. . . . . . . . . . . . . . .. . .
. . . . . . . . .
2 3 6
. . . . . . . . . . . . . . . . . .
CHAPTER I Preliminaries
. 1. 1;unctions . . . . . . . Relations and Partial Functions 3 . Monoids . . . . . . . . . . 4. Categories . . . . . . . . . 5 . Equivalences and Congruences 6 . Miscellaneous Conventions . . References . . . . . . . . . 2.
. .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
12 15 17 21 24 26 29
1. Basic Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 2 . T h e Subset Construction . . . . . . . . . . . . . . . . . . . . . 3 . T h e Division Calculus . . . . . . . . . . . . . . . . . . . . . . .
30 32 34
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . . .
. . . . . . . . .
. . .
. . . . .
. . . . .
8 10 11
CHAPTER I1 Automata and Recognizable Sets 1 . Basic Definitions . . . 2 . Examples . . . . . . . 3 . Operations o n Automata 4. Accessibility . . . . . 5 . Finiteness and Iteration 6. L o c a l S e t s . . . . . . References . . . . . .
. . . . . . . . . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
CHAPTER I11 Deterministic Automata
vii
Contents
viii 4. State-Mappings . . . . . . . . . . . . . . . . 5 . Minimal Automata . . . . . . . . . . . . . . 6 . A Decision Problem . . . . . . . . . . . . . . 7 . Examples . . . . . . . . . . . . . . . . . . . 8 . T h e Quotient Criterion . . . . . . . . . . . . 9 . Right Congruences . . . . . . . . . . . . . . 10. T h e Syntactic Monoid . . . . . . . . . . . . . 11. Examples of Syntactic Monoids . . . . . . . . 12. Generalization to Arbitrary Monoids . . . . . 13. Automata of Type ( p , v) . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
38 43 49 51 55 59 61 65 68 72 74
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
76 78 80 83 88 91 92 97 99
CHAPTER I V Structure of Recognizable Sets 1. 2. 3. 4. 5.
Unitary Sets . . . . . . . . . . . . . . . . Prefixes . . . . . . . . . . . . . . . . . . Unitary Monoids . . . . . . . . . . . . . . T h e Decomposition Algorithm . . . . . . . Bases of Unitary Monoids . . . . . . . . . . 6 . Iterated Up-Decomposition . . . . . . . . . . 7 . Maximal Prefixes . . . . . . . . . . . . . . 8 . Recurrent States . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
CHAPTER V The Integers 1. T h e M o n o i d N . . . 2 . Integers at Base k . 3 . &Recognizable Sets . 4 . Iteration . . . . . . 5 . Gap Theorems . . . 6 . Other Interpretations 7. Coding . . . . . . . References . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
100 103 106 110 111 115 117 118
1 Multiplicity in Automata . . . . . . . . . . . . . . . . . . . . . . 2. Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 . K-Subsets . . . . . . . . . . . . . . . . . . . . . . . . . . . .
120 122 126
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . .
CHAPTER V I Multiplicity
.
Contents
ix
4. Relations and Functions . . . . . . . . . . . . . . . . . . . . . . 5. Monoids and Matrices . . . . . . . . . . . . . . . . . . . . . . . 6. 7. 8. 9. 10. 11. 12.
K-C-Automata . . . . . Recognizable K-Subsets . T h e Equality Theorem . T h e Case K = N . . . . T h e Division Theorem . T h e Subtraction Theorem Undecidable Propositions . References . . . . . . .
. . . . . .
129 133 135 139 143 147 150 153 155 158
. . . . . . . . . . . . . . . . .
159
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
CHAPTER V I I Rational Sets 1. 2. 3. 4. S. 6. 7. 8. 9. 10.
. 1 -Algebras . . . . . . . . . . . Rational K-Subsets . . . . . . . Rational Expressions and Identities Locally Finite Monoids . . . . . Kleene's Theorem . . . . . . . . I, inear Equations . . . . . . . . Examples . . . . . . . . . . . . Unambiguous Rational Sets . . . T h e Semirings N and .I" . . . . Generalized Automata . . . . . . References . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . 163 . . . . 166 . . . 170 . . . 17.5 . . . 179 . . . 182 . . . 186 . . . 188
. . . . . . . . . . . . . . . . .
191 194
. . . . . . . . . . . . . . . . .
CHAPTER V I I I An Excursion into Analysis 1. 2. 3. 4.
Generating Functions . . . . K-Recognizable Power Series . T h e Case When k' Is a Ring T h e Case h'= Z . . . . . . 5. Positive Analytic Functions . . 6 . R+-Recognizable Functions . . 7 . Behavior of Coefficients . . . 8. Bernouilli Distributions . . . 9 . Prefixes and Bases . . . . . References . . . . . . . . .
. . . . . . . . . . . . . . . . . . . 195 . . . . . . . . . . . . . . . . . . . 199 . . . . . . . . . . . . . . . . . . . 204 . . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
207 208 215 219 223 227 235
CHAPTER IX Rational Relations 1. Definitions and Examples . . . . . . . . . . . . . . . . . . . . . 2 . First Factorization Theorem . . . . . . . . . . . . . . . . . . . .
236 240
Contents
X
3. 4. 5. 6. 7 8. 9.
.
Evaluation Theorem . . . . . . . . . . . . . . . . . . . . . . . . Composition Theorem . . . . . . . . . . . . . . . . . . . . . . . Second Factorization Theorem . . . . . . . . . . . . . . . . . . . I.ength.I’reser\. inF Relations . . . . . . . . . . . . . . . . . . . . A Cross-Section Theorem . . . . . . . . . . . . . . . . . . . . . Rational Partial Functions . . . . . . . . . . . . . . . . . . . . . Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . .
242 245 248 252 256 258 261 265
CHAPTER X Machines 1. Basic Definitions . . . . . . . . . . . . . . . 2 . Automata as Machines . . . . . . . . . . . . . 3 . Transducers and Rational Relations . . . . . . 4. Accelerated Transducers . . . . . . . . . . . . 5 . Positive Rational Relations and Transducers . . 6 . Two-way Automata . . . . . . . . . . . . . . 7 . Other Machines . . . . . . . . . . . . . . . . 8 . Deterministic Machines . . . . . . . . . . . . 9 . A Conversion Theorem . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . 266 . . . . . . 271 . . . . . . . 272 . . . . . . 276 . . . . . . . 279 . . . . . . 282 . . . . . . 286
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
288 292 295
CHAPTER XI Sequential Machines 1.
2. 3. 4. 5. 6. 7. 8. 9.
Basic Definitions . . . . . . . . . . . . . . Notation and Interpretation . . . . . . . . . Properties of Sequential Functions . . . . . Digital Computation . . . . . . . . . . . . . State-Dependent Sequential Machines . . . . Recognition of gsp-Functions . . . . . . . . . Sequential Bimachines . . . . . . . . . . . . Examples of Uimachines . . . . . . . . . . . Proof of l’heoreni 7.1 . . . . . . . . . . . .
. . . . . . .
. . . . . . .
. . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . 296 . . . . . . . 300 . . . . . . . . 306 . . . . . . . 309 . . . . . . . . 312 . . . . . . . 314 . . . . . . . 320 . . . . . . . 322 . . . . . . . 325
CHAPTER XI1 Operations on Sequential Machines 1. 2. 3. 4.
State-Mappings . . . . . . . . . . . . . . . . . . . . . . . . . . Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . Minimal gs-Machines . . . . . . . . . . . . . . . . . . . . . . .
330 333 335 338
Contents 5. 6. 7. 8. 9. 10.
xi
Decision Problems . . . . . . . . . . . . T h e Strong Minimization Problem . . . . T h e Synthesis Problenl . . . . . . . . . . Composition of Sequential Llachines . . . 2-Categories . . . . . . . . . . . . . . . Parallel Products . . . . . . . . . . . . . References . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
341
. . . . . . . . . . . . . 343 . . . . . . . . . . . .
348
. . . . . . . . . . . . . 349 . . . . . . . . . . . . 352
. . . . . . . . . . . . . . . . . . . . . . . .
354 356
CHAPTER XI11 Infinite Words 1. 2. 3. 4. 5. 6.
TheSetY1 . . . . . . . . Ultimately Periodic Sequences Expansion of Real Numbers . Infinite Digital Computation . T h e Peano Curve . . . . . . T h e Hilbert Curve . . . . . References . . . . . . . . .
. . . . . . . . . . . . . . . . . . . 358 . . . . . . . . . . . . . . . . . . . 362 . . . . . . . . . . . . . . . . . . . 363 . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
368 371 376 378
CHAPTER XIV Infinite Behavior of Finite Automata 1. 2. 3. 4.
Main Definitions and Results . . . . . . . . . . . . . . . . . . . . An Auxiliary Proposition . . . . . . . . . . . . . . . . . . . . . . Proof of Theorem 1.4 . . . . . . . . . . . . . . . . . . . . . . . Examples and Exercises . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . .
379 383 386 390 393
CHAPTER XV k-Recognizabl e Sequences 1. 2. 3. 4.
k-Recognizable Sequences . . . . . . . . . . . . . &Generic Sequences . . . . . . . . . . . . . . . Examples and Exercises . . . . . . . . . . . . . . k-Recognizable Sequences and Sequential Functions References . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . .
. . . . .
. . . . . 394 . . . . . 396 . . . . . 399 . . . . . . 401 . . . . . 404
CHAPTER XVI Linear Sequential Machines 1. Algebraic Preliminaries . . . . . . . . . . . . . . . . . . . . . . . 2 . Linear Sequential Machines . . . . . . . . . . . . . . . . . . . .
405 408
xii
Contents
3. 4 5. 6. 7. 8. 9. 10. 11. 12.
T h e Free Case; Comparison with Automata . . . . . . . . . . . . . Quality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . Parallel Composition . . . . . . . . . . . . . . . . . . . . . . . . Series Composition . . . . . . . . . . . . . . . . . . . . . . . . T h e Case When K Is a Field . . . . . . . . . . . . . . . . . . . Rationality and Recurrence . . . . . . . . . . . . . . . . . . . . . Sequential Functions and Rationality . . . . . . . . . . . . . . . . Integral Closure and Entire Rings . . . . . . . . . . . . . . . . . T h e Main Rationality Theorems . . . . . . . . . . . . . . . . . .
13
Proof of Theorems 12.1 and 12.2 . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . 440
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
447
.
.
413 415 416 422 424
427 431 433 437 439 444
Preface
T h e last twenty years have brought forth a body of research known under the names of the theory of a~ctomntnand the theory of formal languages. Both topics are closely related and form a distinct part of what is rather nebulously described as “computer science.” They are made up of a body of mathematical objects, theorems, and methods of proof that are essentially algebraic, bordering on logic. Many of the published results show motivations specific to the interests of their authors and these were frequently very varied-to mention a few: logic, linguistics, theory of communicatjon, programming, electronic circuits, and even models for neurophysiology. It appearcd to me that the time is ripe to try and give the subject a coherent mathematical presentation that will bring out its intrinsic aesthetic qualities and bring to the surface many deep results which merit becoming part of mathematics, regardless of any external motivation. This work, planned in four volumes, of which this is the first, proposes to cover a major part of the field. A serious effort has been made to include most of the interesting results. However, restraint had to be used since many of the ramifications, if pursued too far, would lead to many highly specialized researches, far away from what can be discerned as the principal objectives. Although these principal objectives have not been specifically named, I hope that the reader will acquire the perspective that I tried to impart to this work. One very characteristic feature of the subject should be mentioned here. All the arguments and proofs are constructive. A statement asserting that something exists is of no interest unless it is accompanied by an algorithm (i.e., an explicit or efl‘ective procedure) for producing this “something.” Thus, each proof is also an algorithm. Usually, but not always, the simplest proof also gives the most efficient algorithm. xiii
xiv
Preface
I n some parts of the work, minimizing the length of the algorithm is, in itself, a legitimate objective. Contrary to what might be expected of an abstract mathematician, I have refrained from carrying the various developments to their ultimate generality. Quite to the contrary, I have intentionally refrained from generalizing the various developments beyond their original motivations, except when such generalizations actually helped to streamline the structure. I have placed the proofs in the center of my concern. T h e various arguments and constructions that occur in the field were carefully analyzed and digested. Propositions that have multiple use have been identified, and the definitions, notations, and terminology were chosen so as to achieve efficient proofs. T h e resulting economy of space has permitted me to give in most cases complete proofs rather than proof outlines, which are frequently a fashion in this field. T h i s restructuring of the material along lines normally practiced in algebra has not only retained the original motivations, but has frequently had the effect of reinforcing them. Some results were considerably strengthened and new ones have been found. This work is addressed both to pure mathematicians and to computer scientists. T o the pure mathematician, I tried to reveal a body of new algebra, which, despite its external motivation (or perhaps because of it) contains methods and results that are deep and elegant. I believe that eventually some of them will be regarded as a standard part of algebra. To the computer scientist I tried to show a correct conceptual setting for many of the facts known to him (and some new ones). ‘This should help him to obtain a better and sharper mathematical perspective on the theoretical aspects of his researches. T h e volume at hand (Volume A) consists of the study of mathematical structures (sets, functions, and relations) that can be described (or recognized) by finite state devices (i.e., automata deterministic or not, with or without outputs) without auxiliary memory or storage capacity. We use the term “rational” for these structures. T h u s rational sets, rational functions, and rational relations will be investigated. T h e use of the term rational is in my opinion amply justified by the connections with rational numbers, rational functions, and solutions of systems of linear equations, that will be demonstrated in the text. These rational notions form the cornertone of the entire structure. Kleene’s Theorem of Chapter VII occupies a place of honor in this volume. T w o novel features of Volume A should be mentioned. One is the
Preface
xv
general notion of a ninchine defined in Chapter X. This seems to be a very efficient tool that will be used extensively in Volumes C and D. T h e second novel feature worth mentioning here is the way multiplicity is handled. When one has a set A defined by some explicit device (e.g., automaton, machine, grammar, or system of equations), the verification that an element n is in A involves a procedure which may be called a “computation.” When for a given a two (or more) such essentially different computations exist, it is natural to assign to a a “multiplicity” which is the number of ways by which the given algorithm leads to the conclusion ‘ ‘ a E A.” I n Chapter VI is developed a method that permits us to study sets equipped with a multiplicity function alongside ordinary sets, in a manner which is effortless and efficient. Volunie B will delve rather deeply into the various subclasses and hierarchies that occur within the rational domain. T h e main feature here is the Krohn-Rhodes theory and other similar developments. This volume is heavily algebraic. T h e subsequent Volumes C and D move from the rational upward. T h u s they depend on Volume A but are totally independent of Volume B. Volume C starts out with a hierarchy (called the rational hierarchy) of the nonrational phenomena ; this is achieved by using rational relations as a tool for comparison. Rational sets are at the bottom of this hierarchy. Moving upward one encounters “algebraic phenomena,” which differ from the rational in that algebraic equations rather than linear equations are solved. This leads to the context-frce grammars and contest-free languages of Chomsky, and to several related topics. Volume D moves u p higher in the hierarchy and reaches the level that we call “computable.” This level can equivalently be described by general grammars, ‘I’uring, Post, and other machines, by Markov algorithms as well as by recursiveness. At this stage, the hierarchy established using rational relations loses its grip and a new hierarchy based on recursive relations takes over. This leads straight into some of the topics in mathematical logic and is outside the purviem of this work. This book presupposes no prior knowledge of the theory of automata or of algebra or for that matter of anything else. What is presupposed is the general mathematical culture on the level of a mathematics major. T h e chapters carry roman numerals and Theorem 2.3 of Chapter I1 will be referred to in later chapters as Theorem II,2.3. At the end of most chapters the reader will find a section called References. This will be a melange of terminological remarks, credits for specific items in the chapters, occasional suggestions for further reading,
xv i
Preface
and a short annotated bibliography. References to earlier work are skimpy. T h e main reason for this is my ignorance of the proper sources; many of the items were reconstructed from scratch or from hearsay. There is an index at the end of the volume, but no general bibliography. Calvin C. Elgot of the IBM Corporation is responsible for attracting me to this new field. I am deeply grateful. T h e reader will find that the name of M. 1’. Schutzcnberger is often mentioned as author (or coauthor with me) of many of the new results or proofs that appear in this volume; most have not been previously published. However, his contributions went much beyond that; virtually every phase of the development presented here was endlessly discussed with him. I am, however, the only one to blame for any shortcomings. I a m also pleased to acknowledge the help furnished in various degrees by Bret Tilson, Rudolf E. Iialman, Eduardo Sontag, Walter S. Brainerd, Martin Golumbic, and Viera Krnanova. Many thanks are due to the Mathematics Branch of the Office of Naval Research and to Dr. Leila D. Bram who for a number of years have very patiently supported my research. I am certain that despite all the care given to the preparation of this volume, the attentive reader will find many (small, I hope) slip-ups that should be corrected and local improvements that can be made. I shall be most grateful to all those that will take the trouble to communicate them to me.
CHAPTER
I Preliminaries
1. Functions
Given sets S and 1’ we shall use the notation
f: X +
1’
or
A- f Y
to denote a function defined for all K E S and with values in 1’. If g: Y + Z is another function, we denote by fg: X Z the cornposition ---f
.fg:
T h u s for each M
E
f s+ Y 5z
A‘ we have
(fg)(.)
=g(f(*y))
With this notation, the parentheses around x may be omitted, but the other pair must be kept. An alternative notation would write the function symbol after the variable. In this notation, . fg may be written unambiguously without parentheses. ‘The last notation has the following added advantage: l’hc element’ v E X may be interpreted as a function x: I + X, where I is some set containing a single element and the value of the function is s. Then &Yfgis the composition of functions
I”-
- 1 f- 41’”.
z
In the sequel we shall use the second notation and write xf for the value of the function f at x. 1
I. Preliminaries
2 2. Relations and Partial Functions
For any set “i we denote by -? the power set of S,i.e., the set of all subsets of A‘ (including the empty subset (;J). Each element x of X will be regarded as a subset consisting of a single element. With this convention we have X c A relutiorz f from &Yto J’, written f : S I’, is a function
‘v.
.f:
(2.1)
-?
+
P
which is completely additive, i.e., which satisfies
where { , 4 , I i E I } is a family of subsets of -Yindexed by some set I , and U stands for the union. Note that \-;f<$. I n view of this additivity, f is completely determincd by its values on single element subsets, so that f niay be viewed as a function
Coinposition of relations is defined in the obvious way using the original dcfinition (2.1). ‘I’he graph #f of a relation f : -Y - + I’ is defined as a subset of - Y x I’ as follows: #f = {(s,v ) I y E .yf 1 Clearly, every subset of S,.I’ is the graph of some relation from &Yto 1‘; thus # is a bijection (i.e., a 1-1 correspondence) between the relations f : S I’ and the subsets of .Y/ 1’. This leads many authors to define a relation *Y+ I’ as a subset of zI-\17. We prefer to separate the notion of a relation from that of its graph for the following reason: A subset of the product S r Y Y Z (treated associatively) will be the graph of a relation S + I’ ’Z and also of a relation S / I’ + Z . These two relations may have quite different properties. For any relation!: S + I‘, the i w e r s e relation f - I : J’ S is defined by -f
4
yf
{YIY€,Yf}
‘l’hus the graph # f c J’x A‘ is obtained from the graph # f c S:.: Y by an interchange of coordinates.
3. Monoids
3
T h e domain of a relation f : X
4
1' is defined as
PI relation f: A' 4 IT is called a partial fiinction if for each x E X the set xf has at most one element. If xf has cxactly one element, then f is a function. T h u s a partial function f is a function iff Dom f = S. A function f : S- J 7 is said to be injective if x, f x p implies x, f f x2f. l'he function f is said to be surjectiue if -Yf = Y, i.e., if every 31E T', = .yf holds for at least one $2' E .Ti'. I f f is both injective and surjective, then f is said to be bijective. T h e inverse f-' is then also a bijective function and the composites # - I : S + X, f -tf: I' 4 I' are identity functions. T h e term surjecticye will also be used for partial functions f : X Y provided A f = 1.. Given g, f: S + 1' we write g c f if xg c xf for all x E S. This is equivalent with the inclusion of graphs #g c # f . I f f is a partial function, this implies that g is a partial function and that xg = xf whenever xg f 13. However, we may have xg = ~3and xf f If both g and f are functions, then g c f implies g = f. --f
a.
EXERCISE 2.1. Given relations f :
S
,'T g : I.'+ Z, verifr
4
3. Monoids
A monoid consists of a set M and a function
The function is not given any name and the image of the pair ( m , , m,) under this function is denoted by m , m 2 . T h e following axioms are postulated :
(3.1) Associativity: For any m , , m , , m3 E M (m,m2)m, = ml(mpm3)
I. Preliminaries
4
(3.2)
U ~ i t :There exists an eIenient 1 E ic3 such that lnz for all m
E
=
nz
=
ml
M.
It is easy to see that the unit element 1 is unique. Indeed if 1' is another unit element for M , then 1' = 11' = 1. We shall use the same letter 111 to designate the monoid as well as its underlying set. If M , hi" are monoids, a niorpkisrri T: Ad -+ M ' is a function satisfying the following conditions.
(3.3)
(m,m,)p
=
(m,p)(m27i)
(3.4)
ly
for
all m , , nip E M
1
More precisely the last formula should be written l.,{y~= l.,,, . However, we shall follow the general habit of using the letter 1 to denote the unit element in any monoid, unless this symbol has another meaning in the same context. T h e composition of two morphisms
M L M I L 111'1 is again a morphism
M%
MI1
Given two subsets S,E.' of a tnonoid M , the set 'Yl' is defined by
x I'
= {xy
It is easy to see that this definition converts the set !Tiof all subsets of M into a monoid. T h e unit element in A'?? is the set 1 consisting of the unit element of M alone (in general wc shall not distinguish between an element and the subset consisting of this element alone). A subset T of a monoid Ad is called a szibmonoid if
where 7'" = T T . I t is important to observc that we require the submonoid T to contain the unit element of M . For example, the set of all non-empty subsets of M is a submonoid of A?!.
3. Monoids
5
For any subset -4 of a monoid
A"
=
IM, the set
1 u A v .42 u . . . v A'' v
where A"+l A " J , is a submonoid of IM and is the least submonoid of M containing '4. :
We shall now list a number of monoids that we shall encounter most frequently. For any set S,the set of all relations f : .Y + S with the composition of relations as defined in Section 2 is a monoid R X . T h e unit element of this monoid is the identity function 1, : S -+ S.Partial functions and functions form submonoids PF-Y and F S of R X . Further submonoids of FLYare obtained by considering injections, surjections, and bijections. is finite, T h e submonoid of all bijections of ,Y is a group. Usually if this group is called the permutation group of X. Given any set V, the free nzonoid V" with base V is defined as follows. T h e elements of 1"are n-tuples
of elements of 1.T h e integer n is called the length of s and is denoted by I s 1 . If t = ( T I , . . . , T , , ~ )is another element of I",the product st is defined by concatenation, i.e.,
This clearly produces a monoid with 1 = ( ) (the only 0-tuple) as unit element. Clearly I st 1 = I s I I t I and I 1 I = 0. We shall agree to write CT instead of the 1-tuple ( 0 ) . In this way ( 3 . 5 ) may be written as s = cr, . . . g,,
+
if n .\0. Because of this, the element s is called a zuord of length TG, while cr E .Y is called a letter, and V itself is called an alplmbet. T h e convention CT = ( 0 ) permits 11s to trcat S as a subset of I". This justifies the notation L*, as indced L* is the only submonoid of S* containing S. T h e basic property of the free monoicl I*is that any function .? M, where M is a monoid, admits a unique extension to a morphism --f
I"+ M . Let s E I".An element t
E
I"is a sepnent of s if s
=
zctv for some
I. Preliminaries
6
u, v E P. If u = 1, then t is an initial segment; if v = 1, then t is a terminal segment. Observe that t = 1 or t = s are not excluded. I'" be a morphism of free monoids with bases C and I', Let f : ,Z* respectively. Such a niorphism is completely determined by the elements af E P for a E I.If of E 1 u I' for all a E 2, then f is called a fine morphism; a fine morphism then maps letters of C into letters of f or into 1. If of E I' for all (T E Z, then f is said to be very Jine. Occasionally we shall also consider semigroups. A semigroup differs from a monoid only by the omission of axiom (3.2). Thus every monoid is a semigroup but not vice versa. T he notion of a morphism of semigroup is defined as for monoids but (3.4) is omitted. If A is a subset of a semigroup S , then --f
A + = A u A ' u . . . uA'&u . . . is the least subsemigroup of S containing A. I n particular
i.e., L'+ consists of all words of strictly positive length.
Show that $ A is any subset of L'" such that A" = Z", then Z c A. Thus Z is the smallest subset of C" generating Z*, Show that the covresponding statement for free groups is false. EXERCISE 3.1.
EXERCISE 3.2. Let s = u,v, = u,v, be two factorizations of s E 2". Show that there exists a unique factorization s = x y z such that either u1 = x , v1 = y z , u2 = x y , v2 = z or u1 = x y , vl = z , uo = x , vp = y z . 4. Categories
Although this book will not use category theory as a systematic mathematical tool, many of the notions that we shall consider lead to categories and it will be convenient and useful to identify them as such and use an appropriate terminology. Thus even though category theory will not be used, the language of category theory will be adopted whenever applicable. We therefore give here the relevant definitions. A category A consists of the following data.
(4.1)
Objects: a class Obj A, the elements of which are called objects of A .
7
4. Categories
(4.2) Morphisms: a function which to every ordered pair ( A , B ) of objects of A assigns a set A ( A , B ) ; the elements f E A ( A , B ) are called nzorpkisnis from A to B. We frequently write f : A -+ B or A B instead off E A ( A , B ) . (4.3) Conzposition: an operation of composition which to each consecutive pair of morphisms
. 4 -/ B L C assigns a morphism fg: A - C
These primitive terms are subject to the following axioms.
(4.4) Associativity : Given morphisms /
A-BLC-D
h
we have
( fgV
= f ( g h)
(4.5) Identity: For each object A , there exists a morphism 1,1: iz + A such that l Afl = f for every morphism f : A for every morphism g: C 4 A .
+
B and glAL =g
,
We note that 1 is unique. Indeed, if 1:4: A + A were another such identity, then 1 = 1.,11, = 114 . A subcategory A' of a category A is a category such that
,
(4.6) Obj A' is a subclass of Obj A . (4.7) For iZ, B in A', the set A ' ( A , B ) is a subset of A ( A , B ) .
(4.8) T h e composition of morphisms in A', is that of A. (4.9) For A in A', 1 , is in A'(A, '4). -4 subcategory A' of A is said to be a fulI subcategory if A'('4, B ) A ( A , B ) for A , B in A'. Thus, a full subcategory is obtained by restricting the class of objects. An example of a category is the category R of relations. T h e objects are sets and the morphisms in R(X, 1') are all the relations f : X Y, with composition being composition of relations. Partial functions yield =
--f
I. Preliminaries
8
a subcategory P of R, the functions yield a subcategory F of P. These are not full subcategories. Another example of a category is the category Sgp of semigroups. T h e objects are semigroups and the morphisms are as defined in Section 3 . Monoids form a subcategory Mon of Sgp. This is not a full subcategory since for a morphism Q': M + M ' of monoids we require 1p = 1, while a morphism of semigroups need not have this property. T h e category of groups is a full subcategory Gp of Mon. This results from the observation that if cp: M 4 M ' is a morphism of monoids, and M and M ' are groups, then cp automatically satisfies m-lp = ( m p ) - l and thus p also is a morphism of groups. All these are examples of large categories in which the objects form a class which is not a set (in the sense of Bernays-Godel-von Neumann set theory). Categories in which the objects form a set are called small. I n the sequel we shall encounter mostly small categories. There is a close connection between categories and monoids. Indeed, let A be a category with a single object A . Then all the morphisms of A are of the form p: A 4A and A(A, A ) is a monoid which may be identified with the category A . T h u s a category appears as a generalization of the notion of a monoid. A morphism f: A + B in a category A is called an isomorphism if there exists a morphism g : B -+ A such that both compositions f A-B -A
0
and
U B-A -B
f
are identity morphisms. The morphism g is easily seen to be unique and is usually denoted by f-'. EXERCISE 4.1. Let f: A + B and g : B C Be isomorphisms (in a category A ) . Show that fg: A -,C is an isomorphism and that ( f g ) - ' = g-tf-1. 4
5. Equivalences and Congruences
A relation Y : X + X is called an equivalence relation if it satisfies the following conditions
l s c r ,
-
Y - ~ C Y ,
wcr
-
Instead of writing x p E x , r we write x1 -r x2 (or x1 x p mod r , or just x2 if no confusion is caused). Conditions above then take the more
x,
5. Equivalences and Congruences
9
familiar form .z'
x1 - x 2
x
implies
and
x, - x ,
-
x2
-
x,
imply
x., -xg
x, -x3
I t follows from these conditions that for any two elements x,, x2 of X the subsets s , r and s , r are either equal or disjoint. These are the equivalence classes of S mod r . T h e set of all these equivalence classes is denoted by X / r and is called the quotient of X mod r . T h e function n: X 4 X / Y which sends x into xr is called the natural factorization mapping. It should be observed that any covering of S b y disjoint and non-empty sets determines a unique equivalence relation in S for which the given sets are exactly the equivalence classes. Let f : X I' be a function. T h e non-empty subsets of 2Yof the form yj-1 determine an equivalence relation in S called the kernel o f f (notation: Kerf). T h u s x, x2 mod K e r f holds iff x,f == x 2 f . T h e function f then admits a unique factorization --f
-
x -L s / K e r f L
Y
where g is a function. Further the function g is injective. T h e function f itself is injective iff Iier f is the identity relation l.y in which case Xjls = Let r be an equivalence relation in a monoid M . \Ye say that 1' is a congruence in III if ( m l r ) ( m 2 r )c (m,7n2)r
x.
for all m l , m.,E M . An equivalent formulation is m,
-
nil'
and
-
m.,
m,'
imply
m,m,
-
Still another equivalent forniulation is
m,
- m2
implies
mnil
-
mm.2 and
m,m
m,'m2'
-
mzni
T h e fact that the product (m,r)(m.,r) of two equivalence classes is containcd in a single equivalence class ( ~ 1 ~ n ican ~ ) rbe used to define a multiplication in X j r . With this multiplication the quotient set X / Y becomes a monoid and x : S X / r is a morphisni of monoids.
I. Preliminaries
10
I f f : il/r + h1‘ is a morphism of monoids, then K e r f is a congruence in M and in the factorization
M
L M / I i e r f 5 M’
g is a n injective morphism. Observe that if Ad is a group, then a congruence Y in M is completely determined by thc equivalence class Ir containing the unit element of M . ‘I’his subset IY is then an invariant subgroup I I of A4 and each invariant subgroup gives rise to a congruence. ‘I’he quotient inonoid Af/r then coincides with the quotient group M / l l in the usual sense of group theory. 6. Miscellaneous Conventions
‘I’he Cartesian product ,Y., 1’ of two sets \ d l as usual dcnote t h e set made u p of all pairs (x, y ) with .Y E *\, 41 E l r ;similarly for the Cartesian product Sx/YxZ. Further we shall regard t h e sets (SU
Y)xZ,
aY .: (Y.42)
as identical. ‘I’his involves an identification of the elements
I n general, \vc do not hesitate to identify two sets whcnc\er an unanibiguous 1-1 correspondence bct\veen them has been established, provided such an identification is safe. ‘I’he \torcI “safe” is not given any precise meaning and thus may be taken quite subjectively. In the same spirit we shall identify -Y . with I’ whenever card -Y = 1, i.e., *Y has a single element. We shall systcmatically confuse an eleincnt ,x of a set S with the subset [x} of S consisting of .v alone. A much more subtle question is the disjointness of sets. W e regard the operation of intersection of sets as an algebraic operation defined on t h e set .t of all subsets of a set S.‘I’hus given two sets ’4 and B , the qucstion whether .4 and B are disjoint, i.c., whether ‘-1 n B = g , can be asked only after a set S has been exhibited of which both A and B are subsets. Indirectly this also denies the formation of t h e union .4 u R (unless A and R are given as subsets of sonic set S). Given two sets ’4 and I], we do assume that a set il u B, called the disjoint iinioir of 13 and B (or the coprodiirt of A and B ) , may be formed in
References
11
which .J and B appear as disjoint subsets. In the process of forming this A u B, elements of rl and B may have to be renamed to avoid artificial coalescense. These conventions may sound unorthodox but are actually in common use. For instance, in group theory the unit clement of any group is denoted by 1, but this does not mean that any two groups intersect. I n the rare event when the disjoint union of two groups G a n d H has to be formed, the unit elcments (and possibly other elements) will be renamed, to avoid confusion. T h e above conventions do not (as yet) fit into any of the established frameworks of foundations of mathematics, but they are very convenient and “safe.” References
Our usc of catcgories w i l l be very superficial. We have not even introduced the notions of functor, natural transformation, adjointness, or product. ‘1’0 the reader familiar with category theory, it will become clear while reading the text that a more substantial use of categorical terminology and techniques could have been made. T o the readers wishing to familiarize thcniselves with category theory we recommend the following tests: H. Herrlich a n d G. 1.; Strecker, “Category Theory,” Allyn and Uecon, Boston, 1973. S. h l a c l m i e , “Categories for the Working Mathematician,” Springer-Verlag, Berlin and New York, 1971. 13. I’areigis, “Categories and Functors,” Xcademic Press, New I’ork, 1970. €3. Mitchell, “Theory of Categories,” Academic Press, New I’ork, 1965.
CHAPTER
11 Automata and Recognizable Sets
This chapter introduces the notions of an automaton and of a set recognized by an automaton. l ' h e sets in question are subsets of a free monoid S* where S is a finite alphabet. T h u s we shall be dealing with sets of words in a finite alphabet. 'I'he approach is finitistic and explicit and all the arguments are effective and constructible. T o some extent this will be compensated for in Chapter 111 where the approach will be somewhat more algebraic. 1. Basic Definitions
Let S be a finite alphabet. An automaton' A over 2 (or a Z-automaton) consists of the following four data:
States:
a finite set Q of elements called states.
Initial states: a subset I of Q ; the states in I are called initial. Ternzinal states: a subset T of Q ; the states in I' are called terminal. Edges: a subset E of Q X S X0. A triple ( p , u, q ) in E is called an edge of the automaton. T h e edge ( p , u, q ) begins at p , ends at q, and carries the label u. We frequently use the notation u: p + q or p 5 q to indicate the edge. Except for the finiteness of Q, the above data arc subject to no restrictions whatsoever. 12
1. Basic Definitions
13
I n pictorial representations of automata, states will be indicated by small circles, by letters, or by numbers, depending upon the convenience of the moment. T h e initial states will be marked by a small arrow pointing toward the state. T h e terminal states will be equipped with a short arrow pointing aL\ay froin the state. States that are both initial and terminal will be equipped with a double-headed arrow. An edge ( p , (T, q ) will be indicated by an arrow pointing froin p to q with label (T. If there are several such edges with the same p and q, the several arrows may be replaced by a single arrou carrying several labels. An example is given to illustrate all these possibilities. +
0
01
:./,I.
-0-0
0
~ ? . ~ J
01
,;I: t+
m1,tra
0-
0
There are six states of which two are initial and two are terminal; one state is both initial and terminal. There are nine edges, but only seven are traced since two of them carry double labels. A p a t h c in &' is a finite sequence c =
(90
7
GI
, YI)(Ql
7
c, 9 q 2 ) . ' . ( Q r - 1 9
Ok
9
Qk)
of consecutive edges. T h e integer k ' . 0 is called the length of the path, q,, is called its beginning, and qr is its end. An abbreviated notation for a path is C -
We shall also write or or
I he element s = o,,.. ( T ~E L* is called the label of c and is denoted I c 1. Since 1s I is used to denote the length of s, we have k = I s 1 = jl c 11. 'Thus I/ c 11 is the length of c. For each state q ~ \ introduce e also the null path or the trivial puth I,] beginning at q and ending at q. By definition the null path has the label 1. 0. T h u s I 1,{I = 1 and 1) I,, 1 r ,
by
II. Automata and Recognizable Sets
14
A path c: i + t with i E I , t E T is called successfill. T h e labels carried by the successful paths in d form a subset I d I of Z*called the beAavior of d. A useful device is the composition of paths. Given paths d: q - r
c:p+q, the path cd:
p +r
is defined by concatenation. We have
I d =
I C I
Id1
and
IIcdII
= IIcIlf
IIdll
If we regard the states as objects and the paths as morphisms, we arc in the presence of a very simple example of a category (see 1,4). We shall frequently use the notation d’ = (Q, I , T ) for an automaton; the set E of edges is left out of the notation. With each automaton d = (Q, I , T ) a matrix E, called the transition matrix of d, may be associated as follows: T h e matrix E is a square matrix with both rows and columns indexed by Q. T h e entries are subsets of 2. Explicitly
Epp= {c I a: p
+q
is an edge in d}
Obviously, knowing the matrix E, the edges of d may be reconstructed. Later in this work we shall frequently use the transition matrix, particularly in situations which will permit us to algebraicize arguments of a counting and combinatorial nature. I n fact, the pictorial representation of automata described above uses the transition matrix; the elements of E,, appear as labels of the arrow the arrow is omitted. pointing from p to q. If E,, = A subset A of Z” is said to be recognizable if there exists a Z-automaton &’ such that I &’ I = A . When we say that a recognizable subset A of L’* is given, we shall understand that a 2-automaton d’such that 1 d’ I = A is effectively supplied. If a set A is supplied by other means, then to prove that it is recognizable will require the construction of &’ with 1 &’ 1 = A. Since we are concerned here with effective mathematics, we shall require that the construction of d be effective from the data describing A. We leave the word “effective” undefined as a mathematical notion. T h e class of recognizable subsets of 2” is denoted by KecZ. This is one of the important classes of subsets of 2’” that we shall study.
a,
2. Examples
15
2. Examples EXAMPLE 2.1.
T h e empty automaton &', without any states. Clearly
\g.
I,W'(=
..
EXAMPLE 2.2. Let s = al. a1
E
D.Consider the automaton on
02
-+O+O-...- 0-
+
with n 1 states. There is only one successful path and its label is s. Th u s I JP' I = S. If n = 0, the automaton has only one state and no edges. T h e trivial path is the only path and it is successful. Thus I &' 1 = 1 in this case. EXAMPLE 2.3. Let A c 2. Consider the automaton
with a single state which is both initial and terminal, and one edge for each 0 E A . All paths are successful. T h u s 1 ,31 = A". EXAMPLE 2.4. Let 2 = {a, T } . Consider o,r
EiA t3 q
2
o,r
Every successful path admits a decomposition r
c o i+i+q-t-+
d
t
Since 1 c I and 1 d I can be arbitrary elements of L'*= {a, T } " we have I 1 = ,r+,TZ". EXAMPLE 2.5. Let Z = {u,T}. Consider a
7
0,I
ou,--)*o q-t'
-2-
Every successful path admits a decomposition e
o
d
i-i-q-q-tLt with 1 c
1
E T*,
1d1
E ax,
1e1
E
Z*.
r
II. Automata and Recognizable Sets
16
I = t*ao*t2*. This set may also be rewritten as z * a * a t P . Thus I This set coincides with the set of Example 2.4; indeed both sets consist of all words in z’* which contain OT as a segment. EXAMPLE 2.6.
Let L‘= {a,T } . Consider r
a
T h e behavior is the set
A
= (T
u o+T’)*
u T*O+ u T*LT+T
and consists of all words s E {a, T}” which do not contain ment. EXAMPLE 2.7.
(TTU
as a seg-
Let S = {a, T ) . Consider
o(-+03T T h e behavior is the set a* EXAMPLE 2.8.
u a%*
=
a*t*.
Let S = {a, T } . T h e set
A
I >_ 0}
= { ( T ” T ~ TZ
is not recognizable. Indeed let A? be an automaton such that A = 1 &’ 1. For each n 2 0 we then have a successful path
.
tn
dn
en --*
qn
--*
tn
such that I c, I = a n , I d , I = T,. We claim that the states q,! must be distinct. Indeed if q,t = qm with m # 12, then
is a successful path with I c,,d,,, 1 niteness of the set of states of LP’.
=
a”t”L 4 A. This contradicts the fi-
3. Operations on Automata EXERCISE 2.1.
17
Show that any automaton recognizing the set {dk” 1 0
must contain at least 2N actly 2N 1 states.
+
5n 5N}
+ 1 states. Construct such an automaton with ex-
3. Operations on Automata
When we consider two automata and A it will be silently assumed that their sets of states Q,, and 0, do not overlap. This can always be achieved by relabeling the states in one of them. We shall now pass in review a number of basic operations on automata and analyze their behaviors.
Union: Given Z-automata d , .2,define the Z-automaton
8=dU 9 as the (disjoint) union of d and 3’.Thus Q(; = QA,u Q B , iff it is either in d Ic = I-4 u In, T c f= T., u T u . An edge is in or in .d.It follows readily that every path in ‘8 is either a path in &‘ or in .3. This yields
~ d u . a ~ = / d ~ u ~ L 2 ? ~ . Product: Given 2-automata d, .2? , define the Zautomaton L d X
I&=
29
by setting
Q~~= Q . x~ Q ~ ~ rc, = r, x I ~ , T~ = T . x~ T ~ . An edge
(f, P o ) 2 (9’9 9”) is in %‘ iff p’ A q’ is an edge in &‘ and at the same time p” q” is an edge in 25‘.I t is clear how each path c: (p’, p”) + (q’, q”) in 6 may be viewed as a pair c = (c’, c”) of paths cr: c”:
p’ P”
-
4
q1
in
,3
9“
in
8
II. Automata and Recognizable Sets
18
such that I c I I c' 1 = I c" c' and c" are. Therefore 7-
I.
Further, c is a successful path iff both
Given a 1-automaton %.d:(0, I , T ) , the reversed au-
Reorrsul: tomaton is
dQ = (Q, 7', I ) with an edge p A q for each edge q 1 , p in d. T h u s a path c in -3 with I c I = a].. .akyields a path CQ in with Q'&
where p : 1"
--f
1" is the reversalfunction defined by 1g
=
1,
ag = 0,
(st)g = (tp)(sp)
'l'hesc three constructions yield : PROPOSITION 3.1. tersection, arid reeiersal
The class Kec 1 is closed under finite
iinioii,
in-
!
T h e reader will notice that the operation of complementation was not mentioned. l'he fact is that the class Kec 1: is closed under complementation (this will be shown in I I1,2). However, the appropriate construction is more involved. Next we give some constructions on automata, related to a morphism
where 1' and 1 are two alphabets. Iiizwse inznge: Assume that the morphism f is fine (i.e., that c 1 u 1). Let Ld (Q, I , I') bc a 2-automaton. We define a rautomaton Ldf-'with Q, I , T unchanged and with edges of the following two types
ly
P-1-s
3. Operations on A u t o m a t a
if yf
=
(T
and
19
p A q is an edge in -d, and Y
9-q
1.
ifyf=
A path c': p q in -df may easily be seen to be completely givcn by a pair (c, g ) where c : p + q is a path in ,d and g E f" is such that I c' I = g , gf = 1 c I. It follows that
I d f - '1
=
I ,d
I.f-1
PROPOSITION 3.2. If f : 1'" 1"is a fine morphism and A c 2" is vecognizable, then so is Af-I c P I --f
Direct image: Assume that the morphism f statisfies yf f 1 for all I' (or equivalently that If = 1 o r still equivalently that I g 1 5 I g f I for all g E P). Given a r-automaton &' = (Q, I, T ) we define a Lautomaton ,d' = (Q', I , T ) with 0 c Q' as follows. Let
y E
be an edge in ,d and let yf we have the edge
= o 1 . . .crJL (n
2 1). If n
=
1, then in d r
WI
P+9 If
12
1, then in ,d'we have edges
> '
where the intermediate n - 1 states are new distinct states adjoined to Q. W e repeat this for every edge in d'.W e thus obtain AY". I t is then manifest that ~ G d ' ~ : f ~ ~ d ~ PROPOSITION 3.3.
If A
c
Let f:1'"
~
+ S"
be a morphism such that 1 = If-'.
r" is recognizable, then so is Af c S" I
The shufle product: Given subsets A c X", B c 1'" with L n r ;d,the shufle product A LL B c (S u 1')" consists of all words of the form slg,. . .Srlg,!E (Lu 1')" =
II. Automata and Recognizable Sets
20
A more algebraic description is obtained as follows. Let
be the morphism given by
Now assume that A and B are recognizable and let d and 8' be automata such that I ,d 1 = A , IM'I = B. W e define the automaton
'6 =d = (Q.1
Lu
9
x QD
9
IAX I I I T.Ix Tn) 9
T h e edges of '8 are
(P,P') 2 for each edge a: p
+q
P')
in d , and
(P,PO 2 ( P , q ' ) for each edge y :
p'
4
q' in 9. I t is clear from the construction that
1 gI = 1 d 1
w 1 9I
PROPOSITION 3.4. If X and I' are disjoint alphabets, A is a recognizable subset of 2 7 , and B is a recognizable subset of P,then A LU B is a recognizable subset of (C u r)" I
There is a variant of the shuffle product A u B (called the internal sJ2ufle product) defined for subsets A and B of the same free monoid 2". T o describe it, consider a copy 2' of L' disjoint with 2 and let B' be the subset of 2'" corresponding to B under the isomorphism S* 5 2"". Consider the morphism
v : (2 u S')* + X",
av = d v
=G
4. Accessibility
21
Then
Since l r l
=
1, Propositions 3.3 and 3.4 imply:
PROPOSITION 3.5. If A and B are recognizable subsets .f S*, then soisAuB I
Let &' Define a new automaton EXERCISE 3.1.
=
(Q, I , T ) be a S-automaton and let a
E
2.
d' = (Q u t', I, t ' ) where t' is a new state with new edges t +"t for each t
E
I
T. Show that
1 d '1 = 1 ,d 1 CT Thus if A is recognizable, so is Aa. EXERCISE 3.2. Show that the internal shufle product converts the set of all subsets of I*into a commutative monoid with a zero, and that the recognizable subsets form a submonoid. EXERCISE 3.3. Describe the internal shufle product A u B directly (using essentially the same description as f o r A LU B ) . Define d u '8f o r Zautomata d and -8 and prove that I d u 9 I = 1 d'I u 155'I . 4. Accessibility
Let &' = (0,I , T ) be a L-automaton. For any subset X of Q and any s E S" we define a subset Xs of Q, by the following properties:
(4.1) S ( s t ) = ( X s ) t , (4.2) zYl
=
X,
(4.3) (XI u S , ) S (4.4) qa
=
= XIS
{ p I cr: q - p
u SzS,
@s
=
0,
is an edge in d } .
22
II. Automata and Recognizable Sets
That these formulas define X s in a unique tnanner is clear. Indeed
(4.1) and (4.2) show that it suffices to define X a for G E L'. Then (4.3) shows that it suffices to define 40. This is done in (4.4). From (4.1)-(4.4) we derive (4.5) 'Ys
z
{ q I there exists a path c : p
q with p
-+
E
X and I c I
=
s}.
For any subset A of L'* we may define
XA
(JXS
=
st.1
and verify the obvious analogs of (4.1)-(4.3). From (4.5) follows
(4.6) I
&'
1
= {s
I Is n 'I' f 8)
For any s E L'*, the set Is can be effectively calculated (essentially in I s 1 steps). T h u s we can decide whether Is n 'I' f (3 and thus decide whether s E I 1. 'The automaton a' is said to be nccessible if for every state q there exists a path c : i + q with i E I . I t is easy to see that A?' is accessible if€
IS*
=
0 h
From formula (4.6) it is clear that the behavior of &' remains unchanged if the inaccessible states, i.e., the states in Q IL'* are removed. By doing so we obtain an accessible automaton ~
= I F , T;l = 7' n p, such that I &' I &:I' I. We shall call the accessible part of A?. T o find @ effectively in a finite number of steps the following formal procedure is recommended. Define the sequence of subsets Qo, Q, ,. . . , Q,?,. . . of Q by induction as follows.
with
=I
QO
If
Qk
f
=I,
0 and
Qi+I =
Qk+l =
QLZ
0, then
- (Qi
Qk+, =
u QL-I
U. . . u
for all
p >1
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 O-automaton. 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 2-automaton &' = (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
4-4
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.
m7-y
segment of s of length
Proof. 1,ct -4 = 1 Ld1 where d is a Y-automaton 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
iLp-p-t
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 4-kn + 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 E-automaton 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 non-trivial 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 S-automaton ,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. . .@,> 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 S-automaton 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 Z-automaton &‘ = (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)
QXxr-Q
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 X-module 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 2-automaton (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 2-module. 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 Z-automaton
*-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 E-automaton 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 1-automata 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 (non-deterministic) S-automata 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 2-module. 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 right-hand 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-'(I-c-')
=
B-l(LY-llr)
(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 B-lA and AB-I 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, TB-I) is i-1(
TB-1)
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 = q-1T
=
( 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. State-Mappings
Consider deterministic Z-automata
a'=(Q, i, T ) ,
d'= (Q',i ' , T ' ) .
A morphism (or a state-mapping)
M'
$9: .-ti?-+
4. State-Mappings
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 state-mappings
dz
d
l
d
l
l
is again a state-mapping
&"": d " This follows directly froin the definitions. If $': d"+ d'" is another state-mapping, then the associativity (Q'Y')?~''= p(p'p?'')is obvious. Also the identity mapping of C, into Q is a state-mapping 1 , J : d4d. T h u s deterministic 5-automata and their state-mappings form a category that we shall denote by A ( 2 ) . T h e state-mapping 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 state-mappings is again proper. Since the identity state-mapping 1,d : d d is proper, it follows that proper state-mappings 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 state-mappings. Let d =(Q, i , 7') be a deterministic Z-automaton 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 L-module 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 state-mapping E:
d 4 d I Q'
called the restriction niupping. T h e state-mapping E is proper iff the following conditions hold
(4.5)
i c Q',
Q'Z c Q'
4. State-Mappings
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 state-mapping 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 state-mapping, called the inclusion. EXAMPLE 4.2.
Let 2 =
(0,T )
and consider the X-automata
-
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 state-mapping 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 state-mapping, 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 state-mapping and assume dt= 1 Qt and SY''~ = ,3' 1 Q't be the trim There is then a state-mapping yt : Ld such --f
It
d'
commutes, where F and F' are the restriction state-mappings of Example 4.1. The state-mapping 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 state-mapping 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 S-automata 1 d ' 1, There is then at most one state-mapping 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 state-mappings. 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 state-mapping where ,u/ = ( Q , i, T ) and d = = (Q', i', T ' ) are deterministic E-automata. 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 state-mopping. 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 state-mapping. 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 state-mapping 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 state-mapping qr: ,d---f d'. If we write JY" 5 whenever such a state-mapping 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 state-mappings, 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 state-mapping ,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 by-product 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 Z-module. The behavior is the set I Q , ' I = i-ll' = { 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 s-lA with s E Z* intervene. This is justified by the following:
Let d'=( Q , i, T ) be a deterministic (possibly infinite) Z-automaton 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
q-1T
z
(is)-'T =
('2 1 T ) = s-'A
Further the state q is coaccessible iff q-lT f @3
I
I,et Q" be the set of all subsets of 1*. We convert Qo into a (infinite) right 1-module 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 =
t-1 (s-'X)
=
( X * s) . t
it follows that Qo is indeed a Z-module. I n Qo we consider the subset
TO = { X I X
E
QO,
1E X )
We note that in the S-module Q O we have
-Y-lTO
(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 2-automaton with behavior A. Consider the function
Q+QO q'p = q-'T p:
We assert that
(5.2)
p':
d-+ Ld2,0 is a state-mapping.
This follows from the following three calculations :
ic~,= i - ' T = I ,d I (qs)cC, = (4s)-'T q E
=
=
A
s-1 (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 state-mapping rp is proper; however, this fact will not be used.
Ill. Deterministic A u t o m a t a
46
Let Ld-l = dltbe the trim part of d ' , O . Applying Proposition 4.2 we find that y defines a proper state-mapping 9':
, J t
+
Ld.l
Thus, in particular, if &'= d'is trim, we have a state-mapping 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 -1-is 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 if-f 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 Ir-automaton with behavior A , then the unique state-mapping 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 Z-automaton ' A
=
(Q,
i, T ) with behavior A , there exists a unique state-mapping p: Ld+- d . , c
This state-mapping is proper and is a surjective firnetion. If q qp = 9-11'
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 (non-deterministic) 2-automaton let d ' denote the result I$ the accessible (zero-free) 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<
... S c a r d Q
Further if we exclude t h e trivial cases T = D and T = Q, then E, has exactly two equivalence classes, namely T and 0 - T . T h u s e, = 2 . Consequently we must have el, = e p f l for some p 5 (card Q) - 2. T h i s implies El, = E,J+,and thus E , = E. We have thus proved: PROPOSITION 6.1. In a deterministic automaton d =(Q, i, T ) two states y1 and q2 are equivalent if and only
qls E T for all s
E
q2s E T
c,
S* such that
I s I -(card : Q) - 1 I 'This readily implies: COROLLARY 6.2.
The equivalence of two states in a deterministic
automuton is decidable T h e argument used to prove Proposition 6.1 is entirely independent of t h e choice of the initial state. Given two deterministic 'automata A",= (Q, , i, , T I ) and Ld,= (Q,, i,, T 2 ) we can form their disjoint union and test t h c states i, and i , for equivalence. T h e r e results: PROPOSITION 6.3 Let -d, (i = I , 2 ) be deterministic 1-outonzata -3, I = I -w', 1 whenever with set of states Q L . Then sE(LdljeSEId21
f o r all s E L* such that
I :i 1 < card Q1 -\ card Q,
-
1
I
51
7. Examples 7. Examples
We give a number of examples in which the subset construction and reduction will be carried out and a minimal automaton will be obtained. Some of the theoretical aspects of the procedure will be explained in the first example. These explanations will not be repeated in the subsequent ones. EXAMPLE 7.1.
Consider the automaton
of Example 11, 2.4. Its behavior has been computed to be the set
(7.1)
'7"~~S"with
I
S=
(0, T }
T h e automaton is not deterministic: two edges with label CT issue from i. We apply the accessible subset construction. T h u s starting with the subset consisting of i alone we build a table of the sets is with s E 2'". For simplicity we shall write iq for the subset {i,q } , etc. We obtain the table
i ia
=
iq,
(iq)o = iq,
(it)a = iqt, (iqt)a = iqt,
1T =
t
(iq)r = it ( i t ) t = it (iqt)r = it
Observe that while the second, third, and fourth rows produced new sets, the fifth one did not. T h u s the table stops as the next row would simply repeat formulas already written. A total of four states i, iq, it, iqt are obtained of which the first one is initial while the last two are terminal since they contain t. Note that the empty set has not been obtained and thus the resulting accessible automaton is complete. Renaming the states 1, 2, 3, 4 we obtain
Ill. Deterministic Automata
52
We now repeat the same procedure but with the dual automaton. This will not only check the above automaton for coaccessibility but, as we shall see, it will also tell us which pairs of states are equivalent. T h u s we start with the terminal set 34 and build the table of sets (34)s-1with s E 3.We obtain
34 (34)a-1= 34, (234)a-' = 1234, = 1234, (1234)~~'
= 234 (34)~~' (234)~-1 = 234 = 1234 (1234)~~'
We observe that both non-terminal states 1, 2 appear on the right-hand side of some equation. This proves that the automaton above is coaccessible. We also observe that the states 3 and 4 never get separated; whenever one appears on the right-hand side of an equation then so does the other one. This means that
3 E (34)s-10 4 E (34)s-1 or equivalently
3s E 34 0 4s E 34 Since 34 is the terminal set T , it follows that the states 3 and 4 are equivvalent and should be merged. An inspection of the table shows that this is the only such pair. Performing this merger gives the minimal automaton
c
0
+1"-2".3-
0,r
I t is complete. If we compute the behavior from this automaton, we obtain the set 5 *a0
*a*
or equivalently
(74
t*a*orS*
This expression formally differs from (7.1) but both describe the same subset of P, namely the set of all words which contain GT as a segment. T h c form (7.2)emphasizes the first (i.e., the leftmost) appearance of this segment.
53
7. Examples EXAMPLE 7.2. u,r
Consider the automaton
3
E 1 ~ 2 3 u , 7+ 3 ~ 4 -
a,r
which is trim but not dctcrministic. It calculates the set L ' * T P u 02". Of course this is the set 2+(as indeed every word in L'+ either begins with (T or contains T ) . T h e table of sets 13s is
13 140= 14,
130 = 14,
132 = 12
1 4 t = 124,
1 2 0 = 12,
1240 = 124,
1247 = 124
1 2= ~ 12
T h u s there are four states 13, 12, 14, 124 of which 13 is initial and the others are terminal. Renaming these as 1, 2, 3, 4 we obtain the accessible deterministic (even complete) automaton
We now build the table for 234s-I
234 2340.'
=
1234 = 2 3 4 ~ - '
12340-'
=
1234 = 1234~-'
T h e states 2, 3, 4 are inseparable and therefore are equivalent. Merging them we obtain the minimal automaton +,'YS
EXAMPLE 7.3.
Consider the automaton
Y
54
Ill. Deterministic Automata
This automaton is deterministic and accessible and calculates the set to*. We thus proceed directly with the table for ts-'
t to-1
= t,
i0-1
=
tt-1
0,
=
i
it-' = @
There are no equivalent states and q does not appear because it is not coaccessible. Th us NU* is
+02+&-Jo Similarly do*, is
U++o+ EXAMPLE 7.4.
Consider the automaton
computing the set S*tS*. T h e table for 1s is
1 l o = 1,
010 = 01.
It =
Olt
=
01
01
There results the automaton
which upon inspection is already minimal. EXAMPLE 7.5.
Consider the automaton
1A 0 +
U,T
computing the set
Pt.
The table for 1s is
1 lo
Ola
= =
1, 1,
It =
Olt
=
01 01
8. The Quotient Criterion
55
T h e resulting automaton
is already minimal. Observe that the reversal of the original automaton is
computing tZ".This automaton already is minimal.
8. The Quotient Criterion
THEOREM 8.1. (The Quotient Criterion) For any subset A of Z" the following conditions aye equivalent:
A is recognizable. (ii) The family of sets {$-'AI s (iii) The family of sets { A - ' I s (i)
E
S"} is finite.
E
S " } is finite.
Proof, (i) c1. (ii). T h e family in (ii) is the set Q2.1c of the (a priori infinite) complete minimal automaton Lda4c of A. T h u s if QAlc is finite, -dAlC is a finite automaton and thus A is recognizable. Conversely, if A is recognizable, then A = 1 jY' 1 where .dis a finite, deterministic, and trim automaton. T h e surjective state-mapping ,d+ ,ull implies that the minimal automaton LdA, of A is finite. T h u s Q.l is finite and so is the family in (ii). = se-lAe, where e is the reversal opera(ii) 3 (iii). Since (As-')@ tion, the finiteness of the family in (iii) is equivalent with the finiteness of the family {s-lAe I s E S"}, i.e., with the recognizability of
[email protected], Ae is recognizable iff A is (Proposition 11,3.1) [ It is important to observe that while the definition of automata was biased in the sense that right modules were used throughout, the resulting notion of recognizability is two-sided, as is seen from conditions (ii) and (iii). T h u s automata based on left modules would yield the same notion of recognizability.
Ill. Deterministic Automata
56
T h e cardinality of the family in (ii) is denoted by uCA.This is the number of states of the automaton We also introduce the number aA which is the cardinality of the set in (ii) with 0 deleted. Clearly uCA = uA or uCA= 1 cxA.
+
PROPOSITION 8.2. Let A be a recognizable subset of Z", and let &'= (Q, i, T ) be a deterministic (resp. complete) Z-automaton such that I ,d1= A. Then
card Q
with equality holding
2 (LA
(resp. card Q 2 acA)
if and only if ,dis minimal
(resp. complete minimal).
Without prejudice we may assume that JY' is trim (resp. accessible). Then q ~ :,d+ ,d.(resp. , p: d+Ld.,c) is surjective and the inequality follows. If equality holds, then 9 is bijective and is an isomorphism I Proof,
EXAMPLE 8.1. A palindrome is an element s of Z* such that s = SQ where s@ is the reversed word. We show that the set P of all palindromes in L'* (card Z= k > 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 {s-lP} 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 s-IA 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 s-1A n Jq
=
X* is recognizable if there E S* the condition
t-1A n 21
implies
$-'A n z Show that
r
t - ' A n 21
if this is the case, then
implies
SP'A= t-l-4 and therefore
where k
=
card 2.
EXERCISE 8.5.
Show that f A is a recognizable subset of u(AB-l) 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) Z-automaton with behavior A . T h e development presented in Sections 5-8 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 non-empty 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 Z-automaton 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 2-module. 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 Z-automaton, then Q is a right 2-module 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 Z-automaton Proof.
-
d =( M , 1, B ) with M converted into a complete right L-module 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
(u-lA)(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 ,
Bp-l
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 anti-isomorphic, 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
Med-M,,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 s-yntactic 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
= 0-7= 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 non-recognizable 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 (non-deterministic, 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 = D9-l. 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 = Eyr-I. 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,ry-l, 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 m-l(Alf-l) = ( ( m f ) - ' A ' ) f - l for A' c M' and in Alf-1.
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 an-v 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 } 0-v 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 2-automaton 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 Z-module 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 2-module
(XI, . . . ,S r ) s
=
(sr'X,, . . . , s-LX,)
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) Z-automaton
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 non-coaccessible 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., b-v 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), 114-125. Reprinted in “Sequential hlachines” (E. F. Moore, ed.), pp. 63-91, Addison-Wesley, 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 clear-cut and systematic exposition of the syntactic monoid. S. Ginshurg and G. F. Rose, A characterization of machine mappings, Cattad. J . Moth. 16 (1966), 381-383.
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), 111-146 and 38 (1946), 123-1 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.3-6.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 non-empty. (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 : t-lt. 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) s-lA = 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 @,
A-1A
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 enipt-y 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 s-lA = 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 non-empty 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 non-empty 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 non-empty subset of 9, the syntactic morphism of iZ with A = Be-,, B c M . Show that A is a prefix iff 1e-l = 1 and B-IB = 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 P-IP' #, 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 non-empty 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 1-lA = 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 non-empty 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 = i-It 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 a-IA. 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,
V-1U 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 Ao-l is
recognizable and a(An-') 5 crA
(4.3)
If further '4 is a non-empty prejix, then a(Ao-') < uA
(4.4) Proof,
Let d
=
((3, i, T ) be the minimal automaton of A. Define Ldo-l =
((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 non-empty 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 unitary-prejix monomial (up-monomial for short). A up-monomial 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 up-monomial 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 up-monomial of degree < U A
I
The decomposition of A obtained by applying the algorithm above is called the unitary-prefix decomposition (up-decomposition for short) of A. T h e up-decomposition 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 up-monomial 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 up-decomposition 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 = 19-l 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 Up-Decomposition
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 = M-1 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
M-lM 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 up-decomposition 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 up-decomposition 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 up-decomposition 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 up-decomposition 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\‘x-l
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 , . . . aj-l = 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 , . . . aj-ltv = 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 non-recognizable 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 Z-module. 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 Z-module. Let d '= ( Q , i, T ) be a finite, complete, coaccessible Z-automaton 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 non-empty 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 up-decomposition 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), 346-350.
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 Dubreil-Pisot, 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 non-negative 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 Z-automaton 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 qs-l (and possibly other states) terminal, while dAtc
with r0 a non-terminal 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 nEA-n+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+iEAc-m+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 non-trivial submonoid of N and let p be the greatest common divisor of all the non-zero 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 pair-representation. 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 2-matrices with entries in N . 3. k-Recognizable 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. k-Recognizable 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 k-recognizable. COROLLARY 3.2. The class of k-recognizable subsets of N is closed under Boolean operations I PROPOSITION 3.3. A subset A of N is k-recognizable 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 k-recognizable for all k -, 1.
Proof. By Corollary 3.2 the union of two k-recognizable 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 k-recognizable. 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 k-recognizable 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 k-recognizable. 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, k-recognizable.
Let 1 = kp with k > 1, p >; 0. A subset A of N is k-recognizable ;f and only if it is I-recognizable. 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 I-recognizable, 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 k-recognizable 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 k-recognizable set is also I-recognizable 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 I-recognizable is recognizable I
110
V. The Integers
4. Iteration PROPOSITION 4.1. Let A be an infinite k-recognizable 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 k-recognizable 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 k-recognizable 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 k-recognizable 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 k-recognizable 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
R,,
ai+1 = lim sup -
i-+m
ai
or by considering consecutive differences and defining
D.i = lim sup(ai+, - a i ) i+m
Observe that the quantities R., and D., are not entirely independent. We have (5.1)
D-.l < 00
implies
R,
=
1
+
Indeed, assume R, > 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 k-recognizable 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 k-recognizable 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 k-recognizable 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 k-recognizable 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
s-IB 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 s-lB 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 k-recogniza6le f o r any k > 1 EXAMPLE 5.2. Let a i = it’ where 6 > 1 is a fixed integer. Then A is not k-recognizable 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 well-known consequence of the Pritne Number Theorem. Consequently A is not k-recognizable 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 k-recognizable but not I-recognizable. [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 k-recognizability. 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 k-recognizability 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 intel-pet 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
N-tNxN. References R. W. Ritchie, Finite automata and the set of squares,]. Assoc. Cornput. Mach. 10 (1963),
528-531.
This paper proves that the set of all squares is not 2-recognizable (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), 281-286.
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 Minsky-Papert theorem deals with the condition s-lB f 0 for all s E 2'". Theorem 5.1 was obtained by M. P. Schutzenberger and the author (unpublished). A. Cobham, On the base-dependence of sets of numbers recognizable by finite automata, Math. Systems Theory 3 (1969), 186-192.
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), 233-236.
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 (non-necessarily deterministic) X-automaton. 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
i-i-t-t
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 N-subsets. 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 K-subset 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 non-negative 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 well-defined 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 -i-is 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. K-Subsets 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 K-subset 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 K-subset 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. K-Subsets
127
of ;’iin the usual sense. In particular, if K = 9all K-subsets of X are unambiguous and every .%‘-subset may also be viewed as an unambiguous K-subset. 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 K-subset 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 K-subsets. 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 K-subsets 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 K-subset 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 K-subsets is defined by x(A n B ) = (xA)(xB) This formula also applies if B is a K-subset and A is a .%'-subset, by simply regarding A as an unambiguous K-subset. Thus in this case X(A
nB)=
{ :B
if if
X E A x@A
For each K-subset 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 right-hand side of (3.1) is called the expansion of A (in terms of singletons). It is a useful formal device in manipulating K-subsets. For instance, we have
A nB
=
C (xA)(xB)x X € S
Let A be a K-subset of X and let X ' be a-q-subset of X . If xA = 0 for all x E X - X', then we may regard A also as a K-subset 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 K-relation f: X + Y we shall proceed similarly but will replace P by the set KY of all K-subsets of Y. Thus a K-relation
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 K-relations form a category. T h e graph #f of a K-relation f : X + Y is the K-subset of X x Y defined by
(X,Y)#f = y ( x f ) T h e inverse relation f
-l:
Y
-+
X is given by
4yf-l) =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 K-relations 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 K-subsets of --f
X x Y. EXAMPLE 4.1.
Let B be a K-subset 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 K-subset 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 K-subset 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
x-X-LX.
nc
T h e completeness of K was not required. For a K-relation 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’9-subset while I mf is a K-subset. A K-relation f : X + 1’ is said to be unambiguous if for each x E X the K-subset 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 K-relationf: 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 non-zero 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 K-subset B
For any function f :
PROPOSITION 4.1.
= xf
of Y the diagrams
commute, where B' Proof.
Y-Ynn
x-xnw
x-xnw
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 K-subsets A
X and B , C of Y we have (C n l3)f-I
=
Cf-l n Bf-I
( A n Bf-l)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 Y-x-x-Y
f
I
5.
133
Monoids and Matrices
EXERCISE 4.1. Let f:A‘ + E’, g : I’+ Z be K-relations. Show that ( f g ) - ’ = g-tf-I. 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 K-subsets of S. Our first aim is to define the K-subset 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 K-subset 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 K-subsets. Thus if B E Kz'xQis another P XQ-matrix, 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 XQ-matrix 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. K-S-Automata
EXERCISE 5.2. Dejne the K-relations L ,: S + S and RAi:S S where A is a K-subset of S. Derive the formalproperties following the pattern of III,3. Dejne the K-subsets A-lB 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 K-2automaton d =(P,1,T ) is given by a finite set
0 with K-subsets I and
T and by a K-subset E of
If then we say that the edge ka
p-q is in d a n d that ka is the label of the edge. As in the case of 2-automata, paths c:
p+q
are considered. If c is the path
p-q,' kiai
I
.
- 411-1
.
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 K-subset 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 K-subset E of QxL’xQ is a function
E : QxL‘xQ-K Thus writing
( P , 0,9 ) E = CE,, we find that EPqis a K-subset 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 K-subset of 2‘ may be viewed as a K-subset 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 Q-matrix 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. K-2-Automata
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 matrix-valued morphism
PROPOSITION 6.1. For an-v p , q E Q the K-subset 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 K-subset 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 K-subset of Q. We may regard A' as a row vector (i.e., a 1 x Q-matrix of elements of K ) . For each s E Z*, the matrix sE" is a Q X Q-matrix 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 K-2-automaton d = (Q, I, T ) is said to be normalized if I T = t are distinct singletons and if further there are no edges ka
9-29
.
=
i and
kn
t-9
(with k f 0). Clearly for such an automaton we have
I &’ I
c Z+.
PROPOSITION 6.4. For any K-2-automaton d there exists a nornialized K-S-automaton A?” such that
7. Recognizable K-Subsets 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 K-Subsets Let K be a (commutative) semiring and 2 a finite alphabet. A K-subset 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 K-subsets 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 K-subsets 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 K-subset A of C* is the composition
PROPOSITION 7.2. I f f : r*+ C* is a fine morphism and A is a recognizable K-subset of P, then Af is a recognizable K-subset 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 K-subset of 11*,then Af is a recognizable K-subset 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 K-subsets 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 K-subsets. 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 K-subset of Z", and B is a recognizable K-subset of P, then A w B is a recognizable K-subset of (Z u T)* I
141
7. Recognizable K-Subsets T h e passage from the shuffle product
LL
to the internal shuffle product
A u B of two K-subsets 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 K-subsets 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 K-subset of 2" and let K . Then k A is a recognizable K-subset of S".
PROPOSITION 7.6.
k
E
Proof. Let SY' = (0,I , T ) be a K-2-automaton recognizing A. Then k A is recognized by either one of the K-2-automata
k d = ( Q , kI, T ) , with the transition matrix unchanged PROPOSITION 7.7.
q the
K-subset A'
=
d k
=
(0,I , AT)
I
A K-subset 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 K-subsets 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 4-kB' + 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 K-2-automata recognizing A' and B'. Consider the normalized K-S-automaton '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 K-subset of 2f. Then the
K-subsets
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 well-defined K-subsets. Indeed, since A c Z'f we have sAJJ= 0 whenever I s I < n. Let & = (Q, i, t ) be a normalized K-2-automaton recognizing A. Then merging the two states i and t into a single state which is both initial and terminal we obtain a K-S-automaton &' * (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 K-subset A of Zfis recognizable if and only if there exists an integer n > 1 and an nxn-matrix E of K-subsets of Z such that A = E:l.
Proof, Assume that A is recognizable and let & = (Q, i, t ) be a normalized K-2-automaton 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 n-matrix of Ksubsets of .Z and n > 1. Then setting Q = (1, . . . , n } we obtain a K-Z-automaton M = (Q, 1, n ) with transition matrix E. As above Idq=E;,=A I
8. The Equality Theorem
143
As a by-product of the argument above we obtain COROLLARY 7.11. If E is a n x n-matrix of K-subsets of L', then for any 1 5 i, j 5 n the K-subsets E$ and E$ are recognizable I PROPOSITION 7.12. Let p: K + K' be a morphism of semirings. Zf A is a recognizable K-subset of P, then A p is a recognizable K'-subset of 2".
Let d =(Q, I , T ) be a K-2-automaton with transition matrix E, such that I ,d I = A. Then the K'-2-automaton 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 K-subset of S*,then A t is a recognizable 9-subset of L'* I PROPOSITION 7.14. Let A be a recognizable 93'-subset of 2*. Then A viewed as an unambiguous K-subset of Z* is recognizable. Proof. Let &' be a deterministic 2-automaton with behavior A. If we view d as a K-S-automaton, then its behavior is A regarded as a K-subset
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.1-7.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 K-subsets of Z* and let di = (Pi, Zi,Ti)be K-2-automata 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
then A , Proof.
=
A,.
Consider the automaton
where Q1 and Q, are assumec disjoint and the transition matrix is Qi
QZ
E= From dlu d, we derive the automata
and observe that
I , qI i= I &di I = Ai,
i
=
1,2
T h u s the conclusion of Theorem 8.1 follows from: THEOREM 8.2. Let
di = (Q, I i , T ) ,
i
=
1, 2
be K-Z-automata differing only in their initial subsets. Then I dlI if and only if sId l I =sI I
=
I d, 1
for all s E Z* such that
I s I < card Q Proof, By assumption K is a subsemiring of a field F. Thus we may I and I ,d2I are equal as F-subsets regard dias F-Z-automata. If I dl of Z*, then they are also equal as K-subsets. Thus we may replace K by F, or equivalently assume that K is a field. Thus K Qis a vector space over K of dimension n = card Q. Consider the K-Z-automaton
d =(Q, I , T )
8. The Equality Theorem with I = I ,
-
145
12.Since s 1 ‘YL
I = s I dlI
s 1 -d, I we have
( s ( < n
if
s l d ( = O
-
and we wish to prove that sId
I =0
Z*
for all s E
Equivalently, in view of Corollary 6.3, we are given that
(Is)T = 0
I sI
if
r‘ n
and we wish to prove that
(Is)T = 0
for all s E .Z*
Define
W = {X 1 X
E
K4, KT
=
O}
V , = subspace of K Q generated by vectors Is with I s I 5 k. Assuming that n > 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 K-E-automaton, 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’21-1
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 K-subsets 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 N-I-automaton
two N-subsets I and T of 0, and an N-subset 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 N-1-automata are exactly the 1-automata 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 N-L-automaton such that .-I = I 3 1. T h e N-subsets 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 5j<
Ld= , ( Q x k , (i,O), ( t , j ) ) , is normalized
I
COROLLARY 9.2. For each recognizable N-subset A of V + there exists an unambiguous X-automaton Gdwith a single initial state (or with a single termirial state) siiclz that I I = '4. Indeed, it suffices to pinch together the initial states (or the terminal states) of the normalized automata in the conclusion of Theorem 9.1 I EXAMPLE 9.1.
Consider the N-1-automaton
Ei
:
-T, t
3
2:
9. The Case K = N
with
T
149
a distinguished letter in L'. Then A
=
1 -d1 is
given by
the summation extended over all decompositions s=
UTZ',
u, v E
L'*
Observe that A may also be defined inductively by the formulas
1A
=
0
(os)A = s A
( t s ) A = 2'"' We now apply to obtain
for
o#
T
+~'4
the procedure of the proof of Theorem 9.1. We
Since the state (i, 1) is not coaccessible it can be supressed. We thus obtain the unambiguous (and trim) automaton
Theve exists THEOREM 9.3. Let A be a recognizable N-subset of P. a finite alphabet Q, a local subset L of Q*, and a fine morphisin f:f2* + 9 such that Lf = A. If A is an N-subset of Z+,then f may be chosen to be very fine. Proof. We first consider the case when A is in S+. I n view of i-' an unambiguous Theorem 9.1 we may assume that A = I d 1 wheres@
150
VI. Multiplicity
C-automaton. We now apply the graph construction of II,6. This yields the alphabet Q, the very fine inorphisni f,and thc local set L = #Ld. We have shown in II,6 that f establishes a 1-1 correspondence between the words c in L and the successful paths in JX' with label cf. T h u s the equality Lf = A is an equality of N-subsets. T o consider the general case we write
A
=
n1
+ A',
A' = A n C +
and construct the very fine inorphisin f ': Q'* 49and the local subset L' of 9'" so that A' = L ' f ' . We now define Q by adjoining n letters T , , . . . , z,, to Q' and extend f ' to a fine morphism f: sZ* + I*by setting t i f = 1 for 1 5 i f n. T h e n 1, = L' u { T ~ ., . . , r,?} is the required local set I EXERCISE 9.1, Show that a normalized and unambiguous autowinton for a recognizable N-subset A of P exists iff A c 2-i and A n C is unanzblguous. EXERCISE 9.2. Show that if the N-2-automaton the multiplicity of the edges is 5 k then
EXERCISE 9.3.
&'
has n states, and
lJse Exercise V,2.2 and Theorem 7.10 to show that the
function
vk: k*
4
N
of V,2, viewed as an N-subset of k* is recognizable. Establish the same fact for the bijective interpretation of V,6. 10. The Division Theorem
Let p > 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 N-subset A of a set S we have
(10.1)
A
= p(Arx)
+ A/3
10. The Division Theorem
151
where An is an N-subset and '41 is an N-subset satisfying x(AP) < p for every .T E S.
p
THEOREM 10.1. Ldet A be a recognizable N-subset of -Y*, and let -, 0 be an integer. Then in the decomposition (10.1 ) the N-subsets Ars and
'411 are recognizable. Further, f o r every 0 5 k ': p the 3-subset 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 2-automaton d =(Q, I , t ) with a single terminal state t. For each function r: Q-p
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 N-subset of Q will also be viewed as an N-subset of Q u R. Note that Y above is an N-subset of Q and thus also of Q u R. However, r ) is a single element of R. For every s E S" and every N-subset B of Q, Bs is again an N-subset 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
(
Y.
Thus
VI. Multiplicity
152
Thus equality (10.2) follows from the following two equalities
(CU)"
+ [(CP)v]a
=
[(CB)VIP
=
.+
T o prove these two equaIities we use the identities C ( P . y)" = Y", and (P. y)B = YB.Then
+
+
=
p(Cu) + C/3,
+ (CP>vIa
( C V b = [(P(C@))V =
{P[(CU)VI
+
=
(CV)P = C(P(C")V
[(CP)V]W
+ (CPbIB
= {P[(CQ)VI =
+ (CPbh
+ (CP>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)c-x= 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 N-subset i3B is recognizable
COROLLARY 10.2. If A is an N-subset of S" and p A is recognizable f o r some p >* 0, then '4 is recognizable I COROLLARY 10.3. For any recognizable N-subset '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 N-subsets of Sx
I
11. The Subtraction Theorem
Let A and B be N-subsets 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 N-subset
5 A , we may define A
B by
1
consider the N-subsets 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 non-recognizable set (Example II,S.4). 'Thus the N-subset C' - I1 of L'" is not recognizable. Let A and 13 be recognizable N-subsets .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
~
COROLLARY 11.2.
For ever-v integer k 2 0, the set
A
L
k.Y*
is recogiiizable COROLLARY 11.3.
I;Or niiy iiiteger k
1k) is a recognizable +'-subset of
L*,
Indeed this set is ( A - k P ) t
I
0, the set
12. Undecidable Propositions
,.1his follows from Corollary
155
11.3 using eoniplcmentatioii and inter-
I
section
Show that -4, is reco~tti:nl)le. 12. Undecidable Propositions
O n tlic previous pages and also in Chapter I 1 we gave a nrimbcr of efkctive procediires for dccicling a number of questions. \Ve did this lvithout defining the notion of an “effective procccliire.” \’e siniply described thc procediire and assumed that the reader will find it “effective” enough for his satisfaction. \I’hcn it conies to proving that in sonic situation such an effective procedure docs not esist, obviously a tiiorc formal definition is needed. ‘l’liis, however, \vill not take place until Yolurne I). In the tncantiinc, \ve shall have to be satisfied \vith a “relative undecidability” in the follo\ving sense : O n e particular undecicl;iblc proposition I’ will be stated (its undccidability ivill be pro\,ed in Volume I)). Any proposition (1 will be called rinderidnhle if a decision procedure for Q \rrould, using naive means, imply a decision procedure for I). ‘L’he particular proposition most suited for a choice o f P is tlic POST CORRESPONDENCE PROBLEM. Giwn any finite nlphnhet 1: and given t w o mwpltisitis g, 11 ; 1* + 2* decide wlwtlitv or not there exists sl1. sE s1rclz thmt sg \‘I
If L
(12.1)
~
~
{cT,,
. . . , u,?}, then g and h are defined by words XI,
. . . , x,, E 2”,
y , , . . . , y n E 2”
VI. Multiplicity
156
given by x i = uig, y i = uih. If s E S+ is given by s = ui,. , . u i k ,k then sg = sh holds iff (12.2)
xi,
> 0,
. . . x.hk = y i , . . . yis
T h e problem consists in finding an effective procedure for deciding, once (12.1) is given, whether a sequence (il,. . . , ik) exists with k > 0 such that (12.2) holds. I t will be shown that (with a suitable definition) such a procedure does not exist.
Given recognizable N-subsets B and C of S" such that B 5 C , it is undecidable whether or not there exists s E S+ such that sB = sc. THEOREM 12.1.
Proof. We show that if a decision procedure for the problem above exists, then a decision procedure for the Post Correspondence Problem would follow. T h e proof utilizes an injective morphism
where N2x2 is the monoid of 2x3-matrices with entries in N . From Exercise V,2.2 it follows that
yields such a morphism. Another one is given by
T h e choice of the morphism y is immaterial for the rest of the proof. The only fact needed is that it be injective. Given morphisms g , h : S" + 2 " consider the compositions
12. Undecidable Propositions
157
where
Gij, H i , : Z* + N ,
i, j
E
2
are functions. T h u s we may regard G i j and H i j as N-subsets of S*. By Corollary 7.1 1, these N-subsets of I * are recognizable. Consider the N-subsets A , B, C of S* defined by the functions
,4
=
C (Gij- H i j ) 2 L.J
Then
A
4-B = C,
B 5C
Clearly B and C a r e recognizable since they are obtained froni recognizable subsets by the operations and n. Let s E z".T h e n sB = sC iff sA = 0. This holds iff sGij = s H i j for all i , j E 2, i.e., iff sgy = shy. Since y is injective, this holds iff sg = sh. T h u s a decision procedure for finding such an s, leads to a decision procedure for the Post Correspondence Problem [
-+
THEOREM 12.2. Given recognizable N-subsets B and C of 2'*, it is undecidable whether B 5 C .
Let B' and C' be recognizable N-subsets satisfying B' 5 C'. Consider the recognizable N-subsets Proof.
B
=
B'
C= f If,
C'
Then the inequality
B I C holds if€
sB' < sC'
for all s E z"
This question has however been shown to be undecidable
[
Let B and C be recognizable N-subsets of X*.Define by setting SD = Sup(sB, SC)
Sup(B, C)
D
=
158
VI. Multiplicity
T h e question whether , ! I5 C is then equivalent with the question whether D = C. If we could (constructively) prole that D always is recognizable, then by the Equality ’l’hcoreni we could decide whether D= C, i.e., \+hethcr B B 5 C. It fo1lon.s that given automata 8 and ‘6such that I 8 I and 1 P 1 = C there is no algorithm for constructing an automaton 3 7 such that I 9 I = D. This does exclude the possibility that D is recognizable. However, this is extremely unlikely since a constructive proof cannot exist. An explicit counterexample is lacking. A similar argument applies to Inf(B, C). ‘Two other open problems are listed: OPEN PROBLEM.
‘4
Let A , B, C be N-subsets of =
B nC
and
Bt
=
P. iZssiiine Ct
If A and B are recognizable, is C recognizable ? OPEN PROBLEM. Let A be an N-subset of 2’”. If A n A is recognizable, is A recognizable ? References M. P. Schutzenberger, Certain elementary families ot automata, “Proceedings of Sy mposium o n Mathrimtical Th eo r y of Automata,” Polytcchnic Institute of Brooklyn, 1962, 139-153.
This paper introduces Z-subsets, N-subsets, and also #-subsets through the mechanism of formal power series which arc essentially the expansions (3.1). Subsequent publications of Schutzenberger and several of his associates considered only the case K = 2 (or more generally, the case when K is a comniutativc ring) and took on a very algebraic or analytic outlook. T h e aim has become to generalize various theorems from classical analysis to the case of power series in several non-commuting variables. T h e results of Sections 8-12 are new and were obtained by the author in collaboration with M. P. Schutzenberger. T h e proof of the Equality Theorem (Theorem 8.1) went through several improvements, and one major improvement was contributed by M. 0. Rabin.
CHAPTER
VII Rationa/ Sets
In this chapter we consider rational sets (also known as “regular sets” or “regular events”). T h e key result here is Iilcene’s Theorem which asserts that “rational” equals “recognizable” in a finitely generated free monoid. Kleene’s Theorem is the first major theorem of the theory of automata, both chronologically (1956) and in terms of its actual position in the subject. 1. +-Algebras
Let K be a commutative scmiring. ,4n algebra over K (or a K-algebra) consists of a set ‘4 equipped with four operations. T w o of these are binary operations which to elements a, 0 E i3 assign elements a
+ b,
a
. b (usually written ab)
of A. One is a mixed operation which to each k E K and each a E A assigns an element ka E ‘4. T h e fourth one is a nullary operation which singles out a zero element 1.3of ’4. T h e axioms are
a + b - b f a a -1- ( b $- c ) = (0 b ) c (k,k,)rz = h,(k,n), l a = a, Oa Ld k ( ~ b ) = ka -k kb (k, k 2 ) a = k , -4~ k,cl, a(bc) = (a/,)c a(/) c) = ab ac ( a b)c = ar $- be, k(ab) = ( k ~ ) = b a(kb)
+ +
:
+
+
+
+
159
+
VII. Rational S e t s
160
T h e axioms are a paraphrase of the axioms of an algebra over a commutative ring adapted to the semiring situation. Indeed if K is a ring, then we may define -a = (-1)a. Then a
+ (-a)
= la
+ (-1)a
=
+ (-1)).
(1
=
Oa
=
@
so that A becomes a K-algebra in the traditional sense. We prove that
a+ @=a,
@a= @ = a 0
Indeed a+ D=la+Oa=(l+O)a= la=a @u = (O@)a = O( @a) = @ a @ = a(O@) = O ( a 0 ) = 0 As in the case of a semiring (see VI,2) the operation a replaced by the operation a<
+ b may be
c
,ieI
for any finite indexing set I , and the axioms may be reformulated accordingly. If K is a complete commutative semiring and if Ciclai is given for any indexing sct I (not necessarily finite), with the proper generalization of the axioms satisfied, then we say that A is a complete K-algebra. We let the reader make an explicit list of the axioms. A +-algebra over K (or a K+-algebra) is simply a K-algebra A with an additional unary operation a+ subject to no axioms whatsoever. T h e a2 ... operation a + is intended to represent the infinite sum a an . . .. Consequently if K is complete and A is a complete Kalgebra, A can always (and always will) be converted into a K+-algebra by setting
+ +
+ +
m I
a+ = C an fl=l
Let A be a K+-algebra. A subset B of A is called a subalgebra of A if B is non-empty and if for any b, b’ E B and k E K , the elements
(1.1)
b
+ b’,
bb‘,
kb,
b+
are in B. Since Ob = @ it follows that 0E B. Thus B is a K+-algebra. It is clear from the definition that the intersection of any family of subalgebras of A is again a subalgebra of A. Consequently given any
1. +-Algebras
161
subset B, we may define the closure
B
as
where C ranges over all the subalgebras of A containing B. T h u s B is the smallest subalgebra of A containing B. I n other words B is the smallest non-empty subset of A , containing B and closed under the four operations (1.1). We shall refer to these four operations as the rational operations. T h u s a subalgebra is a non-empty subset which is rationally closed (i.e., is closed under the four rational operations). Let a : K + K' be a morphism of semirings, A a K+-algebra, and let A' be a K'+-algebra. A function p: A A' is called a morphism of Kf-algebras (relative to a ) if it satisfies --f
a.
for all a , b E A and K E K . Taking k = 0 it follows that = When K = K' and c( is not specified, it will silently be assumed that ( I is the identity. With K fixed, the K+-algebras form a category in the obvious manner.
PROPOSITION 1.1. Let A be K+-algebra, A' a K'+-algebra, let p: A + A' be a morphism relatice to a morphism u : K + k".
and
I f B' is a subalgebra of A ' , then B'T-' is a subalgebra of A. I f (1 is surjective and B is a subalgebra of A , then By) is a subalgebra of A'. (iii) For any subset B of A
(i) (ii)
Bp
c
Bp,
I f further u is surjective, then Bp
=
Bp
+
Ad (i). Let a, b E B'vl-', i.e., ap., b y E B'. Then ( a b)p = ap bp E B' so that a b E B'q-1. T h e proof for the other operations is similar. Proof.
+
+
VII. Rational Sets
162
Ad (ii). Let a', b' E B y , i.e., a' = aq, 6' = bp with a, b E B. T h e n b' = up, bq = ( a b ) y E Bv. Similarly a'b' E Bq and a'+ E Brp. If k' E K ' , then since a is surjective, k' = ku for some k E K . Consequently k'a' = ( k a ) ( a p ) = (ka)p E Bp
a'
+
+
+
Ad (iii). Since B c Byy-' c Byy-' and &y]-' is a subalgebra of A [by (i)] it follows that B c &q-l, i.e., Bq c If (;I is surjective, then
&.
by (ii), By is a subalgebra of B. Since Bp c Bp it follows that
&c
I
The construction of the rational closure B of a subset 13 of a K+algebra A may be presented inductively by constructing a sequence
B'-" c B(O)c B ( ' )c . , . c B'") c . . such that
(1.2) T h e definition of the sets B(h) is as follows:
(1.3) B'-" is empty. consists of all finite sums of monomials (1.4) B(h+l)
k n , . . . a,, with k
E
K , and
ai E
R or a i = C + with c E B ( h )
Thus, in particular, B'O) consists of all finite sums of monomials ka, . . . a,, with a , , . . . , a,, E B. T h e verification of (1.2) is immediate. T h e elements of - B'h-l) are said to have height h . T h e K+-algebra '4 is callcd zinituvy if there exists an element l A E j A such that for all a E A l,a = u = a1 I, For a unitary K+-algebra '4, we denote a" = 1
+ a'
2 . Rational K-Su bsets
163
Even when A is not unitary we shall use
a"6
and
6a"
and
6 +bat
as convenient abbreviations for
a76
+6
2. Rational KJubsets
Let K be a commutative complete semiring and let S be a semigroup. With the operations
as defined in V1,3 and VI,5, the set k'" of all the K-subsets of S forms a complete K-algebra. Consequently with
K s also is a K-+-algebra. We shall bc interested in the subalgebra Rat,; S which is the closure of the class of all singletons of S . T h e K-subsets of S belonging to RatI; S are called rational. More generally given any class '8 of K-subsets of S we shall denote by Rat,<'&'
or
Rat '8
the closure 7 of @' in K". We call Rat,; 5 the rational closure of the class '8. It is important to emphasize that even though in eS infinite summation is available, in the formation of Rat,; '%' only finite sums are used. Otherwise the closure of the set of all singletons of S would be all of K.". Let Q : K 4 K , be a niorphisni of complete semirings and S a semigroup. For each A E nS, we have A p E K,S and there results a inorphism of +-algebras
VII. Rational Sets
164
over cp: K + K,. Since (2.1) maps singletons into singletons, Proposition 1.1, (iii) implies: PROPOSITION 2.1.
If y ~ K : + K' is a morphism
of complete semirings,
then for each semigroup S
(Rat,; S)v c RatK, S.
If further
'p:
K + K ' is surjective, then (Rat, S)'p = Rat,, S
COROLLARY 2.2.
I
If K is positive, then (RatK S)t = Rat.2 S
I
Let S , S' be semigroups and let
f: S + S ' be a K-relation which is multiplicative, i.e., such that
for all x , y E S . For each A results a function
E
KS we then have Af E Ks' and there
f: Ks + KS' which is a morphism of K+-algebras. This follows from the identities
From Proposition 1.1, (iii), we deduce: PROPOSITION 2.3. Let S , S' be semigroups and f: S tiplicative K-relation. Let
@ = {xf
IXE S}
+
S' a mul-
2. Rational K-Su bsets
165
Then (RatIc S)f
=
Ratl,.
5 I
Since a morpliism f : S + S' is a special case of a multiplicative relation we obtain : PROPOSITION 2.4,
Let f ; S
4
S' be a morphism of senilgroups. Then
(Rat,; S ) f c Ratlc S'.
I f further f : S
+
S' is surjective, then (RatK S)f
=
Rat,,. S'
I
PROPOSITION 2.5. Let S be a semlgroup. For each A E RatK S there exists a finite alphabet .Z and a niorphisni f : S+ + S such that A = Bf for some B E RatK S+.
Further, ;f I' is any subset of S generating S , then f may be chosen so that Zf c r. be an alphabet in a 1-1 correspondence with the set l', Proof. Let and let f : p++ S be the morphism defined by pf = y . Since generates f is surjective. T h u s by Proposition 2.4 we have A = /if for some A E Rat,; p. T h e conclusion now follows from:
r
S,
PROPOSITION 2.6. Let k' be a complete semiring and r an infinite alphabet. For each A E Ratli r+(resp. A E Rat,; P ) there exists a finite subset S of I ' s u c h that A E Rat,; If(resp. A E Rat,; Z"). Proof. Let A be the class of all rational K-subsets of T+ for which the conclusion holds. Clearly all singletons are in g.It is also clear that t8' is rationally closed. T h u s Rat!; T +c 6' I
COROLLARY 2.7. For each seinigroup S Rat,; S =
U RatK Si
where S , ranges ocer all the finitely generated subsemigroups of S . If S = I*or S = Yr+, it suffices to consider S , = Eb*or S , = S,+ with
z l C sI
VII. Rational Sets
166
\lie rcnrind the reader that in this section K is assumed to be a complete semiring. 'l'lic case \\.lien K is a seniiring that is not ncccssarily complete will be treated in Section 4. EXERCISE 2.1. Let K 1)r N (coniniiitati7~ecomplete) semiring, and let A , '4' be cntnplete K-algebras. Dejinr ( I morphisni (1 : .4 -+ '4' as a function S(I t i s f ying
(C JOT (k.J)r/
IZ(A/),
c (J,T)
('4/1)(/
~
(.4f/)(Hy)
Show tlicrt this yields a category A,; (4roniplete I\'-algehr.os. Show that in this rntegory the (rIgehras Kx', where V is any set, are free. This means that for anjl roniplete K-algebrii A , tiny fiinctiori f : .Y -* '4 udniits a unique tnorphism 78: K L 1-+ .4 which iigvees with ,f on the singletons 0 E I. EXERCISE 2.2. IVithitz thr terniitzology of Exerrise 2.1, show that any tnorphistn 71: K s + P ' ,where S and S' are semigroiips, is defined by a niiiltiplirntive K-relation f : S + S ' .
I d K be a coniplrte serniritig cind S a sernigroiip. Show that the K-(rlgebra KS is coniniiitative ;ff S is commutatizw. Show that Es is unitary I# ,S is n motioid. EXERCISE 2.3.
EXERCISE 2.4. Let K be a (conzplete rotnniiitativr) serniring. 1,rt ( S ,, i E I ) be a f(ztni1y of subsemigroups of n srtnigroiip S siirlr that
(i)
S
=
u Si it I
(ii)
Given i, , i, E I , there exists i E I such that
Show thut RatK S =
Rat,; Si it1
3. Rational Expressions and Identities
In making ~ 1 pthe list of axioms for a K+-algebra we did not list any axioms involving the operation a ' . In the K-+-algebras k'" that we studicd in Section 2 many identities liold involving thc operation a +.
3. Rational Expressions and Identities
167
We give a partial list of the ones that seein to be of importance
(3.1)
.3'
(3.2)
aaf =
3 a+a
(3.3)
(I
=
a"0
(3.4P)
lZ+
=
( a -1 . . .
(3.5)
(""b)+
(3.6)
(a
(3.7)
= (a
+ aP)(uP)",
p
1
-16)"b
t 6 ) + = (a*b)+cz" + a ' (ah)+- a(0a)"b
Before we indicate the proofs, we must discuss the meaning of these equations. Consider (3.5)-(3.7). If a and 6 are elenients of a K+-algebra A , then both the left-hand side and the right-hand side are elements of '4 that we may denote by
respectively. These functions
are built using thc rational operations only and are called rational expressions in two variables. T h e equation ( a , b ) u = (a, O)ZJ does not hold in all K+-algebras A. Howcver, it does hold if .4 = k's, where S is a semigroup. We show that it suffices to verify the equation ( a , / I ) . = ( a , 6)u in the generic case when S {o,-c}+ and a = 0 , 6 T . Indeed, assume :
Let A , B
E
Ks, and consider the multiplicative A--relation f:
(0,
-c}++S
defined by Uf'-
iz,
Tf
Then f defines a morphistn f : K{'~ri'
--f
=
B
k"of K+-algebras. Since u
VII. Rational Sets
168
and
ZJ
are built using only the rational operations, we have
and similarly for v . T h u s (3.8) implies
( A , B)u = ( A , B)" as required. When written in the generic case the identities become obvious. For instance, (3.8) becomes
(rift)'which asserts that any word of written in the form
= (0 (0,7 ) '
C,TC27
+ T)*T ending with
T
can uniquely be
. . . C,,T
with n > 0 and with each c i a power of 0 or c i = 1. From these identities one can derive others that are much less obvious. We give an interesting example. Let a ( p ) denote the pth iterate of a+
a(P)= ( p a ) * a
(3.9)
for all p 1 1
For p = 1 the equation becomes a+ = .+a (3.9) for p we compute using (3.5) a(P+')= (a(,))+ = ((pa)*a)' = ( p a
which is (3.3). Assuming
+ a)*a = ( ( p + l)a)*a
as required. Observe that if K = .a,then p a = a so that (3.9) becomes a(,) = a + or equivalently a++ = a+. Let L be any list of identities valid in all the K+-algebras Ks. Denote by A ( L ) the class of all K+-algebras in which all the identities in L are valid. We say that I, is complete if A ( L ) c A ( L ' ) where L' is any other such list. W e quote without proof the following:
.'a,
(Conway) If K = then any complete list of identities must contain infinitely many identities with two or more variables I THEOREM 3.1.
3. Rational Expressions and Identities
169
We shall now assume that the semiring K is positive. T h e height uh of a rational expression u is defined inductively as
@h=0, (u
ah=O
+ v ) h = max(uh, vh)
( k u ) h = uh
if
(uv)h = max(uh, v h ) (11
' )h = 1 f
ku f 1 3 if
u # 3f v
24h
T h u s the height measures the number of nested +-operations. In identity (3.1) the left-hand side has height 1 while the right-hand side has height 0. In ( 3 . 5 ) the left-hand side has height 2 while the right-hand side has height 1. If A E Rat,; E + ,the height iliz of A is the least height of a rational expression representing A. T h e question as to whether one can effectively determine the height of any rational K-subset of S t is open. An equivalent question is to give an algorithm to decide whether, for a given rational expression u of height 11, a rational expression v of height lower than h can be found representing the same K-subset of S t as u. T h e following $-subsets Ah of {a, 7 ) ' are known to have height exactly h A, = (at)'
A,,, EXERCISE 3.1.
=
(a?4,LT?4h)t
Let
be rational ecpressions. Show that if the equation (a,,
. . . , a,,)u= ( a , , . . . , a , , ) ~
holds for a , , . . . , a , E Rat,; {a, t}+,then it holds f o r a , , . . . , a,, E K S , where S is aniv semigroup. [Hint: Use the coding S* + 2" of ~ 7 . 1 EXERCISE 3.2. Show that the dejinition of height given in this section agrees with the one given in Section 1.
170
VII. Rational Sets
4. Locally Finite Monoids
In trying to define the class Rat,,- S when S is a semigroup and K is a commutative semiring not assumed to be complete we encounter the following difficulties. T h e formula
x ( A B )=
c (yA)(zB)
z=gz
cannot be used unless x admits only a finite number of factorizations x = y z . Also the family of K-subsets A”, n E N , need not be locally finite, so that A’ cannot be defined. T o overcome this difficulty we must put some restriction on the semigroup A semigroup S is said to be locally jinite if each x E S admits only a finite number of factorizations
s.
.Y = .Y1
(4.2)
. . . xjl
A locally finite semigroup cannot have an idempotent element and thus cannot have a unit element. For a locally finite semigroup the summation (4.1) is finite. Also, if n is the largest intcger for which a factorization (4.2) exists, then x ( A p ) 0 for n < p and .4+ = AILis well defined. Consequently k”’ becomes a K +-algebra and Rat,; S is defined without any difficulty, just as in the case when K was complete. All the conclusions of Section 2 now carry over with the completeness assumption on K replaced by the local finiteness of the semigroup. I n Propositions 2.3 and 2.4 we must assume that f is locally finite (see VI,4) while in Proposition 2.5 we must add the local finiteness off to the conclusion. We let the reader verify the details. T h e difficulties are, however, not yet over. Since a locally finite semigroup cannot have a unit element, we do not have the class Ratli V* except when K is complete. Indeed 1” will involve the infinitc summation 1 1 .... A monoid M is said to be locally jinite if each x E M admits only a finite number of factorizations (4.2) with x, f 1 for 1 5 i 5 n. I t follows that if xy = 1, then s = 1 = y , since otherwise infinitely many factorizations xysy . . . xy of 1 are obtained. If follows that M - = M - 1 is a semigroup and indeed is a locally finite semigroup. Conversely, if M - is any locally finite semigroup, then the monoid
x:=l
+ +
(4.3)
M=l+M
171
4. Locally Finite Monoids
obtained from Ill- by adj