• Nenhum resultado encontrado

4 Two-Way Alternating Automata, Complemented

Complement for Two-Way Alternating Automata 139 A starts in the state PINI = +1q0,0 with the head at the leftmost cell, labeled by q0a0 = q0 and containing the read-write symbol C = αq0, = unknown. This starts the evaluation of the computation tree of A, rooted in q0,0 . When this evaluation is over, the outcome is written as the final value C ∈ {accept,reject} in the leftmost cell. Next, A switches to the respective state PACC = res accept, μ1,q0,q0 = res accept,2q0 or PREJ = res reject, μ1,q0,q0 = res reject,2q0 , trying to back up with the result to a nonexistent parent q0,01 to the left of the leftmost cell. At this moment, the computation is halted.

As the finishing touch, we can eliminate transitions in whichAdoes not move its head (see, e.g., [10, p. 319]). The idea is quite simple: each chain of transitions P1, L, C1 →C2,0, P2 ,. . . ,Pg−1, L, Cg−1 →Cg,0, Pg ,Pg, L, Cg →C, d, P , withd∈ {−1,+1}, is replaced byP1, L, C1 →C, d, P .

It is trivial to see that the size of the read-only worktape alphabet can be bounded by L = Q ·(Σ+ 2) O(n· Σ), the size of the read-write worktape alphabet by C= (3· Q)·(3· Q) + 3 = 9n2+ 3≤O(n2), while for the number of finite control states we getP= (3· Q+ 2)·(4· Q+ 1) = 12n2+ 11n+ 2≤O(n2). Another important complexity measure for A is the number of visits at any worktape cell during the computation, bounded by

T = 5·n24n+ 1. (3)

To sum it up, we have derived the following:

Lemma 1. For each two-way alternating finite state automatonAwithnstates accepting a languageL ⊆Σ, there exists a deterministic linear bounded automa- ton A and a homomorphism H such that, for each w Σ, the machine A accepts H(w) if and only if A accepts w. The machine A starts in the initial state PINI at the leftmost worktape cell and returns the outcome by trying to leave the worktape to the left, in the respective statePACC orPREJ.

The machine A uses a linear worktape with two tracks; the first track is read-only; the second track is used in the standard read-write way. The read- write alphabet is of sizeO(n2)and the number of finite control states is bounded by O(n2). Moreover, A does not visit any cell along the worktape more than O(n2)times in the course of the entire computation.

140 V. Geffert

A starts in the initial statePINI with the worktape head at the leftmost symbol and rejects by trying to leave the worktape to the left in the unique state PREJ. Thus, to verify that A rejects, the alternating automaton A verifies whether there exists a backward path starting fromPREJand ending inPINI.Aguesses the trajectory of this unique backward path existentially. Along this path,Akeeps track of the currentlocal configuration S=k, qja, t, P, C , consisting of:

k, an auxiliary value, represented by the position of the head ofAalong the input tape containingw=a1· · ·am (on the worktape ofA, this corresponds to a block ofncells, labeled byq0ak, q1ak, . . . , qn−1ak),

qja, the label in the current cell under the head ofAalong its worktape, satisfy- inga=ak(the current worktape position ofAis thus completely determined byqj, k ),

t, the current number of visits at the current worktape position, made byAalong the computation path by which it gets from the initial configuration to the current configuration,

P, the current finite control state ofA, and

C, the current read-write contents in the worktape cell under the head.

The local configurationS is correct, if all values inS agree with some real configuration along the computation path ofA starting in the initial configura- tion onH(w). This real configuration is unique, sinceA is deterministic and loop-free, and hence each reachable configuration is completely determined by the worktape head position and by the number of visits at this position. Along the backward path, the current local configurationS is obtained by existential guessing. Now, the machineAhas to verify whetherSis correct. Before present- ing the verification procedure, consider how the correctness ofS can be derived from other local configurations in a “near neighborhood”.

If S represents the initial configuration, then S = 0, q0,1, PINI,unknown . Otherwise, there must exist S =k, qja, t, P, C , a correct local configura- tion describing the previous configuration, one step ofA back in time.S must be consistent withS, which means that:(i)S, Smust agree withd ∈ {−1,+1}, the direction of the latest move ofA along the worktape—the structure of this worktape was presented by (2). Namely, if d = +1, then j = (j−1) modn. Now, if j > 0, thenk =k, otherwisek =k−1. The case of d = 1 is sym- metric:j = (j+ 1) modnand, if j < n−1, thenk =k, otherwisek =k+ 1.

(ii) Moreover, all data must agree withH, the set of transitions of A. Namely, ifP, qja, C → C, d,P is a transition inH, thend=dandP=P.

Second, if t > 1, the current worktape position had to be visited in the past. Thus, there must exist S2 = k2, qj2a2, t2, P2, C2 , a correct local con- figuration describing the previous visit of A at the same worktape position, i.e., with k2 = k, qj2a2 =qja, and t2 =t−1. But then there must also exist S2 = k2, qj2a2, t2, P2, C2 , a correct local configuration describing the next configuration, one step of A forward in time from S2. The local configuration S2 must be consistent with S2 in the same way as S with S, that is, they agree withd2, the direction of the head movement fromS2 toS2, and withH,

Complement for Two-Way Alternating Automata 141 the set of transitions. Moreover, d2 = −d, since A cannot leave the current worktape cell to the right and then return back from the left, or vice versa. For these reasons, k2 =k and qj2a2 =qja. In addition, t2 ≤t, sinceA cannot reachSearlier thanS2, not excluding the possibility thatS2=S, witht2 =t. Finally, ifP2, qja, C2 → C, d,P is a transition inH, then C=C, since the contents in the current worktape cell did not change along the path connecting S2withS, not visiting the current worktape position in the meantime. This also givesd=d2 =−d.

Third, for each τ ∈ {t2, . . . , t1}, the computation path connecting S2

with S must pass through a configuration visiting the same worktape position for the τ-th time. Thus, there must exist Sτ =kτ, qjτaτ, τ, Pτ, Cτ , a correct local configuration with the head placed at the same position as in S, with kτ = k and qjτaτ = qja. (If t2 = t, the set {t2, . . . , t1} is empty.) In addition, A must move the head from Sτ in the direction −d, since the path connectingS2 withSdoes not visit the same worktape position in the meantime.

Thus, ifPτ, qja, Cτ → C, d,P is a transition inH, then d=−d.

The situation is different for S with t = 1. That is, the current worktape position has not been visited before. Also here there must exist S as specified above, but here the latest executed step, from S to S, must move the head of A in the direction d = +1, since the first visit to any cell must arrive from the left. Moreover, C must be equal to αqj,ak = αqj,a, the initial read-write contents for the current cell.

Next, for eachτ∈ {1, . . . , t1}, the computation path connecting the initial configuration withSmust pass through a configuration visiting the same work- tape position for theτ-th time. Thus, there must existSτ =kτ, qjτaτ, τ, Pτ, Cτ , a correct local configuration with the head placed at the same position as inS, which giveskτ=k andqjτaτ=qja. (Ift= 1, the set{1, . . . , t1}is empty.) In addition, A must move the head from Sτ in the direction −d =1, since A does not visit the worktape segment on the right ofS before it reachesS.

Summing up, a local configuration S with t > 1 is correct if and only if there exist correct local configurations S, S2, S2 such that, for each τ ∈ {t2, . . . , t1}, there exists a correct local configuration Sτ such that S, S2 , S2, Sτ satisfy all requirements specified above. Thus, verifying the cor- rectness ofS can be reduced to the same kind of verification for S, S2, S2 and St2, . . . , St1, all of them backward in time along the path ofA. An analogous reduction works forSwitht= 1, usingSandS1, . . . , St1instead ofS, S2, S2

andSt2, . . . , St1.

By implementation of these ideas, we can construct a2AFA A representing the local configuration S = k, qja, t, P, C by k, the head position along the input, and by qja, t, P, C, kept in the finite state control. Since Q =n, T O(n2) by (3), andP,C are bounded byO(n2), a local configuration can be represented by the use ofO(Σ ·n7) finite control states. For the givenS, the machineAverifies whether S is correct.

This is done as follows. First, branching existentially,Agenerates the local configurations S, S2, S2. Next, branching universally, A generates a value

142 V. Geffert

τ∈ {t2, . . . , t1}. After that, in each branch of the computation tree running in parallel,Abranches existentially again and generates the local configurationSτ. Next,Achecks whetherS, S2, S2, andSτ are consistent, i.e., whether they sat- isfy all requirements, as specified above. Then, in parallel, the correctness of each of them is verified in the same way, i.e., it becomes a new current local configu- rationS, after “forgetting” all data that are no longer required and, if necessary, updating the position of the head along the input tape. Even though these paral- lel branches make existential guesses about the computation ofAindependently of each other, the global consistency of allcorrect guesses is ensured by the fact thatA is deterministic, and hence the computation ofA is unique. Any wrong existential guess that contradicts this unique computation is overridden; such guess leads to an alternating subtree that is rejecting. Now, along each branch running in parallel and guessing correctly, A traces the unique computation of A backward in time to the initial local configuration, where the correctness is decided deterministically, by comparingS with0, q0,1, PINI,unknown . (We skip narration for the case oft= 1, handled analogically.) Starting from a local configuration that represents a moment whenAis going to reject,Acan verify whether the given input is rejected by the original machineA.

Recall that the local configurationSis represented by usingO(Σ·n7) finite control states, except for k, represented by the head position along the input.

All values inS, S2, S2 and inSτ, whereτ∈ {t2, . . . , t1}, are also kept in the finite state control, except fork, k2, k2, kτ. However, sincek∈ {k−1, k, k+ 1}, k2 = k, and k2 = kτ = k, also these values can be kept in the finite state control, relative to k. Moreover, utilizing qj2a2 = qja, qj2a2 =qjτaτ = qja, andt2=t−1, we can bound the total number of states byO(Σ2·n30).

Theorem 2. For each two-way alternating finite state automaton A with n states accepting a language L ⊆ Σ, there exists a two-way alternating finite state automaton A withO(Σ2·n30) states accepting the complement of the original language.