turing machines
play

Turing Machines Context-Free Languages n b n R a ww Regular - PDF document

Review Languages and Grammars Alphabets, strings, languages Regular Languages Deterministic Finite and Nondeterministic Automata Equivalence of NFA and DFA and Minimizing a DFA CS 301 - Lecture 19 Regular Expressions


  1. Review • Languages and Grammars – Alphabets, strings, languages • Regular Languages – Deterministic Finite and Nondeterministic Automata – Equivalence of NFA and DFA and Minimizing a DFA CS 301 - Lecture 19 – Regular Expressions – Regular Grammars Turing Machines – Properties of Regular Languages – Languages that are not regular and the pumping lemma • Context Free Languages – Context Free Grammars Fall 2008 – Derivations: leftmost, rightmost and derivation trees – Parsing and ambiguity – Simplifications and Normal Forms – Nondeterministic Pushdown Automata – Pushdown Automata and Context Free Grammars – Deterministic Pushdown Automata – Pumping Lemma for context free grammars – Properties of Context Free Grammars • Turing Machines The Language Hierarchy ww ? n n n ? a b c Turing Machines Context-Free Languages n b n R a ww Regular Languages a * a * b * 1

  2. Languages accepted by Tape A Turing Machine Turing Machines ...... ...... ww n n n a b c Read-Write head Context-Free Languages Control Unit n b n R a ww Regular Languages a * a * b * ...... ...... The Tape No boundaries -- infinite length Read-Write head ...... ...... The head at each time step: Read-Write head 1. Reads a symbol 2. Writes a symbol The head moves Left or Right 3. Moves Left or Right 2

  3. Example: Time 1 Time 0 ...... ...... a b k c ...... ...... a a c b Time 2 Time 1 ...... ...... f ...... ...... a c k a c b k a b 1. Reads 1. Reads f 2. Writes k 2. Writes 3. Moves Left 3. Moves Right The Input String Input string Input string Blank symbol Blank symbol ...... ...... ...... ...... a a c a a c b b ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ head head Head starts at the leftmost position Remark: the input string is never empty of the input string 3

  4. Example: Time 1 States & Transitions Write ...... ...... Read a a c Move Left b ◊ ◊ ◊ ◊ ◊ q 1 a b , L → current state q q 1 2 Move Right a b , R → q q a b , R → 2 1 q q 1 2 Example: Time 1 Time 1 ...... ...... ...... ...... a a c a a c b b ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ q q 1 1 Time 2 Time 2 ...... ...... ...... ...... a c a c b b b b ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ q q 2 2 a b , R a b , L → → q q q q 1 2 1 2 4

  5. Example: Time 1 Determinism ...... ...... a a c b Turing Machines are deterministic ◊ ◊ ◊ ◊ ◊ Not Allowed Allowed q 1 a b , R q a b , R q → → 2 Time 2 2 ...... ...... g a c b b ◊ ◊ ◊ ◊ q q 1 1 q q 3 a d , L 3 q b d , L → → 2 g , R ◊ → q q No lambda transitions allowed 1 2 Partial Transition Function Example: Halting ...... ...... a a c b ◊ ◊ ◊ ◊ ◊ The machine halts if there are q no possible transitions to follow 1 Allowed: a b , R q → 2 No transition q 1 for input symbol c q 3 b d , L → 5

  6. Example: Final States q q Allowed 1 2 ...... ...... a b a c ◊ ◊ ◊ ◊ ◊ q 1 Not Allowed q q 1 2 a b , R q → 2 No possible transition • Final states have no outgoing transitions q 1 HALT!!! q b d , L 3 • In a final state the machine halts → Acceptance Turing Machine Example If machine halts A Turing machine that accepts the language: Accept Input in a final state aa * If machine halts a a , R → in a non-final state Reject Input or , L ◊ → ◊ q q If machine enters 0 1 an infinite loop 6

  7. a a a a a a Time 0 Time 1 ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ q q 0 0 a a , R a a , R → → , L , L ◊ → ◊ ◊ → ◊ q q q q 0 1 0 1 Time 2 a a a Time 3 a a a ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ q q 0 0 a a , R a a , R → → , L , L ◊ → ◊ ◊ → ◊ q q q q 0 1 0 1 7

  8. Rejection Example a a a Time 4 ◊ ◊ ◊ ◊ q a a Time 0 b 1 ◊ ◊ ◊ ◊ q 0 a a , R → Halt & Accept a a , R → , L ◊ → ◊ q q 0 1 , L ◊ → ◊ q q 0 1 Infinite Loop Example Time 1 a a b ◊ ◊ ◊ ◊ q 0 b b , L → No possible Transition a a , R → Halt & Reject a a , R → , L ◊ → ◊ q q 0 1 , L ◊ → ◊ q q 0 1 8

  9. Time 0 a a Time 1 a a b b ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ q q 0 0 b b , L b b , L → → a a , R a a , R → → , L , L ◊ → ◊ ◊ → ◊ q q q q 0 1 0 1 Time 2 a a b Time 2 a a b ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ q 0 q 0 Time 3 a a b ◊ ◊ Infinite loop ◊ ◊ q 0 b b , L → a a a a , R Time 4 b → ◊ ◊ ◊ ◊ q 0 , L ◊ → ◊ q q 0 1 Time 5 a a b ◊ ◊ ◊ ◊ q 0 9

  10. Turing Machine Example Because of the infinite loop: n b n Turing machine for the language { a } • The final state cannot be reached • The machine never halts y y , R y y , L → q → 4 y y , R → a a , R a a , L → → , L ◊ → ◊ • The input is not accepted y y , R a x , R b y , L → → → q q q q 3 0 2 1 x x , R → a a x a Time 0 b b Time 1 b b ◊ ◊ ◊ ◊ ◊ ◊ q q 0 1 y y , L y y , L y y , R y y , R → → q → q → 4 4 y y , R y y , R → a a , R a a , L → a a , R a a , L → → → → , L , L ◊ → ◊ ◊ → ◊ y y , R a x , R b y , L y y , R a x , R b y , L → → → → → → q q q q q q q q 3 0 1 2 3 0 1 2 x x , R x x , R → → 10

  11. Time 2 x a Time 3 x a y b b b ◊ ◊ ◊ ◊ ◊ ◊ q q 1 2 y y , R y y , L y y , R y y , L → → q → q → 4 4 y y , R y y , R → a a , R a a , L → a a , R a a , L → → → → , L , L ◊ → ◊ ◊ → ◊ y y , R a x , R y y , R a x , R b y , L b y , L → → → → → → q q q q q q q q 3 0 2 3 0 2 1 1 x x , R x x , R → → x a y x a y Time 4 b Time 5 b ◊ ◊ ◊ ◊ ◊ ◊ q q 2 0 y y , L y y , L y y , R y y , R → → q → q → 4 4 y y , R y y , R → a a , R a a , L → a a , R a a , L → → → → , L , L ◊ → ◊ ◊ → ◊ y y , R a x , R b y , L y y , R a x , R b y , L → → → → → → q q q q q q q q 3 0 1 2 3 0 1 2 x x , R x x , R → → 11

  12. Time 6 x x y Time 7 x x y b b ◊ ◊ ◊ ◊ ◊ ◊ q q 1 1 y y , R y y , L y y , R y y , L → → q → q → 4 4 y y , R y y , R → a a , R a a , L → a a , R a a , L → → → → , L , L ◊ → ◊ ◊ → ◊ y y , R a x , R y y , R a x , R b y , L b y , L → → → → → → q q q q q q q q 3 0 2 3 0 2 1 1 x x , R x x , R → → x x y y x x y y Time 8 Time 9 ◊ ◊ ◊ ◊ ◊ ◊ q q 2 2 y y , L y y , L y y , R y y , R → → q → q → 4 4 y y , R y y , R → a a , R a a , L → a a , R a a , L → → → → , L , L ◊ → ◊ ◊ → ◊ y y , R a x , R b y , L y y , R a x , R b y , L → → → → → → q q q q q q q q 3 0 1 2 3 0 1 2 x x , R x x , R → → 12

  13. Time 10 x x y y Time 11 x x y y ◊ ◊ ◊ ◊ ◊ ◊ q q 0 3 y y , R y y , L y y , R y y , L → → q → q → 4 4 y y , R y y , R → a a , R a a , L → a a , R a a , L → → → → , L , L ◊ → ◊ ◊ → ◊ y y , R a x , R y y , R a x , R b y , L b y , L → → → → → → q q q q q q q q 3 0 2 3 0 2 1 1 x x , R x x , R → → x x y y x x y y Time 12 Time 13 ◊ ◊ ◊ ◊ ◊ ◊ q q 3 4 Halt & Accept y y , L y y , L y y , R y y , R → → q → q → 4 4 y y , R y y , R → a a , R a a , L → a a , R a a , L → → → → , L , L ◊ → ◊ ◊ → ◊ y y , R a x , R b y , L y y , R a x , R b y , L → → → → → → q q q q q q q q 3 0 1 2 3 0 1 2 x x , R x x , R → → 13

  14. Observation: Formal Definitions If we modify the n b n machine for the language { a } for Turing Machines we can easily construct n n n { a b c } a machine for the language Transition Function Transition Function a b , R c d , L → → q q q q 1 2 1 2 ( q , a ) ( q , b , R ) ( q , c ) ( q , d , L ) δ = δ = 1 2 1 2 14

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