# www.rose-hulman.edu

MA/CSSE 474 Theory of Computation Reduction Part 3 HALL = { : TM M halts on all inputs} We show that HALL is not in D by reduction from H. H = { : TM M halts on } R (?Oracle) HALL = { : TM M halts on all inputs } R() = 1. Construct the description , where M#(x) operates as follows: 1.1. Erase the tape. 1.2. Run M.

2. Return . If Oracle exists, then C = Oracle(R()) decides H: R can be implemented as a Turing machine. C is correct: M# halts on everything or nothing, depending on whether M halts on . So: H: M halts on , so M# halts on all inputs. Oracle accepts. H: M does not halt on , so M# halts on nothing. Oracle rejects. But no machine to decide H can exist, so neither does Oracle. The Membership Question for TMs We next define a new language: A = { : M accepts w }. Note that A is different from H since it is possible that M halts but does not accept. An alternative definition of A is: A = { : w L(M) }.

A = { : w L(M)} We show that A is not in D by reduction from H. H = { : TM M halts on input string w} R (?Oracle) A = { : w L(M) } R() = 1. Construct the description , where M#(x) operates as follows: 1.1. Erase the tape. 1.2. Write w on the tape. 1.3. Run M on w. 1.4. Accept 2. Return . If Oracle exists, then C = Oracle(R()) decides H:

R can be implemented as a Turing machine. C is correct: M# accepts everything or nothing. So: H: M halts on w, so M# accepts everything. In particular, it accepts w. Oracle accepts. H: M does not halt on w. M# gets stuck in step 1.3 and so accepts nothing. Oracle rejects. But no machine to decide H can exist, so neither does Oracle. A, AANY, and AALL Theorem: A = { : TM M accepts } is not in D. Proof: Analogous to that for H. Theorem: AANY = { : TM M accepts at least one string} is not in D. Proof: Analogous to that for HANY. Theorem: AALL = { : = L(M) = *} is not in D. } is not in D.

Proof: Analogous to that for HALL. EqTMs={: L(Ma)=L(Mb)} M ? Oracle for EqTMs EqTMs={: L(Ma)=L(Mb)} AANY = { : there exists at least one string which TM M accepts} R

(Oracle?) EqTMs = {: L(Ma)=L(Mb)} R() = 1. Construct the description of M#(x): 1.1. Accept. 2. Return . If Oracle exists, then C = Oracle(R()) decides AANY: C is correct: M# accepts everything. So: AANY: L(M) =? L(M#). Oracle ? Oops. AANY: L(M) L(M#). Oracle rejects. EqTMs={: L(Ma)=L(Mb)} AALL =

{ : L(M) = *} is not in D. } R (Oracle) EqTMs = {: L(Ma)=L(Mb)} R() = 1. Construct the description of M#(x): 1.1. Accept. 2. Return . If Oracle exists, then C = Oracle(R()) decides AALL: C is correct: M# accepts everything. So if L(M) = L(M#), M must also accept everything. So: AALL: L(M) = L(M#). Oracle accepts.

AALL: L(M) L(M#). Oracle rejects. But no machine to decide AALL can exist, so neither does Oracle. A Practical Consequence Consider the problem of virus detection. Suppose that a new virus V is discovered and its code is . Is it sufficient for antivirus software to check solely for occurrences of ? Is it possible for it to check for equivalence to V? Sometimes Mapping Reducibility Isnt Right

Recall that a mapping reduction from L1 to L2 is a computable function f where: x*} is not in D. (x L1 f(x) L2). When we use a mapping reduction, we return: Oracle(f(x)) Sometimes we need a more general ability to use Oracle as a subroutine and then to do other computations after it returns. { : M accepts no even length strings} H = {< M, w> : TM M halts on input string w} R (?Oracle) L2 = { : M accepts no even length strings}

R() = 1. Construct the description , where M#(x) operates as follows: 1.1. Erase the tape. 1.2. Write w on the tape. 1.3. Run M on w. 1.4. Accept. 2. Return . If Oracle exists, then C = Oracle(R()) decides H: C is correct: M# ignores its own input. It accepts everything or nothing, depending on whether it makes it to step 1.4. So: H: M halts on w. Oracle: __________ H: M does not halt on w. Oracle : __________ Problem: { : M accepts no even length strings} H = {< M, w> : TM M halts on input string w}

R (?Oracle) L2 = { : M accepts no even length strings} R() = 1. Construct the description , where M#(x) operates as follows: 1.1. Erase the tape. 1.2. Write w on the tape. 1.3. Run M on w. 1.4. Accept. 2. Return . If Oracle exists, then C = Oracle(R()) decides H: R and can be implemented as Turing machines. C is correct: H: M halts on w. M# accepts everything, including some

even length strings. Oracle rejects so C accepts. H: M does not halt on w. M# gets stuck. So it accepts nothing, so no even length strings. Oracle accepts. So C rejects. But no machine to decide H can exist, so neither does Oracle. Are All Questions about TMs Undecidable? Let L = { : TM M contains an even number of states} Let L = { : M halts on w within 3 steps}. Let Lq = { : there is some configuration (p, uav) of M, with p q, that yields a configuration whose state is q }. Is Lq decidable? Is There a Pattern?

Does L contain some particular string w? Does L contain ? Does L contain any strings at all? Does L contain all strings over some alphabet ? A = { : TM M accepts w}. A = { : TM M accepts }. AANY = { :

there exists at least one string that TM M accepts}. AALL = { : TM M accepts all inputs}. Rices Theorem No nontrivial property of the SD languages is decidable. or Any language that can be described as: {: P(L(M)) = True} for any nontrivial property P, is not in D. A nontrivial property is one that is not simply: True for all languages, or False for all languages.

Because of time constraints, we will skip the proof of this theorem. Applying Rices Theorem To use Rices Theorem to show that a language L is not in D we must: Specify property P. Show that the domain of P is the SD languages. Show that P is nontrivial: P is true of at least one language P is false of at least one language Applying Rices Theorem

1. { : L(M) contains only even length strings}. 2. { : L(M) contains an odd number of strings}. 3. { : L(M) contains all strings that start with a}. 4. { : L(M) is infinite}. 5. { : L(M) is regular}. 6. { : M contains an even number of states}. 7. { : M has an odd number of symbols in its tape alphabet}. 8. { : M accepts within 100 steps}. 9. {: M accepts }. 10. { : L(Ma) = L(Mb)}. Given a TM M, is L(M) Regular? The problem: Is L(M) regular? As a language: Is { : L(M) is regular} in D?

No, by Rices Theorem: P = True if L is regular and False otherwise. The domain of P is the set of SD languages since it is the set of languages accepted by some TM. P is nontrivial: We can also show it P(a*} is not in D. ) = True. directly, using reduction. P(AnBn) = False. (Next slide) Given a TM encoding , is L(M) Regular? H = { : TM M halts on input string w} R (Oracle) L2 = { : L(M) is regular} R() =

1. Construct M#(x): 1.1. Copy its input x to another track for later. 1.2. Erase the tape. 1.3. Write w on the tape. 1.4. Run M on w. 1.5. Put x back on the tape. 1.6. If x AnBn then accept, else reject. 2. Return . Problem: But We Can Flip R() = 1. Construct the description , where M#(x) operates as follows: 1.1. Save x for later. 1.2. Erase the tape. 1.3. Write w on the tape.

1.4. Run M on w. 1.5. Put x back on the tape. 1.6. If x AnBn then accept, else reject. 2. Return . If Oracle decides L2, then C = Oracle(R()) decides H: H: M# makes it to step 1.5. Then it accepts x iff x AnBn. So M# accepts AnBn, which is not regular. Oracle rejects. C accepts. H: M does not halt on w. M# gets stuck in step 1.4. It accepts nothing. L(M#) = , which is regular. Oracle accepts. C rejects. But no machine to decide H can exist, so neither does Oracle. Or, Doing it Without Flipping R() =

1. Construct the description , where M#(x) operates as follows: 1.1. If x AnBn then accept, else: 1.2. Erase the tape. 1.3. Write w on the tape. 1.4. Run M on w. 1.5. Accept 2. Return . If Oracle exists, C = Oracle(R()) decides H: C is correct: M# immediately accepts all strings in AnBn: H: M# accepts everything else in step 1.5. So L(M#) = *} is not in D. , which is regular. Oracle accepts. H: M# gets stuck in step 1.4, so it accepts nothing else. L(M#) = AnBn, which is not regular. Oracle rejects. But no machine to decide H can exist, so neither does Oracle. Any Nonregular Language Will Work

R() = 1. Construct the description , where M#(x) operates as follows: 1.1. If x WW then accept, else: 1.2. Erase the tape. 1.3. Write w on the tape. 1.4. Run M on w. 1.5. Accept 2. Return . If Oracle exists, C = Oracle(R()) decides H: C is correct: M# immediately accepts all strings WW: H: M# accepts everything else in step 1.5. So L(M#) = *} is not in D. , which is regular. Oracle accepts. H: M# gets stuck in step 1.4, so it accepts nothing else. L(M#) = WW, which is not regular. Oracle rejects. But no machine to decide H can exist, so neither does Oracle.

How you cannot use Rice's theorem (in this course) You are not allowed to use Rice's Theorem as a substitute for learning how to do reductions. There will be exam problem(s) that explicitly disallow use of Rice's Theorem, requiring you to do an explicit reduction instead. Is L(M) Context-free? How about: L3 = { : L(M) is context-free}? R() =

1. Construct the description , where M#(x) operates as follows: 1.1. If x AnBnCn then accept, else: 1.2. Erase the tape. 1.3. Write w on the tape. 1.4. Run M on w. 1.5. Accept 2. Return . Practical Impact of These Results 1. Does P, when running on x, halt? 2. Might P get into an infinite loop on some input? 3. Does P, when running on x, ever output a 0? Or anything at all? 4. Are P1 and P2 equivalent? 5. Does P, when running on x, ever assign a value to n? 6. Does P ever reach S on any input (in other words, can we

chop it out? 7. Does P reach S on every input (in other words, can we guarantee that S happens)? Can Can the Patent Office check prior art? the CSSE department buy the definitive grading program? { : M reaches q on some input} HANY = { : there exists some string on which TM M halts} R (?Oracle)

L2 = { : M reaches q on some input} R() = 1. Build so that M# is identical to M except that, if M has a transition ((q1, c1), (q2, c2, d)) and q2 is a halting state other than h, replace that transition with: A good example, ((q1, c1), (h, c2, d)). but the term is 2. Return . flying by, so we If Oracle exists, then C = Oracle(R()) decides H : may skip it for now. ANY R can be implemented as a Turing machine. C is correct: M# will reach the halting state h iff M would reach some

halting state. So: HANY: There is some string on which M halts. So there is some string on which M# reaches state h. Oracle accepts. HANY: There is no string on which M halts. So there is no string on which M# reaches state h. Oracle rejects. But no machine to decide HANY can exist, so neither does Oracle. Side Road with a purpose: obtainSelf From Section 25.3: In section 25.3, the author proves the existence of a very useful computable function: obtainSelf. When called as a subroutine by any Turing machine M, obtainSelf writes onto M's tape. Related to quines

Some quines main(){char q=34, n=10,*a="main() {char q=34,n=10,*a=%c%s%c; printf(a,q,a,q,n);} %c";printf(a,q,a,q,n);} ((lambda (x) (list x (list 'quote x))) (quote (lambda (x) (list x (list 'quote x))))) Quine's paradox and a related sentence: "Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation. "quoted and followed by itself is a quine." quoted and followed by itself is a quine. Non-SD Languages There is an uncountable number of non-SD languages, but only a countably infinite number of TMs (hence SD languages). The class

of non-SD languages is much bigger than that of SD languages! Non-SD Languages Intuition: Non-SD languages usually involve either infinite search (where testing each potential member could loop forever) or determining whether the a TM will infinitely loop. Examples: H = { : TM M does not halt on w}. { : L(M) = *} is not in D. }.

{ : TM M halts on nothing}. Proving Languages are not SD Contradiction L is the complement of an SD/D Language. Reduction from a known non-SD language Contradiction Theorem: TMMIN = {: Turing machine M is minimal} is not in SD. Proof: If TMMIN were in SD, then there would exist some Turing machine ENUM that enumerates its elements. Define the following Turing machine: We'll probably skip this one in class

M#(x) = 1. Invoke obtainSelf to produce . 2. Run ENUM until it generates the description of some Turing machine M whose description is longer than ||. 3. Invoke U on the string . Since TMMIN is infinite, ENUM must eventually generate a string that is longer than ||. So M# makes it to step 3 and thus M# is equivalent to M since it simulates M. But, since || < ||, M cannot be minimal. But M#'s description was generated by ENUM. Contradiction. The Complement of L is in SD/D Suppose we want to know whether L is in SD and we know: L is in SD, and At least one of L or L is not in D.

Then we can conclude that L is not in SD, because, if it were, it would force both itself and its complement into D, which we know cannot be true. Example: H (since (H) = H is in SD and not in D) Aanbn = { : L(M) = AnBn} Aanbn contains strings that look like: (q00,a00,q01,a00,), (q00,a01,q00,a10,), (q00,a10,q01,a01,), (q00,a11,q01,a10,), (q01,a00,q00,a01,), (q01,a01,q01,a10,), (q01,a10,q01,a11,), (q01,a11,q11,a01,)

It does not contain strings like aaabbb. But AnBn does. Aanbn = { : L(M) = AnBn} Whats wrong with this proof that Aanbn is not in SD? H = { : TM M does not halt on w} R (?Oracle) Aanbn = { : L(M) = AnBn} R() = 1. Construct the description , where M#(x) operates as

follows: 1.1. Erase the tape. 1.2. Write w on the tape. 1.3. Run M on w. 1.4. Accept. 2. Return . If Oracle exists, C = Oracle(R()) semidecides H: Aanbn = { : L(M) = AnBn} is not SD What about: H = { : TM M does not halt on w} R

(?Oracle) Aanbn = { : L(M) = AnBn} R() = 1. Construct the description , where M#(x) operates as follows: 1.1 Copy the input x to another track for later. 1.2. Erase the tape. 1.3. Write w on the tape. 1.4. Run M on w. 1.5. Put x back on the tape. 1.6. If x AnBn then accept, else loop. 2. Return . If Oracle exists, C = Oracle(R()) semidecides H: Aanbn = { : L(M) = AnBn} is not SD R() reduces H to Aanbn: 1. Construct the description :

1.1. If x AnBn then accept. Else: 1.2. Erase the tape. 1.3. Write w on the tape. 1.4. Run M on w. 1.5. Accept. 2. Return . If Oracle exists, then C = Oracle(R()) semidecides H: M# immediately accepts all strings in AnBn. If M does not halt on w, those are the only strings M# accepts. If M halts on w, M# accepts everything: H: M does not halt on w, so M# accepts strings in AnBn in step 1.1. Then it gets stuck in step 1.4, so it accepts nothing else. It is an AnBn acceptor. Oracle accepts. H: M halts on w, so M# accepts everything. Oracle does not accept. But no machine to semidecide H can exist, so neither does Oracle.

## Recently Viewed Presentations

• The (Uncertain Compression) problem. Wish to design encoding/decoding schemes (?/?) to be used as follows: Sender has distribution ? on ? = {1,2,…,?}
• A Study of social influence in diffusion of innovation over Facebook Shaomei Wu [email protected] Information Science Cornell University Information Science Breakfast, Dec 5, 2008 Diffusion of Innovation " Diffusion is the process in which an innovation is communicated through certain...
• Úvod - základní pojmy Hlavními dvěma otázkami, které se objevují v souvislosti s řízením zásob, jsou: V jakém okamžiku objednat novou dodávku dané jednotky zásob?
• Why study programming languages? Make it easier to learn new languages some languages are similar; easy to walk down family tree. concepts have even more similarity; if you think in terms of iteration, recursion, abstraction (for example), you will find...
• Educators can create their personal "My Toolbox". With a tr4y account, individual educators can save the resources they have located in "My Favorite Resources", and can complete the tools accessible to teachers. The individual educator is the only one able...
• Utah's total state budget from all sources for FY 2018 is \$16.2 billion - that's about \$885 million or 6.1% more than the \$14.2 billion budget passed during the 2016 General Session. You can see from this chart that the...
• Verdana Arial Lucida Sans Unicode Wingdings 2 Courier New Times New Roman Wingdings 1_Equity 2_Equity 3_Equity 4_Equity Microsoft Office Excel Chart Microsoft Office Excel 97-2003 Worksheet Facilitating Compiler Optimizations Through the Dynamic Mapping of Alternate Register Structures Motivation Vector Multiply...
• [3] S. Hin/B. Lopez-Jimena, et al., in preparation. (A) (B) (C) Figure 3: (A) Packaged LabDisks ready for use. (B) Dr. Cheikh Fall using the LabDisk & Player at the Institut Pasteur de Dakar (March 2016. Source. Dr. B. Lopez-Jimena)...