Reducibility: TM TM NFA NFA DFA
Reducibility: TM TM NFA NFA DFA
Chapter 5
Reducibility
CS 341: Foundations of CS II
Contents
• Reducing One Problem to Another
• Examples of Undecidable Problems
Marvin K. Nakayama • Mapping Reducibility
Computer Science Department
New Jersey Institute of Technology
Newark, NJ 07102
ATM = { M, w | M is a TM and M accepts string w }, ATM = { M, w | M is a TM and M accepts string w },
HALT TM = { M, w | M is a TM and M halts on string w }. HALT TM = { M, w | M is a TM and M halts on string w }.
Basic idea of proof by contradiction is to reduce ATM to HALT TM: • Assume ∃ TM R that decides HALT TM.
• Define TM S to decide ATM using TM R as follows:
• Suppose ∃ TM R that decides HALT TM.
S = “On input M, w ∈ Ω, where M is a TM and w a string:
• How could we use R to construct TM to decide ATM? 1. Run R on input M, w.
• Recall universal TM U recognizes ATM: 2. If R rejects, reject.
3. If R accepts, simulate M on input w until it halts.
U = “On input M, w, where M is a TM and w is a string:
4. If M accepts, accept; otherwise, reject.”
1. Simulate M on input w.
2. If M ever enters its accept state, accept; • TM S always halts and decides ATM
if M ever enters its reject state, reject.” S accepts M, w ∈ ATM, and S rejects M, w ∈ ATM.
• U doesn’t decide ATM since M may loop on w in stage 1. • Thus, deciding ATM is reduced to deciding HALT TM.
• Solution: first run R on M, w to see if it’s safe to run M on w. • But ATM is undecidable, so HALT TM must also be undecidable.
CS 341: Chapter 5 5-9 CS 341: Chapter 5 5-10
Emptiness Problem for TMs is Undecidable Constructing Decider S for ATM From Decider R for ETM
• Does a TM M recognize the empty language? ETM = { M | M is a TM and L(M ) = ∅ }
ETM = { M | M is a TM and L(M ) = ∅ }.
• Bad Idea: When S receives input M, w, it calls R with input M .
• Universe Ω = { M | M is a TM } of all Turing machines. If R accepts, then L(M ) = ∅.
• For a specific encoded TM M ∈ Ω, In particular, M does not accept w , so S rejects input M, w.
if M accepts at least one string, then M ∈ ETM, If R rejects, then L(M ) = ∅, so M accepts at least one string.
if M accepts no strings, then M ∈ ETM. But don’t know if M accepts w , so TM S can’t decide ATM.
recognizes a regular language if and only if M accepts w. S = “On input M, w, where M is a TM and w is a string:
{ 0n 1n | n ≥ 0 }, M
= “On input x:
1. If x ∈ { 0n1n | n ≥ 0 }, accept.
which is nonregular.
2. If x ∈ { 0n1n | n ≥ 0 }, run M on input w
If M accepts w, then M
recognizes language Σ∗, which is regular.
and accept if M accepts w.”
• We construct M
as follows: 2. Run R on input M
.
M
automatically accepts all strings in { 0n 1n | n ≥ 0 }. 3. If R accepts, accept; if R rejects, reject.”
In addition, if M accepts w, then M
accepts all other strings. • M
∈ REG TM ⇐⇒ M, w ∈ ATM,
so S decides ATM, which is impossible.
• Reductions appear in
Theorem 5.13
ALLCFG is undecidable. decidability theory
complexity theory (as we’ll see later in Chapter 7).
Proof Idea: (see Sipser for full proof)
• Approach: Reduce ATM to ALLCFG. • Now we want to formalize the notion of reducibility.
• Construct a CFG G from TM M and input w.
If M does not accept w, then G generates all strings.
If M accepts w, then G generates all strings except the accepting
computation histories for M on w.
• CFG G generates all strings iff TM M does not accept w.
CS 341: Chapter 5 5-25 CS 341: Chapter 5 5-26
Computable Functions Computable Functions
• Suppose we have 2 languages A and B , where One useful class of computable functions transforms one TM into another.
A is defined over alphabet Σ1, so A ⊆ Σ∗1, i.e., universe Ω1 = Σ∗1
B is defined over alphabet Σ2, so B ⊆ Σ∗2, i.e., universe Ω2 = Σ∗2 Example:
• Informally speaking, A is reducible to B if we can use a “black box” for T = “On input w:
B to build an algorithm for A. 1. If w = M , where M is some TM,
• Construct M
, where M
is a TM such that
• Definition: A function L(M
) = L(M ), but
M
never tries to move tape head off LHS of tape.”
f : Σ∗1 → Σ∗2
is a computable function if some TM M , on every input w ∈ Σ∗1, The function T accomplishes this by adding several states to the
halts with just f (w) ∈ Σ∗2 on its tape. description of M .
• All the usual integer computations are computable:
Addition, multiplication, sorting, etc.
Definition: Suppose f
• A is defined over alphabet Σ1, so A ⊆ Σ∗1, i.e., universe Ω1 = Σ∗1 Σ∗1 Σ∗2
• B is defined over alphabet Σ2, so B ⊆ Σ∗2, i.e., universe Ω2 = Σ∗2
f B
Then A is mapping reducible to B , written A
A ≤m B
if there is a computable function
f : Σ∗1 → Σ∗2
such that, for every w ∈ Σ∗1,
w∈A ⇐⇒ f (w) ∈ B. w∈A ⇐⇒ f (w) ∈ B
YES instance for problem A ⇐⇒ YES instance for problem B
The function f is called a reduction of A to B .
(f is also called a many-one reduction.)
CS 341: Chapter 5 5-29 CS 341: Chapter 5 5-30
Example: Mapping Reduction ATM ≤m HALT TM Example: Mapping Reduction ATM ≤m HALT TM
• Recall that
The following TM F computes this function f .
ATM = { M, w | M is a TM that accepts string w },
HALT TM = { M, w | M is a TM that halts on string w }. F = “On input M, w, where M is a TM and w is a string:
• Instance for acceptance problem is M, w.
1. Construct the following TM M
:
• Instance for halting problem is M, w.
• We previously proved that HALT TM is undecidable by showing M
= “On input x:
ATM reduces to HALT TM. 1. Run M on input x.
2. If M accepts, accept.
• To show ATM ≤m HALT TM, need computable function f with
3. If M rejects, enter a loop.”
input M, w, which is an instance for acceptance problem for TMs
output f (M, w) = M
, w
, which is an instance for halting 2. Output M
, w.”
problem for TMs
M, w ∈ ATM ⇐⇒ f (M, w) = M
, w
∈ HALT TM. Note that M, w ∈ ATM ⇐⇒ M
, w ∈ HALT TM.