CSCE 355 Foundations of Computation Lecture 17 Undecidability
CSCE 355 Foundations of Computation Lecture 17 Undecidability Topics: • TM variations • Undecidability June 25, 2015
Overview • At first, the TM doesn’t look very powerful. n Can it really do anything a computer can? • We’ll discuss “programming tricks” to convince you that it can simulate a real computer. – 2– ialc slides Ullman Stanford 2 CSCE 355 Summer 2015
Overview – (2) • We need to study restrictions on the basic TM model (e. g. , tapes infinite in only one direction). • Assuming a restricted form makes it easier to talk about simulating arbitrary TM’s. n – 3– That’s essential to exhibit a language that is not recursively enumerable. ialc slides Ullman Stanford 3 CSCE 355 Summer 2015
Overview – (3) • We also need to study generalizations of the basic model. • Needed to argue there is no more powerful model of what it means to “compute. ” • Example: A nondeterministic TM with 50 sixdimensional tapes is no more powerful than the basic model. – 4– ialc slides Ullman Stanford 4 CSCE 355 Summer 2015
Programming Trick: Multiple Tracks • Think of tape symbols as vectors with k components. • Each component chosen from a finite alphabet. • Makes the tape appear to have k tracks. • Let input symbols be blank in all but one track. – 5– ialc slides Ullman Stanford 5 CSCE 355 Summer 2015
Picture of Multiple Tracks Represents input symbol 0 q Represents the blank 0 X B B Y B B Z B Represents one symbol [X, Y, Z] – 6– ialc slides Ullman Stanford 6 CSCE 355 Summer 2015
Programming Trick: Marking • A common use for an extra track is to mark certain positions. • Almost all cells hold B (blank) in this track, but several hold special symbols (marks) that allow the TM to find particular places on the tape. – 7– ialc slides Ullman Stanford 7 CSCE 355 Summer 2015
Marking q Marked Y – 8– B X B W Y Z Unmarked W and Z ialc slides Ullman Stanford 8 CSCE 355 Summer 2015
Simulating Infinite Tape by Semiinfinite Tape q U/L State remembers whether simulating upper or lower track. Reverse directions for lower track. 0 1 2 3. . . * -1 -2 -3. . . – 9– Put * here at the first move You don’t need to do anything, because these are initially B. 9 CSCE 355 Summer 2015 ialc slides Ullman Stanford
Extensions • More general than the standard TM. • But still only able to define the RE languages. 1. 2. 3. – 10 – Multitape TM. Nondeterministic TM. Store for key-value pairs. ialc slides Ullman Stanford 10 CSCE 355 Summer 2015
Multitape Turing Machines • Allow a TM to have k tapes for any fixed k. • Move of the TM depends on the state and the symbols under the head for each tape. • In one move, the TM can change state, write symbols under each head, and move each head independently. – 11 – ialc slides Ullman Stanford 11 CSCE 355 Summer 2015
Nondeterministic TM’s • Allow the TM to have a choice of move at each step. n Each choice is a state-symbol-direction triple, as for the deterministic TM. • The TM accepts input if any sequence of choices leads to an accepting state. – 12 – ialc slides Ullman Stanford 12 CSCE 355 Summer 2015
Simulating a Name-Value Store by a TM • The TM uses one of several tapes to hold an arbitrarily large sequence of name-value pairs in the format #name*value#… • Mark, using a second track, the left end of the sequence. • – 13 – A second tape can hold a name whose value we want to look up. ialc slides Ullman Stanford 13 CSCE 355 Summer 2015
Lookup • Starting at the left end of the store, compare the lookup name with each name in the store. • When we find a match, take what follows between the * and the next # as the value. – 14 – ialc slides Ullman Stanford 14 CSCE 355 Summer 2015
Insertion • Suppose we want to insert name-value pair (n, v), or replace the current value associated with name n by v. • Perform lookup for name n. • If not found, add n*v# at the end of the store. – 15 – ialc slides Ullman Stanford 15 CSCE 355 Summer 2015
Insertion – (2) • If we find #n*v’#, we need to replace v’ by v. • If v is shorter than v’, you can leave blanks to fill out the replacement. • But if v is longer than v’, you need to make room. – 16 – ialc slides Ullman Stanford 16 CSCE 355 Summer 2015
Insertion – (3) • Use a third tape to copy everything from the first tape at or to the right of v’. • Mark the position of the * to the left of v’ before you do. • Copy from the third tape to the first, leaving enough room for v. • Write v where v’ was. – 17 – ialc slides Ullman Stanford 17 CSCE 355 Summer 2015
Closure Properties of Recursive and RE Languages • Both closed under union, concatenation, star, reversal, intersection, inverse homomorphism. • Recursive closed under difference, complementation. • RE closed under homomorphism. – 18 – ialc slides Ullman Stanford 18 CSCE 355 Summer 2015
Union • Let L 1 = L(M 1) and L 2 = L(M 2). • Assume M 1 and M 2 are single-semi-infinite-tape TM’s. • Construct 2 -tape TM M to copy its input onto the second tape and simulate the two TM’s M 1 and M 2 each on one of the two tapes, “in parallel. ” – 19 – ialc slides Ullman Stanford 19 CSCE 355 Summer 2015
Union – (2) • Recursive languages: If M 1 and M 2 are both algorithms, then M will always halt in both simulations. • Accept if either accepts. • RE languages: accept if either accepts, but you may find both TM’s run forever without halting or accepting. – 20 – ialc slides Ullman Stanford 20 CSCE 355 Summer 2015
Picture of Union/Recursive Accept M 1 Input w Reject OR Accept AND Reject M Accept M 2 Reject Remember: = “halt without accepting – 21 – ialc slides Ullman Stanford 21 CSCE 355 Summer 2015
Picture of Union/RE Accept M 1 OR Input w Accept M 2 – 22 – ialc slides Ullman Stanford 22 CSCE 355 Summer 2015
Intersection/Recursive – Same Idea Accept M 1 Input w Reject AND Accept OR Reject M Accept M 2 – 23 – Reject ialc slides Ullman Stanford 23 CSCE 355 Summer 2015
Intersection/RE Accept M 1 AND Input w Accept M 2 – 24 – ialc slides Ullman Stanford 24 CSCE 355 Summer 2015
Decidable Problems • A problem is decidable if there is an algorithm to answer it. n n Recall: An “algorithm, ” formally, is a TM that halts on all inputs, accepted or not. Put another way, “decidable problem” = “recursive language. ” • Otherwise, the problem is undecidable. – 25 – ialc slides Ullman Stanford 25 CSCE 355 Summer 2015
Bullseye Picture Not recursively enumerable languages Ld Decidable problems = Recursive languages Recursively enumerable languages – 26 – Are there any languages here? ialc slides Ullman Stanford 26 CSCE 355 Summer 2015
From the Abstract to the Real • While the fact that Ld is undecidable is interesting intellectually, it doesn’t impact the real world directly. • We first shall develop some TM-related problems that are undecidable, but our goal is to use theory to show some real problems are undecidable. – 27 – ialc slides Ullman Stanford 27 CSCE 355 Summer 2015
Examples: Undecidable Problems • Can a particular line of code in a program ever be executed? • Is a given context-free grammar ambiguous? • Do two given CFG’s generate the same language? – 28 – ialc slides Ullman Stanford 28 CSCE 355 Summer 2015
The Universal Language • An example of a recursively enumerable, but not recursive language is the language Lu of a universal Turing machine. • That is, the UTM takes as input the code for some TM M and some binary string w and accepts if and only if M accepts w. – 29 – ialc slides Ullman Stanford 29 CSCE 355 Summer 2015
Designing the UTM • Inputs are of the form: Code for M 111 w • Note: A valid TM code never has 111, so we can split M from w. • The UTM must accept its input if and only if M is a valid TM code and that TM accepts w. – 30 – ialc slides Ullman Stanford 30 CSCE 355 Summer 2015
The UTM – (2) • The UTM will have several tapes. • Tape 1 holds the input M 111 w • Tape 2 holds the tape of M. n Mark the current head position of M. • Tape 3 holds the state of M. – 31 – ialc slides Ullman Stanford 31 CSCE 355 Summer 2015
The UTM – (3) • Step 1: The UTM checks that M is a valid code for a TM. n E. g. , all moves have five components, no two moves have the same state/symbol as first two components. • If M is not valid, its language is empty, so the UTM immediately halts without accepting. – 32 – ialc slides Ullman Stanford 32 CSCE 355 Summer 2015
The UTM – (4) • Step 2: The UTM examines M to see how many of its own tape squares it needs to represent one symbol of M. • Step 3: Initialize Tape 2 to represent the tape of M with input w, and initialize Tape 3 to hold the start state. – 33 – ialc slides Ullman Stanford 33 CSCE 355 Summer 2015
The UTM – (5) • Step 4: Simulate M. n n n – 34 – Look for a move on Tape 1 that matches the state on Tape 3 and the tape symbol under the head on Tape 2. If found, change the symbol and move the head marker on Tape 2 and change the State on Tape 3. If M accepts, the UTM also accepts. ialc slides Ullman Stanford 34 CSCE 355 Summer 2015
A Question • Do we see anything like universal Turing machines in real life? – 35 – ialc slides Ullman Stanford 35 CSCE 355 Summer 2015
Proof That Lu is Recursively Enumerable, but not Recursive • We designed a TM for Lu, so it is surely RE. • Suppose it were recursive; that is, we could design a UTM U that always halted. • Then we could also design an algorithm for Ld, as follows. – 36 – ialc slides Ullman Stanford 36 CSCE 355 Summer 2015
Proof – (2) • Given input w, we can decide if it is in Ld by the following steps. 1. Check that w is a valid TM code. u 2. 3. – 37 – If not, then its language is empty, so w is in Ld. If valid, use the hypothetical algorithm to decide whether w 111 w is in Lu. If so, then w is not in Ld; else it is. ialc slides Ullman Stanford 37 CSCE 355 Summer 2015
Proof – (3) • But we already know there is no algorithm for Ld. • Thus, our assumption that there was an algorithm for Lu is wrong. • Lu is RE, but not recursive. – 38 – ialc slides Ullman Stanford 38 CSCE 355 Summer 2015
Bullseye Picture Not recursively enumerable languages Ld Decidable problems = Recursive languages All these are undecidable Recursively enumerable languages – 39 – Lu ialc slides Ullman Stanford 39 CSCE 355 Summer 2015
- Slides: 39