comp20121 the implementation and power of computer
play

COMP20121 The Implementation and Power of Computer Languages Power - PowerPoint PPT Presentation

COMP20121 The Implementation and Power of Computer Languages Power Part http://www.cs.man.ac.uk/ petera/2121/index.html . Peter Aczel room: CS2.52, tel: 56155 petera@cs.man.ac.uk email: School of Computer Science, University of


  1. COMP20121 The Implementation and Power of Computer Languages ‘Power’ Part http://www.cs.man.ac.uk/ ∼ petera/2121/index.html . Peter Aczel room: CS2.52, tel: 56155 petera@cs.man.ac.uk email: School of Computer Science, University of Manchester COMP20121 - Section 0 – p.1/307

  2. COMP20121, ‘power’ part: section 3 LECTURE EIGHT Section 3: Turing machines (ctd) COMP20121 - Section 3 – p.162/307

  3. Informal description Here is an alternative way of describing the same machine. COMP20121 - Section 3 – p.163/307

  4. Informal description Here is an alternative way of describing the same machine. • Remember the first symbol of the input string (by going to state 1 if it is an a and to state 2 if it is a b ) and erase it. COMP20121 - Section 3 – p.163/307

  5. Informal description Here is an alternative way of describing the same machine. • Remember the first symbol of the input string (by going to state 1 if it is an a and to state 2 if it is a b ) and erase it. • Go to the right until you find a blank. (This is the end of the input string.) COMP20121 - Section 3 – p.163/307

  6. Informal description • If the symbol to the left of that blank is the one remembered, erase it. If it is a blank, stop in an accepting state (0). Otherwise stop (in a non-accepting state). COMP20121 - Section 3 – p.164/307

  7. Informal description • If the symbol to the left of that blank is the one remembered, erase it. If it is a blank, stop in an accepting state (0). Otherwise stop (in a non-accepting state). • Go to the left until you find a blank. (This is the start of what’s left of the input string.) COMP20121 - Section 3 – p.164/307

  8. Informal description • If the symbol to the left of that blank is the one remembered, erase it. If it is a blank, stop in an accepting state (0). Otherwise stop (in a non-accepting state). • Go to the left until you find a blank. (This is the start of what’s left of the input string.) • Start over with the head pointing at the symbol to the right of that blank. COMP20121 - Section 3 – p.164/307

  9. Informal description–II Having gone through these states we know that COMP20121 - Section 3 – p.165/307

  10. Informal description–II Having gone through these states we know that • If the first letter and the last letter of the string were not equal, the machine has stopped in a non-accepting state. COMP20121 - Section 3 – p.165/307

  11. Informal description–II Having gone through these states we know that • If the first letter and the last letter of the string were not equal, the machine has stopped in a non-accepting state. • If the first and the last letter were equal, they have now both been erased and the head is pointing at the new first letter (the old second letter). COMP20121 - Section 3 – p.165/307

  12. Informal description–II Having gone through these states we know that • If the first letter and the last letter of the string were not equal, the machine has stopped in a non-accepting state. • If the first and the last letter were equal, they have now both been erased and the head is pointing at the new first letter (the old second letter). The machine will now start over. COMP20121 - Section 3 – p.165/307

  13. Informal description–II Hence the recognized language is that COMP20121 - Section 3 – p.166/307

  14. Informal description–II Hence the recognized language is that of all palindromes. COMP20121 - Section 3 – p.166/307

  15. Accepting languages Consider a Turing machine over the alphabet Σ = { a } which accepts the set of all words of even length COMP20121 - Section 3 – p.167/307

  16. Accepting languages Consider a Turing machine over the alphabet Σ = { a } which accepts the set of all words of even length, that is { a 2 i | i ∈ N } . COMP20121 - Section 3 – p.167/307

  17. Accepting languages Consider a Turing machine over the alphabet Σ = { a } which accepts the set of all words of even length, that is { a 2 i | i ∈ N } . We can code this with two states, for ‘odd’ and ‘even’. COMP20121 - Section 3 – p.167/307

  18. Accepting languages–II The machine moves to the right until it finds a blank, switching between these two states, where 0 is the sole accepting state. COMP20121 - Section 3 – p.168/307

  19. Accepting languages–II The machine moves to the right until it finds a blank, switching between these two states, where 0 is the sole accepting state. δ a 0 (1 , a, R ) stop 1 (0 , a, R ) stop COMP20121 - Section 3 – p.168/307

  20. Accepting languages–II Now consider instead the Turing machine given by δ a 0 (1 , a, R ) stop 1 (0 , a, R ) (1 , , R ) COMP20121 - Section 3 – p.169/307

  21. Accepting languages–II Now consider instead the Turing machine given by δ a 0 (1 , a, R ) stop 1 (0 , a, R ) (1 , , R ) This machine moves to the right as well, switching between two states coding for ‘odd’ and ‘even’. COMP20121 - Section 3 – p.169/307

  22. Accepting languages–II If the machine finds a blank then COMP20121 - Section 3 – p.170/307

  23. Accepting languages–II If the machine finds a blank then • it will stop (in an accepting state) if the current state is the one which is for ‘even’; COMP20121 - Section 3 – p.170/307

  24. Accepting languages–II If the machine finds a blank then • it will stop (in an accepting state) if the current state is the one which is for ‘even’; • it will keep moving to the right forever if the current state is the one for ‘odd’. COMP20121 - Section 3 – p.170/307

  25. Accepting languages–III The machines δ a (1 , a, R ) 0 stop (0 , a, R ) 1 stop and δ a (1 , a, R ) 0 stop (0 , a, R ) (1 , , R ) 1 both with sole accepting state 0 accept the same language. COMP20121 - Section 3 – p.171/307

  26. Accepting languages–III The machines δ a (1 , a, R ) 0 stop (0 , a, R ) 1 stop and δ a (1 , a, R ) 0 stop (0 , a, R ) (1 , , R ) 1 both with sole accepting state 0 accept the same language. Which one is more useful? COMP20121 - Section 3 – p.171/307

  27. Recognizable versus decidable Definition 16 A language is Turing-recognizable (or recursively enumerable) if there is a Turing machine which recognizes it. COMP20121 - Section 3 – p.172/307

  28. Recognizable versus decidable Definition 16 A language is Turing-recognizable (or recursively enumerable) if there is a Turing machine which recognizes it. A language is Turing-decidable (or recursive) if there is a Turing machine which recognizes it which halts for all inputs. COMP20121 - Section 3 – p.172/307

  29. Recognizable versus decidable–II • Every Turing-decidable language is Turing-recognizable, but not vice versa . COMP20121 - Section 3 – p.173/307

  30. Recognizable versus decidable–II • Every Turing-decidable language is Turing-recognizable, but not vice versa . • In order to show that a language is Turing-decidable, we have to design a machine which halts for all inputs. Such a machine will give us a definite answer, ‘yes’ or ‘no’, for every word. COMP20121 - Section 3 – p.173/307

  31. Recognizable versus decidable–II • In order to show that a language is Turing-recognizable, we merely have to design a machine which halts for all inputs which it accepts. COMP20121 - Section 3 – p.174/307

  32. Recognizable versus decidable–II • In order to show that a language is Turing-recognizable, we merely have to design a machine which halts for all inputs which it accepts. • With a Turing-recognizable language, we may never be certain that some given word really does not belong to the language. COMP20121 - Section 3 – p.174/307

  33. C-F languages are Turing-decidable Proposition 3.1 Every context-free language is Turing-decidable. Biggest problem: Create machine which terminates for all inputs. COMP20121 - Section 3 – p.175/307

  34. C-F languages are Turing-decidable Proposition 3.1 Every context-free language is Turing-decidable. The proof requires the following. COMP20121 - Section 3 – p.175/307

  35. C-F languages are Turing-decidable Proposition 3.1 Every context-free language is Turing-decidable. The proof requires the following. • Convert grammar into Chomsky normal form (Chomsky nf) . COMP20121 - Section 3 – p.175/307

  36. C-F languages are Turing-decidable Proposition 3.1 Every context-free language is Turing-decidable. The proof requires the following. • Convert grammar into Chomsky normal form (Chomsky nf) . • We haven’t covered this, so we will only describe the properties of this normal form here. COMP20121 - Section 3 – p.175/307

  37. C-F languages are Turing-decidable Proposition 3.1 Every context-free language is Turing-decidable. The proof requires the following. • Convert grammar into Chomsky normal form (Chomsky nf) . • Then a string of length n will be generated after at most 2 n − 1 applications of a production rule. COMP20121 - Section 3 – p.175/307

  38. C-F languages are Turing-decidable The proof requires the following. • Convert grammar into Chomsky nf . • There is a TM to do this. COMP20121 - Section 3 – p.176/307

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend