=========================================================================== CSC 363 Lecture Summary for Week 11 Fall 2009 =========================================================================== Self-reducibility for optimization problems: - Some search problems with one or more numerical parameters naturally occur in practice in the form of optimization problems, e.g., . MAX-CLIQUE . MIN-VERTEX-COVER . etc. As in the case of vertex cover above, optimization problem can also be self-reducible by using decision problem algorithm to find optimal value of relevant parameter(s). Example: MAX-CLIQUE Idea: Given G, perform binary search in range [1,n] by making calls to CL(G,k) for various values of k, in order to find maximum value k such that G contains a k-clique but no (k+1)-clique. Then, use search algorithm to find k-clique. (Note: Linear search for value of k would also be OK in this case, because search is in the range [1,n] and input size = n.) Similar idea would work for MIN-VERTEX-COVER, etc. ---------------- Space Complexity ---------------- SPACE(s(n)) = { L : L is a language that can be decided by a TM running in worst-case space O(s(n)), i.e., the TM never uses more than O(s(n)) tape cells on any input } NSPACE(s(n)) = { L : L is a language that can be decided by a NTM running in worst-case space O(s(n)), i.e., the NTM never uses more than O(s(n)) tape cells on any input } Fact: If language L is recognized by a TM M running in space O(s(n)), then L is decidable (no matter what s(n) is equal to). Proof: Main idea: The only way that M can loop is by repeating a configuration exactly (because it is limited in how many cells it can use). We can simulate M until it stops or repeats a configuration, thereby deciding L(M). Details: Since M uses <= c*s(n) tape cells on any input, there are at most m^{c*s(n)} possible tape contents that M can enter during its computation (where m = number of symbols in tape alphabet) -- m symbols per cell for c*s(n) cells. For each possible tape content, there are c*s(n) positions that M's head can be in, and k = |Q| different states that M can be in. So M can run through at most k*c*s(n)*m^{c*s(n)} many different configurations before it enters some configuration twice (meaning M is in an infinite loop). Since k, c, m are constants with respect to the input size, this means it is possible to decide L(M) by simulating M and rejecting if M ever runs for more than k*c*s(n)*m^{c*s(n)} = 2^{O(s(n))} steps. This more detailed argument shows SPACE(s(n)) (_ TIME(2^O(s(n)))! Unlike time, space much less affected by details of model (e.g., using k tapes saves time but not space -- information must still be stored). Surprising result: SAT (- SPACE(n) -- keep track of original formula, truth-value assignment to its variables, and simplified formula, all in linear space; simply evaluate formula on each possible truth-value assignment one by one, reusing space. Important point: possible to generate one assignment from the previous one in linear space, so no need to store them all at once. So space seems more "powerful" than time. Intuition: space can be reused; time cannot. Surprising result (Savitch's Theorem): NSPACE(s(n)) subset of SPACE((s(n))^2). Proof idea: NTM running in space O(s(n)) runs in nondeterministic time 2^O(s(n)). Trying out all computation branches takes too much space (if time is 2^O(s(n)), there are as many as 2^O(2^O(s(n))) possible computation paths to try). Instead, use algorithm to test whether NTM can get from initial configuration to accepting configuration by recursively breaking up computation in two halves -- doing this properly (see textbook) gets space usage down to O((s(n))^2): O(s(n)) for storing configurations, and log(2^O(s(n))) = O(s(n)) for recursion depth. --------- Polyspace --------- PSPACE = U_{k >= 0} SPACE(n^k) = { all languages decided in polyspace } By Savitch's Theorem, NPSPACE = PSPACE. Clearly, P (_ PSPACE and NP (_ NPSPACE, so P (_ NP (_ NPSPACE = PSPACE. What about coNP? coNP (_ coNPSPACE = coPSPACE = PSPACE (deterministic polyspace decider for L yields deterministic polyspace decider for ~L by simply swapping accept/reject). Even more so than with NP, it seems "clear" that P != PSPACE (think of linear-space algorithm for SAT). However, question still open! More on this next week... Examples of languages in PSPACE, likely not in P (evidence later): - Quantified boolean formula = propositional formula with quantifiers on propositional variables, e.g., \-/ p, -] q, ( ((p \/ q) -> r) /\ (~p -> (q /\ r)) ). Fully quantified boolean formula = all variables quantified and all quantifiers at the front ("prenex normal form"), e.g., formula above with "-] r" or "\-/ r" added in front. Fully quantified boolean formulas are always either true or false. Note: asking "is propositional formula F satisfiable" same as asking "is -] p_1 -] p_2 ... -] p_k F true" (where p_1,p_2,...,p_k are all variables of F). TQBF = { : F is a true fully quantified boolean formula } TQBF (- PSPACE: On input : - If F has no quantifiers, then evaluate F and accept iff it is true. - If F = -] x F', then recursively evaluate F'[x=0] and F'[x=1] and accept iff either computation accepts. - If F = \-/ x F', then recursively evaluate F'[x=0] and F'[x=1] and accept iff both computations accept. Clearly, algorithm accepts iff F is true. Entire recursion tree covers exponentially many possible settings of variables, but tree is traversed in depth-first manner, so only need to store information for one path. Recursion depth = number of variables of F and each level stores value of one variable: total space used for recursion is linear. Evaluating F at bottom of each path also requires linear space, but this can be shared between calls. - Many types of two-player games for which we can ask: given a certain game configuration, does player 1 have a guaranteed win? For example, "Generalized Geography": on directed graph G with selected start node, players take turns moving along edges, without ever going back to previously visited nodes. Last player to move wins. GG = { : G is a directed graph, b is a node in G, and player I has a winning strategy playing generalized geography from start node b, i.e., there are moves for player I to win no matter how player II moves } GG (- PSPACE: On input : - Reject if no outgoing edge from b. - Otherwise, remove b and all its edges to get G_1; let b_1, ..., b_k be endpoints of edges from b. - Recursively run on inputs , ..., ; reject if all accept (player II wins); accept if one rejects. Clearly, this accepts iff playing b is guaranteed win in G. Recursion depth = number of nodes in G (linear). Information stored at each call = nodes b, b_1,...,b_k, graph G_1 (linear). Total space required is O(n^2). (Possible to do better by storing only nodes visited so far: constant information at each level, so total linear.) --------- Log-space --------- - L = SPACE(log n) = { languages decided by TM in space O(log n) } NL = NSPACE(log n) = { languages decided by NTM in space O(log n) } coNL = { complements of languages in NL } - Q: How can TM use less than linear space when it needs at least that much to store input? A: Measure "work" space independently of space to store input: use 2-tape TM with read-only "input tape" and read-write "work tape", and count only cells used on work tape. (Similar to working with data on read-only medium when main memory much smaller.) - Note: Sublinear time not useful (can't even read entire input) but sublinear space useful (as we'll see). - Example 1: { 0^k 1^k : k >= 0 } . Can't just scan back-and-forth marking 0s and 1s because input tape is read-only and marking would require copying to work tape, using more than log n space. . Idea: count instead! Read over 0s and use work tape to record number of 0s read as a binary counter; when we start reading 1s, decrease counter; accept iff no 0 is encountered following a 1 and counter = 0 when we reach end of input and not before. . Space usage: counting up to k requires O(log_2 k) bits, so space is logarithmic. - Think of L as languages that can be recognized by using a fixed number of counters/pointers (counters can be used to keep track of positions into the input string).