18. Logarithmic Space
By refining our basic space cost definition, we can study the complexity classes corresponding to languages that can be decided with a sublinear amount of space.
L and NL
The main modification we want to consider to the standard Turing machine model in order to study sublinear space complexity classes is to make the input tape read-only and add a new work tape that the Turing machine can use (in read/write fashion) as usual during its execution.
Definition. An input/work tape Turing machine is a two-tape Turing machine whose input is on the first read-only tape and where the other tape is a standard read/write tape that is initially empty.
Apart from the restriction that the first tape is read-only, input/work tape Turing machines behave exactly as standard Turing machines. The extension of verifiers to input/work tape verifiers is also done in the same way, with the certificate also being read-only (as before).
The space cost of an input/work tape Turing machine
Space Class | Definition |
---|---|
Constant space | |
The classes
Proposition.
.
Proof. This result is another direct corollary of the Time-Space Hierarchy theorem from the last lecture.
Are any of these inclusions strict? After all, it seems intuitively obvious that some languages in
NL-Completeness
Does
Definition. Given two languages
, the language is log-space reducible to , denoted if there is a function
such that
For every
, we have ; and There is a logarithmic-space Turing machine
that on input , index , and symbol , accepts if and only if the th symbol of is .
Remarks.
-
As per the definition, when the index
is larger than the length of the string , rejects on for all values of . -
Whenever
, then also holds. That’s because by iterating on indices and all , we can compute in polynomial time. -
However, the converse is not necessarily true: if
, then there are languages for which holds but does not.
Log-space reductions play the same role for
Lemma. For every two languages
that satisfy ,
If
, then as well; and If
, then as well.
Proof. Let
be a machine that provides the logarithmic space reduction from to . Consider an input
. Ideally, we would like to use to output on the tape and then invoke a (deterministic or non-deterministic) logspace TM for on input to determine if or not. But the problem with this approach is that we can’t write
on the tape when we only have logarithmic space. So instead we simulate access to the input tape for : we use a counter to keep track of the tape head position of on the input tape, and we use to determine what the symbol of is at that position to simulate each transition of . Doing so enables us to simulate accurately with only a logarithmic space extra cost.
We can now define the class of
Definition. The language
is -complete if
Every language
satisfies ; and
.
By the last lemma, to show that
Connectivity
The
Lemma.
.
Proof. Consider the verifier
whose certificate represents a sequence of vertices in the graph that starts in and ends in . can verify that each pair of adjacent vertices in the certificate are indeed connected by an edge in the graph and also that the length of the sequence includes at most vertices. Both these checks require only a logarithmic amount of space.
The language
Theorem.
is -complete.
Proof. We already saw that
so it remains to show that it is -hard. Fix any language
. Let be a verifier that decides with space cost . Let us consider partial configurations of
. Such partial configuration is defined by the current state of , the position of its tape heads on the input, certificate, and work tapes, and the contents of the input and work tapes. Importantly, a partial configuration of does not include the content of the certificate tape. Define
to be the partial configuration graph of , as defined in the last lecture. Each partial configuration of is a vertex, and there is a directed edge from to when there is a certificate that causes to go from configuration to in one step. We can assume without loss of generality that has a single accepting configuration . When
has space cost , the number of partial configurations of the machine is polynomial in . And the transformation from to can be completed with logarithmic space cost. Finally, there is a parameter such that an input is in if and only if where is the vertex corresponding to the initial configuration of on input . This means that we obtain the logspace reduction .
This last result shows that we can resolve the