CS 637: Mathematics-II

Lecture 17: Space Complexity Classes L, NL, PSPACE, and NPSPACE

Definitions via SPACE and NSPACE

Space-Bounded Classes

\[ SPACE(s(n)) = \{L : \text{some deterministic TM decides } L \text{ using } O(s(n)) \text{ work space}\}, \] \[ NSPACE(s(n)) = \{L : \text{some nondeterministic TM decides } L \text{ using } O(s(n)) \text{ work space}\}. \]

The input tape is read-only and is not counted toward work space.

Named Classes

\[ L = SPACE(\log n), \qquad NL = NSPACE(\log n), \] \[ PSPACE = \bigcup_{c \ge 1} SPACE(n^c), \qquad NPSPACE = \bigcup_{c \ge 1} NSPACE(n^c). \]

Why Logarithmic Space Is Tiny

With \(O(\log n)\) space, a machine cannot store the whole input, but it can store a constant number of pointers, counters, or vertex indices of size \(O(\log n)\).

Relationships Among the Classes

Standard Inclusions

\[ L \subseteq NL \subseteq PSPACE \subseteq EXPTIME \]

and trivially

\[ PSPACE \subseteq NPSPACE. \]

Savitch's Theorem

For every space-constructible \(s(n) \ge \log n\),

\[ NSPACE(s(n)) \subseteq SPACE(s(n)^2). \]

Applying this to polynomial space yields

\[ NPSPACE = PSPACE. \]

Immerman-Szelepcsényi Theorem

\[ NL = coNL. \]

This is a special feature of space-bounded computation. The proof relies on counting how many vertices are reachable within a bounded number of steps, using only logarithmic space and repeated enumeration.

What Is Known and Unknown

Statement Status
\(L \subseteq NL\) known
\(NL = coNL\) known
\(L = NL\) open
\(P \stackrel{?}{=} PSPACE\) open

Enumeration Technique

General Idea

When the machine has little memory, it can recompute needed information rather than store it. A common method is to enumerate all candidate objects one by one using a logarithmic-space counter.

Typical Pattern

  1. Store an index \(i\) using \(O(\log n)\) bits.
  2. Generate the \(i\)-th object on demand.
  3. Test a local property.
  4. Increment \(i\) and repeat.

This is enough to scan all vertices, all positions of a string, or all pairs \((i,j)\) without storing the full list.

Reachability Counting Version

For directed reachability, define \(R_i\) to be the set of vertices reachable from \(s\) by a path of length at most \(i\). The key subroutine is to compute \(|R_i|\) from \(|R_{i-1}|\).

  1. Enumerate all vertices \(v\).
  2. For each \(v\), check whether \(v\in R_i\) by testing whether \(v\in R_{i-1}\) or some predecessor \(u\in R_{i-1}\) has an edge to \(v\).
  3. Increase the counter whenever the test succeeds.

Only the loop indices, a few vertex names, and the running count are stored, so the space usage is \(O(\log n)\).

Why Enumeration Is Powerful

Logarithmic space does not mean weak control. It means the algorithm must trade memory for repeated passes over the input. This is exactly what makes the proof of \(NL = coNL\) possible.

Why PATH Belongs to \(NL\)

PATH Problem

\[ PATH = \{\langle G,s,t \rangle : \text{there is a directed path from } s \text{ to } t \text{ in } G\}. \]

Nondeterministic Log-Space Algorithm

  1. Keep the current vertex \(v\) and a step counter \(c\), each using \(O(\log n)\) bits.
  2. Start with \(v=s\) and \(c=0\).
  3. Nondeterministically guess a next vertex \(u\).
  4. Verify from the input that \((v,u)\) is an edge.
  5. Replace \(v\) by \(u\), increment \(c\), and accept if \(v=t\).
  6. Reject if \(c\) exceeds \(n-1\).

If a path exists, one branch guesses it. If no path exists, no branch can reach \(t\) within \(n-1\) steps.

Space Analysis

The machine stores only a constant number of vertex names and counters, each of size \(O(\log n)\). Hence \(PATH \in NL\).

Why Binary Addition Belongs to \(L\)

Problem

Given binary strings \(x\), \(y\), and \(z\), decide whether

\[ x + y = z. \]

Log-Space Method

  1. Use counters to point to the current bit positions of \(x\), \(y\), and \(z\).
  2. Maintain one carry bit.
  3. Scan from right to left, recomputing the current bits from the input as needed.
  4. Check that each output bit equals the sum of the two input bits plus carry modulo \(2\).
  5. Update the carry and continue.

Space Bound

The machine stores:

  • three position counters, each needing \(O(\log n)\) bits,
  • one carry bit,
  • a constant number of temporary symbols.

Therefore the total work space is \(O(\log n)\), so binary addition is in \(L\).

Lesson

Sequential arithmetic can often be checked in logarithmic space because we only need a few pointers and a tiny amount of state.

🏠