* Space Complexity * Basic inclusion results * Savitch's Theorem SPACE COMPLEXITY For defining space, we work with a 2-tape TM with the first tape being a read-only tape containing the input string, and the second tape being the worktape. We say that a nondeterministic TM runs in space S(n) if for all inputs of length n, no computation path uses more than S(n) worktape cells. SPACE(S(n)) = {L | L is a language decided by an O(S(n)) space deterministic TM} NSPACE(S(n)) = {L | L is a language decided by an O(S(n)) space nondeterministic TM} Example: SAT is in SPACE(n) PSPACE = U_k SPACE(n^k) NPSPACE = U_k NSPACE(n^k) L = U_k SPACE(log(n)) NL = U_k NSPACE(log(n)) BASIC INCLUSION RESULTS Theorem: TIME(S(n)) is subset of SPACE(S(n)) Theorem: NTIME(S(n)) is subset of NSPACE(S(n)) Theorem: If S(n) >= log(n), SPACE(S(n)) is subset of TIME(2^{O(S(n))}) and NSPACE(S(n)) is subset of NTIME(2^{O(S(n))}). Proof: Define a configuration to consist of the TM state, position on the input tape and the worktape, and the contents of the worktape. The number of different configurations is at most q*n*S(n)*d^{S(n)} = 2^{O(S(n))}, if S(n) >= log(n). Consider any computation path that goes through the same configuration twice. If it does, then there is a shorter computation path that has the same effect. We have the simulating TM maintain a clock, and the TM stops and rejects as soon the clock exceeds 2^{O(S(n))}. End Proof Theorem: NTIME(T(n)) is a subset of SPACE(T(n)) and NSPACE(S(n)) is subset of TIME(2^{O(S(n))}) for S(n) >= log(n). Proof: For the first part, we simulate a T(n) time NDTM N with a T(n) space DTM M. We can consider the computation tree of N. Each branch is T(n) length long. We will simulate all possible branches. Each branch number can be written in O(T(n)) space. Just lexicographically trying out all branches will yield the desired simulation in O(T(n)) space. For the second part, we simulate a NTM N of space S(n) by a deterministic TM M of time 2^{O(S(n))}. First we assume that S(n) is known or can be computed in space O(S(n)). The number of different configurations of N is 2^{O(S(n))}, following the proof of the above theorem. The TM M writes down all configurations one by one, and does a reachability calculation. It does a breadth-first search through the configuration space. It can complete this in 2^{O(S(n))} since BFS of an m-node graph can be accomplished in O(m) time and O(m) space. We need to remove the assumption about the knowledge/computability of S(n). The TM M tries the above for S(n) = 1, 2, .... When working with S(n) = S, if we find a configuration that wants to move to a configuration with space S+1, then we increase S(n) to S+1 and repeat. Otherwise, we have reached a point S such that the TM N does not use space more than S. This is indeed S(n), and we can complete the proof as in the above para. End Proof SAVITCH'S THEOREM Theorem: For S(n) >= log(n), NSPACE(S(n)) is a subset of SPACE(S(n)^2). Proof: We will again use the concept of configurations as defined in the above proofs. We can assume that the NSPACE(S(n)) machine runs in 2^{O(S(n))} time. We have 2^{O(S(n))} configurations. So essentially we have to develop a DTM that in small space determines whether a given node (start configuration) reaches another node (accept configuration) in a graph of 2^{O(S(n))} nodes in 2^{O(S(n))} steps. The degree of each node is constant and the space needed to write a node is S(n). One approach is to try all paths. This would take 2^{O(S(n))}} space, since the number of paths is doubly exponential. The other clever approach is using recursion. We solve the following general problem: given start config X, an end config Y, and an integer t, is Y reachable from X in t steps? We solve this by recursion. We try all possible Z, (X -> Z in t/2 steps and Z -> Y in t/2 steps). If for any Z, this is true, we return yes. Space requirement for this recursion is O(S(n)) for each recursion level. Since the number of recursion levels is O(S(n)), the total space needed is O(S(n)^2). The above proof implicitly assumes that S(n) is known. If not, we apply the same idea as in the proof of the previous theorem. End Proof