334 Hints and Solutions
Homework 6 Solutions
1. (a) If S(n) is space-constructible, there is a machine M that on any
input of length n lays off exactly S(n) space on its worktape with-
out using more than S(n) space and halts. If M has q states and
d worktape symbols, and if S(n) ≤ o(log n), then the number of
configurations of state, worktape contents, and worktape head po-
sitionsisatmostqS(n)d
S(n)
, which is less than n/2 for sufficiently
large n.IfM ever scans all the way to the midpoint of a very
long input string 0
n
, it must be in a loop by the time it hits the
midpoint. That is, after the last time it sees the left endmarker
and before it gets to the midpoint, it must be in the same configu-
ration c while scanning two different input tape locations i and j,
i<j<n/2, without seeing the left endmarker in between. Because
it sees nothing but 0’s on the input tape after i, it will go through
the same sequence of configurations starting from j as it did from
i, continuing all the way across until it sees the right endmarker,
which may cause it to change behavior. If we insert a string of 0’s of
length a multiple of p
1
= j −i ≤ n/2, the machine will not be able
to tell the difference; it will hit the right endmarker in the same
configuration. The same is true if it scans back again from right
to left; by the time it hits the midpoint, it is in a loop of period
p
2
≤ n/2, and so on. We can thus insert a string of 0’s of length
m! for any m ≥ n, which is a multiple of all the possible periods p
i
of these loops, and the machine will not behave any differently; in
particular, it will not lay off any more or less space on its worktape.
This says that S(n + m!) = S(n) for all m ≥ n.
(b) lim inf log log n = ∞.
2. To show that the problem is in PSPACE ,weguessastringthatis
not accepted by M and verify that it is not accepted. We start with a
pebble on the start state of M , then guess an input string symbol by
symbol, moving pebbles on the states of M to mark all states reachable
from the start state under the string guessed so far. We do not have
to remember the guessed string, just the states that M could currently
be in. We accept if we ever get to a situation with no pebble on an
accept state. Because the pebble configuration can be represented in
polynomial space, this is a nondeterministic PSPACE computation. It
can be made deterministic by Savitch’s theorem.
(Note. It is not true that if an NFA accepts all strings of length less than
or equal to the number of states, then it accepts all strings, even over a
single letter alphabet. For example, consider an automaton with a start