1.43k likes | 1.45k Views
Lecture 6: Computational Complexity. 虞台文. 大同大學資工所 智慧型多媒體研究室. Content. Time-Bounded Turing Machine Rate of Growth Functions Time-Bound Simulations P and NP NP –Completeness Bounded Halting Problems Some Important NP -Complete Problems. Lecture 6: Computational Complexity.
E N D
Lecture 6: Computational Complexity 虞台文 大同大學資工所 智慧型多媒體研究室
Content • Time-Bounded Turing Machine • Rate of Growth Functions • Time-Bound Simulations • P and NP • NP –Completeness • Bounded Halting Problems • Some Important NP-Complete Problems
Lecture 6: Computational Complexity Time-Bounded Turing Machine 大同大學資工所 智慧型多媒體研究室
Not Solvable Solvable Computational Effectiveness for Solvable Problems Can such a problem, e.g., TSP, be solved in any practical sense?
├ ├ ├ ├ ├ Yields in t Steps iff iff such that and
Let T: N N be a function. Let L be a language, and let be a k-tape TM with 0 . We say that MdecidesL in time T if the following holds: ├ for some t T(|w|); ├ for some t T(|w|); Time-Bounded TM • w L • w L
TIME(T) We say that L is decidable in time T if there is some k-tape TM (k > 0) that decidesL in time T. The class of all languagesdecidable in time T is denoted by
Head # w # Head # Y/N # >L # >L # # # RYR RNR Absolute Time Bound (2n + 4) n • |w|+1 writing steps • |w|+3 head-moving steps erase w(write ‘#’) write ‘Y’ or ‘N’
Lecture 6: Computational Complexity Rate of Growth Functions 大同大學資工所 智慧型多媒體研究室
Time-Bound Notations • Upper Bound • Lower Bound • Exact Bound
Fact: Time-Bound Notations • Upper Bound • Lower Bound • Exact Bound
For a, we need to prove and . Lemma Pf) c Therefore, we have to find c(exercise) such that
Lemma Pf) Since f = O(nd), we only need to show that nd= O(nd+1), which is trivially satisfied because nd nd+1 for all n 0. Suppose that nd+1 = O(nd), Then, nnd = nd+1 cnd for n n0. But for any c, when n > c, nd+1 cnd.
Theorem Pf) Because f = O(nd), we only need to prove that nd = O(rn), i.e., k terms
Theorem Pf) Because f = O(nd), we only need to prove that nd = O(rn), i.e., Hence, nd = O(rn). Let
Lecture 6: Computational Complexity Time-Bound Simulations 大同大學資工所 智慧型多媒體研究室
Not Solvable Solvable Time-Complexities on TMs The complexities to solve problems on different TMs are different.
Theorem 1 where
Theorem 2 where
Conclusions • A polynomial algorithm of any TM can be simulated using some polynomial algorithms of other TM’s. • In the following, we consider two classes of problems: • Polynomial algorithms (P) • Exponential algorithms (NP) ?
Lecture 6: Computational Complexity P and NP 大同大學資工所 智慧型多媒體研究室
Definition (P ) That is, Pdenotes the class of all languages that are decided by TM’s in some polynomial time bounds.
Does have solution in 0 and 1? 0-1 Example: (Integer Programming) Matrix formulation: Given A and b, is there any binary vector x such that
No answer! Given A and b, is there any binary vector x such that Example: (Integer Programming) A b x Encode: Language
No answer! Given A and b, is there any binary vector x such that Example: (Integer Programming) Language Language Yes, it is. Fact:
For all , ├ Definition MacceptsL in nondeterministic timeT if the following holds for some u, v*, , and t T(|w|). We say that L is acceptable in nondeterministic timeT if there is an NTM that acceptsL in nondeterministic time T.
What is the difference between TIME(T) and NTIME(T)? Definition The class of languages acceptable in nondeterministic time T.
Definition (NP ) That is, NPdenotes the class of all languages that are accepted by NTM’s in some nondeterministic polynomial time bounds.
├ Definition (Step Counting Function) f : NN is a step-counting function if a k-tape Turing machine M such that for all w*, M halts in exactly f(|w|) steps on input w, i.e., for some u1, …, uk, v1, …, vk * and a1, …, ak.
Exercise Given d >0, there exists a polynomial p of degree dbeing a step counting function.
See text for the proof. Theorem 3 Let L be a language accepted in time T1 by a NTM M1=(K1, 1, 1, s1) whereT1 is a step counting function. A k2-tape DTM M2=(K2, 2, 2, s2) decides L in time T2 where
Polynomial Balanced Languages Let L *$*be a language, where $. Then, L is said to be polynomial balanced if there exists a polynomial p such that
Theorem 4 Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a polynomial balanced language.
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. M: >$(1) M’: M’’: . . . >RNR >RNR M’’ Theorem 4 Pf) “” L’ is a p.b.l. Polynomial p s.t. x$yL’ only if |y| p(|x|). • k–tape DTM M’ that decides L’ in time q (a polynomial). L’P To prove L NP, we construct an NTM M based on M’ to accept L as follows:
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. M: >$(1) M’: M’’: . . . >RNR >RNR M’’ Theorem 4 M can be accept L in nondeterministic time p + q. Hence, L NP. Pf) “” L’ is a p.b.l. Polynomial p s.t. x$yL’ only if |y| p(|x|). • k–tape DTM M’ that decides L’ in time q (a polynomial). L’P To prove L NP, we construct an NTM M based on M’ to accept L as follows:
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. Theorem 4 Pf) “” We shall show that L’ = {x$Y(x) : x L, |Y(x)| p(|x|)}, where p is a polynomial, such that L’P, i.e., a DTMM’can decidesL’ in polynomial time. Y(x)=? M’ =?
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. . . . ├M ├M ├M Theorem 4 Pf) “” Since LNP, an NTM M that accept L in nondeterministic time q (a polynomial). Let be the encoding function that encodes TM’s and their memory configurations in {I, c}*. That is, given xL, we have such that Let Y(x)be the set of all strings where M is the NTM that accepts L.
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. Theorem 4 Pf) “” q(|x|) to be discussed constant accept in time q input length
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. Theorem 4 Pf) “” q(|x|)
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. Theorem 4 Pf) “” Polynomial of |x|
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. Theorem 4 Pf) “” Let L’ is polynomial balanced.
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. Theorem 4 Pf) “” ? Let L’ is polynomial balanced.
Let L * be a language, $ and ||2. L NP iff L’ *$*such that where L’ is a p.b.l. Theorem 4 Pf) “” • We now show that L’P by designing a DTM M’ which decides L’ as follows: • Check the syntax of the input string • To verify the following things: • Is Cj a configuration of M? • C0 = (s, #x#)? • Ct = (h, uv)? • If rejected, print out ‘N’ then halt. This steps requires O(n) time. • Check Cj├M Cj+1, j= 0, …, t1 by consulting (M). If rejected print out ‘N’ and then halt. This steps requires O(n2). • Therefore, L’P.
Example (Integer Programming BNP ) No answer
P NP NP P Show and P NP How to show? Is P = NP ? Trivial (why?) Difficult No answer, now.
2 1 3 5 8 4 7 6 Example (TSPNP ) TSPF Find the shortest tour t.
2 1 3 5 8 4 7 6 t is a bijection E.g., Example (TSPNP ) TSPF Find the shortest tour t. It is not language decision problem. Rather, it is a problem of function evaluation.