Lecture 2: Logspace
Last week:
 $TIME(f(n)), SPACE(f(n)), NTIME, NSPACE, ..$
 Speedup Theorem (2.2)
 $REACH$ (for directed graphs) aka $GAP$ is in $NL$ aka $NSPACE(log(n))$
 $REACH$ is in $SPACE(log^2(n))$
Th: NL ⊆ P i.e. ∀ℳ ∈ NL, ∃M'_ℳ ∈ P \text{ running in } P_L(n), M'_ℳ \text{ recognizes } L(ℳ)
Proof: the number of possible configurations of the TM is exponential in the space used. So if logarithmic space is used ⟶ polynomial time.
ndTM in Logspace:
on input $x∈Σ^\ast$
The set of configurations depends on the input: a configuration is of the form:
number of configurations:
bounded by:
it is polynomial in the size of the input, since the polynomial may depend on $M$ (or $L$ when considering the language)
The machine $M’_ℳ$ creates the graph of configurations so that each edge from one configuration to another match according to the transition table of $ℳ$
⟶ then: is there a path from an initial configuration to a final one ? ⟹ in polynomial time with respect to the input $x$ (the polynomial depending on $ℳ$)
Savitch Theorem (1970)
Savitch: NSPACE(f(n)) ⊆ SPACE(f^2(n))
for every space constructible $f$ (or $f(n) ≥ \log(n)$)
Space constructible ⟹ $f ≥ \log$
Proof: we will reduce this problem to $REACH$ in $SPACE(\log^2(n))$
Lemma: Let
 $M’$ that computes $G: A^\ast ⟶ B^\ast$ in space $g(n)$ ($≥ \log(n)$)
 $M$ that computes $F: C^\ast ⟶ A^\ast$ in space $h(n)$ (space constructible, $≥ \log(n)$)
then $∃ M’’$ that computes $G \circ F$ in space $g(\vert Γ \vert^{h(n)})$
Reminder:
 one does not write on the output tape nor does one reuse anything already written on it (one cannot scan it)
 it’s useless to compose the machine “naively”: the output of the first one might be too long for the second one.
 the output of the first one is bounded by the running time, which is bounded by the number of configurations $≤ \vert Γ \vert^{h(n)}$ since it doesn’t loop (since it terminates)
The problem is that if $g ≤ id$, $\vert Γ \vert^{h(n)}$ may be greater than $g(\vert Γ \vert^{h(n)})$
The thing is that $M’$ doesn’t even need to modify the output tape of $M$: it just needs to scan it.
$M’$ will write on the “output” tape of $M$: $i$ (remembered for later) to mean “$M$, give me $F(x)[i]$”.
Then, $M$ computes on $x$ and keeps up to date a counter to keep track of the current letter being output, then compares this counter with the $i$ of $M’$.
One doesn’t use $Γ^{h(n)}$ anymore, but just $2 \cdot h(n)$.
Then, since $g ≥ \log$,
so that the final space complexity is $O(g(Γ^{h(n)}))$
NB: if $M’$ is non deterministic, it works exactly the same way, and $M’’$ is then non deterministic as well: $M’’$ is of the same “nature” than $M’$ (whether it be deterministic or not)
Coming back to our proof:
we want to show that $L ∈ NSPACE(f(n))$
Here:
 $M’’$ in $SPACE(f^2(n))$
 $M’$ : REACH in $\log^2(n)$
 $M$ (deterministic) : generates the graph of configurations of the machine $M_L$ in $NSPACE(f(n))$ for $L$ running on $x$: $h(n) = O(f(n))$, and the size of the output (not needed) is $Γ^{f(n)}$
Corollary: \underbrace{PSPACE}_{≝ \bigcup_k SPACE(n^k) = SPACE(n^{O(1)})} = NPSPACE = coNPSPACE
trivial inclusion: $⊆$ since deterministic TMs are a special case of nondeterministic ones.
other inclusion: Savitch theorem:
And:
(coclass: you switch answers “yes” and “no” ⟶ for deterministic TM: reverse accepting and rejecting states)
Usually, nondeterministic space/time classes are NOT closed by complementation (since existentials are turned into universals)
But here, it is the case.
Reductions
If $P_1, P_2$ are problems/languages $⊆ A^\ast$
 $P_1$ reduces to $P_2$ in Logspace: $P_1 ≼_L P_2$:

iff there exists an $F : A^\ast ⟶ A^\ast$ logspacecomputable s.t. ∀x, x∈ P_1 ⟺ F(x) ∈ P_2
Ex:
 $SAT ≼_L 3\text{}SAT$
 the general graph accessibility problem can be reduced to the one where $s = 0, t=n$ and the number of edges is $n$
Corollary: if $P_1 ≼_L P_2$ and $P_2 ∈ P \text{ resp. } NL$, then $P_1 ∈ P \text{ resp. } NL$
Proof: application of the lemma of composition seen just before.
Property:
≼_L \text{ is transitive}
Proof: lemma of composition again.
Complete problems
 $L$ is complete for $𝒞$ (under logspace reduction) iff:

L ∈ 𝒞 ⟺ ∀L'∈ 𝒞, L' ≼_L L

REACH aka GAP is complete for $NL$
 to reduce any problem in $NL$: build the graph of configurations of the TM, and then: reachability problem in this graph

SAT is complete for $NP$: CookLevin Theorem (1971)
 in $NP$: guess valuation for the variable and evaluate to check if it gives “true” or “false”
 $NP \ni L ⊆ A^\ast$ ($M_L$ nd TM recognizing $L$) F_L: \begin{cases} A^\ast ⟶ B^\ast (\supset SAT) \\ x ⟼ φ_x \text{ boolean formula} \\ \end{cases} s.t. x ∈ L \text{ iff } φ \text{ is satisfiable }
One constructs boolean formulas
 $b_{t, i, a}$ which is true iff at time $t$, on position $t$, the current letter is $a$. We have $p(n) × n × \vert A \vert$ such formulas.
 $b_{t, q}$ true iff in state $q$ at time $t$
 $b_{t, j}$ true iff in position $j$ at time $t$
Then we encode the conditions enforced by the transition table of the TM, so that:
 if there is an accepting run, there will a truth valuation for the formula
 if there is a truth valuation for the formula, on can just read the execution table to check that the word is accepted
Leave a Comment