1 / 31

CSCI 3130: Formal languages and automata theory Tutorial 7

CSCI 3130: Formal languages and automata theory Tutorial 7. Chin. Reminder. Homework 4 is due at 23:59, today !. Turing Machines. current state. a / b L. q 1. q 2. …. a. b. a. ☐. Replace a with b , and move head left. new state. a / b L. q 1. q 2. …. a. b. b. ☐.

Download Presentation

CSCI 3130: Formal languages and automata theory Tutorial 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI 3130: Formal languagesand automata theoryTutorial 7 Chin

  2. Reminder • Homework 4 is due at 23:59, today!

  3. Turing Machines current state a/bL q1 q2 … a b a ☐ Replace a with b, and move head left new state a/bL q1 q2 … a b b ☐

  4. Turing Machines: Low-level Design • Useful tools • Move to left/right until pointing to ‘x’ S = {a, b, x} G= {a, b, x, ☐} a b a x b ☐ … a/a R b/b R q1 a b a x b ☐ …

  5. Turing Machines: Low-level Design • Useful tools • Go to first symbol of the tape S = {a, b, x} G= {a, b, x, a, b, x, ☐} At the beginning Now, use tool 1.    a b a x b ☐ … q0 q1 a b a x b ☐ …     b/b R a/a R x/x R

  6. Turing Machines: Low-level Design • Useful tools • Go to last symbol of the tape S = {a, b, x} Use component 1, then go 1 step to the left. G= {a, b, x, ☐} x/x R a b a x b ☐ … a/a R b/b R ☐/☐ L q1 a b a x b ☐ … a b a x b ☐ …

  7. Turing Machines • Useful tips • Check if the input is in the right form to • reduce the possible inputs you have to deal with later

  8. Turing Machines • Exercise • L1 = {0n1n : n ≥ 0}

  9. Turing Machines L1 = {0n1n : n ≥ 0} High-level idea: If input is e, accept Check if the string is of the form 00*11* For each ‘0’ replace with ‘x’ find the first ‘1’ on the right and cross it Check if everything on the tape is ‘x’

  10. Turing Machines L1 = {0n1n : n ≥ 0} Implementation: If input is e, accept ☐/☐ R q0 qacc

  11. Turing Machines L1 = {0n1n : n ≥ 0} Implementation: Check if the string is of the form 00*11* 0/0 R 1/1 R 0/0 R 1/1 R ☐/☐ L q0 q1 q2

  12. Turing Machines L1 = {0n1n : n ≥ 0} Implementation: Check if the string is of the form 00*11* (Go back to the first position) For each ‘0’ replace with ‘x’ find the first ‘1’ on the right and cross it Check if everything on the tape is ‘x’

  13. Turing Machines L1 = {0n1n : n ≥ 0} Implementation: Go back to the first position q0 q1 0/0 L 1/1 L  0/0 R q1

  14. Turing Machines L1 = {0n1n : n ≥ 0} Implementation: For each ‘0’ (resp. ‘0’) replace with ‘x’ (resp. ‘x’) find the first ‘1’ on the right and cross it  

  15. Turing Machines L1 = {0n1n : n ≥ 0} Possible situations: x 0 0 1 1 1 ☐ …  x 0 0 x 1 1 ☐ …  x x 0 x x ☐ …  x x x x 1 1 ☐ … 

  16. Turing Machines L1 = {0n1n : n ≥ 0} Implementation: For each ‘0’ (resp. ‘0’) replace with ‘x’ (resp. ‘x’) find the first ‘1’ on the right and cross it   x/x R 0/0 R x 0 0 x 1 1 ☐ …  0/x R 1/x L q1 q2 q3 x x 0 x x 1 ☐ … 

  17. Turing Machines L1 = {0n1n : n ≥ 0} Implementation: For each ‘0’ (resp. ‘0’) replace with ‘x’ (resp. ‘x’) find the first ‘1’ on the right and cross it How to go back to the left after each iteration?   x/x R x x 0 x x 1 ☐ …  x/x L 0/0 L 0/0 R 0/0 L 0/x R 1/x L q4 q1 q2 q3 x/x R x x 0 x x 1 ☐ …  x/x R  

  18. Turing Machines L1 = {0n1n : n ≥ 0} Implementation: For each ‘0’ (resp. ‘0’) replace with ‘x’ (resp. ‘x’) find the first ‘1’ on the right and cross it What will happen after the last iteration?   x/x R x x x x x x ☐ …  x/x L 0/0 L 0/0 R 0/0 L 0/x R 1/x L q4 q1 q2 q3 x/x R x x x x x x ☐ …  x/x R  

  19. Turing Machines L1 = {0n1n : n ≥ 0} Implementation: Check if everything on the tape is ‘x’ x/x R ☐/☐ R q2 qacc x/x R x/x L 0/0 L 0/0 R 0/0 L x x x x x x ☐ … ☐ 0/x R 1/x L  q4 q1 q2 q3 x/x R x/x R x/x R     x x x x x x ☐ … ☐ 

  20. Turing Machines • If input is e, accept • Check if the string is of the form 00*11* • (Go back to the first position) • For each ‘0’ • replace with ‘x’ • find the first ‘1’ on the right and cross it • Check if everything on the tape is ‘x’ L1 = {0n1n : n ≥ 0} Implementation: Putting everything together x/x R ☐/☐ R q0 qacc ☐/☐ R q2 qacc 0/0 R 1/1 R x/x R x/x L 0/0 L 0/0 R  0/0 R 0/0 R 1/1 R ☐/☐ L q0 q1 q2 0/0 L 0/x R 1/x L q4 q1 q2 q3 x/x R 0/0 L x/x R x/x R     1/1 L q0 q1 q1

  21. Turing Machines • If input is e, accept • Check if the string is of the form 00*11* • (Go back to the first position) • For each ‘0’ • replace with ‘x’ • find the first ‘1’ on the right and cross it • Check if everything on the tape is ‘x’ L1 = {0n1n : n ≥ 0} Implementation: Putting everything together x/x R 0/0 L ☐/☐ R q8 qacc 1/1 L ☐/☐ R 0/0 R 1/1 R x/x R x/x L 0/0 L 0/0 R q3  0/0 R 1/1 R ☐/☐ L q0 q1 q2   0/x R 0/0 L 0/x R 1/x L q7 q4 q5 q6 x/x R x/x R x/x R    

  22. Variants of Turing Machines • Turning machine with left reset • The machine’s head can move one symbol to the right, or • jump to the leftest position of the tape • It cannot move one symbol to the left Show that it is equivalent to a Turing Machine.

  23. Variants of Turing Machines Show that TM with left resetis equivalent to a TM • Two steps • Show how to simulate a TM with left reset on a TM • Show how to simulate a TM on a TM with left reset

  24. Variants of Turing Machines • Show how to simulate a TM with left reseton a TM • How to go to first symbol of the tape? e.g. a/b reset • S = {a, b, x} G= {a, b, x, a, b, x, ☐} At the beginning To reset    a b a x b ☐ … q0 q1 a b a x b ☐ …     a/a R b/b R x/x R x/x L a/a L b/b L a b a x b ☐ …  q1 a b a x b ☐ … 

  25. Variants of Turing Machines • Show how to simulate a TM with left reseton a TM • Every time you change the symbol in the first position • e.g. a / bR • Add dots to the symbols • e.g. a / bR   a b a x b ☐ … a b a x b ☐ …  b b a x b ☐ … b b a x b ☐ … 

  26. Variants of Turing Machines • Show how to simulate a TM on a TM with left reset Idea: First, mark the current position with a dot Then reset and mark the first position with a * Reset While (the dot is not one symbol to the right of the * position) Move the star to one position to the right Now the star is at the position you want to reach Remove the dot, reset, and go to the star position . … * . … … * . …

  27. Variants of Turing Machines . * … While (the dot is not one symbol to the right of the * position) Move the star to one position to the right • How? • reset • Go to the * position • Move one position to the right • If it is a dot, done Else mark it with a * • reset • Find the first * and remove it . … * . * … . * * … . * * … . … * * . * …

  28. Variants of Turing Machines • Show how to simulate a TM on a TM with left reset • e.g. a/x L a b a x b ☐ … a b x b b ☐ …

  29. Variants of Turing Machines • Show how to simulate a TM on a TM with left reset • e.g. a/x L • a/x reset • a/a reset • a/a R • b/b reset a b a x b ☐ …  * a b x x b ☐ … *  * a b x x b ☐ … *  a b x x b ☐ … *  a b x x b ☐ … * * 

  30. Variants of Turing Machines • Show how to simulate a TM on a TM with left reset • e.g. a/x L • a/a R • b/b R • x/x reset • a/aR Done. a b x x b ☐ … *  * * * a b x x b ☐ … *   a b x x b ☐ … *

  31. End • Questions?

More Related