Problem text in black, solution text in blue.
I'll describe the four-state DFA in words:
The four Myhill-Nerode classes are the sets of strings that take this DFA from the start state to each of the states:
Many other correct solutions are possible.
Hint: M is in essence a two-way DFA, like an ordinary DFA except that it can move in either direction based on its state and the letter it sees. That is, its transition function is from (Q times Σ) to (Q times {L,R}) where Q is its state set and Σ its alphabet.
To show that L(M) is regular, we define a set of questions about a string w and show that two strings with the same answers to all these questions are Myhill-Nerode equivalent with respect to L(M). Here are the questions:
If you choose to follow this Hint, your job is to show (a) that if
strings v and w have the same answers for each of these questions, then
they are Myhill-Nerode equivalent for L(M), (b) there are only finitely
many different possible answers for these questions, and (c) it follows
that L(M) is regular.
Consider these two behaviors of M from the beginning, with M started on
the left end of each string. If M never leaves v when running on vx, it also
never leaves w running on wx (because the first question has the same answer)
and so neither string is accepted. If it does enter x on vx, it enters x on
wx in the same state, because the first question has the same answer. Running
on x starting from the same state, the two machines have the same behavior
because they see the same letters of x. If they both leave the right end of
x, they do so in the same state, and we are done.
The remaining case is when the two machines leave x to the left, doing so
in the same state. Now because v and w have the same answers to each of the
second class of questions, the machines either both fail to return or both
return to x in the same state. In the former case we are done, in the latter
the two machines again behave identically on x, either leaving to the right in
the same state or returning once more to v and w.
By induction on the number of times the machines enter x, we see that they
always do so in the same state given our assumption about the answers to the
questions for v and w. Thus if one machine ever leaves x to the right, the
other also does so after the same number of visits to x, and in the same state.
No one explained this correctly. Several people noted
that if there was no worktape at all in the DSPACE(1) machine, it would be
a two-way DFA and its language would be regular by Question 2. But of course
there is a worktape, and we need to explain why the worktape
doesn't allow the DSPACE(1) machine to accept a non-regular language.
The key point is that the size of the worktape is bounded by a constant
that does not depend on the input size. Let a be the number of worktape
cells and b the size of the worktape alphabet. There are only ba
possible strings to be on the worktape, and only a possible head positions,
so the worktape is always in one of at most aba states, a number
that does not depend on the input size.
Let q be the number of states in the DSPACE(1) machine. By treating the
state of the worktape as part of the machine state, we can build a two-way
DFA with qaba states, one state for each possible combination of
machine state and worktape state. Since the DSPACE(1) machine's behavior
and next worktape state depend only on the current state, current worktape
state, and input letter it sees, this can be modeled as a two-way DFA.
Then by Question 2 we may conclude that L(M) is regular, though with
a potentially huge number of equivalence classes:
(qaba+1)(qaba+1).
We must prove that every r.e. language is the language of some 2SDPA and that the language of every 2SPDA is r.e.:
We can define the acceptance condition of P so that L(P) = L(M) = A, and thus we prove that A is the language of a 2SPDA as desired. Many students described the simulation convincingly, but did not explain how this simulation's existence proved the desired result.
Because A is recursively enumerable, there exists some TM MA
such that A = L(MA), that is, such that MA halts on
an input string w in an accepting state iff w is in A.
We design M as follows. Its input must be two strings u and v, separated
by a space. It runs MA on both u and v in parallel,
alternating between running a step on u and running a step on v. It does
this on two sections of its single tape, moving the v-tape part to the right
whenever necessary to create enough room for the u-tape part.
We are given that exactly one of u and v is in A, and thus that exactly
one of these two computations will eventually halt and accept. We design
M to halt when this happens, and indicate with its output which one accepted.
By the assumption, we are guaranteed that M will eventually halt.
Several students had the right idea for this problem but did not indicate
what machine they were running in the two parallel computations.
Last modified 25 June 2003