Appeared in: ICALP’03, c Springer Lecture Notes in Computer Science, vol. 2719, pages 426-438. Skew and infinitary formal power

Manfred Droste and Dietrich Kuske⋆

Institut f¨ur , Technische Universit¨at Dresden, D-01062 Dresden, Germany {droste,kuske}@math.tu-dresden.de

Abstract. We investigate finite-state systems with costs. Departing from classi- cal theory, in this paper the cost of an action does not only depend on the state of the system, but also on the time when it is executed. We first characterize the terminating behaviors of such systems in terms of rational formal . This generalizes a classical result of Sch¨utzenberger. Using the previous results, we also deal with nonterminating behaviors and their costs. This includes an extension of the B¨uchi-acceptance condition from finite automata to weighted automata and provides a characterization of these nonter- minating behaviors in terms of ω-rational . This generalizes a classical theorem of B¨uchi.

1 Introduction

In automata theory, Kleene’s fundamental theorem [17] on the coincidence of regular and rational languages has been extended in several directions. Sch¨utzenberger [26] showed that the formal power series (cost functions) associated with weighted finite automata over words and an arbitrary for the weights, are precisely the rational formal power series. Weighted automata have recently received much interest due to their applications in image compression (Culik II and Kari [6], Hafner [14], Katritzke [16], Jiang, Litow and de Vel [15]) and in speech-to-text processing (Mohri [20], [21], Buchsbaum, Giancarlo and Westbrook [4]). On the other hand, B¨uchi [3] extended Kleene’s result to languages of infinite words, showing that finite automata recognize precisely the ω-rational languages. This result stimulated a huge amount of more recent research on automata acting on various infi- nite structures, and B¨uchi-automata are used for formal verification of reactive systems with infinite processes. For theoretical background on formal power series, we refer the reader to [25,19,1,18], and for background on automata on infinite words to [27,23]. In this paper, we wish to extend B¨uchi’s and Sch¨utzenberger’s approaches to weigh- ted automata on infinite words. Whereas Sch¨utzenberger’s result for automata on finite words works for weights taken in an arbitrary semiring, it is clear that for weighted automata on infinite words questions of summability and convergence arise. There- fore we assume that the weights are taken in the non-negative real numbers, endowed with maximum and addition as operations. This max-plus semiring of real numbers is fundamental in max-plus algebra and algebraic optimization (Gaubert and Plus [13], Cuninghame-Green [7]), and related also occurred in other investigations on

⋆ This work was done while the second author worked at the University of Leicester.

1 formal power series (e.g., [18,8,9]). We note that a different approach of weighted au- tomata acting on infinite words has been considered before in connection with digital image processing by Culik and Karhum¨aki [5]. We will introduce the concept of automata acting on infinite words and with weights in the real max-plus semiring. Their behaviour is described by the associating to each word the cost the automaton needs for evaluating it. However, here the arising infinite sums of weights of the transitions in an infinite computation usu- ally diverge. In order to enforce their convergence, we introduce a deflation parameter q ∈ [0, 1). That is, we assume that in a computation sequence, the cost of a later tran- sition is decreased by multiplication with a power of q. This is a usual mathematical procedure in order to obtain convergence of series. It even enables one to compare their “rate of former divergence”. Moreover, here somewhat surprisingly it also reflects the usual human evaluation practices in which later events are considered less urgent and carry less weight than close events. Note that multiplication with a nonnegative real constitutes an of the max-plus semiring. Therefore we derive, as our first new result, a generalization of Sch¨utzenberger’s classical result on automata on finite words, where the weights are taken in an arbitrary semiring, but now changed along computation by a given endomorphism. In fact, we show that also under this notion several different concepts of automata inves- tigated before in the literature again coincide. If the endomorphism is the identity, we obtain Sch¨utzenberger’s theorem as a particular case. This result is of independent in- terest, since such skew multiplications have been considered in the area of Ore series in difference and differential algebra, cf. [22,12,11,2]. We prove analogues of classical preservation theorems for homomorphisms between different alphabets or semirings. We also show that when considering the max-plus semiring and multiplication with reals as , then different numbers yield indeed different collections of recognizable series. Then we turn to automata on infinite words with weights in the real max-plus semir- ing as described above. The ω-recognizable series are those which can be obtained as the behaviour of a finite weighted automaton acting on infinite words. We define ratio- nal operations on series over infinite words like sum and skew product, Kleene iteration and ω-iteration. The ω- then are those which can be obtained by these operations from the . Our second main result states that ω-recognizable and ω-rational formal power series over the real max-plus semiring with deflation parameter q coincide, for each q ∈ [0, 1). We show that from this one can obtain B¨uchi’s classical result on the coinci- dence of ω-recognizable and ω-rational languages as a consequence. This is essentially due to the fact that the Boolean semiring can be naturally embedded into the (idempo- tent) max-plus semiring. Due to length restrictions, many proofs had to be omitted from this extended ab- stract, the interested reader is referred to the technical report [10] for a complete ver- sion. For a recent study on B¨uchi-automatawith weights in bounded distributive lattices, see [24].

2 2 Weighted automata

First let us recall some background on semirings; see also [25,19,1,18]. A structure (K, ⊕, ⊙, 0, 1) is a semiring if (K, ⊕, 0) is a commutative , (K, ⊙, 1) is a monoid, ⊙ is both left- and right-distributive over ⊕, and 0⊙x = x⊙0= 0 for any x ∈ K. If no confusion can arise, we will denote a semiring just by K. Important examples include – the natural numbers (N, +, ·, 0, 1) with the usual addition and multiplication, – the Boolean semiring B = ({0, 1}, ∨, ∧, 0, 1), – the tropical semiring Rmax = (R≥0 ∪ {−∞}, max, +, −∞, 0) (that is also known as max-plus semiring) with R≥0 = [0, ∞) and −∞+x = −∞ for each x ∈ Rmax. Observe that in this semiring −∞ acts as zero, i.e., neutrally with respect to max, and 0 as one, i.e., neutral with respect to +.

A mapping ϕ : K1 → K2 between two semirings K1 and K2 is called homomor- phism if ϕ(x ⊕ y)= ϕ(x) ⊕ ϕ(y) and ϕ(x ⊙ y)= ϕ(x) ⊙ ϕ(y) for all x, y ∈ K1, and ϕ(0) = 0 and ϕ(1) = 1. A homomorphism ϕ : K → K is an endomorphism of K. In the following, (K, ⊕, ⊙, 0, 1) will always denote a semiring and ϕ : K → K an endomorphism of this semiring. We next define weighted automata. The underlying idea is to provide the transitions of a finite automaton with costs in the semiring K. For later purposes, we include ε- transitions. In order that costs for words are well defined, we have to assume that the ε-transitions do not form any loop. So let A be an alphabet and A = (Q,T, in, out) where – Q is a finite of states, – T ⊆ Q × (A ∪{ε}) × K × Q is a finite set of transitions, – in, out : Q → K are cost functions for entering and leaving the system. ∗ A path is a word P = t1t2 ...tn ∈ T with ti = (qi,ai, xi, qi+1). Its label is the ∗ w word w = a1a2 ...an ∈ A . Then we write P : q1 →A qn+1 to denote that P is a w-labeled path from q1 to qn+1. We call A a weighted automaton with ε-transitions provided there is no nonempty ε-labeled path P : q → q for any state q ∈ Q, and A is called a weighted automaton if T ⊆ Q × A × K × Q. ∗ The running cost rcost(P ) of the path P = t1t2 ...tn ∈ T is defined inductively: rcost(ε)=1 x ⊙ ϕ(rcost(P )) if a 6= ε rcost((q1, a, x, q2)P )= (x ⊙ rcost(P ) otherwise. If the path P is labeled by w, its cost is given by

|w| cost(P ) = in(q1) ⊙ rcost(P ) ⊙ ϕ (out(qn+1)) Let w ∈ A∗ be some word. Since our automata do not have ε-loops, there are only finitely many paths labeled by w. The behavior ||A|| of the weighted automaton with ε-transitions A is the mapping ||A|| : A∗ → K defined by

(||A||, w)= {cost(P ) | P is a path with label w} X 3 for w ∈ A∗. Note that the sum on the right is finite. If it is empty, then (||A||, w)=0. In the sequel, we will use the term formal power series (series or FPS for short) for mappings S : A∗ → K.

Definition 2.1. A series S : A∗ → K is called ϕ-recognizable if there exists a weighted ∗ automaton A with ||A|| = S. By Recϕ(A ), we denote the set of all series that are ϕ- recognizable.

If the endomorphism ϕ is understood from the context, we will simply speak of recognizable functions. First we claim that weighted automata have the same computa- tional power as weighted automata with ε-transitions.

Lemma 2.2. Let A be a weighted automaton with ε-transitions. Then there exists a weighted automaton A′ such that ||A|| = ||A′|| and, for any transitions (q,a,x,r) and (q,a,y,r) of A′, one has x = y.

Next we show that ϕ-recognizability of a series can also be described algebraically by representations, similarly to the classical case (with ϕ = id), cf. [1]. Let n ∈ N and (Kn×n, ⊙) be the monoid of (n × n)-matrices over the semiring K (with the usual multiplication). We extend ϕ to an endomorphism ϕ of Kn×n by n×n ∗ setting (ϕ(B))ij = ϕ(bij ) for each matrix B ∈ K . We call a mapping µ : A → Kn×n a ϕ-morphism if µ(ε) = E (the matrix) and for all words u, v ∈ A∗, we have µ(uv) = µ(u) ⊙ ϕ|u|(µ(v)). We call a triple (in, µ, out) a representation of the weighted automaton A and of the series ||A|| if µ : A∗ → Kn×n is a ϕ-morphism, in ∈ K1×n a row and out ∈ Kn×1 a column vector of size n such that (||A||, w) = in ⊙ µ(w) ⊙ ϕ|w|(out) for w ∈ A∗ where ϕ(out) is the vector defined by applying ϕ to each coordinate of out. Now let A = (Q,T, in, out) be a weighted automaton with Q = {1, 2,...,n}. We define a ϕ-morphism µ : A∗ → Kn×n by letting (for any w ∈ A∗ and i, j ∈ Q)

µ(w)ij = rcost(P ). w PX:i→j Considering in as a (1×n)-row vector and out as (n×1)-column vector, one can show that (in, µ, out) is a representation of A. Conversely, let µ : A∗ → Kn×n be a ϕ-morphism, in ∈ K1×n, and out ∈ Kn×1. Let Q be the set {1, 2,...,n} and define T ⊆ Q×A×K ×Q by putting (i,a,x,j) ∈ T iff (µ(a))ij = x. Then A = (Q,T, in, out) is a weighted automaton and (in, µ, out) is a representation of A. Thus we obtain

Proposition 2.3. Let S : A∗ → K. Then S is ϕ-recognizable iff there is a representa- tion of S.

3 Finitary formal power series

Recall that (K, ⊕, ⊙, 0, 1) is a semiring and ϕ is an endomorphism of this semiring. On ∗ the set KA of series S : A∗ → K, we define the operation ⊕ pointwise: (S ⊕ T, w)=

4 (S, w) ⊕ (T, w). The ϕ-skew product of formal power series is defined by

|u| (S ⊙ϕ T, w)= (S,u) ⊙ ϕ (T, v). ∗ u,v∈A uvX=w Note that this is the well studied in case ϕ is the identity on K. The ∗ A ∗ ∗ structure (K , ⊕, ⊙ϕ, 0, 1) is denoted by Kϕ hhA ii (here, (0, w)=0 for w ∈ A , (1, w)=0 for w ∈ A+, and (1,ε)=1). With this definition, tedious but straightfor- ward calculations show

∗ Lemma 3.1. The structure Kϕ hhA ii is a semiring, the semiring of skew formal power series.

∗ Since our definition of ⊙ϕ involves the “skew parameter” ϕ, the semiring Kϕ hhA ii deviates strongly from the semiring of classical formal power series over any semiring: for u ∈ A∗ and x ∈ K, let xu denote the power series with (xu, w)=0 for w 6= u and (xu,u)= x. Then, for a ∈ A and y ∈ K, the Cauchy product satisfies 1a ⊙ yε = ya = yε ⊙ 1a, but for the skew product, we have 1a ⊙ϕ yε = ϕ(y)a and yε ⊙ϕ 1a = ya. n n−1 0 ∗ For a series S, let S = S ⊙ϕ S with S = 1. Then, for w ∈ A ,

n |u1u2...ui−1| ∗ (S , w)= ϕ (S,ui) | ui ∈ A , w = u1u2 ...un . (i=1...n ) X Y The series S is quasiregular provided (S,ε)=0. In this case, we define

(S+, w)= (Sn, w) 1≤Xn≤|w| for w ∈ A+ and (S+,ε)=0. Furthermore, S∗ = S+ ⊕ 1 for S quasiregular.

∗ Definition 3.2. Let Ratϕ(A ) denote the least class of formal power series that con- tains the monomials xu for x ∈ K and u ∈ A ∪{ε} and is closed under the operations + ∗ ⊕, ⊙ϕ, and (applied to quasiregular formal power series). The series in Ratϕ(A ) are called ϕ-rational.

∗ For ϕ the identity, the set Ratϕ(A ) consists of those formal power series that are ∗ classically termed “rational”. In this case, Sch¨utzenberger showed that Ratϕ(A ) = ∗ Recϕ(A ). We will indicate how to prove this fact for arbitrary endomorphisms. + Let E be a term over the signature (⊕, ⊙ϕ, ) with constants of the form xa for x ∈ K and a ∈ A ∪{ε}. The evaluation ||E|| is defined canonically in the semiring ∗ + Kϕ hhA ii. The term E is a rational expression if the operation is only applied to subexpressions whose value is a quasiregular formal power series. Let Exp denote the set of all rational expressions. It is obvious that they give rise precisely to the rational formal power series. Let Q be a finite set of states, T ⊆ Q × Exp × Q a finite set of transitions, ι ∈ Q an ∗ initial state, and F ⊆ Q a set of accepting states. The label ||P || ∈ Kϕ hhA ii of a path

5 P is defined inductively by ||ε|| = 1 and ||(i,E,j)P || = ||E|| ⊙ϕ ||P ||. The quadruple A = (Q,T,ι,F ) is called a generalized weighted automaton provided the label of any nonempty path P : q → q is quasiregular for any q ∈ Q. The behavior of the generalized weighted automaton is the formal power series given by

(||A||, w)= {(||P ||, w) 6=0 | P : ι → F is a path}

(here we write P : ι → F Xto denote that the path P leads from the initial state ι to some accepting state in F .) Note that, due to our assumption on the label of loops, this is well defined since, for any w ∈ A∗, there are only finitely many paths P in A with (||P ||, w) 6= 0. Such automata have been investigated for the case ϕ = id before, e.g., by Kuich and Salomaa [19]. The depth of a rational expression is defined in the obvious way:

depth(xa)=0, depth(E+) = 1 + depth(E), and ′ ′ ′ depth(E ⊙ϕ E ) = depth(E ⊕ E ) = 1 + max(depth(E), depth(E ))

Let A be a generalized weighted automaton. Since T is finite, there is a rational expression occurring in a transition of A that has maximal depth; its depth is the depth of A. Finally, the breadth of a generalized weighted automaton measures how often its depth is realised: breadth(A) = |{(i,E,j) ∈ T | depth(E) = depth(A)}|. Since T is finite, this is always a finite number.

Lemma 3.3. Let S be a ϕ-rational formal power series. Then S is ϕ-recognizable.

Proof. Let A be a generalized weighted automaton and let (i,E,j) be an edge of max- imal depth. If the depth of E is 0, then any edge in A is labeled by a constant (i.e., by a monomial over a letter or the empty word). We can easily define a weighted automaton with ε-transitions A′ with the same behavior. By Lemma 2.2, we can dispense of the ε-transitions of this automaton, hence the formal power series ||A|| is ϕ-recognizable. If the depth of E is positive, then E is of one of the forms E1 ⊕ E2, E1 ⊙ϕ E2, + or E1 . In each of these cases, we can replace the edge (i,E,j) by some other edges whose labels are among E1, E2, and 1ε. Hence the breadth (if it was at least 2) or the depth (otherwise) has decreased which allows us to proceed by induction. ⊓⊔

A weighted automaton A = ({1, 2,...,n}, T, in, out) is called normalized provided

1 if i =1 1 if i =2 1. in(i)= and out(i)= (0 otherwise (0 otherwise. 2. Furthermore, in T , there are no transitions of the form (i, a, x, 1) or (2,a,x,i). Lemma 3.4. Let S be a ϕ-recognizable formal power series. Then there exists a nor- malized weighted automaton A with (||A||, w) = (S, w) for w ∈ A+ and (||A||,ε)=0. Thus, in the proof of the following lemma, we can start from a normalized weighted automaton that we consider as a generalized weighted automaton. Inductively, the tran- sitions of this generalized weighted automaton get collapsed until, finally, just one is left whose label is the desired rational expression.

6 Lemma 3.5. Let S be a ϕ-recognizable formal power series. Then S is ϕ-rational. Altogether, we have obtained: Theorem 3.6. Let K be a semiring and ϕ an endomorphismof K. Let A be an alphabet and let S : A∗ → K be a formal power series. Then the following are equivalent: 1. S is ϕ-recognized by a weighted automaton with ε-transitions. 2. S is ϕ-recognized by a weighted automaton. 3. S is ϕ-recognized by a generalized weighted automaton. 4. S is ϕ-rational. 5. S has a representation.

4 Preservation properties

In analogy to classical results on formal power series [25,1,19], here we show that also in our setting certain homomorphisms h : A∗ → B∗ and also homomorphisms between semirings define transformations of series which preserve rationality resp. recognizabil- ity of the series. Such a homomorphism h is called length-preserving if |h(u)| = |u| for any u ∈ A∗, and h is finite-to-one, if h−1(w) is finite for any w ∈ B∗. An endo- morphism ϕ of K is idempotent if ϕ ◦ ϕ = ϕ. Theorem 4.1. Let h : A∗ → B∗ be a monoid homomorphism. Assume that either h is length-preserving or that h is finite-to-one and ϕ is idempotent. Then the mapping ∗ ∗ h : Kϕ hhA ii → Kϕ hhB ii defined by

(h(S), w)= (S, v) ∗ v∈A h(Xv)=w

∗ ∗ for S ∈ Kϕ hhA ii and w ∈ B is a semiring homomorphism. Furthermore, for any ∗ ϕ-rational S ∈ Kϕ hhA ii, the series h(S) is ϕ-rational. We can also consider homomorphisms of the underlying semiring: Theorem 4.2. Let α : (K, ϕ) → (K′, ψ) be a homomorphism (i.e., α is a semiring homomorphism that commutes with the endomorphisms ϕ and ψ: α ◦ ϕ = ψ ◦ α). ∗ ′ ∗ Then α˜ : Kϕ hhA ii → Kψ hhA ii defined by (˜α(S), w) = α(S, w) is a semiring homomorphism that preserves rationality of formal power series. As a consequence of Theorems 4.1, 4.2 and 3.6, h and α˜ also preserve the recog- nizability of formal power series. For a formal power series S, let the support supp(S) denote the set of words w with (S, w) 6=0. Corollary 4.3. Let K be a semiring such that x ⊙ y =0 or x ⊕ y =0 implies x =0 or y =0. Let ϕ be an endomorphism of K with ϕ−1(0) = {0}. Let S be a ϕ-recognizable formal power series. Then supp(S) ⊆ A∗ is a regular word language. Proof. Our assumptions on the semiring K allow us to define a semiring homomor- phism α from K onto the Boolean semiring with α(x)=0 iff x =0. Then the previous theorem yields the result. ⊓⊔

7 5 Weighted automata over the semiring Rmax

In this section, we will consider the semiring K = Rmax. It is our aim to compare the ∗ sets Recϕ(A ) for different endomorphisms ϕ of Rmax. For q ∈ R≥0, let q · (−∞)= −∞. Then the mapping x 7→ q · x is a semiring endomorphism of Rmax. Conversely, ∗ all endomorphisms of Rmax are of this form. We will write Recq(A ) and ⊙q whenever we refer to the endomorphism given by multiplication with q.

∗ ∗ Lemma 5.1. Let S ∈ Recq(A ), x ∈ Rmax, w ∈ A , and p,q > 0. Then xw ⊙p S ∈ ∗ Recq(A ).

∗ ∗ Thus, the set Recp(A )∩Recq(A ) is closed under skew multiplication by a mono- ∗ ∗ mial from the left. The following lemma prepares the proof that Recp(A ) ∩ Recq(A ) is not closed under skew multiplication with a monomial from the right. It also shows ∗ ∗ that the sets Recp(A ) and Recq(A ) are incomparable for distinct and positive p and q. ∗ For a word language L ⊆ A , let 1L denote the function of L. Lemma 5.2. Let p,q > 0 be distinct. Let furthermore σ ∈ A. 1. If q 6= 1, then the series S with (S, σn) = n and supp(S) = σ∗ is 1- but not q-recognizable. 2. If p 6=1, then the series Tp = 1σ∗ ⊙p 1ε is p- but not q-recognizable. This lemma is shown using pumping arguments in weighted automata. For the sec- ond statement, we deal with the possible order relations between p, q, and 1 separately. Summarizing, we get the following

∗ ∗ Theorem 5.3. Let p 6= q be . Then Recp(A ) and Recq(A ) are ∗ ∗ incomparable. Furthermore, the intersection Recp(A ) ∩ Recq(A )

– contains all monomials and characteristic series 1L for regular word languages L, – is closed under finite summation and contains xw ⊙r S for xw a monomial, S ∈ ∗ ∗ Recp(A ) ∩ Recq(A ), and r> 0, and ∗ – does not necessarily contain S ⊙r xw for xw a monomial, S ∈ Recp(A ) ∩ ∗ Recq(A ) and r 6=1 positive.

∗ ∗ Let p 6= q be positive real numbers. Then Recp(A ) ∩ Recq(A ) contains all mono- mials, certain characteristic series, and satisfies the above closure properties. We con- jecture that it is the least set of formal power series having these properties. If this is ∗ ∗ ∗ indeed the case, then Recp(A ) ∩ Recq(A )= r>0 Recr(A ). T 6 Weighted Buchi-Automata¨ over Rmax

In this section, we will consider non-terminating executions of a weighted automaton. For these considerations, we restrict the parameter q to values satisfying 0 ≤ q< 1. However, first we recall the classical definition of a Buchi-automaton¨ :it is a quadru- ple A = (Q,T,I,F,F∞) with Q a finite set, T ⊆ Q × A × Q and I,F,F∞ ⊆ Q.A finite word w ∈ A∗ is accepted by A if it is accepted in the usual way by the automaton

8 (Q,T,I,F ). An infinite word w ∈ Aω is accepted by A if there exists a w-labeled path P in A which starts in some state from I and passes infinitely often through F∞. The set of all words in A∞ accepted by A is denoted by L∞(A). A language L ⊆ A∞ is Buchi-recognizable¨ if there exists a B¨uchi-automaton A with L = L∞(A). Now we generalize this concept to weighted B¨uchi-automata.

Definition 6.1. A weighted B¨uchi-automaton is a tuple A = (Q,T, in, out, out∞) such that (Q,T, in, out) and (Q,T, in, out∞) are weighted automata with weights in Rmax. For a finite word w ∈ A∗, we define (||A||, w) = (||(Q,T, in, out)||, w). For an infinite path P = (pi,ai, xi,pi+1)i∈N let P ↾n denote the prefix of P of length n. Then the cost of P is defined by

n cost(P ) = lim sup{in(p1) + rcost(P ↾n)+ q out∞(pn+1) | n ∈ N} and the behavior of A at infinite words w is given by

(||A||, w) = sup{cost(P ) | P is a path labeled by w}

∞ Definition 6.2. A mapping S : A → Rmax is q-B¨uchi-recognizable if there exists a ∗ weighted Buchi-automaton¨ A with ||A|| = S. By ω−Recq(A ), we denote the set of all functions that are q-Buchi-recognizable.¨ Culik II and Karhum¨aki [5] used another definition of the behavior of a weighted automaton on infinite words: for T : A∗ → R ∪ {−∞, ∞} define another function −→ ∞ −→ T : A → R ∪ {−∞, ∞} by ( T , w) = lim sup (T, w↾n) for w infinite and −→ n→∞ ( T , w) = −∞ for w finite.1 For a weighted automaton, they define the behavior at −−→ infinity |A| by |A| = ||A||. Therefore, the behavior according to their definition is −∞ at finite words. Let A = {a,b} and

−∞ if w ∈ A∗ or w contains infinitely many bs S, w ( )= ∗ ω (0 if w ∈ A a Then one can construct a weighted B¨uchi-automaton A with ||A|| = S. On the other −→ hand, there is no function T : A∗ → R whose limit T is S (the proof is analogous −→max to the proof that A∗aω is not the limit L of any subset L of A∗, cf. [23]). Let A be a deterministic automaton and let L ⊆ A+ be the language accepted −→ by A. If we consider A as a B¨uchi-automaton, it accepts the language L . A similar fact can be shown for weighted automata, where a weighted automaton is deterministic if (i,a,x,j), (i,a,y,k) ∈ T imply x = y and j = k. The following slightly more general lemma imposes restrictions on the number of paths with a given label. Furthermore, we have to assume the automaton to be complete: for any state i and any letter a, there is an edge (i,a,x,j) for some weight x ≥ 0 and some state j.2

1 Actually, Culik II and Karhum¨aki work in the semiring (R, +, ·, 0, 1), but the idea of their definition is captured by this formula. 2 These conditions are required by our proof, we are not sure whether they can be relaxed.

9 Lemma 6.3. Let A = (Q,T, in, out) be a complete weighted automaton and let A′ = (Q,T, in, −∞, out) with −∞(i)= −∞ for each i ∈ Q. If for any infinite word w there are only finitely many w-labeled paths P in A with cost(P ) ≥ 0, then |A| = ||A′||.

Recall that the class of ω-rational languages in A∞ is the smallest class of languages that contains all singletons and is closed under the operations union, product, Kleene- iteration and ω-iteration (the latter two applied to languages in A∗). Now we define the corresponding notions in our context. ∞ A mapping S : A → Rmax = K is an infinitary formal power series; the set of all ∞ infinitary formal power series is denoted by Kq hhA ii. Any (finitary) formal power series S can be considered as an infinitary formal power series by setting (S, w)= −∞ for w ∈ Aω. The operation max can naturally be extended to infinitary formal power series. The sum +q of a finitary FPS S and an infinitary FPS T is defined by

|u| (S +q T, w) = sup ((S,u)+ q (T, v)). uv=w∗ u∈A

If S and T are both finitary, then this is precisely the operation ⊙q we considered so far. The formal difference in the definition is the replacement of max by sup. This has no effect for w finite since in that case we consider only the supremum of a finite set. If w is infinite, the set {(S,u)+ q|u|(T, v) | u ∈ A∗, uv = w} can be infinite; hence we consider its supremum.

Note that for a sequence of elements xi ∈ K, the sum i∈N xi equals −∞ when- ever there is i ∈ N with xi = −∞. If this is not the case, then the sum can well be +∞, i.e., it need not be defined within the semiring K. Formally,P we define for a quasiregular finitary formal power series S its ω-iteration by

ω |u1u2...ui−1| ∗ (S , w) = sup q (S,ui) | ui ∈ A , w = u1u2 . . . (i N ) X∈ ω ω ∗ ω for w ∈ A and (S , w) = −∞ for w ∈ A . In general, S +q T and S can take the ω ∞ value +∞ 6∈ Rmax, i.e., in general S +q T,S 6∈ Kq hhA ii. Suppose S and T are bounded, i.e., there is some b ∈ R with (S, w) ≤ b for any w ∈ A∗ and similarly for T . |u| |u1u2...ui−1| b ∗ Then (S,u)+ q (T, v) ≤ 2b and i∈N q (S,ui) ≤ 1−q for any ui ∈ A . Thus, for bounded finitary FPS, we have S + T,Sω ∈ K hhA∞ii and rational finitary P q q FPS are bounded. Hence the following definition makes sense:

∗ Definition 6.4. Let ω−Ratq(A ) denote the least class of infinitary FPS that contains the monomials xu for x ∈ K and u ∈ A ∪{ε} and is closed under the operations max, + ω +q, and (the latter two applied to quasiregular finitary formal power series).

Lemma 6.5. Let S be an ω-rational infinitary formal power series. Then S is ω-recog- nizable.

Proof. Recall that any ω-rational language can be written as a finite union of ω-lan- guages of the form U · V ω with U, V ⊆ A∗ regular. One can prove this fact using the

10 characterization of ω-rational languages by B¨uchi-automata or finite syntactic . An alternative proof is by induction on the ω-rational construction of the ω-language; ω this second proof generalizes to our situation yielding S = max(T, max{Ti +q Ui | ∗ 1 ≤ i ≤ n}) for some n ∈ N and T,Ti,Ui ∈ Ratq(A ) such that Ti and Ui are quasiregular (1 ≤ i ≤ n). Then one shows that any infinitary formal power series of ω the form Ti +q Ui is ω-recognizable (which uses Lemma 3.3). Combining the B¨uchi- automata for these series yields an automaton for S. ⊓⊔

The converse implication is provided by the following

Lemma 6.6. Let S be an ω-recognizable infinitary formal power series. Then S is ω- rational.

Proof. One first shows that S is the behavior of a weighted B¨uchi-automaton A = (Q,T, in, out, out∞) with out∞(i) ∈{0, −∞} for i ∈ Q. The finitary part of ||A|| is rational. To show the same for the infinitary part, one considers automata Ast that differ from A only in the costs for entering and leaving the system:

st in(k) if s = k st out∞(k) if t = k in (k)= and out∞(k)= (−∞ otherwise (−∞ otherwise

st Then ||A|| = maxs,t∈Q ||A ||. Changing the costs for entering and leaving the system st appropriately once more, one defines two weighted automata A1 and A2 from A st ω satisfying ||A || = ||A1|| +q ||A2|| . ⊓⊔

Thus, we obtain the following characterization of ω-recognizable formal power se- ries:

∞ Theorem 6.7. Let 0 ≤ q < 1 and U : A → Rmax. Then U is ω-recognizable iff it is ω-rational.

To formally derive the classical B¨uchi-result for ω-languages, one first shows that ∞ for any L ⊆ A , we have that L is B¨uchi-recognizable (ω-rational, resp.) iff 1L ∈ ∗ ∗ ω−Recq(A ) (1L ∈ ω−Ratq(A ), resp.). Together with Theorem 6.7, this implies

Corollary 6.8. Let L ⊆ A∞. Then L is Buchi-recognizable¨ iff L is ω-rational.

References

1. J. Berstel and C. Reutenauer. Rational Series and Their Languages. EATCS Monographs. Springer Verlag, 1988. 2. M. Bronstein and M. Petkovsek. An introduction to pseudo-. Theoret. Comp. Science, 157:3–33, 1996. 3. J.R. B¨uchi. Weak second-order arithmetic and finite automata. Z. Math. Logik Grundlagen Math., 6:66–92, 1960. 4. A. Buchsbaum, R. Giancarlo, and J. Westbrook. On the determinization of weighted finite automata. Siam J. Comput., 30:1502–1531, 2000.

11 5. K. Culik II and J. Karhum¨aki. Finite automata computing real functions. SIAM J. of Com- puting, pages 789–814, 1994. 6. K. Culik II and J. Kari. Image compression using weighted finite automata. Computer & Graphics, 17:305–313, 1993. 7. R.A. Cuninghame-Green. Minimax algebra and applications. Advances in Imaging and Electron Physics, 90:1–121, 1995. 8. M. Droste and P. Gastin. The Kleene-Sch¨utzenberger theorem for formal power series in partially commuting variables. Information and Computation, 153:47–80, 1999. 9. M. Droste and P. Gastin. On aperiodic and star-free formal power series in partially commut- ing variables. In Formal Power Series and Algebraic (Moscow, 2000), pages 158–169. Springer, 2000. 10. M. Droste and D. Kuske. Skew and infinitary formal power series. Technical Report 2001-38, Department of Mathematics and Computer Science, University of Leicester, 2002. www.math.tu-dresden.de/˜kuske/. 11. A. Galligo. Some algorithmic questions on ideals of differential operators. In Proc. EURO- CAL ’85, vol. 2, Lecture Notes in Comp. Science vol. 204, pages 413–421. Springer, 1985. 12. S. Gaubert. Rational series over dioids and discrete event systems. In Proceedings of the 11th Int. Conf. on Analysis and Optimization of Systems: Discrete Event Systems, Sophia Antipolis, 1994, Lecture Notes in Control and Information Sciences vol. 199. Springer, 1994. 13. S. Gaubert and M. Plus. Methods and applications of (max, +) linear algebra. Technical Report 3088, INRIA, Rocquencourt, January 1997. 14. U. Hafner. Low Bit-Rate Image and Video Coding with Weighted Finite Automata. PhD thesis, Universit¨at W¨urzburg, Germany, 1999. 15. Z. Jiang, B. Litow, and O. de Vel. Similarity enrichment in image compression through weighted finite automata. In COCOON 2000, Lecture Notes in Comp. Science vol. 1858, pages 447–456. Springer, 2000. 16. F. Katritzke. Refinements of data compression using weighted finite automata. PhD thesis, Universit¨at Siegen, Germany, 2001. 17. S.E. Kleene. Representation of events in nerve nets and finite automata. In Automata Studies, pages 3–42. Princeton University Press, Princeton, N.J., 1956. 18. W. Kuich. Semirings and formal power series: Their relevance to formal languages and automata. In Handbook of Formal Languages Vol. 1, chapter 9, pages 609–677. Springer, 1997. 19. W. Kuich and S. Salomaa. Semirings, Automata, Languages. Springer, 1986. 20. M. Mohri. Finite-state transducers in language and speech processing. Computational Lin- guistics, 23:269–311, 1997. 21. M. Mohri, F. Pereira, and M. Riley. The design principles of a weighted finite-state transducer library. Theoretical Comp. Science, 231:17–32, 2000. 22. O. Ore. Theory of non-commutative . Annals Math., 34:480–508, 1933. 23. D. Perrin and J.-E. Pin. Infinite words. Technical report, 1999. Book in preparation. 24. U. P¨uschmann. Zu Kostenfunktionen von B¨uchi-Automaten. Diploma thesis, TU Dresden, 2003. 25. A. Salomaa and M. Soittola. Automata-Theoretic Aspects of Formal Power Series. EATCS Texts and Monographs in Computer Science. Springer, 1978. 26. M.P. Sch¨utzenberger. On the definition of a family of automata. Inf. Control, 4:245–270, 1961. 27. W. Thomas. Automata on infinite objects. In J. van Leeuwen, editor, Handbook of Theoreti- cal Computer Science, pages 133–191. Elsevier Science Publ. B.V., 1990.

12