• No results found

Description of the subroutine Reach

3.3 The subroutine Reach

3.3.1 Description of the subroutine Reach

We are now ready to design a subroutine Reach(qS, qT) that receives two states qS, qT

of A as parameters and, by examining the string w on the input tape, decides whether A has a computational segment from qS to qT on w. Depending on the outcome, the

procedure returns the corresponding Boolean value true or false. We will show that this subroutine can be implemented by the use of a 2dfa with O(n) internal states and with a read-only access to qS and qT.

A rst idea would be to try to compute Reach(qS, qT) by initializing the automaton A

in the state qS with the input head at the left endmarker and by stopping its computation

as soon as it reaches the left endmarker again, then testing whether the state so reached is qT. However, this approach runs into two problems: rst, the original automaton A

could get into an innite loop, never coming back to the left endmarker; second, the rst move from the state qS on the left endmarker could be nondeterministic.

To solve these problems, we adapt the construction given in [33] (where it was used for dierent purposes, to make a 2dfa halting, with 4n states) which, in turn, was a renement of the corresponding Sipser's construction [73] for space bounded Turing ma- chines. Here we give a brief outline of this construction. For each w∈ Σ∗, a deterministic

machine accepts w if and only if there is a backward path, tracing back the history of the computation, from the unique accepting conguration c+ to the unique initial

conguration c−.

Consider the graph in which nodes represent congurations and edges single com- putation steps. If the machine under consideration is deterministic, the component of the graph containing the accepting conguration c+ is a tree rooted at this congura-

tion, with backward paths branching to all possible predecessors of c+. In addition, since

the accepting conguration is also halting, no backward path starting from c+ can cycle

(hence, it is of nite length). Thus, it is sucient to perform a depth-rst search of this tree in order to detect whether the initial conguration c− belongs to the predecessors

of c+. If this is the case, the simulator accepts. On the other hand, if the entire tree

is examined without reaching c−, there is no path from c− to c+ and so w is not in the

language. Hence, the simulator rejects.

We adapt this procedure by choosing c− = (qS, 0) and c+ = (qT, 0), where qS and qT

are the two parameters, since we are interested in detecting the existence of just one computational segment, from qSto qT. This is possible, because our machineA is in normal

form given by Lemma 3, and hence it does not make nondeterministic decisions when the input head is not scanning the left endmarker, i.e., ∣δ ∩ ({q} × {a} × {−1,+1} × Q)∣ ≤ 1 for each q∈ Q and a ≠ ▷.

The only problem is that both qS and qTare located at the left endmarker, where non-

deterministic branching is allowed. This is resolved as follows. For the purposes of walking along the tree of the backward depth-rst search, we ignore the transitions on the left endmarker, as if such transitions did not exist, i.e., as if δ∩ (Q × {▷} × {−1,+1} × Q) = ∅. Hence, the backward search starts from c+= (qT, 0), which now behaves as a root of a tree

with backward paths leaving the left endmarker and branching to possible predecessors of qT. However, the transitions at the left endmarker are missing. Therefore, a backward

path can never reach the left endmarker again. Instead, such path ends up one backward step earlier, in a conguration c= (q,1), with the input head placed one position to the right of the left endmarker, even though, in reality, using a transition (p, ▷,+1, q) ∈ δ, the original machine could get to c from a conguration c′ = (p, 0). Hence, there exists

a computational segment connecting c−= (qS, 0) with c+= (qT, 0) if and only if, for some

conguration c= (q,1) placed one position to the right of the left endmarker, there ex- ists a backward path from c+ to c visiting the left endmarker only in c+ and, moreover,

(qS,▷, +1,q) ∈ δ.

Thus, we stop the depth-rst search and return true at the moment when we reach a conguration c with the above properties. If the entire tree has been visited without reaching any such c, we stop and return false.

head of the original 2onfa A is placed exactly one position to the right of the left endmarker. By a closer look to the simulation in [33], one can observe that, for each conguration c= (q, i), all the left predecessors c′= (p,i−1) are examined in q, a copy

of the state q, with the input head shifted one position to the left of the actual input head position, i.e., in the position i−1, while the right predecessors c′= (p, i+1) are examined

in q↗, another copy of q, with the input head shifted one position to the right.1 (For

completeness, the simulation uses two more copies for each state q, namely, q↓1 and q↓2,

with the input head placed exactly at the actual input head position i, at the moment when, respectively, all the left, or both all the left and all the right predecessors have already been visited.) Hence, when the procedure reaches a state q↖with the input head

scanning the left endmarker and, moreover,(qS,▷, +1, q) ∈ δ, we can stop the computation

and return true.

There are only three points which depend on the states qS and qT: the choice of the

root for the depth-rst search, i.e., of the conguration c+= (qT, 0), the detection of exit

nodes in this tree, depending on transitions in δ∩ ({qS} × {▷} × {+1} × Q), and nally

handling some trivial cases, namely, if qS= qT or if qT= q+.

More details are presented in Section 3.3.2. Hence, with this strategy, we obtain the following result, required later:

Lemma 5. Let A be a 2onfa with a state set Q, in the form of Lemma 3, and let Reach(qS, qT) be a procedure returning true or false depending on whether A has a

computational segment connecting two states qS, qT on a given input w. Then the truth of

Reach(qS, qT) can be computed by a 2dfa A′′ using two read-only variables containing

qS, qT∈ Q and one working variable to store one of O(∣Q∣) internal states.

More precisely, there exists a 2dfa A′′ such that, starting at the left endmarker of

the input w in a state [qSTART, qS, qT], A′′ will stop in [qTRUE, qS, qT] or [qFALSE, qS, qT],

depending on the truth of the statement Reach(qS, qT). This holds for each qS, qT ∈ Q

and each input w. The state set ofA′′ is Q′′= Q×Q×Q, with ∣Q∣ ≤ 4⋅∣Q∣−1. Thus, A′′uses

4⋅∣Q∣−1 internal states; the second and third components in Q′′, containing qS, qT∈ Q, are

never modied and hence used in a read-only way.