The descriptional power of queue automata of constant length

We consider the notion of a constant length queue automaton—i.e., a traditional queue automaton with a built-in constant limit on the length of its queue—as a formalism for representing regular languages. We show that the descriptional power of constant length queue automata greatly outperforms that of traditional finite state automata, of constant height pushdown automata, and of straight line programs for regular expressions, by providing optimal exponential and double-exponential size gaps. Moreover, we prove that constant height pushdown automata can be simulated by constant length queue automata paying only by a linear size increase, and that removing nondeterminism in constant length queue automata requires an optimal exponential size blow-up, against the optimal double-exponential cost for determinizing constant height pushdown automata. Finally, we investigate the size cost of implementing Boolean language operations on deterministic and nondeterministic constant length queue automata.


Introduction
It is well known that the computational power of computing devices can be tuned by restricting the way they access memory. To catch a glimpse of this phenomenon, one may start from the traditional model of a one-way Turing machine equipped with a potentially unbounded and freely accessible working tape representing memory. If we impose a lifo usage of the working tape, still keeping unboundedness, then we obtain a pushdown automaton, whose computational power is strictly lower than that of a one-way Turing machine. Instead, by imposing a fifo memory access policy, we get a queue automaton, whose computational power gets back to that of a one-way Turing machine. However, for all these (and other) models, by fixing a constant 1 -i.e., not depending on the input length-bound on the amount of available memory, we have that their computational power boils down to that of finite state automata, regardless of the memory access policy in use.
For constant memory machines, it is then worth investigating how the memory access policy affects their descriptional power, that is, their capability of succinctly representing regular languages. (We refer the reader to, e.g., [19] for a thoughtful survey on descriptional complexity theory.) This line of research is settled in [17], where the notion of a constant height pushdown automaton is introduced and studied from a descriptional complexity perspective. Roughly speaking, a constant height pushdown automaton is a traditional pushdown automaton with a built-in constant limit on the height of the pushdown. Optimal exponential and double-exponential gaps are proved, between the size of constant height deterministic and nondeterministic pushdown automata (dpdas and npdas, respectively) and the size of equivalent deterministic and nondeterministic finite state automata (dfas and nfas, respectively) and classical regular expressions. Moreover, the notion of a straight line program for regular expressions (slp, see Sect. 2) is also introduced in [17], as a formalism equivalent to a constant height npda from a size point of view. In [5], the fundamental problem of removing nondeterminism in constant height npdas is tackled, and a double-exponential size blow-up for determinization is emphasized. Finally, the size cost of boolean operations on constant height dpdas and npdas is analyzed in [3,4,6].
In this paper, we investigate the descriptional advantages of replacing the pushdown with a queue storage of fixed size, by considering the notion of a constant length queue automaton. Basically, this device is a traditional queue automaton (see, e.g., [2,14]), in which the length of the queue cannot grow beyond a fixed constant limit.
As for constant height pushdown automata, in Sect. 3 we single out optimal exponential and double-exponential gaps between the size of constant length deterministic and nondeterministic queue automata (dqas and nqas, respectively) and the size of equivalent dfas and nfas. In addition, differently from constant height pushdown automata, in Sect. 4 we prove that a queue storage enables a size-efficient removal of nondeterminism. Precisely, we show that nfas can be simulated by constant length dqas paying by only a linear size increase. This, in turn, leads us to prove that the optimal size cost of removing nondeterminism in constant length nqas is only exponential, in sharp contrast with the optimal double-exponential size blow-up above pointed out for determinizing constant height npdas.
The higher descriptional power of a queue vs. a pushdown storage for constant memory machines is also emphasized in Sect. 5, where we show that constant height npdas (resp., dpdas) can be simulated by constant length nqas (resp., dqas), paying by only a linear size increase. On the other hand, the opposite simulation features an optimal exponential size cost. This is witnessed by proving, in Sect. 6, that constant length dqas can be exponentially smaller than equivalent slps, this gap being optimal. In Sect. 7, a complete overview on the optimal simulation size costs between finite state automata, constant height pushdown automata, constant length queue automata, and straight line programs is portrayed for reader's convenience. In Sect. 8, as typically done in the literature for formalisms defining regular languages (see, e.g., [3,4,6,16,19,[22][23][24]), the problem of establishing the size cost of implementing boolean language operations on constant length dqas and nqas is tackled. As a useful tool in this investigation, analogously to what is done for constant height pushdown automata [3][4][5][6]17], a normal form for constant length queue automata is defined, where at most one symbol is enqueued on each move. The size cost of converting constant length queue automata into their normal form is analyzed. Finally, in Sect. 9, we sum up obtained results and provide possible developments of our work.

Preliminaries: adding memory to finite state automata
We assume the reader is familiar with basics in formal language theory, and we refer to, e.g., [18,20] for an extensive presentation of the topic. The set of all words (including the empty word ε) on a finite alphabet Σ is denoted by Σ * . The length of a word w ∈ Σ * is denoted by |w|, and we let Σ i be the set of words on Σ of length i ≥ 0 (with Σ 0 = {ε}). Moreover, Finite state automata. A nondeterministic finite state automaton (nfa, see, e.g., [18,20]) is formally defined as a 5-tuple A = Q, Σ, δ, q 0 , F , where Q is the finite set of states, Σ the finite input alphabet, q 0 ∈ Q the initial state, F ⊆ Q the set of final, or accepting, states, and δ is the transition function mapping Q × (Σ ∪ {ε}) to finite subsets of Q. The computation of A on an input string x = σ 1 σ 2 · · · σ n ∈ Σ * begins in the initial state q 0 by scanning the first input symbol σ 1 . Next, the rules established by the transition function δ are subsequently applied. An application of δ is called move. An input string is accepted, if there exists a computation beginning in the state q 0 and ending in some final state q ∈ F after reading the entire input. If such a computation does not exist, then the input string is rejected. The set of all inputs accepted by A is denoted by L(A) and called the accepted language. The automaton A is deterministic (dfa), if there are no ε-transitions in δ and, for every q ∈ Q and a ∈ Σ, we have |δ(q, a)| ≤ 1.
The other two computational models we shall be dealing with can be obtained by equipping finite state automata with some auxiliary memory storage. Depending on whether such memory is used in a lifo-or fifo-mode, we have pushdown or queue automata, respectively. In particular, we will be interested in the case in which the auxiliary memory storage has a fixed constant size (not depending on input length). Constant height pushdown automata. A nondeterministic pushdown automaton (npda, see, e.g., [18,20]) is formally defined as a 7-tuple A = Q,Σ, Γ , δ, q 0 , ⊥, F , where Q, Σ, q 0 and F are defined as for nfas, Γ is the pushdown alphabet, ⊥ ∈ Γ is the initial symbol in the pushdown store, and the transition function δ maps Q × (Σ ∪ {ε}) × Γ to finite subsets of Q × Γ * . At any time, the pushdown content may be represented by a string where the leftmost symbol is the top of the pushdown, while the rightmost is its bottom. Let δ(q, σ, X ) ( p, γ ). Then A, being in the state q, reading the input symbol σ and the pushdown symbol X on the top of the pushdown, can reach the state p, replace X by γ , and finally advance input scanning to the next input symbol only if σ = ε. An input string is accepted, if there exists a computation beginning in the state q 0 with ⊥ in the pushdown, and ending in some final state q ∈ F after reading the entire input. The set of all inputs accepted by A is denoted by L(A). The automaton A is deterministic (dpda), if for any q ∈ Q, σ ∈ Σ ∪ {ε} and X ∈ Γ , we have |δ(q, σ, X )| ≤ 1, and if δ(q, ε, X ) is defined then |δ(q, a, X )| = 0 for any a ∈ Σ.
A constant height npda [17] is obtained from a traditional npda by imposing that the pushdown store can never contain more than h pushdown symbols, for a fixed constant h ≥ 0 not depending on input length. By definition, any attempt to store more than h symbols in the pushdown results in rejection. This constant memory bounded device is formally specified by an 8-tuple A = Q, Σ, Γ , δ, q 0 , ⊥, F, h , where h ≥ 0 is the built-in pushdown height, while all other components are defined as above.
Constant length queue automata. A nondeterministic queue automaton (nqa, see, e.g., [2,14]) is formally defined as a 7-tuple A = Q, Σ, Γ , δ, q 0 , , F , where Q, Σ, q 0 , F are defined as for nfas, Γ is the queue alphabet, ∈ Γ is the initial symbol in the queue store, and the transition function δ maps Q ×(Σ ∪{ε})×Γ to finite subsets of Q ×{D, K }×Γ * . At any time, the queue content may be represented by a string where the leftmost symbol is the head of the queue, while the rightmost is its tail. Let δ(q, σ, X ) ( p, χ, ω). Then A, being in the state q, reading σ on the input and X as the head of the queue, can reach the state p, delete (resp., keep) X if χ = D (resp., χ = K ), enqueue ω (i.e., append ω after the tail), and finally advance input scanning to the next input symbol only if σ = ε. So, a transition with parameter D (resp., K ) means that we delete (resp., keep) the symbol at the head of the queue. An input string is accepted, if there exists a computation beginning in the state q 0 with in the queue, and ending in some final state q ∈ F after reading the entire input. The set of all inputs accepted by A is denoted by L(A). The automaton A is deterministic (dqa), if for any q ∈ Q, σ ∈ Σ ∪ {ε} and X ∈ Γ , we have |δ(q, σ, X )| ≤ 1, and if δ(q, ε, X ) is defined then |δ(q, a, X )| = 0 for any a ∈ Σ.
A quick comment on our definition of a queue automaton is in order. In the definition of several automata models, two special types of moves, namely stationary moves and εmoves, are sometimes allowed. Basically, a stationary moves takes place on well-defined "configurations" established in the transition function where a particular state and a particular input symbol must be scanned. Acting such a move may possibly modify the state of the automaton, some auxiliary storage (if any), while the input head has to stay put. On the other hand, an ε-move is defined on a particular state without the need of reading a particular input symbol. After an ε-move, the state and some storage (if any) content may be changed, while the input head is allowed to move or stay put.
In our definition of a queue automaton, we allow ε-moves but not stationary moves on the input, this latter feature being usually assumed (see, e.g., [2,14]). Our choice is motivated by guaranteeing direct and fair comparisons between queue automata and pushdown automata where stationary moves are never considered. However, it is not hard to see that queue automata with ε-moves and queue automata with stationary moves are descriptionally equivalent.
A constant length nqa is obtained from a traditional nqa by imposing that the queue can never contain more than h symbols, for a fixed constant h ≥ 0 not depending on input length. Any attempt to store more than h symbols in the queue results in rejection. This constant memory bounded device is formally specified by an 8-tuple A = Q, Σ, Γ , δ, q 0 , , F, h , where h ≥ 0 is the built-in queue length, while all other components are defined as above.
Some common notions and observations. Throughout the rest of the paper, we will say that two automata A and A are equivalent whenever L(A) = L(A ) holds true. Moreover, for the sake of conciseness and when no possible confusion arises, we will be using the designation constant memory automaton to denote either a constant height npda or a constant length nqa. We observe that a constant memory automaton can be replaced by a corresponding "traditional"-i.e., without a built-in limit h on its memory storage-automaton by storing in its finite control states a counter recording permitted memory amounts (i.e., a number ranging within {1, . . . , h}). This increases the number of states by the multiplicative factor h (see, e.g., Lemma 3, where this technique is used in the proof). Indeed, notice that, for h = 0, the definition of a constant memory automaton exactly coincides with that of a finite state automaton.
Concerning acceptance mode, our constant memory automata are defined to accept by final states. However, in case of nondeterministic devices, at the cost of one more state it is always possible to accept by a single final state and with empty memory at once. This result is proved, e.g., in [17] for constant height npda; for constant length nqa, the same can be obtained with a similar approach.
For a constant memory automaton, a fair size measure (see, e.g., [3,17]) should take into account all the components the device consists of, namely: (i) the number of finite control states, (ii) the size of the memory alphabet, and (iii) the built-in memory limit. So, we adopt the following

Definition 1
The size of a constant memory automaton with state set Q, memory alphabet Γ , and memory limit h, is specified by measuring |Q|, |Γ |, and h.
We observe that this definition immediately implies that the size of an nfa, for which clearly |Γ | = 0 = h holds true, is completely determined by the number of its states.

Straight line programs for regular expressions.
A regular expression over a given alphabet Σ is inductively defined as: (i) ∅, ε, or a for any symbol a ∈ Σ, (ii) (r 1 + r 2 ), (r 1 · r 2 ), or r * 1 , if r 1 and r 2 are regular expressions. The language represented by a given regular expression is defined in the usual way (see, e.g., [18,20]). With a slight abuse of terminology, we will often identify a regular expression with the language it represents.
A convenient and concise way of specifying regular expressions is provided by straight line programs. Given a set of variables X = {x 1 , . . . , x }, a straight line program for regular expressions (slp, see [17]) on Σ is a finite sequence of instructions P ≡ instr 1 ; . . .
where the ith instruction instr i has one of the following forms: (i) x i := ∅, x i := ε, or x i := a for any symbol a ∈ Σ, (ii) x i := x j +x k , x i := x j ·x k , or x i := x * j , for 1 ≤ j, k < i. The program P expands to the regular expression in x (output variable), obtained by nested macro-expansion of the variables x 1 , . . . , x −1 , using the right parts of their instructions. Note that point (ii) in the definition of instruction form imposes a loopless structure to slps, naturally leading to their digraph representation analogous to that of boolean circuits (see, e.g., [1,17]).
The length of P is defined to be , i.e., the number of its variables or equivalently of its instructions. Yet, we remark that a variable may occur several times in the right parts of the instructions P consists of. Such a number of occurrences is called the fan-out of that variable. The fan-out of x is 0, while the fan-out of any other variable is at least 1 (if no useless instructions occur). The fan-out of P is the maximum fan-out of its variables.

Definition 2
The size of an slp is specified by measuring its length and its fan-out.
It is easy to see that a regular expression may be seen as an slp with fan-out 1. In general, due to fan-out power, straight line programs can be exponentially more succinct than regular expressions [17].
We end this section by a quick comment on our way of writing and denoting the type of size increasing when simulating computational models. As the reader noticed, due to their different "hardware", the size of the models under consideration here clearly is not always measured by the same parameters. So, with a slight abuse of terminology we say, e.g., that the size blow-up is exponential in the simulation of the model A with the model B whenever some parameter measuring the size of B is bounded above by some parameter of A appearing at the exponent. An example of this attitude can be seen in the discussion before Proposition 2.

Comparing constant length queue automata and finite state automata
We start comparing the descriptional power of constant memory automata with that of classical finite state automata. In [17], it is proved that any constant height npda (resp., constant height dpda) can be converted into an equivalent nfa (resp., dfa) paying by an exponential size increase, this size cost being optimal, that is, necessary in some cases. An analogous result may be obtained for converting constant length nqas and dqas: The key idea is to keep the queue content of A, represented by a string in Γ ≤h , in the finite control state. The transitions of A reflect step-by-step the evolution of both state and queue content in A. So, we let our nfa The reader may easily verify that L(A ) = L(A), and that this transformation preserves determinism.
Let us now show the optimality of the exponential simulation costs presented in Theorem 1. Consider the following witness language, for each h > 0, each alphabet Γ , and a separator symbol / ∈ Γ : Such a language is accepted by small constant length dqas, while any accepting nfa must be exponentially larger: Proof For point (i), we informally describe the behavior of a constant length dqa A for D Γ ,h , when accepting the input string w w ∈ D Γ ,h . First, A stores w in its queue by remaining in its initial state and using no more than h + 1 queue cells. Then, by switching to another state, A symbol-by-symbol compares the input suffix w against the queue content by dequeuing any matching symbol. Finally, by reading the sole symbol in the queue, A reaches a final state by an ε-move. The formal definition of A, correctly managing also inputs not in D Γ ,h , may be easily fixed by the reader.
For point (ii), assume by contradiction an nfa B for D Γ ,h exists, with less than |Γ ≤h | states. Suppose also that any non-final state of B has an outgoing path leading to a final state; otherwise, we can remove the state without altering the accepted language. By counting arguments, there exist v, w ∈ Γ ≤h such that v = w and the computation of B on both v and w may end up in the same non-final state q. Now, let α be a word leading B from q to a final state. Consequently, we have that both vα and wα belong to D Γ ,h . From this, we get that β vβ = α = β wβ for some β ∈ Γ ≤h . Hence, v = w against the hypothesis v = w. Now, we investigate the size trade-off between constant length nqas and dfas. By Theorem 1, any constant length nqa can be simulated by an equivalent nfa, paying by an exponential size increase. In turn, the classical powerset transformation of nfas into dfas (see, e.g., [18,20]) induces another exponential size blow-up. So, we get Proposition 1 Any constant length nqa with state set Q, queue alphabet Γ , and queue length h can be converted into an equivalent dfa with 2 |Q|·|Γ ≤h | states.
The double-exponential simulation cost pointed out in Proposition 1 is optimal. In fact, for each h > 0, each alphabet Γ , and a separator symbol / ∈ Γ , we define the language Proof For point (i), informally an nqa A for S Γ ,h sweeps the first half of the input string while counting modulo h in its finite state control, in order to delimit each block v i . While doing this, A nondeterministically chooses a block v i to be stored in the queue, and skips the others until is reached. From this point on, A sweeps the second half of the input string as done for the first half, but this time it nondeterministically chooses a block w j to be matched against the block v i previously stored in the queue. Clearly, the length of the queue is h, and O(h) states suffice to count modulo h and perform queuing/dequeuing operations as described.
For point (ii), assume by contradiction the existence of a dfa A for S Γ ,h featuring less than 2 |Γ h | states. By counting arguments, there exist two different subsets of Γ h , say B = {x 1 , x 2 , . . . , x m } and C = {y 1 , y 2 , . . . , y n }, such that A reaches the same state q after processing either the input string α = x 1 x 2 · · · x m and the input string β = y 1 y 2 . . . y n . Without loss of generality, assume that u ∈ B and u / ∈ C. Clearly, the word α u belongs to S Γ ,h , while the word β u does not. However, starting from q and deterministically processing the same suffix u, we get that A accepts α u ∈ S Γ ,h if and only if it accepts β u / ∈ S Γ ,h , a contradiction.

The cost of determinizing constant length queue automata
Let us now focus on the cost of removing nondeterminism in constant length nqas. We are going to prove an optimal exponential cost, in sharp contrast with the realm of constant height npdas, where an optimal double-exponential cost is proved in [5].
As a preliminary result, we complete the picture given in the previous section by studying the missing simulation. Precisely, we show that, by having a constant length queue at our disposal, we can remove nondeterminism in finite state automata paying by only a linear size increase.

Proof
The key idea is to simulate the behavior of the powerset automaton of A (i.e., the dfa obtained from A by the powerset construction [18,20]) by using the queue of A to store the set of states in which A might currently be. Each possible transition of A is simulated in A by consuming the state q at the head of the queue, and enqueuing the set of successors of q on the current input symbol. Basically, A performs a breadth-first traversal of the computation digraph of A on a given input string, searching for a possible accepting state.
Formally, we define our constant length dqa A = Q , Σ, Γ , δ , q 0 , , F , h as having: Let us now focus on defining the transition function δ . The first transition initializes the queue, reads the first input symbol, and stores it in the finite state control. So, for every a ∈ Σ, we let Roughly speaking, along the computation of A , the queue content will be a string in Γ * of the form α β , with α, β ∈ Q * , having the following meaning: the prefix α represents the set of states in which A might currently be in, while the factor β represents the set of states A might reach upon reading the current input symbol. This queue content is managed by A as follows: the first symbol of α (i.e., the state q at the head of the queue) is consumed and its successor states in A are enqueued. To accomplish this task, a queue rotation is required to avoid multiple storing of the same state in the second part β of the queue. To this aim, the transitions on the state e q a rotate the queue content until is reached, while those onẽ q a still rotate the queue content, together with deleting the successors of q already occurring in β. Formally, let Q = {q 1 , q 2 , . . . , q n } be the state set of A, and for any If there is no further state symbol of A in the first part of the queue, i.e., if the head of the queue is , we need to process β upon the next input symbol. To this aim, the queue content is modified from β to β . We get this by rotating the queue in the states r and r F , while checking whether some state in F shows up in the queue. If this is the case, A enters the accepting state r F at the end of rotation; otherwise, it enters the state r . Formally, for any a ∈ Σ and q ∈ Q, we let To see that L(A ) = L(A), let the dfa A be the powerset automaton from A. First, note that ε is accepted by A if and only if ε is accepted by A . Now, assume that A is in some state P 1 ⊆ Q, reads an input symbol a ∈ Σ, and goes to successor state P 2 ⊆ Q. Further, assume that A , after consuming the input symbol a, is in the state t a , and its queue content is w 1 , for some permutation w 1 of w P 1 -note that this situation is established since the beginning, after the first transition of A . Then, for each state symbol q in w 1 , the dqa A deletes this symbol from w 1 , and adds the state symbols from δ(q, a) to the second part of the queue between the and symbols. When all state symbols from w 1 are processed, the queue content of A is w 2 , where w 2 is some permutation of w P 2 . Now, A sees the symbol in the queue and scans the word w 2 , trying to reveal some accepting state symbol q ∈ F by rotating the queue content symbol by symbol. When A sees the symbol, the scanning of w 2 is completed. In this situation, A is in the accepting state r F if and only if there is an accepting state of A in the state set P 2 . Then, the next input symbol is consumed, the new queue content is w 2 , and A is ready to simulate the next step of A . Therefore, after completely sweeping the input string, A is in the accepting state r F if and only if A entered an accepting state. Clearly, the dqa A has 2·|Q|·|Σ|+|Σ|+3 states and |Q|+2 queue symbols. Moreover, notice that at any time the queue contains: any state symbol q ∈ Q at most once in the first part and at most once in the second part, at most one symbol, at most one symbol. So, the queue length never exceeds 2 · |Q| + 2.

Theorem 5 For each constant length nqa
Proof First, we use Theorem 1 to transform the given constant length nqa into an equivalent nfa, paying by an exponential size increase. Then, we use the linear transformation in Theorem 4 to obtain the desired constant length dqa.
To get the optimality of this exponential size blow-up, assume by contradiction a subexponential size increase. Then, by Theorem 1, we would get a sub-double-exponential size cost for converting constant length nqas into dfas, against the double-exponential optimality pointed out at Theorem 3.

Comparing constant length queue automata and constant height pushdown automata
We begin by showing that constant height pushdown automata can be simulated by constant length queue automata paying by only a linear size increase.

Proof
The key idea is to maintain the pushdown storage in the queue so that the queue head (resp., tail) represents the symbol at the top (resp., bottom) of the pushdown. The simulation in A of a move of A works as follows: (i) the head (corresponding to the top of A) is consumed, (ii) the string to pile at the top of the pushdown is enqueued, preceded by a special separator symbol / ∈ Γ , (iii) the whole queue content is rotated symbol by symbol, until is consumed.
It is easy to see that at the end of this rotation the new queue content reflects the pushdown content in A after the simulated move.
So, we define our constant length nqa A = Q , Σ, Γ ∪{ }, δ , q 0 , ⊥, F, h +1 as having Q = Q ∪ {r q : q ∈ Q}, and δ stated as follows. Given in A the move δ(q, σ, Z ) ( p, γ ), with σ ∈ Σ ∪ {ε}, we let The first transition enqueues the pushed string and prepares the queue rotation which is then accomplished by the second transitions. Finally, the third transition switches the state according to δ.
Clearly, |Q | = |Q| + |{r q : q ∈ Q}| = 2 · |Q|, while the set of queue symbols has cardinality |Γ | + 1. Also, notice that the queue rotation process increases by 1 the length of the queue at the first step, due to appending . In conclusion, observe that no nondeterminism is induced by moves from the states in {r q : q ∈ Q}. So, if A is deterministic, then A is deterministic as well.
For the reverse conversions, i.e., from constant length queue automata to constant height pushdown automata, we notice that Theorem 1 directly implies an exponential upper bound since a finite automaton can be seen as a pushdown automaton that does not use its own pushdown store. Therefore,

. Moreover, if A is a constant length dqa then A is a constant height dpda.
A corresponding exponential size cost lower bound for converting constant length queue automata to constant height pushdown automata, that is, the optimality of Proposition 2, will be proved later in Proposition 6, Sect. 6.
We end this section, by addressing the size costs for the conversions of constant height npdas to constant length dqas, and constant length nqas to constant height dpdas. We show an optimal exponential size cost for the former conversion, and a double-exponential size cost for the latter. Proof For the size cost upper bound, it suffices to apply Theorem 6 and get from A an equivalent constant length nqa which in turn, according to Theorem 5, can be transformed into an equivalent constant length dqa A with the claimed size.
For the optimality, we notice that if every constant height npda could be transformed to an equivalent constant length dqa with a sub-exponential size blow-up, then we could use the exponential transformation from Proposition 2 to convert the resulting constant length dqa into an equivalent constant height dpda. Altogether, this would yield a sub-doubleexponential size cost for removing nondeterminism in constant height npdas, against the results proved in [5]. Proof The size cost upper bound directly follows from Proposition 1. For the optimality, we observe that a sub-double-exponential size cost conversion plus the linear transformation in Theorem 6, from constant height npdas to constant length nqas would yield a sub-doubleexponential cost for removing nondeterminism in constant height npdas, against the results proved in [5].

Comparing queue automata and straight line programs
Let us state the cost of turning constant length nqas into slps. By composing Proposition 2 with a result in [17] relating the size of a constant height npda with the size of an equivalent slps we get: A = Q, Σ, Γ , δ, q 0 , , F, h , there exists an equivalent slp of length O(|Q| 4 · |Γ ≤h | 4 · |Σ|) and fan-out O(|Q| 2 · |Γ ≤h | 2 ).

Proposition 5 For each constant length nqa
Proof The exponential size cost is obtained by composing the exponential simulation from constant length nqas to constant height npdas in Proposition 2 with the polynomial transformation given in [17], from constant height npdas to slps.
For the optimality of Proposition 5, we consider the following language, for each h > 0, each alphabet Γ , and separator symbols $, / ∈ Γ :

Theorem 7 For each h > 0 and each alphabet Γ : (i) The language L Γ ,h is accepted by a constant length dqa with O(h) states, queue alphabet Γ = Γ ∪ { , }, and queue length h + 1. (ii) Any slp accepting the language L Γ ,h must have at least |Γ h | variables.
Proof A constant length dqa for L Γ ,h stores the prefix u of a given input word in its queue, while checking that |u| = h. This requires O(h) states. Then, it matches its queue content against the rest of the input word by rotating the queue symbol by symbol, rejecting whenever a bad input format problem or a wrong symbol match is revealed. Upon reading the input symbol $ and the symbol at the head of the queue, the dqa enters a final state.
Let us now switch to slps for L Γ ,h , and first introduce some terminology. In an slp, we call star-variable any variable x occurring on the left-hand side in a star-instruction of the form x := y * . Moreover, we denote by L(x) the language represented by the regular expression computed in x.
Thus, let P be an slp computing a regular expression for L Γ ,h , and let P be the slp obtained from P by replacing every star-instruction x := y * by the instruction x := ε. Clearly, P describes a finite language for which we let m be the length of the longest word. It is easy to see that, for any word z ∈ L Γ ,h with |z| > m, the slp P must make use of a star-variable producing some non-empty factor of z. By applying this observation to the word z u = ( u) m $ ∈ L Γ ,h , with u ∈ Γ h , we get the existence of a star-variable x u in P such that: (i) z u = z u,1 z u,2 z u,3 with ε = z u,2 ∈ L(x u ), and (ii) for all z u,2 ∈ L(x u ), we have z u,1 z u,2 z u,3 ∈ L Γ ,h .
The non-empty factor z u,2 must contain at least one symbol. Otherwise, P would describe a word with a factor ω ∈ Γ * satisfying |ω| > h, which cannot belong to L Γ ,h . If z u,2 contains at least two symbols, then it contains the factor u . If z u,2 contains only one symbol, i.e., if z u,2 = v 1 v 2 for v 1 , v 2 ∈ Γ * , then v 1 (resp., v 2 ) is a suffix (resp., prefix) of u. In fact, since z 2 u,2 ∈ L(x u ), it must be v 2 v 1 = u. Thus, we have shown that, for every word u ∈ Γ h , there exists a star-variable x u such that L(x u ) contains a word having u as a factor. If P has less than |Γ h | variables, then clearly there exist u, v ∈ Γ h , with u = v, satisfying x u = x v . This implies that the language L(x u ) contains words that have either u and v as factors. Moreover, since L(x u ) is closed under star operation, we get that P describes words of the form α u β v γ / ∈ L Γ ,h , for α, β, γ ∈ (Γ ∪ { , $}) * , a contradiction. Thus, P must have at least |Γ h | variables.
As a consequence of Theorem 7, we get the optimality of the exponential size cost conversions of constant length queue automata to constant height pushdown automata addressed in Proposition 2:
Proof Assume, by contradiction, a sub-exponential size cost conversion from constant length dqas to constant height npdas. Then, by the polynomial size cost conversion of constant height npdas to slps shown in [17], one could also convert any constant length dqa to an equivalent slp of sub-exponential size, against Theorem 7. We can argue similarly for the other conversions.
We conclude by converting slps to constant length nqas or dqas:

Proposition 7
The size blow-up for converting slps to equivalent constant length dqas (resp., nqas) is exponential (resp., linear). Furthermore, the former exponential transformation is optimal.
Proof In [17], a linear size cost transformation from slps to constant height npdas is presented. Together with the linear size cost conversion from constant height npdas to constant length nqas established in Theorem 6, this yields a linear size cost conversion from slps to constant length nqas. In turn, Theorem 5 implies an exponential size cost upper bound for converting of slps to constant length dqas.
For the optimality of this latter exponential size blow-up, assume by contradiction a sub-exponential size cost conversion exists, from slps to constant length dqas. Then, by a preliminary size cost polynomial transformation from constant height npdas to slps, plus a successive exponential size cost conversion from constant length dqas to constant height dpdas, one could get a sub-double-exponential size cost for removing nondeterminism in constant height npdas, against results proved in [5].

Summary of simulation costs
For reader's ease of mind, we sum up in Fig. 1 the main relations among the sizes of the different types of formalisms for regular languages considered in this paper. Such size relations are briefly commented below the figure.
Linear and polynomial size blow-ups. The Fig. 1 The size costs of simulations among different types of formalisms defining regular languages. Here h-dpda (h-npda, resp.) denotes a constant height dpda (npda, resp.), while h-dqa (h-nqa, resp.) denotes a constant length dqa (nqa, resp.). An arc labeled by lin (poly, exp, double exp, resp.) from a vertex A to a vertex B means that, given a representation of type A, we can build an equivalent representation of type B, paying by a linear (polynomial, exponential, double-exponential, resp.) increase in the size slp → h-npda: the linear cost comes from [17].
Exponential and double-exponential size blow-ups.
h-dqa → dfa, h-dqa → nfa, and h-nqa → nfa: the exponential costs come from Theorem 1, their optimality from Theorem 2. h-nqa → dfa: the double-exponential cost comes from Proposition 1, its optimality from Theorem 3. h-dqa → slp: the exponential cost comes from Proposition 5, its optimality from Theorem 7. slp → h-dqa: the optimal exponential cost comes from Proposition 7.
h-nqa → h-dqa: the optimal exponential cost comes from Theorem 5.

Boolean language operations on constant length queue automata
Let us now study the size cost of implementing boolean language operations on constant length nqas and dqas. This is a commonly investigated topic in descriptional complexity, for formalisms defining regular languages. For instance, for constant height npdas and dpdas, results can be found in [3,4,6]. Indeed, also for nonclassical language acceptors, such as different variants of quantum finite automata, several results on the size complexity of boolean language operations are established (see, e.g., [7][8][9][10]12,13]).
To simplify our constructions, sometimes it will be useful to assume that our queue automata enqueue at most one symbol at any move, that is, any transition ( p, χ, ω) ∈ δ(q, σ, X ) satisfies |ω| ≤ 1. In this case, the queue length changes at most by 1 at any move, and we say that the queue automaton is in normal form.
The next technical lemma shows that any constant length queue automaton can be converted in normal form, by preserving determinism. To suitably evaluate the size cost of this conversion, we adopt a size measure accounting for the "complexity" of the instructions of the queue automaton.
According to [18], the size of an automaton M can be defined as the length of a string describing its transition function. For a queue automaton, if the ith transition of M is δ(q, σ, X ) ( p, χ, Y 1 . . . Y k ), with k ≥ 0 and Y s ∈ Γ , it can be written down as a string t i = q σ X p χ Y 1 . . . Y k . (Here we assume, without loss of generality, that Q, Σ, Γ and {D, K } are mutually disjoint sets. This makes decoding of transitions unambiguous.) So, globally M can be written down as t 1 · · · t m ∈ (Q ∪ Σ ∪ Γ ∪ {D, K }) * , a string listing all machine's instructions one after another. By charging "1" for the constant part in each transition, we define the size of M as |M| = (q,σ,X )∈Q×(Σ∪{ε})×Γ ( p,χ ,ω)∈δ(q,σ,X ) max{|ω|, 1} .
As the reader may easily verify, we have that |M| ∈ O(|Q| 2 · |Γ | 2 ). We are now ready to establish the size cost of converting constant length queue automata into normal form:

. Moreover, if A is deterministic, then A is deterministic as well.
Proof Consider an instruction ρ = δ(q, σ, X ) ( p, χ, γ ) of A, with γ ∈ Γ * . If |γ | ≤ 1, then we let δ (q, σ, X ) ( p, χ, γ ). Otherwise, assuming γ = Y 1 . . . Y k with k > 1, we add k − 1 new states s 1 , . . . , s k−1 and, for 1 ≤ i ≤ k − 2 and all Z ∈ Γ , we translate ρ into the following instructions: Let us count the number of states required by A . For the instruction ρ, the automaton A uses the states q, s 1 , . . . , s |γ |−1 , p. If q is reachable by some nonempty input string, then it is already counted in some other instruction translation. Therefore, simulating the instruction ρ requires at most max{|γ |, 1} additional states. The only state that might not be counted is the initial state q 0 . Altogether, we get |Q | ≤ |A| + 1.
Another simplification we need for combining two constant length nqas in order to implement boolean language binary operations, is to assume that such automata have the same queue length. The evaluation of the size blow-up to implement this assumption is the subject of the following: A = Q, Σ, Γ , δ, q 0 , , F,  Proof First, we notice that a trivial step-by-step simulation of A by A using a queue of length h would not be able to reproduce the situation in which A rejects by attempting to enqueue more than h symbols. Thus, one possibility is to build A by integrating an integer counter within the finite state control of A, keeping track of the current queue length and immediately rejecting whenever the counter attempts to exceed h. This clearly implies the usage of h · |Q| states in A .

Lemma 2 Given a constant length nqa
Another possibility is that A initially inserts h − h dummy symbols in the queue, which will never be deleted. This clearly reduces A 's queue capacity to h, and requires h − h new states to be implemented. Along the computation, A maintains the simulated queue content of A before the dummy symbols by using a queue rotation subroutine. For this subroutine, we add new states of the form r Y p storing the state p to be entered and the symbol Y to be moved from the head to the tail of the queue (see, e.g., proofs of Theorems 4 and 6). This implies the usage of |Q| + |Q| · |Γ | + h − h states in A and a queue alphabet which is Γ equipped with a dummy symbol.
We are now ready to implement boolean language binary operations on constant length nqas which, by considering Lemmas 1 and 2 above, are assumed to be in normal form and working with the same queue length. We begin by considering the intersection:

Proof
The key idea is that A simulates in parallel the behavior of A 1 and A 2 , using its queue divided into two tracks. To this aim, the queue symbols of A consist of pairs of symbols from Γ 1 × Γ 2 . Analogously, the states of A come from Q 1 × Q 2 . The two components of the elements of these two sets are responsible of simulating the computation steps of A 1 and A 2 on the corresponding tracks. Since the queue operations of A 1 and A 2 are generally not synchronized, a special blank queue symbol b / ∈ Γ 1 ∪ Γ 2 is inserted at the end of the shortest track to allow tracks aligning. Every enqueuing operation requires a rotation subroutine in order to keep the b's at the end of the shortest track. To this purpose, a special queue symbol ( , ), with / ∈ Γ 1 ∪ Γ 2 , is introduced, together with new elements that will be used as state components of A during the rotation subroutine. Namely, for i ∈ {1, 2}, we let: An element r Y p stores the state p to be entered and the queue symbol Y to be enqueued at the end of the non-blank part of the corresponding track. 2 An element s X p stores the state p to be entered and the queue symbol X to be enqueued at the next rotation step during the rotation subroutine. This is required whenever the operations of A 1 and A 2 on the queue are not synchronized.
stores the state p to be entered, the queue symbol Y to be enqueued at the end of the non-blank part of the corresponding track, and the queue symbol X to be enqueued at the next rotation step during the subroutine.
The transition function δ simulates δ 1 and δ 2 on the two tracks, and performs the rotation subroutine whenever required.
Particular attention must be paid to handle ε-moves. If one of the two automata A 1 or A 2 requires to perform an ε-move, the other automaton must be synchronized by replicating an ε-move too, in which state and queue are not modified. To this aim, we add the following rules to δ i , for i ∈ {1, 2}, which can be simulated by δ. For any q ∈ Q i and X ∈ Γ i , we let: (1) (Y 1 , b)).
The reader may fill the definition of δ for the cases Y 1 = ε or/and Y 2 = ε. We simply notice that for Y 2 = ε, instead of having the second component of the states in the form t Y 2 ,Z p 2 , we have s Z p 2 since we do not record Y 2 to be inserted. The rules in δ for simulating moves of type keep--delete are managed symmetrically, while moves keep--keep and delete--delete are replicated simply by parallel simulations (in these two latter cases, involved states are only from the set ( It is easy to see that A is a constant length nqa, with queue length at most h +1. Moreover, since each component of the states of A is from the set Q i ∪ R i ∪ S i ∪ T i , we have the claimed number of states.
We observe that the two constant length nqas considered in Theorem 8 for intersection enjoy particular properties, e.g., being in normal form and operating with the same queue length. However, by considering the transformation size costs in Lemma 1 and Lemma 2, the reader may easily verify that the state cost of implementing the intersection for two general constant length nqas turns out to be at most the square of the state cost pointed out in Theorem 8, multiplied by the length of the shortest queue among the two involved constant length nqas.
Proof We can consider the construction provided in the proof of Theorem 8, by simply observing that there the only rules adding nondeterminism are the ones displayed in Eq. (1) for handling ε-moves synchronization. Since A 1 and A 2 are realtime, we here do not need these additional rules any more.
For general realtime constant length dqas, again by considering Lemma 1 and Lemma 2, the reader may easily verify that the state cost of implementing intersection turns out to be at most the square of the state cost pointed out in Corollary 1, multiplied by the length of the shortest queue among the two involved constant length dqas.
Instead, in case of two nonrealtime constant length dqas, the idea is to turn one of the two devices into an equivalent dfa according to Theorem 1, remove ε-moves from the dfa, and finally embed the dfa into the finite control of the other dqa. The resulting constant length dqa implements the intersection with a number of states bounded by |Q 1 | · |Q 2 | · |Γ ≤h 2 2 |, where Q 1 , Q 2 , Γ 2 , h 2 have the usual meaning. Now, we turn to implementing the union. For this operation, the construction is simpler since we can exploit nondeterminism: Theorem 9 Given two constant length nqas A 1 = Q 1 , Σ, Γ 1 , δ 1 , c 1 , , F 1 , h and A 2 = Q 2 , Σ, Γ 2 , δ 2 , c 2 , , F 2 , h , we can construct a constant length nqa A recognizing L(A 1 )∪ L(A 2 ), with queue length h, queue alphabet Γ 1 ∪ Γ 2 , and |Q 1 | + |Q 2 | + 1 states.
Proof Without loss of generality, we can assume that Q 1 and Q 2 are disjoint sets. The states of A are from the set Q 1 ∪ Q 2 , plus a new initial state c, the queue alphabet is Γ 1 ∪ Γ 2 , and the set of final states is F 1 ∪ F 2 . As a first step, A performs a nondeterministic ε-move from c leading to enter either c 1 or c 2 . Then, A simulates δ 1 on states from Q 1 , and δ 2 on states from Q 2 . It is not hard to see that A accepts whenever either A 1 or A 2 accepts.
In case of two constant length nqas with queues of different lengths, by Lemma 2 one may easily obtain that the state cost for their union turns out to be at most |Q 1 |+h 2 ·|Q 2 |+1, where Q 1 , Q 2 , h 2 have the usual meaning.
For implementing the union in the realtime deterministic case, we can use the same construction for intersection, addressed in the proof Corollary 1, with small modifications. Such modifications are basically due to handling situations in which one of the two queue automata rejects before consuming the whole input. To this aim, we present a technical lemma: Lemma 3 Given a realtime constant length dqa A = Q, Σ, Γ , δ, c, , F, h , we can construct an equivalent realtime constant length dqa A = Q , Σ, Γ , δ , c, , F , h with |Q | ≤ h · |Q| + 2, which always consumes the whole input before halting. Moreover, if A is in normal form, then A is in normal form as well.
Proof Being A realtime, there cannot exist infinite loops due to ε-moves. The only situations where A might halt before the end of the input string are the following: (i) queue underflow and overflow, (ii) undefined δ for some configurations.
To fix situation (i), we store the current length of the queue in the finite state control of A , i.e., the states of A has the form (q, ) ∈ Q × {1, . . . , h}. Underflow and overflow situations can be detected from the values of , and can be managed by redirecting the corresponding computation to a new trap state rej. A particular situation might arise, where the queue length of A is zero, the input has been completely scanned, and A enters an accepting state. To handle this situation, we equip A with a new accepting state acc and, for δ(q, a, Z ) = ( p, D, ε) with p ∈ F, we let δ ((q, 1), a, Z ) = (acc, K , ε) and δ (acc, σ, X ) = (rej, K , ε), for any σ ∈ Σ and X ∈ Γ . When entering the state rej, we consume the whole input by the rules δ (rej, σ, X ) = (rej, K , ε).
Proof The construction of A works out similarly to that in the proof of Corollary 1. However, we here have to handle cases in which one of the two simulated automata A 1 or A 2 halts before consuming the whole input and the other accepts. To this aim, we first transform A 1 and A 2 into A 1 and A 2 according to Lemma 3. Then, to get A, we compose A 1 and A 2 as in Corollary 1, except for the set of final states which is now defined to be (F 1 × Q 2 )∪(Q 1 × F 2 ).
For general realtime constant length dqas, the reader may easily verify that the state cost of implementing the union turns out to be the same as the one above discussed for intersecting general realtime constant length dqas, multiplied by the factor h 1 · h 2 . This latter factor follows from the construction in Lemma 3, aimed to accept or reject at the end of the input only.
Instead, in case of non-realtime devices, we use the same construction above addressed for implementing the intersection of non-realtime constant length dqas, thus yielding the same state complexity.
Proof First, we transform A into an equivalent nfa, according to Theorem 1. The transition function of the obtained nfa might be partial and containing ε-moves. Therefore, we complete this function by adding transitions to a new trap state in which the remaining part of the input is consumed, and remove ε-moves by standard tools (see, e.g., [18,20]) without increasing the number of states. Then, we use Theorem 4 to convert the obtained nfa to an equivalent constant length dqa. Considering the above-mentioned properties of the nfa to be converted and how the construction of Theorem 4 works, it is not hard to see that the resulting constant length dqa always sweeps the whole input, accepting or rejecting at the end only. So, by swapping accepting and rejecting states, we obtain a constant length dqa for L(A) c , with the claimed features.
For complementing a realtime constant length dqa, it is enough to use Lemma 3 to get an equivalent automaton consuming the whole input, and then swap accepting and rejecting states of this automaton. Thus, we have Corollary 3 Given a realtime constant length dqa A = Q, Σ, Γ , δ, q 0 , , F, h , we can construct a realtime constant length dqa for L(A) c , having queue length h, queue alphabet Γ , and featuring h · |Q| + 2 states.
In case of non-realtime constant length dqas, the state cost for the complement remains the same. In fact, before applying the construction used for proving Corollary 3, it suffices to precompute and remove infinite loops due to ε-moves.

Conclusions
In this paper, we have considered the notion of a constant length queue automaton-i.e., a traditional queue automaton with a built-in constant limit on the length of its queue-as a formalism for representing regular languages.
We have shown that the descriptional power of constant length queue automata is higher than that of several formalisms for defining regular languages by providing optimal exponential and double-exponential size gaps.
In particular, we have proved that constant height pushdown automata can be simulated by constant length queue automata paying only by a linear size increase, and that removing nondeterminism in constant length queue automata requires an optimal exponential size blowup, against the optimal double-exponential cost for determinizing constant height pushdown automata. This proves the descriptional advantages of using a queue instead of a pushdown in the realm of constant memory machines.
Finally, we have investigated the size cost of implementing boolean language operations on deterministic and nondeterministic constant length queue automata.
Among possible future lines of research, one may investigate restricted variants of constant memory automata, for instance devices working on unary, i.e., single-letter, input alphabets (see, e.g., [11,15,26,27]), or input-driven devices [25]. We also would like to emphasize the interest in two-way devices [28].
Concerning the investigation of the size cost of language operations on constant length queue automata, it would be interesting to consider further typical operations on regular languages, such as Kleene's star, reversal, quotient, shuffle, homomorphisms and inverse homomorphisms, etc. Moreover, one could extend the investigation on language operations for restricted models, such as realtime constant length nqas. Also the size optimality should be proved or improved constructions should be designed, for the language operations considered in this paper.