Two-way transducers
A deterministic two-way transducer consists of:
• an input alphabet ;
• an output alphabet ;
• a set of states with a distinguished initial state and final state;
• a transition function
The semantics of the transducer are defined similarly to Turing machines, as follows. (Actually, the model is equivalent to a Turing machine where there is one read-only input tape and one write-once output tape.) If the input word is , the we embellish it with start and end markers as follows:
The head of the automaton is then placed over the start marker with the initial state. (For two-way automata, the head is over a letter, as opposed to one-way automata, where the head is between letters.) At any given moment, the automaton applies its transition function to its current state and the symbol under the head, yielding a new state, a direction to move the head, and some output letters that to be appended to the output. The output letters are used in chronological order, i.e. those which are output at the beginning of the run are at the beginning of the output, regardless of the position of the head when executing the transition. The run of the automaton might fail, either by moving out of the word (i.e. doing a move on the start marker , or doing a move on the end marker ), or by entering an infinite loop; such failing runs do not produce any output, and therefore the semantics of the automaton is a partial function from to .
The run of the automaton ends when the final state is reached. If the final state is never reached, or if the automaton moves out of the input tape (by crossing a marker or in the wrong direction), then the automaton produces no input, i.e. its value is undefined. Therefore, the semantics of the machine is a partial function.
Typical things that can be done using a two-way transducer are duplication or reversing the input.
Past oracle
A two-way automaton with a past oracle is defined the same way as above, with the following difference. There is an additional DFA, which is called the past oracle. If the states of the past oracle are , then the transition function of the two-way automaton which uses this past oracle is of the form
The following theorem shows that past oracles can be eliminated. Other features that can also be eliminated are nondeterminism and future oracles.
Theorem. For every two-way automaton with a past oracle, there is a two-way automaton (without any oracle), which defines the same partial function from words to words.
Proof. The idea for this proof comes from Hopcroft and Ullman. Suppose that we have a two-way automaton with a past oracle, such that the states of the two-way automaton are and the states of the past oracle are . The general idea for the simulation is straightforward: the simulating automaton knows both the state of the two-way automaton and the state of the oracle. The question is how to maintain this information.
The key insight is to consider the graph which describes the states of the past oracle and how they are updated by the transition function of the past oracle. This graph looks likes this:
The vertices of the graph are configurations of the past oracle, i.e. pairs (state of the past oracle, column between positions in the word), and the edges correspond to transitions of the automaton. We number the columns beginning with 1. Because the past oracle is a deterministic automaton, the graph is a forest.
Let us define to be the state of the past oracle when in the -th column, i.e. after reading the first letters of the input word. The two-way automaton which uses the past oracle uses the state to make its decision when its head is over the -the position. Suppose that the head of the two-way automaton is over some position in the input word, and the state of the oracle is known, as indicated by a red circle in the following picture:
We want to show that the state of the oracle can be maintained when doing one transition of the two-way automaton. If the transition of the two-way automaton does not move the head, there is no problem. If the transition of the two-way automaton moves the head to the right, there is also no problem, since the transition function of the past oracle can be simply applied.
The issue is when the two-way automaton wants to move the head to the left, and we need to compute the state . Here is the solution. In terms of the forest in the pictures above, the state corresponds to the configuration in the forest. We are going to inspect the subtree of this configuration, which contains the initial configuration , and therefore goes all the way to the left side of the input.
We start by moving the head one step to the left, which identifies all possible candidates for the predecessor configurations. Here is the picture, with the candidates being coloured yellow:
If there is only one yellow configuration, i.e. only one candidate for the predecessor, then we are done. The more interesting case is when there is more than one yellow configuration. In this case, we keep moving to the left, and colour all descendants of the yellow configuration (and therefore of the red configuration as well) using a green colour.
Two things may happen. In one case, we might reach a moment when all green configurations are descendants of a unique yellow configuration, as in this picture:
In this case, the unique yellow configuration is the one that we want to compute. The question is how to return to this unique configuration? The solution is this: since we have stopped in the first column when the yellow configuration was uniquely identified, in the previous column there were at least two candidates for the yellow configurations. Therefore, if we remember the previous column, we can start moving to the right until the first time that the whole subtree reaches a single node, this way we will reach the red configuration again. But in our state we can keep the yellow configuration that was the actual predecessor.
The remaining case is when we reach the first column at the beginning of the input. Here we do the same trick to return to the red configuration, and we can keep in our state which branch of the subtree corresponds to the computation of the past oracle.
Leave a Reply