Computational limitations of affine automata and generalized affine automata

We present new results on the computational limitations of affine automata (AfAs). First, we show that using the endmarker does not increase the computational power of AfAs. Second, we show that the computation of bounded-error rational-valued AfAs can be simulated in logarithmic space. Third, we identify some logspace unary languages that are not recognized by algebraic-valued AfAs. Fourth, we show that using arbitrary real-valued transition matrices and state vectors does not increase the computational power of AfAs in the unbounded-error model. When focusing only the rational values, we obtain the same result also for bounded error. As a consequence, we show that the class of bounded-error affine languages remains the same when the AfAs are restricted to use rational numbers only.


Introduction
Finite automata are interesting models to study since they express a very natural limitation of finite memory. They are also an interesting starting point for many computational models, since they are simpler than many others like pushdown automata or Turing machines. Due to this simplicity, there exist many different models of finite automata, all trying to express different computational settings. Deterministic (Sipser 2013), probabilistic (Paz 1971) and quantum (Ambainis and Yakaryılmaz 2015) finite automata (DFAs, PFAs, and QFAs, respectively) have been studied to try to understand better the computational limitations inherent to all these cases.
Recently, Díaz-Caro and Yakaryılmaz introduced a new computational concept, called affine computation (Díaz-Caro and . As a non-physical model, the goal of affine computation is to investigate the power of interference caused by negative amplitudes in the computation, like in the quantum case. But unlike QFAs, affine finite automata (AfAs) have unbounded state set and the final operation corresponding to quantum measurement cannot be interpreted as linear. The final operation in AfAs is analogous to renormalization in Kondacs-Watrous (Kondacs and Watrous 1997) or Latvian (Ambainis et al. 2006) quantum automata models.
AfAs and their certain generalizations have been investigated in a series of works by Díaz-Caro and , Villagra and Yakaryılmaz (2018), Belovs et al. (2017), Hirvensalo et al. (2017), Nakanish et al. (2017), Ibrahimov et al. (2018). In most of the cases, affine models (e.g., bounded-error and unbouded-error AfAs, zero-error affine OBDDs, zero-error affine counter automata, etc.) have been shown more powerful than their classical or quantum counterparts. On the other hand, we still do not know too much regarding the computational limitations of AfAs. Towards this direction, we present new results. First, we show that using end-marker does not increase the computational power of affine automata with unbounded error or bounded error. Second, we show that the computation of bounded-error rational-valued affine automata is simulated in logarithmic space, and so we answer positively one of the open problems in Díaz-Caro and . Third, we give an impossibility result for algebraic-valued AfAs, and, as a result, we identify some unary languages (in logarithmic space) that are not recognized by algebraic-valued AfAs with cutpoints, improving a previous result showing that the same languages cannot be recognized with bounded error (Hirvensalo et al. 2017).
Moreover, we give the formal definition of generalized AfAs by allowing to use arbitrary real-valued transition matrices and state vectors. Fourth, we show that such generalization does not increase the computational power of AfAs with cutpoint language recognition. If we restricted these generalized AfAs to use only rational numbers, we obtain the same result also for bounded error language recognition. As a consequence, we show that the class of bounded-error affine languages remains the same when the AfAs are restricted to use rational numbers or only integers.
We provide all definitions in the next section and our results regarding using end-marker in Sect. 2.4. Our logarithmic space simulation is given in Sect. 3. Our impossibility result is given in Sect. 4. Our results related to generalized AfAs are given in Sect. 5.
A preliminary version of this paper was presented in UCNC2019 (Hirvensalo et al. 2019). In this version, Sects. 2.4 and 5 are completely new.

Preliminaries
Throughout the paper, R denotes the input alphabet -not containing letter $ (we fix it as the right end-marker wherever it is used) , and e R ¼ R [ f$g. The empty word is represented as e. The set of all words defined on the alphabet R is denoted R Ã . For any given word w 2 R Ã , |w| is the length of w, we definew ¼ w$, and, if w 6 ¼ e, w i represents its i-th letter, where 1 i jwj.
For any given class C, C Q and C A denote the classes defined by the machines restricted to have rational-valued and algebraic-valued components, respectively. The logarithmic and polynomial space classes are denoted as L and PSPACE, respectively. We assume that the reader is familiar with the basic notions of automata theory.

Models
As a probability distribution (also known as a stochastic vector) we understand a (column) vector with nonnegative entries summing up to one, and a stochastic matrix (also known as a Markov matrix) here stands for a square matrix whose all columns are probability distributions.
A k-state probabilistic finite automaton (PFA) P over alphabet R is a triplet P ¼ ðx; fM i j i 2 Rg; yÞ where x 2 R k is a stochastic vector called initial distribution, each M i 2 R kÂk is a stochastic matrix, and y 2 f0; 1g k is the final vector (each 1 in y represents an accepting state).
For any input word w 2 R Ã with length n, P has a probability distribution of states as follows: The accepting probability corresponds to the probability of P being in an accepting state after reading w, which is given by Affine finite automaton (AfA) is a generalization of PFA allowing negative transition values. Only allowing negative values in the transition matrices does not add any power (generalized PFAs are equivalent to usual ones, see Turakainen (1969)), but affine automata introduce also a nonlinear behaviour. The automaton acts like a usual generalized probabilistic automaton until the last operation, which is a non-linear operation called a weighting operation.
A vector v 2 R k is an affine vector if and only if its coordinates sum up to 1. A matrix M is an affine matrix if and only if all its columns are affine vectors. It is easy to verify that the multiplication of an affine matrix with an affine vector is also an affine vector, which ensures that affine automata are well defined.
A k-state AfA A over alphabet R is a triplet A ¼ ðx; fM i ji 2 Rg; FÞ; where x is an initial affine vector, each M i is an affine transition matrix, and The value computed by an affine automaton can be defined most conveniently via the following notation: jvj ¼ P i jv i j stands for the usual L 1 norm. The final value of the affine automaton A is Clearly f A ðwÞ 2 ½0; 1 for any input word w 2 R Ã . Remark that the final value for PFAs (1) is defined as matrix product v f 7 !y T v f , which is a linear operation on v f . On the other hand, computing final value from v f as in (2) involves nonlinear operations v f 7 ! jFv f j jv f j such as L 1 -norm and normalization (division).

Language recognition
Given a function f : R Ã ! ½0; 1 computed by an automaton (stochastic or affine), there are different ways of defining the language recognized by this automaton. A language L R Ã is recognized by an automaton A with cutpoint k 2 ½0; 1Þ if and only if L ¼ fw 2 R Ã j f A ðwÞ [ kg: These languages are called cutpoint languages.
A language L R Ã is recognized by an automaton A with exclusive cutpoint k 2 ½0; 1 if and only if L ¼ fw 2 R Ã j f A ðwÞ 6 ¼ kg: These languages are called exclusive cutpoint languages.
A stronger condition is to impose that accepted and rejected words are separated by a gap: the cutpoint is said to be isolated. A language L is recognized by an automaton A with isolated cutpoint k if and only if there exist d [ 0 such that 8w 2 L; f A ðwÞ ! k þ d and 8w 6 2 L; f A ðwÞ k À d. By fixing k ¼ 1 2 , we define language recognition with bounded error: A language L is recognized by an automaton A with bound error if and only if there exists an error bound 2 ½0; 1=2Þ such that 8w 2 L, f A ðwÞ ! 1 À and 8w 6 2 L, f A ðwÞ .
It is known that if a language recognized by a AfA (or PFA) with bounded error, then the error bound can be arbitrarily close to 0 (Hirvensalo et al. 2017).

Language classes
In the case of probabilistic (resp., affine automata), the set of cutpoint languages are called stochastic languages (resp., affine languages) and denoted by SL (resp., AfL). We remark that fixing the cutpoint in the interval (0, 1) does not change the classes SL and AfL (Paz 1971;Díaz-Caro and Yakaryılmaz 2016).
The set of languages recognized with bounded error (or isolated cutpoint, which is the same) by affine automata is denoted by BAfL.
A classical result by Rabin (1963) shows that isolated cutpoint stochastic languages are regular. Rabin's proof essentially relies on two facts: 1) the function mapping the final vector into [0, 1] is a contraction, and 2) the state vector set is bounded. By modifying Rabin's proof, it is possible to show that also many quantum variants of stochastic automata obey the same principle (Ambainis and Yakaryılmaz 2015): bounded-error property implies the regularity of the accepted languages. In fact, E. Jeandel generalized Rabin's proof by demonstrating that the compactness of the state vector set together with the continuity of the final function are sufficient to guarantee the regularity of the accepted language if the cutpoint is isolated (Jeandel 2007). Affine automata do not have these properties, and in fact, they can recognize more than regular languages with bounded error (Díaz-Caro and Yakaryılmaz 2016).

Models using the right end-marker
A PFA or AfA can be defined by reading an extra letter (M $ ) for post-processing after reading the whole input. That is, the automaton readsw ¼ w$ for a given input word w 2 R Ã . Any such AfA (the definition of any such PFA is similar) can be formally defined as A ¼ ðx; fM i j i 2 e Rg; FÞ, and the accepting probability of the input w is calculated as It is known that, for any k-state PFA using the right endmarker, there is an equivalent k 2 -state PFA without using the right end-marker such that, for any input word, both automata have the same accepting probabilities (Turakainen 1969). Even though we do not know whether this result is valid for AfAs or not, we can still show that post-processing does not increase the computational power of AfAs in the case of recognition with cutpoint or bounded error.
Theorem 1 For a given k-state AfA A ¼ ðx; fM i j i 2 e Rg; FÞ using the end-marker and for a given cutpoint k 2 ½0; 1, there is a 4k-state AfA A 0 ¼ ðx 0 ; fM 0 i j i 2 Rg; F 0 Þ not using the end-marker such that, for any w 2 R Ã , both of f A ðwÞ and f A 0 ðwÞ are greater than k or equal to k or less than k.
It is clear that the summation of entries are 1 and so v 0 0 is an affine state. For any i 2 R, M 0 i is defined as Computational limitations of affine automata and generalized affine automata 261 It is easy to see that the entry summation of each column of M 0 i is equal to 1, and so M 0 i is an affine transition matrix. The multiplication of transition matrices with state vectors is trivial, and so we can easily obtain that Then, we can calculate f A 0 ðwÞ as follows: Corollary 1 Any language recognized by an AfA using the right end-marker with a cutpoint (or an exclusive cutpoint) can be recognized by another AfA not using the right endmarker with the same cutpoint.
Theorem 2 Any language L recognized by a k-state AfA A ¼ ðx; fM i j i 2 e Rg; FÞ using the right end-marker with error bound 1 10 can be recognized by a 3k-state AfA A 0 ¼ ðx 0 ; fM i j i 2 Rg; F 0 Þ not using the right end-marker with error bound 2 10 . Proof We use the same terminology in the previous proof. Let m 0 ¼ jxj and let m [ 1 be a real number satisfying jM i vj\mjvj for any i 2 R and for any affine vector v.
Let w 2 R Ã be an input of length n ! 0. We define A . We know that jv n j\m 0 m n . The accepting probability of A 0 on w is If w 6 2 L, then 10jFv f j jv f j and Therefore, L is recognized by A 0 with error bound 2 10 . h 3 Logarithmic simulation Macarie (1998) proved that SL ¼ Q L and SL Q L. That is, the computation of any rational-valued probabilistic automaton can be simulated by an algorithm using only logarithmic space. However, this logarithmic simulation cannot be directly generalized for rational-valued affine automata due to the non-linearity of their last operation. In order to understand why, we will first reproduce the proof.
The problem of recovering x from the residue representation ððx mod n 1 Þ; . . .; ðx mod n r ÞÞ is practically resolved by the following well-known theorem.
Remark 1 The Chinese Remainder Theorem implies that the integer ring operations ðþ; ÁÞ can be implemented using the residue representation, and that the integers can be uncovered from the residue representations provided that 1) n ¼ ðn 1 ; . . .; n r Þ consists of pairwise coprime integers and 2) the integers stay in interval of length N À 1, where Remark 2 In order to ensure that n ¼ ðn 1 ; . . .; n r Þ consists of pairwise coprime integers, we select numbers n i from the set of prime numbers. For the reasons that will become obvious later, we will however omit the first prime 2.
Definition 2 p r is an r-tuple p r ¼ ð3; 5; 7; . . .; p r Þ consisting of r first primes by excluding 2. For this selection, a consequence of the prime number theorem is that, asymptotically, P r ¼ 3 Á 5 Á 7 Á Á Á Á Á p r ¼ 1 2 e ð1þoð1ÞÞr ln r . Definition 3 Let p r be as before. Then for any integer x, the residual representation Res p r ðxÞ stands for an integer vector of the residues: ðxðmod 3Þ; xðmod 5Þ; xðmod 7Þ; . . .; xðmod p r ÞÞ.
We remind that, for any input word w ¼ w 1 Á Á Á w n 2 R Ã , we have Since each M i 2 Q kÂk , there exists an integer D such that all entries of each matrix M 0 i ¼ DM i are integers, and (4) can be rewritten as ; and the language L can be characterized as Since the original matrices M i are stochastic, meaning that their entries are in [0, 1], it follows that each matrix M 0 i ¼ DM i has integer entries in [0, D]. Moreover, f P ðwÞ 2 ½0; 1 implies that f P 0 ðwÞ 2 ½0; D n for every input word w 2 R n . As now f P 0 ðwÞ can be computed by multiplying k Â k integer matrices, the residue representation will serve as a space-saving technique.
We will fix r later, but the description of the algorithm is as follows: For each entry p of p r ¼ ð3; 5; 7; . . .; p r Þ, we let As all the products are computed modulo p, k 2 log p bits are needed to compute (6). Likewise, ðD n mod pÞ can be computed in space Oðlog pÞ for each coordinate p of p r . The comparison 2f P 0 ðwÞ D n ðmod pÞ can be hence done in Oðlog pÞ space. Reusing the space, the comparison can be made sequentially for each coordinate of p r , and if any comparison gives a negative outcome, we can conclude that 2P 0 ðwÞ 6 ¼ D n .
To conclude the proof, it remains to fix r so that both 2f P 0 ðwÞ and D n are smaller than P r ¼ 3 Á 5 Á 7 Á Á Á Á Á p r . If no congruence test is negative, then the Chinese remainder theorem ensures that 2f P 0 ðwÞ ¼ D n . Since f P 0 ðwÞ D n , we need to select r so that P r [ 2D n ; which is equivalent to This inequality is clearly satisfied with r ¼ n for large enough n, and for each n ! 1 by choosing r ¼ c Á n, where c is a positive constant (depending on D). As a final remark let us note that p bcnc , the bcnc-th prime, can be generated in logarithmic space and the prime number theorem implies that Oðlog nÞ bits are enough to present p bcnc , since c is a constant. h To extend the above theorem to cover SL Q as well, auxiliary results are used.
Lemma 1 (Macarie 1998) If N is an odd integer and x, y 2 ½0; N À 1 are also integers, then x ! y iff x À y has the same parity as ððx À yÞ mod NÞ.
Proof As x, y 2 ½0; N À 1, it follows that & which shows that the parity changes in the latter case since N is odd. h The problem of using the above lemma is that, in modular computing, numbers x and y are usually known only by their residue representations Res p r ðxÞ and Res p r ðyÞ, and it is not straightforward how to compute the parity from the modular representation in logarithmic space. Macarie solved this problem not only for parity but also for a more general modulus (not necessarily equal to 2).
Lemma 2 (Claim modified from Macarie (1998)) For any integer x and modulus p r ¼ ð3; 5; 7; . . .; p r Þ, there is a deterministic algorithm that given Res p r ðxÞ and M 2 Z as input, produces the output xðmod MÞ in space Oðlog p r þ log MÞ.
Computational limitations of affine automata and generalized affine automata 263 As a corollary of the previous lemmata, Macarie presented a conclusion which implies the logarithmic space simulation of rational stochastic automata.
Proof The equality test can be done as in the proof of Theorem 4, testing the congruence sequentially for each prime. Testing x ! y is possible by Lemmata 1 and 2: First compute Res p r ðzÞ ¼ Res p r ðxÞ À Res p r ðyÞðmod p r Þ, then compute the parities of x, y, z using Lemma 2 with M ¼ 2. h The following theorem is a straightforward corollary from the above: Theorem 5 SL Q L.
When attempting to prove an analogous result to affine automata, there is at least one obstacle: computing the final value includes the absolute values, but the absolute value is not even a well-defined operation in the modular arithmetic.
For example, 2 À3ðmod 5Þ, but 2 j j 6 À3 j jðmod 5Þ. This is actually another way to point out that, in the finite fields, there is no order relation compatible with the algebraic structure.
Hence for affine automata with matrix entries of both signs, another approach must be adopted. One obvious approach is to present an integer n as a pair ð n j j; sgnðnÞÞ, and apply modular arithmetic to n j j. The signum function and the absolute value indeed behave smoothly with respect to the product, but not with the sum, which is a major problem with this approach, since to decide the sign of the sum requires a comparison of the absolute values, which seems impossible without having the whole residue representation. The latter, in its turn seems to cost too much space resources to fit the simulation in logarithmic space.
Hence the logspace simulation for automata with matrices having both positive and negative entries seems to need another approach. It turns out that we can use that introduced by Turakainen already in 1969 (Turakainen 1968(Turakainen , 1969.
Proof For a given alphabet R, let L 2 R Ã be a language in AfL Q and A ¼ ðx; fM i j i 2 Rg; FÞ be a k-state rationalvalued AfA over R such that For each M i 2 Q kÂk , we define a new matrix as where c i , d i , and e i are chosen so that the column and row sums of B i are zero. We define x 0 ¼ 0 x 0 0 @ 1 A as the new initial state. For the projection matrix F, we define an extension It is straightforward to see that B w x 0 j j¼ M w x j j as well as F 0 B w x 0 j j¼ FM w x j j. For the next step, we introduce an ðk þ 2Þ Â ðk þ 2Þ matrix E, whose each element is 1. It is then clear that where m 2 Z is selected large enough to ensure the nonnegativity of the matrix entries of each C i . It follows that Similarly, which can further be modified by expanding the denominators away: For an integer g large enough all matrices D i ¼ gC i will be integer matrices and the former equation becomes Hence the inequality In order to verify inequality (8) in logarithmic space, it is sufficient to demonstrate that the residue representations of both sides can be obtained in logarithmic space. For that end, the residue representation of vector a ¼ F 0 D w x 0 2 R kþ2 can be obtained in logarithmic space as in the proof of Theorem 4.
Trivially, the residue representation of b ¼ m w j j ðk þ 2Þ w j jÀ1 g w j jþ1 F 0 Ex 0 2 R kþ2 can be found in logarithmic space, as well. In order to compute the residue representation of it is sufficient to decide whether a i ! b i holds. As the residue representations for each a i and b i is known, all the decisions can be made in logspace, according to Lemma 3. The same conclusion can be made for the right hand side of (8). h

A Non-affine Language
As we saw in the previous section, AfL Q L, and hence languages beyond L, are good candidates for non-affine languages. 1 In this section, we will however demonstrate that the border of non-affinity may lie considerably lower: There are languages in L which are not affine.
In an earlier work (Hirvensalo et al. 2017), we applied the method of Turakainen (1981) to show that there are languages in L which however are not contained in BAfL. Here we will extend the previous result to show that those languages are not contained even in AfL A .
Definition 4 (Lower density) Let L a Ã be a unary language. We call lower density of L the limit densðLÞ ¼ lim inf n!1 fa k 2 Ljk ng n þ 1 : Definition 5 (Uniformly distributed sequence) Let ðx n Þ be a sequence of vectors in R k and I ¼ ½a 1 ; b 1 Þ Â Á Á Á Â ½a k ; b k Þ be an interval in R k . We define C(I, n) as CðI; nÞ ¼ fx i mod 1 2 Ij1 i ng j j .
We say that ðx n Þ is uniformly distributed mod 1 if and only if for any I of such type, lim n!1 CðI; nÞ n ¼ ðb 1 À a 1 Þ Á Á Á ðb k À a k Þ: Theorem 7 If L a Ã satisfies the following conditions: 1. densðLÞ ¼ 0. 2. For all N 2 N, there exists r 2 N and an ascending sequence ðm i Þ 2 N such that a rþm i N L and for any irrational number a, the sequence ðr þ m i NÞa ð Þis uniformly distributed mod 1.

Then L is not in AfL
Proof Let's assume for contradiction that L 2 AfL A . Then there exists an AfA A with s states, matrix M and initial vector v such that the acceptance value of A is Without loss of generality, we can assume that the cutpoint equals to 1 2 , and hence w 2 L , f A ðwÞ [ 1 2 : Using the Jordan decomposition M ¼ PJP À1 , one has M n ¼ PJ n P À1 . So the coordinates of M n v have the form where k k are the eigenvalues of M and p jk are polynomials of degree less than the degree of the corresponding eigenvalue. For short, we denote FðnÞ ¼ f A ða n Þ, and let k k ¼ k k j je 2iph k . When studying expression (9), we can assume without loss of generality, that all numbers h k are irrational. In fact, replacing matrix M with aM, where a 6 ¼ 0 does not change (9), since Computational limitations of affine automata and generalized affine automata 265 By restricting to an arithmetic progression n ¼ r þ mN (m 2 N) we can also assume that no k i =k j is a root of unity for i 6 ¼ j. In fact, selecting N ¼ lcmfordðk i =k j Þ j i 6 ¼ j and k i =k j is a root of unityg; ð11Þ equation (10) becomes where fl 1 ; . . .; l s 0 g are the distinct elements of set fk N 1 ; . . .; k N s g Now for i 6 ¼ j l i =l j cannot be a root of unity, We can now write the acceptance condition f A ða n Þ [ 1 2 equivalently as Where E is the set of states of A, E a E its set of accepting states, and E a the complement of E a . According to (10), gðnÞ :¼ P j2E a ðM n vÞ j À P j2E a ðM n vÞ j consists of combinations of absolute values of linear combination of functions of type n d k n . We say that n d 1 k n 1 is of larger order than n d 2 k n 2 , if k 1 j j[ k 2 j j; and in the case k 1 j j ¼ k 2 j j, if d 1 [ d 2 . If k 1 j j ¼ k 2 j j, we say that n d k n 1 and n d k n 2 and of the same order. It is clear that if term t 1 ðnÞ is of larger order than t 2 ðnÞ, then lim n!1 t 2 ðnÞ t 1 ðnÞ ¼ 0.
We can organize the terms in expression (10) as (for notational simplicity, we mostly omit the dependency on j in the right hand side of (14)). Here k m 2 R þ is the common absolute value of all eigenvalues k mk ¼ k m e 2pih mk , and expression (13) is organized in descending order: K ðNÞ j is the sum of terms of the highest order multiplier, K ðNÀ1Þ j contains the terms of the second highest order multiplier, etc. We say that K ðk 2 Þ j is lower than K ðk 1 Þ j if k 2 \k 1 : We will then fix a representation where A j ðnÞ þ B j ðnÞ þ C j ðnÞ is a grouping of all K-terms in (13) defined as follows: sen as the maximal number so that is a constant function N ! R. Such an m exists, since for m ¼ À1, the sum is regarded empty and A j ðnÞ ¼ 0, but for m ¼ N, all K-terms are included, and then (16) becomes f A ða n Þ, which is not constant (otherwise condition 1 or 2 of the theorem would be false). 2. B j ðnÞ consists a single K-term immediately lower than those in A j ðnÞ, and 3. C j ðnÞ contains the rest of the K-terms, lower than B j ðnÞ We choose k 2 R þ and d so that the highest K-term in B(n) is of order n d k n and define A 0 j ðnÞ ¼ n Àd k Àn A j ðnÞ, B 0 j ðnÞ ¼ n Àd k Àn B j ðnÞ, g 0 ðnÞ ¼ gðnÞn Àd k Àn . Then clearly g 0 ðnÞ [ 0 if and only if gðnÞ [ 0 and each B j ðnÞ remains bounded as n ! 1. To simplify the notations, we omit the primes and recycle the notations to have a new version of g(n) of (15) where A j -terms may tend to infinity but B jterms remain bounded.
Recall that we may assume (by restricting to a arithmetic progression) that no k i =k j is a root of unity. By Skolem-Mahler-Lech theorem (Hansel 1986), this implies that functions A j can have only a finite number of zeros, and in the continuation we assume that n is chosen so large that no function A j becomes zero. Furthermore, by the main theorem of Evertse (1984), then A j ðnÞ ¼ Xðn d k nÀ Þ for each [ 0. 3 As each B j remains bounded, we find that B 2 j =A j tend to zero as n ! 1, and hence by Lemma 4, defining we have a function g 1 ðnÞ with the property g 1 ðnÞ À gðnÞ ! 0 (C-terms are lower than B-terms, so they can be dropped without violating this property), when n ! 1. Also by the construction it is clear that hðnÞ ¼ C Á n d k n , where C is a constant, and by the conditions of the theorem, this is possible only if C ¼ 0.
Notice tat g 1 ðnÞ is not a constant function by construction. Also, each B j is a linear combination of functions of form e 2pih k n , each h k can be assumed irrational, and jjA j ðnÞjjA j ðnÞ ¼ 1, so we can conclude that g 1 ðnÞ is a continuous function formed of terms of form ce ih k n and of ratios A j =A j . In these terms, however the behaviour is asymptotically determined by the highest K-terms, so the conclusion remains even if we drop the lower terms.
By assumption, for all k, the sequence ðr þ mNÞh k is uniformly distributed modulo 1. It follows that the values e 2ipðrþmNÞh k are dense in the unit circle. If for some m, g 1 ðr þ mNÞ\0, then g 1 ðr þ NmÞ À e for some [ 0. Then, because of the density argument, there are arbitrarily large values of i for which g 1 ðr þ m i NÞ 0 contradicting condition 2 of the statement. Hence g 1 ðr þ mNÞ ! 0 for each m large enough. As g 1 is not a constant, there must be some m 0 so that g 1 ðm 0 Þ ! [ 0.
Next, let Rðx 1 ; . . .; x s Þ be a function obtained from g 1 by replacing each occurrence of e ih k n by a variable x k , hence each x k will assume its value in the unit circle. Moreover, by the assumptions of the theorem, the values of x k will be uniformly distributed in the unit circle.
Note that g 1 ðnÞ ¼ Rððe 2ipðrþm i NÞh k Þ k2A Þ. Then, because the sequences ððr þ m i NÞh k Þ i are uniformly distributed modulo 1, it follows that any value obtained by the function Rððe 2ipy k Þ k2A Þ can be approximated by some g 1 ðr þ m i MÞ with arbitrary precision. The function R is continuous, therefore there exists an interval I ¼ Corollary 3 The language fa p jp is primeg is not in AfL A .
Proof of Corollary 2 and Corollary 3 Turakainen proved that these two languages satisfies the two conditions of Theorem 7 (Turakainen 1981). Therefore, these two languages not in AfL A . h

Generalized affine automata
In this section, we show that using arbitrary real state vector and transition matrices does not increase the computational power of AfAs. A generalized affine finite automaton (GAfA) is a 3-tuple G ¼ ðx; fM i ji 2 e Rg; FÞ; where, different from an AfA, fM i ji 2 e Rg is the set of realvalued transition matrices without any restriction on the column summations and x is the real-valued initial state vector. The final affine state of G on the given input w 2 R Ã for some n ! 0 is where M e ¼ I. It must be guaranteed that at least one entry of v f is non-zero for any possible input. The accepting probability of G on w is calculated in the same way of an We start with proving that GAfAs with cutpoint define the same class of languages as AfAs with cutpoint.
Theorem 8 Any language L recognized by a k-state GAfA G ¼ ðx; fM i ji 2 e Rg; FÞ with cutpoint k 2 ½0; 1Þ is recognized by a ðk þ 2Þ-state AfA A ¼ ðx 0 ; fM i ji 2 e Rg; F 0 Þ with cutpoint k.
For letter i 2 R, let c j be the j-th column summation of M i and d j ¼ 1 À c j . We define M 0 i based on M i : where each column summation is 1. Then, we can calculate v 0 f , for a given input w 2 R Ã , as Then the accepting probability of w by A is Thus, both of f G ðwÞ and f A ðwÞ are greater than k or equal to k or less than k. h Remark that when the cutpoint is 0, then the constructed AfA can indeed use one state less in the above proof.
We can obtain the same result for bounded error case when focusing on the rational numbers. First we show that there is no difference between using rational numbers and integers.
Lemma 5 For any given GAfA G 1 ¼ ðx; fM i ji 2 e Rg; FÞ with rational number components, there is a GAfA G 2 with integer number components such that they have the same accepting probability on any input string.
Proof Let z be sufficiently big integer such that zM i for each i 2 R and zx contains only integers. Then, G 2 is defined as ðzx; fzM i ji 2 e Rg; FÞ. Due to linearity, if the final vector of G 1 on a given input w 2 R Ã is v f , then, the final vector of G 2 on a any given input is z jwjþ1 v f . Thus, Theorem 9 Any language L recognized by a k-state GAfA G ¼ ðx; fM i ji 2 e Rg; FÞ with bounded error can be recognized by a ð2k þ 1Þ-state AfA A ¼ ðx 0 ; fM 0 i ji 2 e Rg; F 0 Þ with bounded error, where both automata have only integer components.
Proof Let 1 2 À 1 m for m ! 2 be the error bound and w 2 R Ã be the given input. We A , and for letter $, we define r ¼ jv f j À a. Remark that a and r can be only non-negative integers. The accepting probability of A on w is f A ðwÞ ¼ 2m 2 a 2m 2 a þ 2m 2 r þ 1 ð17Þ since we have two copies of v f where one is multiplied by m 2 and the other is multiplied by Àm 2 . For any w 6 2 L, it is straightforward that f A ðwÞ ¼ 2m 2 a 2m 2 a þ 2m 2 r þ 1 2m 2 a 2m 2 a þ 2m 2 r ¼ a a þ r ¼ f G ðwÞ: In the remaining part, we focus on only the members: w 2 L and a aþr ¼ 1 2 þ c for some 1 2 ! c ! 1 m . From the equation of f G ðwÞ; we can obtain a þ r ¼ 2a 1þ2c and we can substitute a þ r with 2a 1þ2c in equation (17): 4m 2 a 1þ2c þ 1 ¼ ð1 þ 2cÞ2m 2 a 4m 2 a þ 2c þ 1 ¼ ð1 þ 2cÞð2m 2 a þ c þ 1 2 À c À 1 2 Þ 4m 2 a þ 2c þ 1 : After simplification, we have þ 1Þ 2 8m 2 a þ 4c þ 2 : We know that a ! 1 (a 6 ¼ 0 for w 2 L) and c 1 2 . Thus, we can easily follow that ð2c þ 1Þ 2 8m 2 a þ 4c þ 2 \ 4 8m 2 ¼ 1 2m 2 : Hence, we can bound the accepting probability of any member from below as Since there is a constant gap for every member, we conclude that A recognizes L with bounded error. h Villagra and Yakaryılmaz (2016), showed that one-sided error (either all members are accepted with probability 1 or all non-members are accepted with probability 0) versions of BAfL are the identical if they are defined by AfAs with rational number components or by AfAs with integer components. By using the above results, we can follow that the same result is valid also for (two-sided error class) BAfL.
Funding Open access funding provided by University of Turku (UTU) including Turku University Central Hospital..
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons. org/licenses/by/4.0/.