80 likes | 441 Views
Turing Machine Example. 2 n. A TM M that recognizes the language: L = {0 | n ≥ 0 } PSEUDOCODE Sweep the input string from left to right, cross out every other 0 (cuts the number of 0s in half). If in step 1, the tape had only one 0 , accept .
E N D
Turing Machine Example 2n • A TM M that recognizes the language: L = {0 | n ≥ 0 } PSEUDOCODE • Sweep the input string from left to right, cross out every other 0 (cuts the number of 0s in half). • If in step 1, the tape had only one 0, accept. • Else if the tape had an odd number of 0’s, reject. • Move the head back to the first input symbol. • Go to step 1.
Formal description of the M recognize L • M = (Q, Σ, Γ, , q0, qaccept, qreject) where: • Q = {q0, q1, q2, q3, q4, qaccept, qreject } • Σ = {0} • Γ = {0, x} • is described by the diagram in the next slides • The start , accept, reject states are q0, qaccept, and qreject respectively
State transition diagram of M x/x, L 0/0, L The symbol “x” is used to cross out symbols. q2 /,R /,L x/x, R x/x, R q0 q1 q3 0/x, R 0/, R x/x, R /, R 0/x, R 0/0, R /, R qaccept qreject q4 x/x, R /, R
Example run on input “0000”: q00000 q1000 xq300 x0q40x0xq3 x0q2xxq20xq2x0x q2x0x q1x0xxq10xxxq3x xxxq3 xxq2xxq2xxq2xxx q2xxx q1xxxxq1xxxxq1xxxxq1xxxqaccept References: http://www.cs.sunysb.edu/~cse350/slides/turing2.pdf http://www.cs.cmu.edu/~emc/flac09/lectures/Lecture8x.ppt http://www.cs.cmu.edu/~emc/flac09/lectures/Lecture9x.ppt