#A6 INTEGERS 11B (2011) DEGREES OF STREAMS Jörg Endrullis1 Department of Computer Science, VU University Amsterdam, Amsterdam, The Netherlands j.endrullis@vu.nl Dimitri Hendriks2 Department of Computer Science, VU University Amsterdam, Amsterdam, The Netherlands r.d.a.hendriks@vu.nl Jan Willem Klop Department of Computer Science, VU University Amsterdam, Amsterdam, The Netherlands j.w.klop@vu.nl Received: 10/18/10 , Revised: 4/4/11, Accepted: 7/14/11, Published: 12/2/11 Abstract We introduce a novel approach to comparing the complexity of streams, namely in terms of reducibility by finite state transducers. This gives rise to a hierarchy of stream ‘degrees,’ somewhat analogous to the recursion-theoretic degrees of unsolvability. It is the structure and properties of this partial order of degrees that we are primarily interested in. Remarkably, in spite of its simplicity, the main idea of this approach seems to have remained unexplored. 1. Introduction Streams (one-sided infinite sequences of symbols) arise in several fields, ranging from formal language theory and mathematics (dynamical systems [21], fractal theory [34], number theory [36]) to physics. Streams can be compared as to their complexity in some measure, e.g., subword complexity [15] or Kolmogorov complexity [28], but we can also consider how they can be transformed into each other. The latter is also the foundation of the recursion 1 Author supported by the Netherlands Organisation for Scientific Research (NWO) in project A Term Rewriting Perspective on Program Termination, grant number 639.021.020. 2 Author supported by the Netherlands Organisation for Scientific Research (NWO) in project Lazy Productivity grant number 612.000.934. 2 INTEGERS: 11B (2011) theoretic degrees of unsolvability [38] that classify the intrinsic ‘difficulty’ of a set of natural numbers. Here sets of natural numbers are transformed into one another via a general algorithm (Turing machine). Another analogous hierarchy is that of Wadge degrees, an important notion in mathematical logic with implications for computational complexity, see [30]. Here subsets of spaces like the space of all 01-streams (the Cantor space) are transformed into one another using continuous functions. We propose a novel approach to comparing stream complexity, employing finite state transducers (FSTs) to transform one stream into the other; if also a backtransformation is possible, the streams are deemed equivalent. This gives rise to a partial order, a hierarchy of degrees, that we refer to as the FST-hierarchy. The concept of finite automata and regular languages is a well-studied subject in formal language theory. Also finite state transducers for infinite words have gained attention. For example, in [2, Theorem 7.9.1] it has been shown that ‘morphic streams’ are closed under FSTs. For a general reference to these well-known notions, we refer to [2]. An FST is a finite automaton with output. More precisely, an FST has pairs of input letters a ∈ Σ and output words w ∈ Σ∗ along the edges. When applied to a finite or infinite word w, the output of an FST is the concatenation of the output words encountered along the edges when reading w (in Section 5 we give the formal definition). Figure 1 depicts an FST that computes the difference of consecutive bits (the starting state is q0 ). When applied to the well-known Thue–Morse sequence M, the transducer produces the period doubling sequence PD (below we state its proper definition): M = 0110100110010110 . . . PD = 1011101010111011 . . . q1 0|ε q0 0|1 1|ε 0|0 1|1 q2 1|0 Figure 1: From Thue–Morse (M) to the period doubling sequence (PD). We write σ # τ to denote that there exists an FST that transduces the stream σ to the stream τ . Then we easily have that reducibility # is reflexive and transitive, and hence we can define " = # ∩ % as a notion of equivalence between streams where % is the converse of #. The equivalence classes we call degrees. 3 INTEGERS: 11B (2011) sup? descending sequence of degrees M " ? PD "? Π S ascending sequence of degrees prime degree 0 ultimately periodic streams Figure 2: Uncountable partial order of stream degrees. The darker, countable part consists of morphic degrees. The Thue–Morse sequence M and the period doubling sequence PD are in the same degree. Is this a prime degree like Π ? What about the Sierpiński stream S (see Section 2 )? Is S convertible with M ? The relation # induces a partial order on the degrees. The ensuing hierarchy of degrees is sketched in Figure 2. The structure of the FST-hierarchy, as we call it, is much finer than that of the recursion-theoretic hierarchy where all computable streams are identified. For example, the Thue–Morse sequence M is no longer identified with the trivial stream of zeros 00000 . . .. We have already seen M # PD, and a simple exercise shows that the converse direction PD # M holds as well. For this reason, we have M " PD, that is, M belongs to the same degree as PD. It is this partial order of degrees that we are primarily interested in. See Figure 2 which also summarizes our main results. The bottom degree 0 is formed by the ultimately periodic streams, that is, all streams σ of the form σ = τ υυυ . . . for finite τ , υ. An interesting notion that suggests itself is that of a prime degree: a stream σ is prime if there exists no stream τ whose degree is strictly intermediate between that of σ and the bottom degree 0. Thus the prime degrees reduce only to 0 or themselves. An example of a prime stream is: Π = 1101001000100001000001 . . . Intuitively, the information content of this stream is ‘indestructible’: whatever FST is applied on Π, either the result is ultimately periodic, standing for trivial information, the 0 degree, or there is enough structure left for an FST to reconstruct INTEGERS: 11B (2011) 4 the original stream. We briefly mention some initial results on the hierarchy (Section 6 contains the proofs): (i) There exist prime streams; thus the hierarchy is not dense. (ii) The hierarchy is not well-founded: there exist infinite descending chains. (iii) There are no maximal degrees: for each degree a strictly larger one can be constructed. Hence there exist infinite ascending chains. (iv) For every pair of streams σ, τ there exists a stream υ majorizing σ and τ . However, we conjecture that not every pair of streams has a supremum as argued in Section 6.5. (v) Ultimate recurrence is preserved under transduction. Let us motivate our interest in this specific hierarchy. There are various possibilities to fine-tune the recursion theoretic hierarchy. For example, one can take the (minimal) size of the programs into account for performing a certain transformation, arriving at a notion of ‘relative’ Kolmogorov complexity. Another possibility is to alter the computational model employed for transforming one stream into another. We propose the use of finite state transducers, but clearly other choices like pushdown automata would be possible as well. Our motivation for advocating the FST-hierarchy is that it has interesting properties from the perspective of infinite patterns. In a slogan one could say: The hierarchy arising from finite state transducers classifies streams by a notion of degree that codifies their intrinsic, invariant infinite pattern. With ‘intrinsic, invariant infinite pattern’ we mean a notion of pattern that is invariant under the insertion, removal or alteration of arbitrary finite parts of an infinite sequence. For instance, Kolmogorov complexity does not have this property; see further Section 4 for a comparison with alternative approaches. Another reason for investigating the FST-hierarchy is the exceptional simplicity and beauty of FSTs, as well as their ubiquitous presence in computer science. Related Work In [4] Belov studies Mealy machines and the hiearchy of streams induced by those machines. A Mealy machine (MM) is an FST with the restriction that for every input letter precisely one output letter is produced. We briefly compare the FST and MM-hierarchies. 5 INTEGERS: 11B (2011) The hierarchies have a number of properties in common, to wit: the degree 0 of ultimately periodic streams is their least element, and both hierarchies contain infinite chains and antichains. As to their differences: For the FST-hierarchy it suffices to consider a binary alphabet (Lemma 14), whereas for the MM-hierarchy it is crucial to have alphabets of unbounded size. In the FST-hierarchy there exist prime degrees (Section 6.2), whereas in the MM-hierarchy every stream σ $∈ 0 admits an infinite descending chain. In the MM-hierarchy suprema always exist while we conjecture that this does not hold for the FST-hierarchy. As argued above FST-equivalence is a natural choice for a notion of stream comparison invariant under removal and insertion of finitely many elements. For instance, every stream x = x0 x1 x2 . . . is FST-equivalent to its tail (shift) tail(x) = x1 x2 . . . . However, using Mealy machines, one can only transduce tail(x) to x; the reverse direction works only for ultimately periodic streams. 2. Defining Streams by Infinitary Term Rewriting For defining streams and operations on them, we like to use the unifying framework of term rewriting [42]. Term rewriting not only brings a uniform notation, but also offers a framework for evaluation with a guarantee of unicity. In previous work [18, 17] we have been interested in definability of streams by means of fixed point equations in a certain restricted format (PSF, pure stream format), restricted enough to guarantee decidability of productivity, a constructive notion of well-definedness. Definitions of paradigm streams families abound, to wit: automatic sequences, morphic or D0L words, Toeplitz words, or streams defined by means of recurrence equations. The format PSF is expressive enough to encompass all of these classes. Also, operations realized by finite state transducers are easy to formulate in PSF. Here we will not present the formal definition of the format, but give some examples instead. First some notation. We use 2 to denote the two-letter alphabet 2 = {0, 1}. Let w, v ∈ 2∗ . We write |w| for the length of w. We use w ! v to denote that w is a prefix of v, that is, there exists u ∈ 2∗ such that v = wu. We write w|<n to denote the prefix of w of length n, that is, the word a0 . . . an−1 where w = a0 a1 a2 . . .. Likewise we write w|≥n for the suffix of w starting from letter an , that is, the stream an an+1 an+2 . . .. A stream σ is written by listing its elements: σ(0) : σ(1) : σ(2) : . . . Here the infix symbol ‘:’ is called the stream constructor ; it prepends an element a to a stream σ to form a new stream a : σ. 6 INTEGERS: 11B (2011) Thue–Morse M = 0110100110010110 . . . [39, A010060] Period doubling PD = 0100010101000 . . . [39, A096268] Mephisto Waltz W = 001001110001001110 . . . [39, A064990] Kolakoski K = 1221121221221121 . . . [39, A000002] Fibonacci F = 0100101001001 . . . [39, A003849] Paperfolding PF = 0010011000110110 . . . [39, A014707] M= 0:X X = 1 : zip(X, Y) Y = 0 : zip(Y, X) zip(x : σ, τ ) = x : zip(τ, σ) PD = zip(zeros, inv(PD)) inv(0 : σ) = 1 : inv(σ) inv(1 : σ) = 0 : inv(σ) zeros = 0 : zeros W = 0:A A = 0 : 1 : zip3 (A, A, B) B = 1 : 0 : zip3 (B, B, A) zip3 (x : σ, τ, υ) = x : zip3 (τ, υ, σ) K = 1 : 2 : K$$ K$$ = 2 : κ1 (K$$ ) κ1 (1 : σ) = 1 : κ2 (σ) κ1 (2 : σ) = 1 : 1 : κ2 (σ) κ2 (1 : σ) = 2 : κ1 (σ) κ2 (2 : σ) = 2 : 2 : κ1 (σ) F = 0 : F$ F$ = 1 : φ(F$ ) φ(0 : σ) = 0 : 1 : φ(σ) φ(1 : σ) = 0 : φ(σ) PF = zip(alt, PF) alt = 0 : 1 : alt zip(x : σ, τ ) = x : zip(τ, σ) Table 1: Rewrite specifications of some paradigm streams. To fit in the rewrite formalism, we have to read equality ‘=’ in the table as ‘→’, ‘rewrites to’. Simple recursive equations can be used to define stream operations; for instance, the rule: zip(x : σ, τ ) = x : zip(τ, σ) defines an operation zip : Aω × Aω → Aω which merges two streams by taking alternatingly one element from σ and one from τ . This corresponds to the more 7 INTEGERS: 11B (2011) explicit definition: zip(σ, τ )(2n) = σ(n) zip(σ, τ )(2n + 1) = τ (n) for all n ∈ N, where σ(n) denotes the n-th element of the stream σ. In the same way we can define individual streams. For example: M=0:X X = 1 : zip(X, Y) Y = 0 : zip(Y, X) is an elegant specification of the Thue–Morse sequence M due to Larry Moss. We frequently use the streams zeros and ones defined by zeros = 0 : zeros and ones = 1 : ones. Table 1 also shows PSF specifications of some other sequences: the period doubling sequence PD, the Mephisto Waltz W [25, 23], the Kolakoski sequence K, the Fibonacci word F, and the paperfolding sequence PF [11, 1, 2]. (Of course, many alternative PSF specifications exist for these paradigm streams.) The Sierpiński Sequence There is an intimate connection between some important fractal curves and streams via turtle graphics [22, 14]. Some sequences give rise to fractal curves by reading the terms of the sequence as drawing instructions. For example, in this way both the Thue–Morse sequence and the period doubling sequence give rise to the von Koch curve, see [31, 19]. An amusing puzzle is to derive such a sequence by looking at a curve. In Figure 3 we have displayed the initial approximations of the Sierpiński ar- Figure 3: Construction of the Sierpiński arrowhead curve. rowhead curve [34]. The question arises: what is the sequence behind this fractal curve? In other words, interpreting 0 and 1 as turtle drawing instructions e.g. as follows: 0: move forward one unit length and turn to the left π/3 radials, and 1: move forward one unit length and turn to the right π/3 radials, the search is for the sequence which generates the curve, in the limit using the Hausdorff metric. 8 INTEGERS: 11B (2011) To construct the sequence, we consider Figure 3. The first iteration of the construction, the arrowhead shape, corresponds to the word w1 = 00111100. The second iteration is obtained from w2 = w1 0 w1 0 w1 1 w1 1 w1 1 w1 1 w1 0 w1 0 where w1 = 11000011, that is, w1 is the mirrored arrowhead. Note that w1 and w1 alternate, and the word filled in-between is w1 itself. The construction clearly resembles the construction of Toeplitz words, as iterated self-substitution. Toeplitz words were introduced in [24]. A Toeplitz word over an alphabet Σ is constructed as follows: Let ? $∈ Σ be a new symbol, and P ∈ Σ · (Σ ∪ {?})∗ , in the notation of regular expressions. Starting with the sequence σ0 = P ω = P P P · · · , σi is obtained from σi−1 by replacing the first occurrence of ? in σi−1 by the i-th term of σi−1 (which is always unequal to ?). The Toeplitz word generated by P , which we denote by T (P ), is defined by T (P ) = limi→∞ σi . Thus the sequence under construction itself is used to fill its ‘holes’, that is, replace the ?’s. For example, the period doubling sequence PD is the Toeplitz word generated by the pattern P = (0 1 0 ?) : Pω = 010?010?010?010? ... PD = T (P ) = 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 0 . . . As in [1], we allow application of a letter–to–letter encoding to the read symbols that replace the ?’s. For words over {0, 1}, we write ? to denote taking the inverse of the bit that is read, i.e., 0 = 1 and 1 = 0. In this way the pattern generating PD can be simplified to (0 ?) : (0 ?)ω = 0 ? 0 ? 0 ? 0 ? 0 ? 0 ? 0 ? 0 ? . . . PD = T (0 ?) = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 . . . = 0100010101000100 ... Back to the Sierpiński curve, and the sequence generating it. After close inspection, we found that the Toeplitz word generated by the pattern: 00111100?11000011? is the desired sequence, which we call the Sierpiński sequence S. This pattern can be simplified to 0 0 ? 1 1 ?, and we define: S = T (0 0 ? 1 1 ?) In the rewriting format PSF the Sierpiński sequence S can be defined thus: S = zip3 (alt, alt, inv(S)) with zip3 , alt and inv defined by the equations in Table 1. This example shows eloquently the unifying merits of the PSF notation, as compared to the original ad hoc notation. 9 INTEGERS: 11B (2011) 3. Fingerprints of Streams Before we discuss some classical notions to compare streams in Section 4, followed by our main subject, the investigation of a new way to compare streams, namely by mutual finite state transformations, we first briefly consider a way to compare streams ‘graphically’ by displaying their orbit of iterated difference streams. This graphical rendering lends itself to some interesting possibilities for experimentation, and we describe in this section a fortunate experiment that yielded a surprising connection between two seemingly unrelated streams. and this connection yields a useful piece of information in the FST-hierarchy introduced and analysed in Section 5. The idea is to display in a 01-matrix ∈ 2N×N as the first row the sequence σ that we want to ‘fingerprint’, and such that the (n+ 1)-th row is the difference row of the n-th. This gives a graphical impression of the ‘volatility’ of the original stream σ, at any depth. It is interesting to print the fingerprint of, e.g., the Kolakoski sequence K, totally chaotic, of the sturmian Fibonacci sequence F, looking fairly ‘quiet’ as could be expected. Let us be more precise now. The difference operator δ : 2ω → 2ω realized by the FST depicted in Figure 1 can be defined in the pure stream format by the rule: δ(x : y : σ) = (x + y) : δ(y : σ) for all σ ∈ 2ω . Here + denotes addition modulo 2. ω In [20] we investigated the δ-orbit D(σ) = (δ n (σ))∞ n=0 of streams σ ∈ 2 . We showed that the δ-orbit of an arbitrary stream σ is ultimately periodic if and only if σ is ultimately periodic. Hence the δ-orbit of M is not periodic, that is, all streams δ n (M) are mutually different.3 A visual impression of the δ-orbit of the Morse sequence M is given by Figure 4. Another experiment with δ-orbits is shown in Figure 5, where the δ-orbits of the Sierpiński sequence S and the Mephisto Waltz W are displayed. It is readily seen that both patterns seem identical, from the distribution of the black triangles. That they are indeed identical is revealed by a closer inspection of the first couple of rows; it turns out that the third row of the left orbit, i.e. δ 2 (S), is identical to the fourth row of the right orbit, i.e. δ 3 (W). Indeed, the 16×16 enlargements show at these row-positions both the prefix 1100110111100111 of length 16. We prove this observation. Let us write σ $ for the tail of a stream σ : σ $ (n) = σ(n + 1) for all n ≥ 0. The zipk operator interleaving k streams is defined by: zipk (x : σ1 , σ2 , . . . , σk ) = x : zipk (σ2 , . . . , σk , σ1 ) 3 In fact, we can give explicit expressions for the iterations of δ on M (see [26]): δ2n (M) = zip(δn (M), δn (M)) and δ2n+1 (M) = zip(zeros, δn+1 (M)). 10 INTEGERS: 11B (2011) Figure 4: The first 400 iterations of δ on the Thue–Morse sequence (top row); 0s are black, 1s are white. Moreover we let σ + τ denote coordinatewise addition of streams σ, τ ∈ 2ω : (σ + τ )(n) = σ(n) + τ (n). We have σ + σ = zeros, δ(σ) = σ + σ $ , and σ = σ + ones. Note that )2ω , +, 0ω * forms a group structure, and that ( )$ and δ are group homomorphisms: (σ + τ )$ = σ $ + τ $ and δ(σ + τ ) = δ(σ) + δ(τ ). Moreover we have that zipk (σ1 , . . . , σk ) + zipk (τ1 , . . . , τk ) = zipk (σ1 + τ1 , . . . , σk + τk ). We show δ(W) = S + alt from which it immediately follows that δ 3 (W) = δ 2 (S), since for all σ ∈ 2ω it holds that δ 2 (σ + alt) = δ 2 (σ). Let σ ∈ 2ω . First note that δ(σ + ones) = (σ + ones) + (σ $ + ones) = σ + σ $ = δ(σ). Then δ 2 (σ + alt) = δ(σ + alt + σ $ + alt$ ) = δ(σ + σ $ + ones) = δ(σ + σ $ ) = δ 2 (σ). To show that δ(W) = S + alt we prove that both left and right-hand side of the equation are a solution for X in the following equation: X = zip3 (zeros, ones, X) which clearly has precisely one solution (namely the Toeplitz word T (01?)). To see this one may unfold the right-hand side to a guarded definition. INTEGERS: 11B (2011) 11 Figure 5: Comparing the ‘fingerprints’ D(S) and D(W) of the Sierpiński sequence S (left), and the Mephisto Waltz W. We find that δ 2 (S) = δ 3 (W)! For W we know that W = zip3 (W, W, W), and so δ(W) = W + W$ = zip3 (W, W, W) + zip3 (W, W, W)$ = zip3 (W, W, W) + zip3 (W, W, W$ ) = zip3 (W + W, W + W, W + W$ ) = zip3 (zeros, ones, W + W$ + ones) = zip3 (zeros, ones, δ(W)) We use S = zip3 (alt, alt, S) to show that also S + alt is a solution for the unknown X in the equation above. We have S + alt = zip3 (alt, alt, S) + alt = zip3 (alt, alt, S) + zip3 (alt, alt, alt) = zip3 (alt + alt, alt + alt, S + alt) = zip3 (zeros, ones, S + alt) Hence W and S belong to the same degree in the FST-hierarchy. 4. Classical Complexity Notions of Streams We briefly discuss two main notions of complexity, in order to compare these with our main subject in sections 5 and 6. INTEGERS: 11B (2011) 12 Subword Complexity Subword complexity [15, 2, 16, 5, 36] is a classical complexity measure on infinite words σ, that records as a function of n, how many factors of σ of length n occur in σ. Thus Sturmian [29] words have subword complexity n + 1, automatic sequences linear, morphic words quadratic, and so on. The subword complexity of the mysterious Kolakoski stream [27, 9, 7, 33, 8, 40, 12] is unknown. Kolmogorov Complexity The Kolmogorov complexity [28] K(w) of a word w is the length of the shortest binary program computing w in a fixed universal programming system (e.g., Java, C, or a Universal Turing machine). It does not matter which system we choose, but once the choice is made it must be fixed to obtain a definite Kolmogorov complexity. All choices are also equivalent up to a constant factor. For streams the same definition can be employed provided the streams are computable. For non-computable streams σ we can consider the function f (n) = K(σ|<n ) where σ|<n is the prefix of σ of length n. Kolmogorov complexity can also be employed for comparing streams, that is, computing a relative complexity. This corresponds to a fine tuning of the recursion theoretic hierarchy where one is not only interested in the existence of a finite binary program transforming one stream (equivalently, a set or function) into another, but moreover considers the size of the corresponding machines. Formally one can define the Kolmogorov complexity K(σ, τ ) of σ relative to τ , as the size of the smallest binary program computing σ given τ as oracle. Comparison with the FST-hierarchy The three notions recursion theoretic complexity, subword complexity and Kolmogorov complexity seem largely orthogonal to the complexity as in the FSThierarchy. As mentioned in the introduction, we envisage a notion of degrees of streams classifying their infinite pattern, invariant under the exchange of finite subsequences. The subword complexity measure is not suitable for our purposes as even noncomputable streams can have linear subword complexity. To see this, take a stream σ, and define the stream τ by τ (2n ) = σ(n) for every n ∈ N, and let τ (m) = 0 for all remaining positions m. Roughly speaking, we obtain the stream τ by distributing σ sparsely over the stream of zeros. Then τ has linear subword complexity and is computable if and only if σ is computable. Kolmogorov complexity is not appropriate as well. The reason is that the (relative) Kolmogorov complexity of a stream can be increased by an arbitrary constant by prefixing a finite word or by changing the encoding. From an infinitary point of 13 INTEGERS: 11B (2011) view, however, the streams are equivalent. For example, let M$ be obtained from the Thue–Morse sequence M by applying the substitution: 0 +→ I am a zero! 1 +→ Yes, here stands a one! Then in the (relative and non-relative) Kolmogorov complexity measure, the stream M is closer to the stream of zeros 0000 . . . than to M$ . In contrast, in the FSThierarchy discussed below, the streams M, M$ and PD are identified, and distinguished from zeros. They can easily be transformed into each other using FSTs. 5. Comparing Streams with Transducers In this section we introduce our main subject, being the classification of streams into degrees obtained by FSTs, finite state transducers. For a thorough introduction to stream transducers, we refer to [2, 37]. We recall some of the main definitions which we employ here, for the sake of completeness, and to fix notations. Definition 1. A (deterministic) finite stream transducer (FST) A = )Σ, Γ, Q, q0 , δ, λ* consists of a finite input alphabet Σ, a finite output alphabet Γ, a finite set of states Q, an initial state q0 ∈ Q, a transition function δ : Q × Σ → Q, and an ouput function λ : Q × Σ → Γ∗ . It suffices to consider FST’s with Σ = Γ = 2, see Lemma 14 below. If Σ = Γ = 2 we simply write )Q, q0 , δ, λ* for the FST. Example 2. In Figure 1 we have already seen an FST A. Formally, A can be defined as follows: A = )Q, q0 , δ, λ* where Q = {q0 , q1 , q2 }, and δ and λ are given by: δ(q0 , 0) = q1 λ(q0 , 0) = ε δ(q0 , 1) = q2 λ(q0 , 1) = ε δ(q1 , 0) = q1 λ(q1 , 0) = 0 δ(q1 , 1) = q2 λ(q1 , 1) = 1 δ(q2 , 0) = q1 λ(q2 , 0) = 1 δ(q2 , 1) = q2 λ(q2 , 1) = 0 An FST A transforms a word w = a0 a1 a2 . . . by reading w letter for letter. The output of A when applied to w is the concatenation λ(q0 , a0 )λ(q1 , a1 ) . . . of the output words encountered along the edges of A when reading w where qi+1 = δ(qi , ai ) for i = 0, 1, . . .. Definition 3. Let A = )Σ, Γ, Q, q0 , δ, λ* be an FST. We extend the state transition function δ from letters Σ to finite words Σ∗ as follows: δ(q, ε) = q for q ∈ Q, a ∈ Σ, w ∈ Σ∗ . δ(q, aw) = δ(δ(q, a), w) 14 INTEGERS: 11B (2011) The output function λ is extended to the set of all words Σ∞ = Σω ∪ Σ∗ by the following co-recursive definition: λ(q, ε) = ε λ(q, aw) = λ(q, a) · λ(δ(q, a), w) for q ∈ Q, a ∈ Σ, w ∈ Σ∞ . We introduce abbreviations δ(w) and λ(w) as shorthand for δ(q0 , w) and λ(q0 , w), respectively. Moreover, we define A(σ) = λ(σ), the output of A on σ ∈ Σω . Example 4. The modified frequency modulation (MFM) [21] is a coding scheme used for storing data on floppy disk formats and early hard discs. The MFM inserts a 0 between each two symbols unless they both are 0s, in which case it inserts a 1. This encoding guarantees that never four subsequent bits are equal, thereby allowing for easy synchronisation of the position of the read/write head. An FST implementing the MFM transformation is displayed in Figure 6. 0|ε q0 q1 0|10 1|ε 0|01 1|00 q2 1|10 Figure 6: Modified frequency modulation. E.g., the sequence 10100110001 is transformed into 100010010010100101001. Remark 5. The output of an FST applied to a stream σ is not guaranteed to be a stream again. Namely, the output is a finite word if the transducer eventually visits only edges with empty output ε. For this special case, the above co-recursive definition is not ‘productive,’ and leaves λ(q, σ) undefined. For our purposes, this setup is fine as we are only interested in the hierarchy of streams (excluding finite words). Finite words would not add structure to the hierarchy as they would be situated in the bottom degree 0 ; FSTs can produce any finite word without even reading the given input. Remark 6. An alternative to the co-recursive definition of λ(q, σ) is to extend λ from finite words to streams σ by: λ(q, σ) = lim λ(q, σ|<n ). n→∞ We now define ‘reducibility’ between streams in the obvious way: INTEGERS: 11B (2011) 15 Definition 7. Let A = )Σ, Γ, Q, q0 , δ, λ* be an FST, σ ∈ Σω and τ ∈ Γω . We write σ #A τ to denote that the A reduces σ to τ , that is, whenever A(σ) = τ . We say σ is reducible to τ , denoted σ # τ , if there exists an FST A such that σ #A τ . The following lemma is immediate from known theory on transducers [2]: Lemma 8. Reducibility is reflexive and transitive, that is #∗ ⊆ #. Remark 9. Transitivity of # can be shown using the ‘wreath product’ of FSTs [2]. Let Ai = )Σi , Σi+1 , Qi , qi,0 , δi , λi * be FSTs for i ∈ {1, 2}. We define the wreath product (or composition) A1 · A2 of A1 and A2 by: A1 · A2 = )Σ1 , Σ3 , Q1 × Q2 , )q1,0 , q2,0 *, δA1 ·A2 , λA1 ·A2 * δA1 ·A2 ()q1 , q2 *, a) = )δ1 (q1 , a), δ2 (q2 , λ1 (q1 , a))* λA1 ·A2 ()q1 , q2 *, a) = λ2 (q2 , λ1 (q1 , a)) Then it is an easy exercise to check that A2 (A1 (σ)) = (A1 · A2 )(σ). Whenever we have σ # τ as well as a back-transformation τ # σ, then we consider the streams σ and τ to be equivalent: Definition 10. We define " = # ∩ % as the notion of equivalence of streams. The equivalence classes of " are called degrees. For streams σ we use σ ( = {τ | σ " τ } to denote the equivalence class of σ with respect to ". Note that " is a congruence relation with respect to #. As a consequence # induces a partial order on the degrees. ω Notation 11. Let σ ∈ 2ω be a stream, S, T ⊆ 2ω sets of streams, and S, T ⊆ 22 sets of sets of streams (e.g., sets of degrees). We write S # T if τ # υ for all τ ∈ S and υ ∈ T . We write S # T if S # T for all S ∈ S and T ∈ T. Then, σ # S is shorthand for {σ} # S, S # T for {S} # T, σ # T for {σ} # T, and likewise S # σ for S # {σ}, T # S for T # {S}, and T # σ for T # {σ}. We recall a few well-known definitions from partial orders: Definition 12. Let S be a set of degrees, and T a degree. The degree T is • an upper bound of S if T # S, • a lower bound of S if S # T , • the supremum of S if T # S and T $ # T for every upper bound T $ of S, • the infimum of S if S # T and T # T $ for every lower bound T $ of S. We are interested in the hierarchy of streams generated by #. When investigating the hierarchy we can, without loss of generality, restrict to streams over the alphabet 2. All other alphabets can be encoded using prefix codes: 16 INTEGERS: 11B (2011) Definition 13. A prefix code is a morphism φ : Σ → Γ∗ such that for all a, b ∈ Σ with a $= b we have φ(a) $- φ(b). Note that for every finite alphabet Σ there exists a prefix code φ : Σ → 2∗ . Then the following lemma is immediate as FSTs can convert between arbitrary prefix codes for finite alphabets: Lemma 14. Let Σ, Γ be finite alphabets and φΣ : Σ → 2∗ , φΓ : Γ → 2∗ be prefix codes. Then we have: (∀σ ∈ Σω , τ ∈ Γω )(σ # τ ⇐⇒ φΣ (σ) # φΓ (τ )) . Lemma 14 justifies that we restrict our investigation of the hierarchy to 2ω , the set of streams over 2. Convention 15. In the sequel, we consider only stream transducers having 2 as input and output alphabet. We then write FSTs as quadruples )Q, q0 , δ, λ*, tacitly assuming that Σ = Γ = 2. We also restrict the hierarchy of degrees to bitstreams, then writing σ ( for the set σ ( = {τ ∈ 2ω | τ " σ}. Larger alphabets may be convenient in examples or proofs, but do not enrich the structure of the hierarchy due to the translation from larger alphabets to bitstreams given in Lemma 14. Definition 16. Let E ( = {σ ( | σ ∈ 2ω } be the set of equivalence classes of ". Figure 2 on page 3 gives a pictorial impression of the FST-hierarchy E ( , partially ordered by #. Before we start analyzing the properties of )E ( , #*, note how the fingerprint experiment of Section 3, yielding δ 3 (W) = δ 2 (S), yields that W " S. That is, W and S have the same degree. 6. An Initial Investigation of the Hierarchy 6.1. Immediate Observations In this section we investigate basic properties of the FST-hierarchy. We start with a few self-evident observations. The bottom degree 0 is defined to be the set of ultimately periodic streams: 0 = {vwω | v ∈ 2∗ , w ∈ 2+ } and is the lowest degree in the FST-hierarchy: Proposition 17. For all degrees S we have S # 0. Proposition 18. Every degree of E ( is countable. 17 INTEGERS: 11B (2011) Proof. Let σ ∈ 2ω be a stream. The degree σ ( is countable since there are only countably many FSTs over the alphabet 2 (recall Convention 15). Proposition 19. The set E ( of equivalence classes is uncountable. Proof. Every degree is countable by Proposition 18, but there are uncountably many streams over 2. Hence E ( must be uncountable. Proposition 20. Every degree has only a countable set of degrees below it. Proof. Analogous to the proof of Proposition 18. Lemma 21. The degree zip(σ, τ )( is an upper bound of {σ ( , τ ( } all σ, τ ∈ 2ω . The FSTs Aeven and Aodd corresponding to the transformations zip(σ, τ ) # σ and zip(σ, τ ) # τ are displayed in Figures 7 and 8, respectively. q0 0|0 1|1 q1 0|ε 1|ε q0 0|ε 1|ε q1 0|0 1|1 Figure 7: FST Aeven for zip(σ, τ ) # σ. Figure 8: FST Aodd for zip(σ, τ ) # τ . Proposition 22. There exist no maximal degrees. Proof. Let σ be a stream. The set of degrees below σ ( is countable by Proposition 20, but the hierarchy of degrees is uncountable by Proposition 19. Hence there exists τ such that σ $ # τ . Then zip(σ, τ ) # σ but not σ # zip(σ, τ ). As a consequence we obtain: Corollary 23. There exist infinite ascending sequences. In Section 6.4 we give a constructive example of an ascending sequence. 0 1 2 3 4 5 6 7 8 9 10 11 σ0 (0) σ1 (0) σ0 (1) σ2 (0) σ0 (2) σ1 (1) σ0 (3) σ3 (0) σ0 (4) σ1 (2) σ0 (5) σ2 (1) ... Figure 9: Zipping countably infinite families of streams: zip((σi )i∈N ). We extend the operation zip to countably infinite families of streams. Let (σi )i∈N be a family of streams. Then we define zip((σi )i∈N ) as the limit of the following 18 INTEGERS: 11B (2011) Toeplitz-like construction: Let τ0 =? ? ? . . ., and let τi+1 be obtained from τi by consecutively filling the elements of σi into every second ?-symbol of τi . The initial segment of zip((σi )i∈N ) is displayed in Figure 9. Alternatively, we can define zip((σi )i∈N ) using the binary zip operation: Definition 24. Let (σi )i∈N be a family of streams. Then we define the family of streams (τi )i∈N coinductively by τi = zip(σi , τi+1 ), and let zip((σi )i∈N ) = τ0 . For i ∈ N the projection zip((σi )i∈N ) # σi is realized by the wreath product Aiodd · Aeven (with Aeven and Aodd given in Figures 7 and 8). As a consequence we obtain the following lemma: Lemma 25. The degree zip((σi )i∈N )( is an upper bound for {σi( | i ∈ N}. By Lemma 25, every countable set of degrees has an upper bound. The following proposition strengthens this observation by stating that the condition ‘being countable’ is not only a sufficient but also a necessary condition: Proposition 26. A set S ⊆ E ( of degrees has an upper bound ⇐⇒ S is countable. Proof. The direction ‘⇐’ follows from Lemma 25, and ‘⇒’ from Proposition 20. 6.2. A Prime Stream After harvesting the low hanging fruits in Section 6.1, we now turn to establishing a more challenging fact, concerned with the notion of a ‘prime degree’, that is, a degree that is minimal in the sense that it has only the bottom degree 0 below it. Definition 27. A degree S ∈ E ( is prime if S is not the trivial degree 0, and there is no degree between S and 0: S is prime if and only if S $= 0 and ¬∃T ∈ E ( . S # T # 0 The apparent question is: Do prime streams exist? We give a positive answer to this question by showing that the following stream Π is prime: Π= ∞ ! 1 0k = 1101001000100001 . . . k=0 That is, we prove that every result of transducing Π is either ultimately periodic or in the degree of Π itself. The proof of primality of Π proceeds in the following steps: (i) We analyse the structure of reducts {σ | Π # σ} of Π. (ii) For every reduct which is not ultimately periodic we prove that the breaking points of periodicity can be recognised by finite state transducers. 19 INTEGERS: 11B (2011) (iii) The distance between the breaking points of periodicity grows linearly. Employing the fact that finite state transducers can compute inverse linear functions on the length of words, we can find a finite state transducer which reconstructs Π. We sketch the main line of the proof. For the details, we refer to the appendix. 6.2.1. The Structure of Reducts of Π Inspired by the structure of Π, containing blocks of zeros of increasing length, we analyse the behaviour of stream transducers on zero-words 0∗ . Definition 28. Let A = )Σ, Γ, Q, q0 , δ, λ* be an FST. We define: • A path of length n ∈ N in A is a sequence of pairs )q1 , a1 *, . . . , )qn , an * ∈ Q×Σ such that qi+1 = δ(qi , ai ) for all i = 1, . . . , n − 1. • A loop in A is a path )q1 , a1 *, . . . , )qn , an * for which q1 = δ(qn , an ), and a loop is called minimal if ∀i $= j. qi $= qj . • A zero-loop in A is a minimal loop )q1 , a1 *, . . . , )qn , an * in A that visits only edges with input 0, that is, ai = 0 for all 1 ≤ i ≤ n. We use zloops(A) to denote the set of zero-loops of A, and write ZA for the least common multiple of the lengths of all zero-loops in zloops(A). 000000000000000000 Figure 10: FST reading a word of the form 0∗ . Whenever an FST A reads a finite word v = 000 . . . that is longer than the number of states of A, then there must be repetition of states when A reads v. From the repetition point onwards, the automaton A is ‘caught’ in a zero-loop which A repeatedly executes, as illustrated in Figure 10. The following lemma employs this observation for the consideration of words v0n and v0m for which the difference of the lengths is a multiple of ZA : Lemma 29. Let A = )Q, q0 , δ, λ* be an FST. For all v ∈ 2∗ , n ∈ N, n > |Q| and q ∈ Q there exist w1 , w2 ∈ 2∗ such that for all i ∈ N: δ(q, v 0n+i·ZA ) = δ(q, v 0n ) λ(q, v 0n+i·ZA ) = w1 w2i . 20 INTEGERS: 11B (2011) Using Lemma 29 we derive a characterisation of the form of reducts of Π, that is, streams σ for which Π # σ. Proposition 30. For every stream σ ∈ 2ω with Π # σ we have: σ=w· ∞ ! n ! pj · cij i=0 j=0 for some n ∈ N and finite words w, pj , cj ∈ 2∗ . Note that pj · cij in Proposition 30 arises from the application of Lemma 29 to the blocks 1 0∗ in the stream Π. To obtain the form of the double product we prove that the states of A when entering the blocks 1 0∗ eventually start repeating periodically. We give an example, to illustrate Proposition 30. 1|1 q0 0|0 q1 0|0 1|000 Figure 11: FST replacing every second 1 by 000. Example 31. The FST displayed in Figure 11 replaces every second 1 by 000, that is, it reduces Π to: Π1 = 1000010000000010000000000001 . . . = 1 04 1 08 1 012 1 016 1 . . . = ∞ ! (1 (00)i · 000 0 (00)i) = i=0 ∞ ! 1 ! pj · cij i=0 j=0 where p0 = 1, c0 = 00, p1 = 0000 and c1 = 00. We can transform Π1 back to Π by 0000 +→ 0, a linear ‘compression’ which can easily be realised by an FST, see Lemma 35. 6.2.2. Breaking Points of Periodicity Proposition 30 describes the general form of reducts of Π. It remains to be shown that every stream of this form that is not ultimately periodic can be transformed back to Π. For this purpose a stream transducer needs to be able to detect the transition from factors pj · cij to the subsequent factor pj+1 · cij+1 . In general this 21 INTEGERS: 11B (2011) is not the case, as illustrated by Example 31. There it is not possible to detect the transition from 1 (00)i to 000 0 (00)i since the transducers have a finite state space. However, the reduct Π1 can be written as: Π1 = ∞ ! (10000 (0000)i) i=0 where each factor can be detected by the leading 1. The following proposition generalises this observation: Proposition 32. Let σ ∈ 2ω such that σ is not ultimately periodic and: σ=w· ∞ ! n ! pj · cij i=0 j=0 where n ∈ N and w, pj , cj ∈ 2∗ are finite words for j = 0, . . . , n. Then n, w, pj , cj can be chosen such that: (i) cj $= ε for all j = 0, . . . , n, and ω (ii) pj+1 $! cω j for all j = 0, . . . , n − 1, and p0 $! cn . Remark 33. As a consequence of this proposition, a finite state transducer reading σ can recognise the transition from one factor pj · cij to the subsequent factor pj+1 · cij+1 using bounded ‘look-ahead’. In particular, the maximum required look-ahead is max {pj | 0 ≤ j ≤ n} symbols. Although the definition of FSTs does not include look-ahead, we can simulate a look-ahead of m letters as follows. We construct an FST that reads m symbols ahead, and stores the values of the last m symbols in its memory (encoded in an enlarged state space). Then the algorithm with look-ahead can be simulated using the oldest stored letter as input, and employing the m symbols stored in memory as oracle for look-ahead. 6.2.3. Primality of Π and Density of the Hierarchy In order to reconstruct Π, we need the following auxiliary result: FSTs can compute (inverse) linear functions on the length of words. Definition 34. Let f : N → N be a function. An FST A = )Q, q0 , δ, λ* is called an f -compressor if λ(w) = 0f (|w|) for every non-empty word w ∈ 2∗ . For every linear rational function f we can construct an FST A such that on the input of a word w, A produces the output 0f (|w|). Lemma 35. Let a ∈ Q and b ∈ Q≥0 , and define f (n) = max(4a + b · n5, 0) for all n ∈ N. Then there exists an f -compressor. 22 INTEGERS: 11B (2011) We are ready for the main result: Theorem 36. The stream Π is prime. Proof. Let σ ∈ 2ω such that Π # σ and σ is not ultimately periodic. By Proposition 32, the stream σ can be written as: σ=w· ∞ ! n ! pj · cij i=0 j=0 ∗ where n ∈ N and w, pj , cj ∈ 2 for j = 0, . . . , n such that cj $= ε for all j = 0, . . . , n, ω and pj+1 $! cω j for all j = 0, . . . , n − 1, and p0 $! cn . We construct a finite state automaton A that transforms σ back to Π as follows. Let A start by reading |w| letters without empty output. Afterwards we let A alternating read p0 c∗0 , . . . , pn c∗n where A recognises the the transition from one factor pj c∗j to pj+1 c∗j+1 as described in Remark 33. The automaton A is able to recognise the occurrences of the displayed factors "n p0 ci0 . Hence we obtain Π by mapping the factors j=0 pj · cij of the outer product " #n n to 10i for i = 0, 1, . . .. We have f (i) = | j=0 pj · cij | = a + i · b where a = j=0 |pj | #n −1 and b = (m) = j=0 |cj |. The inverse of f is a linear rational function: f (m − a)/b. As a consequence, we obtain Π by outputting 1 at the start of each factor of the outer product, followed by 0i constructed the f −1 -compressor (exists by Lemma 35) applied to the factor of the outer product. The f −1 -compressor can be ‘run in parallel’ with the other tasks of A by employing a cross-product like construction. As a direct consequence of Theorem 36 we obtain: Corollary 37. The FST-hierarchy is not dense. 6.3. An Infinite Descending Chain We show that the hierarchy is not well-founded by proving that the following sequence of streams forms an infinite decreasing chain: 0 1 2 3 4 5 6 0 2 4 6 8 10 0 4 8 12 I0 = 102 102 102 102 102 102 102 . . . 12 # I1 = 102 102 102 102 102 102 102 . . . 16 20 24 # I2 = 102 102 102 102 102 102 102 . . . # ... where # = (# ∩ $=), and for i ∈ N we define: Ii = ∞ ! k=0 k·2i 10(2 ) 0·2i = 10(2 ) 1·2i 10(2 ) 2·2i 10(2 ) ... 23 INTEGERS: 11B (2011) 0|ε 1|1 q0 q1 1|ε 0|0 Figure 12: FST reducing Ii to Ii+1 for all i ∈ N. Then the FST displayed in Figure 12 reduces Ii to Ii+1 for all i ∈ N. Roughly speaking, the automaton segments the streams into blocks of the form 10∗ , and deletes every second block (starting from the second one). Lemma 38. We have Ii # Ii+1 for all i ∈ N. Proof. Let i ∈ N; we apply the automaton A from Figure 12 to Ii . As discussed above, the A drops every second block of the form 10∗ . Hence we obtain Ii = ∞ ! k·2i 10(2 ) ∞ ! #A k=0 2·k·2i 10(2 ) ∞ ! = k=0 k·2i+1 10(2 ) = Ii+1 . k=0 Hence (Ii )i∈N forms an infinite # chain. It remains to be shown that each of the #-steps is strict, that is, a #-step. Lemma 39. Let k ∈ N. For every stream σ ∈ 2ω with Ik # σ we have: ∞ ! n ! σ=w· f (i·(n+1)+j) p j · cj i=0 j=0 k for some n ∈ N and words w, pj , cj ∈ 2∗ , and f : N → N with f (m) ∈ Θ(2m·2 ). Proof. The proof is analogous to the proof of Lemma 30. Let k ∈ N, σ ∈ 2ω , and A = )Q, q0 , δ, λ* be an FST such that Ik #A σ. We have: 0·2k Ik = 10(2 ) 1·2k 10(2 ) 2·2k 10(2 i·2k ) ... We consider Ik as sequence of blocks γi = 10(2 ) . Let qi denote that state of A when entering the block γi (during reading σ). By the Pigeonhole Principle there exist n1 , n2 ∈ N such that |Q| < 2n1 < 2n2 , and 2n1 ≡ 2n2 mod ZA , and qn1 = qn2 . Then 2n1 +i ≡ 2n2 +i mod ZA for all i ∈ N. Hence qn1 +i = qn2 +i for all i ∈ N as a consequence of Lemma 29. 24 INTEGERS: 11B (2011) By Lemma 29 there exist pj , cj ∈ 2∗ for j = 0, . . . , n2 − n1 such that: whenever m = n1 + i · (n2 − n1 ) + j with i ∈ N and 0 ≤ j < n2 − n1 , then λ(qm , γm ) = λ(qni +j , γm ) = λ(qni +j , γn1 +j 0"·ZA ) = pj · c"j k k where - ∈ N such that 2m·2 − 2(n1 +j)·2 = - · ZA . Thereby we have implicitly k defined the mapping f : N → N by (m − n1 ) +→ -. Note that f ∈ Θ(2(m−n1 )·2 ), which yields the claim. Theorem 40. I0 # I1 # I2 # . . . is an infinite decreasing chain. Proof. We have Ii # Ii+1 for all i ∈ N by Lemma 38. Assume there exists k ∈ N such that Ik+1 # Ik . Then by Lemma 39 Ik must be of the form I$k = w · ∞ ! n ! f (i·(n+1)+j) p j · cj i=0 j=0 k+1 with f (m) ∈ Θ(2m·2 ). Since for every - ∈ N, 1 0" 1 occurs at most once in Ik , it follows that for all j = 0, . . . , n, pj contains at most one 1, and cj consists only of zeros. However, there must exist one j ∈ {0, . . . , n} such that cj $= ε. Hence, the displayed occurrences f (i·(n+1)+j) for i = 0, 1, 2, . . . are separated by at most n + 1 ones, but of γi = cj k+1 the number of zeros in γi grows with speed Θ((22 ·(n+1) )i ). This is faster than k ! the growth of the corresponding blocks in Ik : Θ((22 ·(n +1) )i ) with n$ ≤ n. This contradicts the assumption I$k = Ik . 6.4. An Infinite Ascending Chain In this section, we construct an infinite ascending chain. The existence of such a chain was non-constructively proven in Corollary 23. The family (Uk )k∈N establishes a concrete example of an infinite ascending chain: ... # U2 = 1(10)2 1(100)2 1(10000)2 1(100000000)2 . . . # U1 = 110 1100 110000 1100000000 . . . # U0 = 111111 . . . where for k ∈ N we define: Uk = ∞ ! (1 · i=0 k−1 ! j=0 i 10(2 ) ) = 1(10)k 1(100)k 1(10000)k 1(100000000)k . . . 25 INTEGERS: 11B (2011) 0|0 1|1 q0 1|1 q1 0|ε q2 0|0 1|ε Figure 13: FST reducing Uk+1 to Uk for all k ∈ N. We can transform Uk+1 to Uk by mapping 110∗ 1 +→ 11, that is, we remove the first block 10∗ after every occurrence of 11. This transformation is implemented by the FST displayed in Figure 13. Then we immediately obtain the following lemma: Lemma 41. We have Uk+1 # Uk for all k ∈ N. Theorem 42. U0 # U1 # U2 # . . . is an infinite ascending chain. Proof. We have Uk+1 # Ik for all k ∈ N by Lemma 41. Assume that there exists k ∈ N and an FST A = )Q, q0 , δ, λ* such that Uk #A Uk+1 . Then k > 0 since U0 is ultimately periodic while U1 is not. We consider Uk as a sequence of blocks γi of the form 110+ and 10+ . Let qi be the state of A when entering γi . By the Pigeon Hole Principle there exist n1 , n2 ∈ N such that |Q| < 2n1 < 2n2 , n1 n2 and 2n1 ≡ 2n2 mod ZA , and A enters the block 1102 in the same state as 1102 . n2 n1 Let m1 be the index of block 1102 and m2 the index of block 1102 , that is, n1 n2 γm1 = 1102 and γm2 = 1102 . Define p = m2 − m1 . Then qm+p = qm for every m ≥ m1 . Then: λ(Uk ) = w · λ(qm1 , γm1 ) · λ(qm1 +1 , γm1 +1 ) . . . By Lemma 29 for every q ∈ Q there exist pq , cq , p$q , c$q such that: λ(q, 10|Q|+"·ZA ) = pq · c"q λ(q, 110|Q|+"·ZA ) = p$q · c$" q As in the proof of Theorem 40 it follows that for every q ∈ Q, pq contains at most one occurrence of 11 or 1, and cq consists only of zeros if λ(q, 10∗ ) occurs in the periodic part, and likewise for p$q , and c$q if λ(q, 110∗ ) occurs in the periodic part. As a consequence, from γm1 onwards, one block of Uk gets mapped to at most one block of λ(Uk ) (no fresh delimiters 11 or 1 are created). Again, since Uk+1 is not ultimately periodic, there exists q ∈ Q such that either cq $= ε and λ(q, 10∗ ) occurs in the periodic part, or c$q $= ε and λ(q, 110∗ ) occurs INTEGERS: 11B (2011) 26 in the periodic part. Without loss of generality assume cq $= ε. Then we have |λ(q, 10m )| ∈ Θ(m). As in the proof of Theorem 40 this leads to a contradiction as the size of the blocks in λ(Uk ) grows faster than the size of the blocks in Uk+1 . 6.5. Do Suprema Exist? In analogy with the situation of the famous degrees of unsolvability [38, 3], one would expect that the interleaving (zip) of two streams yields their supremum. More precisely, one would expect that zip(σ, τ )( is the supremum of the degrees σ ( and τ ( . However, in the FST-hierarchy this question is much more complicated. By Proposition 26 every pair of degrees has an upper bound. For Turing degrees it is known that every pair of degrees has a least upper bound, a supremum. This raises the question whether the same holds for the FST hierarchy. We conjecture that the answer to this question is negative: Conjecture 43. There exist σ, τ ∈ E ( without supremum. Let us briefly substantiate this conjecture. We define operations on streams: zip1,1 (x : σ, y : τ ) = x : y : zip1,1 (σ, τ ) zip1,2 (x : σ, y : z : τ ) = x : y : z : zip1,2 (σ, τ ) Note that zip1,1 is equivalent with the earlier defined zip. Let σ, τ be streams, and define γ1 = zip1,1 (σ, τ ), and γ2 = zip1,2 (σ, τ ). Then obviously γ1 and γ2 are upper bounds for {σ, τ }. If {σ, τ } has a supremum υ, then υ must be a common reduct of γ1 and γ2 and an upper bound for {σ, τ }, that is, γ1 # υ % γ2 and σ % υ # τ . However, γ1 and γ2 contain the information of the streams σ and τ at different speeds. That is, neighbouring digits of γ1 have unbounded distance in γ2 and vice versa. Hence, information from a bounded size area of the common reduct υ has unbounded distance in either γ1 or γ2 . It appears implausible if not impossible that a transducer with finite memory can perform such a transformation. However, for particular streams σ and τ the common reduct υ may very well exist. Therefore, the streams σ and τ have to be chosen carefully. For example, σ and τ should be incomparable, that is, σ $ # τ and τ $ # σ. Even for streams with this property, it is not excluded that zip1,1 (σ, τ ) # zip1,2 (σ, τ ) or zip1,2 (σ, τ ) # zip1,1 (σ, τ ), which should be excluded as well. The operations zip1,1 and zip1,2 are only examples for constructing upper bounds. There are various other constructions for obtaining upper bounds. A possible line of attack for proving Conjecture 43 is as follows: (i) Choose streams σ and τ . (ii) Choose upper bounds γ1 , γ2 of {σ, τ } such that the set of common reducts C = {υ | γ1 # υ} ∩ {υ | γ2 # υ} of γ1 and γ2 has a manageable structure. INTEGERS: 11B (2011) 27 (iii) Show that for no stream υ ∈ C we have υ # σ and υ # τ . The crucial point is (ii), that is, finding upper bounds with a manageable set of common reducts. 6.6. Recurrence As a final observation in our initial investigation of the FST-hierarchy we show that the property of ultimate recurrence, defined below, is invariant under reducibility #. Such invariances are useful for discriminating degrees σ ( and τ ( , that is, proving that σ $ # τ or τ $ # σ. Definition 44. A stream σ is called recurrent if every factor (finite subword) w of σ occurs infinitely often in σ. A stream σ is called ultimately recurrent if for some n ∈ N the suffix σ|≥n is recurrent. A simple example shows that the property of being ‘recurrent’ is not invariant under stream transduction. Let σ = 00000 . . . and τ = 100000 . . .. Then obviously σ # τ , but σ is recurrent while τ is not. However, being ‘ultimately recurrent’ turns out to be an invariance. We give a slightly different characterisation of recurrent streams: Lemma 45. A stream σ is recurrent if and only if for all prefixes w of σ we have that w occurs infinitely often in σ. We now show that ultimate recurrence is preserved by FSTs. Buls [6] derived a similar result for Mealy machines. Other related results have been obtained in [32, 35]: preservation of almost periodicity and of strong almost periodicity (= uniform recurrence) by FSTs, respectively. Theorem 46. If σ # σ $ and σ is ultimately recurrent, then σ $ is ultimately recurrent. Proof. Let σ, τ ∈ 2ω , and A = )Q, q0 , δ, λ* an FST such that σ #A τ and σ is an ultimately recurrent stream. Let n0 ∈ N such that σ|≥n is recurrent. For w ∈ 2∗ , let Pos(w) denote the set of positions of w in σ, that is, Pos(w) = {n | w ! σ|≥n }. Moreover, let Q∞ (w) ⊆ Q be the set of states q ∈ Q such that for infinitely many positions n ∈ Pos(w) we have δ(σ|<n ) = q. Note that: (i) Q∞ (w) ⊆ Q∞ (w$ ) whenever w$ - w, and (ii) Q∞ (w) $= ∅ for every factor w of σ|≥n by the Pigeonhole principle. (iii) As a consequence of (i) and (ii), for every n$ ≥ n, there exists a state q ∈ Q such that q ∈ Q∞ (w) for every w ! σ|≥n! . 28 INTEGERS: 11B (2011) We determine an index m ∈ N such that for all prefixes w ! σ|≥m it holds that δ(σ|<m ) ∈ Q∞ (w). Then, it follows that λ(δ(σ|<n ), σ|≥n ) is recurrent by Lemma 45, and hence λ(σ) = λ(σ|<n ) · λ(δ(σ|<n ), σ|≥n ) is ultimately recurrent. To determine m, we employ the following iterative algorithm with the invariant Qi = Q∞ (pi ) for all i ∈ N. We start with m1 = n0 , p1 = ., and Q1 = Q∞ (p1 ). For k = 1, 2, . . ., we define: $ - Let Qk+1 = {Q∞ (p) | p ! σ|≥mk }. Note that ∅ $= Qk+1 by (iii), and Qk+1 ⊆ Qk by (i) since pk ! σ|≥mk with Q∞ (pk ) = Qk . - Let pk+1 be a prefix of σ|≥mk such that Q∞ (p) = Qk+1 . Such a prefix exists as a consequence of (i) and ∅ $= Qk+1 . - Let mk+1 ∈ Pos(pk+1 )σ such that mk+1 ≥ mk and for every occurrence of pk+1 at positions n ≥ mk+1 in σ it holds δ(σ|≥n ) ∈ Qk+1 . We stop the iterative process as soon as we reach k ∈ N such that Qk+1 = Qk . Then we define m = mk . The construction is guaranteed to terminate since for all k $ ≥ 1 we have Qk! +1 ⊆ Qk! . We check that m has the desired properties. Let p ! σ|≥m . If p ! pk then ∅ ⊆ Q∞ (pk ) ⊆ Q∞ (p) and hence δ(σ|<m ) ∈ Q∞ (p) since δ(σ|<m ) ∈ Q∞ (pk ). Otherwise if p0 - p then δ(σ|<m ) ∈ Q∞ (pk ) = Q∞ (p). 7. Primality of Morse Of special interest in the FST-hierarchy is the location of well-known streams. In particular, we are intrigued by the wonderful Thue–Morse sequence M = 01101001 . . . and we wonder whether the degree of M is prime. Question 47. Is the degree M( prime? In order to gain insight in this problem, we may consider some non-trivial (i.e., not ultimately periodic) FST-reducts of M and then try to find the way back to M. As evidence in favor of an affirmative answer to Question 47 one can for instance establish that all arithmetical subsequences of M can be transformed back by some FST to M again: Let σan+b = (σ(an + b))n≥0 denote the subsequence of σ ∈ Aω indexed by the arithmetic progression b, a + b, 2a + b, . . . : Proposition 48. Every arithmetic subsequence of M is equivalent to M: M " Man+b , for all a ≥ 0, b ≥ 1. 29 INTEGERS: 11B (2011) Proof. (A more detailed proof of Proposition 48 is given in [41].) Let a ≥ 0 and b ≥ 1. We define a morphism by h(0) = 01 and h(1) = 10. Then we have M = h(M). Thus, for every k ∈ N, M can be viewed as a sequence M = hk (0) hk (1) hk (1) hk (0) . . . of blocks hk (0) and hk (1) of length 2k . We choose k such that a ≤ 2k . If we number the blocks d0 , d1 , . . ., then beginning from the block d*b/2k + , the sequence Man+b contains at least one bit from every block. Note that every block dj is completely determined by an index 0 ≤ i < 2k in the block and the bit dj (i) at position i. A finite stream transducer can reconstruct M from Man+b employing that the sequence (an + b)n∈N is periodic modulo 2k , that is, the indexes of the picked digits within each block are periodic. We generalize and extend the question of primality of M to sequences formed by sequences (vp (n)mod2)n≥1 where vp (n) is the p-adic valuation of n (the multiplicity of p in the prime factorisation of n). The Morse sequence M is FST-equivalent to such a sequence, namely the period doubling sequence PD, which is defined as 2-adic valuation modulo 2. Thus M is prime if and only if PD is. Definition 49. We write P = {2, 3, . . .} for the set of prime numbers. Let p ∈ P. The p-adic valuation vp (n) of a number n ≥ 1 is defined by: vp (n) = max {a | pa divides n} The sequence generated by A ⊆ P, which we denote by vA , is defined as follows: %& ' vA (n) = vp (n) mod 2 , for all n ≥ 1. p∈A A sequence σ ∈ 2ω such that σ = vA for some A ⊆ P is called prime generated. For instance the period doubling sequence is defined as PD = v{2} . We mention without proof that sequences generated by a singleton prime are morphic and Toeplitz words. Question 50. Do there exist sets A ⊆ P such that the degree of vA is prime? One may also wonder how the sequences relate to each other. We have seen that the Mephisto Waltz W = 001001110 . . . and the Sierpiński stream S = 001111000 110000110 . . . belong to the same degree in the FST-hierarchy, W " S just like M " PD. What about M and S, can one be reduced to the other? It is not hard to show that δ(W) is prime generated; more precisely: δ(W) = vA where A = { p ∈ P | p ≡ 2 (mod 3) } ∪ {3} Note that A is an infinite set of primes by Dirichlet’s Theorem [13]. We conjecture that for every A ⊆ P the sequence vA belongs to a unique degree in the FST-hierarchy: 30 INTEGERS: 11B (2011) Conjecture 51. For all sets A, B ⊆ P the following implication holds: vA # vB =⇒ A = B If this is true, M and S are incomparable. 8. Conclusions and Questions Finite state transducers capture the intuition of infinite pattern. Summarising, the hierarchy of degrees of streams, generated by FSTs, is fine grained as FSTs can do only simple transformations, robust under the exchange of an arbitrary finite amount of elements in the streams, prepending or cutting-off of prefixes, change of encoding, etc., and captures the infinitary information content in the sense of invariant infinite patterns. The main idea leading to this hierarchy of degrees seems to us both simple and necessary to investigate. Remarkably, it seems to have remained unexplored. We have made a first step in the study on the FST-hierarchy, considering a few elementary properties like well-foundedness, the existence of maximal degrees, prime degrees, . . . . Most of all, we have encountered questions, the most interesting of which we want to mention here: (i) Is the degree of M (Thue–Morse sequence) prime? (ii) How many prime streams degrees exist? (iii) How do the degrees of some well-known streams compare? For example, are M (Morse) and S (Sierpiński) of the same degree? (iv) How to prove non-reducibility σ $ # τ ? An especially interesting instance: how to prove non-reducibility between morphic streams? (v) Is every prime generated sequence vp with p ∈ P prime? Note that this would immediately imply (i). (vi) Do the structures displayed in Figure 14 exist? In this paper, we have employed pumping lemma-like arguments to prove primality and non-reducibility of certain streams. However, these arguments apply only for streams with a very regular structure, for example for streams built from blocks of the form 1 0n of growing size n. It seems challenging to prove primality and non-reducibility of streams that avoid repeating patterns, for example morphic streams like the Morse sequence M. It is inspiring to compare streams and fractal curves; from fractal curves we obtain interesting new streams such as the stream S, generating the Sierpiński triangle. Can we find criteria for streams which guarantee that the turtle drawings 31 INTEGERS: 11B (2011) 0 0 Figure 14: Possible structures in the FST-hierarchy: a diamond, and a line. The arrows S → T mean S # T . Using transitivity of # we leave some arrows implicit. Moreover, we assume that if S is a degree and S # T , then T is depicted as well. In particular there are no intermediate degrees between two displayed nodes connected by an arrow. Figure 15: The necklace curve generated by the sequence v{7} using the instuctions: turn π/6 radials left on reading 0 and turn 7π/6 right on reading 1. The figure displays the first 77 steps. converge towards a fractal curve? Can fractal curves be used as a tool to distinguish degrees? As an illustration we mention the prime generated sequence v{7} (see Section 7) which generates the ‘necklace’ fractal displayed in Figure 15. Acknowledgements. We thank Frits Dannenberg for his interest in this subject, and refer to his master’s thesis [10] which in particular contains some more general 32 INTEGERS: 11B (2011) expressions for characterizing FST-reducts of sequences like Π. We thank Alexander Belov for his encouraging comments on our work and making us aware of his own work on the hierarchy that arises from considering Mealy machines (see Related work on page 4). We thank the anonymous referees from prompting us to rewrite and clarify some of the proofs in the appendix. References [1] J.-P. Allouche and R. Bacher. Toeplitz Sequences, Paperfolding, Towers of Hanoi, and Progression-Free Sequences of Integers. L’Enseignement Mathématique, 38:315–327, 1992. [2] J.-P. Allouche and J. Shallit. Automatic Sequences: Theory, Applications, Generalizations. Cambridge University Press, New York, 2003. [3] K. Ambos-Spies and P.A. Fejer. Degrees of Unsolvability, 2006. [4] Alexander Belov. Some Algebraic Properties of Machine Poset of Infinite Words. ITA, 42(3):451–466, 2008. [5] V. Berthé. Sequences Of Low Complexity: Automatic And Sturmian Sequences. Course notes. [6] J. Buls. The Lattice of Machine Invariant Sets and Subword Complexity. abs/cs/0502064, 2005. CoRR, [7] A. Carpi. Repetitions in the Kolakovski Sequence. Bull. of the EATCS, 50:194–196, 1993. [8] V. Chvátal. Notes on the Kolakoski Sequence. Technical Report 93-84, DIMACS, 1994. [9] K. Culik II, J. Karhumäki, and A. Lepistö. Alternating Iteration of Morphisms and the Kolakovski Sequence. In G. Rozenberg and A. Salomaa, editors, Lindenmayer Systems, pages 93–103. Springer, 1992. [10] F.G.W. Dannenberg. Symbolic Dynamics and Automata Theory. Master’s thesis, Delft University of Technology, 2011. [11] F.M. Dekking. Constructies voor 0-1-Rijen met Strikt Ergodische Afgesloten Baan. Master’s thesis, Universiteit van Amsterdam, 1974. [12] F.M. Dekking. and J. Patera, 1995), volume pages 115–125, What Is the Long Range Order in the Kolakoski Sequence? In R.V. Moody editors, The Mathematics of Long-Range Aperiodic Order (Waterloo, ON, 489 of NATO ASI Series, Series C: Mathematical and Physical Sciences, Dordrecht, The Netherlands, 1997. Kluwer Academic Publishers. [13] P. G. L. Dirichlet. Beweis des Satzes, daß jede unbegrenzte arithmetische Progression, deren erstes Glied und Differenz ganze Zahlen ohne gemeinschaftlichen Factor sind, unendlich viele Primzahlen enthält. Abhand. Ak. Wiss. Berlin, pages 45–81, 1837. [14] G. Edgar. Measure, Topology, and Fractal Geometry. Springer, 2nd edition, 2008. [15] A. Ehrenfeucht, K.P. Lee, and G. Rozenberg. Subword Complexities of Various Classes of Deterministic Developmental Languages Without Interaction. Theoretical Computer Science, 1:59–75, 1975. [16] A. Ehrenfeucht and G. Rozenberg. Subword Complexity of Square-Free D0L Languages. Theoretical Computer Science, 16(1):25–32, 1981. [17] J. Endrullis, C. Grabmayer, and D. Hendriks. Data-Oblivious Stream Productivity. In Proc. Conf. on Logic for Programming, Artificial Intelligence, and Reasoning (LPAR 2008), pages 79–96, 2008. [18] J. Endrullis, C. Grabmayer, D. Hendriks, A. Isihara, and J.W. Klop. Productivity of Stream Definitions. Theoretical Computer Science, 411(4-5):765–782, 2010. 33 INTEGERS: 11B (2011) [19] J. Endrullis, C. Grabmayer, D. Hendriks, and J.W. Klop. Infinite Streams. In Nieuwsbrief van de NVTI (Newsletter of the Dutch Association for Theoretical Computer Science), pages 39–48. 2009. http://www.nvti.nl/Newsletter/Nieuwsbrief2009.pdf . [20] J. Endrullis, D. Hendriks, and J.W. Klop. Let’s Make a Difference! CoRR, abs/0911.1004, 2009. [21] R.A. Holmgren. A First Course in Discrete Dynamical Systems. Springer Universitext, 2nd edition, 1996. [22] J.E. Hutchinson. Fractals and Self-Similarity. Indiana Univ. Math. J., 30:713–747, 1981. [23] K. Jacobs. Invitation to Mathematics. Princeton University Press, 1992. [24] K. Jacobs and M. Keane. 0-1-Sequences of Toeplitz Type. Zeitschrift für Wahrscheinlichkeitstheorie und Verwandte Gebiete, 13(2):123–131, 1969. [25] M. Keane. Generalized Morse Sequences. Zeitschrift für Wahrscheinlichkeitstheorie und Verwandte Gebiete, 10(4):335–353, 1968. [26] J.W. Klop. A Wonderful Stream. In F. de Boer et al., editor, Liber Amicorum Jaco de Bakker, pages 125–142. CWI, 2002. [27] W. Kolakovski. Self Generating Runs. Amer. Math. Monthly, 72, 1965. Problem 5304. [28] M. Li and P.M.B. Vitányi. An Introduction to Kolmogorov Complexity and Its Applications. Springer, 2nd edition, 2008. [29] M. Lothaire. Algebraic Combinatorics on Words. Cambridge University Press, 2002. [30] B. Löwe. Complexity Hierarchies Derived from Reduction Functions. In Classical and New Paradigms of Computation and their Complexity Hierarchies, volume 23 of Trends in Logic, pages 1–14. Springer, 2004. [31] J. Ma and J.A. Holdener. When Thue–Morse meets Koch. In Fractals: Complex Geometry, Patterns, and Scaling in Nature and Society, volume 13, pages 191–206, 2005. [32] A.A. Muchnik, A.L. Semenov, and M. Ushakov. Almost periodic sequences. Theoretical Computer Science, 1-3(304):1–33, 2003. [33] G. Paun. How much Thue is Kolakovski? Bull. of the EATCS, 49:183–185, 1993. [34] H. Peitgen, H. Jürgens, and D. Saupe. Chaos and Fractals. New Frontiers of Science. Springer, 2nd edition, 2004. [35] Y. Pritykin. Strongly Almost Periodic Sequences under Finite Automata Mappings. CoRR, abs/cs/0605026, 2006. [36] N. Pytheas Fogg. Substitutions in Dynamics, Arithmetics and Combinatorics, volume 1794 of Lecture Notes in Mathematics. Springer, 2002. [37] J. Sakarovitch. Elements Of Automata Theory. Cambridge, 2003. [38] J.R. Shoenfield. Degrees of Unsolvability. North-Holland, Elsevier, 1971. [39] N.J.A. Sloane. Online Encyclopedia of Integer Sequences, 2010. http://oeis.org/classic/ . [40] R. Steacy. Structure in the Kolakoski Sequence. Bull. of the EATCS, 59:173–181, 1996. [41] S. Stern. The Thue–Morse Sequence. Master’s thesis, Vrije Universiteit Amsterdam, 2008. [42] Terese. Term Rewriting Systems, volume 55 of Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 2003. 34 INTEGERS: 11B (2011) Appendix A. Proof of Theorem 36: Π is Prime Consider words w = 0n , w$ = 0m with |Q| < n < m such that the difference of the lengths (m − n) is a multiple of ZA . Let L be the final zero-loop in the run of A on w. Then the run of A on w$ is an extension of the run on w with (whole) multiples of L. Lemma 29 lemma employs this finding in the consideration of words of the form v 0∗ . states input output 10000000000000000000000000 w1 w2 w2 Figure 16: FST reading a word of the form 10∗ . Proof of Lemma 29. Since n > |Q| there exist k, p ∈ N with k + p ≤ n such that δ(q, v0k ) = δ(q, v0k+p ), that is, we have a repetition of states. Let k, p ∈ N be minimal with these properties. Then p is the length of a zero-loop in A, and hence ! ! ZA = m·p for some m ∈ N. It follows that δ(q, v0k ) = δ(q, v0k +p ) for every k $ ≥ k, and as a consequence δ(q, v 0n+i·ZA ) = δ(q, v 0n+i·m·p ) = δ(q, v 0n ) Define w1 = λ(q, v 0n ), q $ = δ(q, v 0n ) and w2 = λ(q $ , 0ZA ); see Figure 16. Then λ(q, v 0n+i·ZA ) = w1 w2i since δ(q $ , 0ZA ) = q $ as shown above. In the sequel we will employ Lemma 29 for the special case of v = 1. The Structure of Reducts of Π We give a few examples, to illustrate the Proposition 30 and Theorem 36. 1|1 0|0 q0 q1 0|00 1|0 Figure 17: FST deleting every second 1, doubling the zeros in even blocks. 35 INTEGERS: 11B (2011) Example 52. The FST from Figure 17 removes every second 1, and doubles the zeros in even blocks 1 0∗ . That is, it reduces Π to: Π2 = 1001000000001000000000000001 . . . = 1 02 1 08 1 014 1 . . . = ∞ ! ∞ ! 1 ! (1 (0000)i · 0 0 (00)i ) = pj · cij i=0 j=0 i=0 where p0 = 1, c0 = 0000, p1 = 00 and c1 = 00. n−2 We can transform Π2 back to Π by compressing blocks of zeros 0n +→ 0 6 . Again, we can construct an FST performing this compression by Lemma 35. Let us consider a slightly slightly more involved example: 1|100 0|010 q0 q1 0|100 1|10 Figure 18: FST transforming Π. Example 53. The FST from Figure 18 transforms Π into: Π3 = 100100101001001001001001001010010010010010010010010010 . . . = ∞ ! (100 (100100)i · 10 010 (010010)i) = ∞ ! 1 ! pj · cij i=0 j=0 i=0 where p0 = 100, c0 = 100100, p1 = 10010 and c1 = 010010. The stream can be transformed back to Π. The stream Π3 is not ultimately periodic. In particular, the periodicity is broken by the occurrences of 101, and we can construct an FST that recognizes these occurrences. A simple calculation shows that the distance between 101 grows linearly, and hence we can reconstruct Π by Lemma 35. We remark that a slight modification of the FST from Figure 18, as shown in Figure 19, would result in the (ultimately) periodic stream (010)ω which cannot be transformed back to Π. Proof of Proposition 30. Let A = )Q, q0 , δ, λ* be an FST such that Π #A σ. Define fΠ (n) as the position of the (n + 1)-th 1 in Π, that is: fΠ (n) = (n + 1) · n 2 36 INTEGERS: 11B (2011) 1|0100 0|010 q0 q1 0|100 1|10 Figure 19: FST transforming Π to a periodic stream. By the Pigeonhole Principle there exist n1 , n2 ∈ N such that |Q| < n1 < n2 , and δ(Π|<fΠ (n1 ) ) = δ(Π|<fΠ (n2 ) ), and n1 ≡ n2 mod ZA . In other words, we consider two blocks 10n1 and 10n2 in Π that the automaton A enters in the same state and whose length difference is a multiple of ZA . Let m ∈ N such that n2 − n1 = m · ZA . Note that Π|≥fΠ (n) begins with the prefix 10n (followed by a 1) for every n ∈ N. For every i ∈ N, we have n2 +i = n1 +i+m·ZA . As a consequence, by Lemma 29 together with induction on i ∈ N we obtain: δ(Π|<f (n1 +i+m·ZA ) ) = δ(Π|<f (n1 +i) ) for all i ∈ N. Define qj = δ(Π|<f (n1 +j) ) for j = 0, . . . , m · ZA . Then δ(Π|<f (n1 +j+k·m·ZA ) ) = qj for all j ∈ {0, . . . , m · ZA } and m k k ∈ N, and hence λ(qj , 10n1 +j+k·m·ZA ) = pj (vj,2 ) by Lemma 29, for suitable words ∗ pj , vj,2 ∈ 2 . m Define w = λ(Π|<f (n1 ) ) and cj = vj,2 . Then we obtain: σ=w· ∞ m·Z ! !A λ(qj , 10 n1 +j+k·m·ZA )=w· ∞ m·Z ! !A pj · ckj k=0 j=0 k=0 j=0 which proves the claim. Breaking Points of Periodicity In this section we consider non-ultimately periodic streams σ defined by: σ=w· ∞ ! n ! pj · cij (1) i=0 j=0 where n ∈ N and w, pj , cj ∈ 2∗ are finite words for j = 0, . . . , n. We show that the double product can always be rewritten to a form such that a finite state transducer reading σ can recognize the transition from one factor pj · cij to the subsequent factor pj+1 · cij+1 . The following definition allows us to unroll the first factor p0 · c00 of the inner product. Thereby the factors of the inner product get rotated, and hence we can bring every factor of the inner product to the front. 37 INTEGERS: 11B (2011) Definition 54. By unrolling we refer to the transformation from (1) to: ∞ n−1 ! ! pj+1 · cij+1 ) · p0 c0 · ci0 ) σ = w · p0 · (( ( )* + ()*+ ()*+ ()*+ ()*+ i=0 j=0 w! = w$ · p!j ∞ ! n ! c!i j p!n c!i n p$j · c$i j i=0 j=0 where w$ = w · p0 , pj = pj+1 and cj = cj+1 for 0 ≤ j < n, and p$n = p0 c0 and c$n = c0 . We present different transformations that allow us to stepwise simplify the product until it has the desired form. The next lemma, for example, allows us to ‘remove’ factors pj · cij for which cj = ε: Lemma 55. If n ≥ 1 and c0 = ε, then we have: σ=w· ∞ ! i=0 (p0 · p1 · ci1 n ! j=2 pj · cij ) = w$ · ∞ n−1 ! ! p$j · c$i j i=0 j=0 where w$ = w, p$0 = p0 · p1 , c$0 = c1 and p$j = pj+1 , c$j = cj+1 for all 0 ≤ j ≤ n − 1. We have cj $= ε for some 0 ≤ j ≤ n since otherwise σ would be ultimately periodic. Employing unrolling together with Lemma 55 we can transform (1) to a form where cj $= ε for all 0 ≤ j ≤ n. Hence, without loss of generality, we assume cj $= ε for all 0 ≤ j ≤ n in the sequel. Definition 56. An index k ∈ {0, . . . , n − 1} is said to have confusion if we have ω ω ω cω k = pk+1 · ck+1 . Likewise, index n has confusion if cn = p0 · c0 . For indexes j with confusion a finite state transducer cannot recognize the transition from the factor pj · cij to pj+1 · cij+1 . Example 57. Reconsider Example 53 where p0 = 100, c0 = 100100, p1 = 10010 ω ω and c1 = 010010. Here the index 0 has confusion since cω 0 = (100) = p1 · c1 . This ω ω ω is in contrast to the index 1 for which we have cω = (010) = $ (100) = p · 0 c0 . 1 We now work towards Lemma 60 stating that there is an index without confusion. Lemma 58. Let x, y ∈ {0, 1}+, v ∈ {0, 1}∗ such that xω = vy ω . Then for some u ∈ {0, 1}∗ we have y = uv or v = uy. Proof. From xω = vy ω it follows that x|y| xω = x|y| vy ω = vy |x| y ω . Hence we obtain x|y| v = vy |x| from |x|y| | = |x| · |y| = |y |x| |. Thus we have a word that has both v and y as a suffix, and so the claim follows. 38 INTEGERS: 11B (2011) Lemma 59. Let 0 ≤ k < n, v ∈ {0, 1}∗ and m ∈ N maximal such that vcm k+1 = pk+1 . Then k has confusion if and only if ck+1 = uv for some u ∈ {0, 1}∗ such that ck and vu are powers of the same word. ω ω ω Proof. Assume k has confusion, cω k = pk+1 ck+1 , and so ck = vck+1 . By Lemma 58 ∗ we get ck+1 = uv for some u ∈ {0, 1} (the other case v = uck+1 is excluded by |vu| ω ω ω maximality of m). Hence cω = (vu)|ck | . k = vck+1 = v(uv) = (vu) and so ck Then by the second theorem of Lyndon and Schützenberger [2, Theorem 1.5.3], ck and vu are powers of the same word. For the other direction, let ck+1 = uv for some u ∈ {0, 1}∗ such that ck and vu ω ω ω ω are powers of the same word. Hence cω k = (vu) = v(uv) = vck+1 = pk+1 ck+1 . By the following lemma, there always exists at least one index without confusion since otherwise σ would be ultimately periodic: Lemma 60. There exists an index k ∈ {0, . . . , n} without confusion. Proof. Assume that all indexes 0 ≤ k ≤ n have confusion. We show that then the stream σ would be ultimately periodic. For this purpose it suffices to show that v" ! wp0 cω 0 for every - ∈ N, where v" is the following prefix of σ: v" = w p0 c00 . . . pn c0n p0 c10 . . . pn c1n . . . p0 c"0 . . . pn c"n For 0 ≤ i ≤ n and 0 ≤ j ≤ -, let qi,j denote the suffix of v starting with pi cji , that is, qi,j = pi cji . . . pn cjn . . . p0 c"0 . . . pn c"n . We show by induction on the length of ω " qi,j that qi,j ! pi cω i . For the base case: qn," = pn cn ! pn cn . For the induction step, ω we distinguish two cases: If i < n, then as i has confusion, cω i = pi+1 ci+1 and hence j ω ω qi+1,j ! pi+1 cω i+1 = ci by the induction hypothesis, and qi,j = pi ci qi+1,j ! pi ci . In case i = n, we reason analogously. It follows that σ is ultimately periodic with period c0 . Next we show that all indexes with confusion can be removed: Lemma 61. Assume that index 0 has confusion (then n ≥ 1 by Lemma 60). Then: σ=w· ∞ n−1 ! ! p$j · c$i j i=0 j=0 where - p$0 = p0 · p1 , - p$j = pj+1 , |c |+|c1 | - c$0 is the suffix of length |c0 | + |c1 | of c1 0 - c$j = cj+1 for all 1 ≤ j ≤ n − 1. , and 39 INTEGERS: 11B (2011) Proof. Define vi = p0 · ci0 · p1 · ci1 for all i ∈ N. It suffices to show that p$0 · c$i 0 = vi . We proceed by induction on i. The base case i = 0 is trivial. For the induction step we show that vi+1 = vi c$0 holds (then by the induction hypothesis vi+1 = vi c$0 = $ $ $i+1 p$0 c$i ). 0 c0 = p 0 c0 j ω ω ω By confusion of the index 0 we have cω 0 = p1 · c1 and hence c0 = c0 · p1 · c1 for j j j j ω ω all j ∈ N. As a consequence c0 · p1 · c1 ! c0 and vj = p0 c0 · p1 · c1 ! p0 c0 for all j ∈ N. Hence vi+1 = vi · ui for some ui ∈ 2∗ . We have |ui | = |c$0 | and so it remains |c |+|c1 | to be shown that ui is a suffix of c1 0 (just like c$0 ). j i i Clearly we also have that c0 c0 p1 c1 ! p1 cω 1 for all j ∈ N. We take j such that j |c0 | > |p1 | and |cj+i | ≡ 0 (mod |c |). Hence ci0 p1 ci1 is a suffix ce1 for some e ∈ N. 1 0 |c |+|c1 | i i Since ui is a suffix of c0 p1 c1 we obtain that ui is a suffix of c1 0 . Again, employing unrolling together with Lemma 61 we can transform (1) to a form where no index 0 ≤ k ≤ n has confusion. Definition 62. By unfolding we refer to the transformation from (1) to: σ = (w · n ! pj ) · j=0 ( )* w! + ∞ ! n ! (pj · cj ) · cij ( )* + i=0 j=0 p!j where w$ and p$j are as indicated, and c$j = cj . The following lemma states that v ω = v1 · v2ω can be decided by inspecting a finite prefix of both streams: Lemma 63. Let v, v1 , v2 ∈ 2∗ such that v, v2 = $ ε. Then v ω = v1 · v2ω holds if and q p only if v ! v1 · v2 where p = |v1 | + |v2 | and q = p · |v|. Proof. Note that |v p | ≤ |v1 · v2q | by the choice of q and |v2 | ≥ 1. As a consequence, the direction ‘⇒’ follows. For ‘⇐’ let v p ! v1 · v2q . Then v p = v |v1 | · v |v2 | and v1 ! v |v1 | . We have |v |v2 | | = k · |v2 | for some k ∈ N. Consequently it follows that v |v1 | · v |v2 | ! v1 · v2ω implies v |v1 | · (v |v2 | )" ! v1 · v2ω for all - ∈ N. Using unfolding together with the bounds implied by Lemma 63 we can transω form (1) to a form where pj+1 $! cω j for all 0 ≤ k ≤ n − 1, and p0 $! cn . This immediately implies that there is no confusion. Proof of Proposition 32. Proposition 32 summarizes the results of this section. Stream Transducers and Linear Compression Note that the Definition 34 considers only non-empty words w (length |w| ≥ 1). The reason is that we employ FSTs without ε-transitions, and as a consequence, on the input of an empty word, the output is always empty. 40 INTEGERS: 11B (2011) Proof of Lemma 35. Assume a + b ≥ 0. Let b = c/d with c, d ∈ N. Define A = )Q, q0 , δ, λ* as follows. Let Q = {0, 1, . . . , d}, q0 = 0, and δ(n, x) = n + 1 for n ∈ Q \ {d} and δ(d, x) = 1 for every x ∈ 2. Moreover define: λ(0, x) = 0f (1) λ(n, x) = 0f (n+1)−f (n) for every x ∈ 2 and n ∈ Q \ {1}. For every non-empty word w we have 1 ≤ δ(w) ≤ d and δ(w) ≡ |w| mod d (follows immediately by induction on |w|). Again by induction on |w| we prove λ(w) = 0f (|w|) . For |w| = 1 the claim is trivial. Let |w| > 1. We have w = w$ x for some w$ ∈ 2∗ and x ∈ 2. Then λ(w) = λ(w$ ) λ(δ(w$ ), x) which is by induction hypothesis equivalent to 0f (|w|−1)λ(δ(w$ ), x), and we have ! ! ! ! λ(δ(w$ ), x) = 0f (δ(w )+1)−f (δ(w )) = 0f (|w |+1)−f (|w |) since f (n + 1) − f (n) = f (m + 1) − f (m) whenever n, m ≥ 1 and n ≡ m mod d. Consequently λ(w) = 0f (|w|−1) 0f (|w|)−f (|w|−1) = 0f (|w|). Let us consider the case a + b < 0. The case a < 0 and b = 0 is covered by the trivial FST consisting of only one state and empty output ε along all edges. Therefore assume a < 0 and b > 0. Let n ∈ N be minimal such that a + b · n ≥ 0. Let A$ be the FST constructed for a$ = a + b · (n − 1) and b$ = b. We define A as extension of A$ with states {q1 , . . . , qn−1 } and δ(qi , x) = qi+1 , δ(qn−1 , x) = 0 for every 1 ≤ i ≤ n, and λ(qi , x) = ε for every 1 ≤ i < n and x ∈ 2. Then after n − 1 transitions without output, the automaton A starts behaving as A$ : a + b · (n − 1 + i) = a + b · (n − 1) + b · i = a$ + b$ · i.