Monographs in Theoretical Computer Science

2 downloads 0 Views 5MB Size Report
both functions fi = pri ◦ f, i = 1, 2 are monotone or continuous, where pr1 and pr2 denote the ...... {caa, cbc, dca, ddc} {cab, cbd, dcb, ddd}. ) . It is easily proved ...... Hence, the constructions transform unambiguous grammars into unam- biguous ...
Monographs in Theoretical Computer Science An EATCS Series Editors: W. Brauer J. Hromkoviˇc G. Rozenberg A. Salomaa On behalf of the European Association for Theoretical Computer Science (EATCS)

Advisory Board: G. Ausiello M. Broy C.S. Calude A. Condon D. Harel J. Hartmanis T. Henzinger T. Leighton M. Nivat C. Papadimitriou D. Scott

Manfred Droste r Werner Kuich r Heiko Vogler Editors

Handbook of Weighted Automata

Editors Prof. Dr. Manfred Droste Universit¨ at Leipzig Institut f¨ ur Informatik 04009 Leipzig, Germany [email protected]

Prof. Dr. Werner Kuich Technische Universit¨ at Wien Institut f¨ ur Diskrete Mathematik und Geometrie 1040 Wien, Austria [email protected]

Prof. Dr.-Ing. Heiko Vogler Technische Universit¨ at Dresden Institut f¨ ur Theoretische Informatik 01062 Dresden, Germany [email protected]

Series Editors Prof. Dr. Wilfried Brauer Institut f¨ ur Informatik der TUM Boltzmannstr. 3 85748 Garching, Germany [email protected]

Prof. Dr. Juraj Hromkoviˇ c ETH Zentrum Department of Computer Science Swiss Federal Institute of Technology 8092 Z¨ urich, Switzerland [email protected]

Prof. Dr. Grzegorz Rozenberg Leiden Institute of Advanced Computer Science University of Leiden Niels Bohrweg 1 2333 CA Leiden, The Netherlands [email protected]

Prof. Dr. Arto Salomaa Turku Centre of Computer Science Lemmink¨ aisenkatu 14 A 20520 Turku, Finland asalomaa@utu.fi

ISBN 978-3-642-01491-8

e-ISBN 978-3-642-01492-5

Monographs in Theoretical Computer Science. An EATCS Series. ISSN 1431-2654 Library of Congress Control Number: 2009926056 ACM Computing Classification (1998): F4.3, F1.1, F1.2 Mathematics Subjects Classification (2000): 68Q45, 68Q70, 03B50, 03B70, 03D05, 68R99, 68Q85 c 2009 Springer-Verlag Berlin Heidelberg  This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilm or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer. Violations are liable to prosecution under the German Copyright Law. The use of general descriptive names, registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.

Cover Design : K¨ unkelLopka GmbH Printed on acid-free paper 9 8 7 6 5 4 3 2 1 springer.com

Preface

The purpose of this Handbook is to highlight both theory and applications of weighted automata. Weighted finite automata are classical nondeterministic finite automata in which the transitions carry weights. These weights may model, e.g., the cost involved when executing a transition, the amount of resources or time needed for this, or the probability or reliability of its successful execution. The behavior of weighted finite automata can then be considered as the function (suitably defined) associating with each word the weight of its execution. Clearly, weights can also be added to classical automata with infinite state sets like pushdown automata; this extension constitutes the general concept of weighted automata. To illustrate the diversity of weighted automata, let us consider the following scenarios. Assume that a quantitative system is modeled by a classical automaton in which the transitions carry as weights the amount of resources needed for their execution. Then the amount of resources needed for a path in this weighted automaton is obtained simply as the sum of the weights of its transitions. Given a word, we might be interested in the minimal amount of resources needed for its execution, i.e., for the successful paths realizing the given word. In this example, we could also replace the “resources” by “profit” and then be interested in the maximal profit realized, correspondingly, by a given word. Furthermore, if the transitions carry probabilities as weights, the reliability of a path can be formalized as the product of the probabilities of its transitions, and the reliability of a word could be defined again as the maximum of the reliabilities of its successful paths. As another example, we may obtain the multiplicity of a word, defined as the number of paths realizing it, as follows: let each transition have weight 1; for paths take again the product of the weights of its transitions (which equals 1); then the multiplicity of a word equals the sum of the weights of its successful paths. Finally, if in the latter example we replace sum by “maximum,” weight 1 is associated to a word if and only if it is accepted by the given classical automaton.

v

vi

Preface

In all of these examples, the algebraic structure underlying the computations with the weights is that of a semiring. Therefore, we obtain a uniform and powerful automaton model if the weights are taken from an abstract semiring. Here the multiplication of the semiring is used for determining the weight of a path, and the weight of a word is then obtained by the sum of the weights of its successful paths. In particular, classical automata are obtained as weighted automata over the Boolean semiring. Many constructions and algorithms known from classical automata theory can be performed very generally for such weighted automata over large classes of semirings. For particular properties, sometimes additional assumptions on the underlying semiring are needed. Another dimension of diversity evolves by considering weighted automata over discrete structures other than finite words, e.g., infinite words, trees, traces, series-parallel posets, or pictures. Alternatively, in a weighted automaton, the state set needs not to be finite, so we can consider, e.g., weighted pushdown automata with states being pairs of states (in the usual meaning) and the contents of the pushdown tape. Moreover, weighted context-free grammars and algebraic systems arise from weighted automata over trees by using the well-known equivalence between frontier sets of recognizable tree languages and context-free languages. For the definition of weighted automata and their behaviors, matrices and formal power series are used. This makes it possible to use methods of linear algebra over semirings for more succinct, elegant, and convincing proofs. Weighted finite automata and weighted context-free grammars were first introduced in the seminal papers of Marcel-Paul Sch¨ utzenberger (1961) and Noam Chomsky and Marcel-Paul Sch¨ utzenberger (1963), respectively. These general models have found much interest in Computer Science due to their importance both in theory as well as in current practical applications. For instance, the theory of weighted finite automata and weighted context-free grammars was essential for the solution of classical automata theoretic problems like the decidability of the equivalence: of unambiguous context-free languages and regular languages; of deterministic finite multitape automata; and of deterministic pushdown automata. For the variety of theoretical results discovered, we refer the reader to the indispensable monographs by Samuel Eilenberg (1974), Arto Salomaa and Matti Soittola (1978), Wolfgang Wechler (1978), Jean Berstel and Christophe Reutenauer (1984), Werner Kuich and Arto Salomaa (1986), and Jacques Sakarovitch (2003). (See Chap. 1 for precise references.) On the other hand, weighted automata and weighted context-free grammars have been used as basic concepts in natural language processing and speech recognition, and recently, weighted automata have been used in algorithms for digital image compression.

Preface

vii

Since the publication of the mentioned monographs, the field of weighted automata has further developed both in depth and breadth.1 The editors of this Handbook are very happy that international experts of the different areas agreed to write survey articles on the present shape of their respective field. The chapters of this Handbook were written such that a basic knowledge of automata and formal language theory suffices for their understanding. Next, we give a short overview of the contents of this Handbook. Part I provides foundations. More specifically, in Chap. 1, Manfred Droste and Werner Kuich present basic foundations for the theory of weighted automata, in particular, semirings, formal power series, and matrices. As is well known, regular and context-free languages can be obtained as least solutions of suitable fixed ´ point equations. In Chap. 2, Zolt´ an Esik provides an introduction to that part of the theory of fixed points that has applications to weighted automata and their behaviors, and to weighted context-free grammars in the shape of algebraic systems. Part II of this Handbook investigates different concepts of weighted recog´ nizability. In Chap. 3, Zolt´ an Esik and Werner Kuich develop the theory of finite automata starting from ideas based on linear algebra over semirings. In particular, they derive the fundamental Kleene–Sch¨ utzenberger characterization of the behaviors of weighted automata over Conway semirings. In Chap. 4, Jacques Sakarovitch presents the theory of rational and recognizable formal power series over arbitrary semirings and graded monoids. As a consequence, he derives that the equivalence of deterministic multitape transducers is decidable. A seminal theorem of J. Richard B¨ uchi (1960) and Calvin C. Elgot (1961) shows the equivalence in expressive power between classical finite automata (over finite and infinite words) and monadic second-order logic. In Chap. 5, Manfred Droste and Paul Gastin present a weighted version of monadic second-order logic and derive corresponding equivalence results for weighted automata. In Chap. 6, Mehryar Mohri presents several fundamental algorithms for weighted graphs, weighted automata, and regulated transducers as, e.g., algorithms for shortest-distance computation, ε-removal, determinization, minimization, and composition. In Part III of this Handbook, alternative types of weighted automata and various discrete structures other than words are considered. In Chap. 7, Ion Petre and Arto Salomaa present the core aspects of the theory of algebraic power series in noncommuting variables, weighted pushdown automata, and their relationship to formal languages. In Chap. 8, Juha Honkala extends the theory of algebraic power series by considering Lindenmayerian algebraic systems and several restricted such systems. The following two chapters consider weighted automata acting on extensions of finite words. In Chap. 9, Zolt´ an F¨ ul¨ op and Heiko Vogler survey the theory of weighted tree automata and weighted tree transducers. This combines classical results of weighted au1

For instance, see the biennial workshops on “Weighted Automata: Theory and Applications” (WATA) since 2002.

viii

Preface

tomata and transducers on words and of unweighted tree automata and tree transducers. In Chap. 10, Ina Fichtner, Dietrich Kuske, and Ingmar Meinecke present different weighted automata models for concurrent processes, formalized by traces and series-parallel posets, and analyze their relationships. They also consider two-dimensional extensions of words, namely pictures. Part IV deals with applications of weighted automata. In Chap. 11, J¨ urgen Albert and Jarkko Kari present the use of weighted automata and transducers for digital image compression and give comparisons with the image compression standard JPEG. In Chap. 12, George Rahonis describes the theory of fuzzy recognizable languages. This theory arises by considering weighted automata over particular semirings, namely bounded distributive lattices. In Chap. 13, Christel Baier, Marcus Gr¨ oßer, and Frank Ciesinski present the main concepts of Markov decision processes as an operational model for probabilistic systems, and basic steps for the (qualitative and quantitative) analysis against linear-time properties. In Chap. 14, Kevin Knight and Jonathan May address the reawakened interest in string and tree automata among computational linguists. The chapter surveys tasks occurring in natural language processing and shows their solutions by using weighted automata. Some of the chapters contain open problems. We hope that this will stimulate further research. Finally, we would like to express our thanks to all authors of this Handbook and to the referees for their careful work. Moreover, warm thanks go to Carmen Heger for her support in the technical compilation of the chapters. Manfred Droste Leipzig May 13, 2009

Werner Kuich Wien

Heiko Vogler Dresden

List of Contributors

J¨ urgen Albert Universit¨ at W¨ urzburg Informatik II 97074 W¨ urzburg, Germany albert@informatik. uni-wuerzburg.de Christel Baier Technische Universit¨at Dresden Faculty of Computer Science 01062 Dresden, Germany [email protected] Frank Ciesinski Technische Universit¨at Dresden Faculty of Computer Science 01062 Dresden, Germany [email protected]. tu-dresden.de

Ina Fichtner Universit¨ at Leipzig Institut f¨ ur Informatik 04009 Leipzig, Germany fichtner@informatik. uni-leipzig.de Zolt´ an F¨ ul¨ op University of Szeged Department of Computer Science 6720 Szeged, Hungary [email protected] Paul Gastin LSV, ENS Cachan, INRIA, CNRS 94230 Cachan, France [email protected]

Manfred Droste Universit¨ at Leipzig Institut f¨ ur Informatik 04009 Leipzig, Germany droste@informatik. uni-leipzig.de

Marcus Gr¨ oßer Technische Universit¨at Dresden Faculty of Computer Science 01062 Dresden, Germany [email protected]

´ Zolt´ an Esik University of Szeged, Szeged, Hungary, and Rovira i Virgili University Tarragona, Spain

Juha Honkala University of Turku Department of Mathematics 20014 Turku, Finland [email protected] ix

x

List of Contributors

Jarkko Kari University of Turku Department of Mathematics 20014 Turku, Finland [email protected]

Mehryar Mohri Courant Institute of Mathematical Sciences New York, NY 10012 [email protected] Google Research Kevin Knight New York, NY 10011 USC Information Sciences Institute USA Marina del Rey, CA 90292 [email protected] USA [email protected] Ion Petre Academy of Finland and Werner Kuich ˚ Abo Akademi University Institut f¨ ur Diskrete Mathematik Turku 20520, Finland und Geometrie [email protected] Technische Universit¨at Wien 1040 Wien, Austria George Rahonis [email protected] Aristotle University of Thessaloniki www.dmg.tuwien.ac.at/kuich Department of Mathematics Dietrich Kuske Universit¨ at Leipzig Institut f¨ ur Informatik 04009 Leipzig, Germany kuske@informatik. uni-leipzig.de

54124 Thessaloniki, Greece [email protected] Jacques Sakarovitch CNRS and Ecole Nationale Sup´erieure des T´el´ecommunications 75634 Paris Cedex 13, France [email protected]

Jonathan May USC Information Sciences Institute Arto Salomaa Marina del Rey, CA 90292 Turku Centre for Computer Science USA Turku 20520, Finland [email protected] [email protected] Ingmar Meinecke Universit¨ at Leipzig Institut f¨ ur Informatik 04009 Leipzig, Germany meinecke@informatik. uni-leipzig.de

Heiko Vogler Technische Universit¨at Dresden Faculty of Computer Science 01062 Dresden, Germany [email protected]

Contents

Part I Foundations Chapter 1: Semirings and Formal Power Series Manfred Droste and Werner Kuich . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Monoids and Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Formal Power Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Cycle-Free Linear Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3 3 5 12 17 22 26

Chapter 2: Fixed Point Theory ´ ...................................................... Zolt´ an Esik 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Least Fixed Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Conway Theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Iteration Theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Unique Fixed Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Fixed Points of Linear Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1 Inductive ∗ -Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 Complete Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3 Iterative Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Fixed Points of Affine Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1 Complete Semiring–Semimodule Pairs . . . . . . . . . . . . . . . . . . . . . . 7.2 Bi-inductive Semiring–Semimodule Pairs . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

29 29 30 38 41 44 46 51 52 53 54 59 61 62

xi

xii

Contents

Part II Concepts of Weighted Recognizability Chapter 3: Finite Automata ´ Zolt´ an Esik and Werner Kuich . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 2 Finite Automata over Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 2.1 Finite Automata over Arbitrary Power Series Semirings . . . . . . . 72 2.2 Finite Automata over Conway Semirings . . . . . . . . . . . . . . . . . . . . 75 2.3 Finite Linear Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 3 Finite Automata over Quemirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 3.1 Semiring–Semimodule Pairs and Quemirings . . . . . . . . . . . . . . . . 85 3.2 Finite Automata over Quemirings and a Kleene Theorem . . . . . 91 3.3 Finite Linear Systems over Quemirings . . . . . . . . . . . . . . . . . . . . . 99 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Chapter 4: Rational and Recognisable Power Series Jacques Sakarovitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 2 Rational Series and Weighted Rational Expressions . . . . . . . . . . . . . . . 107 2.1 Series over a Graded Monoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 2.2 Rational Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 3 Weighted Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 3.1 The Behaviour of a Weighted Automaton . . . . . . . . . . . . . . . . . . . 122 3.2 The Fundamental Theorem of Automata . . . . . . . . . . . . . . . . . . . . 126 3.3 Conjugacy and Covering of Automata . . . . . . . . . . . . . . . . . . . . . . 132 4 Recognisable Series and Representations . . . . . . . . . . . . . . . . . . . . . . . . . 138 4.1 The Family of Recognisable Series . . . . . . . . . . . . . . . . . . . . . . . . . 138 4.2 Other Products on Recognisable Series . . . . . . . . . . . . . . . . . . . . . 141 4.3 Series on a Product of Monoids . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 5 Series over a Free Monoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 5.1 The Representability Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 5.2 Reduced Representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 5.3 Applications of the Reduction of Representations . . . . . . . . . . . . 161 6 Support of Rational Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 7 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 7.1 General Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 7.2 Notes to Sect. 2: Rational Series . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 7.3 Notes to Sect. 3: Weighted Automata . . . . . . . . . . . . . . . . . . . . . . 169 7.4 Notes to Sect. 4: Recognisable Series . . . . . . . . . . . . . . . . . . . . . . . 170 7.5 Notes to Sect. 5: Series over a Free Monoid . . . . . . . . . . . . . . . . . . 170 7.6 Notes to Sect. 6: Support of Rational Series . . . . . . . . . . . . . . . . . 171 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

Contents

xiii

Chapter 5: Weighted Automata and Weighted Logics Manfred Droste and Paul Gastin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 2 MSO-Logic and Weighted Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 3 Weighted Logics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 4 Unambiguous Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 5 Definability Equals Recognizability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 6 Locally Finite Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 7 Weighted Automata on Infinite Words . . . . . . . . . . . . . . . . . . . . . . . . . . 197 8 Weighted Logics on Infinite Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 9 Conclusions and Open Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Chapter 6: Weighted Automata Algorithms Mehryar Mohri . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 2 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 2.1 Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 2.2 Weighted Transducers and Automata . . . . . . . . . . . . . . . . . . . . . . . 215 3 Shortest-Distance Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 3.1 All-Pairs Shortest-Distance Problems . . . . . . . . . . . . . . . . . . . . . . . 218 3.2 Single-Source Shortest-Distance Problems . . . . . . . . . . . . . . . . . . . 222 4 Rational Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 5 Elementary Unary Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 6 Fundamental Binary Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 6.1 Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 6.2 Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 6.3 Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 7 Optimization Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 7.1 Epsilon-Removal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 7.2 Determinization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 7.3 Weight Pushing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 7.4 Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 7.5 Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 Part III Weighted Discrete Structures Chapter 7: Algebraic Systems and Pushdown Automata Ion Petre and Arto Salomaa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 2 Auxiliary Notions and Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 3 Algebraic Power Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

xiv

Contents

3.1 Definition and Basic Reductions . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 3.2 Interconnections with Context-Free Grammars . . . . . . . . . . . . . . 265 3.3 Normal Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 3.4 Theorems of Shamir and Chomsky–Sch¨ utzenberger . . . . . . . . . . . 271 4 Transductions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 5 Pushdown Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 5.1 Pushdown Transition Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 5.2 SΣ ∗ -Pushdown Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 5.3 Equivalence with Algebraic Systems . . . . . . . . . . . . . . . . . . . . . . . . 284 6 Other Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 Chapter 8: Lindenmayer Systems Juha Honkala . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 2 Iterated Morphisms and Rational Series . . . . . . . . . . . . . . . . . . . . . . . . . 292 3 Lindenmayerian Algebraic Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 4 D0L Power Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 5 Other Power Series Generalizations of L Systems . . . . . . . . . . . . . . . . . 307 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 Chapter 9: Weighted Tree Automata and Tree Transducers Zolt´ an F¨ ul¨ op and Heiko Vogler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 2 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 2.1 General Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 2.2 Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 2.3 Algebraic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 2.4 Tree Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 3 Weighted Tree Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 3.1 Bottom-up Tree Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 3.2 Recognizable Tree Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 3.3 Closure Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 3.4 Support of Recognizable Tree Series . . . . . . . . . . . . . . . . . . . . . . . . 328 3.5 Determinization of Weighted Tree Automata . . . . . . . . . . . . . . . . 330 3.6 Pumping Lemmata and Decidability . . . . . . . . . . . . . . . . . . . . . . . 331 3.7 Finite Algebraic Characterizations of Recognizable Tree Series . 335 3.8 Equational Tree Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 3.9 Rational Tree Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 3.10 MSO-Definable Tree Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 3.11 Other Models Related to Recognizable Tree Series . . . . . . . . . . . 353 3.12 Further Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 4 IO-Substitution and Tree Series Transformations . . . . . . . . . . . . . . . . . 361 5 Weighted Tree Transducers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 5.1 Tree Transducers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364

Contents

xv

5.2 The Basic Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 5.3 Restricted Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 5.4 Composition and Decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 5.5 The Inclusion Diagram of Some Fundamental wtt Classes . . . . . 386 5.6 Hierarchies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 5.7 Further Models of Weighted Tree Transducers . . . . . . . . . . . . . . . 391 5.8 Further Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394 Chapter 10: Traces, Series-Parallel Posets, and Pictures: A Weighted Study Ina Fichtner, Dietrich Kuske, and Ingmar Meinecke . . . . . . . . . . . . . . . . . . 405 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 2 Traces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 2.1 Weighted Distributed Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 2.2 Other Formalisms: Presentations, Expressions, and Logics . . . . . 411 2.3 Relating the Formalisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 2.4 History and Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 3 Series-Parallel Posets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 3.1 Series-Parallel Posets and Bisemirings . . . . . . . . . . . . . . . . . . . . . . 423 3.2 Weighted Branching Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 3.3 Rationality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 3.4 The Hadamard Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 3.5 History and Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 4 Pictures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 4.1 Pictures and Weighted Picture Automata . . . . . . . . . . . . . . . . . . . 436 4.2 Other Formalisms: Expressions and Logics . . . . . . . . . . . . . . . . . . 438 4.3 Relating the Formalisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 4.4 Decidability Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 4.5 History and Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446 Part IV Applications Chapter 11: Digital Image Compression J¨ urgen Albert and Jarkko Kari . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453 2 Image Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 3 Weighted Finite Automata and Multi-resolution Images . . . . . . . . . . . 457 4 Drawing WFA Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 5 An Encoding Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 6 Practical Image Compression Using WFA . . . . . . . . . . . . . . . . . . . . . . . 463 7 Weighted Finite Transducers (WFT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 8 Parametric Weighted Finite Automata (PWFA) . . . . . . . . . . . . . . . . . . 472

xvi

Contents

9 Conclusions and Open Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477 Chapter 12: Fuzzy Languages George Rahonis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 2 Lattices and Fuzzy Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 3 Fuzzy Recognizability over Bounded Distributive Lattices . . . . . . . . . 486 3.1 Fuzzy Recognizability over Finite Words . . . . . . . . . . . . . . . . . . . . 487 3.2 Fuzzy Recognizability over Infinite Words . . . . . . . . . . . . . . . . . . . 495 3.3 Multi-valued MSO Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 4 Fuzzy Languages: An Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505 4.1 Fuzzy Languages over -Monoids . . . . . . . . . . . . . . . . . . . . . . . . . . . 506 4.2 Fuzzy Languages over Residuated Lattices . . . . . . . . . . . . . . . . . . 507 4.3 Fuzzy Automata with Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509 4.4 Fuzzy Abstract Families of Languages . . . . . . . . . . . . . . . . . . . . . . 509 4.5 Fuzzy Tree Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509 5 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 Chapter 13: Model Checking Linear-Time Properties of Probabilistic Systems Christel Baier, Marcus Gr¨ oßer, and Frank Ciesinski . . . . . . . . . . . . . . . . . . 519 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 2 Markov Decision Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526 3 Maximal Reachability Probabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 4 Model Checking ω-Regular Properties . . . . . . . . . . . . . . . . . . . . . . . . . . 538 5 Partial Order Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547 6 Partially Observable MDPs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557 7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559 8 Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 Chapter 14: Applications of Weighted Automata in Natural Language Processing Kevin Knight and Jonathan May . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571 1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571 2 WFST Techniques for Natural Language Processing . . . . . . . . . . . . . . 572 2.1 Example 1: Transliteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573 2.2 Example 2: Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578 2.3 Language Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582 3 Applications of Weighted String Automata . . . . . . . . . . . . . . . . . . . . . . 583 3.1 Language Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 3.2 Speech Recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 3.3 Lexical Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585 3.4 Tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585

Contents

xvii

3.5 Summarization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 3.6 Optical Character Recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 4 Applications of Weighted Tree Automata . . . . . . . . . . . . . . . . . . . . . . . . 586 4.1 Open Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590 5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597

Chapter 1: Semirings and Formal Power Series Manfred Droste1 and Werner Kuich2 1

2

Institut f¨ ur Informatik, Universit¨ at Leipzig, 04009 Leipzig, Germany [email protected] Institut f¨ ur Diskrete Mathematik und Geometrie, Technische Universit¨ at Wien, 1040 Wien, Austria [email protected] www.dmg.tuwien.ac.at/kuich

1

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

2

Monoids and Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

3

Formal Power Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4

Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5

Cycle-Free Linear Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

1 Introduction It is the goal of this chapter to present basic foundations for the theory of weighted automata: semirings and formal power series. Weighted automata are classical automata in which the transitions carry weights. These weights may model, e.g., the cost involved when executing the transition, the amount of resources or time needed for this, or the probability or reliability of its successful execution. In order to obtain a uniform model of weighted automata for different realizations of weights and their computations, the weight structures are often modeled as semirings. A semiring consists of a set with two operations addition and multiplication satisfying certain natural axioms like associativity, commutativity, and distributivity, just like the natural numbers with their laws for sums and products. The behavior of weighted automata can then be defined as a function associating to each word the total weight of its execution; see Chaps. 3 and 4 of this handbook [12, 38]. Any function from the free monoid Σ ∗ of all words over a given alphabet Σ into a semiring S is called a formal power series. It is important to notice that

M. Droste, W. Kuich, H. Vogler (eds.), Handbook of Weighted Automata, Monographs in Theoretical Computer Science. An EATCS Series, c Springer-Verlag Berlin Heidelberg 2009 DOI 10.1007/978-3-642-01492-5 1, 

3

4

Manfred Droste and Werner Kuich

each language over Σ can be viewed as a formal power series over the Boolean semiring B and Σ ∗ (by identifying the language with its characteristic series). Therefore, formal power series form a generalization of formal languages, and similarly, weighted automata generalize classical automata. For other semirings (like the natural or real numbers), formal power series can be viewed as weighted, multivalued or quantified languages in which each word is assigned a weight, a number, or some quantity. In this chapter, we will present the basics of the theory of semirings and formal power series as far as they are used in the forthcoming chapters of this handbook. Now, we give a summary of the contents of this chapter. First, we consider various particular monoids and semirings. Many semirings (like the natural numbers) carry a natural order. Also, when generalizing the star operation (= Kleene iteration) from languages to formal power series, important questions on the existence of infinite sums arise. This leads to the notions of ordered, complete or continuous monoids and semirings. Besides these, we will consider the related concepts of star semirings and Conway semirings, and also locally finite semirings. Next, we introduce formal power series, especially locally finite families of power series and cycle-free power series. It is a basic result that the collection of all formal power series over a given semiring and an alphabet can be endowed with addition and Cauchy multiplication yielding again the structure of a semiring, as well as with several further useful operations like the Hadamard product or the Hurwitz (shuffle) product. We prove that, under suitable assumptions, certain equalities involving the Kleene-star of elements are valid. Moreover, various important properties of the underlying semiring transfer to the semiring of formal power series. In particular, this includes properties like being ordered, complete, continuous, or Conway. We also consider morphisms between semirings of formal power series. As is well known, the set of transitions of a classical finite automaton can be uniformly represented by matrices with entries 0 or 1. A similar representation is also easily possible for the transitions of a weighted automaton: here the matrices have entries from the underlying semiring, namely the weights of the transitions. This yields very compact representations of weighted automata and often very concise algebraic proofs about their behaviors. We prove a theorem on (infinite) matrices central for automata theory: In a complete star semiring, the blocks of the star of a matrix can be represented by applying rational operations to the blocks of the matrix. Moreover, the Kronecker (tensor) product of matrices is considered. Finally, we consider cycle-free equations. They have a unique solution and can be used to show that two expressions represent the same formal power series. Again, we obtain results on how to compute the blocks of the star of a matrix, but now for arbitrary semirings, by imposing restrictions on the matrix. In the literature, a number of authors have dealt with the interplay between semirings, formal power series and automata theory. The following books and

Semirings and Formal Power Series

5

surveys deal with this topic: Berstel [2], Berstel and Reutenauer [3], Bloom and ´ ´ Esik [4], Carr´e [5], Conway [6], Eilenberg [8], Esik and Kuich [9], Kuich [28], Kuich and Salomaa [29], Sakarovitch [37], Salomaa and Soittola [39], Wechler [40]. Further books on semirings and formal power series are Golan [15] and Hebisch and Weinert [20]. Glazek [13] is a bibliography on semirings and formal power series. Some ideas and formulations of this presentation originate from Kuich and ´ Salomaa [29] and Esik and Kuich [11].

2 Monoids and Semirings In this section, we consider monoids and semirings. The definitions and results ´ on monoids and semirings are mainly due to Bloom and Esik [4], Eilenberg [8], Goldstern [16], Karner [22, 23], Krob [25, 26], Kuich [27, 28], Kuich and Salomaa [29], Manes and Arbib [31], and Sakarovitch [36]. Our notion of continuous monoids and semirings is a specialization of the continuous algebras as defined, e.g., in Guessarian [17], Goguen, Thatcher, Wagner, and Wright [14], Ad´ amek, Nelson, and Reiterman [1]. A monoid consists of a non-empty set M , an associative binary operation · on M and a neutral element 1 such that m · 1 = 1 · m = m for every m ∈ M . A monoid M is called commutative if m1 ·m2 = m2 ·m1 for every m1 , m2 ∈ M . The binary operation is usually denoted by juxtaposition and often called product. If the operation and the neutral element of M are understood, then we denote the monoid simply by M . Otherwise, we use the triple notation M, ·, 1. A commutative monoid M is often denoted by M, +, 0. The most important type of a monoid in our considerations is the free monoid Σ ∗ generated by a nonempty set Σ. It has all the (finite) words over Σ x1 . . . xn , with xi ∈ Σ, 1 ≤ i ≤ n, n ≥ 0, as its elements, and the product w1 · w2 is formed by writing the string w2 immediately after the string w1 . The neutral element of Σ ∗ (the case n = 0), also referred to as the empty word, is denoted by ε. The elements of Σ are called letters or symbols. The set Σ itself is called an alphabet. The length of a word w = x1 . . . xn , n ≥ 0, in symbols |w|, is defined to be n. A morphism h of a monoid M into a monoid M  is a mapping h : M → M  compatible with the neutral elements and operations in M, ·, 1 and M  , ◦, 1 , i.e., h(1) = 1 and h(m1 · m2 ) = h(m1 ) ◦ h(m2 ) for all m1 , m2 ∈ M . If Σ is an alphabet and M, ·, 1 is any monoid, then every mapping h : Σ → M can be uniquely extended to a morphism h : Σ ∗ → M by putting h (ε) = 1 and h (x1 x2 . . . xn ) = h(x1 )·h(x2 )· · · · ·h(xn ) for any x1 , . . . , xn ∈ Σ, n ≥ 1. Usually, h is again denoted by h.

6

Manfred Droste and Werner Kuich

Next, we consider monoids with particular properties, like carrying an order or having an infinite sum operation. For our purposes, it suffices to consider commutative monoids. A commutative monoid M, +, 0 is called idempotent, if m + m = m for all m ∈ M , and it is called ordered if it is equipped with a partial order ≤ preserved by the + operation. An ordered monoid M is positively ordered, if m ≥ 0 for each m ∈ M . A commutative monoid M, +, 0 is called naturally ordered if the relation defined by: m1 m2 if there exists an m such that m1 + m = m2 , is a partial order. Clearly, this is the case, i.e., is antisymmetric, iff whenever m, m , m ∈ M with m + m + m = m, then m + m = m. Then in particular M is positively ordered. We note that if M, +, 0 is idempotent, then M is naturally ordered and for any m1 , m2 ∈ M we have m1 + m2 = sup{m1 , m2 } in M, . Further, m1 m2 iff m1 + m2 = m2 . Morphisms of ordered monoids are monoid morphisms which preserve the order.  If I is an index set, an infinitary sum operation I : M I → M associates M. with every family (mi | i ∈ I) of elements of M an element i∈I mi of  A monoid M, +, 0 is called complete if it has infinitary sum operations I (for any index set I) such that the following conditions are satisfied:    (i) mi = 0, i∈{j} mi = mj , i∈{j,k} mi = mj + mk , for j = k. i∈∅       (ii) j∈J ( i∈Ij mi ) = i∈I mi , if j∈J Ij = I and Ij ∩ Ij = ∅ for j = j . A morphism of complete monoids is a monoid morphism preserving all sums. Note that any complete monoid is commutative. Recall that a non-empty subset D of a partially ordered set P is called directed if each pair of elements of D has an upper bound in D. A positively ordered commutative monoid M, +, 0 is called a continuous monoid if each directed subset of M has a least upper bound and the + operation preserves the least upper bound of directed sets, i.e., when m + sup D = sup(m + D), for all directed sets D ⊆ M and for all m ∈ M . Here, m + D is the set {m + d | d ∈ D}. It is known that a positively ordered commutative monoid M is continuous iff each chain in M has a least upper bound and the + operation preserves least upper bounds of chains, i.e., when m + sup C = sup(m + C) holds for all non-empty chains C in M . (See Markowsky [32].) Proposition 2.1. Any continuous monoid M, +, 0 is a complete monoid equipped with the following sum operation:      mi = sup mi F ⊆ I, F finite , i∈I

i∈F

for all index sets I and all families (mi | i ∈ I) in M .

Semirings and Formal Power Series

7

A function f : P → Q between partially ordered sets is continuous if it preserves the least upper bound of any directed set, i.e., when f (sup D) = sup f (D), for all directed sets D ⊆ P such that sup D exists. It follows that any continuous function preserves the order. A morphism of continuous monoids is defined to be a monoid morphism which is a continuous function. Clearly, any morphism between continuous monoids is a complete monoid morphism. A semiring is a set S together with two binary operations + and · and two constant elements 0 and 1 such that: (i) S, +, 0 is a commutative monoid, (ii) S, ·, 1 is a monoid, (iii) the distributivity laws (a + b) · c = a · c + b · c and c · (a + b) = c · a + c · b hold for every a, b, c ∈ S, (iv) 0 · a = a · 0 = 0 for every a ∈ S. A semiring S is called commutative if a · b = b · a for every a, b ∈ S. Further, S is called idempotent if S, +, 0 is an idempotent monoid. By the distributivity law, this holds iff 1 + 1 = 1. If the operations and the constant elements of S are understood, then we denote the semiring simply by S. Otherwise, we use the notation S, +, ·, 0, 1. In the sequel, S will denote a semiring. Intuitively, a semiring is a ring (with unity) without subtraction. A typical example is the semiring of nonnegative integers N. A very important semiring in connection with language theory is the Boolean semiring B = {0, 1} where 1 + 1 = 1 · 1 = 1. Clearly, all rings (with unity), as well as all fields, are semirings, e.g., the integers Z, rationals Q, reals R, complex numbers C, etc. Let N∞ = N ∪ {∞} and N = N ∪ {−∞, ∞}. Then N∞ , +, ·, 0, 1, ∞ N , min, +, ∞, 0 and N, max, +, −∞, 0, where +, ·, min and max are defined in the obvious fashion (observe that 0 · ∞ = ∞ · 0 = 0 and (−∞) + ∞ = −∞), are semirings. Let R+ = {a ∈ R | a ≥ 0}, R∞ + = R+ ∪ {∞} and R+ = R+ ∪ {−∞, ∞}. ∞ Then R+ , +, ·, 0, 1, R∞ + , +, ·, 0, 1 and R+ , min, +, ∞, 0 are semirings. The ∞ ∞ semirings N+ , min, +, ∞, 0 and R+ , min, +, ∞, 0 are called tropical semirings or min-plus semirings. Similarly, the semirings N, max, +, −∞, 0 and R+ , max, +, −∞, 0 are called max-plus semirings or arctic semirings. A further example is provided by the semiring [0, 1], max, ·, 0, 1, called the Viterbi semiring in probabilistic parsing. We note that the tropical and the arctic semirings are very often employed in optimization problems of networks, cf., e.g., Heidergott, Olsder, and van der Woude [21]. Let Σ be a finite alphabet. Then each subset of Σ ∗ is called a formal language over Σ. We define, for formal languages L1 , L2 ⊆ Σ ∗ , the product of L1 and L2 by L1 · L2 = {w1 w2 | w1 ∈ L1 , w2 ∈ L2 }.

8

Manfred Droste and Werner Kuich ∗

Then 2Σ , ∪, ·, ∅, {ε} is a semiring, called the semiring of formal languages over Σ. Here, 2U denotes the power set of a set U and ∅ denotes the empty set. If U is a set, 2U ×U is the set of binary relations over U . Define, for two relations R1 and R2 , the product R1 · R2 ⊆ U × U by R1 · R2 = {(u1 , u2 ) | there exists u ∈ U such that (u1 , u) ∈ R1 and (u, u2 ) ∈ R2 } and furthermore, define Δ = {(u, u) | u ∈ U }. Then 2U ×U , ∪, ·, ∅, Δ is a semiring, called the semiring of binary relations over U . Further semirings are the chain of nonnegative reals R∞ + , max, min, 0, ∞ and any Boolean algebra, in particular the power set Boolean algebras 2U , ∪, ∩, ∅, U  where U is any set. These examples can be generalized as follows. Recall that a partially ordered set L, ≤ is a lattice if for any two elements a, b ∈ L, the least upper bound a ∨ b = sup{a, b} and the greatest lower bound a ∧ b = inf{a, b} exist in L, ≤. A lattice L, ≤ is distributive, if a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c) for all a, b, c ∈ L; and bounded, if L contains a smallest element, denoted 0, and a greatest element, denoted 1. Now, let L, ≤ be any bounded distributive lattice. Then L, ∨, ∧, 0, 1 is a semiring. Since any distributive lattice L also satisfies the dual law a∨(b∧c) = (a∨b)∧(a∨c) for all a, b, c ∈ L, the structure L, ∧, ∨, 1, 0 is also a semiring. Such semirings are often used for fuzzy automata; see Chap. 12 [35] of this book. Another semiring is the L  ukasiewicz semiring [0, 1], max, ⊗, 0, 1 where a⊗b = max{0, a+b−1} which occurs in multivalued logic (see H´ ajek [18]). Recall that in formal languagetheory, the Kleene-iteration L∗ of a language L ⊆ Σ ∗ is defined by L∗ = n≥0 Ln . Later on, we wish to extend this star operation to formal power series (i.e., functions) r : Σ ∗ → S where S is a semiring. For this, it will be useful to know which semirings carry such a star operation like the semiring of formal languages. We will call a star semiring any semiring equipped with an additional unary operation ∗ . The following semirings are star semirings: (i) The Boolean semiring B, +, ·, ∗ , 0, 1 with 0∗ = 1∗ = 1. (ii) The semiring N∞ , +, ·, ∗ , 0, 1 with 0∗ = 1 and a∗ = ∞ for a = 0. ∗ ∗ (iii) The semiring R∞ + , +, ·, , 0, 1 with a = 1/(1 − a) for 0 ≤ a < 1 and ∗ a = ∞ for a ≥ 1. ∗ ∞ ∗ (iv) The tropical semirings R∞ + , min, +, , ∞, 0 and N , min, +, , ∞, 0 ∗ ∞ ∞ with a = 0 for all a ∈ R+ resp. all a ∈ N . (v) The arctic semirings R+ , max, +, ∗ , −∞, 0 and N, max, +, ∗ , −∞, 0 with (−∞)∗ = 0∗ = 0 and a∗ = ∞ for a > 0. ∗ formal languages over a finite alpha(vi) The semiring 2Σ , ∪, ·, ∗ , ∅, {ε} of  bet Σ, as noted before, with L∗ = n≥0 Ln for all L ⊆ Σ ∗ .

Semirings and Formal Power Series

9

(vii)  The semiring 2U ×U , ∪, ·, ∗ , ∅, Δ of binary relations over U with R∗ = n ∗ n≥0 R for all R ⊆ U × U . The relation R is called the reflexive and transitive closure of R, i.e., the smallest reflexive and transitive binary relation over S containing R. (viii) The L  ukasiewicz semiring [0, 1], max, ⊗, ∗ , 0, 1 with a∗ = 1 for all a ∈ [0, 1]. (ix) The idempotent naturally ordered commutative semiring {0, 1, a, ∞}, +, ·, ∗ , 0, 1, with 0 1 a ∞, a · a = a, 0∗ = 1∗ = 1, a∗ = ∞∗ = ∞. (x) The bounded distributive lattice semiring L, ∨, ∧, ∗ , 0, 1 with a∗ = 1 for all a ∈ L. The semirings (i)–(v) and (viii)–(x) are commutative. The semirings (i), (iv)–(x) are idempotent. A semiring S, +, ·, 0, 1 is called ordered if S, +, 0 is an ordered monoid and multiplication with elements s ≥ 0 preserves the order; it is positively ordered, if furthermore, S, +, 0 is positively ordered. When the order on S is the natural order, S, +, ·, 0, 1 is automatically a positively ordered semiring. A semiring S, +, ·, 0, 1 is called complete if S, +, 0 is a complete monoid ´ and the following distributivity laws are satisfied (see Bloom and Esik [4], Conway [6], Eilenberg [8], Kuich [28]):     (a · ai ) = a · ai , (ai · a) = ai · a. i∈I

i∈I

i∈I

i∈I

This means that a semiring S is complete if it is possible to define “infinite sums” (i) that are an extension of the finite sums, (ii) that are associative and commutative and (iii) that satisfy the distributivity laws. In complete semirings for each element a, we can define the star a∗ of a by  a∗ = aj , j≥0

where a0 = 1 and aj+1 = a · aj = aj · a for j ≥ 0. Hence, with this star operation, each complete semiring is a star semiring called a complete star semiring. The semirings (i)–(viii) are complete star semirings. The semiring (ix) is complete, but it violates the above equation for the element a, hence it is not

a complete star semiring. The distributive lattice semiring L satisfies a∗ = j≥0 aj for each a ∈ L, but is not necessarily complete. It is a complete semiring iff (L, ∨, ∧) is a join-continuous

complete lattice, i.e., any subset of L

has a supremum in L and a∧ i∈I ai = i∈I (a∧ai ) for any subset {ai | i ∈ I} of L. A semiring S, +, ·, 0, 1 is called continuous if S, +, 0 is a continuous monoid and if multiplication is continuous, i.e., a · (supi∈I ai ) = supi∈I (a · ai ) and

(supi∈I ai ) · a = supi∈I (ai · a)

10

Manfred Droste and Werner Kuich

´ for all directed sets {ai | i ∈ I} and a ∈ S (see Bloom and Esik [4]). It follows that the distributivity laws hold for infinite sums:     ai = (a · ai ) and ai · a = (ai · a) a· i∈I

i∈I

i∈I

i∈I

for all families (ai | i ∈ I). Proposition 2.2. Any continuous semiring is complete. All the semirings in (i)–(ix) are continuous. We now consider two equations that are important in automata theory. Let S be a star semiring. Then for a, b ∈ S: (i) The sum star identity is valid for a and b if (a + b)∗ = (a∗ b)∗ a∗ . (ii) The product star identity is valid for a and b if (ab)∗ = 1 + a(ba)∗ b. If the sum star identity (resp. the product star identity) is valid for all a, b ∈ S, then we say that the sum star identity (resp. the product star identity) is valid (in the star semiring S). A Conway semiring is now a star semiring in which the sum star identity and the product star identity are valid (see Conway [6], Bloom and ´ Esik [4]). All the star semirings in (i)–(x) are Conway semirings. The semiring ∗ ∞ ∞ , Q∞ + +, ·, , 0, 1, with Q+ = R+ ∩(Q∪{∞}) and operations defined as in (iii), is a Conway semiring (since the sum star identity and product star identity hold in R∞ + ) but is not complete. Now we have the following proposition. Proposition 2.3. Let S be a star semiring. Then S is a Conway semiring iff, for all a, b ∈ S: (i) (a + b)∗ = (a∗ b)∗ a∗ . (ii) (ab)∗ a = a(ba)∗ . (iii) a∗ = 1 + aa∗ = 1 + a∗ a. Proof. If S is a Conway semiring, we obtain (iii) from the product star identity with b = 1, resp. a = 1. Then (ii) follows from the product star identity, distributivity, and (iii). Conversely, for the product star identity compute   (ab)∗ by using (iii) and then (ii). Next we introduce conditions which often simplify the definition or the calculation of the star of elements. A semiring S is k-closed, where k ≥ 0, if for each a ∈ S, 1 + a + · · · + ak = 1 + a + · · · + ak + ak+1 . It is called locally closed, if for each a ∈ S, there is an integer k ≥ 0 such that ´ the above equality is valid. (See Carr´e [5], Mohri [33], Esik and Kuich [10], Zhao [41], Zimmermann [42].) If S, +, ·, 0, 1 is a k-closed semiring, then define the star of a ∈ S by a∗ = 1 + a + · · · + a k .

Semirings and Formal Power Series

11

An analogous equality defines the star in a locally closed semiring. With this star operation, each k-closed (resp. locally closed) semiring is a star semiring called a k-closed (resp. locally closed ) star semiring. The semirings (i), (iv), (viii), and (x) are 0-closed star semirings; the semiring (ix) is a 1-closed semiring, but not a 1-closed star semiring. In [10, 41], the following was shown. Theorem 2.4. Any locally closed star semiring is a Conway semiring. Next we consider morphisms between semirings. Let S and S  be semirings. Then a mapping h : S → S  is a morphism from S into S  if h(0) = 0, h(1) = 1, h(a + b) = h(a) + h(b) and h(a · b) = h(a) · h(b) for all a, b ∈ S. That is, a morphism of semirings is a mapping that preserves the semiring operations and constants. A bijective morphism is called an isomorphism. For instance, the semirings R∞ + , min, +, ∞, 0 and [0, 1], max, ·, 0, 1 are isomorphic via the mapping x → e−x , and the semiring R∞ + , max, min, 0, ∞ is isomorphic to [0, 1], max, min, 0, 1 via the mapping x → 1 − e−x . A morphism h of star semirings is a semiring morphism that preserves additionally the star operation, i.e., h(a∗ ) = h(a)∗ for all a ∈ S. Similarly, a morphism of ordered (resp. complete, continuous) semirings is a semiring morphism that preserves the order (resp. all sums, all suprema of directed subsets). Note that every continuous semiring is an ordered semiring and every continuous semiring morphism is an ordered semiring morphism. Complete and continuous semirings are typically infinite. For results on weighted automata, sometimes it is assumed that the underlying semiring is finite or “close” to being finite. A large class of such semirings can be obtained by the notion of local finiteness (which stems from group theory where it is well known). A semiring S is locally finite (see Wechler [40], Droste and Gastin [7]) if each finitely generated subsemiring is finite. We note that a semiring S, +, ·, 0, 1 is locally finite iff both monoids S, +, 0 and S, ·, 1 are locally finite. Indeed, if S, +, 0 and S, ·, 1 are locally finite and U is a finite subset of S, then the submonoid V of S, ·, 1 generated by U is finite and the submonoid W of S, +, 0 generated by V is also finite. Now, it is easy to check that W ·W ⊆ W and we deduce that the subsemiring of S, +, ·, 0, 1 generated by U is the finite set W . For instance, if both sum and product are commutative and idempotent, then the semiring is locally finite. Consequently, any bounded distributive lattice L, ∨, ∧, 0, 1 is a locally finite semiring. In particular, the chain [0, 1], max, min, 0, 1 and any Boolean algebra are locally finite. Further, the L  ukasiewicz semiring [0, 1], max, ⊗, 0, 1 is locally finite, since its additive and multiplicative monoid are commutative and locally finite. Moreover, each positively ordered locally finite semiring is locally closed, and each positively ordered finite semiring is k-closed where k is less than the number of elements of the semiring. Examples of infinite but locally finite fields are provided by the algebraic closures of the finite fields Z/pZ for any prime p.

12

Manfred Droste and Werner Kuich

3 Formal Power Series In this section, we define and investigate formal power series (for expositions, see Salomaa and Soittola [39], Kuich and Salomaa [29], Berstel and Reutenauer [3], Sakarovitch [37]). Let Σ be an alphabet and S a semiring. Mappings r from Σ ∗ into S are called (formal) power series. The values of r are denoted by (r, w), where w ∈ Σ ∗ , and r itself is written as a formal sum  r= (r, w)w. w∈Σ ∗

The values (r, w) are also referred to as the coefficients of the series. The collection of all power series r as defined above is denoted by SΣ ∗ . This terminology reflects the intuitive ideas connected with power series. We call the power series “formal” to indicate that we are not interested in summing up the series but rather, for instance, in various operations defined for series. Given r ∈ SΣ ∗ , the support of r is the set supp(r) = {w ∈ Σ ∗ | (r, w) = 0}. A series r ∈ SΣ ∗  where every coefficient equals 0 or 1 is termed the characteristic series of its support L, in symbols, r = char(L) or r = 1L . The subset of SΣ ∗  consisting of all series with a finite support is denoted by SΣ ∗ . Series of SΣ ∗  are referred to as polynomials. It will be convenient to use the notations SΣ ∪ {ε}, SΣ and S{ε} for the collection of polynomials having their supports in Σ ∪ {ε}, Σ and {ε}, respectively. Examples of polynomials belonging to SΣ ∗  are 0 and aw, where a ∈ S and w ∈ Σ ∗ , defined by: (0, w) = 0 for all w, (aw, w) = a and (aw, w ) = 0 for w = w . Often, 1w is denoted by w or 1{w} . Next, we introduce several operations on power series. For r1 , r2 , r ∈ SΣ ∗  and a ∈ S, we define the sum r1 + r2 , the (Cauchy) product r1 · r2 , the Hadamard product r1  r2 , and scalar products ar, ra, each as a series belonging to SΣ ∗ , as follows: • • • • •

(r1 , w) + (r2 , w) (r1 + r2 , w) = (r1 · r2 , w) = w1 w2 =w (r1 , w1 )(r2 , w2 ) (r1  r2 , w) = (r1 , w)(r2 , w) (ar, w) = a(r, w) (ra, w) = (r, w)a

for all w ∈ Σ ∗ . It can be checked that SΣ ∗ , +, ·, 0, ε and SΣ ∗ , +, ·, 0, ε are semirings, the semirings of formal power series resp. of polynomials over Σ and S.

Semirings and Formal Power Series

13

We just note that the structure SΣ ∗ , +, , 0, char(Σ ∗ ) is also a semiring (the full Cartesian product of Σ ∗ copies of the semiring S, +, ·, 0, 1). ∗ Clearly, the formal language semiring 2Σ , ∪, ·, ∅, {ε} is isomorphic to ∗ BΣ ∗ , +, ·, 0, ε. Essentially, a transition from 2Σ to BΣ ∗  and vice versa means a transition from L to char(L) and from r to supp(r), respectively. Furthermore, the operation corresponding to the Hadamard product is the intersection of languages. If r1 and r2 are the characteristic series of the languages L1 and L2 , then r1  r2 is the characteristic series of L1 ∩ L2 . ∗ This basic transition between 2Σ and BΣ ∗  will be very important in all of the following as it often gives a hint how to generalize classical results from formal language theory into the realm of formal power series (with an arbitrary or suitable semiring S replacing B). Let ri ∈ SΣ ∗  (i ∈ I), where I is an arbitrary index set. Then for w ∈ Σ ∗ let Iw = {i | (ri , w) = 0}. Assume now that for all w ∈ Σ ∗ , Iw is finite. Then we call the family of power series {ri | i ∈ I} locally finite. In this case, we can define the sum i∈I ri by   ri , w = (ri , w) i∈I

i∈Iw

for all w ∈ Σ ∗ . Also, in this case for each r ∈ SΣ ∗ , the families {r·ri | i ∈ I} · r | i ∈ I} are also locally finite, and r · r = and {r i i i∈I   i∈I r · ri and  ( i∈I ri ) · r = i∈I ri · r. Indeed, let w ∈ Σ ∗ and put J = w=uv Iv , a finite set. Then       ri , w = (r, u) ri , v = (r, u) · (ri , v) r· w=uv

i∈I

=

 

w=uv i∈J

i∈J

(r, u) · (ri , v) =

i∈J w=uv

 i∈J

(r · ri , w) =



r · ri , w ,

i∈I

as (r · ri , w) = 0 implies i ∈ J. This proves the first equation, and the second one follows similarly. A power series r ∈ SΣ ∗  is called proper or quasiregular if (r, ε) = 0. The star r∗ of a proper power series r ∈ SΣ ∗  is defined by  rn . r∗ = n≥0

Since r is proper, we infer  (rn , w) = 0 for each n > |w|. Hence, {rn | n ≥ 0} is locally finite, (r∗ , w) = 0≤n≤|w| (rn , w), and the star of a proper power series is well-defined. We generalize this result to cycle-free power series. A power series r ∈ SΣ ∗  is called cycle-free of index k > 0 if (r, ε)k = 0. It is called cycle-free if there exists a k ≥ 1 such that r is cycle-free of index k. Again, we define

14

Manfred Droste and Werner Kuich

the star of a cycle-free power series r ∈ SΣ ∗  by  rn . r∗ = n≥0

Since r is cycle-free of some index k ≥ 1, an easy proof by induction on the length of w ∈ Σ ∗ yields (rn , w) = 0 for n ≥ k · (|w| + 1). Hence, {rn | n ≥ 0} ∗ is locally finite, (r , w) = 0≤n 0. Hence, (sr)k+1 , ε = (s, ε) (rs)k , ε (r, ε) = 0   and sr is cycle-free. It follows that (rs)∗ r = n≥0 ((rs)n ·r) = n≥0 r·(sr)n =   r · (sr)∗ . The Hurwitz product (also called shuffle product) is defined as follows. For w1 , w2 ∈ Σ ∗ and x1 , x2 ∈ Σ, we define w1  w2 ∈ SΣ ∗  by w1  ε = w1 ,

ε  w2 = w2 ,

and w1 x1  w2 x2 = (w1 x1  w2 )x2 + (w1  w2 x2 )x1 . For r1 , r2 ∈ SΣ ∗ , the Hurwitz product r1  r2 ∈ SΣ ∗  of r1 and r2 is then defined by

Semirings and Formal Power Series

r1  r2 =



15

(r1 , w1 )(r2 , w2 )(w1  w2 ).

w1 ,w2 ∈Σ ∗

Observe that (r1  r2 , w) =



(r1 , w1 )(r2 , w2 )(w1  w2 , w)

|w1 |+|w2 |=|w|

 is a finite sum for all w ∈ Σ ∗ . Hence, { w1 w2 =w (r1 , w1 )(r2 , w2 )w1  w2 | w ∈ Σ ∗ } is locally finite and the Hurwitz product of two power series is well-defined. In language theory, the shuffle product is customarily defined for languages L and L by L  L = {w1 w1 . . . wn wn | w1 . . . wn ∈ L, w1 . . . wn ∈ L , n ≥ 1}. If r1 , r2 ∈ BΣ ∗ , then this definition is “isomorphic” to that given above for formal power series. When the semiring S is ordered by ≤, we may order SΣ ∗ , and thus SΣ ∗  by the pointwise order: We define r ≤ r for r, r ∈ SΣ ∗  iff (r, w) ≤ (r , w) for all w ∈ Σ ∗ . Equipped with this order, clearly both SΣ ∗  and SΣ ∗  are ordered semirings. If S, +, ·, 0, 1 is a complete semiring, we can define an infinitary sum  ∗ ∗ operation on SΣ  as follows: If r ∈ SΣ  for i ∈ I, then r i i∈I i =   ( (r , w))w. By arguing elementwise for each word w ∈ Σ ∗ , we ∗ i w∈Σ i∈I obtain the following proposition. Proposition 3.3. Let S be a semiring. (a) If S is complete, SΣ ∗  is also complete. (b) If S is continuous, SΣ ∗  is also continuous. We just note here that an analogous result holds if S is a Conway semiring, with an appropriate definition of the star operation in SΣ ∗ ; see Chap. 3, Theorem 2.8 [12] of this book. Proposition 3.3 and the Hurwitz product are now used to prove that each complete star semiring is a Conway semiring (see Kuich [27], Hebisch [19]). Theorem 3.4. Each complete star semiring is a Conway semiring. Proof. Let S be a complete star semiring and let a, b ∈ S. Let a ¯, ¯b be letters. ¯ Note that to each word w ¯ = c¯1 c¯2 . . . c¯n , with c¯i ∈ {¯ a, b} for 1 ≤ i ≤ n, there corresponds the element w = c1 c2 . . . cn ∈ S. Let S  be the complete star semiring generated by 1. Then S  is commutative. By Proposition 3.3, a, ¯b}, +, ·, 0, ε is a complete semiring. Also, observe that a ¯ → a, ¯b → b S  {¯ induces a complete star semiring morphism from the complete star semiring S  {¯ a, ¯b}∗  to S.

16

Manfred Droste and Werner Kuich

Using induction, the following equalities can be shown for all n, m ≥ 0:  n a ¯ + ¯b = a ¯j  ¯bn−j , 0≤j≤n

 n−j a ¯j  ¯bm−1 ¯b¯ a

a ¯  ¯bm = n

0≤j≤n

and

a ¯∗  ¯bn =



∗ n ∗ a ¯j  ¯bn = a ¯ ¯b a ¯ .

j≥0

Hence, we infer the equality ∗   j a ¯ + ¯b = a ¯  ¯bn , n≥0 j≥0

which implies immediately

∗ a∗¯b)∗ a ¯∗ . a ¯ + ¯b = (¯

Applying the complete star semiring morphism defined above, we obtain the sum star identity in S: (a + b)∗ = (a∗ b)∗ a∗ . The product star identity is clear by ∗

(ab) = 1 +



n

(ab) = 1 + a

n≥1



(ba) b n

n≥0

= 1 + a(ba)∗ b.   Finally, we show that morphisms between two semirings and also particular morphisms between free monoids induce morphisms between the associated semirings of formal power series. First, let Σ be an alphabet, S, S  two semirings and h : S → S  a mor¯ ¯ : SΣ ∗  → S  Σ ∗  by h(r) = h ◦ r for each r ∈ SΣ ∗ , phism. We define h ∗ ¯ ¯ is again denoted by h. i.e., (h(r), w) = h((r, w)) for each w ∈ Σ . Often, h The following is straightforward by elementary calculations. Proposition 3.5. Let Σ be an alphabet, S, S  two semirings and h : S → S  a semiring morphism. Then h : SΣ ∗  → S  Σ ∗  is again a semiring morphism. Moreover, if r is cycle-free, so is h(r) and h(r∗ ) = (h(r))∗ . Second, let S be a semiring, Σ, Σ  two alphabets and h : Σ ∗ → Σ ∗ a morphism. We define h−1 : SΣ ∗  → SΣ ∗  by h−1 (r ) = r ◦ h for each r ∈ SΣ ∗ , that is, (h−1 (r ), v) = (r , h(v)) for each v ∈ Σ ∗ . We call h : Σ ∗ → Σ ∗ length-preserving, if |v| = |h(v)| for each v ∈ Σ ∗ ; equivalently,

Semirings and Formal Power Series

17

h(x) ∈ Σ  for each x ∈ Σ. Further, h is non-deleting, if h(x) = ε for each x ∈ Σ; equivalently, |v| ≤ |h(v)| for each v ∈ Σ ∗ . If h is non-deleting or ∗ ∗ ¯ ¯ if S is complete, we define h : SΣ ∗  → SΣ  ∗by letting (h(r), w) = v∈Σ ∗,h(v)=w (r, v) for each r ∈ SΣ  and w ∈ Σ . Observe that if h is ¯ non-deleting, h−1 (w) is a finite set for each w ∈ Σ ∗ , and hence h(r) is well defined. Proposition 3.6. Let S be a semiring, Σ, Σ  two alphabets and h : Σ ∗ → Σ ∗ a morphism. (i) Let h be length-preserving. Then the mapping h−1 : SΣ ∗  → SΣ ∗  is a semiring morphism. Moreover, if r ∈ SΣ ∗  is cycle-free, then so is h−1 (r ), and h−1 (r∗ ) = (h−1 (r ))∗ . ¯ : SΣ ∗  → (ii) Let h be nondeleting, or assume that S is complete. Then h ∗ SΣ  is a semiring morphism. Moreover, if h is non-deleting and r ∈ ∗ ¯ ¯ ∗ ) = (h(r)) ¯ and h(r . SΣ ∗  is cycle-free, then so is h(r), Proof. This can be shown again by elementary calculations. For (i), note that if v ∈ Σ ∗ and h(v) = w1 w2 with w1 , w2 ∈ Σ ∗ , then since h is lengthpreserving, there are v1 , v2 ∈ Σ ∗ with v = v1 v2 and h(v1 ) = w1 , h(v2 ) = w2 .   This implies that h−1 preserves the Cauchy product.

4 Matrices In this section, we introduce and investigate (possibly infinite) matrices. These are important here since the structure and the behavior of weighted automata can often be compactly described using matrices (see Chaps. 3, 4, and 7 of this book [12, 38, 34]), and hence results from matrix algebra can be used to derive results for weighted automata. Consider two nonempty index sets I and I  and a set U . A mapping A : I × I  → U is called a matrix. The values of A are denoted by Ai,i , where i ∈ I and i ∈ I  . The values Ai,i are also referred to as the entries of the matrix A. In particular, Ai,i is called the (i, i )-entry of A. The collection of  all matrices as defined above is denoted by U I×I . If both I and I  are finite, then A is called a finite matrix. If I or I  is   a singleton, then AI×I is denoted by A1×I or AI×1 , and A is called a row  I×1 (resp. A ∈ U 1×I ), then we often or column vector, respectively. If A ∈ U  denote the ith entry of A for i ∈ I (resp. i ∈ I ), by Ai instead of Ai,1  (resp. A1,i ). If I = {1, . . . , m} and I  = {1, . . . , n}, the set U I×I is denoted by U m×n . As before, we introduce some operations and special matrices inducing a monoid or semiring structure to matrices. Let S be a semiring. For A, B ∈   S I×I , we define the sum A + B ∈ S I×I by (A + B)i,i = Ai,i + Bi,i for all  i ∈ I, i ∈ I  . Furthermore, we introduce the zero matrix 0 ∈ S I×I . All entries

18

Manfred Droste and Werner Kuich 

of the zero matrix 0 are 0. By these definitions, S I×I , +, 0 is a commutative monoid.  Let A ∈ S I×I . Consider, for i ∈ I, the set of indices {j | Aij = 0}. Then A is called a row finite matrix if these sets are finite for all i ∈ I. Similarly, consider, for i ∈ I  , the set of indices {j | Aji = 0}. Then A is called a column finite matrix if these sets are finite for all i ∈ I  . If A is row finite or B is column finite, or if S is complete, then for A ∈ S I1 ×I2 and B ∈ S I2 ×I3 , we define the product AB ∈ S I1 ×I3 by  Ai1 ,i2 Bi2 ,i3 for all i1 ∈ I1 , i3 ∈ I3 . (AB)i1 ,i3 = i2 ∈I2

Furthermore, we introduce the matrix of unity E ∈ S I×I . The diagonal entries Ei,i of E are equal to 1, the off-diagonal entries Ei1 ,i2 (i1 = i2 ) of E are equal to 0, for i, i1 , i2 ∈ I. It is easily shown that matrix multiplication is associative, the distributivity laws are valid for matrix addition and multiplication, E is a multiplicative unit, and 0 is a multiplicative zero. So, we infer that S I×I , +, ·, 0, E is a semiring if I is finite or if S is complete. Moreover, the row finite matrices in S I×I and the column finite matrices in S I×I form semirings.  If S is complete, infinite sums can be extended to matrices.  Consider S I×I  and define, for Aj ∈ S I×I , j ∈ J, where J is an index set, j∈J Aj by its entries:   Aj = (Aj )i,i , for all i ∈ I, i ∈ I  . j∈J

i,i

j∈J

I×I

By this definition, S is a complete semiring. If S is ordered, the order on S is extended pointwise to matrices A and B  in S I×I : A ≤ B if Ai,i ≤ Bi,i for all i ∈ I, i ∈ I  . If S is continuous, then so is S I×I . Eventually, if S is a locally closed star semiring, then S n×n , n ≥ 1, is ´ again a locally closed star semiring (see Esik and Kuich [10], Zhao [41]); and n×n , n ≥ 1, is again a Conway semiring (see if S is a Conway semiring, then S ´ ´ Conway [6], Bloom and Esik [4], Esik and Kuich [9]). Clearly, if S is locally n×n for each n ≥ 1 (cf. [7]). finite, then so is S For the remainder of this chapter, I (resp. Q), possibly provided with indices, denotes an arbitrary (resp. finite) index set. For the rest of this section, we assume that all products of matrices are well-defined. I×I . Assume We now introduce blocks of matrices.  Consider a matrix A in S that we have a decomposition I = j∈J Ij where J and all Ij (j ∈ J) are non-empty index sets such that Ij1 ∩ Ij2 = ∅ for j1 = j2 . The mapping A, restricted to the domain Ij1 × Ij2 , i.e., A Ij1 ×Ij2 : Ij1 × Ij2 → S is, of course, a matrix in S Ij1 ×Ij2 . We denote it by A(Ij1 , Ij2 ) and call it the (Ij1 , Ij2 )-block of A.

Semirings and Formal Power Series

19

We can compute the blocks of the sum and the product of matrices A and B from the blocks of A and B in the usual way: (A + B)(Ij1 , Ij2 ) = A(Ij1 , Ij2 ) + B(Ij1 , Ij2 ),  A(Ij1 , Ij )B(Ij , Ij2 ). (AB)(Ij1 , Ij2 ) = j∈J 

In a similar manner, the matrices of S I×I can be partitioned into blocks. This yields the computational rule (A + B)(Ij , Ij  ) = A(Ij , Ij  ) + B(Ij , Ij  ). 





If we consider matrices A ∈ S I×I and B ∈ S I ×I partitioned into compatible blocks, i.e., I  is partitioned into the same index sets for both matrices, then we obtain the computational rule  A(Ij , Ij  )B(Ij  , Ij ). (AB)(Ij , Ij ) = j  ∈J 

Now let us assume that I and I  are finite, or that S is complete. In the sequel, the following isomorphisms are needed: (i) The semirings

SI



×I  I×I

, S (I×I



)×(I×I  )

, S (I



×I)×(I  ×I)

I  ×I  , S I×I

are isomorphic by the correspondences between (Ai1 ,i2 )i ,i , A(i1 ,i1 ),(i2 ,i2 ) , A(i1 ,i1 ),(i2 ,i2 ) , (Ai1 ,i2 )i 1

2

I, i1 , i2 I×I

1 ,i2



for all i1 , i2 ∈ ∈I. I×I Σ ∗  and (SΣ ∗ ) are isomorphic by the corre(ii) The semirings S spondence between (A, w)i1 ,i2 and (Ai1 ,i2 , w) for all i1 , i2 ∈ I, w ∈ Σ ∗ . Moreover, analogous isomorphisms are valid if the semirings of row finite or column finite matrices are considered. Observe that, in case S is complete, these correspondences are isomorphisms of complete semirings, i.e., they respect infinite sums. These isomorphisms are used without further mention. Moreover, the notation Ai1 ,i2 , where A ∈ S I1 ×I2 Σ ∗  and i1 ∈ I1 , i2 ∈ I2 , is used: Ai1 ,i2 is the power series in SΣ ∗  such that the coefficient (Ai1 ,i2 , w) of w ∈ Σ ∗ is equal to (A, w)i1 ,i2 . Similarly, the notation (A, w), where A ∈ I ×I (SΣ ∗ ) 1 2 and w ∈ Σ ∗ , is used: (A, w) is the matrix in S I1 ×I2 whose (i1 , i2 )-entry (A, w)i1 ,i2 is equal to (Ai1 ,i2 , w) for each i1 ∈ I1 , i2 ∈ I2 . For the proof of the next theorem, we need a lemma. Lemma 4.1. Let S be a complete star semiring. Then for all a, b ∈ S, (a + b)∗ = (a + ba∗ b)∗ (1 + ba∗ ).

20

Manfred Droste and Werner Kuich

Proof. Using Theorem 3.4, we have (a + ba∗ b)∗ (1 + ba∗ ) = (a∗ ba∗ b)∗ a∗ (1 + ba∗ )   = (a∗ b)2n a∗ + (a∗ b)2n+1 a∗ n≥0

n≥0

= (a∗ b)∗ a∗ = (a + b)∗ .   The next theorem is central for automata theory (see Conway [6], Lehmann ´ [30], Kuich and Salomaa [29], Kuich [28], Bloom and Esik [4], Kozen [24]). It allows us to compute the blocks of the star of a matrix A by sum, product, and star of the blocks of A. For notational convenience, we will denote in Theorem 4.2 and in Corollaries 4.3 and 4.4 the matrices A(Ii , Ij ) by Ai,j , for 1 ≤ i, j ≤ 3. Theorem 4.2. Let S be a complete star semiring. Let A ∈ S I×I and I = I1 ∪ I2 with I1 , I2 = ∅ and I1 ∩ I2 = ∅. Then ∗

A∗ (I1 , I1 ) = (A1,1 + A1,2 A∗2,2 A2,1 ) , ∗

A∗ (I1 , I2 ) = (A1,1 + A1,2 A∗2,2 A2,1 ) A1,2 A∗2,2 , ∗

A∗ (I2 , I1 ) = (A2,2 + A2,1 A∗1,1 A1,2 ) A2,1 A∗1,1 , ∗

A∗ (I2 , I2 ) = (A2,2 + A2,1 A∗1,1 A1,2 ) . Proof. Consider the matrices  A1,1 0 A1 = 0 A2,2

 and A2 =

0 A2,1

A1,2 . 0



The computation of (A1 + A2 A∗1 A2 ) (E+A2 A∗1 ) and application of Lemma 4.1 prove our theorem.   Corollary 4.3. If A2,1 = 0, then

A∗1,1 ∗ A = 0

A∗1,1 A1,2 A∗2,2 A∗2,2

 .

Corollary 4.4. Let I = I1 ∪ I2 ∪ I3 be a decomposition into pairwise disjoint nonempty subsets. If A2,1 = 0, A3,1 = 0, and A3,2 = 0, then ⎞ ⎛ ∗ A∗1,1 A1,2 A∗2,2 A∗1,1 A1,2 A∗2,2 A2,3 A∗3,3 + A∗1,1 A1,3 A∗3,3 A1,1 ⎟ ⎜ A∗2,2 A∗2,2 A2,3 A∗3,3 A∗ = ⎝ 0 ⎠. ∗ 0 0 A3,3 Next, we consider an arbitrary partition of the index set I.

Semirings and Formal Power Series

21

 Theorem 4.5. Let S be a complete star semiring, and let I = j∈J Ij be a decomposition into pairwise disjoint nonempty subsets. Fix j0 ∈ J. Assume that the only non-null blocks of the matrix A ∈ S I×I are A(Ij , Ij0 ), A(Ij0 , Ij ) and A(Ij , Ij ), for all j ∈ J. Then  ∗  ∗ A∗ (Ij0 , Ij0 ) = A(Ij0 , Ij0 ) + A(Ij0 , Ij )A(Ij , Ij ) A(Ij , Ij0 ) . j∈J, j =j0

Proof. We partition I into Ij0 and I  = I − Ij0 . Then A(I  , I  ) is a block∗ ∗ diagonal matrix and (A(I  , I  ) )(Ij , Ij ) = A(Ij , Ij ) for all j ∈ J − {j0 }. By Theorem 4.2, we obtain ∗ ∗ A∗ (Ij0 , Ij0 ) = A(Ij0 , Ij0 ) + A(Ij0 , I  )A(I  , I  ) A(I  , Ij0 ) . The computation of the right-hand side of this equality proves our theorem.   We now introduce the Kronecker product (also called tensor product)     A ⊗ B ∈ S (I1 ×I2 )×(I1 ×I2 ) for the matrices A ∈ S I1 ×I1 and B ∈ S I2 ×I2 , by defining its entries: (A ⊗ B)(i1 ,i2 ),(i1 ,i2 ) = Ai1 ,i1 Bi2 ,i2 ,

for all i1 ∈ I1 , i1 ∈ I1 , i2 ∈ I2 , i2 ∈ I2 . 



Sometimes, the Kronecker product A ⊗ B is defined to be in (S I2 ×I2 )I1 ×I1 with (A ⊗ B)i1 ,i1 i ,i = Ai1 ,i1 Bi2 ,i2 , for all i1 ∈ I1 , i1 ∈ I1 , i2 ∈ I2 , i2 ∈ I2 . 2

2

Since the semirings S (I1 ×I2 )×(I1 ×I2 ) and (S I2 ×I2 )I1 ×I1 are isomorphic, this will not make any difference in the computations. Easy proofs show the following computational rules for Kronecker products. 





Theorem 4.6. Let A, A ∈ S I1 ×I1 , B, B  ∈ S I2 ×I2 , C ∈ S I3 ×I3 . Then: (i) (A + A ) ⊗ B = A ⊗ B + A ⊗ B. (ii) A ⊗ (B + B  ) = A ⊗ B + A ⊗ B  . (iii) A ⊗ 0 = 0 and 0 ⊗ B = 0. (iv) A ⊗ (B ⊗ C) = (A ⊗ B) ⊗ C. Theorem 4.7. Let A ∈ S I1 ×I2 {ε}, B ∈ S I2 ×I3 {ε}, C ∈ S I4 ×I5 Σ ∗  and D ∈ S I5 ×I6 Σ ∗ . Assume that S is complete or that (A, ε) and (C, w) are row finite for all w ∈ Σ ∗ , or that (B, ε) and (D, w) are column finite for all w ∈ Σ ∗ . Furthermore, assume that all entries of (B, ε) commute with those of (C, w) for all w ∈ Σ ∗ . Then (AB) ⊗ (CD) = (A ⊗ C)(B ⊗ D).

22

Manfred Droste and Werner Kuich

Proof. Let ij ∈ Ij for j = 1, 3, 4, 6. Then we obtain (AB) ⊗ (CD) (i1 ,i3 ),(i4 ,i6 ) = (AB)i1 ,i3 (CD)i4 ,i6   = Ai1 ,i2 Bi2 ,i3 Ci4 ,i5 Di5 ,i6 i2 ∈I2 i5 ∈I5

=

 

Ai1 ,i2 Ci4 ,i5 Bi2 ,i3 Di5 ,i6

i2 ∈I2 i5 ∈I5

=



(A ⊗ C)(i1 ,i4 ),(i2 ,i5 ) (B ⊗ D)(i2 ,i5 ),(i3 ,i6 )

(i2 ,i5 )∈I2 ×I5

= (A ⊗ C)(B ⊗ D) (i1 ,i4 ),(i3 ,i6 ) .   The Kronecker product is useful for investigating the Hadamard product of formal power series, cf., e.g., Chap. 4, Sect. 4.2 [38] of this book.

5 Cycle-Free Linear Equations Let Σ be an alphabet and S any semiring. Cycle-free linear equations over SΣ ∗  are a useful tool for proving identities in SΣ ∗ . Assume that two expressions are shown to be solutions of such an equation. Then the uniqueness of the solution (shown below) implies that these two expressions represent the same formal power series in SΣ ∗ . A cycle-free linear equation (over SΣ ∗ ) has the form y = ry + s, where r, s ∈ SΣ ∗  and r is cycle-free. A solution to this equation is given by a power series σ ∈ SΣ ∗  such that σ = rσ + s. Theorem 5.1. The cycle-free equation y = ry + s with r, s ∈ SΣ ∗ , r cyclefree, has the unique solution σ = r∗ s. Proof. By Theorem 3.1, we obtain rσ + s = rr∗ s + s = (rr∗ + ε)s = r∗ s = σ. Hence, σ is a solution. Assume that r is cycle-free of index k, i.e., (r, ε)k = 0, and that  is a solution. Then by substitution, we obtain for all n ≥ 0,   = r + s = · · · = rn  + rj s. 0≤j 1, we partition A into blocks A = ac db and define A∗ = αγ βδ with a, α ∈ S 1×1 , b, β ∈ S 1×(n−1) , c, γ ∈ S (n−1)×1 , d, δ ∈ S (n−1)×(n−1) by α = (a + bd∗ c)∗ ,

β = αbd∗ ,

γ = δca∗ ,

δ = (d + ca∗ b)∗ .

(See Theorem 3.3 of Conway [4], Theorem 4.21 of Kuich and Salomaa [19], Theorem 2.5 of Kuich [18], Theorem 5.7 of Droste and Kuich [5], Bloom and ´ ´ Esik [2], Sect. 6 of Esik [8], and Example 2.1.) If S, +, ·, ∗ , 0, 1 is a star semiring, then the star operation in the star semiring S n×n , +, ·, ∗ , 0, E will always be defined as above. ´ ´ Theorem 2.6 (Conway [4], Bloom and Esik [2], Esik and Kuich [12], ´ Esik [8]). If S is a Conway semiring, then for n ≥ 1, S n×n again is a Conway semiring. Let A and A∗ be given as in (ii) of the definition of A∗ above, but with a, α ∈ S n1 ×n1 , b, β ∈ S n1 ×n2 , c, γ ∈ S n2 ×n1 , d, δ ∈ S n2 ×n2 , n1 + n2 = n. Then the matrix star identity is valid in the star semiring S if A∗ is independent of the partition of n in summands. ´ ´ Theorem 2.7 (Conway [4], Bloom and Esik [2], Esik and Kuich [12], ´ Esik [8]). If S is a Conway semiring, then the matrix star identity holds. Let S be a star semiring. Then for r ∈ SΣ ∗ , we define the star r∗ ∈ SΣ ∗  of r inductively as follows:  (r∗ , ε) = (r, ε)∗ , (r∗ , w) = (r, ε)∗ (r, u)(r∗ , v), w ∈ Σ ∗ , w = ε. uv=w, u=ε

´ (See Bloom and Esik [2], and Theorem 3.5 of Kuich and Salomaa [19].) If ∗ S, +, ·, , 0, 1 is a star semiring, then the star operation in the star semiring SΣ ∗ , +, ·, ∗ , 0, ε will be always defined as above. ´ ´ Theorem 2.8 (Bloom and Esik [2], Esik and Kuich [12]). If S is a Conway semiring and Σ is an alphabet then SΣ ∗  is again a Conway semiring. Corollary 2.9. If S is a Conway semiring, Σ is an alphabet and n ≥ 1, then (SΣ ∗ )n×n is again a Conway semiring. Each complete semiring is a Conway semiring (Kuich [17], Hebisch [14], ´ ´ Bloom and Esik [2], see also Droste and Kuich [5] and Esik [8]). Moreover, for a complete semiring S, the star operations in the complete semirings S n×n and SΣ ∗  are the same as the star operations in the Conway semirings S n×n and SΣ ∗ , respectively. For the rest of this subsection, S denotes a Conway semiring and S  denotes a subset of S. We now generalize the finite automata of Sect. 2.1 to finite S  automata over a Conway semiring S.

Finite Automata

77

A finite S  -automaton A = (n, R, A, P ),

n≥1

(over the Conway semiring S) is given by: (i) A transition matrix A ∈ (S  ∪ {0, 1})n×n (ii) An initial state vector R ∈ (S  ∪ {0, 1})1×n (iii) A final state vector P ∈ (S  ∪ {0, 1})n×1 The behavior A of A is defined by  Ri1 (A∗ )i1 ,i2 Pi2 = RA∗ P. A = 1≤i1 ,i2 ≤n

The (directed) graph of A is constructed analogous to that in Sect. 2.1. It has nodes 1, . . . , n and an edge from node i to node j if Aij = 0. The weight of this edge is Aij ∈ S  ∪ {1}. The initial (resp. final ) weight of a node i is given by Ri (resp. Pi ). A node is called initial (resp. final ) if its initial (resp. final) weight is unequal to 0. The weight of a path is the product of the weights of its edges. It is easily shown that (Ak )ij is the sum of the weights of paths of length  k from node i to node j. If S is a complete semiring, and hence (A∗ )ij = k≥0 (Ak )ij , then (A∗ )ij is the sum of the weights of the paths from node i to node j. Hence, Si1 (A∗ )i1 ,i2 Pi2 is this sum for nodes i1 and i2 , multiplied on the left and right by the initial weight of node i1 and the final weight of node i2 , respectively. Eventually, the behavior of A is the sum of all these terms with summation over all initial states i1 and all final states i2 . Theorem 2.10. Let S be a complete semiring and S  ⊆ S. If A is a finite S  -automaton then A is the sum of the weights of all paths from an initial state to a final state multiplied by the initial and final weights of these states. Two finite S  -automata A and A are equivalent if A = A . A finite S -automaton A = (n, R, A, P ) is called normalized if n ≥ 2 and: 

(i) R1 = 1, Ri = 0, for all 2 ≤ i ≤ n. (ii) Pn = 1, Pi = 0, for all 1 ≤ i ≤ n − 1. (iii) Ai,1 = An,i = 0, for all 1 ≤ i ≤ n. Hence, the directed graph of a normalized finite S  -automaton has the unique initial node 1 and the unique final node n, both with weight 1; moreover, no edges are leading to the initial node and no edges are leaving the final node. Theorem 2.11. Let S be a Conway semiring and S  ⊆ S. Then each finite S  -automaton is equivalent to a normalized finite S  -automaton. Proof. Let A = (n, R, A, P ) be a finite S  -automaton. Define the finite S  automaton A by

78

´ Zolt´ an Esik and Werner Kuich



⎛ ⎞ ⎛ ⎞⎞ 0R 0 0 A = ⎝1 + n + 1, (1 0 0), ⎝0 A P ⎠ , ⎝0⎠⎠ . 0 0 0 1 Then A is normalized. Applying the matrix star identity yields the proof that

A  = A. The substar semiring of S that is generated by S  is denoted by Rat(S  ). The collection of all behaviors of finite S  -automata is denoted by Rec(S  ). The classical theorem of Kleene essentially states that Rat(BΣ) and Rec(BΣ) coincide. As a generalization of the theorem of Kleene–Sch¨ utzenberger, we ´ [2], Kuich show that Rat(S  ) = Rec(S  ). (See Conway [4], Bloom and Esik ´ [17, 18], Esik and Kuich [9]). We now define, for given finite S  -automata A = (n, R, A, P ) and A =  (n , R , A , P  ), the finite S-automata A + A , A · A and A∗ :      A 0 P    A + A = n + n , (R R ), , , 0 A P      A P R 0 , , A · A = n + n , (R 0), 0 A P      0 R 1 , . A∗ = 1 + n, (1 0), P A 0 Theorem 2.12. Let S be a Conway semiring and S  ⊆ S. Then Rat(S  ) = Rec(S  ). Proof. (i) An easy proof by induction on n using the matrix star identity shows that A∗ ∈ Rat(S  )n×n if A ∈ (S  ∪{0, 1})n×n . This implies immediately Rec(S  ) ⊆ Rat(S  ). (ii) Easy constructions yield S  ∪ {0, 1} ⊆ Rec(S  ). Consider now a and  a in Rec(S  ). Then there exist finite S  -automata A = (n, R, A, P ) and A = (n , R , A , P  ) such that A = a and A  = a . Clearly, A + A and A∗ are finite S  -automata. If P R is in S  ∪ {0, 1}, then also A · A is a finite S  -automaton. If P R is not in S  ∪ {0, 1}, choose A or A to be normalized. This is, by Theorem 2.11, no loss of generality. Then again A · A is a finite S  automaton. Application of the matrix star identity shows that the equations A + A  = A + A  = a + a , A · A  = A · A  = a · a and A∗  =

A∗ = a∗ are valid. We now turn to the power series semiring SΣ ∗ . A finite SΣ ∪ {ε}automaton A = (n, R, A, P ) is called a finite automaton (over S and Σ) without ε-moves if A ∈ (SΣ)n×n , R ∈ (S{ε})1×n with R1 = ε, Rj = 0 for 2 ≤ j ≤ n, P ∈ (S{ε})n×1 . (This definition holds also for arbitrary semirings.) For S = B, this is the usual definition, i. e., such a finite BΣautomaton is a nondeterministic finite automaton without ε-moves in the classical sense.

Finite Automata

79

We now show that each finite SΣ ∪ {ε}-automaton is equivalent to a finite automaton without ε-moves. Theorem 2.13. Let S be a Conway semiring. Then each finite SΣ ∪ {ε}automaton is equivalent to a finite automaton over A and Σ without ε-moves. Proof. For each finite SΣ ∪ {ε}-automaton there exits, by Theorem 2.11, an equivalent normalized finite SΣ ∪ {ε}-automaton. Let A = (n, R, A, P ) be such a normalized finite SΣ ∪ {ε}-automaton. Let A0 = (A, ε)ε and A1 = x∈Σ (A, x)x and define the finite automaton without ε-moves A = (n, R, A∗0 A1 , A∗0 P ). Then A  = R(A∗0 A1 )∗ A∗0 P = R(A0 + A1 )∗ P = RA∗ P = A. Here, we have applied in the second equality the sum star identity.



Observe that, in case of a Conway semiring S, we have Rat(SΣ ∪ {ε}) = S rat Σ ∗ . Indeed, it is clear that S rat Σ ∗  ⊆ Rat(SΣ ∪ {ε}). The reverse inclusion is consequence of the fact that if r ∈ S rat Σ ∗  then r∗ ∈ S rat Σ ∗ , whichis shown as follows. Given r, write r = r0 + r1 , where r0 = (r, ε)ε and r1 = w∈Σ + (r, w)w. Now, one can easily see that r1 is also in S rat Σ ∗ , and by the sum star identity we obtain r∗ = (r0∗ r1 )∗ r0∗ ∈ S rat Σ ∗ . Analogously, in case of a Conway semiring, by Theorem 2.13, we have Rec(SΣ ∪ {ε}) = S rec Σ ∗ . Corollary 2.14. S rat Σ ∗  = S rec Σ ∗  = {A | A is a finite automaton over S and Σ without ε-moves}. The classical theorem of Kleene in terms of formal power series essentially states that Brat Σ ∗  and Brec Σ ∗  coincide. Corollary 2.15. Brat Σ ∗  = Brec Σ ∗  = {A | A is a finite automaton over B and Σ without ε-moves}. Usually, a nondeterministic finite automaton without ε-moves is defined as follows (see Hopcroft and Ullman [15]). A nondeterministic finite automaton (in the classical sense) A = (Q, Σ, δ, q1 , F ) is given by: (i) (ii) (iii) (iv) (v)

A finite nonempty set of states Q An input alphabet Σ A transition function δ : Q × Σ → 2Q An initial state q1 ∈ Q A set of final states F ⊆ Q

80

´ Zolt´ an Esik and Werner Kuich

The transition function δ is extended to a mapping δˆ : Q × Σ ∗ → 2Q by    ˆ w) , ˆ ε) = {q}, ˆ wx) = p  p ∈ δ(r, x) for some r ∈ δ(q, δ(q, δ(q, for q ∈ Q, w ∈ Σ ∗ and x ∈ Σ. ˆ 1 , w) ∩ F = ∅. The language A A word w ∈ Σ ∗ is accepted by A if δ(q accepted by A, is defined by    ˆ 1 , w) ∩ F = ∅ . A = w ∈ Σ ∗  δ(q ∗

We now connect the notion of a finite automaton A over 2Σ without εmoves with the notion of a nondeterministic finite automaton A as defined above. Assume that A = (n, R, A, P ) and A = (Q, Σ, δ, q1 , F ). Then A and A correspond to each other if the following conditions are satisfied: (i) |Q| = n; so we may assume Q = {q1 , . . . , qn }, where i corresponds to qi , 1 ≤ i ≤ n. (ii) x ∈ Aij ⇔ qj ∈ δ(qi , x), 1 ≤ i, j ≤ n, x ∈ Σ. (iii) Rq1 = {ε}, Rqi = ∅, 2 ≤ i ≤ n. / F. (iv) Pi = {ε} ⇔ qi ∈ F , Pi = ∅ ⇔ qi ∈ It is easily seen that A = A if A and A correspond to each other. This is due to the fact that w ∈ (Ak )ij and

ˆ i , w), qj ∈ δ(q

⇐⇒

w ∈ (A∗ )ij

1 ≤ i, j ≤ n, k ≥ 0, w ∈ Σ ∗ , |w| = k,

1 ≤ i, j ≤ n, w ∈ Σ ∗ .  ∗ (In the complete star semiring (2Σ )n×n , we have A∗ = n≥0 An .) Hence, A = RA∗ P = =



⇐⇒

 1≤i,j≤n

ˆ i , w), qj ∈ δ(q

Ri (A∗ )ij Pj =



(A∗ )1j

qj ∈F

     ˆ 1 , w) ∩ F = ∅ = A. ˆ 1 , w) = w  δ(q w  qj ∈ δ(q

qj ∈F

It is clear that Rec(Σ) coincides with the collection of all languages over Σ accepted by a nondeterministic finite automaton, and Rat(Σ) coincides with the set of all languages that can be constructed from the finite subsets of Σ ∗ by the rational operations of union, concatenation, and Kleene-iteration. ∗

Corollary 2.16 (Kleene’s theorem [16]). In the semiring 2Σ of formal languages over Σ, Rat(Σ) = Rec(Σ).

Finite Automata

81

2.3 Finite Linear Systems A finite linear system (over the semiring S) is of the form y = Ay + P.  y1  .. Here, y = is a column vector of variables y1 , . . . , yn , A ∈ S n×n and . yn

P ∈ S n×1 . A solution to the finite linear system y = Ay + P is given by a column vector σ ∈ S n×1 such that σ = Aσ + P . A finite linear system y = Ay + P over the semiring SΣ ∗  is called cycle-free if A is cycle-free. Theorem 2.17. The cycle-free finite linear system y = Ay +P over the semiring SΣ ∗  has the unique solution σ = A∗ P . Proof. The proof is analogous to the proof of Theorem 5.1 of Droste and Kuich [5].

The next theorem connects finite automata and finite linear systems. The special form of the cycle-free finite linear system in Theorem 2.18(i) is needed in connection with regular grammars in Theorem 2.20. In the sequel, ek denotes the kth row vector of unity. Theorem 2.18. Let r ∈ SΣ ∗ . Then the following statements are equivalent: (i) r is a component of the solution of a cycle-free finite linear system y = Ay + P over the semiring SΣ ∗ , where A ∈ (SΣ)n×n , Ai,1 = 0 for all 1 ≤ i ≤ n, and P1 ∈ SΣ ∪ {ε}, Pi ∈ SΣ, 2 ≤ i ≤ n. (ii) r is in S rec Σ ∗ . Proof. (i) ⇒ (ii): The solution of y = Ay + P is σ = A∗ P . We now construct cycle-free finite automata Ak such that Ak  = σk , 1 ≤ k ≤ n: Ak = ({1, . . . , n}, ek , A, P ). Hence, by Theorem 2.3, σk ∈ S rec Σ ∗ . (ii) ⇒ (i): Let r ∈ S rec Σ ∗ . Then by Theorem 2.4, there exists a cycle-free finite automaton A = ({1, . . . , n}, e1 , A, P ), A ∈ (SΣ)n×n , P ∈ (S{ε})n×1 , such that A = r. Consider now the finite linear system        0 e1 A e P + e1 AP y0 y0 = + 1 . y y 0 A AP  y1  .. . By Corollary 5.8 of Droste and Kuich [5], this finite linear Here, y = . yn

system is cycle-free and its solution is given by    ε e1 AA∗ e1 P + e1 AP σ= . 0 A∗ AP Hence, σ0 = e1 P + e1 AP + e1 AA∗ AP = e1 P + e1 AP + e1 AAA∗ P = e1 A∗ P = A = r. Here, we have applied Theorems 3.1 and 3.2 of Droste and Kuich [5].

82

´ Zolt´ an Esik and Werner Kuich

Let G = ({y1 , . . . , yn }, Σ, Π, y1 ) be a context-free grammar. Then G is called right linear if Π contains only productions of the form yi → xyj or yi → x, where x ∈ Σ ∪ {ε} and 1 ≤ i, j ≤ n. And G is called regular if Π contains only productions of the form yi → xyj , yi → x, where x ∈ Σ, or y1 → ε; but if y1 → ε ∈ Π then y1 must not appear on the right side of any production of the grammar. Consider the right linear grammars Gi = ({y1 , . . . , yn }, Σ, Π, yi ), 1 ≤ i ≤ n. Then define the finite linear system y = Ay + P over the semi∗ ring 2Σ by Ai,j = {x | yi → xyj ∈ Π} and Pi = {x | yi → x ∈ Π}, 1 ≤ i, j ≤ n. Conversely, given a finite linear system y = Ay + P with ∗ Ai,j , Pi ∈ Σ ∪ {ε}, 1 ≤ i, j ≤ n, over the semiring 2Σ , define the right linear grammars Gi = ({y1 , . . . , yn }, Σ, Π, yi ) by yi → xyj ∈ Π iff x ∈ Ai,j and yi → x ∈ Π iff x ∈ Pi . Whenever we speak of right linear grammars corresponding to a finite linear system, or vice versa, then we mean the correspondence in the sense of the above definition. The next theorem is a special case of a result referred to in Petre and Salomaa [21]. Theorem 2.19. Let Gi = ({y1 , . . . , yn }, Σ, Π, yi ), 1 ≤ i ≤ n, be regular gram∗ mars and consider the corresponding finite linear system over 2Σ with unique solution σ. Then σi = L(Gi ), 1 ≤ i ≤ n. Consider a cycle-free finite linear system of the form of Theorem 2.18(i) and the corresponding right linear grammars G1 , . . . , Gn . Then G1 is regular. Corollary 2.20. A language is generated by a regular grammar iff it is accepted by a nondeterministic finite automaton. More statements on the correspondence of finite automata and right linear grammars can be found in the forthcoming Theorems 3.20 and 3.21, Corollary 3.24 with k = 0, and Corollary 3.25. We now turn to Conway semirings S. Theorem 2.21. Let S be a Conway semiring. Then σ = A∗ P is a solution to the finite linear system y = Ay + P over S. Proof. Aσ + P = AA∗ P + P = (AA∗ + E)P = A∗ P = σ. Here, we have ´ applied Theorem 2.6 and the star fixed point identity, cf. Esik [8].

We call the above solution of the system y = Ay+P the canonical solution. ´ ´ Next, we consider inductive star semirings, cf. Esik and Kuich [9], Esik [8]. Recall that every inductive star semiring is a Conway semiring (and an iteration semiring). Theorem 2.22. Let S be an inductive star semiring. Then the canonical solution is the least solution to the finite linear system y = Ay + P over S. ´ Proof. By Corollary 6.18 of Esik [8].



Finite Automata

83

Let S  ⊆ S. A finite linear system y = Ay + P over the semiring S is called finite S  -linear system if the entries of A and P are in S  ∪ {0, 1}. The next theorem connects finite S  -linear systems and finite S  -automata. Theorem 2.23. Let S be a Conway semiring and S  ⊆ S. Then for a ∈ S, the following statements are equivalent: (i) a is a component of the canonical solution of a finite S  -linear system. (ii) a is the behavior A of a finite S  -automaton A. Proof. (i) ⇒ (ii): Consider the finite S  -linear system y = Ay + P with n variables and the kth component ek A∗ P of its canonical solution, 1 ≤ k ≤ n. Then the behavior of the finite S  -automaton Ak = (n, ek , A, P ) equals ek A∗ P for all 1 ≤ k ≤ n. (ii) ⇒ (i): By Theorem 2.11, a is, without loss of generality, the behavior of a normalized finite S  -automaton A = (n, e1 , A, P ). The behavior A = e1 A∗ P is then the first component of the canonical solution of the finite S  linear system y = Ay + P .

Corollary 2.24. Let S be an inductive star semiring and S  ⊆ S. Then for a ∈ S, the following statements are equivalent: (i) a is a component of the least solution of a finite S  -linear system. (ii) a is the behavior A of a finite S  -automaton A. Since every continuous semiring is an inductive star semiring, the last two results also apply for continuous semirings.

3 Finite Automata over Quemirings In this section, we deal with semiring–semimodule pairs and finite automata over quemirings. Here, semiring–semimodule pairs constitute a generalization of formal languages with finite and infinite words. The semiring models formal languages with finite words while the semimodule models formal languages with infinite words. The main result of this section is a generalization of the Kleene theorem of B¨ uchi [3] in the setting of semiring–semimodule pairs. (See also Perrin and Pin [20].) This section consists of three subsections. In Sect. 3.1 we introduce the algebraic structures used in this section: semiring–semimodule pairs and quemirings. In Sect. 3.2, we define finite automata over quemirings. Given a Conway ´ ´ semiring–semimodule pair (S, V ), cf. Bloom and Esik [2], Esik [8], we prove   a Kleene theorem for S -finite automata, where S is a subset of S: the collection of all behaviors of S  -finite automata coincides with the generalized star quemiring generated by S  (Theorem 3.14). A special case of this Kleene theorem is the result of B¨ uchi [3].

84

´ Zolt´ an Esik and Werner Kuich

In Sect. 3.3, we consider finite linear systems over quemirings as a generalization of regular grammars with finite and infinite derivations. We show a connection between certain solutions of these finite linear systems, the weights of finite and infinite derivations with respect to regular grammars and the behaviors of finite automata over quemirings. We now give a typical example on B¨ uchi automata over infinite words. Example 3.1. A (finite) B¨ uchi automaton A = (Q, Σ, δ, q, G) is given by: (i) A finite set of states Q = {q1 , . . . , qn }, n ≥ 1 (ii) An input alphabet Σ (iii) A transition function δ : Q × Σ → 2Q (iv) An initial state q ∈ Q (v) A set of repeated states G = {q1 , . . . , qk }, k ≥ 0 A run of A on an infinite word w ∈ Σ ω , w = a1 a2 a3 . . . , is an infinite sequence of states q(0), q(1), q(2), q(3), . . . such that the following conditions are satisfied: (i) q(0) = q. (ii) q(i) ∈ δ(q(i − 1), ai ) for i ≥ 1. A word w ∈ Σ ω is B¨ uchi accepted by A if there exists a run ρ of A on w and a repeated state in G occurring infinitely often in ρ. The behavior A ⊆ Σ ω of A is defined to be the set of infinite words that are B¨ uchi accepted by A (see B¨ uchi [3]). Let now A = (Q, Σ, δ, 2, {1}) be a B¨ uchi automaton, where Q = {1, 2}, Σ = {a, b, c, d}, and δ(1, a) = {1}, δ(1, b) = {2}, δ(2, c) = {1}, δ(2, d) = {2} are the only nonempty images of δ. The graph of A is

and the adjacency matrix of this graph is   {a} {b} A= . {c} {d} (See Example 2.1.) The language of inscriptions of paths from 1 to 1 not passing 1 is given by {a} ∪ {b}{d}∗ {c}. Hence, the ω-language of inscriptions of infinite paths starting in 1 and passing infinitely often through 1 is ({a} ∪ {b}{d}∗ {c})ω and

Finite Automata

85

the ω-language of inscriptions of infinite paths starting in 1, passing finitely often through 1 and infinitely often through 2 is ({a} ∪ {b}{d}∗ {c})∗ {b}{d}ω . By symmetry, the ω-language of inscriptions of infinite paths starting in 2 and passing infinitely often through 2 (resp. finitely often through 2 and infinitely often through 1) is ({d} ∪ {c}{a}∗ {b})ω (resp. ({d} ∪ {c}{a}∗ {b})∗ {c}{a}ω ). We now define a column vector Aω by   ({a} ∪ {b}{d}∗ {c})ω ∪ ({a} ∪ {b}{d}∗ {c})∗ {b}{d}ω ω A = , ({d} ∪ {c}{a}∗ {b})ω ∪ ({d} ∪ {c}{a}∗ {b})∗ {c}{a}ω where (Aω )1 (resp. (Aω )2 ) is the ω-language of inscriptions of all infinite paths starting in 1 (resp. 2). Observe that ({a} ∪ {b}{d}∗ {c})ω ∩ ({a} ∪ {b}{d}∗ {c})∗ {b}{d}ω = ∅ and

({d} ∪ {c}{a}∗ {b})ω ∩ ({d} ∪ {c}{a}∗ {b})∗ {c}{a}ω = ∅.

The ω-language of inscriptions of infinite paths starting in 2 and passing infinitely often through 1 is {d}∗ {c}({a} ∪ {b}{d}∗ {c})ω . We define a column vector Aω,1 by   ({a} ∪ {b}{d}∗ {c})ω Aω,1 = , {d}∗ {c}({a} ∪ {b}{d}∗ {c})ω where (Aω,1 )1 (resp. (Aω,1 )2 ) is the ω-language of inscriptions of all infinite paths starting in 1 (resp. 2) and passing infinitely often through 1. The ω-language A is the ω-language of all inscriptions of infinite paths starting in 2 and passing infinitely often through 1, i.e., A = (Aω,1 )2 . 3.1 Semiring–Semimodule Pairs and Quemirings Suppose that S is a semiring and V is a commutative monoid written additively. We call V a (left) S-semimodule if V is equipped with a (left) action S × V → V, (s, v) → sv subject to the following rules: s(s v) = (ss )v, (s + s )v = sv + s v, s(v + v  ) = sv + sv  , 1v = v, 0v = 0, s0 = 0,

86

´ Zolt´ an Esik and Werner Kuich

for all s, s ∈ S and v, v  ∈ V . When V is an S-semimodule, we call (S, V ) a semiring–semimodule pair. Suppose that (S, V ) is a semiring–semimodule pair such that S is a star semiring, and S and V are equipped with an omega operation ω : S → V . Then we call (S, V ) a star semiring–omega semimodule pair. Following Bloom ´ ´ and Esik [2], see also Esik [8], we call a star semiring–omega semimodule pair (S, V ) a Conway semiring–semimodule pair if S is a Conway semiring and if the omega operation satisfies the sum omega identity and the product omega identity: (a + b)ω = (a∗ b)ω + (a∗ b)∗ aω (ab)ω = a(ba)ω , for all a, b ∈ S. It then follows that the omega fixed point identity holds, i.e., aaω = aω , for all a ∈ S. ´ ´ ´ Theorem 3.2 (Bloom and Esik [2], Esik and Kuich [12], Esik [8]). If (S, V ) is a Conway semiring–semimodule pair, then for n ≥ 1, (S n×n , V n×1 ) again is a Conway semiring–semimodule pair. ´ Esik and Kuich [13] define a complete semiring–semimodule pair to be a semiring–semimodule pair (S, V ) such that S is a complete semiring, V is a complete monoid with    vi = svi , s i∈I

i∈I

   si v = si v, i∈I

i∈I

for all s ∈ S, v ∈ V , and for all families si , i ∈ I over S and vi , i ∈ I over V . Moreover, it is required that an infinite product operation  sj (s1 , s2 , . . .) → j≥1

is given mapping infinite sequences over S to V subject to the following three conditions:   si = (sni−1 +1 · · · · · sni ), s1



i≥1

si+1

i≥1

 =

i≥1

  j≥1 ij ∈Ij

 i≥1

sij =

si , 



(i1 ,i2 ,...)∈I1 ×I2 ×··· j≥1

sij ,

Finite Automata

87

where in the first equation 0 = n0 ≤ n1 ≤ n2 ≤ · · · and I1 , I2 , . . . are arbitrary index sets. Suppose that (S, V ) is complete. Then we define  si , s∗ = i≥0

ω

s =



s,

i≥1

for all s ∈ S. This turns (S, V ) into a star semiring–omega semimodule pair. ´ ´ By Esik and Kuich [13], see also Esik [8], each complete semiring–semimodule pair is a Conway semiring–semimodule pair. A star–omega semiring is a semiring S equipped with unary operations ∗ and ω : S → S. A star–omega semiring S is called complete if (S, S) is a complete semiring–semimodule pair, i.e., if S is complete and is equipped with an infinite product operation that satisfies the three conditions stated above and the omega operation is determined by the infinite product as above. Example 3.3. Suppose that Σ is an alphabet. Let Σ ∗ denote the set of all finite words over Σ including the empty word ε, and let Σ ω denote the set of all ω∗ words over Σ. The set 2Σ of all subsets of Σ ∗ , equipped with the operations of set union as sum and concatenation as product is a semiring, where 0 is the empty set ∅ and 1 is the set {ε}. Moreover, equipped with the usual star ∗ ω operation, 2Σ is a Conway semiring. Also, 2Σ , equipped with union as the sum operation and the empty set as 0 is a commutative idempotent monoid. ∗ ω Define an action of 2Σ on 2Σ by KL = {uv | u ∈ K, v ∈ L}, for all ∗ ∗ ω K ⊆ Σ and L ⊆ Σ . Moreover, for each sequence (K0 , K1 , . . . ) over 2Σ , let  ω Σ∗ Σω , 2 ) is a complete j≥0 Kj = {u0 u1 . . . ∈ Σ | ui ∈ Ki , i ≥ 0}. Then (2 Σω semiring–semimodule pair with idempotent module 2 . Note that in this example, 1ω = 0, where 1 = {ε} and 0 = ∅. Example 3.4. Consider the semiring N∞ = N ∪ {∞}, obtained by adjoining a top element ∞ to the semiring of the natural numbers. Note that N∞ is a complete semiring where an infinite sum is ∞ iff either a summand is ∞ or the number of nonzero summands is infinite. Moreover, ∞ multiplied with a nonzero element on either side gives ∞. Define an infinite product  nj (n1 , n2 , . . .) → j≥1

on N∞ as follows. If some nj is 0, then so is the product. Otherwise, if all but a finite number of the nj are 1s, then the infinite product is the product of those nj with nj > 1. In all remaining cases, the infinite product is ∞. Then N∞ is a complete star–omega semiring, where ∗ and ω are defined as above. Let Σ denote an alphabet. The semiring S = N∞ Σ ∗  of all power series over Σ ∗ with coefficients in N∞ is a complete and continuous semiring. Now

88

´ Zolt´ an Esik and Werner Kuich

let V = N∞ Σ ω  be the collection of all formal power series over Σ ω with coefficients in N∞ . Thus, the elements of V are formal sums of the sort  s= (s, w)w, w∈Σ ω

where each coefficient (s, w) belongs to N∞ . Now V can be turned into an Ssemimodule by the pointwise sum operation and the action (r, s) → rs defined by  (rs, w) = (r, u)(s, v), u∈Σ ∗ , v∈Σ ω , uv=w

where the infinite sum on the right hand side exists since N∞ is complete. We may also define an infinite product  taking sequences over S to series in V . Given s1 , s2 , . . . in S, we define j≥1 sj to be the series r in V with 

(r, w) =



(sj , wj ).

w=w1 w2 ...∈Σ ω j≥1

Then (N∞ Σ ∗ , N∞ Σ ω ) is a complete semiring–semimodule pair, and thus a Conway semiring–semimodule pair. This can be generalized to a large extent. Suppose that S is a complete star–omega semiring. If Σ is a set, consider the complete semiring SΣ ∗  and the complete monoid SΣ ω  of all series over Σ ω with coefficients in S equipped with the pointwise sum operation. If we define the action sr of s ∈ SΣ ∗  on r ∈ SΣ ω  by  (sr, w) = (s, u)(r, v), w=uv

then (SΣ ∗ , SΣ ω ) becomes a semiring–semimodule pair. Now, SΣ ∗  is a star semiring, and if we define the infinite product operation  (s1 , s2 , . . .) → sj ∈ SΣ ω  j≥1

by  j≥1

 sj , w

=





(sj , wj ),

w=w1 w2 ...∈Σ ω j≥1

then (SΣ ∗ , SΣ ω ) becomes a complete semiring–semimodule pair, hence a Conway semiring–semimodule pair, satisfying sω = 0, where each s ∈ S is identified with a series in the usual way. Consider a star semiring–omega semimodule pair (S, V ). Following Bloom ´ ´ and Esik [2], see also Esik [8] and Example 3.1, we define a matrix operation

Finite Automata

89

: S n×n → V n×1 on a star semiring–omega semimodule pair (S, V ) as follows. When n = 0, then Aω is the unique element of V 0×1 . When n = 1, so that A = (a), for some a ∈ S, Aω = (aω ). For n > 1, we partition A into blocks   ab A= , (1) cd ω

where a ∈ S 1×1 , b ∈ S 1×(n−1) , c ∈ S (n−1)×1 , d ∈ S (n−1)×(n−1) , and define   (a + bd∗ c)ω + (a + bd∗ c)∗ bdω Aω = . (2) (d + ca∗ b)ω + (d + ca∗ b)∗ caω Let A and Aω be given as in the definition above, but with a ∈ S n1 ×n1 , b ∈ S n1 ×n2 , c ∈ S n2 ×n1 , d ∈ S n2 ×n2 , where n1 + n2 = n. Then the matrix omega identity is valid in the star semiring–omega semimodule pair if Aω is independent of the partition of n into summands. ´ ´ ´ Theorem 3.5 (Bloom and Esik [2], Esik and Kuich [12], Esik [8]). If (S, V ) is a Conway semiring–semimodule pair, then the matrix omega identity holds in the Conway semiring–semimodule pair (S n×n , V n×1 ) for all n ≥ 1. ´ Following Esik and Kuich [11] (see also Example 3.1), we define matrix operations ω,k : S n×n → V n×1 , 0 ≤ k ≤ n, as follows. Assume that A ∈ S n×n is decomposed into blocks a, b, c, d as in (1), but with a of dimension k × k and d of dimension (n − k) × (n − k). Then   (a + bd∗ c)ω ω,k A = . (3) d∗ c(a + bd∗ c)ω Observe that Aω,0 = 0 and Aω,n = Aω . Suppose that (S, V ) is a semiring–semimodule pair and consider T = S×V . Define on T the operations (s, u) · (s , v) = (ss , u + sv), (s, u) + (s , v) = (s + s , u + v) and constants 0 = (0, 0) and 1 = (1, 0). Equipped with these operations and constants, T satisfies the identities (x + y) + z = x + (y + z), x+y x+0 (x · y) · z x·1

= = = =

y + x, x, x · (y · z), x,

1 · x = x, (x + y) · z = (x · z) + (y · z), 0 · x = 0.

(4) (5) (6) (7) (8) (9) (10) (11)

90

´ Zolt´ an Esik and Werner Kuich

Define also the unary operation ¶ on T : (s, u)¶ = (s, 0). Thus, ¶ selects the “first component” of the pair (s, u), while multiplication with 0 on the right selects the “second component,” for (s, u) · 0 = (0, u), for all u ∈ V . The new operation satisfies: x¶ · (y + z) = (x¶ · y) + (x¶ · z), x = x¶ + (x · 0), x¶ · 0 = 0, (x + y)¶ = x¶ + y¶, (x · y)¶ = x¶ · y¶.

(12) (13) (14) (15) (16)

Note that when V is idempotent, also x · (y + z) = x · y + x · z holds. Elgot [7] defined a quemiring to be an algebraic structure T equipped with the above operations ·, +, ¶ and constants 0, 1 satisfying the identities (4)–(11) and (12)–(16). A morphism of quemirings is a function preserving the operations and constants. It follows that x¶¶ = x¶, for all x in a quemiring T . Moreover, x¶ = x iff x · 0 = 0. When T is a quemiring, S = T ¶ = {x¶ | x ∈ T } is easily seen to be a semiring. Moreover, V = T 0 = {x · 0 | x ∈ T } contains 0 and is closed under +, and furthermore, sx ∈ V for all s ∈ S and x ∈ V . Each x ∈ T may be written in a unique way as the sum of an element of T ¶ and of an element of T 0 as x = x¶ + x · 0. Sometimes, we will identify S × {0} with S and {0} × V with V . It is shown in Elgot [7] that T is isomorphic to the quemiring S × V determined by the semiring–semimodule pair (S, V ). Suppose now that (S, V ) is a star semiring–omega semimodule pair. Then we define on T = S × V a generalized star operation: (s, v)⊗ = (s∗ , sω + s∗ v)

(17)

for all (s, v) ∈ T . Note that the star and omega operations can be recovered from the generalized star operation, since s∗ is the first component of (s, 0)⊗ and sω is the second component. Thus, (s∗ , 0) = (s, 0)⊗ ¶, (0, sω ) = (s, 0)⊗ · 0. Observe that, for (s, 0) ∈ S × {0}, (s, 0)⊗ = (s∗ , 0) + (0, sω ). Suppose now that T is an (abstract) quemiring equipped with a generalized star operation ⊗ . As explained above, T as a quemiring is isomorphic to the quemiring S × V associated with the semiring–semimodule pair (S, V ), where S = T ¶ and V = T 0, an isomorphism being the map x → (x¶, x · 0). It is

Finite Automata

91

clear that a generalized star operation ⊗ : T → T is determined by a star operation ∗ : S → S and an omega operation ω : S → V by (17) iff x⊗ ¶ = (x¶)⊗ ¶, x⊗ · 0 = (x¶)⊗ · 0 + x⊗ ¶ · x · 0

(18) (19)

hold. Indeed, these conditions are clearly necessary. Conversely, if (18) and (19) hold, then for any x¶ ∈ T ¶ we may define (x¶)∗ = (x¶)⊗ ¶, ⊗

(x¶) = (x¶) · 0. ω

(20) (21)

It follows that (17) holds. The definition of star and omega was forced. Let us call a quemiring equipped with a generalized star operation ⊗ satisfying (18) and (19) a generalized star quemiring. 3.2 Finite Automata over Quemirings and a Kleene Theorem In this subsection, we consider finite automata over quemirings and prove a Kleene theorem. Throughout this subsection, (S, V ) denotes a Conway semiring–semimodule pair and T denotes the generalized star quemiring S×V . Moreover, S  denotes a subset of S. A finite S  -automaton (over the quemiring T ) A = (n, R, A, P, k) is given by: (i) (ii) (iii) (iv) (v)

A finite set of states {1, . . . , n}, n ≥ 1 A transition matrix A ∈ (S  ∪ {0, 1})n×n An initial state vector R ∈ (S  ∪ {0, 1})1×n A final state vector P ∈ (S  ∪ {0, 1})n×1 a set of repeated states {1, . . . , k}, k ≥ 0

The behavior of A is an element of T and is defined by A = RA∗ P + RAω,k . If A = n, (i1 i2 ), ac db , pp12 , k , where i1 ∈ (S  ∪ {0, 1})1×k ,

i2 ∈ (S  ∪ {0, 1})1×(n−k) ,

a ∈ (S  ∪ {0, 1})k×k ,

b ∈ (S  ∪ {0, 1})k×(n−k) ,

c ∈ (S  ∪ {0, 1})(n−k)×k ,

d ∈ (S  ∪ {0, 1})(n−k)×(n−k) ,

p1 ∈ (S  ∪ {0, 1})k×1 ,

p2 ∈ (S  ∪ {0, 1})(n−k)×1 ,

we write also A = (n; i1 , i2 ; a, b, c, d; p1 , p2 ; k).

92

´ Zolt´ an Esik and Werner Kuich

Theorem 3.6. If (S, V ) is a complete semiring–semimodule pair and A is a finite S  -automaton, then A = F + I, where F is the sum of the weights of all finite paths from an initial state to a final state, multiplied by the initial and final weights of these states, and where I is the sum of the weights of all infinite paths starting at an initial state, passing infinitely often through repeated states, and multiplied by the initial weight of this initial state. Proof. By formalization of the considerations in Example 3.1 (see the proof ´ of Theorem 3.5 of Esik and Kuich [11]). Note that the finite S  -automata A = (n, R, A, P ) and A = (n, R, A, P, 0) over a Conway semiring S and a star semiring–omega semimodule pair (S, V ), respectively, have the same behavior A = A  = RA∗ P . By definition, ω-Rat(S  ) is the Conway semiring–semimodule pair generated by S  . We now will prove a Kleene theorem: Let a ∈ S × V . Then a ∈ ω-Rat(S  ) iff a is the behavior of a finite S  -automaton. To achieve this result, we need a few theorems and corollaries. In our arguments, we will use Theorem 3.5. Let A = (n, R, A, P, k) be a finite S  -automaton. It is called normalized if: (i) (ii) (iii) (iv)

n ≥ 2 and k ≤ n − 2. Rn−1 = 1 and Rj = 0 for j = n − 1. Pn = 1 and Pj = 0 for j = n. Ai,n−1 = 0 and An,i = 0 for all 1 ≤ i ≤ n.

Two finite S  -automata A and A are equivalent if A = A . Theorem 3.7. Each finite S  -automaton A = (n, R, A, P, k) is equivalent to a normalized finite S  -automaton A = (n + 1 + 1, R , A , P  , k). A 0 P  0 Proof. We define R = (0 1 0), A = R 0 0 and P  = 0 . Let now 1 0 0 0 A = (n; i1 , i2 ; a, b, c, d; p1 , p2 ; k). Then ⎛ ⎞ a b 0 p1 ⎜ c d 0 p2 ⎟ ⎟ A = ⎜ ⎝ i1 i2 0 0 ⎠ 0 0 0 0 and the first k entries of Aω,k are equal to ⎛ ⎞∗ ⎛ ⎞⎞ω ⎛ c d 0 p2 ⎝a + (b 0 p1 ) ⎝i2 0 0 ⎠ ⎝i1 ⎠⎠ 0 0 0 0 ⎞ ⎛ ⎞⎞ω ⎛ ⎛ ∗ c d 0 d∗ p2 = ⎝a + (b 0 p1 ) ⎝i2 d∗ 1 i2 d∗ p2 ⎠ ⎝i1 ⎠⎠ 0 0 1 0 = (a + bd∗ c)ω .

Finite Automata

93

Hence, the last n − k + 2 entries of Aω,k are equal to ⎞ ⎞∗ ⎛ ⎞ ⎛ ⎛ c d∗ c d 0 p2 ⎝ i2 0 0 ⎠ ⎝ i1 ⎠ (a + bd∗ c)ω = ⎝ i2 d∗ c + i1 ⎠ (a + bd∗ c)ω 0 0 0 0 0 and we obtain

A  = R A∗ P  + R Aω,k = (A∗ )n+1,n+2 + Aω,k n+1 = RA∗ P + (i2 d∗ c + i1 )(a + bd∗ c)ω = RA∗ P + RAω,k = A.



Lemma 3.8. If A = (n; i1 , i2 ; a, b, c, d; p1 , p2 ; k) is a finite S  -automaton then A = i1 (a + bd∗ c)∗ (p1 + bd∗ p2 ) + i2 d∗ c(a + bd∗ c)∗ (p1 + bd∗ p2 ) + i2 d∗ p2 + i1 (a + bd∗ c)ω + i2 d∗ c(a + bd∗ c)ω . Let A = (n; i1 , i2 ; a, b, c, d; f, g; m) and A = (n ; h, i; a , b , c , d ; p1 , p2 ; k) be finite S  -automata. Then we define the finite S  -automata A + A and A · A to be   A + A = n + n ; (i1 h), (i2 i);         b 0 c 0 d 0 a 0 , , , ; 0 b 0 c 0 d 0 a      g f , ,m + k p2 p1 and A · A =

 n + n ; (i1 0), (i2 0);         b fi c gh d gi a fh , , , ; 0 b 0 c 0 d 0 a      0 0 , ,m + k . p2 p1

 For the definition of A · A , we assume that either fg (h i) ∈ (S  ∪ {0, 1})n×n or A is normalized. Observe that the definitions of A + A and A · A (and of A⊗ which is defined below) are the usual ones except that certain rows and columns are permuted. These permutations are needed since the set of repeated states of a finite S  -automaton is always a set {1, . . . , k}. Theorem 3.9. Let A and A be finite S  -automata. Then A + A  = A + A  and A · A  = A · A .

94

´ Zolt´ an Esik and Werner Kuich

Proof. Let A and A be defined as above. We first show A+A  = A+A  and compute A + A  · 0. The transition matrix of A + A is given by ⎛ ⎞ a 0 b 0 ⎜ 0 a 0 b  ⎟ ⎟ A=⎜ ⎝c 0 d 0 ⎠ . 0 c  0 d We now compute the first m + k entries of Aω,m+k . This column vector of dimension m + k is given by     ∗  ω a 0 b 0 d 0 c 0 + 0 a 0 b 0 d 0 c     ω a + bd∗ c (a + bd∗ c)ω 0 = = . (a + b d∗ c )ω 0 a + b d∗ c The last n + n − (m + k) entries of Aω,m+k are given by the product of ∗    ∗   c 0 d c 0 d 0 = 0 d∗ c 0 c 0 d with the column vector computed above. Hence, we obtain by Lemma 3.8 A + A  · 0 = (i1 h i2 i)Aω,m+k = i1 (a + bd∗ c)ω + h(a + b d∗ c )ω + i2 d∗ c(a + bd∗ c)ω + id∗ c∗ (a + b d∗ c )ω = (A + A ) · 0. We now compute A + A ¶. If, in the transition matrix A of A + A we commute the m + 1, . . . , m + k row and column with the m + k + 1, . . . , n + k row and column, and do the same with the initial and final vector we obtain ´ ´ by the star permutation identity (see Conway [4], Bloom and Esik [2], Esik ´ and Kuich [9], and Esik [8]). ⎛ ⎞∗ ⎛ ⎞ ab 0 0 f ⎜c d 0 0 ⎟ ⎜ g ⎟  ⎜ ⎟ ⎜ ⎟ A + A ¶ = (i1 i2 h i) ⎝ 0 0 a b ⎠ ⎝ p1 ⎠ 0 0 c  d p2  ∗      ∗   ab f a b p1 = (i1 i2 ) + (h i) c  d p2 cd g = (A + A )¶. Hence, A + A  = A + A . We now show A · A  = A · A  and compute A · A  · 0. The transition matrix of A · A is given by

Finite Automata



a ⎜0 ⎜ A=⎝ c 0

fh b a 0 gh d c 0

95

⎞ fi b ⎟ ⎟. gi ⎠ d

We now compute the first m + k entries of Aω,m+k . This column vector of dimension m + k is given by     ∗ ∗ ∗   ω  b fi d d gid c gh a fh + 0 d∗ 0 b 0 c 0 a  ω a + bd∗ c (f + bd∗ g)(h + id∗ c ) = 0 a + b d∗ c   (a + bd∗ c)ω + (a + bd∗ c)∗ (f + bd∗ g)(h + id∗ c )(a + b d∗ c )ω = . (a + b d∗ c )ω The last n + n − (m + k) entries of Aω,m+k are given by the product of ∗    ∗   c gh d c d∗ g(h + id∗ c ) d gi = 0 d∗ c 0 c 0 d with the column vector computed above. Hence, we obtain A · A  · 0 = (i1 0 i2 0)Aω,m+k = i1 (a + bd∗ c)ω + i1 (a + bd∗ c)∗ (f + bd∗ g)(h + id∗ c)(a + b d∗ c )ω + i2 d∗ c(a + bd∗ c)ω + i2 d∗ c(a + bd∗ c)∗ (f + bd∗ g)(h + id∗ c ) × (a + b d∗ c )ω + i2 d∗ g(h + id∗ c )(a + b d∗ c )ω . On the other side, we obtain by Lemma 3.8 A · A  · 0 = A · 0 + A¶ · A  · 0 = i1 (a + bd∗ c)ω + i2 d∗ c(a + bd∗ c)ω + (i1 (a + bd∗ c)∗ (f + bd∗ g) + i2 d∗ c(a + bd∗ c)∗ (f + bd∗ g) + i2 d∗ g)(h + id∗ c )(a + b d∗ c )ω . Hence, A · A  · 0 = A · A  · 0. We now compute A · A ¶. If, in the transition matrix A of A · A , we commute the m + 1, . . . , m + k row and column with the m + k + 1, . . . , n + k row and column, and do the same with the initial and final vector we obtain ´ ´ by the star permutation identity (see Conway [4], Bloom and Esik [2], Esik ´ and Kuich [9], and Esik [8]),

96

´ Zolt´ an Esik and Werner Kuich

⎞∗ ⎛ ⎞ 0 a b fh fi ⎜ c d gh gi ⎟ ⎜ 0 ⎟  ⎟ ⎜ ⎟ A · A ¶ = (i1 i2 0 0) ⎜ ⎝ 0 0 a b ⎠ ⎝ p1 ⎠ 0 0 c  d p2  ∗      ∗   ab f a b p1 = (i1 i2 ) (h i) cd c  d p2 g ⎛

= A¶ · A ¶ = A · A ¶. Hence, A · A  = A · A .



 Let A = (n; h,

i; a, b, c, d; f,

g; k) be a finite S -automaton and write R = f a b (h i), A = c d and P = g . Then we define the finite S -automaton A⊗ to be      0h iR ⊗ , , A = 1 + n + n; (1 0), (0 0); 0a b 0          0 c d 0 1 0 , ; , ;1 + k . P 0 0A 0 0

Theorem 3.10. Let A be a finite S  -automaton. Then A⊗  = A⊗ . Proof. Let A be defined as above. Let ⎛ 0 ⎜0  ⎜ A =⎝ 0 P

h a c 0

i b d 0

⎞ R 0⎟ ⎟. 0⎠ A

We first compute A⊗ ¶. Observe that A can be written as ⎛ ⎞ 0 RR A = ⎝ 0 A 0 ⎠ P 0 A and that A⊗ ¶ = (A∗ )11 . We obtain   ∗  ∗ A 0 0 (A∗ )11 = (R R) 0 A P = (RA∗ P )∗ = (A¶)∗ = A⊗ ¶. We now compute the first 1 + k entries of Aω,1+k . This column vector of dimension 1 + k is given by ω     ∗  0 c 0h iR d 0 + P 0 0a b 0 0A  ω ∗ ∗ RA P h + id c = . 0 a + bd∗ c

Finite Automata

97

Hence,

A⊗  · 0 = Aω,1+k 1 = (RA∗ P )ω + (RA∗ P )∗ (h + id∗ c)(a + bd∗ c)ω . By definition, A⊗ · 0 = (A¶)ω + (A¶)∗ A · 0. Thus, A⊗ · 0 = (RA∗ P )ω + (RA∗ P )∗ (h + id∗ c)(a + bd∗ c)ω = A⊗  · 0 and we obtain A⊗  = A⊗ .



Theorem 3.11. Let A = (n, R, A, P, k) be a finite S  -automaton. Then there exists a finite S  -automaton A¶ such that A¶ = A¶. Proof. A¶ = (n, R, A, P, 0).



Theorem 3.12. Let a ∈ S  ∪ {0, 1}. Then there exists a finite S  -automaton Aa such that Aa  = a. Proof. Let Aa = 2, (1 0), ( 00 a0 ) , 01 , 0 . Then    1a 0 Aa  = (1 0) = a.

01 1 Corollary 3.13. The behaviors of finite S  -automata form a generalized star quemiring that contains S  . Theorem 3.14 (Kleene theorem). Let (S, V ) be a Conway semiring–semisemimodule pair. Then the following statements are equivalent for (s, v) ∈ S×V: (i) (s, v) = A, where A is a finite S  -automaton. (ii) (s, v) ∈ ω-Rat(S  ).   (iii) s ∈ Rat(S  ) and v is of the form 1≤i≤m si tω i with si , ti ∈ Rat(S ).  Proof. (i) ⇒ (iii): Each entry in A∗ and Aω,k is of the form s and 1≤i≤m si tω i , respectively, with s, si , ti ∈ Rat(S  ).   ) (iii) ⇒ (ii): (s,  v) = (s, 0)ω + (0, v). Since (s, 0) is in Rat(S ) ⊆ ω − Rat(S  and (0, v) = (0, 1≤i≤m si ti ) is in ω − Rat(S ), (s, v) is in ω − Rat(S ). (ii) ⇒ (i): By Corollary 3.13.

We now consider finite SΣ ∪ {ε}-automata over the Conway semiring– semimodule pair (SΣ ∗ , SΣ ω ), where S is a complete star–omega semiring, and will delete ε-moves in these finite SΣ ∪ {ε}-automata without changing their behavior. Theorem 3.15. Let (SΣ ∗ , SΣ ω ) be a Conway semiring–semimodule pair satisfying (sε)ω = 0 for all s ∈ S. Let A = (n, R, A, P, k) be a finite SΣ ∪ {ε}-automaton. Then there exists a finite SΣ ∪ {ε}-automaton A = (n, R , A , P  , k) with A  = A satisfying the following conditions:

98

´ Zolt´ an Esik and Werner Kuich

(i) A ∈ (SΣ)n×n . (ii) R ∈ (S{ε})1×n . (iii) P  ∈ (S{ε})n×1 . Proof. Without loss of generality, we assume

Theorem 3.7 that R ∈ by (S{ε})1×n and P ∈ (S{ε})n×1 . Let A = ac db , where a is a k × k-matrix and d is a (n − k) × (n − k)-matrix. Let a = a0 + a1 , b = b0 + b1 , c = c0 + c1 , d = d0 + d1 , such that the supports of the entries of a0 , b0 , c0 , d0 (resp. ∗ ω a1 , b1 , c1 , d1 ) are subsets of {ε} (resp. Σ). By assumption, 0 + b0 d0 c0 ) = 0.

0(a b0 Define the matrices A01 , A02 , and A1 to be A01 = 0 d0 , A02 = ac00 00

and A1 = ac11 db11 . We now specify the finite SΣ ∪ {ε}-automaton A : R = R(A∗01 A02 )∗ , A = A∗01 A1 (A∗01 A02 )∗ and P  = A∗01 P . The behavior of A is then given by A  = R A∗ P  + R Aω,k

∗ = R(A∗01 A02 )∗ A∗01 A1 (A∗01 A02 )∗ A∗01 P

ω,k + R(A∗01 A02 )∗ A∗01 A1 (A∗01 A02 )∗ = R(A01 + A02 + A1 )∗ P + R(A01 + A02 + A1 )ω,k = RA∗ P + RAω,k = A. ´ Here, we have applied Theorem 2.10 of Esik and Kuich [11] in the third equality.

In the next theorem, we construct a finite SΣ ∪ {ε}-automaton without ε-moves with a unique initial state of initial weight ε. Theorem 3.16. Let (SΣ ∗ , SΣ ω ) be a Conway semiring–semimodule pair as in Theorem 3.15, and consider a finite SΣ ∪ {ε}-automaton A = (n, R, A, P, k). Then there exists a finite SΣ ∪ {ε}-automaton A = (n + 1, R , A , P  , k) with A  = A satisfying the following conditions: (i) A ∈ (SΣ)(n+1)×(n+1) .  = ε. (ii) Rj = 0, 1 ≤ j ≤ n, and Rn+1  (n+1)×1 . (iii) P ∈ (S{ε}) Proof. We assume that A satisfies the conditions of Theorem 3.15. We

specify A 0 ) and P  = ( P ). We compute A∗ = A∗ 0 A by R = (0 ε), A = ( RA 0 RP RAA∗ ε a b and, for A = c d , R = (i1 i2 ), ⎞ω,k ⎛ a b 0 c d 0⎠ Aω,k = ⎝ i1 a + i2 c i1 b + i2 d 0 ⎞ ⎛ (a + bd∗ c)ω ⎠ d∗ c(a + bd∗ c)ω =⎝ (i1 (a + bd∗ c) + i2 d∗ c)(a + bd∗ c)ω  ω,k  A = . RAω,k

Finite Automata

Hence, A  = RAA∗ P + RP + RAω,k = A.

99



In the case of the Boolean semiring, the finite BΣ ∪{ε}-automata of Theorem 3.16 with P  = 0 are nothing else than the finite automata introduced by B¨ uchi [3]. In the case of the semiring N∞ , we get the following result. Theorem 3.17. The constructions of Theorems 3.15 and 3.16 do not change, for w ∈ Σ ∗ (resp. for w ∈ Σ ω ), in the digraphs of the finite automata, the number of finite paths with label w from an initial state to a final state (resp. the number of infinite paths with label w starting in an initial state and passing infinitely often through repeated states). 3.3 Finite Linear Systems over Quemirings In this subsection, we consider finite linear systems over quemirings as a generalization of regular grammars with finite and infinite derivations. A finite S  -linear system (with variables y1 , . . . , yn , over the quemiring S × V ) is a system of equations y = Ay + P

(22)  y1  .. . A column vector where A ∈ (S  ∪ {0, 1})n×n , P ∈ (S  ∪ {0, 1})n×1 , y = . yn

σ ∈ (S × V )n×1 is called a solution to the system (22) if σ = Aσ + P.

Theorem 3.18. Let (S, V ) be a Conway semiring–semimodule pair. Consider a finite S  -linear system y = Ay + P,  y1  .. is a column where A ∈ (S  ∪ {0, 1})n×n , P ∈ (S  ∪ {0, 1})n×1 , and y = . yn

vector of variables. Then for each 0 ≤ k ≤ n, Aω,k + A∗ P is a solution of y = Ay + P . Proof. We obtain by Theorem 3.2 and the star and omega fixed point identities ´ (cf. Esik [8]), for each 0 ≤ k ≤ n, A(Aω,k + A∗ P ) + P = Aω,k + A∗ P.

Let k ∈ {0, . . . , n} and Ai = (n, ei , A, P, k), 1 ≤ i ≤ n, be finite S  automata, where ei is the ith vector of unity. Then Ai  is the ith component of a solution given in Theorem  3.18 of  the finite S  -linear system y = Ay + P .

A1

Therefore, we call the solution

.. .

= Aω,k + A∗ P of y = Ay + P the kth

An

automata-theoretic solution of y = Ay + P .

100

´ Zolt´ an Esik and Werner Kuich

Theorem 3.19. Let (S, V ) be a Conway semiring–semimodule pair and S  ⊆ S. Let A = (n, R, A, P, k) be a finite S  -automaton. Then A = Rσ, where σ is the kth automata-theoretic solution of the finite S  -linear system y = Ay + P . ´ Bi-inductive semiring–semimodule pairs were defined in Esik and Kuich ´ [13], see also Esik [8]. As shown in these papers, every bi-inductive semiring– semimodule pair is a Conway semiring–semimodule pair. Suppose that (S, V ) is a bi-inductive semiring–semimodule pair and consider the quemiring S × V , which is equipped with the pointwise partial order inherited from the orders on S and V . Moreover, consider the above finite S  -linear system y = Ay + P and write it in more detail as y  = ay  + by  + p , y  = cy  + dy  + p

(23) (24)

where y  denotes the matrix of the first k entries of y, etc. We point out that the first k components of the above kth automata theoretic solution of y = Ay + P over S × V can be obtained by first taking the least solution d∗ (cy  + p ) of (24) and substituting this least solution into (23), and then by taking the greatest solution (a+bd∗ c)ω +(a+bd∗ c)∗ (p +bd∗ p ) of the resulting equation. The last n − k components of the kth automata theoretic solution are then obtained by substituting this greatest solution into d∗ (cy  + p ), the least solution of (24). Thus, we obtain the kth automata theoretic solution 

ab cd



ω,k +

ab cd

∗ 

p p

 .

Let S be a complete star–omega semiring and consider a finite S  -linear system y = Ay + P over the quemiring SΣ ∗  × SΣ ω  as defined before Theorem 3.18 for S  = SΣ ∪ {ε}. Write this system in the form    yi = (Aij , x)xyj + (Pi , x)x, 1 ≤ i ≤ n. 1≤j≤n x∈Σ∪{ε}

x∈Σ∪{ε}

Analogous to the correspondence stated below Theorem 2.18, the right linear grammars Gi = ({y1 , . . . , yn }, Σ, Π, yi ), 1 ≤ i ≤ n, with weights in the semiring S, where Π = {yi → (Aij , x)xyj | 1 ≤ j ≤ n, x ∈ Σ ∪ {ε}} ∪ {yi → (Pi , x)x | x ∈ Σ ∪ {ε}} correspond to this finite SΣ ∪ {ε}-linear system. Here, (Aij , x) and (Pi , x) are the weights of the productions yi → xyj and yi → x, respectively. Furthermore, let Aki = (n, ei , A, P, k) be finite S  automata, 1 ≤ i ≤ n, for some fixed k ∈ {0, . . . , n}, where ei is the ith row vector of unity. Consider now a finite derivation with respect to Gi : yi ⇒ (Ai,i1 , x1 )x1 yi1 ⇒ · · · ⇒ (Ai,i1 , x1 ) . . . (Aim−1 ,im , xm )x1 . . . xm yim ⇒ (Ai,i1 , x1 ) . . . (Aim−1 ,im , xm )(Pim , xm+1 )x1 . . . xm xm+1

Finite Automata

101

generating the word x1 . . . xm xm+1 with weight (Ai,i1 , x1 ) . . . (Aim−1 ,im , xm )(Pim , xm+1 ). This finite derivation corresponds to the following finite path in the directed graph of Aki : (yi , x1 , yi1 ), . . . , (yim−1 , xm , yim ) with weight (Ai,i1 , x1 ) . . . (Aim−1 ,im , xm ), initial weight 1 and final weight (Pim , xm+1 )xm+1 . Consider now an infinite derivation with respect to Gi : yi ⇒ (Ai,i1 , x1 )x1 yi1 ⇒ · · · ⇒ (Ai,i1 , x1 ) . . . (Aim−1 ,im , xm )x1 . . . xm yim ⇒ · · · generating the infinite word x1 x2 . . . xm . . . with weight (Ai,i1 , x1 ) . . . (Aim−1 ,im , xm ) . . . . This infinite derivation corresponds to the following infinite path in the directed graph of Aki : (yi , x1 , yi1 ), . . . , (yim−1 , xm , yim ), . . . with weight (Ai,i1 , x1 ) . . . (Aim−1 ,im , xm ) . . . and initial weight 1. If S is a complete star–omega semiring, then (SΣ ∗ , SΣ ω ) is a com´ ´ plete semiring–semimodule pair by Esik and Kuich [13], see also Esik [8]. Hence, we obtain by Theorem 3.6, the following result for Gi and Aki as defined above. Theorem 3.20. If S is a complete star–omega semiring and 1 ≤ i ≤ n, 0 ≤ k ≤ n, then for w ∈ Σ ∗ , (Aki , w) = ((A∗ P )i , w) is the sum of the weights of all finite derivations of w with respect to Gi ; and for w ∈ Σ ω , (Aki , w) = ((Aω,k )i , w) is the sum of the weights of all infinite derivations of w with respect to Gi such that at least one of the variables of {y1 , . . . , yk } appears infinitely often in these infinite derivations. In particular, if S = N∞ and (Aij , x), (Pi , x) ∈ {0, 1}, x ∈ Σ ∪ {ε}, 1 ≤ i, j ≤ n, then we get the following result. Theorem 3.21. For w ∈ Σ ∗ , (Aki , w) = ((A∗ P )i , w) is the number of finite derivations of w with respect to Gi ; and for w ∈ Σ ω , (Aki , w) = ((Aω,k )i , w) is the number of all infinite derivations of w with respect to Gi such that at least one of the variables of {y1 , . . . , yk } appears infinitely often in these infinite derivations.

102

´ Zolt´ an Esik and Werner Kuich

Given a right linear grammar Gi = ({y1 , . . . , yn }, Σ, Π, yi ), 1 ≤ i ≤ n, with weights as above, and k ∈ {0, . . . , n}, L(Gi )k is defined to be the weighted language   ω,k  



 A L(Gi )k = (A∗ P )i , w w  w ∈ Σ ∗ ∪ , w w  w ∈ Σω . i The next theorem, Theorem 3.22, shows that such weighted languages can be generated by right linear grammars with weights in the semiring S which have only two types of productions: yi → axyj

and yi → aε,

where a ∈ S and x ∈ Σ. Hence, in such right linear grammars, there are no productions yi → ayj . Corollary 3.23 shows then that the two types of productions can be chosen as yi → axyj

and yi → ax,

where a ∈ S and x ∈ Σ. (Of course, ε is no longer derived. Compare this with the definition of a regular grammar below Theorem 2.18. Moreover, compare the forthcoming Corollary 3.23 with Theorem 2.18.) Theorem 3.22. Let (SΣ ∗ , SΣ ω ) be a Conway semiring–semimodule pair where (sε)ω = 0 for all s ∈ S, consider a finite SΣ ∪ {ε}-linear system  y = Ay + P , where A ∈ (SΣ ∪ {ε})n×n , P ∈ (SΣ ∪ {ε})n×1 , and y1

y=

.. .

and let i ∈ {1, . . . , n}. Then there exists a finite SΣ ∪ {ε}-linear

yn

system y  = A y  + P  , where A ∈ (SΣ)(n+1)×(n+1) , P  ∈ (S{ε})(n+1)×1 , y ) such that, for all 0 ≤ k ≤ n, the (n+1)st component of the kth and y  = ( yn+1 automata-theoretic solution of y = Ay + P coincides with the ith component of the kth automata theoretic solution of y  = A y  + P  . Proof. Consider the finite SΣ ∪ {ε}-automaton Aki = (n, ei , A, P, k), whose behavior is Aki  = (A∗ P )i + (Aω,k )i . Starting with Aki , perform the constructions of Theorems 3.15 and 3.16. This yields a finite SΣ ∪ {ε}-automaton A = (n + 1, en+1 , A , P  , k) with behavior A  = (A∗ P  )n+1 + (Aω,k )n+1 =

Aki . Corollary 3.23. Let (SΣ ∗ , SΣ ω ) be a Conway semiring–semimodule pair where (sε)ω = 0 for all s ∈ S, consider a finite SΣ ∪ {ε}-linear system  y = Ay + P , where A ∈ (SΣ ∪ {ε})n×n , P ∈ (SΣ ∪ {ε})n×1 , and y1

y=

.. .

yn

and let i ∈ {1, . . . , n}. Then there exists a finite SΣ ∪ {ε}-linear

system y  = A y  + P  , where A ∈ (SΣ)(n+1)×(n+1) , P  ∈ (SΣ)(n+1)×1 , y ) such that (Aω,k + A∗ A P  )n+1 = (Aω,k + AA∗ P )i . and y  = ( yn+1

Finite Automata

103

Proof. Let y  = A y  + P  be the finite SΣ ∪ {ε}-linear system constructed according to Theorem 3.22 from y = Ay + P . Consider the finite SΣ ∪ {ε}linear system y  = A y  + P  , where P  = A P  . Then (Aω,k + A∗ P  )n+1 =

(Aω,k + A∗ A P  )n+1 = (Aω,k + AA∗ P )i . Corollary 3.24. Let S be a complete star–omega semiring and consider, for some i ∈ {1, . . . , n}, the right linear grammar Gi = ({y1 , . . . , yn }, Σ, Π, yi ) with weights in S. Then there exists a right linear grammar G(i) = ({y1 , . . . , yn , yn+1 }, Σ, (i) Π , yn+1 ) with weights, which has only the two types of productions yi → axyi

and

yi → aε

(resp.

yi → axyj

and

yi → ax),

a ∈ S, x ∈ Σ, such that, for all 0 ≤ k ≤ n, (i) L Gn+1 k = L(Gi )k



resp.

(i) 

 L Gn+1 k = L(Gi )k − L(Gi )k , ε ε .

If we consider finite N∞ Σ ∪ {ε}-linear systems, we obtain the following result about the derivations with respect to the right linear grammars Gi defined above. Corollary 3.25. The constructions of Theorem 3.22 and Corollary 3.23 do not change, for w ∈ Σ + (resp. for w ∈ Σ ω ), the number of finite derivations of w with respect to Gi (resp. the number of infinite derivations of w with respect to Gi such that at least one of the variables of {y1 , . . . , yn } appears infinitely often in these infinite derivations). Hence, the constructions transform unambiguous grammars into unambiguous grammars.

References 1. J. Berstel and C. Reutenauer. Les s´eries rationelles et leurs langages. Masson, Paris, 1984. English translation: Rational Series and Their Languages, volume 12 of Monographs in Theoretical Computer Science. An EATCS Series. Springer, 1988. ´ 2. S.L. Bloom and Z. Esik. Iteration Theories, Monographs in Theoretical Computer Science. An EATCS Series. Springer, Berlin, 1993. 3. J.R. B¨ uchi. On a decision method in restricted second order arithmetic. In Proc. Int. Congr. Logic, Methodology and Philosophy of Science, 1960. pages 1–11. Stanford University Press, Stanford, 1962. 4. J.H. Conway. Regular Algebra and Finite Machines. Chapman & Hall, London, 1971. 5. M. Droste and W. Kuich. Semirings and formal power series. In this Handbook, chapter 1. Springer, Berlin, 2009

104

´ Zolt´ an Esik and Werner Kuich

6. S. Eilenberg. Automata, Languages and Machines, volume C. Draft of Sects. I–III, 1978. 7. C. Elgot. Matricial theories. Journal of Algebra, 42:391–422, 1976. ´ 8. Z. Esik. Fixed point theory. In this Handbook, chapter 2. Springer, Berlin, 2009 ´ 9. Z. Esik and W. Kuich. Inductive ∗ -semirings. Theoretical Computer Science, 324:3–33, 2004. ´ 10. Z. Esik and W. Kuich. Equational axioms for a theory of automata. In C. Martin-Vide, V. Mitrana, and G. Paun, editors, Formal Languages and Applications, volume 148 of Studies in Fuzziness and Soft Computing, pages 183–196. Springer, Berlin, 2004. ´ 11. Z. Esik and W. Kuich. A semiring–semimodule generalization of ωregular languages II. Journal of Automata, Languages and Combinatorics, 10:243–264, 2005. ´ 12. Z. Esik and W. Kuich. Modern Automata Theory. www.dmg.tuwien. ac.at/kuich, 2007 ´ 13. Z. Esik and W. Kuich. On iteration semiring–semimodule pairs. Semigroup Forum, 75:129–159, 2007. 14. U. Hebisch. The Kleene theorem in countably complete semirings. Bayreuther Mathematische Schriften, 31:55–66, 1990. 15. J.E. Hopcroft and J.D. Ullman. Introduction to Automata Theory, Languages, and Computation. Addison–Wesley, Reading, 1979. 16. St.C. Kleene. Representation of events in nerve nets and finite automata. In C.E. Shannon and J. McCarthy, editors, Automata Studies, pages 3–41. Princeton University Press, Princeton, 1956. 17. W. Kuich. The Kleene and the Parikh theorem in complete semirings. In ICALP87, volume 267 of Lecture Notes in Computer Science, pages 212–225. Springer, Berlin, 1987. 18. W. Kuich. Semirings and formal power series: Their relevance to formal languages and automata theory. In G. Rozenberg and A. Salomaa, editors, Handbook of Formal Languages, volume 1, Chapter 9, pages 609–677. Springer, Berlin, 1997. 19. W. Kuich and A. Salomaa. Semirings, Automata, Languages, volume 5 of Monographs in Theoretical Computer Science. An EATCS Series. Springer, Berlin, 1986. ´ Pin, Infinite Words, Elsevier, 2004 20. D. Perrin and J.-E. 21. I. Petre and A. Salomaa. Algebraic systems and pushdown automata. In this Handbook, chapter 7. Springer, Berlin, 2009 22. A. Salomaa. Formal Languages. Academic Press, San Diego, 1973. 23. A. Salomaa and M. Soittola. Automata-Theoretic Aspects of Formal Power Series. Springer, Berlin, 1978. 24. M.P. Sch¨ utzenberger. On the definition of a family of automata. Information and Control, 4:245–270, 1961.

Chapter 4: Rational and Recognisable Power Series Jacques Sakarovitch LTCI, ENST/CNRS, 46 rue Barrault, 75634 Paris Cedex 13, France [email protected]

1

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

2

Rational Series and Weighted Rational Expressions . . . . . . . 107

2.1 2.2

Series over a Graded Monoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Rational Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

3

Weighted Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

3.1 3.2 3.3

The Behaviour of a Weighted Automaton . . . . . . . . . . . . . . . . . . . . . . . 122 The Fundamental Theorem of Automata . . . . . . . . . . . . . . . . . . . . . . . 126 Conjugacy and Covering of Automata . . . . . . . . . . . . . . . . . . . . . . . . . . 132

4

Recognisable Series and Representations . . . . . . . . . . . . . . . . . . 138

4.1 4.2 4.3

The Family of Recognisable Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Other Products on Recognisable Series . . . . . . . . . . . . . . . . . . . . . . . . . 141 Series on a Product of Monoids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

5

Series over a Free Monoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

5.1 5.2 5.3

The Representability Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Reduced Representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Applications of the Reduction of Representations . . . . . . . . . . . . . . . . 161

6

Support of Rational Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

7

Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

7.1 7.2 7.3 7.4

General Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 Notes to Sect. 2: Rational Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Notes to Sect. 3: Weighted Automata . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Notes to Sect. 4: Recognisable Series . . . . . . . . . . . . . . . . . . . . . . . . . . . 170



This chapter is adapted from Chaps. III and IV of the book Elements of Automata c Theory, Jacques Sakarovitch, 2009, Cambridge University Press, where missing proofs, detailed examples and further developments can be found.

M. Droste, W. Kuich, H. Vogler (eds.), Handbook of Weighted Automata, Monographs in Theoretical Computer Science. An EATCS Series, DOI 10.1007/978-3-642-01492-5 4, Springer-Verlag Berlin Heidelberg 2009

105

106

7.5 7.6

Jacques Sakarovitch

Notes to Sect. 5: Series over a Free Monoid . . . . . . . . . . . . . . . . . . . . . 170 Notes to Sect. 6: Support of Rational Series . . . . . . . . . . . . . . . . . . . . . 171

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

1 Introduction Weighted automata realise power series—in contrast to ‘classical’ automata which accept languages. There are many good reasons that make power series worth an interest compared to languages, beyond the raw appeal to generalisation that inhabits every mathematician. First, power series provide a more powerful mean for modelisation, replacing a pure acceptance/rejection mode by a quantification process. Second, by putting automata theory in a seemingly more complicated framework, one benefits from the strength of mathematical structures thus involved and some results and constructions become simpler, both conceptually, and on the complexity level. Let us also mention, as a third example, that in the beginning of the theory, weighted automata were probably considered for their ability of defining languages—via the supports of realised power series—rather than for the power series themselves. In all these instances, what matters is that the choice of the semiring S of multiplicity be as wide as possible and our first aim is to develop as far as possible a theory with a priori no assumption at all on S. With this in mind, I have chosen as the main thread of this chapter to lay comprehensive bases for the proof of the decidability of the equivalence of deterministic k-tape transducers which is, at least in my opinion, one of the most striking examples of the application of algebra to “machine theory.” To that end, I develop in particular the following points: (a) The definition of rational series over graded monoids (in order to deal with direct product of free monoids) and not over free monoids only. A side benefit of the definition of series over arbitrary (graded) monoids is that it makes clearer the distinction between the rational and the recognisable series. (b) The reduction theory of series over a free monoid and with coefficients in a (skew) field that leads to a procedure for the decidability of equivalence (with a cubic complexity). (c) As it is natural for series with coefficients in a field, and since the topological machinery is set anyway, the star of series is defined in a slightly more general setting than cycle-free series. (d) The basics for rational relations with multiplicity, for the weighted generalisation of the often called Kleene–Sch¨ utzenberger theorem on transducers as well as of the Myhill theorem (on recognisable sets in a product of monoids) or of McKnight theorem (on the inclusion of recognisable set in rational ones in finitely generated monoids).

Rational and Recognisable Series

107

The core of this chapter pertains to a now classical part of automata theory, originating in the seminal paper of M.P. Sch¨ utzenberger [46] and having been exposed in several treatises already quoted in Chap. 1: Eilenberg [14], Salomaa and Soittola [45], Berstel and Reutenauer [5], and Kuich and Salomaa [29]. I have not resisted though to include some more recent developments which are the result of my own work with my colleagues M.-P. B´eal and S. Lombardy: the derivation of weighted expressions [33], and the connection between conjugacy and equivalence [3, 4]. The presentation given here (but for the last quoted result that is too recent) is adapted from Chaps. III and IV of my book Elements of Automata Theory [43], where missing proofs, detailed examples, and further developments can be found. I am grateful to Reuben Thomas who has translated this book from French to English and to Cambridge University Press for allowing me to use the material for this chapter. Finally, I want to acknowledge the always inspiring discussions I have had in the last 10 years with Sylvain Lombardy.

2 Rational Series and Weighted Rational Expressions In the preceding chapters, the formal power series that have been considered are series over a free monoid with coefficients in a semiring S that is almost always supposed to be complete or continuous, opening the way to straightforward generalisations of results and methods developed for languages, that are series with multiplicity in the Boolean semiring, and classical automata. Our first purpose is to build a theory where no assumptions are made on the semiring of coefficients, and as few as possible on the base monoid. There will be some redundancy with Chaps. 1 and 3, but I have preferred to write a comprehensive text that naturally flows rather than to interrupt it with references to results that are always stated under slightly different hypotheses. In what follows, M is a monoid and S a semiring, a priori arbitrary. 2.1 Series over a Graded Monoid For any set E, the set of maps from E to S is usually written S E and canonically inherits from S a structure of semiring when equipped with pointwise addition and multiplication. When E is a monoid M , we equip S M with another multiplication which derives from the monoid structure of M, and we thus use different notation and terminology for these maps together with this other semiring structure—indeed, the ones set up in Chap. 1, Sect. 3. Any map from M to S is a formal power series over M with coefficients in S—abbreviated as S-series over M , or even as series if there is ambiguity neither on S nor on M . The set of these series is written SM . If r is a

108

Jacques Sakarovitch

series, the image of an element m of M under r is written (r, m) rather than (m)r and is called the coefficient of m in r. The support of a series r is the subset of elements of M whose coefficient in r is not 0S . A series with finite support is a polynomial; the set of polynomials over M with coefficients in S is written SM . For all r and r , and all s in S, the following operations on SM  are defined: (i) The (left and right) ‘exterior’ multiplications 1 : sr

and rs

by ∀m ∈ M

(sr, m) = s(r, m) and (rs, m) = (r, m)s.

(ii) The pointwise addition: r + r

by ∀m ∈ M

(r + r , m) = (r, m) + (r , m).

(iii) The Cauchy product: rr

by ∀m ∈ M

(rr , m) =



(r, u)(r , v).

(∗)

u,v∈M uv=m

Addition makes SM  a commutative monoid, whatever S and M ; together with the two exterior multiplications, it makes SM  a left and right semimodule 2 on S. The Cauchy product raises a problem for there could very well exist elements m in M such that the set of pairs (u, v) satisfying uv = m is infinite, and hence there could exist series such that the sum on the right-hand side of (∗) is not defined. Thus, we cannot ensure, without further assumptions, that the Cauchy product is a binary operation totally defined on SM . This difficulty can be overcome in at least three ways. The first is to retreat: we no longer consider SM  but only the set SM  of polynomials. If r and r are polynomials, the sum in (∗) is infinite but only a finite number of terms are non-zero; the Cauchy product is defined on SM  and makes it indeed a semiring (a semi-algebra on S), a subsemialgebra of SM  when that is defined. The second is to assume that S is complete: every sum, even if infinite, is defined on S, and the Cauchy product of two series is defined for any M . This is the case, for example, if S is equal to B, BM , N∞ , +, · or N∞ , min, +. The theory of finite automata over a free monoid and with multiplicity in a complete semiring has been developed in Chap. 3 of this book. The third way, which is ours, aims at being able to define weighted automata, and hence series, without restriction on S, and we are led in this case 1

Which are called scalar products in Chap. 1. For sake of uniformity in this book, I use the terms ‘semimodule’ and ‘semialgebra’ whereas in [43] and other publications, I follow the convention of Berstel and Reutenauer [5] and speak of ‘module’ and ‘algebra’ (over a semiring).

2

Rational and Recognisable Series

109

to make assumptions about M : we suppose for the rest of this chapter that the monoids are graded, a condition that we shall describe in the next paragraph and which allows the natural generalisation of the standard construction of formal power series of a single variable.3 This somewhat different assumption makes it necessary to restate, and sometimes to reprove again, some of the statements already established when S is complete. 2.1.1 Graded Monoid For the Cauchy product to be always defined on SM , independently of S, it is necessary (and sufficient) that, for all m in M , the set of pairs (u, v) such that uv = m is finite—we will say that m is finitely decomposable. However, making SM  a semiring is not an end in itself: the development of the theory to come is the characterisation of the behaviour of finite automata by means of rational operations—a fundamental theorem—and then not only must sum and product be defined on the series, but so must the star operation, which implies an infinite sum. This forces us to have some sort of topology on SM , to which we shall return in the next paragraph. The construction of series on Σ ∗ , which generalises that of series of one variable, shows that it is from the length of words in Σ ∗ that we build a topology on SΣ ∗ . The existence of an additive length is the main assumption that we shall make about M . Returning to the initial problem, we then seek an additional condition that ensures that every element is finitely decomposable. For reasons of simplicity, we assume that M is finitely generated. This solves the problem, while allowing us to deal with the cases that interest us. Definition 2.1. A function ϕ : M → N is a length on M if: (i) ϕ(m) is strictly positive for all m other than 1M (ii) ∀m, n ∈ M ϕ(mn) ≤ ϕ(m) + ϕ(n) We shall say that a length is a gradation if it is additive; that is, if: (iii) ∀m, n ∈ M ϕ(mn) = ϕ(m) + ϕ(n) and that M is graded if it is equipped with a gradation. Every free monoid and every Cartesian product of free monoids is graded. The definition implies that ϕ(1M ) = 0 and that a finite monoid, more generally a monoid that contains an idempotent other than the identity (for example, a zero), cannot be equipped with a gradation. Proposition 2.2. In a finitely generated graded monoid, the number of elements whose length is less than an arbitrary given integer n is finite. 3

A fourth method exists that takes out of both the first and the third. It involves making an assumption about M (we require it to be an ordered group) and considering only a subset of SM  (those series whose support is well ordered). A reference to that set of series will be made in Sect. 5.3.

110

Jacques Sakarovitch

In other words, every element of a graded monoid M can only be written in a finite number of different ways as the product of elements of M other than 1M . We can deduce in particular the following corollary. Corollary 2.3. In a finitely generated graded monoid, every element is finitely decomposable. Note that a finite monoid is not graded, but that every element in it is nonetheless finitely decomposable. From Corollary 2.3, we deduce the proposition aimed at by Definition 2.1: Proposition 2.4. Let M be a finitely generated graded monoid and S a semiring. Then SM , equipped with the Cauchy product, is a semiring, and what is more, a (left and right) semi-algebra4 on S. In the following, M is a graded monoid that is implicitly assumed to be finitely generated. To simplify the notation and in imitation of the free monoid, we will write the length function as a pair of vertical bars, that is, |m| rather than ϕ(m). From the semiring SM , one then builds other semirings, by means of classical constructions; let us quote in particular and for further reference the following fundamental isomorphism. Lemma 2.5. Let S be a semiring, M a graded monoid, and Q a finite set; then the set of square matrices of dimension Q and with entries in the semiring SM  is a semiring, isomorphic to that of series over M with coefficient in the semiring of square matrices of dimension Q and with entries in S; that is, SM Q×Q ∼ = S Q×Q M . Remark 2.6. A notion that is often considered in relationship with gradation is equidivisibility. A monoid M is equidivisible if whenever mn = pq with m, n, p, and q in M , there exists u such that mu = p and n = uq or m = pu and un = q. There is then a theorem by F.W. Levi which states that a graded equidivisible monoid is free (cf. [30]). This notion is also to be compared with the one of equisubtractivity that is considered below. 2.1.2 Topology on SM  The definition to come of the star operation, an infinite sum, calls for the definition of a topology on SM . Since SM  = S M is the set of maps from M to S, it is naturally equipped with the product topology of the topology on S. If this topology on S is defined by a distance, the product topology on SM  coincides, as M is countable, with the simple convergence topology: If S is a ring, SM  is even what is classically called a graded algebra, which is the origin of the terminology chosen for graded monoids. 4

Rational and Recognisable Series

111

rn converges to r, if and only if, for all m in M , (rn , m) converges to (r, m). We shall reexamine the topology question using only the notion of distance, more in line with intuition and explain how to define a distance between two series under the assumption that M is graded. The foregoing reference to simple convergence topology was nevertheless worthwhile, as it made clear that the basis of the topology on SM  is the topology on S. Distance on SM  A distance on a set E is a map d which relates to every pair (x, y) of elements of E a positive real number d(x, y), called the distance from x to y (or between x and y), which satisfies the following properties: • Symmetry:

d(x, y) = d(y, x)

• Positivity: d(x, y) > 0 if x = y and d(x, x) = 0 • Triangular inequality: d(x, y) ≤ d(x, z) + d(y, z) When this triangular inequality can be replaced by • ∀x, y, z ∈ E

d(x, y) ≤ max{d(x, z), d(y, z)}

the distance d is called ultrametric. A sequence {xn }n∈N of elements of E converges to x if the distance between xn and x becomes arbitrarily small as n grows; that is, more formally, ∀η > 0 ∃N ∈ N ∀n ≥ N

d(xn , x) ≤ η.

Such an element x is unique; it is called the limit of the sequence {xn }n∈N and we write x = limn→+∞ xn , or simply x = lim xn if there is no ambiguity. We say that d equips E with a topology. Remark 2.7. We can always assume that a distance is a real number less than or equal to 1. If that is not the case, then by taking f (x, y) = inf{d(x, y), 1}, we obtain a distance f on E that defines the same topology; that is, a distance for which the same sequences will converge to the same limits. Remark 2.8. Whatever E is, we can choose a trivial distance function which is 1 for every pair of distinct elements. This is equivalent to saying that two distinct elements are never ‘close’ to each other, and that the only convergent sequences are those that are eventually stationary. We then say that E is equipped with the discrete topology.

112

Jacques Sakarovitch

We are confronted with two situations which seem fundamentally different. The first is that of a semiring S such as B, N, Z, N∞ , etc., whose elements are ‘detached’ from each other. The natural topology on these semirings is the discrete topology. The second is that of semirings such as Q, Q+ , R, etc., or even later SM  itself, which can act as a semiring of coefficients for series on another monoid; that is, semirings on which there is a priori a distance which can be arbitrarily small. On these semirings as well, we can choose a discrete topology, but it is more satisfactory to preserve their ‘native’ topology. By means of the definition of a distance and the topological notions derived from it, we treat these two situations in the same way. We first assume that S is equipped with a distance c which is bounded by 1. The length function on M allows us to put an ordering on the elements of M and we set      1 1   |m| = n . max c (r, m), (r , m) d(r, r ) = 2 2n n∈N

We then verify that d is indeed a distance on SM , ultrametric when c is, and that the topology defined on SM  by d is, as stated, the simple convergence topology; that is, the following property. Property 2.9. A sequence {rn }n∈N of series of SM  converges to r, if and only if, for all m in M the sequence of coefficients (rn , m) converges to (r, m). Furthermore, choosing a topology on a semiring only really makes sense if the constituent operations of the semiring, addition and multiplication, are consistent with the topology—we say they are continuous—that is, if the limit of a sum (resp. of a product) is the sum (resp. the product) of the limits. We say in this case that not only is the semiring equipped with a topology, but that it is a topological semiring. We easily verify that if S is topological, then so is SM . In other words, if {rn }n∈N and {rn }n∈N are two convergent sequences of elements of SM , we have lim(rn + rn ) = (lim rn ) + (lim rn )

and

lim(rn rn ) = (lim rn )(lim rn ).

Note that conversely the fact that the sequence {rn + rn }n∈N or {rn rn }n∈N converges says nothing about whether {rn }n∈N or {rn }n∈N converges or not. If S is a topological semiring, then so is S Q×Q and the isomorphism quoted in Lemma 2.5 is moreover a bi-continuous bijection. Summable Families Let T be a semiring5 equipped with a distance which makes it a topological semiring. We thus know precisely what means that an infinite sequence {tn }n∈N 5

We have temporarily changed the symbol we use for a semiring on purpose: T will not only play the role of S but also of SM  in what follows.

Rational and Recognisable Series

113

converges to a limit t when n tends to infinity. We must now give an equally precise meaning to the sum of an infinite family {ti }i∈I and it turns out to be somewhat harder. The difficulty arises from the fact that we want a sort of associativity–commutativity extended ‘to infinity’, and hence to ensure that the result and its existence does not depend on an arbitrary order put on the set I of indices. We shall therefore define an ‘absolute’ method of summability, and a family will be described as ‘summable’ if we can find an increasing sequence of finite sets of indices, a sort of ‘kernels’, such that not only do partial sums on these sets tend to a limit, but above all that any sum on a finite set containing one of these kernels stays close to this limit. More precisely, we take the following definition. Definition 2.10. A family {ti }i∈I of elements of T indexed by an arbitrary set I is called summable if there exists t in T such that, for all positive η, there exists a finite subset Jη of I such that, for all finite subsets L of I which contain Jη , the distance between t and the sum of {ti } for i in L is less than η; that is, ∃t ∈ T, ∀η > 0, ∃Jη finite, Jη ⊂ I, ∀L finite, Jη ⊆ L ⊂ I  ti , t ≤ η. d i∈L

The element t thus defined is unique and is called the sum of the family {ti }i∈I . The sum just defined is obviously equal to the usual sum if I is finite, and we write  t= ti . i∈I

From the definition of a summable family, we easily deduce an associativity property restricted to finite groupings, but that repeats infinitely. Property 2.11. Let {ti }i∈I be a summable family with sum t in T . Let K be a set of indices and {Jk }k∈K a partition of I where all the J k are finite (that is, I = k∈K Jk and the Jk are pairwise disjoint). Set sk = i∈Jk ti for every k in K. Then the family {sk }k∈K is summable with sum t. As in the preceding chapters, we say that a family of series {ri }i∈I is locally finite if for every m in M there is only a finite number of indices i such that (ri , m) is different from 0S . Property 2.12. A locally finite family of power series is summable. This simple property is a good example of what the topological structure placed on SM  imposes and adds. That we can define a sum for a locally

114

Jacques Sakarovitch

finite family of series is trivial: pointwise addition is defined for each m, independently of any assumption about M . To say that the family is summable is to add extra information: it ensures that partial sums converge to the result of pointwise addition. For every series r, the family of series {(r, m)m | m ∈ M }, where m is identified with its characteristic series, is locally finite, and we have  (r, m)m, r= m∈M

which is the usual notation that is thus justified. We also deduce from this notation that SM  is dense in SM . Property 2.12 extends beyond locally finite families and generalises to a proposition which links the summability of a family of series and that of families of coefficients. Property 2.13. A family {ri }i∈I of SM  is summable with sum r if and only if for each m in M , the family {(ri , m)}i∈I of elements of S is summable with sum (r, m). 2.2 Rational Series We are now ready to define the star operation on a series. We must nevertheless introduce here an assumption on the semiring, somehow an axiom of infinite distributivity. After that, the definition of rational series comes easily, the double definition indeed, one as a closure under rational operations and one by means of rational expressions which opens the way to effective computations. 2.2.1 Star of a Series We start by considering the problem in arbitrary semirings and not only in the semirings of series. Let t be an element of a topological semiring T ; it is possible for the family {tn }n∈N to be, or not to be summable. If it is summable, we call its sum the ‘star of t’ and write it t∗ :  tn . t∗ = n∈N ∗

Whether t is defined depends on t, on T , on the distance on T , or on a combination of all these elements. For example, (0T )∗ = 1T is defined for all T ; if T = Q, we have ( 12 )∗ = 2 if Q is equipped with the natural topology, or undefined if the chosen topology is the discrete topology, while 1∗ is not defined in either case. Lemma 2.14. Let T be a topological semiring and t an element of T whose star is defined. We have the double equality t∗ = 1T + tt∗ = 1T + t∗ t.

(1)

Rational and Recognisable Series

115

Proof. We obviously have t≤n = 1T +tt