ON RESTARTING AUTOMATA WITH AUXILIARY SYMBOLS AND SMALL WINDOW SIZE∗

Here we show that for monotone RWW(and RRWW-) automata, window size two is sufficient, both in the nondeterministic as well as in the deterministic case. For the former case, this is done by proving that each context-free language is already accepted by a monotone RWW-automaton of window size two. In the deterministic case, we first prove that each deterministic pushdown automaton can be simulated by a deterministic monotone RWW-automaton of window size three, and then we present a construction that transforms a deterministic monotone RWW-automaton of window size three into an equivalent automaton of the same type that has window size two. Furthermore, we study the expressive power of shrinking RWWand RRWW-automata the window size of which is just one or two. We show that for shrinking RRWW-automata that are nondeterministic, window size one suffices, while for nondeterministic shrinking RWW-automata, we already need window size two to accept all growing context-sensitive languages. In the deterministic case, shrinking RWWand RRWW-automata of window size one accept only regular languages, while those of window size two characterize the Church-Rosser languages. Mathematics Subject Classification. 68Q45, 68Q42. Received December 6, 2019. Accepted April 29, 2021.


Introduction
The restarting automaton was introduced in [6] as a formal model for the linguistic technique of 'analysis by reduction'. A restarting automaton, RRWW-automaton for short, is a device M that consists of a finite-state control, a flexible tape containing a word delimited by sentinels, and a read/write window of fixed finite size. This window is moved along the tape by move-right steps until the control decides (nondeterministically) that the contents of the window should be rewritten by some shorter word. In fact, the new word may contain auxiliary symbols that do not belong to the input alphabet. After a rewrite, M can continue to move its window until it either halts and accepts, or halts and rejects, or restarts, which means that it places its window over the left end of the tape and reenters its initial state. It follows that each computation of M can be described through a sequence of cycles and a tail computation. Here a cycle is a part of a computation that begins after a restart step (or by the first step from an initial configuration) and that ends with the next restart step, and expressive as nondeterministic shrinking RRWW-automata in general, which are known to be equivalent to the finite-change automata of [30]. On the other hand, for nondeterministic shrinking RWW-automata, window size one is not enough, as we already need window size two to accept all growing context-sensitive languages. However, window size nine suffices to again obtain all language accepted by finite-change automata. In fact, it remains open whether window size nine is the smallest possible, that is, whether nondeterministic shrinking RWW-automata of window size eight are really less expressive than those of window size nine.
Finally, we consider shrinking RWW-automata and monotone shrinking RRWW-automata of window size one and their deterministic variants. It turns out that deterministic shrinking RWW-and RRWW-automata of window size one just accept the regular languages, while with window size two, these automata characterize the Church-Rosser languages. Furthermore, also the monotone shrinking RWW-automata of window size one just accept the regular languages, while shrinking RWW-automata and monotone shrinking RRWW-automata of window size one are strictly more expressive.
This paper is structured as follows. After presenting the necessary definitions and notation in Section 2, we restate in short the known results on the influence of the window size on the expressive power of restarting automata. In Section 3, we then concentrate on nondeterministic monotone RWW-and RRWW-automata, in Section 4, we study deterministic monotone RWW-and RRWW-automata, and we discuss the influence of the window size on deterministic RWW-and RRWW-automata that are non-monotone. Then we turn to shrinking restarting automata in Section 5, in which we investigate the expressive power of nondeterministic shrinking RWW-and RRWW-automata of window size one and two. Finally, in Section 6, we consider the deterministic case. The paper closes with Section 7 in which we summarize our results using a diagram that depicts the relationships between the various language classes considered and state a number of open problems.

Definitions and notation
Throughout the paper, λ will denote the empty word, and N + will denote the set of all positive integers, while N is used to denote the set of all non-negative integers. Furthermore, for any type of automaton X, we use the notation L(X) to denote the class of languages that are accepted by automata of type X. Definition 2.1. A (one-way) restarting automaton, RRWW-automaton for short, is a one-tape machine that is described by an 8-tuple M = (Q, Σ, Γ, ¢, $, q 0 , k, δ), where Q is a finite set of states, Σ is a finite input alphabet, Γ is a finite tape alphabet containing Σ, where the symbols in Γ Σ are called auxiliary symbols, the symbols ¢, $ ∈ Γ, called sentinels, serve as markers for the left and right border of the workspace, respectively, q 0 ∈ Q is the initial state, k ≥ 1 is the size of the read/write window, and The transition relation contains four different types of transition steps: 1. A move-right step is of the form (q , MVR) ∈ δ(q, u), where q, q ∈ Q and u ∈ PC (k) , u = $. If M is in state q and sees the word u in its read/write window, then this move-right step causes M to shift the read/write window one position to the right and to enter state q . However, if the contents u of the read/write window is only the symbol $, then no shift to the right is possible. 2. A rewrite step is of the form (q , v) ∈ δ(q, u), where q, q ∈ Q, u ∈ PC (k) , u = $, and v ∈ PC ≤(k−1) such that |v| < |u|. It causes M to replace the contents u of the read/write window by the word v, thereby shortening the tape, and to enter state q . Furthermore, the read/write window is placed immediately to the right of the word v. However, some additional restrictions apply in that the sentinels ¢ and $ must not disappear from the tape nor that new occurrences of these symbols are created. In addition, the read/write window must not move across the right sentinel $, that is, if the word u ends in $, then so does the word v, and after performing the rewrite operation, the read/write window is placed on the $-symbol. 3. A restart step is of the form Restart ∈ δ(q, u), where q ∈ Q and u ∈ PC (k) . It causes M to place the read/write window over the left end of the tape, so that the first symbol it contains is the left sentinel ¢, and to reenter the initial state q 0 . 4. An accept step is of the form Accept ∈ δ(q, u), where q ∈ Q and u ∈ PC (k) . It causes M to halt and accept.
If δ(q, u) = ∅ for some q ∈ Q and u ∈ PC (k) , then M necessarily halts when it is in state q with the word u in its window, and we say that M rejects in this situation. There is one additional restriction that the transition relation must satisfy. This restriction says that, when ignoring move operations, rewrite steps and restart steps alternate within any computation of M , with a rewrite step coming first.
Let M = (Q, Σ, Γ, ¢, $, q 0 , k, δ) be an RRWW-automaton. A configuration of M is described by a word of the form αqβ, where q ∈ Q, and either α = λ and β ∈ {¢} · Γ * · {$} or α ∈ {¢} · Γ * and β ∈ Γ * · {$}; here q represents the current state, αβ is the current contents of the tape, and it is understood that the window contains the first k symbols of β or all of β when |β| ≤ k. By M we denote the single-step computation relation that M induces on its set of configurations, and * M is the computation relation of M , which is the reflexive and transitive closure of M . A restarting configuration is of the form q 0 ¢w$, where w ∈ Γ * ; if w ∈ Σ * , then q 0 ¢w$ is an initial configuration. Thus, initial configurations are a particular type of restarting configurations.
A phase of a computation of M , called a cycle, begins with a restarting configuration. The window is moved along the tape by MVR operations and a single rewrite operation until a restart operation is performed and, thus, a new restarting configuration is reached. Accordingly, a computation consists of a sequence of cycles that is followed by a tail, which is the part of a computation that comes after the last restart operation. By c M we denote the relation on restarting configurations that is induced through the execution of a cycle, and we use c * M to denote its reflexive and transitive closure. The above restriction on the transition relation implies that M performs exactly one rewrite operation during each cycle -thus each new phase starts on a shorter word than the previous one -and that it executes at most one rewrite operation during a tail computation.
An input word w ∈ Σ * is accepted by M , if there is a computation which, starting with the initial configuration q 0 ¢w$, finishes by executing an accept step. By L(M ) we denote the language consisting of all (input) words accepted by M ; we say that M accepts the language L(M ).
In general, an RRWW-automaton is nondeterministic, that is, for some pairs (q, u), there may be more than one applicable transition step. If this is not the case, then the automaton is deterministic. We use the prefix det-to denote classes of deterministic restarting automata.
Many restricted classes of restarting automata have been introduced and studied. An RWW-automaton is an RRWW-automaton that is required to execute a restart step immediately after performing a rewrite step. Accordingly, for RWW-automata we combine a rewrite step with the subsequent restart step into a single combined rewrite/restart step to simplify the notation.
• A combined rewrite/restart step is of the form v ∈ δ(q, u), where q ∈ Q, u ∈ PC (k) , u = $, and v ∈ PC ≤(k −1) such that |v| < |u|. It causes M to replace the contents u of the read/write window by the word v, thereby shortening the tape, to place the read/write window over the left end of the tape, so that the first symbol it sees is the left sentinel ¢, and to reenter the initial state q 0 .
An RRW-automaton is an RRWW-automaton which does not use any auxiliary symbols, that is, its tape alphabet coincides with its input alphabet. An RR-automaton is an RRW-automaton the rewrite steps of which can be viewed as deletions, that is, if (q , v) ∈ δ(q, u), then v is a scattered subword of u. Obviously, the restrictions on the rewrite operations can be combined with the restriction on the restart operations (requiring to restart immediately after each rewrite step), which leads to the RW-and the R-automaton. The size of the read/write window is an essential parameter of a restarting automaton. For each k ≥ 1, we use the notation X(k) to denote those restarting automata of type X that have a read/write window of size k.
Recall that the computation of a restarting automaton proceeds in cycles, where each cycle contains exactly one rewrite step. Thus, each cycle C contains a unique configuration of the form αqβ in which a rewrite step is applied. Now |β| is called the right distance of C, which is denoted by D r (C).
A sequence of cycles S = ( A computation is monotone if the corresponding sequence of cycles is monotone. Observe that here the tail of the computation is not taken into account. Finally, a restarting automaton is called monotone if all its computations that start with an initial configuration are monotone. The prefix mon-is used to denote the various classes of monotone restarting automata. The following result extends the characterization of the context-free languages by monotone restarting automata that is presented in [7] to window size three. (3)).
Concerning the monotone deterministic restarting automata, the following results have been derived in [7].
On the other hand, it is easily seen that each RRWW-automaton (RWW-automaton) with a read/write window of size one is just an RR-automaton (R-automaton), as its rewrite operations must be length-reducing. Concerning window size one, the following results are known. Here REG denotes the class of regular languages.
Thus, window size one restricts the expressive power of monotone deterministic and nondeterministic RWWand RRWW-automata considerably.
In [29], Natalie Schluter established the following results concerning the window size of monotone restarting automata. These results were already announced in [27,28].
As a consequence, we obtain that CFL = L(mon-RRWW(2)) = L(mon-RWW(2)). Unfortunately, the constructions used by Natalie Schluter to prove her results are technically very involved and, accordingly, very hard to follow. In the next section, we provide a direct and much simpler proof for the characterization of the class CFL by monotone restarting automata of window size two.

On nondeterministic monotone RWW-automata
Our first main result states that each context-free language is accepted by an RWW-automaton of window size two. Proof. Obviously, L(mon-RWW(2)) ⊆ L(mon-RWW (3)). Hence, because of Theorem 2.2, it remains to show that each context-free language is accepted by a monotone RWW-automaton of window size two.
Let L ⊆ Σ * be a context-free language, and let G = (N, Σ, S, P ) be a context-free grammar for L. Without loss of generality, we may assume that the production rules in P have the following form, which is easily obtained from the Chomsky normal form: Below we use the notation ⇒ * G to denote the derivation relation that is induced by the productions of G on the sentential forms (N ∪ Σ) * . Now we define an RWW-automaton M = (Q, Σ, Γ, ¢, $, q 0 , 2, δ), where Q = {q 0 , q, q + } and and we define a morphism π : Γ * → (N ∪ Σ) * by taking π(A) = A and π((A, B)) = AB for all A, B ∈ N ∪ Σ.
Thus, M uses the nonterminals A of G and the pairs of the form (A, B) with A, B ∈ N ∪ Σ as auxiliary symbols that represent the words A and AB, respectively. The transition relation δ of M is defined as follows, where A, B, C ∈ N ∪ Σ and X ∈ N : for γ ∈ Γ such that S ⇒ * G π(γ), Obviously, M is an RWW-automaton of window size two. The encoding of two letters A, B ∈ N ∪ Σ as a single letter (A, B) is used to mark the position in the actual sentential form that has to be examined in the next step. Thus, the tape contents always consists of a sequence of pairs followed by a sequence of letters from N ∪ Σ, where any of these two subsequences can be empty. Since each rewrite step is performed at the border between these two subsequences, it is easily seen that M is monotone. It remains to verify that M accepts the context-free language L. It is easily seen that an accepting computation of M constructs a G-derivation for the given input in reverse order. Hence, we have L(M ) ⊆ L.
Proof. At first, we prove the claim for n = 1, then for any n > 1. If n = 1, then |w| ≤ 2 and α 1 = w. For |w| = 1, we have by rules (2) and (3), and for |w| = 2, we have w = ab for some letters a, b ∈ Σ and Now assume that q 0 ¢α j $ * M Accept has already been shown for all j ≤ i and some i, 1 ≤ i ≤ n − 1. We consider the sentential form α i+1 .
There is no other possibility, as we consider a rightmost derivation. In the former case, by rules (4) and (6), which implies q 0 ¢α 2 $ * M Accept by the induction hypothesis, while in the latter case, by rules (4), (5), and (8), which yields q 0 ¢α 2 $ * M Accept by rules (2) and (3). Finally, assume that i ≥ 2. Then α i−1 ⇒ G α i ⇒ G α i+1 is a part of the above rightmost derivation. The latter step implies that α i = B 1 B 2 · · · B m Aa m+3 · · · a r−1 a r for some B 1 , B 2 , . . . , B m ∈ N ∪ Σ, a nonterminal A ∈ N , terminals a m+3 , . . . , a r−1 , a r ∈ Σ, and a production (A → B m+1 B m+2 ) ∈ P such that Furthermore, α i−1 = XCY ⇒ G XDEY = α i for a production (C → DE) ∈ P and some words X ∈ (N ∪ Σ) * and Y ∈ Σ * . As α i−1 ⇒ G α i is a part of the above rightmost derivation, it follows that either the distinguished occurrence of the nonterminal A in α i is produced by the above application of the production (C → DE) implying that DE = B m A or DE = Aa m+3 , or that X = B 1 B 2 · · · B m Aa m+3 · · · a m+s−1 , DE = a m+s a m+s+1 , and Y = a m+s+2 a m+s+3 · · · a r for some s ≥ 3.
In the former case, B m+1 B m+2 is then rewritten into the nonterminal A by rule (6), and as the derivation step α i−1 ⇒ G α i either produces the displayed nonterminal A or occurs in the suffix following this letter, we can conclude that the computation q 0 ¢α i $ * M Accept starts with the encoding of the prefix B 1 B 2 · · · B m into the word (B 1 , B 2 ) · · · (B m−1 , B m ). Hence, the configuration obtained in one step from (3.1) appears in an accepting computation that starts from q 0 ¢α i $ and q 0 ¢α i+1 $ * M Accept follows. In the latter case, (B m , B m+1 )B m+2 is either rewritten into (B m , A) by rule (8) Here it follows analogously that the computations q 0 ¢α i $ * M Accept and q 0 ¢α i−1 $ * M Accept start with encoding the prefix B 1 B 2 · · · B m A into the word (B 1 , B 2 ) · · · (B m , A) or B 1 B 2 · · · B m−1 into the word (B 1 , B 2 ) · · · (B m−2 , B m−1 ), respectively. Hence, the configuration obtained in one step from (3.2) appears in an accepting computation starting either from q 0 ¢α i $ or from q 0 ¢α i−1 $. Therefore, also in these cases q 0 ¢α i+1 $ * M Accept follows.
For i = n, the claim above yields that q 0 ¢α n $ = q 0 ¢w$ * M Accept, which means that w ∈ L(M ). Thus, in summary, we have shown that L(M ) = L.
As each RWW(2)-automaton can also be interpreted as an RRWW(2)-automaton, the above result yields the following consequence. From a given monotone RWW-automaton M of window size k ≥ 3, we can first construct a pushdown automaton P for the language L(M ) as shown in the proof of Theorem 2.2 in [7]. From this PDA, we can derive a context-free grammar G in Chomsky normal form for L(G), and then, using the construction above, we obtain a monotone RWW-automaton of window size two for L(M ). Furthermore, as for all k ≥ 3, L(mon-RWW(2)) ⊆ L(mon-RWW(k)), we see that, for each k ≥ 3, L(mon-RRWW(k)) ⊆ CFL ⊆ L(mon-RWW(k)) ⊆ L(mon-RRWW(k)).
Hence, we obtain the following result.

On deterministic RWW-automata
Here we show that Theorem 3.1 carries over to the deterministic case. The proof consists of two major steps that we present in the following two subsections. In a third subsection, we consider deterministic RWW-and RRWW-automata that are not monotone.

On deterministic monotone RWW(3)-automata
Let L ⊆ Σ * be a deterministic context-free language. Then there exists a deterministic pushdown automaton (DPDA) A = (Q A , Σ, ∆ A , #, p 0 , δ A , F A ) that accepts L by final state. Here Q A is a finite set of states, Σ is the input alphabet, ∆ A is the pushdown alphabet, # ∈ ∆ A is the bottom marker of the pushdown, p 0 ∈ Q A is the initial state, is the (partial) transition function, and F A ⊆ Q A is the set of final states. We assume without loss of generality that the bottom marker # occurs only as the bottommost symbol on the pushdown and that this symbol is never popped from the pushdown. A configuration of A is written as (p, u, #α), where p ∈ Q A is the current state, u ∈ Σ * is the suffix of the input that has not yet been processed, and #α ∈ # · ∆ * A is the current contents of the pushdown. Here we assume that the bottom (top) of the pushdown is on the left (right). A word w ∈ Σ * is accepted by A if the computation of A that starts from the initial configuration (p 0 , w, #) reaches a configuration of the form (p, λ, #α) for some final state p ∈ F A and some word α ∈ ∆ * A . We use the notation A to denote the single-step computation relation that A induces on its set of configurations, and we use * A to denote the corresponding computation relation. Here we establish the following technical result.
Without loss of generality we can assume that each λ-step of A pops a symbol from the pushdown, that is, A , then x ∈ ∆ A and y = λ (see, e.g., [1], Prop. 5.4). Thus, given a word w = a 1 a 2 · · · a n ∈ L(A) as input, the computation of A begins with a reading step that reads the first letter a 1 , and then there is a sequence of n − 1 phases that each consists of a (possibly empty) sequence of λ-steps during which some symbols are popped from the pushdown that is followed by a reading step. Finally, after the last reading step, which reads the letter a n , another sequence of λ-steps that pop some symbols from the pushdown may follow taking A into a final state.
For constructing an RWW-automaton M = (Q, Σ, Γ, ¢, $, q 0 , 3, δ) of window size three that simulates the computations of A, we need the constant that is, c A is the length of the longest word that A can push onto its pushdown in a single step. Furthermore, let c = 2c A − 1.
The idea of the construction of M is as follows. Using code symbols of the form [α] and [α, p], the contents #α 1 α 2 · · · α m of the pushdown of A and the actual state p of A are encoded by a word of the form Thus, the contents of the pushdown is compressed by the factor c, and its topmost part is stored together with the current state of A. Processing the input w = a 1 a 2 · · · a n from left to right, M tries to simulate a (possibly empty) sequence of λ-steps together with the next reading step. This sequence of steps causes a change in the contents of the pushdown, that is, some symbols may be popped from the pushdown and a new word may be pushed onto the pushdown. If the corresponding change of the pushdown contents can be stored in the rightmost code symbol, then M can simulate these steps by removing the input letter read and by replacing the rightmost code symbol. However, if the rightmost code symbol does not have sufficient storage space left, then an additional code symbol must be used. This causes a problem as each rewrite step of M must be length-reducing. To overcome this problem, M combines the above steps with the next sequence of λ-steps. If these λ-steps decrease the size of the contents of the pushdown sufficiently enough, then the simulation can continue by just manipulating the rightmost code symbol. Finally, if that is not the case, either, then M moves its window one more step to the right and simulates another reading step, reading the next input symbol as well.
To realize this strategy, the RWW(3)-automaton M is now defined by taking using this rule M accepts inputs of length at most one, rules (2) and (3) create the first code symbol on the tape, , and δ A (p 1 , a, #) = (p 2 , #γ), rules (4)-(6) read the next input symbol if the whole new pushdown contents fits into a single code symbol, (7) or (17) reads the next two input symbols as after reading the first symbol another code symbol is needed, rules (9)-(12) move the window over a sequence of code symbols, , rule (13) removes the last code symbol by a sequence of λ-steps, (14) removes the last code symbol by a sequence of λ-steps followed by reading the next input symbol, and |αγ| ≤ c, rule (15) reads the next input symbol if no additional code symbol is needed, (16) reads the next input symbol if no additional code symbol is needed because of a subsequent sequence of λ-steps, (17) realizes a move to the right as reading the next input symbol would require an additional code symbol -this rule can be followed by (8) or (21), rules (18) and (19) accept when the whole input has been read, (20) removes the last code symbol by a sequence of λ-steps after the whole input has been read, rule (21) accepts if reading the last input symbol would require an additional code symbol, but a subsequent sequence of λ-steps leads to an accepting state.
As each accepting computation of M obviously simulates an accepting computation of the DPDA A, it follows that L(M ) ⊆ L = L(A) holds. On the other hand, we can prove the following claim by induction on the length of the input word w.
In case (b), we also have to consider the next part of the above computation of the DPDA A, in which the first letter of w , say b, is read: Then the above computation of M continues as follows: , q]w $ (by rules (9)-(12), then (7) and (8) or (17) and (8)), where #β 1 β 2 · · · β i−1 β i η 1 η 2 = #α . Then the induction hypothesis can be applied to the configuration (q, w , #α ), which yields Let w ∈ L(A). If |w| ≤ 1, then M accepts on input w by rule (1). So assume that |w| ≥ 2, and let w = abw for some a, b ∈ Σ. Then for some p, p ∈ Q A , q f ∈ F A , and words α, α , γ ∈ ∆ * A . It is easily seen that |#α | ≤ c, and hence, M can execute the following computation: (2)  During a computation, the tape contents of M is always of the form where α 1 , α 2 , . . . , α m ∈ ∆ * A , p ∈ Q A , and a r , a r+1 , . . . , a n ∈ Σ. As each rewrite step involves the rightmost code symbol on the tape, and as it processes the leftmost input symbol (or the two leftmost input symbols), it follows that M is monotone. Thus, M is a deterministic monotone RWW(3)-automaton for the language L(A).
From this simulation and from Theorem 2.3 we obtain the following consequence.  (3)).

On deterministic monotone RWW(2)-automata
Here we show that each deterministic monotone RWW-automaton of window size three can be simulated by a deterministic monotone RWW-automaton of only window size two. This simulation will be based on the following important observation. Proof. Let M = (Q, Σ, Γ, ¢, $, q 0 , 2, δ) be a deterministic RRWW-automaton of window size two. Each rewrite transition of M replaces a factor of length two of the tape contents by the empty word λ or by a single letter. Thus, if M executes a cycle of the form q 0 ¢a 1 a 2 · · · a i−1 a i a i+1 a i+2 · · · a n $ c M q 0 ¢a 1 a 2 · · · a i−1 a i+2 · · · a n $, by deleting the factor a i a i+1 , where a 1 , a 2 , . . . , a n ∈ Γ, then this cycle begins with a sequence of i MVR steps that shift the window to the factor a i a i+1 and a subsequent rewrite step that deletes this factor. As M is deterministic, the next cycle begins with a sequence of i − 1 MVR steps that shift the window to the factor a i−1 a i+2 , which implies that the latter cycle has a smaller right distance than the former. If M executes a cycle of the form q 0 ¢a 1 a 2 · · · a i−1 a i a i+1 a i+2 · · · a n $ c M q 0 ¢a 1 a 2 · · · a i−1 ba i+2 · · · a n $, by replacing the factor a i a i+1 by the letter b, where a 1 , a 2 , . . . , a n , b ∈ Γ, then this cycle begins with a sequence of i MVR steps that shift the window to the factor a i a i+1 and the subsequent rewrite step. As M is deterministic, the next cycle begins with a sequence of i − 1 MVR steps that shift the window to the factor a i−1 b, which implies that the latter cycle has at most the same right distance as the former. Together these two cases show that M is indeed monotone. Obviously, the same arguments apply if M is a deterministic RWW-automaton of window size two.
Thus, we have the following inclusion. The proof of Proposition 4.4 rests on the fact that, in each cycle, a restarting automaton with a window of size two replaces a factor of length two by a word of length at most one. Thus, this result also extends to deterministic restarting automata of any finite window size k ≥ 3, provided that each of their rewrite operations rewrites a factor of length k by a word of length at most one. However, if a deterministic restarting automaton of window size k ≥ 3 contains a rewrite operation of the form δ(q, a 1 a 2 · · · a k ) = (q , b 1 b 2 ), where a 1 , a 2 , . . . , a k , b 1 , b 2 are letters, then after performing a cycle of the form it could happen that in the next cycle the factor of length k that ends in c m b 1 is rewritten, which means that the cycle containing this rewrite step has a larger right distance than the previous cycle. Hence, this restarting automaton would not be monotone.
Below we need the following technical result that is based on Lemma 3 of [4] (pages 1806-1808).
Lemma 4.6. Let A be a deterministic finite-state acceptor with input alphabet Σ. For each word x = x 1 x 2 · · · x n , where x i ∈ Σ, and each integer i, 1 ≤ i ≤ n, let q x,i denote the state entered by A after processing the prefix x 1 x 2 · · · x i . Then there exists a deterministic two-way finite-state acceptor A such that, for each input x = x 1 x 2 · · · x n and each i, 2 ≤ i ≤ n, if A starts its computation on x in state q x,i with its head on x i , then A finishes its computation in state q x,i−1 with its head on the symbol x i−1 . Moreover, during this computation A only visits (a part of ) x 1 x 2 · · · x i . Now we come to the main result of this subsection.
Theorem 4.7. Each deterministic monotone RWW-automaton of window size three can be simulated by a deterministic RWW-automaton of window size two.
Proof. Using Lemma 4.6 we can show the following. Let M = (Q, Σ, Γ, ¢, $, q 0 , 3, δ) be a deterministic monotone RWW-automaton, and let F (M ) be the set of all words x ∈ Γ * such that, after starting from the restarting configuration q 0 ¢x$, M will accept eventually, but the first rewrite/restart step within this computation is performed at the right end of the tape (that is, with the right sentinel $ in its read/write window). Then F (M ) is a regular language.
In fact, if x ∈ F (M ), then all rewrite/restart steps within the computation of M that starts from the configuration q 0 ¢x$ occur at the right sentinel $, as M is monotone. In addition, we can assume without loss of generality that the accept step is also performed at the right sentinel. Furthermore, observe that the move-right steps of M can be simulated by a deterministic finite-state acceptor A MVR . Based on Lemma 4.6, we obtain a deterministic two-way finite-state acceptor A MVR that can simulate the reverse transitions of A MVR . Now we construct a two-way finite-state acceptor A 1 for the set F (M ). The acceptor A 1 simulates the RWWautomaton M while scanning the tape from left to right. If M is to execute a rewrite/restart step before reaching the right sentinel, then A 1 halts in a non-final state. When M reaches the right end of its tape (that is, when the right sentinel $ appears in the read/write window), then, instead of executing the rewrite/restart step of M , the acceptor A 1 simulates the rewrite step within its finite-state control and (a) it remembers the contents of the rewritten tape between the leftmost letter in the window of M and the right sentinel, and (b) by using the deterministic two-way finite-state acceptor A MVR , it computes the state that M enters when it reaches the first symbol that was produced by the rewrite step within the previous cycle. Then it continues the simulation of the computation of M from this point onwards. When M halts accepting or rejecting, then A 1 accepts or rejects as well. Otherwise, A 1 simulates the next rewrite step in its finite-state control and continues.
Obviously, the computation of A 1 is finite for any input word x. Thus, it follows that F (M ) is a regular language. In addition, from A 1 , we can construct a (one-way) finite-state acceptor A = (Q A , Γ, δ A , q A,0 , F A ) for the language F (M ).
We now show how to construct a deterministic RWW-automaton M = (Q , Σ, Γ , ¢, $, q 0 , 2, δ ) of window size two that accepts the same language as M .
The read/write window of M is smaller than the read/write window of M . Hence, in order to simulate a cycle of M , the automaton M may have to perform more than one cycle. Accordingly, its state will be used to represent not only the current state of M , but also the symbol immediately to the left of its current window position and the corresponding state of the finite-state acceptor A. Hence, the set of states of M will be The initial state of M is q 0 = [q 0 , λ, q A,0 ], and the first step performed by M from a restarting configuration with a word x on its tape is for all states p, p ∈ Q A such that δ A (p, u 2 ) = p .
However, the simulation of the rewrite steps of M is more complicated. First of all, no rewrite at the right end of the tape of M needs to be simulated, as all the remaining rewrite steps by M must then also occur at the right end of the tape. Instead, M can inspect the state of A after scanning the last letter of the current contents of the tape and accept or reject immediately. Thus, M will only simulate a rewrite of M if the corresponding contents of the window of M does not contain the right sentinel $. Any combined rewrite/restart step of M according to will be simulated as follows: (i) If v = λ, the automaton M rewrites u 2 u 3 by a special symbol ∆ ∈ Γ and restarts. When in a subsequent cycle the symbol ∆ appears in the read/write window of M , the automaton deletes ∆ and the symbol immediately to the left of ∆. This completes the simulation of (4.1) by M . (ii) If v = v 1 for some v 1 ∈ Γ, the automaton M rewrites u 2 u 3 by the pair [∆, v 1 ] and restarts. When [∆, v 1 ] appears as the second symbol within the read/write window of M , the automaton rewrites the contents of its read/write window by v 1 , in this way completing the simulation of (4.1). (iii) If v = v 1 v 2 for some v 1 , v 2 ∈ Γ, the automaton M cannot simulate this rewrite step in two cycles, as two cycles would shorten the tape by at least two symbols. The automaton M must first read the tape until it sees u 2 u 3 (preceded by u 1 ). If v 1 = u 1 , the automaton simply rewrites u 2 u 3 into v 2 and the simulation of (4.1) is complete. Otherwise, M rewrites u 2 u 3 into the symbol [v 1 , v 2 ] with the meaning that the contents of the corresponding tape field is v 2 and its left neighbour should be v 1 . Because of the monotonicity of M , after performing the combined rewrite/restart step using (4.1), M cannot perform another rewrite within the next cycle before its window contains the whole factor v = v 1 v 2 (otherwise the right distance of the latter cycle would be larger than that of the former). Therefore, the simulating automaton M will scan the tape until it sees u 1 [v 1 , v 2 ]. It can then interpret the contents of both fields containing u 1 and [v 1 , v 2 ] properly as fields containing v 1 and v 2 . Of course, the transition relation δ of M must also include move-right instructions over fields containing pairs of symbols, as the next rewrite after using (4.1) can occur to the right of v 1 , and in addition, all rewrite instructions of M must preserve the information within the first element of a pair symbol on its tape.
In general, the tape of M will contain symbols from Γ and pairs of symbols from Γ × Γ: • The automaton M interprets a symbol x ∈ Γ on its tape as x on the tape of M , if it is not followed by a pair, and as v 1 on the tape of M , if it is followed by a pair [v 1 , v 2 ]. • The automaton M interprets a symbol [x, y] ∈ Γ × Γ on its tape as y on the tape of M , if it is not followed by a pair, and as v 1 on the tape of M , if it is followed by a pair [v 1 , v 2 ].
As M is deterministic and monotone, all pair symbols on the tape of M will be scanned by M prior to simulating any further rewrites by M . Hence, all symbols on the tape of M will be interpreted correctly and the automaton M is deterministic. Moreover, as all computations of deterministic RWW(2)-automata are monotone by Proposition 4.4, it follows that M is monotone.
Because of Theorem 4.1 the above simulation has the following consequence. In combination, our results yield the following construction of a deterministic monotone RWW-automaton of window size two from a deterministic monotone RWW-automaton of window size k ≥ 4. Let M be a deterministic monotone RWW-automaton of window size k ≥ 4. From M , we can first construct a DPDA P for the language L(M ) as shown in the proof of Theorem 2.2 in [7]. From this DPDA, we can derive a deterministic monotone RWW-automaton of window size three for L(M ) as in the proof of Theorem 4.1, and then, using the construction above, we obtain a deterministic (monotone) RWW-automaton of window size two for L(M ).

On deterministic RWW-automata
Here we turn to deterministic RWW-automata that are not (necessarily) monotone. We have seen above that deterministic RWW-and RRWW-automata of window size two are necessarily monotone, which implies that they yield a characterization for the class DCFL of deterministic context-free languages. What can be said about deterministic RWW-and RRWW-automata of window size larger than two?
We begin with a simple example, considering the non-context-free language It is known that L expo is a Church-Rosser language [17], and hence, it is accepted by a deterministic RWWautomaton [24]. In fact, it is even accepted by a deterministic RWW-automaton of window size three. (1) δ(q 0 , ¢a$) = Accept, It is easily seen that M accepts the language L expo . Also observe that M is non-monotone, as, for example, is a non-monotone accepting computation.
As L expo ∈ L(det-RWW(3)), we have the following chain of inclusions, where CRL denotes the class of Church-Rosser languages: It remains open whether the latter inclusions are proper or not.

On shrinking restarting automata
We now turn to a generalized type of restarting automaton, the shrinking restarting automaton, which was introduced in [26] and further studied in [9][10][11]. A shrinking restarting automaton M is defined just like an RRWW-automaton with the one exception that it is no longer required that each rewrite step u → v of M must be length-reducing. Instead, there must exist a weight function ω that assigns a positive integer ω(a) to each letter a of M 's tape alphabet Γ such that, for each rewrite step u → v of M , ω(u) > ω(v). Here the function ω is extended to a morphism ω : Γ * → N by taking ω(λ) = 0 and ω(wa) = ω(w) + ω(a) for all words w ∈ Γ * and letters a ∈ Γ. We use the notation sRRWW and sRWW to denote shrinking RRWW-and RWW-automata.
In [10], the following result has been established, where FCA denotes the class of finite-change automata from [30]. A finite-change automaton is a nondeterministic linear-bounded automaton that does not change the contents of any tape cell more than r times during any accepting computation, where r ≥ 1 is a constant. In the proof of Lemma 17 in [10], it is shown that a finite-change automaton A can be simulated by an sRRWW-automaton M with window size one. In fact, the sRRWW(1)-automaton M just performs rewrite steps that replace a single letter by another single letter. Hence, M can be interpreted as an ordered RRWWautomaton (ORRWW-automaton) as defined in [14]. These are sRRWW-automata that have a window of size three, but the rewrite steps of which just replace the symbol in the middle of the window by a smaller letter, that is, by a letter of less weight. This yields the following consequence, which answers the question about the expressive power of ORRWW-automata that was left open in [14]. The simulation of an sRRWW-automaton of window size k by an sRWW-automaton given in [10] yields that the latter has window size max{2k, 9}. Thus, we obtain the following result.  Proof. Obviously, a finite-state acceptor can be simulated by an sRWW(1)-automaton that does not use any rewrite/restart operations. Thus, REG ⊆ L(sRWW(1)).
In order to prove that this inclusion is proper, we consider the example language which is easily seen to be a deterministic context-free language that is not regular. Now an sRWW(1)-automaton M ≥ = (Q, {a, b}, Γ, ¢, $, q 0 , 1, δ) for the language L ≥ can be defined by taking Q = {q 0 , q 1 , q 2 , p 0 , p 1 , p 2 }, Γ = {a, b, a 1 , a 2 , a 3 , b 1 , b 2 }, and by defining the transition relation δ as follows: From the form of the transitions, it is easily seen that M ≥ performs an accepting tail computation iff the tape contents is of the form z = a m 3 b n 2 for some m, n ≥ 0 or of the form a m 3 a 1 a r b n 2 for some m, n, r ≥ 0. Thus, the corresponding input is of the form a s b t for some s, t ≥ 0. During an accepting computation on an input of this form, the occurrences of the letter a are rewritten, from left to right, first into a 1 , then into a 2 , and finally into a 3 . Analogously, the occurrences of the letter b are rewritten, from left to right, first into b 1 and then into b 2 . However, an occurrence of b can only be rewritten into b 1 (by (11) or (18)) if in that cycle, the rightmost occurrence of the letter a that has already been rewritten happens to be an a 1 (see (4) and (12)), and an occurrence of b 1 can only be rewritten into b 2 (by (15) or (21)) if in that cycle, the rightmost occurrence of the letter a that has already been rewritten happens to be an a 2 (see (5) and (16)). It follows that s ≥ t, that is, L(M ≥ ) = L ≥ . Thus, REG is indeed a proper subclass of L(sRWW (1)).
The technique used in the construction of the sRWW(1)-automaton for the language L ≥ in the above proof can easily be extended to show that also the language L copy = { w#u | w, u ∈ {a, b} * , |w|, |u| ≥ 2, u is a scattered subword of w } is accepted by an sRWW(1)-automaton. In [15], it has been shown that this language is not even growing context-sensitive.
Proposition 5.4 establishes a lower bound for the expressive power of sRWW(1)-automata. Next we derive an upper bound for it. Recall from [15,16] that an ORWW-automaton is an sRWW(3)-automaton the rewrite steps of which just replace the symbol in the middle of the window by a smaller letter, that is, by a letter with less weight. Proof. Let M = (Q, Σ, Γ, ¢, $, q 0 , 1, δ) be a shrinking RWW(1)-automaton that is compatible with the weight function ϕ : Γ → N + , and let c = max{ ϕ(a) | a ∈ Σ }, that is, c is the maximal weight of an input letter. Without loss of generality, we can assume that M only accepts with its read/write window on the right sentinel $.
We construct an ORWW-automaton M o = (Q, Σ, ∆, ¢, $, q 0 , 3, δ o , >), where > is a partial ordering on the tape alphabet ∆ such that x > y holds whenever M o rewrites a symbol x into y. First we take Here the symbol [α] encodes the word α ∈ Γ * , where the weight ϕ(α) is bounded from above by the constant c. As the weight of each letter a ∈ Γ is positive, we see that there are only finitely many words from Γ * with weight bounded from above by c. Hence, ∆ is indeed a finite alphabet. We define a morphism ψ : ∆ * → Γ * through ψ(a) = a for all a ∈ Σ and ψ([α]) = α for all [α] ∈ ∆ Σ, and we define the partial ordering > on ∆ by taking, for all a, b ∈ Σ, a > [a], and for all x, y ∈ ∆ Σ, x > y if ϕ(ψ(x)) > ϕ(ψ(y)).
Finally, we specify the transition relation δ o as follows, where MVR denotes the single-step computation relation that is induced by the MVR steps of M , a, b ∈ Σ, u, v, z, α ∈ Γ * , ω ∈ ∆, X ∈ Γ, and q 1 , q 2 ∈ Q: MVR ¢uq 1 Xv$ and δ(q 1 , X) z, MVR ¢uq 1 ψ(ω), Next we turn to shrinking RWW-automata of window size two. We shall prove that window size two is sufficient for these automata to enable them to accept all growing context-sensitive languages. A language L ⊆ Σ * is growing context-sensitive if it is generated by a grammar G = (N, Σ, S, P ) such that, for each production ( → r) ∈ P , = S or | | < |r| (see, e.g., [3]). Concerning the class GCSL of growing contextsensitive languages, the following characterization has been established, where sTPDA denotes the class of shrinking two-pushdown automata (see below). The two-pushdown automaton is defined as follows, where this definition is taken from [2].
Given a word w ∈ Σ * as input, the TPDA A starts in its initial state q 0 with its first pushdown only containing the bottom marker ⊥ and its second pushdown containing the input w followed by the bottom marker. Thus, at the start, A sees the bottom marker on its first pushdown and the first letter of w on its second pushdown. The automaton A is a deterministic two-pushdown automaton (DTPDA), if δ is a (partial) function from A configuration of the (D)TPDA A is described as uqv, where q ∈ Q is the actual state, u ∈ Γ * is the contents of the first pushdown store with the first letter of u at the bottom and the last letter of u at the top, and v ∈ Γ * is the contents of the second pushdown store with the last letter of v at the bottom and the first letter of v at the top. Thus, for an input string w ∈ Σ * , the corresponding initial configuration is ⊥q 0 w⊥. By applying a transition (q, u, v) ∈ δ(p, a, b), the automaton replaces the symbol a on the top of its first pushdown store by the word u and the symbol b on the top of its second pushdown store by the word v, and it changes from state p to state q. The (D)TPDA A induces a computation relation * A on the set of configurations, which is the reflexive transitive closure of the single-step computation relation A (see, e.g., [5]). The (D)TPDA A accepts with empty pushdown stores, that is, is the language accepted by A.
Thus, if A is a shrinking TPDA with weight-function ϕ, then ϕ(u 1 q 1 v 1 ) > ϕ(u 2 q 2 v 2 ) holds for all configurations u 1 q 1 v 1 and u 2 q 2 v 2 of A that satisfy u 1 q 1 v 1 A u 2 q 2 v 2 . Observe that the input is provided to a TPDA as the initial contents of its second pushdown store, and that in order to accept a TPDA is required to empty its pushdown stores. Thus, it is forced to consume its input completely. Using standard techniques from automata theory, it can be shown that, for a (shrinking) (deterministic) TPDA A = (Q, Σ, Γ, δ, q 0 , ⊥, F ), we may require that the special symbol ⊥ can only occur at the bottom of a pushdown store, and that no other letter can occur at that place.
From the definition of the transition relation δ, we see that A halts immediately whenever one of its pushdown stores is emptied. Because of the above property, this happens if and only if a transition of the form (q, a, ⊥) → (q , u, λ) or (q, ⊥, b) → (q , λ, v) is performed. Thus, we can assume without loss of generality that, if A does accept on input w ∈ Σ * , then ⊥q 0 w⊥ * A q for some q ∈ F , and if A does not accept on input w ∈ Σ * , then ⊥q 0 w⊥ * A ⊥q for some q ∈ F , that is, even in this situation, A empties its second pushdown store completely and only leaves the bottom marker on its first pushdown store before it halts. Hence, all the halting and accepting configurations of A are of the form q, where q ∈ F , and all the halting and rejecting configurations of A are of the form ⊥q, where q ∈ F . In addition, we can assume that A has a single halting state only.
Proof. As the language L copy mentioned above is accepted by an sRWW(1)-automaton, we see that L(sRWW(2)) contains a language that is not growing context-sensitive. So it remains to prove that each growing contextsensitive language is accepted by some sRWW(2)-automaton.
Let L ⊆ Σ * be a growing context-sensitive language. By Theorem 5.6, there exists an sTPDA A = (P, Σ, Γ, δ, p 0 , ⊥, {p f }) that accepts the language L. Let ϕ : P ∪ Γ → N + be a weight function such that A is shrinking with respect to this weight function. Without loss of generality we can assume that ϕ(aqb) − ϕ(upv) ≥ 2 for each transition (p, u, v) ∈ δ(q, a, b). We now present an sRWW(2)-automaton M that simulates the computations of A.
Using this weight function, it is easily verified that the RWW-automaton M is shrinking. Indeed, instructions of types (2) and (9) are weight-reducing because of the weight associated to the letters from Σ , instructions of type (8) are weight-reducing because of the weight associated to the letters from the subalphabet P of Ω, instructions of types (10) and (12) are weight-reducing, as the corresponding instructions of A are weightreducing with respect to ϕ, and the instructions of types (11) and (13) are weight-reducing because of our assumption that each instruction of A reduces the weight of the corresponding configuration by at least two.
It remains to show that L(M ) = h(L(A)), where h : Σ * → Σ * is the morphism induced by mapping a to a for all a ∈ Σ. A configuration of the form ⊥uxpv⊥ of A, where u, v ∈ Γ * , x ∈ Γ, and p ∈ P , is encoded by the tape contents ¢⊥u[x, p]v$ of M , or by the tape contents ¢⊥uxpv$. The latter type of encoding is used whenever a step of A is being simulated that only pops from the lefthand pushdown (see instructions (11) and (13)). However, as soon as such an encoding is detected, it is immediately transformed into an encoding of the former form by instruction (8). Now using this encoding of the configurations of A, the sRWW-automaton M simulates the computations of A step by step. Hence, it follows that L(M ) = h(L(A)).
By renaming the letters of Ω accordingly, an sRWW(2)-automaton is obtained that accepts the language L(A). This completes the proof of Theorem 5.9.
It is easily seen that each ORWW-automaton can be simulated by an sRWW(2)-automaton. Based on a pumping lemma for ORWW-automata, it has been shown in [16] that the deterministic linear language L = { a n b n | n ≥ 0 } is not accepted by any ORWW-automaton. As this language is accepted by an sRWW(2)automaton, we have the following chain of inclusions. It currently remains open whether the inclusions L(sRWW(1)) ⊆ L(ORWW) and L(sRWW(2)) ⊆ L(sRWW(9)) are proper.
Concerning monotone sRWW-and sRRWW-automata of window size one and two, we now derive the following results.
Proof. (a) Obviously, each regular language is accepted by some monotone sRWW(1)-automaton that does not execute any rewrite step. On the other hand, the non-regular language is accepted by a monotone RRWW(1)-automaton, and so it is contained in L(mon-sRRWW(1)). Indeed, let M = (Q, {a, b}, {a, b}, ¢, $, q 0 , 1, δ) be the RRWW(1)-automaton that is defined by taking Q = {q 0 , q 1 , q 2 , p 0 , p 1 , p 2 } and by defining the transition relation δ as follows:  (1)-automaton can be interpreted as replacing a letter by either a letter with a smaller weight or by the empty word λ. Thus, we can assume without loss of generality that M already has this property.
Next we study the implications that the monotonicity has on the computations of M . Let be a cycle of M , where y ∈ δ(q 2 , b), and assume that x ∈ δ(q 1 , a). Thus, in the above cycle, M moves across the distinguished letter a by executing a MVR step (p 1 , MVR) ∈ δ(q 1 , a), and it completes the cycle by the rewrite/restart step y ∈ δ(q 2 , b), but it could have executed the rewrite/restart step x ∈ δ(q 1 , a) instead. Hence, the cycle above, which has the right distance D r (C 1 ) = |w| + 2, can be followed by the cycle which has the right distance D r (C 2 ) = |v| + |y| + |w| + 2. As M is monotone, this means that D r (C 2 ) = |v| + |y| + |w| + 2 ≤ D r (C 1 ) = |w| + 2, which implies that |v| = 0 = |y|, that is, v = y = λ. Thus, the cycle C 1 actually looks as follows: where λ ∈ δ(q 2 , b).
We now define a stateless ORWW-automaton M s = (Σ, ∆, ¢, $, 3, δ s , >). To simplify the notation, the set of states is omitted from the definition and the states are omitted from the transition relation δ s . We take for all a ∈ Σ and B ∈ ∆ Σ, − [i, x, P ] > [j, y, P ] for all i < j and all x, y ∈ Γ ∪ {λ}, P, P ⊆ Q, and define the transition relation δ s as follows, where a, b, c ∈ Σ, i, j ∈ {0, 1, . . . , |Γ|}, P, P ⊆ Q, x, y, z ∈ Γ, x λ ∈ Γ ∪ {λ}, and X ∈ ∆: δ s (¢[i, λ, P ]X) = {MVR}, where P y = { q ∈ Q | ∃p ∈ P : (q, MVR) ∈ δ(p , y) }, Here a letter of the form [i, x, P ] encodes the information that, at the current tape position, M currently has the letter x, that this letter has already been rewritten i times, and that by scanning the current tape contents from left to right, M can reach any of the states in P after having read the letter x. A letter of the form [i, λ, P ] encodes the information that the letter at the current tape position has been rewritten to λ, and that this was done either by the i-th rewrite at the current position or by the first rewrite at the current position, in which case i is the number of rewrites that have been applied so far at the first position to the left of the current position that has not yet been rewritten to λ. Finally, P is again the set of states that M can reach by scanning the current tape contents from left to right up to the current position.
It remains to prove that L(M s ) = L(M ). Instructions (2) and (7) encode state information of M into the letters that are moved over by M 's read/write window through MVR steps. Instructions (3), (5), (8), and (10) simulate rewrite steps of M that rewrite a letter by another letter and they encode the corresponding state information in the newly written symbols. Furthermore, instructions (4), (9), and (10) simulate rewrite steps of M that replace a letter by the empty word, and instruction (11) updates state information that is stored in symbols of the form [i, λ, P ] that has become outdated because a rewrite step was performed somewhere to the left of this symbol. Observe that the λ-rewrite steps of the form (10) (with x λ = λ) can only be applied to letters that have already been rewritten before, which means that later no rewrite steps can be performed to the left of these letters due to the monotonicity of M . From this description it is easily seen that all accepting computations of M s are simulations of accepting computations of M , that is, we have L(M s ) ⊆ L(M ).
To prove the converse inclusion, let w = a 1 a 2 · · · a n be a word from L(M ), where n ≥ 0 and a 1 , a 2 , . . . , a n ∈ Σ. If n ≤ 1, then w ∈ (Σ ∪ {λ}) ∩ L(M ), and so M s can accept on input w by using instruction (1). Assume that n ≥ 2 and let be an accepting computation of M on input w, where q + ∈ Q and Accept ∈ δ(q + , $). As M is monotone, the above computation is monotone. If all rewrites are performed strictly from left to right, then it is easily seen that M s can simulate this computation, that is, M s will also accept on input w. Finally, assume that that w i+1 is obtained from w i by rewriting the letter b r+1 into c, that w i+2 is obtained from w i+1 by rewriting the letter b j into d, and that this is the first such situation in the above computation. Then we see from our discussion above that r = j and that c = λ, that is, · · · b t , w i+1 = b 1 b 2 · · · b j−1 b j b r+2 · · · b t , and w i+2 = b 1 b 2 · · · b j−1 db r+2 · · · b t .
In particular, none of the letters to the left of d can be rewritten anymore. By simulating the steps of the above computation of M up to w i , M s obtains the restarting configuration where we underline the symbols inside the read/write window of M s . Now by instruction (5), (6), and (10), M s can move its window to the right until it reaches the configuration As P j is the set of all states that M can reach by reading the prefix ¢b 1 b 2 · · · b j of the tape contents from left to right, there exists a state q ∈ P j such that λ ∈ δ(q, b r+1 ), and hence, M s can rewrite the letter b r+1 into [i j , λ, P j ] by instruction (9), which yields the configuration In the next cycle [i j , b j , P j ] is rewritten into [i j + 1, d, P ], and then [i j , λ, P j ] can be rewritten into [i j + 1, λ, P ] by instruction (11), which yields the configuration It now follows that M s can simulate the above computation of M , implying that w ∈ L(M s ). Hence, it follows that L(M s ) = L(M ).
This completes the proof of Lemma 5.13 and, therewith, of Theorem 5.11.

On deterministic shrinking restarting automata
Finally, we consider deterministic sRWW-and sRRWW-automata. The construction in the proof of Proposition 5.5 carries over to the deterministic case, and it can easily be extended to simulate a det-sRRWW(1)automaton by a det-ORRWW-automaton. As det-ORWW-automata and det-ORRWW-automata only accept regular languages (see [14,19]), we obtain the following results. Also the simulation of an sTPDA by an sRWW(2)-automaton in the proof of Theorem 5.9 carries over to the deterministic case. As deterministic sTPDAs characterize the class CRL of Church-Rosser languages [25], this yields the following result. L(det-sRWW(2)) = L(det-sRRWW(2)) = L(det-sRWW) = L(det-sRRWW) = CRL.
Thus, we see that for deterministic shrinking RWW-and RRWW-automata, the hierarchy based on window size consists of only two levels: window size one yields the regular languages, and window size k ≥ 2 yields the Church-Rosser languages.
Concerning monotone deterministic sRWW-and sRRWW-automata of window size one or two, the above results yield the following consequences.  The taxonomy of (shrinking) restarting automata with small window size. An arrow → denotes a proper inclusion, while → ? denotes an inclusion that is not known to be proper.

Conclusion
We have studied the expressive power of restarting automata and shrinking restarting automata of small window size. We have seen that for deterministic as well as for nondeterministic RWW-and RRWW-automata that are monotone, window size two suffices to accept all languages that can be accepted by these types of automata. In fact, our proofs provide constructions that allow converting a (deterministic) monotone RWWautomaton of window size k ≥ 3 into an equivalent (deterministic) monotone RWW-automaton of window size two.
It is known that deterministic RWW-and RRWW-automata of window size one just accept the regular languages [13,18]. Here we have seen that deterministic RWW-and RRWW-automata of window size two are necessarily monotone, which implies that they yield a characterization for the class DCFL of deterministic context-free languages. What can be said about deterministic RWW-and RRWW-automata of window size larger than two? Here we have the following chain of inclusions DCFL L(det-RWW(3)) ⊆ L(det-RRWW(3)) ⊆ L(det-R(R)WW) = CRL, but it remains open whether the latter inclusions are proper. In fact, it is open whether there exists an integer k ≥ 3 such that L(det-RWW(k)) = L(det-RWW) = CRL, or whether the language classes (L(det-RWW(k)) k≥3 (and (L(det-RRWW(k)) k≥3 ) yield an infinite ascending hierarchy within the class CRL of Church-Rosser languages.
Also it is open whether L(det-RWW(k)) = L(det-RRWW(k)) for any k ≥ 3. Recall that in [29], Natalie Schluter has only shown that L(det-RRWW(k)) ⊆ L(det-RWW(2k − 2)) for all k ≥ 2. Thus, we see that for deterministic RWW-and RRWW-automata, the influence of the window size on the expressive power of these automata is still unsolved. Concerning shrinking restarting automata, we have seen that for sRRWW-automata, already window size one suffices, while for monotone and/or deterministic sRWW-and sRRWW-automata, window size two is required to obtain the full expressive power of these types of automata. In particular, we have seen that for deterministic shrinking RWW-and RRWW-automata, the hierarchy based on window size consists of only two levels: window size one yields the regular languages, and window size k ≥ 2 yields the Church-Rosser languages. Also it remains open whether sRWW(1)-automata are as powerful as ORWW-automata, whether window size nine is really needed to obtain the full power of sRWW-automata, and whether monotone sRRWW(1)-automata accept all context-free languages. The diagram in Figure 1 summarizes the characterizations and inclusion relations we have obtained for (shrinking) restarting automata of small window size.
Recall from Remark 5.12 that the language L = { a m b m c, a m b 2m d | m ≥ 0 } is accepted by a monotone sRRWW(1)-automaton. This language is context-free, but not deterministic context-free. In fact, L is a linear language that even belongs to the class 2-detLIN of languages that are accepted by deterministic two-head finite automata that read their tape from both ends [22]. Accordingly, it may be of interest to study the relationship between the class 2-detLIN and the various language classes specified by shrinking restarting automata of window size one.