Complexity Theory
Total Page:16
File Type:pdf, Size:1020Kb
Mapping Reductions Part II -and- Complexity Theory Announcements ● Casual CS Dinner for Women Studying Computer Science is tomorrow night: Thursday, March 7 at 6PM in Gates 219! ● RSVP through the email link sent out earlier this week. Announcements ● Problem Set 7 due tomorrow at 12:50PM with a late day. ● This is a hard deadline – no submissions will be accepted after 12:50PM so that we can release solutions early. Recap from Last Time Mapping Reductions ● A function f : Σ1* → Σ2* is called a mapping reduction from A to B iff ● For any w ∈ Σ1*, w ∈ A iff f(w) ∈ B. ● f is a computable function. ● Intuitively, a mapping reduction from A to B says that a computer can transform any instance of A into an instance of B such that the answer to B is the answer to A. Why Mapping Reducibility Matters ● Theorem: If B ∈ R and A ≤M B, then A ∈ R. ● Theorem: If B ∈ RE and A ≤M B, then A ∈ RE. ● Theorem: If B ∈ co-RE and A ≤M B, then A ∈ co-RE. ● Intuitively: A ≤M B means “A is not harder than B.” Why Mapping Reducibility Matters ● Theorem: If A ∉ R and A ≤M B, then B ∉ R. ● Theorem: If A ∉ RE and A ≤M B, then B ∉ RE. ● Theorem: If A ∉ co-RE and A ≤M B, then B ∉ co-RE. ● Intuitively: A ≤M B means “B is at at least as hard as A.” Why Mapping Reducibility Matters IfIf thisthis oneone isis “easy”“easy” ((RR,, RERE,, co-co-RERE)…)… A ≤M B …… thenthen thisthis oneone isis “easy”“easy” ((RR,, RERE,, co-co-RERE)) too.too. Why Mapping Reducibility Matters IfIf thisthis oneone isis “hard”“hard” (not(not RR,, notnot RERE,, oror notnot coco-RE-RE))…… A ≤M B …… thenthen thisthis oneone isis “hard”“hard” (not(not RR,, notnot RERE,, oror notnot coco-RE-RE)) too.too. The Limits of Computability co-RE R RE LD LD ADD HALT ATM HALT ATM ONES SEARCH ONES Le Le What's out here? An Extremely Hard Problem ● Recall: All regular languages are also RE. ● This means that some TMs accept regular languages and some TMs do not. ● Let REGULARTM be the language of all TM descriptions that accept regular languages: REGULARTM = { ⟨M⟩ | ℒ(M) is regular } REGULARTM ∉ RE ● It turns out that REGULARTM is unrecognizable, meaning that there is no computer program that can confirm that another TM's language is regular! ● To do this, we'll do a reduction from LD and prove that LD ≤M REGULARTM. LD ≤M REGULARTM ● We want to find a computable function f such that ⟨M⟩ ∈ LD iff f(⟨M⟩) ∈ REGULARTM. ● We need to choose N such that f(⟨M⟩) = ⟨N⟩ for some TM N. Then ⟨M⟩ ∈ LD iff f(⟨M⟩) ∈ REGULARTM ⟨M⟩ ∈ LD iff ⟨N⟩ ∈ REGULARTM ⟨M⟩ ∉ ℒ(M) iff ℒ(N) is regular. ● Question: How do we pick N? LD ≤M REGULARTM ● We want to construct some N out of M such that ● If ⟨M⟩ ∈ ℒ(M), then ℒ(N) is not regular. ● If ⟨M⟩ ∉ ℒ(M), then ℒ(N) is regular. ● One option: choose two languages, one regular and one nonregular, then construct N so its language switches from regular to nonregular based on whether ⟨M⟩ ∉ ℒ(M). ● If ⟨M⟩ ∈ ℒ(M), then ℒ(N) = { 0n1n | n ∈ ℕ } ● If ⟨M⟩ ∉ ℒ(M), then ℒ(N) = Ø The Reduction ● We want to build N from M such that ● If ⟨M⟩ ∈ ℒ(M), then ℒ(N) = { 0n1n | n ∈ ℕ } ● If ⟨M⟩ ∉ ℒ(M), then ℒ(N) = Ø ● Here is one way to do this: N = “On input w: · If w does not have the form 0n1n, then N rejects w. · Run M on ⟨M⟩. · If M accepts ⟨M⟩, then N accepts w. · If M rejects ⟨M⟩, then N rejects w.” Graphically { 0n1n | n ∈ ℕ } Σ* N = “On input w: N = “On input w: n n · ·If If w w does does not not have have the the form form 0 01n1,n, then N rejects w. then N rejects w. · Run M on ⟨M⟩. · Run M on ⟨M⟩. · If M accepts ⟨M⟩, then N accepts w. · If M accepts ⟨M⟩, then N accepts w. · If M rejects ⟨M⟩, then N rejects w.” · If M rejects ⟨M⟩, then N rejects w.” Theorem: LD ≤M REGULARTM. Proof: We exhibit a mapping reduction from LD to REGULARTM. For any TM M, let f(⟨M⟩) = ⟨N⟩, where N is defined in terms of M as follows: N = “On input w: If w does not have the form 0n1n, N rejects w. Run M on ⟨M⟩. If M accepts ⟨M⟩, N accepts w. If M rejects ⟨M⟩, N rejects w.” We claim f is computable and omit the details from this proof. We further claim that ⟨M⟩ ∈ LD iff f(⟨M⟩) ∈ REGULARTM. To see this, note that f(⟨M⟩) = ⟨N⟩ ∈ REGULARTM iff ℒ(N) is regular. We claim that ℒ(N) is regular iff ⟨M⟩ ∉ ℒ(M). To see this, note that if ⟨M⟩ ∉ ℒ(M), then N never accepts any strings. Thus ℒ(N) = Ø, which is regular. Otherwise, if ⟨M⟩ ∈ ℒ(M), then N accepts all strings of the form 0n1n, so we have that ℒ(M) = { 0n1n | n ∈ ℕ }, which is not regular. Finally, ⟨M⟩ ∉ ℒ(⟨M⟩) iff ⟨M⟩ ∈ LD. Thus ⟨M⟩ ∈ LD iff f(⟨M⟩) ∈ REGULARTM, so f is a mapping reduction from LD to REGULARTM. Therefore, LD ≤M REGULARTM. ■ REGULARTM ∉ co-RE ● Not only is REGULARTM ∉ RE, but REGULARTM ∉ co-RE. ● Before proving this, take a minute to think about just how ridiculously hard this problem is. ● No computer can confirm that an arbitrary TM has a regular language. ● No computer can confirm that an arbitrary TM has a nonregular language. ● This is vastly beyond the limits of what computers could ever hope to solve. LD ≤M REGULARTM ● To prove that REGULARTM is not co-RE, we will prove that LD ≤M REGULARTM. ● Since LD is not co-RE, this proves that REGULARTM is not co-RE either. ● Goal: Find a function f such that ⟨M⟩ ∈ LD iff f(⟨M⟩) ∈ REGULARTM ● Let f(⟨M⟩) = ⟨N⟩ for some TM N. Then we want ⟨M⟩ ∈ LD iff ⟨N⟩ ∈ REGULARTM ⟨M⟩ ∈ ℒ(M) iff ℒ(N) is regular ● Question: How do we pick machine N? LD ≤M REGULARTM ● We want to construct some N out of M such that ● If ⟨M⟩ ∈ ℒ(M), then ℒ(N) is regular. ● If ⟨M⟩ ∉ ℒ(M), then ℒ(N) is not regular. ● One option: choose two languages, one regular and one nonregular, then construct N so its language switches from regular to nonregular based on whether ⟨M⟩ ∈ ℒ(M). ● If ⟨M⟩ ∈ ℒ(M), then ℒ(N) = Σ*. ● If ⟨M⟩ ∉ ℒ(M), then ℒ(N) = {0n1n | n ∈ ℕ} LD ≤M REGULARTM ● We want to build N from M such that ● If ⟨M⟩ ∈ ℒ(M), then ℒ(N) = Σ* ● If ⟨M⟩ ∉ ℒ(M), then ℒ(N) = { 0n1n | n ∈ ℕ } ● Here is one way to do this: N = “On input w: · If w has the form 0n1n, then N accepts w. · Run M on ⟨M⟩. · If M accepts ⟨M⟩, then N accepts w. · If M rejects ⟨M⟩, then N rejects w.” Graphically { 0n1n | n ∈ ℕ } Σ* N = “On input w: N = “On input w: n n · ·If If w w has has the the form form 0 01n1,n, then N accepts w. then N accepts w. · Run M on ⟨M⟩. · Run M on ⟨M⟩. · If M accepts ⟨M⟩, then N accepts w. · If M accepts ⟨M⟩, then N accepts w. · If M rejects ⟨M⟩, then N rejects w.” · If M rejects ⟨M⟩, then N rejects w.” Theorem: LD ≤M REGULARTM. Proof: We exhibit a mapping reduction from LD to REGULARTM. For any TM M, let f(⟨M⟩) = ⟨N⟩, where N is defined from M as follows: N = “On input w: If w has the form 0n1n, then N accepts w. Run M on ⟨M⟩. If M accepts ⟨M⟩, then N accepts w. If M rejects ⟨M⟩, then N rejects w.” We state without proof that f is computable. We further claim that ⟨M⟩ ∈ LD iff f(⟨M⟩) ∈ REGULARTM. Note f(⟨M⟩) = ⟨N⟩ and ⟨N⟩ ∈ REGULARTM iff ℒ(N) is regular. We claim that ℒ(N) is regular iff ⟨M⟩ ∈ ℒ(M). To see this, note that if ⟨M⟩ ∈ ℒ(M), then N accepts all strings, either because that string is of the form 0n1n or because M eventually accepts ⟨M⟩. Thus ℒ(N) = Σ*, which is regular. Otherwise, if ⟨M⟩ ∉ ℒ(M), then N only accepts strings of the form 0n1n, so ℒ(N) = { 0n1n | n ∈ ℕ }, which is not regular. Finally, ⟨M⟩ ∈ ℒ(⟨M⟩) iff ⟨M⟩ ∈ LD. Thus ⟨M⟩ ∈ LD iff f(⟨M⟩) ∈ REGULARTM, so f is a mapping reduction from LD to REGULARTM. Therefore, LD ≤M REGULARTM. ■ The Limits of Computability REGULARTM REGULARTM HALT HALT R ONESTM ONESTM LD ADD LD ONLYONES ONLYONES TM SEARCH TM ATM ATM co-RE RE All Languages Why All This Matters The Limits of Computability REGULARTM REGULARTM HALT HALT R ONESTM ONESTM LD ADD LD ONLYONES ONLYONES TM SEARCH TM ATM ATM co-RE RE All Languages What problems can be solved by a computer? What problems can be solved efficiently by a computer? Where We've Been ● The class R represents problems that can be solved by a computer. ● The class RE represents problems where “yes” answers can be verified by a computer. ● The class co-RE represents problems where “no” answers can be verified by a computer. ● The mapping reduction can be used to find connections between problems. Where We're Going ● The class P represents problems that can be solved efficiently by a computer.