cisc 4090 theory of computation
play

CISC 4090: Theory of Computation Chapter 3 The Church-Turing Thesis - PowerPoint PPT Presentation

CISC 4090: Theory of Computation Chapter 3 The Church-Turing Thesis Section 3.1: Turing Machines Courtesy of Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 1 / 48 2 / 48 Turing machines:


  1. CISC 4090: Theory of Computation Chapter 3 The Church-Turing Thesis Section 3.1: Turing Machines Courtesy of Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 1 / 48 2 / 48 Turing machines: Context Turing machines overview ◮ Introduced by Alan Turing in 1936 Models of computation: ◮ Unlimited memory ◮ Infinite tape that can be ◮ Finite automata: models devices with little memory ◮ moved left/right ◮ Pushdown automata: models devices with unlimited memory, ◮ written accessible only in LIFO order. ◮ Much less restrictive than stack of a PDA ◮ Turing machines: models general purpose computers ◮ A Turing machine can do everything a real computer can do (even though a simple model) ◮ However, a Turing machine cannot solve all problems! 3 / 48 4 / 48

  2. What is a Turing machine? Turing machine Informal description ◮ Contains an infinite tape ◮ Tape initially contains the input string, with blanks everywhere else. ◮ Machine can read and write from tape, and move left or right Control after each action. ◮ The machine continues until it enters an accept state or a . . . � � � � a b a b reject state, at which point it immediately stops and outputs accept or reject . Very different from FSAs and PDAs. ◮ The machine can loop forever. ◮ Why can’t an FSA or PDA loop forever? ◮ Answer: FSA/PDA terminates when input string is fully processed, taking only one “action” for each input symbol processed. 5 / 48 6 / 48 Designing a Turing machine: Example #1 Turing machine: Example #1 ◮ M 1 to recognize B = � w # w : w ∈ { 0 , 1 } ∗ � . ◮ M 1 loops. In each iteration, it matches symbols on each side of the # . � w # w : w ∈ { 0 , 1 } ∗ � . . . to recognize the language B = . ◮ It does the leftmost symbol remaining. ◮ Will focus on informal descriptions, even more than we did ◮ It thus scans forward and backwards. with PDAs. ◮ It crosses off the symbol it’s working on. We can assume the ◮ Imagine that you are standing on an infinite tape with symbols TM replaces it with some special symbol x . on it, and you want to check to see if the string belongs to B . ◮ When scanning forward, it scans to the # , then scans to the ◮ What procedure would you use, given that you can read/write first symbol not crossed off. ◮ When scanning backwards, it scans past the # and then to the and move the tape in each direction? ◮ You have a finite control, so cannot remember much. Hence crossed-off symbol. ◮ If TM discovers a mismatch, it rejects. you must rely on the information on the tape. ◮ If all symbols are crossed off, then accept. ◮ Try it! ◮ What are the possible outcomes? ◮ Accept or reject. ◮ Looping is not possible: Guaranteed to terminate/halt, since each iteration makes progress. 7 / 48 8 / 48

  3. Sample execution Formal definition of a Turing machine for the string 011000#011000 ◮ The key is the transition function Tape head is at red symbol. 0 1 1 0 0 0 # 0 1 1 0 0 0 � � ... δ : Q × Γ → Q × Γ × { L , R } x 1 1 0 0 0 # 0 1 1 0 0 0 � � ... . . . ◮ Suppose TM is in state q , with the head over the tape at x 1 1 0 0 0 # x 1 1 0 0 0 � � ... symbol a . TM now executes. Then TM is in new state r , with x 1 1 0 0 0 # x 1 1 0 0 0 � � ... a new symbol b replacing a on the tape, and tape head moves x x 1 0 0 0 # x 1 1 0 0 0 � � ... either left or right. . . . x x x x x x # x x x x x x � � ... 9 / 48 10 / 48 Formal definition of a Turing machine (cont’d) TM computation ◮ A Turing machine is a 7-tuple ( Q , Σ , Γ , δ, q 0 , q accept , q reject ). ◮ Q is a finite set of states . ◮ A TM’s configuration consists of: ◮ Σ is the input alphabet , not containing the special symbol � . ◮ its current state, ◮ the contents of the current tape location, and ◮ Γ is the tape alphabet , where � ∈ Γ and Σ ⊂ Γ. ◮ the current head location. ◮ δ : Q × Γ → Q × Γ × { L , R } is the transition function . ◮ As a TM computes, its current configuration can change. ◮ q 0 , q accept , and q reject are the start , accept , and reject states. ◮ Do we need more than one accept or reject state? ◮ No, since once we enter such a state, we can terminate. 11 / 48 12 / 48

  4. Turing recognizable and decidable languages Turing machine: Example #2 ◮ Design a TM M 2 that decides A = { 0 2 n : n ≥ 0 } , the language of all strings of 0 s whose length is a power of two. ◮ The set of strings that a Turing machine M accepts is the ◮ Without designing it, do you think (intuitively) that this can language of M , or the language recognized by M , be done? Why? denoted L ( M ). ◮ We could write a (C++, Java, Perl, . . . ) program to do this. ◮ Definitions: ◮ Since a TM can do anything a computer can do, this can be ◮ A language is Turing recognizable (sometimes called done by a TM. ◮ Solution? Basic idea: Divide by 2 each time and see whether recursively enumerable ) if some Turing machine recognizes it. ◮ A Turing machine that halts on all inputs is a decider . A remainder is 1: boxed decider that recognizes a language decides it. while true do ◮ A language is ( Turing -) decidable (sometimes called recursive ) sweep left to right across the tape, crossing off every other 0 ; if it is decided by some Turing machine. ◮ Notes: if tape has exactly one 0 then accept; ◮ Language is decidable if it’s Turing recognizable by a TM that ; always halts, i.e., there is a decider for that language. if tape has an odd number of 0 s then reject; ◮ Every decidable language is Turing-recognizable. return the head to the left-hand end of the tape; ◮ It is possible for a TM to halt only on those strings it accepts. ; end 13 / 48 14 / 48 Sample execution of TM M 2 Turing machine: Example #3 Number is 4 = 2 2 0 0 0 0 � � ◮ Design TM M 3 to decide the language x 0 0 0 � � Now we have 2 = 2 1 C = { a i b j c k : i × j = k and i , j , k ≥ 1 } x 0 x 0 � � x 0 x 0 � � ◮ What does this tell us about the capability of a TM? x 0 x 0 � � ◮ That it can do (or at least check) multiplication. x x x 0 � � ◮ As we have seen before, we often use unary. now we have 1 = 2 0 x x x 0 � � ◮ How would you approach this? seek back to start x x x 0 � � Scan right; one 0 , so accept (Imagine that we were trying 2 × 3 = 6.) x x x 0 � � 15 / 48 16 / 48

  5. Turing machine: Example #3 (cont’d) Transducers 1. First, scan the string from left to right to verify that it is of the form a i b j c k . If it is, scan to start of tape, 1 and if not, ◮ We keep talking about recognizing a language, rather than reject. generating a language. This is common in language theory. (Easy to do with finite control/finite automaton.) ◮ But now that we are talking about computation, this may seem strange and limiting. 2. Cross off the first a and scan until the first b occurs. Shuttle ◮ Computers typically transform input into output. between b ’s and c ’s, crossing off one of each until all b ’s are ◮ For example, we are more likely to have a computer perform gone. If all c ’s have been crossed off and some b ’s remain, multiplication than to check that the equation is correct. reject. ◮ TMs can also generate or transduce . 3. Restore 2 the crossed-off b ’s and repeat step 2 if there are any ◮ How would you compute c i × j , given a i and b j ? a ’s remaining. If all a ’s are gone, check if all c ’s are crossed ◮ Similar to TM M 3 : For every a , scan through the b ’s; for each b , you go to the end of the string and add a c . Thus by off—if so, accept; if not, reject. zig-zagging i times, you can generate the appropriate number of c ’s. 1 Some subtleties here, see text. Can either use a special symbol or can backup until we realize tape is stuck and hasn’t actually moved left. 2 How to restore? Have a special cross-off symbol that incorporates the original symbol; just put an X through that symbol. 17 / 48 18 / 48 Turing machine: Example #4 Turing machine: Example #4 (cont’d) 1. Place a mark on top of the left-most symbol. If it was a blank, accept. If it was a # , continue. Otherwise, reject. ◮ Solve the element uniqueness problem : 2. Scan right to next # and place a mark on same. If no # is ◮ Given a list of strings over { 0 , 1 } , separated by # . encountered, we only had x 1 , so accept. Accept if all the strings are different. 3. By zig-zagging, compare the two strings to the right of the ◮ The language is two marked # s. If they are equal, reject. E = { # x 1 # x 2 # . . . # x l : each x i ∈ { 0 , 1 } ∗ and x i � = x j if i � = j } 4. Move the rightmost of the two marks to the next # symbol to the right. If no # symbol is encountered before a blank, move ◮ How would you do this? the left most mark to its right and the rightmost mark to the # after that. This time, if no # is available for the rightmost mark, all the strings have been compared, so accept. 5. Go back to step 3. 19 / 48 20 / 48

Recommend


More recommend