Presentation is loading. Please wait.

Presentation is loading. Please wait.

 2005 SDU Lecture14 Mapping Reducibility, Complexity.

Similar presentations


Presentation on theme: " 2005 SDU Lecture14 Mapping Reducibility, Complexity."— Presentation transcript:

1

2  2005 SDU Lecture14 Mapping Reducibility, Complexity

3  2005 SDU 2 Mapping reducibility A function f:  *   * is computable if some TM M exists which on every input w halts with f(w) on the tape. Definition: Language A is mapping reducible to language B, A  m B, if there is a computable function, f, such that for every w, w  A  f(w)  B, where f is called a reduction of A to B. ** A ** B f f

4  2005 SDU 3 Conclusion If A  m B and B is decidable, then A is decidable. Proof. Let M be a decider for B and f:  *   *be the reduction function from A to B. The TM N that decides A is: N = “On input w: 1. Compute f(w). 2. Run M on input f(w) and output whatever M outputs.” Corollary: If A  m B and A is un-decidable, then B is un-decidable.

5  2004 SDU 4 Example To reduce A TM to HALT TM we assume that HALT TM is decidable and let TM R decide it. Then we construct the TM S that decides A TM as follows: S = “on input, an encoding of a TM M and a string w: 1.Run TM R on input. 2.If R rejects, reject. 3.If R accepts, simulate M on w until it halts. 4.If M accepted, accept; if M rejected, reject.”

6  2004 SDU 5 Construction a reduction A TM  m HALT TM We can demonstrate a mapping reduction from A TM to HALT TM as follows: Find a computable function f that takes input and return, where  A TM iff  HALT TM

7  2004 SDU 6 TM F that computes f F = “On input : 1.Construct the following machine M’: M’ = “On input x: (a) Run M on x. (b) If M accepts, accept. (c) If M rejects, enter a loop.” 2. Output.” It is easy to verify that  A TM   HALT TM

8  2004 SDU 7 Another Example Assuming that EQ TM is decided by a TM R, then E TM can be decided by the machine S: S = “ On input, where M is a TM: 1.Run R on input, where M 1 is the TM that rejects all inputs. 2.If R accepts, accept; if R rejects, reject.” Sine E TM is un-decidable, R cannot exit. The mapping reduction f from E TM to EQ TM can be computed by the following TM: F =“On input, where M is the encoding of a TM: 1.Compute a TM M 1 that rejects all input. 2.Output. ”

9  2004 SDU 8 Mapping reducibility is transitive Proof: Suppose A  m B and B  m C There are computable functions f and g such that:  x, x  A  f(x)  B and  y, y  B  g(y)  C. Consider the function composition: h = gf. We can build the TM M h that compute h as follows: M h = “On input x: 1. Simulate a TM that computes f on input x and let the result be y=f(x) (such TM exists because f is computable). 2. Simulate a TM that computes g on input y and let the result be z = g(y) (such TM exists because g is computable).”

10  2004 SDU 9 Observation On proving the un-decidability of E TM, we reduce A TM to E TM by first defining a TM M 1 from : M 1 = “On input x: 1. If x  w, reject 2. If x = w, run M on input w and accept if M does.” If we define function f: f( ) = M 1, then f is a mapping reduction from A TM to. Since decidability is not affected by complementation, it still shows that E TM is un-decidable. But it does not give a mapping reduction from A TM to E TM, which in fact does not exist (exercise).

11  2004 SDU 10 Conclusion If A  m B and B is Turing-recognizable, then A is Turing- recognizable. Proof : Assume that B is Turing recognizable, let M be a recognizer of B, f: A  B a mapping reduction from A to B. The TM N that recognizes A is defined by: N=“On input w: 1.Compute f(w) 2.Run M on input f(w) and output whatever M outputs.” Note, Since M is a recognizer for B and f is a mapping reduction from A to B, N is a recognizer for A. Corollary: If A  m B and A is not Turing-recognizable, then B is not Turing-recognizable

12  2004 SDU 11 Application EQ TM is neither Turing-recognizable nor co-Turing-Recognizable. Proof. First, show that EQ TM is not Turing-recognizable. We can do so by showing that A TM is mapping reducible to. Since A TM  m implies that  m EQ TM, as required. The reduction f works as follows: F = “On input, where M is a TM and w is a string: 1.Construct the two machines M 1 and M 2 : M 1 = “On any input: a) Reject.” M 2 =“On any input: b) Run M on w. If it accepts, accept.” 2.Output.”

13  2004 SDU 12 Observation To show that is not Turing-recognizable, we give a reduction function g from A TM to the complement of, which is EQ TM. Hence, we show that A TM  m EQ TM. The TM G that computes this reduction g follows: G = “On input, where M is a TM and w is a string: 1.Construct the two machines M 1 and M 2 : M 1 = “On any input: a)Accept.” M 2 = “On any input: a) Run M on w. If it accepts, accept.” 2.Output. ”

14  2005 SDU 13 Definitions of time and space complexity Let M be a deterministic (multi-tape)TM that halts for every input. The running time or time complexity of M is the function f: N  N, where f(n) is the maximum number of steps that M uses on any input of length n. The running space or space complexity of M is the function f: N  N, where f(n) is the maximum number of distinct tape cells that M scans on any input of length n. If f(n) is the time complexity of M, we say that M runs in time f(n), or that M is an f(n)-time machine. Similarly, if f(n) is the space complexity of M, we say that M runs in space f(n), or that M is an f(n)-space machine. The same definitions apply to nondeterministic Turing machines. In particular, let M be a nondeterministic (multi-tape)TM such that for every input, every branch of computation halts. The time complexity of M is the function f: N  N, where f(n) is the maximum number of steps that M uses on any branch of its computation on any input of length n. The space complexity of M is the function f: N  N, where f(n) is the maximum number of tape cells that M scans on any branch of its computation on any input of length n.

15  2004 SDU 14 time complexity classes Let f: N  N be a function. Define TIME (f(n)) = {L | L is decided by an O(f(n)) time multi- tape Turing machine}. NTIME(f(n)) = {L| L is decided by an O(f(n)) time non- deterministic Multi-tape Turing machine}. Note:  g(n) = O(f (n)), if there exist constant n 0 and c such that for all n  n 0, g(n)  cf(n)  Space complexity classes can be defined similarly.

16  2004 SDU 15 Relationship among models Theorem. For every t(n)  n, each t(n) time multi-tape Turing machine has an equivalent O(t 2 (n)) time single-tape Turing machine. Theorem. For every t(n)  n, each t(n) time nondeterministic Turing machine has an equivalent 2 O(t(n)) time single-tape Turing machine.

17  2004 SDU 16 Complexity class P and NP Alan Cobham[1964], Jack Edmonds[1965], and Michael Rabin[1966] Suggested the “polynomial time” as a broad classification of problems that are solvable in a reasonable amount of time NP is the nondeterministic counterpart of P

18  2005 SDU 17 The classes P, NP, PSPACE and NPSPACE A polynomial function (or simply polynomial) is a function f(x) that can be written as f(x) = a k x k +a k-1 x k-1 +…+a 1 x 1 +a 0 x 0 for some nonnegative integer k and numbers a k,a k-1,…a 1,a 0. P the class of problems (languages ) that can be solved (decided) by a polynomial-time deterministic multi-tape TM NP the class of problems (languages) that can be solved (decided) by a polynomial-time non-deterministic multi-tape TM PSPACE the class of problems (languages) that can be solved (decided) by a polynomial-space deterministic multi-tape TM NPSPACE the class of problems (languages) that can be solved (decided) by a polynomial-space nondeterministic multi-tape TM It is known that P  NP  PSPACE=NPSPACE. However, the question on whether P  NP or even P  PSPACE remains the most challenging unsolved problem!

19  2005 SDU 18 Complexity of regular languages Let A={w | w starts with a 0} What is the time complexity of (the most efficient TM that decides) A? Answer: f(n)=2. I.e., constant time. So that A  P. How about the space complexity? Answer: f(n)=1. I.e., constant space. So that A  PSPACE. Let B={w | w ends with a 0} What is the time complexity of (the most efficient TM that decides) B? Answer: f(n)=n+2. I.e., linear time. So that B  P. How about the space complexity? Answer: f(n)=n+1. I.e., linear space. So that B  PSPACE. Are all the regular languages in P and PSPACE? Answer: Certainly. Their time complexity is at most f(n)=n+2, and space complexity at most f(n)=n+1.

20  2005 SDU 19 Complexity of context-free languages Let K={w | w=w R } What is the time complexity of (the most efficient TM that decides) K? Answer: At most f(n)=n 2. I.e., square time. So that K  P. How about the space complexity? Answer: f(n)=n+1. I.e., linear space. So that K  PSPACE. Generally, it is known that both the time and space complexities of any context-free language are polynomial (P and PSPACE).


Download ppt " 2005 SDU Lecture14 Mapping Reducibility, Complexity."

Similar presentations


Ads by Google