=========================================================================== CSC 363 Lecture Summary for Week 8 Winter 2008 =========================================================================== Next week: - Term Test 2: Wed 12 Mar, 6-7pm, BA *1170* Techniques for recognizability (dovetailing), undecidability of A_TM, informal reductions (undecidability of HALT_TM, E_TM, EQ_TM), mapping reductions "<=m" (definition and properties), unrecognizability of REGULAR_TM and ~REGULAR_TM, unrecognizability of EQ_TM and ~EQ_TM, unrecognizability of INF_TM and ~INF_TM, Rice's Theorem. - Lecture 7-9pm in BA1230, as usual, except with Alexandra Goultiaeva. - I will be away at a conference starting Tuesday. Special office hours: Mon 10-12 at my office; Wed 3-5 in *BA4290* with TAs -- in addition to regular TA office hours Tue 6-7 in BA2200. ----------------- Computation model ----------------- From last week: - Every multitape TM that runs in time t(n) >= n has an equivalent single-tape TM that runs in time O((t(n))^2). - Every NTM that runs in time t(n) >= n has an equivalent single-tape TM that runs in time 2^O(t(n)). Other variants: minor modifications of basic model or ones above don't affect time complexity significantly (e.g., two-way infinite tape can be simulated using 2 tapes with no loss of efficiency). Consequence: TIME(t(n)) sensitive to particular model. Not as nice as for computability, where model did not affect outcome. Can we do better? "Tractability thesis": All reasonable *deterministic* models are polynomially equivalent (i.e., can simulate one another with at most a polynomial factor loss of efficiency). This includes register machines, lambda calculus, etc. ----------- The class P ----------- Concentrate on "coarse scale": ignore polynomial differences. This allows (almost) model-independent characterization (except for nondeterminism). P = U_k TIME(n^k) = { L : language L can be decided by some deterministic algorithm (TM or otherwise) in worst-case polytime } Importance: - Robust: does not depend on details of model, as long as it is deterministic. - Useful: captures rough notion of efficiency. Conventions: - Describe computation in stages, where each stage is "obviously" computable in polytime (with justification) and at most polynomially many stages are executed, on any input. - Encodings: "reasonable" now means "can be encoded/decoded in polytime". In particular, numbers must be represented in some base >= 2 (unary notation requires k symbols to represent integer k, exponentially worse than the log_b(k) symbols required in base b). Examples: Almost all algorithms you've seen in other courses. - PATH = { : graph G contains a path between nodes u, v } Trying all possible paths requires worst-case exponential time. However, DFS (depth-first search) or BFS (breadth-first search) solve problem in polytime. ------------ The class NP ------------ We've seen that nondeterminism is not "practical". Why use it, then? Turns out a large number of real-life problems have no known efficient solution (i.e., are not known to belong to P), yet can be solved efficiently using nondeterminism. So nondeterminism allows us to characterize a large class of problems. Also, nondeterminism is an elegant way to add (what seems to be) significant power to the model. Nondeterminism vs. Verifiers: - Recall acceptance condition for NTMs: there exists an accepting computation path in computation tree. - Verifiers capture that notion directly: verifier for language L = algorithm V that takes input such that x (- L iff V accepts for some c. Runtime measured as a function of n=|x| only (ignoring c). - Every polytime verifier can be simulated by polytime NTM (use non-determinism to check all possible values of certificate c), and every polytime NTM can be simulated by polytime verifier (use certificate to select computation path to take), so both models are equivalent. NTIME(t(n)) = { L : L is a language decided by a NTM in worst-case time O(t(n)) } NP = U_k NTIME(n^k) = { L : L is decided by some polytime NTM } = { L : L has a polytime verifier } By tractability thesis, NP independent of specific details of nondeterministic model (as long as it's nondeterministic). Examples of languages in NP: - COMPOSITES = { x : x is a composite number } COMPOSITES (- P? Unclear (checking all possible factors not polytime because this could require checking up to sqrt{x} possibilities; as a function of n = |x| = log_2 x (in binary), this represents sqrt{x} = sqrt{2^n} = 2^{n/2} possibilities: exponential). COMPOSITES (- NP? Yes: On input : 1. Check that 1 < c < x. 2. Check that c divides x evenly. Accept if all checks succeed; reject if any fail. If x is composite, then the verifier will accept when c is a factor of x. If x is prime, then the verifier will reject for all values of c. Moreover, the verifier runs in polytime: comparing integers (1 < c < x) can be done in linear time; dividing integers can be done in quadratic time (remember we measure time as a function of input size = number of bits to write inputs). - HAMPATH = { : G is an undirected graph that contains a Hamiltonian path, i.e., a simple path that includes every vertex exactly once } HAMPATH (- P? Unknown (checking all possible paths not polytime; no obvious shortcut). HAMPATH (- NP? Yes: On input : 1. Check c encodes a list of vertices (v_1,v_2,...,v_n). 2. Check c contains every vertex of G exactly once, i.e., V = {v_1,v_2,...,v_n}. 3. Check G contains every edge between successive vertices in c: (v_1,v_2) (- E, (v_2,v_3) (- E, ..., (v_{n-1},v_n) (- E. Accept if all checks succeed; reject if any fail. By definition of the language, if (- HAMPATH, then verifier accepts for some value of c (a Hamiltonian path in G); if G not in HAMPATH, then verifier rejects for all values of c. Moreover, verifier runs in polytime: if G contains n vertices and m edges, runtime is at most O(n^2 m).