Rational streams coalgebraically

We study rational streams (over a field) from a coalgebraic perspective. Exploiting the finality of the set of streams, we present an elementary and uniform proof of the equivalence of four notions of representability of rational streams: by finite d…

Authors: J.J.M.M. Rutten

Logical Methods in Computer Science V ol. 4 (3:9) 2008, pp. 1–22 www .lmcs-online.org Submitted Dec. 20, 2007 Published Sep . 19, 2008 RA TIONAL STREAMS CO ALGEBRAICALL Y JAN RUTTE N CWI and VUA, Kruislaan 413, 1098 SJ Amsterdam e-mail addr ess : janr@cwi.nl Abstra ct. W e study r ational streams (ov er a field) from a coalgebraic p erspective. Ex- ploiting the finalit y of the set of strea ms, w e presen t an el ementa ry and uniform proof of the equiv alence of four notions of representabilit y of rational streams: by finite dimensional linear systems; b y finite stream circuits; b y finite w eigh ted stream automata; and by finite dimensional subsystems of the set of streams. 1. Introduction A stream o v er a giv en set A is an infinite sequence of elemen ts o f A . S trea ms are ab ound in b oth mathematics and computer science. Think of limits in mathematics, t ypically defin ed in terms of con v erging sequences, and of T a ylor series of analytical fu ncti ons. In computer science, streams o cc ur in v arious fields suc h as data flow, infi n ite data t yp es, semant ics, formal p o wer series, and fu ncti onal programming. In this pap er, we stud y r ationa l streams (o ver a field). They are w ell-kno wn in m at he- matics, notably system theory , bu t ha v e not receiv ed m uc h atte n tion in computer science. I n con trast, a basic ingredient in any int ro ductory course in the theory of computation is the notion of rational language (also called regular language). Rational languages are a proto- t yp ic al example of a finitely present able data t yp e: a l anguage is rational if and only if it is recognisable b y a fin it e automaton. As w e shall see, rational streams are similarly finitely represen table, in v arious w a ys. More sp ecifically , a stream is rational iff it satisfies one of the follo wing equiv alen t conditions: (a) it is represent able b y a fin ite dimensional linear system; (b) it is computable b y a fi n ite stream c ircuit; (c) it is represent able b y a fin it e weig h ted stream automaton. W e sh all explain the details of all of this as we will go along, bu t for now it is worth wh il e p oin ting out that condition (c) is similar, in the case of languages, to b eing recognisable by a finite auto maton. Condition (b) is particularly nice and relev an t for computer scienti sts, since it pro vides a v ery elemen tary charac terisation of r a tional streams in terms of fi nite memory (registers) a nd feedbac k. 1998 ACM Subje ct Classific ation: F.1.1, G.1.0. Key wor ds and phr ases: streams, coalgebra, coinduction, linear systems, rationalit y , we igh ted automata. This researc h is partially supp orted b y EU pro ject IST-33826 CREDO ( http://credo.cwi .nl ). LOGICAL METHODS l IN COMPUTER SCIENCE DOI:10.216 8/LMCS-4 (3:9) 2008 c  J. Rutten CC  Creative Commons 2 J. RUTTEN Streams are for the th eory of coalge bra, one could sa y , what the natural num b ers are fo r algebra: a canonical example illustrating some of the essen tial notions of the theory . T he set of natural num b ers is an initial alge bra (and satisfies a p rinciple of induction ). Dually , the set of streams is a final coal gebra (and satisfies a p rinciple of c oinduction ). In the presen t p aper, the pro ofs of the equiv alence of the ab o v e three conditions w il l in essence b e based on the fi n ali t y of the set of streams. Finalit y moreov er provides ye t another equiv alen t c haracterisa tion of rationalit y . A stream is rational i f a nd only if (d) it g enerates a finite dimensional sub s y s tem o f the set of all streams. As we s h all see, this criterion is particularly useful for pro ving that a st ream is not rati onal. Most of the ab o v e and of the con ten ts of this pap er is already known, but often at differen t places in the literature and t ypically formulat ed in differen t languages, as it were. The equiv alence of rationalit y and condition (a) ab o ve is tak en as a definition in the theory of formal p ow er series [BR88 ]. The equiv alence of rationali t y and condition (b) is prov ed in system theory and in signal pro cessing, where stream circuits are kn o wn un d er v arious names (such as s ignal flo w graphs ) [Kai80, Lah98]; see also our earlier pap er [Ru t0 7]. Th e equiv alence b et we en (a ) and (c) is kno wn in automata theory . Cond ition (d) occurs in some of our o w n work [Rut05b]; its u s e here to disprov e rational it y of a s tr eam seems to b e new. All i n a ll, o ur mai n g oal has b een to presen t rational streams and all of their charac teri- sations in one plac e and in ele men tary and uniform terms. Moreo v er, this pap er is i n tended as a form of p u blicit y for rational streams to the compu te r science comm unit y . They pro vide a basic and simple mo del of fi nite memory and feedbac k and deserve , therewith, a place in the heart of the foun d at ions of the theory of computing. Finally , our treatmen t of r at ional streams serves as a go o d illustration of the relev ance of the com bined u s e of b oth algebraic and c oalgebraic methods in computer science. 2. Ra tional streams W e define the set of str e ams o v er a giv en set A by A ω = { σ | σ : { 0 , 1 , 2 , . . . } → A } W e will denote elemen ts σ ∈ A ω b y σ = ( σ (0) , σ (1) , σ (2) , . . . ). W e define the str e am derivative of a stream σ by σ ′ = ( σ (1 ) , σ (2) , σ (3) , . . . ) and w e call σ (0) the initial value of σ . F or a ∈ A and σ ∈ A ω w e use the follo w ing notation: a : σ = ( a, σ (0) , σ (1) , σ (2) , . . . ) F or instance, σ = σ (0) : σ ′ , for any σ ∈ A ω . (In computer science, the op erations of initial v alue and deriv ativ e are kno wn as he ad and tail .) If the set A carries some algebraic structur e then t ypically this ind uces some structure on the set A ω as well. In p a rticular, if the s et A is a (semi-)ring A = ( A, + , · , 0 , 1) (see th e App end ix for the full definition) then the set A ω of streams ov er A can b e equipp ed with op erations and consta n ts that allo w the formulatio n of an elemen tary but u seful calculus. RA TIONAL STREAMS COALGEBRAICALL Y 3 So let A b e a (semi-)ring. Examples are the set of real num b ers (which is also a field) and the set of linear transformations on a vec tor sp ace. W e define the follo wing op erators on the set A ω of streams o v er A , for all c ∈ A , σ, τ ∈ A ω , n ≥ 0: [ c ] = ( c, 0 , 0 , 0 , . . . ) (often simply denoted again by c ) X = (0 , 1 , 0 , 0 , 0 , . . . ) ( σ + τ )( n ) = σ ( n ) + τ ( n ) [ sum ] ( σ × τ )( n ) = n X i =0 σ ( i ) · τ ( n − i ) [ convolution product ] (where · denotes m ultiplicatio n in the ring A ). F or the ab o v e definitions, it is already sufficien t if A is a semi -ring. If A is moreo ver a ring then it comes equipp ed with an add it iv e in v erse, which extends to streams, for σ ∈ A ω , as follo ws: − σ = ( − σ (0) , − σ (1) , − σ (2) , . . . ) (here the min us symbols on the righ t are from the rin g A ). If the in it ial v alue σ (0) of a stream σ has a m ultiplicativ e in v erse σ (0) − 1 in A then σ h as a (un iqu e) multiplica tiv e in v erse σ − 1 in A ω : σ − 1 × σ = [1] As us ual, we shall often write 1 /σ f o r σ − 1 . If · and hence × is commutat iv e, then we also write σ /τ for σ × τ − 1 . In general, the n th elemen t σ ( n ) of a stream σ is trivially giv en by σ ( n ) = σ ( n ) (0) where the sup erscript ( n ) den otes the n th stream d eriv ati v e. In [Rut05b], v arious rules for the computation of stream deriv ativ es are giv en. F or the examples used in the present pap er, all w e shall b e needing is the v ery simple rule present ed in Corollary 2.5 b elo w. The stream op erators introduced ab o v e are we ll b eha v ed in that they inh erit the prop er- ties of the op erators of the underlying (semi-)ring. Notably sum and pr o duct are asso cia tiv e; sum is commutat iv e but p rod u ct × is only comm utativ e if · is; [0] is the additiv e identi t y , [1] is the m ultiplicativ e identit y . Another prop ert y we sh a ll b e using is the follo wing. F or all σ ∈ A ω , X × σ = σ × X (2.1) Note that this pr o p ert y also holds for (semi-)rings A in which multi plicatio n is not commu- tativ e. Since X 2 = (0 , 0 , 1 , 0 , 0 , 0 , . . . ), X 3 = (0 , 0 , 0 , 1 , 0 , 0 , 0 , . . . ) and so on, the follo wing infin it e sum is we ll defined, for all σ ∈ A ω : σ = σ (0) + ( σ (1) × X ) + ( σ (2) × X 2 ) + · · · (Note that we write σ ( i ) for [ σ ( i )]; similarly b elo w.) It sho ws that σ can b e view ed as a formal p o w er series in the indeterminate X (whic h h ere in fact is a constan t stream). What distinguishes our appr oa c h from the classical theory of formal p o w er series is a systematic use of the op eration of stream deriv ativ e and the u n iv ersal prop ert y of fin al it y it indu ces (cf. Section 4 ). This leads to a somewhat non-standard algebraic calculus, whic h w e call str e am c alculus . 4 J. RUTTEN The f o llo wing identit y shows how one can compute a stream from its initial v alue and its deriv ativ e. Since this amount s to a form of (stream) inte gr ation it is called the fundamental the or em of str e am c alculus [Ru t0 5b]. Theorem 2.1 (F un damen tal th eorem) . Let A b e a (semi-)ring. F or all σ ∈ A ω , σ = σ (0) + ( X × σ ′ ) Pr o of. Immediate from the fact that X × σ ′ = (0 , σ (1) , σ (2) , σ (3) , . . . ). ✷ F or futu r e reference, w e list the follo wing identiti es on initial v alues, whic h are immediate from the definition of the op erations on streams. Prop osition 2.2 (In itial v alues) . F or all σ ∈ A ω , ( σ + τ )(0) = σ (0) + τ (0) ( σ × τ )(0) = σ (0) · τ (0) σ − 1 (0) = σ (0) − 1 where in the last identit y σ (0) is assumed to hav e a m ultiplicativ e inv erse in A . ✷ Next w e in trod uce the notion of rational stream. Definition 2.3 (Rational streams) . W e call a stream π p olynomial if it is of the form π = c 0 + ( c 1 × X ) + ( c 2 × X 2 ) + · · · + ( c k × X k ) = ( c 0 , c 1 , c 2 , . . . , c k , 0 , 0 , 0 , . . . ) A stream ρ is r ational if it is the quotien t ρ = σ /τ = σ × τ − 1 of tw o p olynomial streams σ and τ for whic h τ (0) − 1 exists. W e denote the set of all r a tional streams o v er A by Rat ( A ω ) = { σ ∈ A ω | σ is rational } ✷ Remark 2.4. In the literature, one also en counters th e notion of r at ional stream defined as b eing ultimately p erio dic . In the present setting, these streams can b e simply c haracterize d as ha ving only fi n ite ly man y distinct d e riv ativ es. As we shall see in Section 5, it follo ws from this basic observ ation that ultimately p eriod ic streams are a sp ecial case of rational streams in our sense. ✷ Theorem 2.1 (together with Prop osition 2.2) giv es an easy calculat ion r ule for the computation of stream deriv ativ es. First note that for all σ ∈ A ω , ( X × σ ) ′ = σ (2.2) F urth erm o re we ha v e, for an y σ ∈ A ω , that X × σ ′ = σ − σ (0), b y Theorem 2.1, and ( X × σ ′ ) ′ = σ ′ , by (2.2). As a consequence, w e hav e the follo wing. Corollary 2.5. F or all σ ∈ A ω , σ ′ = ( σ − σ (0)) ′ ✷ RA TIONAL STREAMS COALGEBRAICALL Y 5 This trivial iden tit y mak es the computation of s tre am d eriv a tiv es often su rprisingly simple. Example 2.6. Let σ = 1 1 − ( c × X ) with c ∈ A . W e compute σ ′ = ( σ − σ (0)) ′ [ Corollary 2.5 ] =  1 1 − ( c × X ) − 1  ′ [ Prop osition 2.2 ] =  c × X 1 − ( c × X )  ′ =  X × c 1 − ( c × X )  ′ [ iden tit y (2 .1) ] = c 1 − ( c × X ) [ iden tit y (2 .2) ] and, more generally , σ ( n ) = c n 1 − ( c × X ) Using the fact th a t σ ( n ) = σ ( n ) (0), this yields the follo w in g w ell-kno wn expression for this protot yp ical example of a r a tional stream: 1 1 − ( c × X ) = (1 , c, c 2 , . . . ) (2.3) Similarly for τ = 1 (1 − X ) 2 one computes τ ′ = ( τ − τ (0)) ′ =  1 (1 − X ) 2 − 1  ′ =  2 X − X 2 (1 − X ) 2  ′ =  X × 2 − X (1 − X ) 2  ′ = 2 − X (1 − X ) 2 and again more generally , τ ( n ) = ( n + 1) − ( n × X ) (1 − X ) 2 leading to 1 (1 − X ) 2 = (1 , 2 , 3 , . . . ) ✷ 6 J. RUTTEN 3. St reams and v ector sp aces Let V b e a vect or sp ac e (o ver a field k ). T he set V ω = { σ | σ : { 0 , 1 , 2 , . . . } → V } of streams o v er V is itself a vec tor space, with addition and scalar multi plicatio n giv en, for n ≥ 0 and c ∈ k , by ( σ + τ )( n ) = σ ( n ) + τ ( n ) ( c · σ )( n ) = c · σ ( n ) where on the right we use ve ctor addition and scalar multi plicatio n in the ve ctor space V . F or future reference, w e denote the op erations of initial v alue and deriv ativ e by i : V ω → V and d : V ω → V ω : for all σ ∈ V ω , i ( σ ) = σ (0) d ( σ ) = σ ′ Prop osition 3.1. The op erations of in itial v alue i : V ω → V and deriv ativ e d : V ω → V ω are linear. Pr o of. Immediate from ( x · σ + y · τ )(0) = x · σ (0) + y · τ (0) ( x · σ + y · τ ) ′ = x · σ ′ + y · τ ′ for all x, y ∈ k and σ, τ ∈ V ω . ✷ 3.1. Strea ms of linear transformations. Next we define streams of linear transformations. T o this end, w e first note that the set L ( V , V ) = { F : V → V | F is a linear transformation } (whic h we sh all u sually denote by L ) is a ring ( L, + L , · L , 0 L , 1 L ) Addition F + L G , multiplic ation F · L G , and negation − L F are defin ed, f or all F , G ∈ L and v ∈ V , by ( F + L G )( v ) = F ( v ) + G ( v ) ( F · L G )( v ) = F ◦ G ( v ) ( − L F )( v ) = − F ( v ) The neutral elemen ts 0 L : V → V and 1 L : V → V for sum and multiplica tion are give n, for all v ∈ V , by 0 L ( v ) = 0 V (the zero v ector in V ) and 1 L ( v ) = v . The s e t L of linear tr ans format ions on a v ector space V b eing a r ing, we ha v e, by the definitions of S ec tion 2, a calculus of streams of linear transformations. Streams φ ∈ L ω are infinite sequences φ = ( φ (0) , φ (1) , φ (2) , . . . ) of linear transformations φ ( i ) : V → V . The op eratio ns of sum and (con v olutio n) pro duct are given, for φ, ψ ∈ L ω , by ( φ + ψ )( n ) = φ ( n ) + L ψ ( n ) ( φ × ψ )( n ) = n X i =0 φ ( i ) · L ψ ( n − i ) = n X i =0 φ ( i ) ◦ ψ ( n − i ) RA TIONAL STREAMS COALGEBRAICALL Y 7 As b efore we also ha v e, for ev ery F ∈ L , a constan t stream [ F ] = ( F, 0 L , 0 L , 0 L , . . . ) In particular w e also ha v e [1 L ] = (1 L , 0 L , 0 L , 0 L , . . . ) whic h we sh al l often simply denote by 1. The constant stream X now lo oks like X = (0 L , 1 L , 0 L , 0 L , 0 L , . . . ) Ev ery stream φ ∈ L ω has an additiv e in v erse − φ giv en, as b efore, by − φ = ( − φ (0) , − φ ( 1) , − φ (2) , . . . ) A stream φ ∈ L ω has a (unique) mult iplicativ e inv erse φ − 1 in L ω : φ − 1 × φ = 1 (= [1 L ] ) whenev er the linear transformation φ (0) : V → V h as a m ultiplicativ e in v erse in the ring L , that is, whenever φ (0) is inv ertible. Example 3.2. F or an y linear transformation F ∈ L , we d efine the stream ˜ F ∈ L ω b y ˜ F = 1 1 − ([ F ] × X ) As b efore, it is a protot yp ic al example of a rational s tr eam. Note that 1 − ([ F ] × X ) = (1 L , − F , 0 L , 0 L , 0 L , . . . ) indeed is in v ertible in L ω as 1 L is trivially in v ertible in L . As an instance of identi t y (2.3) in Example 2.6, w e ha v e ˜ F = 1 1 − ([ F ] × X ) = (1 , F, F 2 , · · · ) (3.1) where no w F n +1 = F ◦ F n , all n ≥ 0. ✷ So far we ha v e lo o k ed at the set L = L ( V , V ) of streams of linear transformations f r om a v ector spav e V to itself. It will also b e conv enien t to consider (streams of ) linear transfor- mations b et ween tw o differen t v ecto r spaces V and W : L ( V , W ) = { F : V → W | F is a linear transformation } Note that L ( V , W ) is not a (semi-)ring — we cannot define m ultiplicatio n to b e comp osition as we did with L ( V , V ) — and as a consequence the set L ( V , W ) ω of streams ov er L ( V , W ) do es not hav e as m uc h structure as the set L ( V , V ) ω . It w il l b e conv enien t, ho w ev er, to u se the follo wing generalised ve rsion of the op eration of con vol ution pro duct. F or vec tor s pace s U, V , W and for all φ ∈ L ( U, V ) ω and ψ ∈ L ( V , W ) ω w e define ψ × φ ∈ L ( U, W ) ω , for all n ≥ 0, b y ( ψ × φ )( n ) = n X i =0 ψ ( i ) ◦ φ ( n − i ) (3.2) One can also app ly streams of linear transformations to streams of v ecto rs, as follo ws. F or all φ ∈ L ( V , W ) ω and σ ∈ V ω w e define φ × σ ∈ W ω , for all n ≥ 0, by ( φ × σ )( n ) = n X i =0 φ ( i ) ( σ ( n − i )) (3.3) 8 J. RUTTEN F or a linear transformation H : V → W , we p ut again [ H ] = ( H, 0 L , 0 L , 0 L , . . . ) (where no w 0 L is the ev erywhere zero transformation from V to W ). As a sp ecial case of (3.3) w e ha v e [ H ] × σ = ( H ( σ (0)) , H ( σ (1)) , H ( σ (2)) , . . . ) Note that the set of s trea ms L ( V , V ) ω has also its o wn op eration of con volutio n pr odu ct, whic h intera cts nicely with the pr o duct defin ed in (3.3). F or instance, for φ, ψ ∈ L ( V , V ) ω and σ ∈ V ω , ( φ × ψ ) × σ = φ × ( ψ × σ ) (3.4) 3.2. Strea ms of matrices. Since linear transform ations b et w een fi nite d ime nsional ve ctor spaces (o v er a field k ) corresp ond to matrices (with en tries in k ), streams of linear trans - formations corresp ond to streams of matrices. Here we s h o w ho w r ational streams of linear transformations corresp ond to matrices with rational streams (o v er k ) as ent ries. First some con v entions. F or any set A and n ≥ 1, w e denote the elements v ∈ A n b y v = ( v 1 , . . . , v n ). It will sometimes b e con v enient to switc h b et ween streams of tuples and tuples of streams. W e defin e the tr ansp ose as f ollo ws: ( − ) T : ( A n ) ω → ( A ω ) n ( σ T ) i ( j ) = ( σ ( j )) i (3.5) This function is an isomorphism and h as an in v erse whic h w e denote again by ( − ) T : ( A ω ) n → ( A n ) ω No w let k b e a field. A linear tr ans format ion F : k n → k m b et wee n finite dimensional v ecto r s pac es corresp onds to an m × n matrix M F with v alues F ij in k : F : k n → k m M F =      F 11 F 12 · · · F 1 n F 21 F 22 · · · F 2 n . . . . . . . . . . . . F m 1 F m 2 · · · F mn      Here and in what follo w s, the matrix is with resp ect to the standard basis (1 , 0 , . . . , 0) , . . . , (0 , . . . , 0 , 1) of k n and k m . Any str eam φ = ( φ (0) , φ (1) , φ (2) , . . . ) of linear transformations φ ( i ) : k n → k m corresp onds to a stream of matrices ( M φ (0) , M φ (1) , M φ (2) , . . . ) = M φ (0) + ( M φ (1) × X ) + ( M φ (2) × X 2 ) + · · · If we consider M φ ( i ) × X i as an m × n matrix obtained from M φ ( i ) b y mult iplying eac h of its en tries by X i , then the infinite s um on the right can itself b e view ed as an m × n matrix M φ with en tries in k ω : ( M φ ) ij = ( M φ (0) ) ij + (( M φ (1) ) ij × X ) + (( M φ (2) ) ij × X 2 ) + · · · (3.6) RA TIONAL STREAMS COALGEBRAICALL Y 9 The corresp ondence b et w een φ and M φ is give n by th e follo wing commutat iv e diagram: ( k n ) ω φ × ( − ) / / ( − ) T   ( k m ) ω ( − ) T   ( k ω ) n M φ × ( − ) / / ( k ω ) m ( φ × σ ) T = M φ × σ T (3.7) Here φ × σ is as d efi n ed in (3.3) and M φ × σ T denotes matrix to v ecto r m ultiplicat ion. Consider L = L ( k n , k n ) and recall th at [1 L ] = (1 L , 0 L , 0 L , 0 L , . . . ). Let I b e the n × n iden tit y matrix o v er k . W e ha v e: M [1 L ] = I (3.8) F urth erm o re addition and con v olution pr oduct of streams of linear transformations, on the one hand, and matrix addition and multiplic ation, on the other, are related as f o llo ws: M φ + ψ = M φ + M ψ M φ × ψ = M φ × M ψ (3.9) As a consequence, w e ha v e the follo w ing prop osition. Prop osition 3.3. Let ρ ∈ L ( k n , k n ) ω b e a stream of linear transform a tions ρ ( i ) : k n → k n . If ρ is rational then M ρ defined in (3.6) has entries in R at ( k ω ). Pro of: Consider tw o p olynomial streams φ, ψ ∈ L ( k n , k n ) ω . The en tries of the matrices M φ and M ψ are p olynomial streams in k ω . If ψ moreo ver has an inv erse ψ − 1 then (3.8 ) and (3.9) imply M ψ − 1 = ( M ψ ) − 1 , wh ic h has v alues in R at ( k ω ). It follo ws that M φ × ψ − 1 = M φ × ( M ψ ) − 1 has v alues in Rat ( k ω ). ✷ Example 3.4. Let k = I R and let F , G : I R 2 → I R 2 b e linear transf orm a tions d efi n ed b y M F =  1 1 0 0  M G =  0 − 1 1 2  W e compute the matrices of the rational streams ˜ F = ( 1 − ( F × X ) ) − 1 and ˜ G = ( 1 − ( G × X ) ) − 1 : M ˜ F = ( M 1 − ( F × X ) ) − 1 =  1 − X − X 0 1  − 1 =  1 1 − X X 1 − X 0 1  M ˜ G = ( M 1 − ( G × X ) ) − 1 =  1 X − X 1 − 2 X  − 1 = 1 (1 − X ) 2 ×  1 − 2 X − X X 1  ✷ 10 J. RUTTEN 4. Linear re present a tions W e in tro duce linear systems and sh ow how they ca n b e used as represent ations for streams. In particular, we shall sho w h o w finite dimensional linear s ys te ms represen t r a- tional streams. Let O b e a v ecto r sp ac e the elemen ts of which w e think of as outputs . A line ar system with output in O is a pair ( V , h H, F i ) consisting of a v ecto r space V cal led the state sp ac e together with a linear transf orm a tion F : V → V called the tr ansition func tion (or d yn amic s) and a linear transformation H : V → O called the output function . A linear system w ith output in O — or linear O -system for short — is in other words a c o algebr a of the functor O × ( − ) : V ect → V ect on the category V ect of vect or spaces and linear transformations. As a consequence, there is the follo wing (standard ) notion of homomorphism. A homomor phism of line ar systems ( V , h H V , F V i ) and ( W, h H W , F W i ) is a linear transformation f : V → W su c h that H W ◦ f = H V and F W ◦ f = f ◦ F V : V f / / h H V ,F V i   W h H W ,F W i   O × V 1 × f / / O × W W e sa w (in Section 3) that if O is a v ector space then O ω is also a v ector space. Since the op eratio ns of initial v alue i : O ω → O and d eriv at iv e d : O ω → O ω are linear tr ans format ions (Prop ositio n 3.1), ( O ω , h d, i i ) is a linear O -system. It is final among all linear O -systems. Prop osition 4.1 (Finalit y) . F rom ev ery linear O -system ( V , h H, F i ) there exists precisely one homomorphism to ( O ω , h i, d i ): V f / / _ _ _ _ _ h H,F i   O ω h i,d i   O × V 1 × f / / O × O ω Pr o of. There exists precisely one function f : V → O ω making the diagram ab o ve comm ute. It is giv en b y f ( v ) = ( H ( v ) , H ◦ F ( v ) , H ◦ F 2 ( v ) , . . . ) for all v ∈ V and it is linear b ecause b oth H and F are. ✷ Definition 4.2 (Linear rep r ese n tatio n) . In the situation ab o v e, we call the stream f ( v ) the final b ehaviour of v . W e call the linear O -system ( V , h H , F i ) with designated p oin t v ∈ V a line ar r epr esentation for the stream σ ∈ O ω if f ( v ) = σ . ✷ Next we lo ok at the sp ecial case where b oth O and V are finite dimensional vect or spaces o ver k . So let n, m ≥ 1, let O = k m , V = k n and consider a linear k m -system ( k n , h H , F i ) w it h dynamics F : k n → k n and output H : k n → k m . The fi nal b eha viour f : k n → ( k m ) ω will map an y state v ∈ k n to a stream of RA TIONAL STREAMS COALGEBRAICALL Y 11 v ecto rs in k m . W e claim that the transp ose of th e latter consists of a ve ctor of m rational streams in k ω . Theorem 4.3. Let n, m ≥ 1 and let ( k n , h H , F i ) b e a finite d imensional k m -system. Let f : k n → ( k m ) ω b e the final b eha viour h o momorphism. T hen for all v ∈ k n , f ( v ) T ∈ Rat ( k ω ) m Pr o of. First we observ e that for ev ery v ∈ V , w e can express f ( v ) in terms of conv olution pro ducts as follo ws: f ( v ) = ( H ( v ) , H ◦ F ( v ) , H ◦ F 2 ( v ) , . . . ) = ( H , 0 , 0 , 0 , . . . ) × (1 , F , F 2 , . . . ) × ( v , 0 , 0 , 0 , . . . ) [ using (3.3) and (3.4) ] = ( H , 0 , 0 , 0 , . . . ) × ˜ F × ( v , 0 , 0 , 0 , . . . ) [ using (3.1) ] = [ H ] × ˜ F × [ v ] By (3.7), the follo wing diagram comm utes: ( k n ) ω ˜ F × ( − ) / / ( − ) T   ( k n ) ω ( − ) T   [ H ] × ( − ) / / ( k m ) ω ( − ) T   ( k ω ) n M ˜ F × ( − ) / / ( k ω ) n M [ H ] × ( − ) / / ( k ω ) m (4.1) or, equiv alen tly , ([ H ] × ˜ F × ( − )) T = M [ H ] × M ˜ F × ( − ) T It f ollo ws that the final b eha viour f satisfies f ( v ) T = ([ H ] × ˜ F × [ v ]) T = M [ H ] × M ˜ F × [ v ] T (4.2) The m at rix M [ H ] has entries in ( k and thus in) R at ( k ω ). Since ˜ F = (1 − ( F × X )) − 1 is a rational stream, the m a trix M ˜ F has v alues in Rat ( k ω ), by Prop osition 3.3. As a consequence, f ( v ) T is obtained from [ v ] T b y m ultiplicatio n with an m × n matrix with v alues in Rat ( k ω ). This prov es the theorem. ✷ Since fi nite dimensional linear systems are finitary ob j e cts (b eing completely determined by t wo finite matrices), the relev ance of T h eo rem 4.3 lies in the fact that it shows that su c h finitary s ys t ems represent (v ecto rs of ) r ational streams. In Section 5, w e will see that an y rational stream can b e repr e sen ted in this mann e r. But first w e lo ok at a few examples illustrating th e present theorem. Example 4.4. Let k = I R and consider the linear system (I R 2 , h H , F i ) with outpu t H : I R 2 → I R and d ynamics F : I R 2 → I R 2 giv en by H =  1 1  F =  1 1 0 0  The matrix M ˜ F corresp onding to ˜ F h as b een computed in Examp le 3.4: M ˜ F =  1 1 − X X 1 − X 0 1  12 J. RUTTEN The final b eha viour f h H,F i : I R 2 → I R ω of this system is giv en, for any ( a, b ) ∈ I R 2 , by f h H,F i ( a, b ) =  1 1  ×  1 1 − X X 1 − X 0 1  ×  a b  = a + b 1 − X (omitting square brac k ets aroun d a and b as usual). Rep eati ng the example with a different output function ¯ H and the same dyn amic s F : ¯ H =  1 2  F =  1 1 0 0  leads to the follo wing fin a l b ehavi our: f h ¯ H ,F i ( a, b ) =  1 1 − X 2 − X 1 − X  ×  a b  = a + 2 b − bX 1 − X ✷ Because linear O -systems are coalg ebras, the general defi niti on of coalge braic equiv alence applies. In conclusion of this section, w e sp ell out this definition toget her with the observ ation that the corresp onding min imization of a system is giv en by (the image und er) the fi nal b eha viour mapp ing. Equiv alence of linear O -systems is defined as follo w s . A relation R ⊆ V × W is called an O -bisimulation b et w een O -systems ( V , h H V , F V i ) and ( W , h H W , F W i ) if for all v ∈ V and w ∈ W : h v , w i ∈ R ⇒  H V ( v ) = H W ( w ) and h F V ( v ) , F W ( w ) i ∈ R W e sa y that v and w are O -e quivalent and write v ∼ O w if there exists an O -bisim u la tion R with h v , w i ∈ R . The fi nal b eha viour f : V → O ω of an O -system ( V , h H V , F V i ) identifies precisely all O -equiv alen t states: v 1 ∼ O v 2 iff f ( v 1 ) = f ( v 2 ), for all v 1 , v 2 ∈ V . (F or the elemen tary pro of, see [Rut05b].) As a consequence, the minimization of an O -system with resp ect to O -equiv alence is giv en by the image of V un d er f , whic h is a s u bsystem f ( V ) ⊆ O ω b ecause f is a homomorph ism. It follo ws that the greatest O -equiv alence on V is giv en by the k ernel k er ( f ). 5. Const r uc ting linear re present a tions Let k b e a field. W e s h o w ho w to constru ct finite-dimensional linear represen tations for (v ectors of ) rational s trea ms in k ω . F or a stream σ ∈ O ω w e consider the smallest subsp ac e of O ω that cont ains σ and is closed under the op eration of stream deriv ativ e, that is, the linear transform ation d : O ω → O ω . This (so-called d -cyclic) v ector space Z σ is the sub space of O ω that is spann ed by the set of v ecto rs giv en by { σ (0) , σ (1) , σ (2) , . . . } (5.1) with σ (0) = σ and σ ( n +1) = d ( σ ( n ) ) = ( σ ( n ) ) ′ . W e can tu rn Z σ in to a linear system b y taking as outpu t fu ncti on and tran s ition fun ction the restrictions of i : O ω → O and d : O ω → O ω to Z σ . T he set in c lusion f : Z σ ⊆ O ω RA TIONAL STREAMS COALGEBRAICALL Y 13 is then a homomorph ism of linear O -systems. By finalit y of ( O ω , h i, d i ), this homomorphism is u nique. I t follo ws that ( Z σ , h i, d i ) with in itial state σ is a min ima l representa tion of σ . In general, the d ime nsion of Z σ will b e infinite. O f sp ecial interest are those σ ∈ O ω for whic h there exists an n ≥ 1 suc h that all of σ = σ (0) through σ ( n − 1) are linearly in depend en t and σ ( n ) = n X i =0 c i × σ ( i ) for some co effici en ts c 0 , . . . , c n − 1 in the base field k of O and O ω . Then Z σ is a vec tor space of dimen s ion n . The linear transformation G : Z σ → Z σ induced by d : O ω → O ω is give n, with resp ect to the (ordered) basis σ (0) , . . . , σ ( n − 1) , by the n × n matrix M G =        0 0 · · · 0 c 0 1 0 · · · 0 c 1 0 1 · · · 0 c 2 . . . . . . . . . . . . . . . 0 0 · · · 1 c n − 1        (This matrix is in fact (a v ariati on of ) the c omp an ion m atrix of the so-called d -order p oly- nomial of σ ; cf. [BM77, Th m.15 , p.339].) The linear transformation H : Z σ → O indu ce d by i : O ω → O is giv en, again w ith resp ect to the b asis σ (0) , . . . , σ ( n − 1) , b y the matrix (of size dim ( O ) × n ) M H =  σ (0) (0) σ (1) (0) σ (2) (0) · · · σ ( n − 1) (0)  Th us w e ha v e obtai ned a linear O -system ( Z σ , h H , G i ) of dimension n . As b efore, the inclusion f : Z σ ⊆ O ω is a homomorphism . Thus f ( τ ) = τ , for all τ ∈ Z σ and ( Z σ , h H , G i ) with σ as initial state is a minimal representat ion of σ . Example 5.1. Let O = I R and consider the stream σ = 1 / (1 − X ) 2 ∈ O ω . Computing the successiv e stream deriv ativ es of σ = σ (0) , u sing Corollary 2.5, giv es σ (1) = 2 − X (1 − X ) 2 σ (2) = 3 − 2 X (1 − X ) 2 = − σ (0) + (2 × σ (1) ) Th us σ (0) and σ (1) form a b asis for Z σ . Because σ (0) (0) = 1 and σ (1) (0) = 2, we h a v e M H =  1 2  M G =  0 − 1 1 2  No w σ is represented b y ( Z σ , h H , G i ), with σ as the initial state. Clearly , I R 2 ∼ = Z σ . Note that this isomorp hism can also b e obtained b y compu ti ng th e final b eha viour f : I R 2 → I R ω of the O -system (I R 2 , h H , G i ), using Theorem 4.3. This giv es, for all ( r 1 , r 2 ) ∈ I R 2 , f ( r 1 , r 2 ) = M H × M ˜ G × ( r 1 , r 2 ) =  1 2  × 1 (1 − X ) 2 ×  1 − 2 X − X X 1  ×  r 1 r 2  (Recall the compu ta tion of M ˜ G from E x amp le 3.4.) As exp ected, we h a v e f (1 , 0) = σ and f (0 , 1) = σ (1) . ✷ 14 J. RUTTEN Example 5.2. Let O = I R 2 and consider the pair ( τ , σ ) ∈ (I R ω ) 2 ∼ = (I R 2 ) ω , with τ = 1 / (1 − 2 X ) and σ = 1 / (1 − X ) 2 . Computing (pairs of ) stream deriv ativ es ( τ , σ ) (1) =  2 1 − 2 X , 2 − X (1 − X ) 2  ( τ , σ ) (2) =  2 2 1 − 2 X , 3 − 2 X (1 − X ) 2  ( τ , σ ) (3) =  2 3 1 − 2 X , 4 − 3 X (1 − X ) 2  = 2 × ( τ , σ ) (0) − 5 × ( τ , σ ) (1) + 4 × ( τ , σ ) (2) w e see that Z ( τ ,σ ) has dimension 3 with H : Z ( τ ,σ ) → I R 2 and G : Z ( τ ,σ ) → Z ( τ ,σ ) giv en by M H =  1 2 4 1 2 3  M G =   0 0 2 1 0 − 5 0 1 4   ✷ Theorem 5.3. L e t k b e a fi eld and let O = k m . A v ector of streams σ ∈ ( k ω ) m is repr e- sen table b y a linear k m -system of finite dimension iff σ ∈ ( Rat ( k ω )) m . Pr o of. F rom left to righ t, this is Theorem 4.3. F or the con verse, it is s u fficie n t to observe that the examples ab o v e generalise to arb itrary ve ctors of rational streams. This is immediate from th e f a ct that for a rational stream σ = ρ/τ , the dimension of Z σ in the constru ct ion ab o ve is b ounded b y the maxim um of the degrees of ρ and τ . ✷ F or s in g le streams, the results of this section can b e summarized as follo ws. Theorem 5.4. Let k b e a field. F or a stream σ ∈ k ω , the follo wing are equiv alent: (1) The stream σ is r a tional: σ = ρ/τ for p olynomial streams ρ and τ (with τ (0) 6 = 0). (2) The stream σ is r e presen table by a linear system of finite dimension. (3) The subsystem Z σ ⊆ ( k ω , h i, d i ) generated by σ has finite d imensio n. ✷ In conclusion of this section, we sh o w that (3) ab o ve can b e con v eniently used to prov e that a stream is not rational. Corollary 5.5. In order to pro v e that a stream σ ∈ k ω is not rational, it su ffice s to sho w that { σ (0) , σ (1) , σ (2) , . . . } ⊆ k ω con tains infin ite ly many linearly indep endent v ectors. ✷ Example 5.6. Consider σ ∈ I R ω giv en by σ = (1 , 1 , 0 , 1 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , . . . ) = 1 + X + X 3 + X 6 + X 10 + X 15 + · · · = ∞ X k =0 X k ( k +1) / 2 RA TIONAL STREAMS COALGEBRAICALL Y 15 The set of stream deriv ativ es of σ con tains the follo wing infinite subset of linea rly indep enden t streams: (1 , . . . ) (0 , 1 , . . . ) (0 , 0 , 1 , . . . ) (0 , 0 , 0 , 1 , . . . ) · · · Th us σ is not r a tional. ✷ 6. St ream ci rcuits W e sa w that rational streams can b e repr esented b y finite dimensional linear s ys t ems. Suc h systems are finitary in that they are determined by (t wo) finite d imensional matrices with v alues in k . In this section, w e show that suc h systems — and as a consequence rational streams — are, equiv alen tly , computed by so-called stream circuits with fi nite memory . Str e am cir cuits (with v alues in a field k ) are d ata flow net w orks that act on streams of inputs and pr oduce streams of outputs. They are bu ilt out of four t yp es of basic gates by means of comp osition, wh ic h amoun ts simply to connecting (single) output ends to (single) input ends. W e in tro d uce these basic gates b elo w, fir s t d esc ribing their single-step b eha viour in terms of inp u t and output v alues (in k ). Next we sh al l describ e their b eha viour in terms of input and output streams (in k ω ). (i) F or a fixed r ∈ k , an r -multiplier x  r / / r · x inputs a v alue x ∈ k at its input en d and outputs th at v alue multiplied with r at its output end. (ii) A r e gister y  x / / is a one-elemen t buffer (or memory cell) con taining as initial v alue an elemen t x ∈ k . Its stepwise compu ta tion consists of the (sim u lta neous) output of the presen t v alue x in th e buffer together with the in p ut of an elemen t y ∈ k , wh ic h b ecomes the new con tents of the buffer:  y / / x (iii) An adder x  + / / x + y y " tak es tw o input v alues at its input ends an d outputs their sum at its output end. Here w e sho w a 2-to-1 add er but more generally we will also u se n -to-1 adders, for n ≥ 2. 16 J. RUTTEN (iv) Lastly a c opier x x  C 0 0 . . x inputs a v alue at its input end and outputs m ultiple copies of it at its output ends. Here we show a 1-to-2 copier but more generally we will also use 1-to- n copiers, for n ≥ 2. Sometimes it w ill b e conv enien t to combine multiplie rs with adders (and similarly copiers). F or in sta nce, x  r 1 + / / ( r 1 · x )+ ( r 2 · y ) y # r 2 m ultiplies its inputs x and y with the v alues r 1 and r 2 and outputs the sum of the r esu lt s. The presence of memory (in the form of registers) makes that the b ehavi our of stream circuits cannot b e d e scrib ed simply in terms of fu nctio ns of single input and output v alues in k . (This is r eflec ted in our explanations ab o v e by the fact that we needed two pictures to illustrate the b eha viour of a register.) Rather w e shall describ e th e b eha viour of our circuits in terms of str e ams of inp uts and outputs. As it turns out, all w e need are th e basic op erations of stream calculus: (i) An r -m u lt iplier con v erts a stream of inpu ts σ ∈ k ω σ  r / / [ r ] × σ in to a stream of outputs [ r ] × σ b y element wise m ultiplying the input v alues w it h r : [ r ] × σ = ( r · σ (0) , r · σ (1) , r · σ (2 ) , . . . ) (ii) A r eg ister with initial v alue x ∈ k tak es a stream of inpu ts σ σ  x / / [ x ]+ ( X × σ ) (6.1) and outputs it with one step dela y , after ha ving output the initial v alue x fi rst: [ x ]+ ( X × σ ) = ( x, σ (0) , σ (1) , . . . ) (iii) An adder tak es tw o input streams σ and τ σ  + / / σ + τ τ ! and outputs th e stream consisting of their elemen t w ise add it ion: σ + τ = ( σ (0) + τ (0) , σ (1) + τ (1) , σ (2) + τ (2) , . . . ) (iv) The copier simply copies inp ut s tre ams int o output streams: σ σ  C 0 0 . . σ RA TIONAL STREAMS COALGEBRAICALL Y 17 Com binations of multipliers and add ers (and similarly copiers) ha v e the exp ected stream b eha viour: σ  r 1 + / / ([ r 1 ] × σ )+ ([ r 2 ] × τ ) τ # r 2 No w that w e hav e seen the basic gates and their b eha viour, let u s lo ok at comp osite stream circuits and see how their b eha viour can b e compu ted from that of the gates from whic h they are made. Consider the follo wing circuit, built out of tw o registers, t wo copiers, three add ers, and six multipliers (tw o of w hic h are com b ined with the adder at the b ottom): ◦  +   ◦  ◦  +   ◦  ◦ _ r 1   ◦ _ r 2   ◦ _ ◦ _ ◦ _ 0 O O C o o / /   ◦ A 1 M M ◦ } − 1 Q Q C o o / /   ◦ _ 2 O O ◦  1 +   ◦  2 In the picture ab o v e, w e use ◦ to d enote the comp osition of an outpu t end with an inpu t end. The circuit as a whole h a s no external inp u t ends and one external outpu t end. The heart of the circuit consists of t w o registers with initial v alues r 1 and r 2 . The outputs of the registers are copied and: (a) fed bac k to the input ends of the registers, via mult ipliers whose v alues can b e ex- pressed by the follo wing 2 × 2 matrix: M =  0 − 1 1 2  This leads to new v alues of the r egisters give n by  0 − 1 1 2   r 1 r 2  =  − r 2 r 1 + 2 r 2  (b) A t the same time, the outputs of the registers are fed f orward in to an adder com bin ed with m ultipliers whose v alues are giv en by the follo wing matrix: N =  1 2  This leads to a (first) output v alue giv en by  1 2   r 1 r 2  = r 1 + 2 r 2 18 J. RUTTEN W e call th is a circuit in c anonic al form . More generally , we h a v e the follo w in g d efinitio n. Definition 6.1. W e sa y that a stream circuit is in c anonic al form if it h a s n o input ends and one output end; consists of n ≥ 1 registers with feedback lines giv en by an n × n matrix; and has feedforw ard lines giv en by an 1 × n m atrix leading via an n -t o-1 adder to a single output end. ✷ In the d e scription of the example circuit ab o v e, (a) and (b) together describe one single atomic computation step of the circuit. Next w e d e scrib e the stream b eha viour of our example canonical circuit. As we shall see, the output end of a canonical stream circuit pro duces precisely one (rational) stream. In ord er to compute this output stream, w e first giv e names ( σ an d τ ) to the s t reams that will o ccur at the output ends of th e tw o registers. Then we apply the stream equations for eac h of the basic gates in the circuit, leading to: 0  +   − τ  σ  +   2 τ  − τ _ r 1   σ + 2 τ _ r 2   σ _ τ _ σ _ 0 O O C o o / /   σ 9 1 I I τ  − 1 U U C o o / /   τ _ 2 O O σ  1 +   τ  2 σ + 2 τ Applying the register la w (6.1) to our tw o registers then leads to the follo wing t w o equations (writing r for [ r ] as usual): σ = r 1 + ( X × − τ ) τ = r 2 + ( X × ( σ + 2 τ )) or, equiv alen tly , in m at rix notation:  σ τ  =  r 1 r 2  + X ×  0 − 1 1 2  ×  σ τ  whence  1 X − X 1 − 2 X  ×  σ τ  =  r 1 r 2  This leads to the follo w ing v alues for σ and τ :  σ τ  =  1 X − X 1 − 2 X  − 1 ×  r 1 r 2  RA TIONAL STREAMS COALGEBRAICALL Y 19 (recall that this inv erse matrix was computed in Example 3.4). As a consequence the output stream of the circuit is giv en by σ + 2 τ =  1 2  ×  1 X − X 1 − 2 X  − 1 ×  r 1 r 2  (6.2) W e saw that the ab o ve circuit is fully determined by the t wo matrices M and N conta ining the v alues of the (feedbac k and feedforward) m ultipliers. A s such, the circuit corresp onds precisely to a linear system ( k 2 , h H , G i ) with G : k 2 → k 2 and H : k 2 → k giv en by G ( r 1 , r 2 ) = M ×  r 1 r 2  H ( r 1 , r 2 ) = N ×  r 1 r 2  A state of this linear system corresp onds to the con ten ts of the t w o registers of the circuit; G ( r 1 , r 2 ) corresp onds to the feedbac k multi plication with the matrix M ; and the output giv en b y H ( r 1 , r 2 ) corresp onds to th e feed-forw ard multiplica tion with th e matrix N . Note that the stream b eha viour of our circuit as describ ed ab o ve corresp onds precisely with the (fin al) b eha viour of the corresp onding linear systems, as giv en b y (the pro of of ) Theorem 4.3 in Section 4. Th is follo ws from the fact that id en tit y (6.2) equals σ + 2 τ =  1 2  ×  1 X − X 1 − 2 X  − 1 ×  r 1 r 2  = M [ H ] × M ˜ G ×  r 1 r 2  with H and G as defin ed ab o ve. Summarizing, w e ha ve presente d an example of a canonical stream circuit and sho wn that ho w to compute the (rational) stream that it pr oduces at its output end . Th en we observe d that suc h a ca nonical stream circuit co rresp onds precisely to a finite dimensional linear system via its t wo matrices of feedbac k and feedforward m ultipliers. Moreo v er, the str eam b eha viour of the circuit coincides with that of the linear system. In conclusion of this section, we note that one can construct, conv ersely , from any finite dimensional linear sys t em ( V , h H , G i ) a corresp onding canonical stream circuit with exactly the same str eam b eha viour: the d imension of V determines the num b er of r eg isters; the matrix corresp onding to G d et ermines the v alues of the feedbac k multipliers; and the matrix corresp onding to H determines the v alues of the feedforward lines. All in all, we ha v e prov ed the follo wing. Theorem 6.2. Let k b e a field. F or σ ∈ k ω , the follo wing are equiv alent: (1) The stream σ is r e presen table by a linear system of finite dimension. (2) The stream σ is compu t able b y a finite stream circuit. ✷ 7. We i ghted stream automa t a W e sa w that rational streams are “finite memory”: they can b e compu te d by stream circuits with finitely many registers. In this section, w e sh o w they are also “fin it e state”: they can b e computed by fin ite s o-called weigh ted stream au tomata. A weighte d str e am automaton with v alues in a fi eld k is a p ai r ( Q, h o, t i ) consisting of a set Q of states, together with an output fu nctio n o : Q → k and a transition fun ct ion 20 J. RUTTEN t : Q → ( Q → k ). The outp u t fun ct ion o assigns to eac h state q ∈ Q a v alue o ( q ) ∈ k called the output of q . Th e transitio n f u nctio n t assigns to eac h state q ∈ Q a function t ( q ) : Q → k , whic h sp ecifies for an y state q ′ ∈ Q a v alue t ( q )( q ′ ) ∈ k . T his n um b er can b e though t of as the weight with whic h the transition from q to q ′ o cc urs. (There are v arious p ossible in terpretatio ns of this notion of w eigh t, su c h as the cost, multi plicit y , duration etc. of the transition.) W e will u se the follo wing notation: q r / / q ′ ≡ t ( q )( q ′ ) = r , q r ⇒ ≡ o ( q ) = r W eigh ted stream automata r e presen t streams in k ω in the follo w ing manner. Definition 7.1. F or a state q ∈ Q of a wei gh ted stream automaton ( Q, h o, t i ) we define a stream S ( q ), for all k ≥ 0, b y S ( q )( k ) = X { l 0 × l 1 × · · · × l k − 1 × l | ∃ q 0 , . . . , q k : q = q 0 l 0 / / q 1 l 1 / / · · · l k − 1 / / q k l ⇒ } (Here × denotes mult iplicatio n in the field k .) So the k th v alue of the stream S ( q ) is obtained by considering all transition paths of length k starting in the state q ; multiplying for eac h suc h path th e lab els of all transitions; and adding up the resulting v alues for all paths. W e say that the stream S ( q ) is r epr esente d by the state q . Example 7.2. Consider the follo w ing example of a we igh ted automaton: q 1 1 ) ) @A GF 0 ED   1   q 2 − 1 i i BC ED 2 GF   2   Computing the streams S ( q 1 ) and S ( q 2 ) according to Definition 7.1 ab o v e giv es S ( q 1 ) = (1 , 2 , 3 , . . . ) , S ( q 2 ) = (2 , 3 , 4 , . . . ) ✷ W e can repr esent all information con tained in the definition of we igh ted stream automata by t wo m atrices, in v ery muc h the same wa y as we could define stream cir cuits by t w o matrices as well. T o this end, we d efine for a w eigh ted stream automaton ( Q, h o, t i ), with states { q 1 , . . . , q n } , an output matrix L and a transition matrix K as follo ws: L i = o ( q i ) , K ij = t ( q i )( q j ) No w we can compute the streams r epresen ted by the states of a w eigh ted automaton directly in terms of these matrices. Illustrating this for the example automaton ab o ve, w e ha v e L =  1 2  K =  0 1 − 1 2  Applying Theorem 2.1 to the (v ector of ) streams σ = S ( q 1 ) , τ = S ( q 2 ) w e obtain  σ τ  =  σ (0) τ (0)  + X ×  σ ′ τ ′  RA TIONAL STREAMS COALGEBRAICALL Y 21 Note that it follo ws from Definition 7.1 that  σ (0) τ (0)  = L and  σ ′ τ ′  = K ×  σ τ  As a consequence, w e find  σ τ  =  1 2  + X ×  0 1 − 1 2  ×  σ τ  whic h leads to  σ τ  =  1 − X X 1 − 2 X  − 1 ×  1 2  = 1 (1 − X ) 2 ×  1 − 2 X X − X 1  ×  1 2  It f ollo ws that S ( q 1 ) = σ = 1 (1 − X ) 2 , S ( q 2 ) = τ = 2 − X (1 − X ) 2 sho wing that the streams represented by our w eigh ted automato n are rational. All of the ab o ve generalises directly to arbitrary weig h ted automata and so w e ha v e prov ed one half of the follo w in g theorem. Theorem 7.3. A stream σ ∈ k ω is rational iff it can b e represen ted by a s t ate q ∈ Q of a finite weigh ted stream automata ( Q, h o, t i ) with v alues in k . Pr o of. The implication fr om righ t to left follo w s from the ab o ve . F or th e con v erse, consider a rational stream σ ∈ k ω . It follo ws from Theorem 5.4 that σ is representa ble b y a linear system of finite d ime nsion ( k n , h H , F i ) with output in k . Without loss of generalit y we can assume that σ is r epresen ted by the ve ctor (1 , 0 , . . . , 0) ∈ k n . W e defin e Q = { q 1 , . . . , q n } by q 1 = (1 , 0 , . . . , 0) , . . . , q n = (0 , . . . , 0 , 1) Next w e define a w eigh ted stream automaton ( Q, h o, t i ) by putting, for all 1 ≤ i, j ≤ n , o ( q i ) = H i , t ( q i )( q j ) = F T ij = F j i It f ollo ws that σ = S ( q 1 ), that is, σ is r e presen ted by the state q 1 in ( Q, h o, t i ). ✷ 8. Su mmar y and discuss ion All in all, we ha v e prov ed the follo wing. Theorem 8.1. Let k b e a field. F or a stream σ ∈ k ω , the follo wing are equiv alent: (1) The stream σ is r a tional: σ = ρ/τ for p olynomial streams ρ and τ (with τ (0) 6 = 0). (2) The stream σ is r e presen table by a linear system of finite dimension. (3) The subsystem Z σ ⊆ ( k ω , h i, d i ) generated by σ has finite d imensio n. (4) The stream σ is compu t able b y a finite stream circuit. (5) The stream σ is r e presen table by a fi nite wei gh ted s tr eam automaton. ✷ 22 J. RUTTEN W e men tion a few examples of the man y in teresting questions and directions that remain to b e explored. Streams o v er a finite field enjoy man y sp ecial p r operties. A sp ecial example is the f a mily of bitstreams, w h ic h consist of 0’s and 1’s. The int erpla y b et wee n coalgebraic tec hn iqu es and v arious algebraic structures on bitstreams, suc h as the Boolean and the 2-adic op erato rs, deserv es further stud y , w h ic h m a y also b e relev an t f o r the constructio n and analysis of digital circuits; see [Rut05a, HCR06] for some preliminary results. Th ere is also muc h and in teresting life b eyo nd rationalit y . F or instance, it w ould b e worth while to try and apply coinductiv e tec hniques to the study of so-called automatic sequences, see for instance [AS03]. Another example is the com bined u se of linear systems theory and coalgebra in the wo rld of h ybrid systems, where discrete time and contin uous time p henomena o ccur sim ultaneously . The relationship b et wee n rational streams and ω -regular infinite wo rds from formal language theory is y et another sub ject that deserves fu rther study . Referenc es [AS03] J.-P . Allouc he and J. Shallit. A utomat ic se quenc es: the ory, applic ations, gener alizations . Cambridge Universit y Press, 2003. [BM77] G. Birkhoff and S . MacLane. A survey of mo dern algebr a (4th e di t ion) . MacMilla n Publishing Co., Inc., 1977 . [BR88] J. Berstel and C. R eutenauer. R ational series and their languag es , volume 12 of EA TCS Mono gr aphs on The or etic al Computer Scienc e . Springer-V erlag, 1988 . [HCR06] H. Hansen, D. Costa, and J.J.M.M. Rutten. Synthesis of Mealy machines using deriv atives. In Pr o- c e e dings of CMCS 2006 , volume 164(1) of ENTCS , pages 27–45. Elsevier Science Publishers, 2006. [Kai80] T. Kailath. Li ne ar systems . Prentice-Hall, 1980 . [Lah98] B.P . Lah ti. Signal Pr o c essing & Line ar Systems . Ox f ord Universi ty Press, 1998. [Rut05a] J.J.M.M. R utten. Algebra, bitstreams, and circuits. In Pr o c e e dings of the Dr esden Confer enc e 2004 (AAA68) , volume 16 of Contributions to Gener al Algebr a , pages 231–250 . V erlag Johannes Heyn, 2005. [Rut05b] J.J.M. M. R utten. A coindu ctive calculus of streams. Mathematic al Structur es in Computer Scienc e , 15:93– 147, 2005. [Rut07] J.J.M.M. Rutten. Coal gebraic foundations of linear systems. In T. Mossak o wski, U. Mon tanari, and M. Hav eraaen, editors, Pr o c e e di ng s of CALCO 2007 , volume 4624 of LNCS , pages 425–446. Springer- V erlag, 20 07. Ac knowledgmen ts : This pap er, as we ll as an earlier v ersion of it, h as b een review ed by anon ymous referees. I am ve ry grateful for the many constructiv e commen ts these referees ha v e made. They ha v e imp ro v ed b oth the present ation of the pap er and my und ersta nding of its con ten ts. Appendix A. A semi-ring A = ( A, + , · , 0 , 1) is a set A with a comm u ta tiv e op eration of add ition c + d ; a (generally non-comm utativ e) op eration of multi plicatio n c · d with c · ( d + e ) = ( c · d ) + ( c · e ) and ( d + e ) · c = ( d · c ) + ( e · c ); and with neutral elemen ts 0 and 1 suc h that c + 0 = c , 1 · c = c · 1 = c and c · 0 = 0 · c = 0. If every c ∈ A moreo ver has an additiv e inv erse − c (with c + ( − c ) = 0) then A is a ring . If m oreo v er multiplica tion is commuta tiv e and eve ry (non-zero) elemen t c ∈ A h as a m ultiplicativ e inv erse c − 1 (with c · c − 1 = 1) then A is a field . This wor k is licensed und er the Creative Commons Attribution-NoDe rivs License. T o view a copy of this l icense, visit http://reativ e om mon s. or g/ li e nse s/ by -n d/ 2.0 / or sen d a letter

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment