=========================================================================== CSC 363 Lecture Summary for Week 7 Winter 2008 =========================================================================== One last example. INF_TM = { : L(M) contains infinitely many strings } INF_TM is not co-recognizable (i.e., ~INF_TM is unrecognizable): Prove A_TM <=m INF_TM (equivalent to ~A_TM <=m ~INF_TM): Given , construct such that M accepts w iff L(M') is infinite, as follows -- "all-or-nothing" reduction: M' = "On input x: run M on w and do the same (ignoring x)." Clearly, can be computed from . Also, if M accepts w, then L(M') = \Sigma* which is infinite, and if M does not accept w, then L(M') = {} which is finite. INF_TM is unrecognizable: Prove HALT_TM <=m ~INF_TM (equivalent to ~HALT_TM <=m INF_TM): Given , construct such that M halts on w iff L(M') is finite, as follows -- requires new idea: M' = "On input x: 1. Run M on w for up to |x| many steps. 2. If M has halted by then, reject; otherwise, accept." Clearly, can be computed from . Also, if M halts on w, then M' accepts only inputs x such that |x| is no more than the number of steps in the computation of M on w, i.e., L(M') is finite; and if M does not halt on w, then M' accepts every input string, i.e., L(M') is infinite. -------------- Rice's Theorem -------------- If P is a nontrivial property of recognizable languages, then P is undecidable. ("Nontrivial" means there is at least one language that satisfies the property and at least one language that does not; a "property of recognizable languages" means a property of L(M) for TMs M -- the property must depend only on L(M) and on no other aspect of M.) Examples (Rice's theorem applies to all of these languages, so each one is undecidable -- recognizability is open and could go either way): - E_TM = { : L(M) = {} } (depends only on L(M) and is non-trivial: L(M) = {} for some M, and L(M) != {} for others) - REGULAR_TM = { : L(M) is regular } - DECIDABLE_TM = { : L(M) is decidable } - INF_TM = { : L(M) contains infinitely many strings } - { : M accepts 00101 } (because if L(M1) = L(M2), then and are either both in or both out of the language, so this depends only on L(M) and the property is non-trivial) - ... Example languages that do NOT fall under Rice's theorem (so we cannot conclude anything about their decidability/undecidability -- anything is possible): - { : L(M) is recognizable } (trivial: L(M) is recognizable for every TM M, by definition) - { : M has a useless state } (not a property of L(M)) - { : M is a 2-tape TM that writes on its 2nd tape for some input } (not a property of L(M)) - ... --------------- Closing remarks --------------- Check out for many undecidable problems from other domains. ------------------------ Computational Complexity ------------------------ Outline (topics and textbook sections): - BRIEF review of complexity analysis and asymptotic notation, complexity classes TIME(t(n)), robustness (7.1). - The classes P and NP -- definitions and examples (7.2, 7.3). - Polytime reducibility, self-reducibility; NP-completeness (7.4, 7.5). - Space complexity; other complexity classes (8.2, 8.2, 9.1). - Dealing with NP-completeness (10.1, 10.2). ------------------- Complexity analysis ------------------- Motivation: answer question "what is *efficient* computation?" (by analogy with first part of course that considered "what is computation"). First, must agree on how to measure efficiency. Two standard measures: time and space. Easy to define on TM model: time = number of steps in computation = number of transitions executed; space = number of tape cells. Worst-case vs. average-case measures as a function of input size are defined as usual, using asymptotic notation (big-Oh, \Omega, \Theta). Complexity classes TIME(t(n)), SPACE(t(n)), for any function t : N -> R^+: TIME(t(n)) = { L : L is a language decided by some TM that runs in worst-case time O(t(n)) } SPACE(t(n)) = { L : L is a language decided by some TM that runs in worst-case space O(t(n)) } For example, TIME(n^2) contains every language decided by a TM in worst-case time O(n^2). Example: A = { 0^n 1^n | n >= 0 }. Can be decided in time O(n^2) by repeatedly scanning back-and-forth, crossing off a single 0 and 1 during each pass. But possible to do better by repeatedly crossing off half of the 0s and 1s until none are left, rejecting if at any point the number of 0s and 1s are not both even or odd -- this takes time O(n log n) only. This time cannot be improved: possible to show any language decided in time o(n log n) on standard TM is regular! With two tapes, A can be decided in time O(n): go over all of the 0s and copy them to second tape, then when first head starts going over 1s move backwards over 0s on second tape. If the end of the 1s and 0s is reached at the same time, accept; otherwise, reject. So specific model used changes meaning of complexity classes! ----------------- Computation model ----------------- Multitape TM: Every multitape TM that runs in time t(n) >= n has an equivalent single-tape TM that runs in time O((t(n))^2). Convert multitape TM M to single-tape TM S. Each step of M requires two passes over entire tape contents of S. Since M runs in time t(n), each tape of M contains at most O(t(n)) symbols so tape of S also contains at most O(t(n)) symbols (remember number of tapes is constant); hence, each step of M requires time O(t(n)) on S. Entire computation requires time O(t(n)) * O(t(n)) = O((t(n))^2). Non-deterministic TM: Every NTM that runs in time t(n) >= n has an equivalent single-tape TM that runs in time 2^O(t(n)). Convert NTM M to DTM S. If M is a decider, then every branch halts. Since running time is defined as height of computation tree (length of longest computation branch) and M runs in time t(n), there are at most b^{t(n)} leaves in computation tree (where b = maximum branching factor). Performing BFS on this tree requires time O(t(n) * b^{t(n)}) = O(C^{t(n)}) (for some constant C >= b) = 2^O(t(n)).