Document

Lecture14 Mapping Reducibility,
Complexity
 2005 SDU
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
 2005 SDU
2
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.
 2005 SDU
3
Example
To reduce ATM to HALTTM we assume that HALTTM is
decidable and let TM R decide it. Then we construct the
TM S that decides ATM as follows:
S = “on input <M, w>, an encoding of a TM M and a
string w:
1.
2.
3.
4.
 2004 SDU
Run TM R on input <M, w>.
If R rejects, reject.
If R accepts, simulate M on w until it halts.
If M accepted, accept; if M rejected, reject.”
4
Construction a reduction ATM mHALTTM
We can demonstrate a mapping reduction from
ATM to HALTTM as follows:
Find a computable function f that takes input <M,
w> and return <M’, w’>, where <M, w>  ATM iff
<M’, w’>  HALTTM
 2004 SDU
5
TM F that computes f
F = “On input <M, w>:
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 <M’, w>.”
It is easy to verify that
<M, w>  ATM  <M’, w>  HALTTM
 2004 SDU
6
Another Example
Assuming that EQTM is decided by a TM R, then ETM can be decided
by the machine S:
S = “ On input <M>, where M is a TM:
1. Run R on input <M, M1>, where M1 is the TM that rejects all inputs.
2. If R accepts, accept; if R rejects, reject.”
Sine ETM is un-decidable, R cannot exit.
The mapping reduction f from ETM to EQTM can be
computed by the following TM:
F =“On input <M>, where M is the encoding of a TM:
1. Compute a TM M1 that rejects all input.
2. Output <M, M1>.
”
 2004 SDU
7
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 Mh that compute h as follows:
Mh = “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).”
 2004 SDU
8
Observation
On proving the un-decidability of ETM, we reduce ATM to
ETM by first defining a TM M1 from <M, w>:
M1 = “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, w>) = M1, then f is a mapping
reduction from ATM to ETM
.
Since decidability is not affected by complementation, it
still shows that ETM is un-decidable. But it does not give a
mapping reduction from ATM to ETM, which in fact does not
exist (exercise).
 2004 SDU
9
Conclusion
If A m B and B is Turing-recognizable, then A is Turingrecognizable.
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
 2004 SDU
10
Application
EQTM is neither Turing-recognizable nor co-Turing-Recognizable.
• Proof. First, show that EQTM is not Turing-recognizable.
We can do so by showing that ATM is mapping reducible to EQTM .
Since ATM m EQ
implies that
m EQTM, as required.
A
The reduction f works as follows: TM
F = “On input <M, w>, where M is a TM and w is a string:
1. Construct the two machines M1 and M2:
• M1 = “On any input:
a) Reject.”
• M2=“On any input:
b) Run M on w. If it accepts, accept.”
2. Output <M1, M2>.”
TM
 2004 SDU
11
Observation
• To show that EQ
is not Turing-recognizable, we give a
reduction function g from ATM to the complement of EQTM ,
which is EQTM. Hence, we show that ATM m EQTM. The
TM G that computes this reduction g follows:
TM
•
G = “On input <M, w>, where M is a TM and w is a string:
1. Construct the two machines M1 and M2:
M1 = “On any input:
a) Accept.”
M2= “On any input:
a) Run M on w. If it accepts, accept.”
2. Output <M1, M2>. ”
 2004 SDU
12
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
2005
SDU n.
13
time complexity classes
Let f: NN be a function. Define
TIME (f(n)) = {L | L is decided by an O(f(n)) time multitape Turing machine}.
NTIME(f(n)) = {L| L is decided by an O(f(n)) time nondeterministic Multi-tape Turing machine}.
Note:
 g(n) = O(f (n)), if there exist constant n0 and c such that for all n
 n0, g(n)  cf(n)
 Space complexity classes can be defined similarly.
 2004 SDU
14
Relationship among models
Theorem. For every t(n)  n, each t(n) time
multi-tape Turing machine has an equivalent
O(t2(n)) time single-tape Turing machine.
Theorem. For every t(n)  n, each t(n) time
nondeterministic Turing machine has an
equivalent 2O(t(n)) time single-tape Turing
machine.
 2004 SDU
15
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
P   TIME (n )
k
k 0
NP is the nondeterministic counterpart of P
NP   NTIME (n )
k
k 0
 2004 SDU
16
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) = akxk+ak-1xk-1+…+a1x1+a0x0
for some nonnegative integer k and numbers ak,ak-1,…a1,a0.
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!
 2005 SDU
17
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.
 2005 SDU
18
Complexity of context-free languages
Let K={w | w=wR}
What is the time complexity of (the most efficient TM that decides) K?
Answer: At most f(n)=n2. 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).
 2005 SDU
19