Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation.

Similar presentations


Presentation on theme: "Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation."— Presentation transcript:

1 Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation

2 – 2 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 2 Overview  At first, the TM doesn’t look very powerful. Can it really do anything a computer can?  We’ll discuss “programming tricks” to convince you that it can simulate a real computer.

3 – 3 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 3 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. That’s essential to exhibit a language that is not recursively enumerable.

4 – 4 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 4 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 six- dimensional tapes is no more powerful than the basic model.

5 – 5 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 5 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.

6 – 6 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 6 Picture of Multiple Tracks q X Y Z Represents one symbol [X,Y,Z] 0 B B Represents input symbol 0 B B B Represents the blank

7 – 7 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 7 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.

8 – 8 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 8 Marking q X Y B Z B W Marked Y Unmarked W and Z

9 – 9 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 9 Simulating Infinite Tape by Semi- infinite Tape 0 1 2 3... * -1 -2 -3... q U/L State remembers whether simulating upper or lower track. Reverse directions for lower track. Put * here at the first move You don’t need to do anything, because these are initially B.

10 – 10 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 10 Extensions  More general than the standard TM.  But still only able to define the RE languages. 1. Multitape TM. 2. Nondeterministic TM. 3. Store for key-value pairs.

11 – 11 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 11 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.

12 – 12 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 12 Nondeterministic TM’s  Allow the TM to have a choice of move at each step. Each choice is a state-symbol-direction triple, as for the deterministic TM.  The TM accepts its input if any sequence of choices leads to an accepting state.

13 – 13 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 13 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.  A second tape can hold a name whose value we want to look up.

14 – 14 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 14 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.

15 – 15 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 15 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.

16 – 16 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 16 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.

17 – 17 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 17 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.

18 – 18 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 18 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.

19 – 19 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 19 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.”

20 – 20 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 20 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.

21 – 21 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 21 Picture of Union/Recursive M1M1 M2M2 Input w Accept Reject OR Reject Accept AND M Remember: = “halt without accepting

22 – 22 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 22 Picture of Union/RE M1M1 M2M2 Input w Accept ORAccept M

23 – 23 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 23 Intersection/Recursive – Same Idea M1M1 M2M2 Input w Accept Reject AND Reject Accept OR M

24 – 24 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 24 Intersection/RE M1M1 M2M2 Input w Accept ANDAccept M

25 – 25 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 25 Decidable Problems  A problem is decidable if there is an algorithm to answer it. 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.

26 – 26 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 26 Bullseye Picture Decidable problems = Recursive languages Recursively enumerable languages Not recursively enumerable languages LdLd Are there any languages here?

27 – 27 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 27 From the Abstract to the Real  While the fact that L d 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 the theory to show some real problems are undecidable.

28 – 28 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 28 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?

29 – 29 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 29 The Universal Language  An example of a recursively enumerable, but not recursive language is the language L u 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.

30 – 30 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 30 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.

31 – 31 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 31 The UTM – (2)  The UTM will have several tapes.  Tape 1 holds the input M111w  Tape 2 holds the tape of M. Mark the current head position of M.  Tape 3 holds the state of M.

32 – 32 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 32 The UTM – (3)  Step 1: The UTM checks that M is a valid code for a TM. 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.

33 – 33 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 33 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.

34 – 34 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 34 The UTM – (5)  Step 4: Simulate M. 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.

35 – 35 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 35 A Question  Do we see anything like universal Turing machines in real life?

36 – 36 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 36 Proof That L u is Recursively Enumerable, but not Recursive  We designed a TM for L u, 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 L d, as follows.

37 – 37 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 37 Proof – (2)  Given input w, we can decide if it is in L d by the following steps. 1. Check that w is a valid TM code.  If not, then its language is empty, so w is in L d. 2. If valid, use the hypothetical algorithm to decide whether w111w is in L u. 3. If so, then w is not in L d ; else it is.

38 – 38 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 38 Proof – (3)  But we already know there is no algorithm for L d.  Thus, our assumption that there was an algorithm for L u is wrong.  L u is RE, but not recursive.

39 – 39 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 39 Bullseye Picture Decidable problems = Recursive languages Recursively enumerable languages Not recursively enumerable languages LdLd LuLu All these are undecidable


Download ppt "Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation."

Similar presentations


Ads by Google