1 Introduction

A pebble automaton is a two-way finite state automaton that uses a fixed, finite number of pebbles that it can drop on, and lift from, the squares of its input tape. Pebble automata recognize regular languages only, provided the life times of the pebbles are nested (otherwise they recognize the logarithmic space languages). Automata with nested pebbles were introduced in [21], and in [11] for tree-walking automata. A tree transducer with nested pebbles was introduced in [25] as a model for XML-based query languages. In [15] some results were proved for the two-way finite state transducer with nested pebbles (pebble transducer, for short), which is the restriction of the tree transducer of [25] to monadic trees, i.e., to strings.

One result of [15] is that every partial function that can be computed by a nondeterministic pebble transducer, can in fact be computed by a deterministic one, with the same number of pebbles. Unfortunately, the proof of this result in [15, Theorem 3] is wrong.Footnote 1 In this paper the result is stated in Corollary 7, with a (hopefully) correct proof.

Another result of [15] is that for every two deterministic pebble transducers \(M_1\) and \(M_2\), there is a deterministic pebble transducer \(M\) that computes the composition of the functions computed by \(M_1\) and \(M_2\). In the proof, the constructed transducer \(M\) has \((k_1+1)(k_2+2)\) pebbles, where \(k_i\) is the number of pebbles of \(M_i\). It is conjectured in [15] that a transducer with \((k_1+1)(k_2+1)-1\) pebbles can do the same job (and it is easy to see that, in general, it cannot be done with less pebbles). In this paper the conjecture is proved, and stated in Theorem 11.

Our proofs are based on a reduction of pebble transducers to two-way finite state transducers (without pebbles), which is a straightforward generalization of the reduction of pebble automata to two-way finite state automata in [20]. This allows us to use the well-known facts that a partial function computed by a nondeterministic two-way finite state transducer can also be computed by a deterministic one (see, e.g., Theorem 22 of [12]), and that the deterministic two-way finite state transductions are closed under composition ([6]).

Other work on nested pebbles has appeared in, e.g., [25, 13, 14, 1619, 22, 2628, 30, 32].

All results stated in this paper are effective. Results that are known from the literature, or can easily be concluded from results in the literature, are stated as Propositions.

2 Definitions

For binary relations \(R_1\subseteq X\times Y\) and \(R_2\subseteq Y\times Z\), where \(X,Y,Z\) are sets, we denote by \(R_1\circ R_2\) their composition \(\{(x,z)\mid \exists y: (x,y)\in R_1, \,(y,z)\in R_2\}\). For classes of binary relations \(\mathcal {R}_1\) and \(\mathcal {R}_2\), we define \(\mathcal {R}_1\circ \mathcal {R}_2=\{R_1\circ R_2\mid R_1\in \mathcal {R}_1, \,R_2\in \mathcal {R}_2\}\). For a binary relation \(R\subseteq X\times Y\), the domain of \(R\) is \(\mathsf{dom}(R)=\{x\in X\mid \exists y\in Y: (x,y)\in R\}\), and its range is \(\mathsf{ran}(R)=\{y\in Y\mid \exists x\in X: (x,y)\in R\}\).

For a set \({\varDelta }\), the set of all strings over \({\varDelta }\) (i.e., sequences of elements of \({\varDelta }\)) is denoted \({\varDelta }^*\). For a string \(w\in {\varDelta }^*\), its length is denoted \(|w|\), and \(w(i)\) denotes its \(i\)th element (for \(1\le i\le |w|\)). The empty string is denoted \(\lambda \). For \(k\in {\mathbb N}=\{0,1,2,\ldots \}\), we define \({\varDelta }^k=\{w\in {\varDelta }^*\mid |w|=k\}\) and \({\varDelta }^{\le k}=\{w\in {\varDelta }^*\mid |w|\le k\}\).

2.1 Pebble transducers

A two-way finite state transducer (also called two-way generalized sequential machine, or 2gsm) is a finite state automaton with a two-way input tape, delimited by the endmarkers \(\triangleleft \) and \(\triangleright \), and a one-way output tape. A k-pebble transducer is a two-way finite state transducer that additionally carries \(k\) pebbles, each with a unique name, say, \(1,\ldots ,k\). Initially there are no pebbles on the input tape, but during its computation the transducer can drop pebbles on the squares of the input tape, lift them, drop them again, etc. In one step of its computation, the transducer can determine which pebbles are lying on the current square of the input tape, lift one of these pebbles, or drop a new pebble. However, the life times of the pebbles should be nested. This means that at each moment of time, pebbles \(1\) to \(\ell \) (for some \(0\le \ell \le k\)) are on the input tape, and at such a moment the only pebble that can be dropped on the current square is pebble \(\ell +1\), whereas the only pebble that can be lifted from the current square (if it is on that square) is pebble \(\ell \).

Formally, a k-pebble transducer (with \(k\ge 0\)) is a system \(M=({\varSigma },{\varDelta },Q,q_0,F,\delta )\) where \({\varSigma }\) and \({\varDelta }\) are the input and output alphabet, respectively, \(Q\) is the finite set of states, \(q_0\in Q\) is the initial state, \(F\subseteq Q\) is the set of final states, and \(\delta \) is the finite set of transitions. Each transition is of the form \((q,\sigma ,b)\mapsto (q',\varphi ,w)\) with \(q\in Q-F\), \(\sigma \in {\varSigma }\cup \{\triangleleft ,\triangleright \}\), \(b\in \{0,1\}^k\), \(q'\in Q\), \(\varphi \in \{\mathsf{right},\mathsf{left},\mathsf{drop},\mathsf{lift}\}\), and \(w\in {\varDelta }^*\). Intuitively, such a transition means that if \(M\) is in state \(q\), \(\sigma \) is the symbol on the current square, and, for every \(1\le m\le k\), \(b(m)=1\) if and only if pebble \(m\) is on the current square, then \(M\) can go into state \(q'\), output the string \(w\), and execute the instruction \(\varphi \), i.e., move the reading head one square to the right or left, drop pebble \(\ell +1\) (the “next” pebble), or lift pebble \(\ell \) (the “last” pebble); note that these instructions are undefined if, respectively, \(\sigma =\triangleright \), \(\sigma =\triangleleft \), all \(k\) pebbles are on the input tape (i.e., \(\ell =k\)), or pebble \(\ell \) is not on the current square (i.e., either \(\ell =0\) or \(b(\ell )=0\)).

For a given input string \(u\in {\varSigma }^*\), the input tape of \(M\) contains the string \(\triangleleft \,u\,\triangleright \). The squares of this tape are numbered \(0,1,\ldots ,|u|,|u|+1\). Accordingly, a pebble configuration of \(M\) on \(\triangleleft \,u\,\triangleright \) is a string \(\pi \in \{0,\ldots ,|u|+1\}^{\le k}\), where \(\pi (m)=j\) means that pebble \(m\) is currently on square \(j\) (for \(1\le m\le |\pi |\) and \(j\in \{0,\ldots ,|u|+1\}\)), and \(|\pi | < m\le k\) means that pebble \(m\) is currently not on the input tape. A configuration of \(M\) on \(\triangleleft \,u\,\triangleright \) is a triple \((q,i,\pi )\) with \(q\in Q\), the current state of \(M\), \(i\in \{0,\ldots ,|u|+1\}\), the current position of the reading head, and \(\pi \in \{0,\ldots ,|u|+1\}^{\le k}\), the current pebble configuration. The one step computation relation \(\vdash _u\) is defined in the obvious way on 4-tuples \((q,i,\pi ,v)\) where \((q,i,\pi )\) is a configuration and \(v\in {\varDelta }^*\) is the current content of the output, as follows.

Let \(\sigma \) be the content of the current input square, i.e., \(\sigma =\triangleleft \) if \(i=0\), \(\sigma =u(i)\) if \(1\le i\le |u|\), and \(\sigma =\triangleright \) if \(i=|u|+1\). Let \(b\in \{0,1\}^k\) indicate which pebbles are placed on this square, i.e., for every \(1\le m\le k\), \(b(m)=1\) if and only if \(\pi (m)=i\). If \(\delta \) contains a transition \((q,\sigma ,b)\mapsto (q',\varphi ,w)\), then \((q,i,\pi ,v)\vdash _u (q',i',\pi ',vw)\) if the following holds:

  • if \(\varphi =\mathsf{right}\), then \(i\ne |u|+1\), \(i'=i+1\) and \(\pi '=\pi \),

  • if \(\varphi =\mathsf{left}\), then \(i\ne 0\), \(i'=i-1\) and \(\pi '=\pi \),

  • if \(\varphi =\mathsf{drop}\), then \(i'=i\), \(|\pi |< k\) and \(\pi '=\pi i\),

  • if \(\varphi =\mathsf{lift}\), then \(i'=i\), \(\pi (|\pi |)=i\) and \(\pi =\pi ' i\).

The transduction computed by M, denoted \(\tau _M\), is the binary relation

$$\begin{aligned} \tau _M=\{(u,v)\in {\varSigma }^*\times {\varDelta }^*\mid \exists (q,i,\pi ): (q_0,0,\lambda ,\lambda )\vdash _u^*(q,i,\pi ,v), \,q\in F\}. \end{aligned}$$

The \(k\)-pebble transducer \(M\) is deterministic if \(\delta \) does not contain two transitions with the same left-hand side. In that case, \(\tau _M\) is a partial function from \({\varSigma }^*\) to \({\varDelta }^*\).

The class of transductions computed by \(k\)-pebble transducers is denoted by \(\hbox {PT}_k\), and by \(\hbox {DPT}_k\) for the deterministic transducers.

Example 1

A deterministic 4-pebble transducer \(M\) can translate an input string \(u\) into an output string that is a concatenation of all strings \(v\#w\#\) where \(v\) and \(w\) are (occurrences of) nonempty substrings of \(u\) and \(vw\) is in a given regular language \(R\). The transducer \(M\) moves pebble 1 from square 1 to square \(n\) of the input tape, where \(n=|u|\). When pebble 1 is at square \(i\), \(M\) moves pebble 2 from square \(i\) to square \(n\). In this way \(M\) systematically considers all nonempty substrings \(v\) of \(u\). For a fixed position of pebbles 1 and 2, \(M\) systematically considers all nonempty substrings \(w\) of \(u\), using pebbles 3 and 4 for that purpose. For each position of all 4 pebbles, \(M\) walks from pebble 1 to pebble 2 and then from pebble 3 to pebble 4, simulating a finite automaton that recognizes the regular language \(R\). If \(vw\in R\), then \(M\) repeats that walk and outputs the string \(v\#w\#\). \(\square \)

2.2 Counting transducers

Our first result (in the next section) will be the equivalence of the \(k\)-pebble transducer with a related type of two-way pebble transducer that uses its \(k\) pebbles in a very restricted, nonstandard way. Rather than manipulating pebbles by dropping and lifting them, a transducer \(M\) of this new type has all its \(k\) pebbles on the input tape at all times. To explain how \(M\) can move the pebbles, we first note that a pebble configuration \(\pi \in \{0,\ldots ,|u|+1\}^k\) on \(\triangleleft \,u\,\triangleright \) (with all pebbles on the input tape) can be viewed as usual as a number \(\mathsf{num}(\pi )\) in the \((|u|+2)\)-ary number system, with \(0\le \mathsf{num}(\pi )\le (|u|+2)^k-1\). As an example, for \(k=3\) and \(|u|=8\), the pebble configuration \(097\) (which means that pebble 1 is on \(\triangleleft \), pebble 2 is on \(\triangleright \), and pebble 3 is on the 7th symbol of \(u\)) corresponds to the (decimal) number \(97\); in this case the pebble configurations on \(u\) of length \(k\) represent all numbers between \(0\) (all pebbles on \(\triangleleft \)) and \(999\) (all pebbles on \(\triangleright \)). For pebble configurations \(\pi _1\) and \(\pi _2\) such that \(\mathsf{num}(\pi _1)+1=\mathsf{num}(\pi _2)\), we say that \(\pi _2\) is the next pebble configuration of \(\pi _1\), and that \(\pi _1\) is the previous pebble configuration of \(\pi _2\). It is well known that a \(k\)-pebble transducer (as defined in Sect. 2.1) can count from \(1\) to \((|u|+2)^k\) by systematically constructing all pebble configurations of length \(k\), going from one to the next, starting with the first pebble configuration of length \(k\) (representing \(0\), with all pebbles on \(\triangleleft \)) and ending with the last one (representing \((|u|+2)^k-1\), with all pebbles on \(\triangleright \)). The transducer \(M\) of the new type only has the instructions \(\mathsf{right}\) and \(\mathsf{left}\), which are now also defined when the current symbol under the reading head is \(\triangleright \) or \(\triangleleft \), respectively (provided the current pebble configuration is not the last or the first, respectively). The effect of moving right from \(\triangleright \), is that the reading head jumps to \(\triangleleft \) and the pebble configuration is changed to the next one. Similarly, the effect of moving left from \(\triangleleft \), is that the reading head jumps to \(\triangleright \) and the pebble configuration is changed to the previous one. We note here that (as in [25]) the reading head can be viewed as an additional pebble, viz. pebble \(k+1\), and so a pair \((i,\pi )\) consisting of the current position of the reading head and the current pebble configuration, can be viewed as the pebble configuration \(\pi i\in \{0,\ldots ,|u|+1\}^{k+1}\) on \(\triangleleft \,u\,\triangleright \). Viewed in this way, the instruction \(\mathsf{right}\) changes the pebble configuration \(\pi i\) to the next one, and the instruction \(\mathsf{left}\) changes it to the previous one. This shows the naturalness of the new interpretation of \(\mathsf{right}\) and \(\mathsf{left}\). We will call the new type of transducer a \(k\)-counting transducer.

Formally, a k-counting transducer (with \(k\ge 0\)) is a system \(M=({\varSigma },{\varDelta },Q,q_0,F,\delta )\), defined in the same way as a \(k\)-pebble transducer except that it does not have instructions \(\mathsf{drop}\) and \(\mathsf{lift}\), i.e., \(\varphi \in \{\mathsf{right},\mathsf{left}\}\) in every transition \((q,\sigma ,b)\mapsto (q',\varphi ,w)\). A pebble configuration of \(M\) on \(\triangleleft \,u\,\triangleright \) (with \(u\in {\varSigma }^*\)) is a string \(\pi \in \{0,\ldots ,|u|+1\}^k\), and a configuration of \(M\) on \(\triangleleft \,u\,\triangleright \) is of the form \((q,i,\pi )\), as for the \(k\)-pebble transducer (but with the pebble configuration of length \(k\)). The one step relation \(\vdash _u\) is defined as for the \(k\)-pebble transducer on 4-tuples \((q,i,\pi ,v)\), except that now:

  • if \(\varphi =\mathsf{right}\) then either \(i\ne |u|+1\), \(i'=i+1\) and \(\pi '=\pi \),

    • or \(i=|u|+1\), \(i'=0\), and \(\pi '\) is the next pebble configuration of \(\pi \),

  • if \(\varphi =\mathsf{left}\) then either \(i\ne 0\), \(i'=i-1\) and \(\pi '=\pi \),

    • or \(i=0\), \(i'=|u|+1\), and \(\pi '\) is the previous pebble configuration of \(\pi \).

Finally, the transduction computed by M, denoted \(\tau _M\), is

$$\begin{aligned} \tau _M=\{(u,v)\in {\varSigma }^*\times {\varDelta }^*\mid \exists (q,i,\pi ): (q_0,0,0^k,\lambda )\vdash _u^*(q,i,\pi ,v), \,q\in F\}. \end{aligned}$$

Note that \(0^k\) denotes a string of \(k\) \(0\)’s; it is the first pebble configuration. Determinism of \(M\) is defined as for the \(k\)-pebble transducer.

The class of transductions computed by \(k\)-counting transducers is denoted by \(\hbox {CT}_k\), and by \(\hbox {DCT}_k\) for the deterministic transducers.

Example 2

A 4-counting transducer \(M'\) that computes the same transduction as the 4-pebble transducer \(M\) of Example 1, systematically considers all possible pebble configurations by repeatedly moving to the right. For each such pebble configuration it checks that the pebbles are not on an endmarker, and it checks that pebble 2 is not to the left of pebble 1, and pebble 4 is not to the left of pebble 3. If so, pebbles 1 and 2 determine a nonempty substring \(v\) of the input string \(u\), and pebbles 3 and 4 determine a nonempty substring \(w\). Then \(M'\) operates in the same way as \(M\).\(\square \)

Whenever we construct a \(k\)-pebble or \(k\)-counting transducer, we can also use transitions containing an identity instruction \(\varphi =\mathsf{stay}\), with the semantics \(i'=i\) and \(\pi '=\pi \). Such an instruction can easily be simulated in two steps, first moving right and then moving left (or vice versa if the reading head is on \(\triangleright \)).

3 Equivalence of pebble and counting transducers

This section contains a basic result, underlying the proofs of our main results. We first show that the two types of two-way pebble transducer, defined in the previous section, are equivalent, and then we use this to characterize the \(k\)-pebble transductions in terms of \(0\)-pebble transductions. One direction of the characterization was shown for \(k=1\) in the proof of Lemma 1 of [15]. For arbitrary \(k\) the characterization was presented for transducers with empty output alphabet, i.e., for automata, in [20] (and rediscovered by this author).

Lemma 3

For every \(k\in {\mathbb N}\), \(\hbox {PT}_k=\hbox {CT}_k\) and \(\hbox {DPT}_k=\hbox {DCT}_k\).

Proof

We first show the obvious fact that every \(k\)-counting transducer \(M\) can be simulated by a \(k\)-pebble transducer \(M'\). The transducer \(M'\) initializes the simulation by dropping all its pebbles on \(\triangleleft \), and then stepwise simulates \(M\). The instruction \(\mathsf{right}\) of \(M\) is simulated by the same instruction of \(M'\) when the reading head is not on \(\triangleright \). Now assume that the reading head is on \(\triangleright \). If all pebbles are on \(\triangleright \), then \(M'\) aborts. Otherwise, \(M'\) must construct the next pebble configuration of \(M\). To do this, \(M'\) first lifts all pebbles \(m+1\) to \(k\), where \(m\) is the largest number such that pebble \(m\) is not on \(\triangleright \). Then \(M'\) walks to the left, finds pebble \(m\) and moves it one square to the right. Finally, \(M'\) walks to the left until it is on \(\triangleleft \), and drops pebbles \(m+1\) to \(k\). The instruction \(\mathsf{left}\) of \(M\) is simulated in a symmetrical way. Note that the initialization and the simulation of each step are deterministic subroutines. Thus, \(\hbox {CT}_k\subseteq \hbox {PT}_k\) and \(\hbox {DCT}_k\subseteq \hbox {DPT}_k\).

We now show that every \(k\)-pebble transducer \(M\) can be simulated by a \(k\)-counting transducer \(M'\). Again, \(M'\) stepwise simulates \(M\). A pebble configuration of \(M\) with pebbles \(1\) to \(\ell \) on the input tape is simulated by the pebble configuration of \(M'\) where pebbles \(1\) to \(\ell \) are on the same squares as those of \(M\), and pebbles \(\ell +1\) to \(k\) are all on the same square as the reading head. The number \(\ell \) is kept in the finite state of \(M'\). Note that \(M'\) already starts in the correct configuration (with \(\ell =0\) in its finite state). The simulation of the instructions \(\mathsf{drop}\) and \(\mathsf{lift}\) is easy: \(\ell :=\ell +1\) and \(\ell :=\ell -1\), respectively, in the finite state. To simulate an instruction \(\mathsf{right}\), \(M'\) first checks that the reading head is not on \(\triangleright \). Then \(M'\) has to move its reading head and all pebbles \(\ell +1\) to \(k\) one square to the right. To do this, \(M'\) repeatedly moves to the right (i.e., executes the instruction \(\mathsf{right}\) with the semantics of the counting transducer) until the reading head and all pebbles \(\ell +1\) to \(k\) are again on the same square. Note that each time \(M'\) moves to the right from \(\triangleright \), the next pebble configuration is realized. For instance, for \(|u|=8\), \(k=4\) and \(\ell =2\), if \(\mathsf{num}(\pi )=7444\) for the current pebble configuration \(\pi \) and the reading head is on square 4, then, after the simulation of \(\mathsf{right}\), \(\mathsf{num}(\pi ')=7455\) for the new pebble configuration \(\pi '\), and the reading head is on square 5; note that \(74555\) is the first number after \(74444\) for which the three least significant digits are equal. The simulation of the instruction \(\mathsf{left}\) is symmetrical. Again, the simulation of each step is a deterministic subroutine, and so \(\hbox {PT}_k\subseteq \hbox {CT}_k\) and \(\hbox {DPT}_k\subseteq \hbox {DCT}_k\). \(\square \)

In the remainder of this section we show that the \(k\)-counting transductions, and hence the \(k\)-pebble transductions, can be characterized as the compositions of a very specific kind of deterministic \(k\)-counting transductions with the \(0\)-counting transductions (i.e., 2gsm’s). Let us now define these specific \(k\)-counting transductions. There is one for each input alphabet \({\varSigma }\), called \(\mathsf{peb}_{k,{\varSigma }}\); it is the mapping \(P_k\) in [20].

For \(u\in {\varSigma }^*\), a string \(\pi \in \{0,\ldots ,|u|+1\}^k\) will be called a k-pebble configuration on \(\triangleleft \,u\,\triangleright \); it is a pebble configuration of a \(k\)-counting transducer with input alphabet \({\varSigma }\). We will need an obvious encoding of the pair \((\triangleleft \,u\,\triangleright ,\pi )\) as a string over the alphabet \(({\varSigma }\cup \{\triangleleft ,\triangleright \})\times \{0,1\}^k\). If \(u=\sigma _1\cdots \sigma _n\) with \(n\ge 0\) and \(\sigma _i\in {\varSigma }\), then

$$\begin{aligned} \mathsf{code}(\triangleleft \,u\,\triangleright ,\pi )=(\triangleleft ,b_0)(\sigma _1,b_1)\cdots (\sigma _n,b_n)(\triangleright ,b_{n+1}) \end{aligned}$$

where \(b_i(m)=1\) if and only if \(\pi (m)=i\), for every \(0\le i\le n+1\) and \(1\le m \le k\).

We define the mapping \(\mathsf{pebb}_{k,{\varSigma }}\) (with two \(\mathsf{b}\)’s!) such that for \(u\in {\varSigma }^*\),

$$\begin{aligned} \mathsf{pebb}_{k,{\varSigma }}(u)=\mathsf{code}(\triangleleft \,u\,\triangleright ,\pi _0)\cdots \mathsf{code}(\triangleleft \,u\,\triangleright ,\pi _s) \end{aligned}$$

where \(s=(|u|+2)^k-1\) and \(\mathsf{num}(\pi _j)=j\) for every \(0\le j\le s\). In other words, \(\mathsf{pebb}_{k,{\varSigma }}(u)\) is the concatenation of all consecutive (encodings of) \(k\)-pebble configurations on \(\triangleleft \,u\,\triangleright \). To define our intended specific \(k\)-counting transductions, we note that the first symbol of \(\mathsf{pebb}_{k,{\varSigma }}(u)\) is \((\triangleleft ,1^k)\) and its last symbol is \((\triangleright ,1^k)\), where \(1^k\) denotes a string of \(k\) \(1\)’s; moreover, these symbols do not occur anywhere else in \(\mathsf{pebb}_{k,{\varSigma }}(u)\).

We now define the mapping \(\mathsf{peb}_{k,{\varSigma }}\) (with one \(\mathsf{b}\)!) such that for \(u\in {\varSigma }^*\),

$$\begin{aligned} \mathsf{pebb}_{k,{\varSigma }}(u)=(\triangleleft ,1^k)\cdot \mathsf{peb}_{k,{\varSigma }}(u)\cdot (\triangleright ,1^k). \end{aligned}$$

Thus, \(\mathsf{peb}_{k,{\varSigma }}(u)\) is the result of removing the first and last symbol from \(\mathsf{pebb}_{k,{\varSigma }}(u)\). In the proof of the next theorem (Theorem 4), a transducer that receives \(\mathsf{peb}_{k,{\varSigma }}(u)\) as input, will view \(\triangleleft \) as \((\triangleleft ,1^k)\) and \(\triangleright \) as \((\triangleright ,1^k)\); in this way, the transducer views the content of its input tape as \(\mathsf{pebb}_{k,{\varSigma }}(u)\).

For \(k\ge 0\), we denote by \(\hbox {PEB}_k\) the class of all mappings \(\mathsf{peb}_{k,{\varSigma }}\), where \({\varSigma }\) is a ranked alphabet.

It is easy to see that \(\mathsf{pebb}_{k,{\varSigma }}\) is in \(\hbox {DCT}_k\): by repeatedly moving right, a deterministic \(k\)-counting transducer \(M\) can consecutively go through the \(k\)-pebble configurations \(\pi _0\) to \(\pi _s\), and for each \(0\le j\le s\) output the string \(\mathsf{code}(\triangleleft \,u\,\triangleright ,\pi _j)\). To be precise, \(M\) has initial state \(q\) and final state \(q'\), and it has the transitions \((q,\sigma ,b)\mapsto (q,\mathsf{right},(\sigma ,b))\) for all \((\sigma ,b)\ne (\triangleright ,1^k)\), plus the transition \((q,\triangleright ,1^k)\mapsto (q',\mathsf{left},(\triangleright ,1^k))\). It should be clear that therefore also \(\mathsf{peb}_{k,{\varSigma }}\) is in \(\hbox {DCT}_k\), just suppressing the first and last symbol of the output of \(M\). Consequently \(\hbox {PEB}_k\subseteq \hbox {DPT}_k\), by Lemma 3.

We now state the characterization of the \(k\)-pebble transductions, of which the proof is intuitively obvious from Lemma 3.

Theorem 4

For every \(k\ge 0\), \(\hbox {PT}_k=\hbox {PEB}_k\circ \hbox {PT}_0\) and \(\hbox {DPT}_k=\hbox {PEB}_k\circ \hbox {DPT}_0\).

Proof

Using Lemma 3, we prove that \(\hbox {CT}_k=\hbox {PEB}_k\circ \hbox {CT}_0\) and \(\hbox {DCT}_k=\hbox {PEB}_k\circ \hbox {DCT}_0\). For a \(k\)-counting transducer \(M=({\varSigma },{\varDelta },Q,q_0,F,\delta )\) we define the associated \(0\)-counting transducer \(M'=({\varSigma }',{\varDelta },Q,q_0,F,\delta ')\) where \({\varSigma }'=({\varSigma }\cup \{\triangleleft ,\triangleright \})\times \{0,1\}^k\) and \(\delta '\) is defined as follows. If \((q,\sigma ,b)\mapsto (q',\varphi ,w)\) is a transition in \(\delta \), then \(\delta '\) contains the transition \((q,(\sigma ,b),\lambda )\mapsto (q',\varphi ,w)\), where \((\triangleleft ,1^k)\) is identified with \(\triangleleft \) and \((\triangleright ,1^k)\) with \(\triangleright \). Note that \(M'\) is deterministic if and only if \(M\) is deterministic. It should be clear that \(\mathsf{peb}_{k,{\varSigma }}\circ \tau _{M'}=\tau _M\). Indeed, if \(M\) moves right from \(\triangleright \), then \(M'\) moves right from some \((\triangleright ,b)\) that is not identified with \(\triangleright \), and so \(M'\) moves from the last symbol of \(\mathsf{code}(\triangleleft \,u\,\triangleright ,\pi _j)\), where \(u\) is the input string and \(\pi _j\) is the current pebble configuration of \(M\), to the first symbol of \(\mathsf{code}(\triangleleft \,u\,\triangleright ,\pi _{j+1})\). And similarly when \(M\) moves left from \(\triangleleft \). As long as \(M\) does not move right from \(\triangleright \) or move left from \(\triangleleft \), \(M'\) stays on the substring \(\mathsf{code}(\triangleleft \,u\,\triangleright ,\pi _j)\) of \(\mathsf{pebb}_{k,{\varSigma }}(u)=\triangleleft \,\mathsf{peb}_{k,{\varSigma }}(u)\,\triangleright \), simulating \(M\).

This shows that \(\hbox {CT}_k\subseteq \hbox {PEB}_k\circ \hbox {CT}_0\) and \(\hbox {DCT}_k\subseteq \hbox {PEB}_k\circ \hbox {DCT}_0\). The reverse inclusions hold because, obviously, every \(0\)-counting transducer with input alphabet \(({\varSigma }\cup \{\triangleleft ,\triangleright \})\times \{0,1\}^k\) is the associated transducer of a \(k\)-counting transducer with input alphabet \({\varSigma }\). \(\square \)

The constructions involved in this theorem, for the case that the output alphabet is empty, are used in [20] to reduce the descriptional complexity of two-way \(k\)-pebble automata to that of two-way (\(0\)-pebble) automata: if nondeterministic two-way automata can be simulated by deterministic two-way automata with a polynomial number of states (which is not known, cf. [29]), then the same is true for \(k\)-pebble automata. We will use Theorem 4 in the following sections in a similar way, to transfer results for 2gsm’s to \(k\)-pebble transducers.

4 Uniformizers

In this section we use Theorem 4 to prove our first main result: that every partial function in \(\hbox {PT}_k\) is in \(\hbox {DPT}_k\). In fact, we will prove the stronger result that every transduction in \(\hbox {PT}_k\) has a uniformizer in \(\hbox {DPT}_k\). A uniformizer of a binary relation \(R\) is a binary relation \(R'\) such that \(R'\subseteq R\) and \(\mathsf{dom}(R')=\mathsf{dom}(R)\), see, e.g., [1, 8]. Note that the only uniformizer of a partial function \(f\) is \(f\) itself. We first prove the result for \(k=0\), i.e., for 2gsm’s. A proof was already sketched in the proof of Theorem 4.9 of [9]. Here we give a proof using the results of [12].

Proposition 5

Every transduction in \(\hbox {PT}_0\) has a uniformizer in \(\hbox {DPT}_0\).

Proof

A writing 0-pebble transducer is a \(0\)-pebble transducer that, in addition, can write on its input tape. For this purpose, it has an additional “work alphabet” \({\varOmega }\) that contains the input alphabet and the endmarkers. Its transitions are of the form \((q,\sigma ,b)\mapsto (q',\sigma ',\varphi ,w)\) with \(\sigma ,\sigma '\in {\varOmega }\), meaning that \(\sigma \) is overwritten by \(\sigma '\) in the current square. A Hennie machine is a writing \(0\)-pebble transducer \(M\) for which there is a number \(k\in {\mathbb N}\) such that for each \((u,v)\in \tau _M\) there is a k-visiting computation of \(M\) on input \(u\) with output \(v\), which means that each square of the input tape is visited at most \(k\) times. For more details see Section 7 of [12]. The Hennie machine was introduced as an accepting device in [23], where it was shown that, due to the \(k\)-visiting restriction, it accepts regular languages only. It was shown in [12] that the Hennie machine computes the MSO definable string transductions, i.e., the string transductions that are definable in monadic second-order logic.

It is easy to see that for every \(0\)-pebble transducer \(M\) there is a Hennie machine \(M'\) such that \(\tau _{M'}\) is a uniformizer of \(\tau _M\). In fact, if \((u,v)\in \tau _M\) then \(M\) has a computation on input \(u\) (with some output \(v'\)) that never enters the same state twice at the same square (because if, during some computation, \(M\) enters state \(q\) at square \(j\) on time \(t_1\) and on time \(t_2> t_1\), then the subcomputation between \(t_1\) and \(t_2\) can be skipped). Such a computation is \(k\)-visiting, where \(k\) is the number of states of \(M\). A Hennie machine \(M'\) can easily simulate the \(k\)-visiting computations of \(M\) using the work alphabet \(({\varSigma }\cup \{\triangleleft ,\triangleright \})\times \{0,1,\ldots ,k\}\) (where \({\varSigma }\) is the input alphabet) and counting the visits to each square in the symbol at that square. To be precise, each transition \((q,\sigma ,b)\mapsto (q',\varphi ,w)\) of \(M\) is replaced by all transitions \((q,(\sigma ,i),b)\mapsto (q',(\sigma ,i+1),\varphi ,w)\) of \(M'\) with \(0\le i < k\), where we identify \((\sigma ,0)\) with \(\sigma \).

By Theorem 25 of [12], every transduction computed by a Hennie machine is a nondeterministic MSO definable string transduction (defined in Section 6.1 of [12]). By the proof of Theorem 21 of [12], for every nondeterministic MSO definable string transduction \(\tau '=\tau _{M'}\) there is a deterministic MSO definable string transduction \(\tau ''\) (defined in Section 4 of [12]) that is a uniformizer of \(\tau '\) and hence a uniformizer of \(\tau _M\). By Theorem 13 of [12], \(\tau ''\) can be computed by a deterministic \(0\)-pebble transducer \(M''\), and so \(\tau _{M''}=\tau ''\) is a uniformizer of \(\tau _M\). \(\square \)

We now prove our first main result.

Theorem 6

For every \(k\ge 0\), every transduction in \(\hbox {PT}_k\) has a uniformizer in \(\hbox {DPT}_k\).

Proof

By Theorem 4 every transduction in \(\hbox {PT}_k\) is of the form \(\mathsf{peb}_{{\varSigma },k}\circ \tau \) with \(\tau \in \hbox {PT}_0\). By Proposition 5, \(\tau \) has a uniformizer \(\tau '\in \hbox {DPT}_0\). This clearly implies that \(\mathsf{peb}_{{\varSigma },k}\circ \tau '\) is a uniformizer of \(\mathsf{peb}_{{\varSigma },k}\circ \tau \), and \(\mathsf{peb}_{{\varSigma },k}\circ \tau '\) is in \(\hbox {DPT}_k\) by Theorem 4. \(\square \)

Corollary 7

For every \(k\ge 0\), if \(\tau \in \hbox {PT}_k\) is a partial function, then \(\tau \in \hbox {DPT}_k\).

5 Composition

In this section we prove that the composition of the transductions of two deterministic pebble transducers with \(k\) and \(m\) pebbles respectively, can be computed by a deterministic pebble transducer with \((k+1)(m+1)-1=km+k+m\) pebbles. For \(k=m=0\), i.e., for deterministic 2gsm’s, this was proved in [6] (see also Theorems 8.10 and 7.14 of [7]).

Proposition 8

\(\hbox {DPT}_0\circ \hbox {DPT}_0\subseteq \hbox {DPT}_0\).

Let \(\hbox {PEBB}_k\) denote the class of all mappings \(\mathsf{pebb}_{k,{\varSigma }}\), where \({\varSigma }\) is a ranked alphabet. It should be clear that \(\hbox {PEBB}_k\subseteq \hbox {PEB}_k\circ \hbox {DPT}_0\) and \(\hbox {PEB}_k\subseteq \hbox {PEBB}_k\circ \hbox {DPT}_0\) (where the \(0\)-pebble transducer adds or removes the first and last symbol, respectively). This, together with Proposition 8 and Theorem 4, gives the following corollary.

Corollary 9

For every \(k\ge 0\), \(\hbox {DPT}_k=\hbox {PEBB}_k\circ \hbox {DPT}_0\).

From Proposition 8 and Corollary 9 (or Theorem 4) we immediately obtain the inclusion \(\hbox {DPT}_k\circ \hbox {DPT}_0\subseteq \hbox {DPT}_k\). In the next lemma we prove a special case of the symmetric inclusion \(\hbox {DPT}_0\circ \hbox {DPT}_k\subseteq \hbox {DPT}_k\).

Lemma 10

For every \(k\ge 0\), \(\hbox {DPT}_0\circ \hbox {PEBB}_k\subseteq \hbox {DPT}_k\).

Proof

Let \(\tau \in \hbox {DPT}_0\) where \(\tau \) is a partial function from \({\varSigma }^*\) to \({\varDelta }^*\). We will construct a deterministic \(k\)-pebble transducer \(N\) such that \(\tau _N=\tau \circ \mathsf{pebb}_{{\varDelta },k}\).

Let \(M=({\varSigma },{\varDelta }\cup \{\triangleleft ,\triangleright \},Q,q_0,F,\delta )\) be a deterministic \(0\)-pebble transducer such that \(\tau _M(u)=\triangleleft \,\tau (u)\,\triangleright \) for every \(u\in {\varSigma }^*\). A configuration \((q,i,\lambda )\) of \(M\) (where \(\lambda \) is the empty pebble configuration) will be denoted by \((q,i)\). Without loss of generality, we assume that at each computation step \(M\) outputs at most one symbol.

Consider an input string \(u\in \mathsf{dom}(\tau _M)\). Each occurrence of an output symbol in \(\tau _M(u)\) is produced by \(M\) in a certain configuration \((q,i)\) during the next computation step, where \(q\) is a state and \(i\) is a square of the input tape \(\triangleleft \,u\,\triangleright \). By the above assumption, this configuration is unique, because if two such occurrences would be produced by \(M\) in the same configuration, then the computation of \(M\) on input \(u\) would loop, contradicting the fact that \(u\in \mathsf{dom}(\tau _M)\). We may assume that \(\triangleleft \) is produced in configuration \((q_\triangleleft ,0)\) and \(\triangleright \) in configuration \((q_\triangleright ,0)\) for certain states \(q_\triangleleft \) and \(q_\triangleright \) (probably the initial state and a final state of \(M\)); thus, \(M\) produces output \(\triangleleft \) and \(\triangleright \) when it reads \(\triangleleft \).

In the computations of \(N\), a \(k\)-pebble configuration \(\pi \in \{0,1,\ldots ,|v|,|v|+1\}^k\) on the output string \(\tau _M(u)=\triangleleft \,v\,\triangleright \), where \(v=\tau (u)\), is uniquely represented by a pair \((\alpha ,\widetilde{\pi })\) where \(\alpha \in Q^k\) associates a state with each pebble and \(\widetilde{\pi }\in \{0,1,\ldots ,|u|,|u|+1\}^k\) is a pebble configuration of \(N\) on \(\triangleleft \,u\,\triangleright \), such that, for every \(1\le m\le k\), the pair \((\alpha (m),\widetilde{\pi }(m))\) is the configuration in which \(M\) produces (the symbol in) square \(\pi (m)\) of the output tape. The association \(\alpha \) is kept in the finite state of \(N\).

For fixed \((\alpha ,\widetilde{\pi })\), the string \(\mathsf{code}(\triangleleft \,v\,\triangleright ,\pi )\) can be produced by \(N\) as output, by simulating the computation of \(M\) on input \(u\). When \(M\), in configuration \((q,i)\), outputs a symbol \(a\in {\varDelta }\cup \{\triangleleft ,\triangleright \}\) during the next computation step, \(N\) instead outputs the symbol \((a,b)\) with \(b\in \{0,1\}^k\) such that, for every \(1\le m\le k\), \(b(m)=1\) if and only if \((\alpha (m),\widetilde{\pi }(m))=(q,i)\), i.e., pebble \(m\) is in the current square and is associated with the current state of \(M\).

Next we explain how \(N\) can realize the representation of the next \(k\)-pebble configuration of \(\pi \), for given \((\alpha ,\widetilde{\pi })\). First \(N\) walks to \(\triangleleft \) and determines the largest number \(m\), \(1\le m\le k\), such that \((\alpha (m),\widetilde{\pi }(m))\ne (q_\triangleright ,0)\) (which means that pebble \(m\) is not on the last symbol of \(\triangleleft \,v\,\triangleright \)). If there is no such \(m\), then \(N\) halts in a final state. If \(m\) exists, then \(N\) lifts the pebbles \(m+1\) to \(k\). After that, \(N\) must move pebble \(m\) one square to the right on \(\triangleleft \,v\,\triangleright \). To do that, it again simulates the computation of \(M\) on input \(u\). On the moment that \(M\) is in configuration \((\alpha (m),\widetilde{\pi }(m))\), \(N\) lifts pebble \(m\) and continues the simulation of \(M\) until the next output symbol is produced. Then \(N\) drops pebble \(m\) on the current square, associates it with the current state of \(M\), and stops the simulation. Finally, \(N\) walks to \(\triangleleft \), drops the pebbles \(m+1\) to \(k\), and associates them with \(q_\triangleleft \).

Initially, \(N\) checks that the input string \(u\) is in the domain of \(\tau _M\). Since the domain of \(\tau _M\) is regular (see, e.g., [31]), \(N\) can simulate a finite automaton recognizing it. If \(u\in \mathsf{dom}(\tau _M)\), then \(N\) drops all its pebbles on \(\triangleleft \) and associates them with \(q_\triangleleft \). \(\square \)

We now prove our second main result.

Theorem 11

For every \(k,m\in {\mathbb N}\), \(\hbox {DPT}_k\circ \hbox {DPT}_m\subseteq \hbox {DPT}_{km+k+m}\).

Proof

We first observe that it suffices to show that

$$\begin{aligned} \hbox {PEB}_k\circ \hbox {PEBB}_m\subseteq \hbox {PEBB}_{km+k+m}\circ \hbox {DPT}_0. \end{aligned}$$

Indeed, \(\hbox {DPT}_k\circ \hbox {DPT}_m = \hbox {PEB}_k\circ \hbox {DPT}_0\circ \hbox {DPT}_m = \hbox {PEB}_k\circ \hbox {DPT}_0\circ \hbox {PEBB}_m\circ \hbox {DPT}_0 \subseteq \hbox {PEB}_k\circ \hbox {DPT}_m\circ \hbox {DPT}_0 = \hbox {PEB}_k\circ \hbox {PEBB}_m\circ \hbox {DPT}_0\circ \hbox {DPT}_0 \subseteq \hbox {PEB}_k\circ \hbox {PEBB}_m\circ \hbox {DPT}_0\) by Theorem 4, Corollary 9, Lemma 10, Corollary 9, and Proposition 8, respectively. If the above inclusion holds, then this is included in \(\hbox {PEBB}_{km+k+m}\circ \hbox {DPT}_0\circ \hbox {DPT}_0\subseteq \hbox {PEBB}_{km+k+m}\circ \hbox {DPT}_0= \hbox {DPT}_{km+k+m}\) by Proposition 8 and Corollary 9.

Let \(r=km+k+m\). Let \({\varSigma }\) be an alphabet, let \({\varDelta }=({\varSigma }\cup \{\triangleleft ,\triangleright \})\times \{0,1\}^k\), let \({\varGamma }=({\varSigma }\cup \{\triangleleft ,\triangleright \})\times \{0,1\}^r\), and let \({\varOmega }=({\varDelta }\cup \{\triangleleft ,\triangleright \})\times \{0,1\}^m\). We will define a deterministic \(0\)-pebble transducer \(M\) with input alphabet \({\varGamma }\) and output alphabet \({\varOmega }\), such that

$$\begin{aligned} \tau _M(\mathsf{pebb}_{r,{\varSigma }}(u))=\mathsf{pebb}_{m,{\varDelta }}(\mathsf{peb}_{k,{\varSigma }}(u)) \end{aligned}$$

for every \(u\in {\varSigma }^*\). In what follows we identify \((\triangleleft ,1^k)\) with \(\triangleleft \) and \((\triangleright ,1^k)\) with \(\triangleright \), in the alphabet \({\varDelta }\). Thus \({\varDelta }\cup \{\triangleleft ,\triangleright \}={\varDelta }\), and so the symbols in \({\varOmega }\) are of the form \(((\sigma ,b_1),b_2)\) with \(\sigma \in {\varSigma }\cup \{\triangleleft ,\triangleright \}\), \(b_1\in \{0,1\}^k\) and \(b_2\in \{0,1\}^m\).

For \(u\in {\varSigma }^*\), we recall that \(\mathsf{pebb}_{k,{\varSigma }}(u)=\mathsf{code}(\triangleleft \,u\,\triangleright ,\pi _0)\cdots \mathsf{code}(\triangleleft \,u\,\triangleright ,\pi _s)\) where \(\pi _0,\ldots ,\pi _s\) is the sequence of consecutive \(k\)-pebble configurations on \(\triangleleft \,u\,\triangleright \). Due to the above identification,

$$\begin{aligned} \mathsf{pebb}_{m,{\varDelta }}(\mathsf{peb}_{k,{\varSigma }}(u))= \mathsf{code}(\mathsf{pebb}_{k,{\varSigma }}(u),\rho _0)\cdots \mathsf{code}(\mathsf{pebb}_{k,{\varSigma }}(u),\rho _t) \end{aligned}$$

where \(\rho _0,\ldots ,\rho _t\) is the sequence of consecutive \(m\)-pebble configurations on \(\mathsf{pebb}_{k,{\varSigma }}(u)\). We also have that \(\mathsf{pebb}_{r,{\varSigma }}(u)=\mathsf{code}(\triangleleft \,u\,\triangleright ,\eta _0)\cdots \mathsf{code}(\triangleleft \,u\,\triangleright ,\eta _z)\) where \(\eta _0,\dots ,\eta _z\) is the sequence of consecutive \(r\)-pebble configurations on \(\triangleleft \,u\,\triangleright \). Note that for \(n=|\triangleleft \,u\,\triangleright |\), we have \(|\mathsf{pebb}_{k,{\varSigma }}(u)|=n^{k+1}\), and hence \(|\mathsf{pebb}_{m,{\varDelta }}(\mathsf{peb}_{k,{\varSigma }}(u))|=|\mathsf{pebb}_{r,{\varSigma }}(u)|=n^{(k+1)(m+1)}\).

We now give meaningful names to the \(r=km+k+m=m(k+1)+k\) pebbles involved in \(\mathsf{pebb}_{r,{\varSigma }}\). From \(1\) to \(r\), they receive the names

$$\begin{aligned}&\langle 1,1 \rangle ,\ldots ,\langle 1,k \rangle ,\langle 1,k+1 \rangle , \\&\langle 2,1 \rangle ,\ldots ,\langle 2,k \rangle ,\langle 2,k+1 \rangle , \\&\dots \\&\langle m,1 \rangle ,\ldots ,\langle m,k \rangle ,\langle m,k+1 \rangle ,\\&\langle m+1,1 \rangle ,\ldots ,\langle m+1,k \rangle . \end{aligned}$$

The pebbles in the last row, \(\langle m+1,1 \rangle ,\ldots ,\langle m+1,k \rangle \), correspond to the pebbles \(1,\ldots ,k\) that determine the \(k\)-pebble configurations \(\pi _0,\ldots ,\pi _s\) of \(\mathsf{pebb}_{k,{\varSigma }}\) on \(\triangleleft \,u\,\triangleright \). The pebbles in the first \(m\) rows determine the \(m\)-pebble configurations \(\rho _0,\ldots ,\rho _t\) of \(\mathsf{pebb}_{m,{\varDelta }}\) on \(\mathsf{pebb}_{k,{\varSigma }}(u)\). The pebbles in the \(j\)th row, \(1\le j\le m\), determine the position of pebble \(j\) on \(\mathsf{pebb}_{k,{\varSigma }}(u)\). To be precise, the pebbles \(\langle j,1 \rangle ,\ldots ,\langle j,k \rangle \) determine the \(k\)-pebble configuration \(\pi _\ell \) such that pebble \(j\) occurs in the substring \(\mathsf{code}(\triangleleft \,u\,\triangleright ,\pi _\ell )\) of \(\mathsf{pebb}_{k,{\varSigma }}(u)\), and the pebble \(\langle j,k+1 \rangle \) determines the position of pebble \(j\) in that substring.

The transducer \(M\) is very simple: it computes a symbol-to-symbol string homomorphism from \({\varGamma }\) to \({\varOmega }\). Walking from left to right through the input tape containing \(\mathsf{pebb}_{r,{\varSigma }}(u)\), it changes each symbol \((\sigma ,b)\), with \({\varSigma }\cup \{\triangleleft ,\triangleright \}\) and \(b\in \{0,1\}^r\), into the symbol \(((\sigma ,b_1),b_2)\) such that

  • \(b_1(i)=b(\langle m+1,i \rangle )\) for every \(1\le i\le k\), and

  • for every \(1\le j\le m\), \(b_2(j)=1\) if and only if

    • \(b(\langle j,i \rangle )=b(\langle m+1,i \rangle )\) for every \(1\le i\le k\), and

    • \(b(\langle j,k+1 \rangle )=1\).

It should be clear, after some thinking, that \(M\) indeed translates each input string \(\mathsf{pebb}_{r,{\varSigma }}(u)\) into \(\mathsf{pebb}_{m,{\varDelta }}(\mathsf{peb}_{k,{\varSigma }}(u))\). \(\square \)

It is well known (and easy to see) that for every transduction \(\tau \in \hbox {DPT}_k\) and every string \(u\) in its domain, \(|\tau (u)|=O(|u|^{k+1})\). In fact, if \(M\) is a deterministic \(k\)-pebble transducer computing \(\tau \), then the number of configurations of \(M\) on \(\triangleleft \,u\,\triangleright \) is \(O(|u|^{k+1})\) and each configuration occurs at most once in the computation of \(M\) on input \(u\). As observed in the proof of Theorem 11, \(|\mathsf{pebb}_{m,{\varDelta }}(\mathsf{peb}_{k,{\varSigma }}(u))|=(|u|+2)^{(k+1)(m+1)}\). Hence \(\mathsf{peb}_{k,{\varSigma }}\circ \mathsf{pebb}_{m,{\varDelta }}\) cannot be computed by a deterministic pebble transducer with less than \((k+1)(m+1)-1\) pebbles. Since \(\mathsf{peb}_{k,{\varSigma }}\in \hbox {DPT}_k\) and \(\mathsf{pebb}_{m,{\varDelta }}\in \hbox {DPT}_m\), this shows that Theorem 11 is optimal.

In the same way as Proposition 8 it can be shown that \(\hbox {DPT}_0\circ \hbox {PT}_0\subseteq \hbox {PT}_0\). From this it follows in the same way as above that \(\hbox {DPT}_k\circ \hbox {PT}_m\subseteq \hbox {PT}_{km+k+m}\) for every \(k,m\in {\mathbb N}\).

By Theorem 11, \(\hbox {DPT}=\bigcup _{k\in {\mathbb N}}\hbox {DPT}_k\) is closed under composition (as already proved in [15]). This is not true for \(\hbox {PT}=\bigcup _{k\in {\mathbb N}}\hbox {PT}_k\).

Proposition 12

\(\hbox {PT}\) is not closed under composition.

Proof

The proof is entirely similar to the proof of Lemma 15 of [12], as follows. Let \(\tau \) be the transduction \(\{(a^n,w\#w\mid n\ge 0,\,w\in \{a,b\}^*,\,|w|=n\}\). Obviously, \(\tau \in \hbox {PT}_0\circ \hbox {DPT}_0\) (first translate \(a^n\) into all strings \(w\in \{a,b\}^*\) of length \(n\), then translate \(w\) into \(w\#w\)).

Assume that \(\tau \) is computed by a \(k\)-pebble transducer \(M\) with \(m\) states, that produces at most one output symbol at each computation step. The number of configurations of \(M\) on \(\triangleleft \,a^n\,\triangleright \) is \(m\cdot (n+2)^{k+1}\). Choose \(n\) such that \(2^n>m\cdot (n+2)^{k+1}\). Consider the behavior of \(M\) on input \(a^n\), and consider in particular the configuration of \(M\) when it has just produced the symbol \(\#\) of the output string \(w\#w\). Since there are \(2^n\) output strings \(w\#w\) for \(a^n\), there exist two strings \(w_1\) and \(w_2\) for which this configuration is the same. Then the computation of output \(w_1\#w_1\) can be switched halfway to the computation of \(w_2\#w_2\), resulting in a computation of output \(w_1\#w_2\) with \(w_1\ne w_2\). \(\square \)

We finally show that the composition closure \(\hbox {PT}^*\) of \(\hbox {PT}\) does not contain more partial functions than \(\hbox {PT}\): all partial functions in \(\hbox {PT}^*\) are already in \(\hbox {DPT}\). We define \(\hbox {PT}^1=\hbox {PT}\), \(\hbox {PT}^{n+1}=\hbox {PT}^n\circ \hbox {PT}\), and \(\hbox {PT}^*=\bigcup _{n\ge 1}\hbox {PT}^n\).

Theorem 13

\(\hbox {PT}^*\) has uniformizers in \(\hbox {DPT}\).

Proof

Consider a transduction \(\tau _1\circ \cdots \circ \tau _n\) with \(\tau _i\in \hbox {PT}\) for \(1\le i\le n\). Since \(\mathsf{dom}(\tau _i)\) is regular (see, for instance, [15]), we may assume that the range of \(\tau _{i-1}\) is contained in the domain of \(\tau _i\) for \(2\le i\le n\) (when computing \(\tau _{i-1}\), simulate a finite automaton for \(\mathsf{dom}(\tau _i)\) on the output). By Theorem 6, \(\tau _i\) has a uniformizer \(\tau _i'\) in \(\hbox {DPT}\). By the above assumption, \(\tau _1'\circ \cdots \circ \tau _n'\) is a uniformizer of \(\tau _1\circ \cdots \circ \tau _n\), and \(\tau _1'\circ \cdots \circ \tau _n'\) is in \(\hbox {DPT}\) by Theorem 11. \(\square \)

6 Conclusion

By Proposition 12, \(\hbox {PT}\subsetneq \hbox {PT}^2\). It is open whether \(\hbox {PT}^n\subsetneq \hbox {PT}^{n+1}\) for every \(n\).

A variant of pebble handling is to allow a pebble to be lifted also when the reading head is not at the square where the pebble was dropped. In the literature these are called “strong” pebbles, as opposed to the “weak” pebbles in this paper. It is shown in [2] that strong \(k\)-pebble tree automata have the same expressive power as weak ones. It is not difficult to show that deterministic strong \(1\)-pebble transducers have the same power as weak ones, but apart from that it is open whether or not strong \(k\)-pebble transducers have more power than weak ones. It is also open whether the results of this paper are also valid for strong pebble transducers.

We finally mention that it is open whether the equivalence problem for deterministic \(k\)-pebble transducers is decidable. By an argument similar to the one in the proof of Theorem 4 of [15], it can be shown that every deterministic \(k\)-pebble transduction is a composition of \(k\) deterministic macro tree transductions. For an overview on the equivalence problem for deterministic macro tree transducers see [24].