Exercise

Place Directed Reachability in NL

Give a log-space nondeterministic reachability algorithm with a bounded path-length counter.

Assignment sources

Noy 2025 high-quality exam preparation and community solutionsCommunity solutionפתרון מטלה 6- סיבוכיות.pdfAssignment 6High-quality preparation and community solution — not official

Problem

For a directed graph GG with vertices numbered 1,…,n1,\ldots,n and distinguished s,ts,t, give a nondeterministic O(log⁡n)O(\log n)-space decider for whether tt is reachable from ss. Ensure all branches halt and account for adjacency access, vertex storage, and the step counter.

Prerequisites

Know the unit definitions and how resources are measured against encoded input length. Distinguish a conditional theorem, a reduction, and an algorithm.

Hint 1

If a path exists, a simple path of at most n−1n-1 edges exists.

Hint 2

Store only the current vertex, not the path.

Hint 3

At each step guess the next vertex and verify its edge by scanning the read-only input.

Full solution

Store a current-vertex register vv, initialized to ss, and a counter i=0i=0. If v=tv=t, accept. While i<n−1i<n-1, nondeterministically choose a number u∈{1,…,n}u\in\{1,\ldots,n\}. Scan the read-only encoding of GG to verify that (v,u)∈E(v,u)\in E; if not, reject this branch. Otherwise set v:=uv:=u, increment ii, and test again for tt. Reject when the budget is exhausted.

Each register for a vertex needs ⌈log⁡n⌉\lceil\log n\rceil bits, as does the counter. A constant number of input-head positions and flags also requires O(log⁡n)O(\log n) bits under the standard read-only input/work-tape convention. For an adjacency matrix, the machine computes or scans to the relevant entry using logarithmic counters. For an adjacency-list encoding, it scans for the pair while retaining v,uv,u. Repeated scans affect time but not work space. Thus the total work space is O(log⁡n)O(\log n).

Every branch makes at most n−1n-1 successful edge guesses and each verification scan halts, so this is a decider rather than a semidecider. If tt is reachable from ss, remove cycles from a shortest walk to obtain a simple directed path with at most n−1n-1 edges. One branch guesses exactly its vertices and accepts. If tt is not reachable, every sequence of verified edges remains a walk from ss and can never reach tt, so every branch rejects. Hence STCON∈NL\mathrm{STCON}\in\mathrm{NL}.

The algorithm may use polynomial time: there are only nn iterations, each with a polynomial input scan. Nondeterminism changes the acceptance semantics, not the space charged per branch; we do not store or explore all branches simultaneously.

The counter is essential for guaranteed halting because blindly guessing a walk could cycle forever. Storing a visited set would also prevent cycles but costs Θ(n)\Theta(n) bits and would miss the desired log-space bound. The simple-path lemma supplies boundedness without that storage.

Checkpoints

Check both logical directions, halting of every relevant branch, and that output length and construction time are polynomial in the encoded input length.

Common mistakes

  • Storing the whole guessed path or a visited bit vector.
  • Omitting the counter and obtaining a non-halting branch.
  • Charging space for all nondeterministic branches at once.

Sources and verification

  • Merged summary, pp. 114-117
  • Sipser 3e, sec. 8.4
  • Arora-Barak draft, sec. 4.3
  • Catalog mapping: data/exercises.json; statements and solutions are independently written; personal submissions are non-authoritative.

Provenance and confidence

The exercise is an original synthesis. Confidence reflects verification of the mathematical claim against the textbook sources listed above; course sources are used only where direct coverage is identified.