Savitch's theorem
Savitch's theorem is a foundational result in computational complexity theory, established by Walter J. Savitch in 1970, which demonstrates that nondeterministic space-bounded computations can be efficiently simulated by deterministic ones up to a quadratic overhead.[1] Specifically, it states that for any space function s(n) \geq \log n, the class of languages accepted by nondeterministic Turing machines using at most s(n) space, denoted NSPACE(s(n)), is contained in the class accepted by deterministic Turing machines using at most O(s(n)^2) space, or DSPACE(s(n)^2).[1] This simulation holds for multi-tape Turing machines and relies on a careful analysis of computation configurations modeled as "threadable mazes."[1]
A key corollary of Savitch's theorem is that the complexity class PSPACE, consisting of problems solvable by deterministic Turing machines in polynomial space, equals NPSPACE, the nondeterministic polynomial-space analogue.[2] This equality arises because Savitch's result places NPSPACE within PSPACE (via the quadratic blowup remaining polynomial), while the reverse inclusion holds trivially since deterministic machines are a special case of nondeterministic ones.[2] Unlike the open question of whether P equals NP for time complexity, Savitch's theorem resolves the analogous issue for space, showing that nondeterminism offers no asymptotic advantage in this regime.[2]
The proof of Savitch's theorem employs a recursive procedure to verify reachability between pairs of machine configurations, effectively exploring the computation graph without enumerating all nondeterministic branches.[2] This technique not only yields the general simulation but also implies that directed graph reachability (st-connectivity) is solvable deterministically in O(\log^2 n) space, thereby showing that the nondeterministic log-space class NL is contained in DSPACE(\log^2 n).[2] These insights have profoundly influenced the study of space-bounded complexity classes and hierarchy theorems.
Background Concepts
Nondeterministic Turing Machines
A nondeterministic Turing machine (NTM) is a variant of the Turing machine model that allows multiple possible transitions from a given state and tape symbol, enabling the computation to branch into several possible paths at each step. This nondeterminism models the ability to "guess" or explore multiple possibilities in parallel, which is useful for defining complexity classes where verification is easier than search. Unlike deterministic machines, an NTM's computation forms a tree of paths, and the overall behavior is defined by the existence of at least one accepting path.[3]
Formally, an NTM is defined as a 7-tuple (Q, \Sigma, \Gamma, \delta, q_0, q_{\text{accept}}, q_{\text{reject}}), where Q is a finite set of states, \Sigma is the input alphabet, \Gamma is the tape alphabet with \Sigma \subseteq \Gamma and a blank symbol B \in \Gamma, q_0 \in Q is the start state, q_{\text{accept}}, q_{\text{reject}} \in Q are the accepting and rejecting states (distinct), and \delta: Q \times \Gamma \to \mathcal{F}(Q \times \Gamma \times \{L, R, S\})^k is the nondeterministic transition function for some finite k, where \mathcal{F} denotes the finite power set (subsets of possible next states, tape symbols, and head movements: left L, right R, or stay S). This allows up to finitely many branches per step, capturing the nondeterministic choice. Deterministic Turing machines are a special case where |\delta(q, \gamma)| = 1 for all q \in Q, \gamma \in \Gamma.[3][4]
The space complexity of an NTM on an input of length n is measured by the maximum number of tape cells visited across all possible computation paths, ensuring a uniform bound for the resource analysis in space-bounded classes. This maximum usage determines whether the machine operates within a given space function s(n). For instance, a simple NTM can recognize the language of palindromes over \{[0](/page/0),[1](/page/1)\}^* in O(\log n) space by nondeterministically guessing the midpoint position (stored in O(\log n) bits on the work tape), then verifying that symbols match symmetrically from both ends toward the guessed middle by using counters to position the read head. This illustrates how nondeterminism facilitates efficient "guessing" to reduce space needs compared to exhaustive deterministic checks.[5][6]
An input is accepted by the NTM if there exists at least one computation path that halts in the accepting state q_{\text{accept}} without exceeding the space bound, regardless of other paths; otherwise, if all paths halt in q_{\text{reject}} or loop infinitely (though space-bounded NTMs are often assumed to halt), the input is rejected. This existential acceptance criterion underpins the power of nondeterminism in space-bounded computation, setting the stage for relating NTM classes to deterministic ones via theorems like Savitch's.[3]
Space Complexity Classes
Space complexity classes organize decision problems based on the minimum space required by Turing machines to solve them, providing a framework for understanding computational resources beyond time. The class \mathsf{DSPACE}(s(n)) consists of all languages that can be decided by a deterministic Turing machine using at most s(n) space on inputs of length n, where s(n) \geq \log n to ensure the machine can access the input via a read-only input tape.[7] Similarly, \mathsf{NSPACE}(s(n)) includes languages decided by a nondeterministic Turing machine bounded by s(n) space, where the machine accepts if there exists at least one accepting computation path.[7] These classes assume a multi-tape model with a separate read-only input tape and work tapes measured for space usage.[7]
Asymptotic notation in space complexity emphasizes sublinear bounds, such as s(n) = o(n), which restrict work tape usage below the input length and highlight efficient memory models. For instance, the class of regular languages belongs to \mathsf{DSPACE}(O(1)), as deterministic finite automata recognize them using constant space independent of input size.[7] Nondeterministic branching can enable potentially more efficient space use than deterministic computation by exploring multiple paths selectively.[7]
A fundamental inclusion holds: \mathsf{DSPACE}(s(n)) \subseteq \mathsf{NSPACE}(s(n)) for s(n) \geq \log n, since any deterministic machine is a special case of a nondeterministic one with no branching, allowing direct simulation without additional space.[7] This follows from the universal simulation of deterministic computations on nondeterministic machines, which preserves the space bound by mimicking the single path.[7]
Space hierarchy theorems establish separations within these classes, preventing collapse. For space-constructible functions s(n) (where a machine can, on input $1^n, mark off s(n) cells), \mathsf{DSPACE}(s(n)) \subsetneq \mathsf{DSPACE}(s(n)^2), meaning there exist languages solvable in O(s(n)^2) space but not in o(s(n)) space.[8] This result, proved via diagonalization, demonstrates that increasing space quadratically allows solving strictly more problems, underscoring the richness of the space hierarchy.[8]
Theorem Enunciation
Savitch's theorem establishes a fundamental relationship between nondeterministic and deterministic space complexity classes. Formally, for any space-constructible function s: \mathbb{N} \to \mathbb{N} with s(n) \geq \log n, \NSPACE(s(n)) \subseteq \DSPACE(s(n)^2).[1][9]
Intuitively, the theorem demonstrates that any nondeterministic computation using space s(n) can be simulated deterministically by exploring the configuration graph of the nondeterministic Turing machine (NTM), where the quadratic space overhead arises from recursively checking reachability between pairs of configurations.[1][9]
The theorem applies to multitape Turing machines and assumes s(n) is space-constructible, meaning there exists a deterministic Turing machine that on input $1^n uses exactly s(n) space and halts.[1] The space complexity classes \NSPACE and \DSPACE are defined using log-space reductions, ensuring the inclusion holds under these standard closure properties.[9]
In notation, the deterministic space bound is often expressed as O(s(n)^2), highlighting the tight quadratic factor in the simulation. No linear-space deterministic simulation of nondeterministic space is known, and the quadratic blowup's necessity is motivated by the deterministic space hierarchy theorem, which separates \DSPACE(s(n)) from \DSPACE(s(n)^2) for suitable s(n), implying that the inclusion cannot hold with subquadratic overhead for all such functions.[9]
Historical Development
Walter J. Savitch proposed the theorem that bounds the space complexity of nondeterministic Turing machines by the square of their space usage during his PhD studies at the University of California, Berkeley, where his dissertation was supervised by Stephen Cook.[10] This work originated in the late 1960s amid growing interest in resource-bounded computation models, building directly on the space hierarchy theorems established by Juris Hartmanis and Richard E. Stearns, which demonstrated strict separations between space complexity classes for Turing machines.[11]
The theorem was formally published in 1970 under the title "Relationships Between Nondeterministic and Deterministic Tape Complexities" in the Journal of Computer and System Sciences (volume 4, issue 2, pages 177–192).[1] At the time, the field of computational complexity was rapidly evolving following Stephen Cook's 1971 introduction of NP-completeness via the satisfiability problem, which highlighted the potential power of nondeterminism in time-bounded computation and posed analogous questions for space. Savitch's result addressed a key open question by showing that nondeterminism does not provide more than a quadratic advantage in space, providing a foundational bridge between nondeterministic and deterministic space classes in the emerging theory of PSPACE.
Upon publication, the theorem quickly influenced early studies in space complexity, serving as a cornerstone for analyzing problems like quantified Boolean formulas and establishing the equivalence of deterministic and nondeterministic polynomial space. It was prominently featured and cited in seminal textbooks, such as John E. Hopcroft and Jeffrey D. Ullman's 1979 Introduction to Automata Theory, Languages, and Computation, which helped disseminate its implications to a broader audience of researchers and students. By the 1980s, the result had become widely known as Savitch's theorem in surveys and monographs on complexity theory, solidifying its status as a landmark achievement in the field's foundational development.[12]
Proof Overview
High-Level Strategy
The proof of Savitch's theorem revolves around deterministically simulating a nondeterministic Turing machine (NTM) that uses space s(n) to decide if there exists an accepting computation path from the initial configuration to an accepting one. This simulation avoids explicitly exploring all possible paths by reducing the acceptance problem to a reachability query in an implicit graph of configurations.
A configuration of the NTM encapsulates its current state, the contents of the tape limited to s(n) cells, and the positions of the tape heads; since each component is bounded, the total number of possible configurations is at most $2^{O(s(n))}. These configurations form the vertices of a directed graph, where edges represent valid single-step transitions computable in space O(s(n)). The core challenge lies in the exponential size of this graph—too vast to construct or traverse explicitly in subexponential space—necessitating a clever method to verify reachability without materializing the entire structure.
The high-level strategy employs a divide-and-conquer paradigm on the potential path lengths, assuming a maximum computation length bounded by $2^{O(s(n))}. It recursively checks for the existence of a midpoint configuration reachable from the start in half the steps and from which the target is reachable in the remaining half, effectively counting paths through intermediate points without storing the full graph. This recursive decomposition ensures that the space overhead remains quadratic in s(n), as the depth of recursion aligns with the logarithm of the path length while reusing space across levels.
Configuration Graph Approach
The configuration graph approach formalizes the computation of a nondeterministic Turing machine (NTM) as a directed graph, enabling a deterministic simulation by reducing acceptance to a reachability problem. In this model, vertices represent all possible configurations of the NTM on a given input of length n, where a configuration is a triple consisting of the current state, the contents of the work tape (of length at most s(n), the space bound), and the positions of the read/write heads on the input and work tapes.[13][14] Each edge in the graph corresponds to a single transition step of the NTM according to its transition function, with nondeterminism manifesting as an out-degree bounded by a constant (the maximum number of choices per configuration).[13][15]
The size of this graph is exponential in the space bound: the number of vertices |V| is at most \exp(O(s(n))), since there are at most exponentially many possible tape contents and head positions given the space limitation s(n) \geq \log n. Similarly, the number of edges |E| is at most \exp(O(s(n))), as each vertex has a constant number of outgoing edges. For halting computations, any accepting path from the initial configuration has length at most \exp(O(s(n))), reflecting the maximum number of distinct configurations before repetition (and thus looping) occurs.[13][15][14]
The NTM accepts the input if and only if there exists a path in this graph from the start configuration q_0 (initial state with blank tapes and heads at the starting positions) to some accepting configuration F (a state marked as accepting, regardless of tape contents). This reduction to graph reachability captures the essence of nondeterministic choice as branching paths, allowing the proof to focus on deterministically verifying path existence.[13][14]
To simulate the NTM deterministically, the approach constructs a deterministic Turing machine (DTM) that, given two configurations c_1 and c_2 as well as a time bound t, decides whether c_1 can reach c_2 in at most t steps within the configuration graph, using space O(s(n)^2 + \log t). Storing a single configuration requires O(s(n)) space to encode the state, head positions, and tape contents. The overall space usage of O(s(n)^2 + \log t) arises from the recursion depth of O(\log t) = O(s(n)) and O(s(n)) space per recursive call for parameters (including pairs of configurations) and computations, resulting in O(s(n)^2) stack space.[13][15] This graph-centric framework underpins the deterministic simulation while bounding resources tightly relative to the original NTM's space usage.[13]
Detailed Proof
Recursive Reachability Simulation
The core of the deterministic simulation in Savitch's theorem relies on a recursive procedure to determine reachability in the configuration graph of the nondeterministic Turing machine (NTM). This procedure, often denoted as REACH(c_1, c_2, t), accepts two configurations c_1 and c_2 along with a time bound t and returns true if there exists a path from c_1 to c_2 of length at most t in the graph, where configurations represent the NTM's state, tape contents (bounded by space s(n)), and head position.[1] The algorithm leverages the structure of the configuration graph, where nodes are all possible configurations (numbering $2^{O(s(n))}) and directed edges correspond to valid one-step transitions under the NTM's nondeterministic rules.[1]
The procedure first checks if c_1 = c_2, returning true in that case to handle paths of length 0 for any t \geq 0. If t = 0 and c_1 \neq c_2, it returns false. When t = 1, the procedure verifies if c_2 is a direct successor of c_1 by applying the NTM's transition function: given c_1's state and head symbol, it enumerates all possible moves (finitely many, per the machine's definition) to generate candidate next configurations and checks if any matches c_2. This handles nondeterminism by exhaustively testing the finite branches from c_1, without exploring longer paths.[1]
In the recursive step for t > 1, the algorithm decomposes the path into two halves by considering midpoints: it returns true if there exists some configuration m such that REACH(c_1, m, \lfloor t/2 \rfloor) and REACH(m, c_2, \lceil t/2 \rceil) both hold. To iterate over possible m, the procedure generates all candidate configurations on the fly, as there are $2^{O(s(n))} possibilities, each describable in O(s(n)) space (encoding tape symbols from a fixed alphabet, head position up to O(s(n)), and finite states). Rather than storing all at once, it uses a nested loop structure—effectively counters for each tape position and symbol—to produce one m at a time, simulating enumeration without exceeding O(s(n)) space per iteration. Nondeterminism is managed here by relying on the recursive calls to explore existential paths through the graph's edges, which are defined by the NTM's transitions.[1]
The following pseudocode illustrates the procedure:
function REACH(c1, c2, t):
if c1 == c2:
return true
if t == 0:
return false
if t == 1:
return exists transition from c1 to c2 // via NTM rules
for each possible configuration m: // generated iteratively in O(s(n)) space
if REACH(c1, m, floor(t/2)) and REACH(m, c2, ceil(t/2)):
return true
return false
function REACH(c1, c2, t):
if c1 == c2:
return true
if t == 0:
return false
if t == 1:
return exists transition from c1 to c2 // via NTM rules
for each possible configuration m: // generated iteratively in O(s(n)) space
if REACH(c1, m, floor(t/2)) and REACH(m, c2, ceil(t/2)):
return true
return false
This recursion halves t at each level, leading to a call tree of depth O(\log t) = O(s(n)), with each level reusing space for configuration storage and counters.[1]
Correctness follows by induction on t. For t=0, it holds by direct verification: true only if c_1 = c_2. For t=1, the equality check handles length 0, and the transition check handles length 1. Assume true for all values up to \max(\lfloor t/2 \rfloor, \lceil t/2 \rceil); for t > 1, any path of length at most t can be split after at most \lfloor t/2 \rfloor steps (first subpath \leq \lfloor t/2 \rfloor, second subpath \leq \lceil t/2 \rceil), and the induction hypothesis ensures the subpaths are detected if they exist. Shorter paths are handled by the equality check or recursive subcalls. Conversely, if the procedure returns true, the recursive witnesses reconstruct a valid path via the NTM's transitions. Thus, it precisely captures whether a path exists in the configuration graph.[1]
Space Analysis
In the recursive REACH procedure used to simulate the nondeterministic Turing machine (NTM), each recursive call requires space to store two configurations of the NTM, each occupying O(s(n)) space, along with the parameter t, which can be represented using O(s(n)) bits since t ≤ 2^{O(s(n))}. Thus, the space per recursive call is O(s(n)).[13]
The recursion depth is O(s(n)), as the procedure halves t at each level, and the initial t is at most 2^{O(s(n))}, yielding log_2(2^{O(s(n))}) = O(s(n)) levels. The total space complexity arises from the recursion stack, where each of the O(s(n)) levels requires O(s(n)) space, resulting in O(s(n)^2) overall; notably, the full configuration graph need not be stored explicitly, as the simulation proceeds without materializing it.[13]
When iterating over possible midpoint configurations m in the recursive step, there are 2^{O(s(n))} candidates, but these are processed sequentially one at a time. For each m, the NTM is simulated for a single step or to verify transitions, using O(s(n)) additional space on a reusable tape, without accumulating beyond the per-call bound. Although the total number of recursive calls forms a tree of size exponential in O(s(n)), the space usage remains confined to the current call stack, as subcalls complete before the next iteration begins.[13]
To formalize the bound, let S(t) denote the space required by REACH for parameter t. The recurrence is
S(t) = O(s(n)) + S\left(\frac{t}{2}\right),
with base case S(1) = O(s(n)). Unrolling the recurrence over the O(s(n)) levels gives
S(t) = O(s(n) \cdot \log t) = O(s(n)^2),
since \log t = O(s(n)). This establishes the O(s(n)^2) space for the core simulation.[13]
At the top level, the deterministic Turing machine (DTM) invokes REACH from the start configuration to each possible accepting configuration (of which there are 2^{O(s(n))}), again processing them sequentially and reusing space, so the overall space remains O(s(n)^2). The quadratic bound is necessary, as the space hierarchy theorem implies strict separations between SPACE(o(s(n)^2)) and SPACE(s(n)^2), showing that deterministic simulations of NSPACE(s(n)) cannot generally achieve subquadratic space.[13]
Corollaries and Implications
Direct Consequences
Savitch's theorem establishes that for any space-constructible function s(n) \geq \log n, \mathsf{NSPACE}(s(n)) \subseteq \mathsf{DSPACE}(s(n)^2).[1] This inclusion directly yields several key relationships among space complexity classes.
Applying the theorem to linear space bounds, \mathsf{NSPACE}(n) \subseteq \mathsf{DSPACE}(n^2).[16] Since \mathsf{L} = \mathsf{DSPACE}(\log n) \subseteq \mathsf{NL} = \mathsf{NSPACE}(\log n) \subseteq \mathsf{NSPACE}(n), it follows that \mathsf{L} \subseteq \mathsf{NL} \subseteq \mathsf{DSPACE}(n^2).[17]
For polynomial space, the theorem implies \mathsf{NPSPACE} \subseteq \mathsf{PSPACE}, as \mathsf{NPSPACE} = \bigcup_{k \geq 1} \mathsf{NSPACE}(n^k) and each \mathsf{NSPACE}(n^k) \subseteq \mathsf{DSPACE}((n^k)^2) = \mathsf{DSPACE}(n^{2k}) \subseteq \mathsf{[PSPACE](/page/PSPACE)}.[16] Combined with the trivial inclusion \mathsf{PSPACE} \subseteq \mathsf{NPSPACE}, this yields \mathsf{[PSPACE](/page/PSPACE)} = \mathsf{NPSPACE}.[17] The space hierarchy theorem further ensures that \mathsf{[PSPACE](/page/PSPACE)} \subsetneq \mathsf{DSPACE}(n^k) for any constant k > 1, preventing a collapse of the polynomial space hierarchy.[18]
In the sublinear regime, setting s(n) = \log n gives \mathsf{NL} = \mathsf{NSPACE}(\log n) \subseteq \mathsf{DSPACE}((\log n)^2), tightening the deterministic simulation of nondeterministic logarithmic space.[16]
A concrete application arises with the quantified Boolean formula problem \mathsf{TQBF}, which is \mathsf{PSPACE}-complete. Savitch's theorem enables a deterministic polynomial-space simulation of the nondeterministic procedure for evaluating \mathsf{TQBF} formulas, confirming that \mathsf{TQBF} \in \mathsf{PSPACE}.[16]
Overall, the theorem demonstrates that nondeterminism provides at most a quadratic space advantage over determinism, preventing \mathsf{NSPACE} classes from significantly exceeding corresponding \mathsf{DSPACE} classes without this blowup.[1] While padding arguments indirectly link space bounds to nondeterministic time classes like \mathsf{NTIME}, the primary impact remains within space complexity.[17]
Connections to Other Results
Savitch's theorem, which establishes that nondeterministic space classes can be simulated deterministically with a quadratic overhead, has profound connections to subsequent results in complexity theory, particularly in refining space hierarchies and addressing nondeterminism's impact on space-bounded computation.
A key complement to Savitch's result is the Immerman–Szelepcsényi theorem, independently proven in 1987–1988, which demonstrates that for space bounds s(n) \geq \log n, nondeterministic space is closed under complementation, i.e., \mathsf{[NSPACE](/page/N-Space)}(s(n)) = \mathsf{co\text{-}[NSPACE](/page/N-Space)}(s(n)).[19] This resolves the question of whether \mathsf{[NL](/page/NL)} = \mathsf{co\text{-}[NL](/page/NL)} without incurring the quadratic space blowup inherent in Savitch's simulation, providing a symmetric treatment of nondeterministic space classes that Savitch's theorem alone could not achieve. As a direct consequence, Savitch's theorem implies \mathsf{[PSPACE](/page/PSPACE)} = \mathsf{NPSPACE}, but Immerman–Szelepcsényi extends this symmetry to co-nondeterministic variants.
Savitch's theorem facilitates refinements in space hierarchy theorems by enabling padding arguments that demonstrate nondeterminism does not cause collapses beyond the quadratic factor. Specifically, these arguments show that space classes like \mathsf{[DSPACE](/page/DSpace)}(s(n)) and \mathsf{[NSPACE](/page/N-Space)}(s(n)) remain separated for suitable s(n), with Savitch ensuring that nondeterministic hierarchies mirror deterministic ones up to the known overhead.[20] For instance, diagonalization techniques combined with padding yield strict separations such as \mathsf{[DSPACE](/page/DSpace)}(s(n)) \subsetneq \mathsf{[DSPACE](/page/DSpace)}(s(n)^2), and Savitch's simulation prevents nondeterminism from closing these gaps further.[21]
In the context of \mathsf{P} versus \mathsf{PSPACE}, Savitch's theorem confirms that \mathsf{PSPACE} \subseteq \mathsf{DSPACE}(\mathsf{poly}(n)), yet the equality \mathsf{P} = \mathsf{PSPACE} remains open, highlighting the theorem's role in bounding but not resolving time-space tradeoffs.[22] This relation extends to circuit complexity, where Savitch-inspired simulations translate nondeterministic space computations into deterministic circuits of depth O(s(n)^2), linking space bounds to circuit size and depth lower bounds.[23]
Modern extensions of Savitch's ideas appear in parallel computation, where simulations inspired by its recursive structure place certain nondeterministic space classes within \mathsf{NC} (Nick's Class) for polylogarithmic depth, aiding the classification of problems solvable efficiently in parallel models.[24] In quantum complexity, analogues of Savitch's theorem have been explored, with quadratic overhead simulations established for bounded-error quantum space classes such as \mathsf{BQSPACE}(s(n)) \subseteq \mathsf{DSPACE}(s(n)^2), though nondeterministic quantum space analogues remain under investigation and recent work suggests they may not hold in the classical form.[25][26] These extensions underscore Savitch's influence on generalized models beyond classical Turing machines.[27]
Despite its power, Savitch's theorem has limitations, notably in derandomization: it does not directly place space-bounded \mathsf{BPP} (bounded-error probabilistic polynomial time, adapted to space) within deterministic polyspace without additional assumptions, contrasting with time hierarchies where nondeterminism collapses more dramatically.[28] For example, while \mathsf{BPL} \subseteq \mathsf{SPACE}(\log^2 n) follows from Savitch, efficient derandomization of space-bounded randomized classes requires separate techniques.[29]
Open questions tied to Savitch's theorem include whether a deterministic simulation of \mathsf{NSPACE}(s(n)) can achieve o(s(n)^2) space, a problem that intertwines with circuit lower bounds, as improved simulations would imply separations in circuit depth for space-bounded computations.[23] Resolving this could bridge gaps between space and circuit complexity, but current barriers suggest connections to longstanding open problems like \mathsf{P} \neq \mathsf{NP}.[30]