CS 361 Meeting 28 11/14/18 Announcements 1. Homework 9 due Friday Computation Histories 1. Some very interesting proos o undecidability rely on the technique o constructing a language that describes the possible computations o a TM on one or more inputs. 2. Recall that a TM coniguration is a triple (q, u, v) with q Q representing the current state o the control, u Γ representing the contents o the tape to the let o the current head position, and v Γ representing the tape contents rom the head to the right end o the non-blank tape. 3. We can use a sequence o strings that describe conigurations to describe the complete computation o a TM. Deinition: Given a TM M = (Q, Σ, Γ, δ, q 0, q accept, q reject ) and a string w Σ, we deine the language o accepting computation histories o M on w as L Computation history (M, w) = {w 0 w 1...w n each w i is a coniguration or M w 0 is the initial coniguration or w w n is a inal/accept coniguration each w i yields w i+1 according to δ } 4. In general, L Computation history (M, w) is a pretty complicated language. It is decidable, but it is not regular or context-ree. 5. Interestingly, i M is deterministic, then L Computation history (M, w) is actually a very simple language. It is either equal to i w / L(M) or it contains a single string i w M. Click here to view the slides or this class This is interesting because the empty language and any language containing just 1 (or any inite number) o strings must be regular and thereore context-ree. I given the description o M and w we could build a DFA that accepted L Computation history (M, w) then since emptiness o a regular language is decidable, we could decide whether w L(M). This question is better known as A T M and we know that it is undecidable! This implies that even though L Computation history (M, w) must be regular i M is deterministic, there is no algorithm to ind a DFA or the language given a description o M. The DFA is uncomputable! 6. To get a bit closer to being able to ind a way to compute L Computation history (M, w), we can deine a slight variation o this language: Deinition: Given a TM M = (Q, Σ, Γ, δ, q 0, q accept, q reject ) and a string w Σ, we deine the language o reversed computation histories o M on w as L R Computation history (M, w) = {w 0 w1 R...w n each w i is a coniguration or M w 0 is the initial coniguration or w w n is a inal/accept coniguration each w i yields w i+1 according to δ every other w i is written backwards } 7. Again, i M is deterministic, this language is inite and thereore both regular and context-ree. 8. You should imagine that it would be possible to construct a CFG or a PDA that ensures that all even-odd pairs o strings or all odd-even pairs o conigurations in such strings satisied the yields requirement, the PDA or CFG can only ensure that every other coniguration yields its successor. 1
9. Somewhat amazingly the complement o L R Computation history (M, w) which is ar rom inite is context-ree and we can eectively construct a PDF or CFG that describes it given a description o M and w. The trick is that we can describe a PDA that uses its nondeterminism to guess where the eature that would make a string invalid as a computation history occurs and then use the stack o the PDA to validate the guesses. The PDA guesses one o the ollowing issues: The whole string is not ormatted properly (this is regular), For any pair o consecutive conigurations, the earlier coniguration does not yield the ollowing coniguration (a PDA could nondeterministically guess which pair didn t match, push the irst coniguration on its stack and then veriy the mismatch as it read the next coniguration), The irst coniguration is not a valid initial coniguration or w (again regular), The last coniguration is not an accepting coniguration (again regular). 10. Using this act, we can show that ALL CF G is not recognizable by reducing A T M to ALL CF G. To do this, we will assume the existence o a TM M ALLCF G that recognizes ALL CF G and build a TM M AT M that recognizes A T M. M AT M should accept its input i it is not a valid encoding o a TM description and input. Next, M AT M should create a CFG G M or L R Computation history (M, w). Finally, M AT M should run M ALLCF G on G M and accept i M ALLCF G accepts. This machine recognizes A T M because M has an accepting computation history on w i w L(M). As a result, L R Computation history (M, w) = L(G M ) = Σ exactly when w / L(M). Since it would be a contradiction i we could recognize A T M, it must be impossible to recognize ALL CF G. 11. Since we can recognize ALL CF G by simply checking all strings looking or one that cannot be derived rom the grammar, this implies that ALL CF G is recognizable but not decidable. Just about Everything about TMs is Undecidable 1. It turns out that just about every interesting question about Turing machines is undecidable. One consequence o this is that just about hal o all interesting questions are not recognizable (because i both a language and its complement are recognizable then both languages are decidable). 2. With this in mind, it should be easy to ind some more languages to practice our reduction proo skills. 3. Here are just a ew possible examples: REV ERSIBLE T M = { M w L(M) i w R L(M)} REGULAR T M = { M L(M) is regular} DISJOINT T M = { M, N L(M) L(N) = } P RIME T M = { M w L(M) w is prime} 4. To give us one more bit o practice with this, let s show that REV ERSIBLE T M is not recognizable. First, observe that {ab} and {a n b n n 0, are nice examples o sets that are not reversible while and Σ are deinitely reversible.. We have seen several proos in which the machine M we built given an input M, w accepted all inputs i M accepted w and rejected all inputs (possible by looping) otherwise. It is easy to reine this machine by running another Turing machine as a sub-module ater M determines whether M accepts w. For example, we could only accept strings o the orm a n b n i M accepts w. 2
This results in M REV ERSIBLE T M exactly when w / L(M). This gives us what we need to give a proo that REV ERSIBLE T M is not recognizable: Proo: Assume that REV ERSIBLE T M is recognized by some Turing machine M RT M. Construct a machine M AT M that operates as ollows: (a) I the machine s input is not a valid encoding o a Turing machine and its input, accept. (b) Otherwise, construct a description o a new machine M which behaves as ollows: On input w, simulate M on w. I M accepts w, then accept w i it is a string o the orm a n b n. Otherwise, reject. Run M RT M on M and accept i it does. The machine M AT M will accept M, w exactly when w / L(M) since in this case, L(M ) = is reversible while otherwise L(M ) = a n b n which is not reversible. 5. It is just as easy to show that REV ERSIBLE T M is not recognizable. 6. We will stick with a n b n as our non-regular language. We will switch rom to Σ or our reversible language. Mapping Reductions 1. We have observed that many o the proos o undecidability and nonrecognizability we have explored have a very similar structure. 2. We can ormalize these similarities in the notion o mapping reducibility and then use this idea to simpliy the proos or many results involving decidability and recognizability. 3. First we must deine the idea o a computable unction. Deinition: A unction rom Σ Σ is computable i and only i some Turing machine M on every input w, halts with (w) on its tape. 4. This deinition is mainly an admission that Turing machines can do interesting things other than just accept and reject. This is not new. One o the irst TMs we considered implemented a computable unction. It took input strings and did its best to insert a # in the middle o them. In each o the non-recognizability proos we have given, we have embedded such a computable unction. Namely, the computation that generated M given some M, w. 5. Given the notion o computable unctions, we can capture the essence o what our M s are really about. Deinition: Language A is many-to-one reducible to language B (written A m B) i there exists a computable unction : Σ Σ such that or every w Σ w A (w) B. In this case we call a reduction. 6. Let me share two handy memory aids or dealing with the notation. (a) The point o the goes in the direction opposite the unction arrow. (b) It helps to read the as is easier than rather than is less than. 7. The ollowing diagram illustrates what this deinition requires and allows. It must map members o A to members o B. It must map strings that are not in A to strings that are not in B. 3
It can map multiple input strings to the same output. 8. As a simple example, the computable unction A (< M, w >) = < M > where M is a TM that ignores its input, runs M on w and accepts its input i M accepts w. shows that A T M m ALL T M since it maps any < M, w > that belongs in A T M to an < M > that belongs in ALL T M. 9. Note that there is nothing that inherently ties this computable unction to A T M and ALL T M. As long as we can identiy two languages A and B such that w A (w) B, A M B. As an easy example o this, note that this unction also shows that A T M m ALL T M. In general A M B A M B. 10. As a more diverse example, this unction also shows that A T M m E T M since it maps any < M, w > that belongs in A T M to an < M > that belongs in E T M. 11. With these deinitions, we can succinctly ormalize the technique we have been using in all our proos or the last ew classes: Theorem: I A m B and... (a) B is decidable, then A is decidable, B (b) A is undecidable, then B is undecidable, (c) B is recognizable, then A is recognizable, and (d) A is not recognizable, then B is not recognizable We won t give a detailed proo o these claims, but they are all just obvious applications o the proo techniques we have been employing. 12. As an example o how we might use such a mapping reduction, consider the language DISJOINT T M = { M, M M & N are TMs and L(M) L(N) = }. We will show that DISJOINT T M is not recognizable by showing that E T M M DISJOINT T M. To do this, we need a mapping that will take any M to a pair o TM descriptions N, N in such a way that L(N) and L(N ) are disjoint i and only i L(M) is empty. Let ACCEP T be a TM that accepts all strings. Consider the unction ( M ) = M, ACCEP T. This is clearly computable. It is also clear that M, ACCEP T C i and only i E E T M. Given that we know that E T M is not recognizable, we can conclude that DISJOINT T M is not recognizable. Rice s Theorem 1. While we have categorized a large number o languages as decidable, recognizable, or not recognizable, there are still plenty o additional examples we could consider: REGULAR T M = { M L(M) is regular } CONT EXT -F REE T M = { M L(M) is context-ree } P ALINDROME T M = { M w L(M) w R L(M)} 4
EV EN T M = { M w L(M) w = 2} P RIME T M = { M w L(M) w is prime } 2. There is a single theorem that will quickly allow us to show that all o the languages listed above are undecidable. This result is known as Rice s Theorem. 3. Inormally, Rice s Theorem says that any nontrivial property o a Turing machine s language is undecidable. Nontrivial means that the languages o some but not all TMs have this property. The act that it is a property o the language rather than the TMs means that it must be based strictly on the set o strings a given TM accepts rather than on how the TM is designed or operates. 4. We can ormalize this notion as: Rice s Theorem. Suppose that L is a language with L { M M is a valid Turing machine} such that i L(M) = L(N) then M L N L then L is undecidable. 5