1 / 15

Turing Machines

Turing Machines. CS 130 Theory of Computation HMU Textbook: Chap 8. Models of computation. Finite automata and regular expressions Represent regular languages Can’t “count” Grammars and pushdown automata Represent context free languages Can count and remember symbols once Turing machines

Télécharger la présentation

Turing Machines

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. Turing Machines CS 130 Theory of ComputationHMU Textbook: Chap 8

  2. Models of computation • Finite automata and regular expressions • Represent regular languages • Can’t “count” • Grammars and pushdown automata • Represent context free languages • Can count and remember symbols once • Turing machines • Represent recursive and recursively enumerable languages • Model contemporary programs

  3. Turing Machine Model • Input tape surrounded by infinitely many blanks • Tape head can move back and forth the tape and replace current symbol … … BBBBBBB000111BBBBB TM

  4. TM definition • A Turing Machine M is a tupleM = (Q, , , , q0, B, F), where: • Q is a set of states •  is the input alphabet •  is the tape alphabet =   {B}  other tape symbols • : Q    Q    D is the state transition function mapping (state, symbol) to (state, symbol, direction);D = {,};  may be undefined for some pairs • q0 is the start state of M • Bis the blank symbol (default symbol on input tape) • F  Q is the set of accepting states or final states of M(if applicable)

  5. TM that accepts 0n1n • Q={q0,q1 ,q2,q3,q4}, ={0,1}, ={0,1,B,Y} •  defined as follows: • (q0,0) = (q1,B,) erase leftmost 0 • (q1,0) = (q1,0,) move to right until a 1(q1,Y) = (q1,Y,) is encountered, replace(q1,1) = (q2,Y,) that 1 with Y • (q2,Y) = (q2,Y,) move to left until a blank(q2,0) = (q2,0,) is encountered, then go(q2,B) = (q0,B,) back to initial state • (q0,Y) = (q3,Y,) if Y on tape go to state 3 • (q3,Y) = (q3,Y,) ensure only Y’s remain on tape(q3,B) = (q4,B,) accept once B is seen (F={q4})

  6. TM that accepts 0n1n 0,0, Y,Y, 0,0, q1 Y,Y, 0,B, 1,Y, q0 q2 B,B, Y,Y, Y,Y, q4 q3 B,B,

  7. TM that increments a bit-string • Q={q0,q1 ,q2,q3}, ={0,1}, ={0,1,B,X} •  defined as follows: • (q0,0) = (q0,0,) go to rightmost(q0,1) = (q0,1,) non-blank(q0,B) = (q1,B,) • (q1,1) = (q1,0,) replace 1’s with 0’s(q1,0) = (q2,1,) until 0/B is encountered, (q1,B) = (q2,1,) replace that 0/B with a 1 • No applicable transitions from q2 means the turing machine halts

  8. TM that increments a bit-string go to the rightmost non-blank move to the left,replacing 1s with 0s 0,0, 1,1, 1,0, 0,1, q0 B,B, q1 q2 B,1, once a B or 0 isencountered, replace it with a 1

  9. Instantaneous descriptions • Instantaneous description (ID): depicts the characteristics of the machine as transitions are carried out • For finite automata, the state of the machine and the remaining input is sufficient • For TM’s, the following are needed for an ID: • State • Symbols on the tape • Position of the tape head • Can be expressed as X1X2…Xi-1qXiXi+1…Xnwhich means the TM is in state q, the tape contains X1X2…Xn and the tape head is at Xi

  10. ID example • Suppose for the first TM example,the input is 0011 • The initial ID is q00011 • After applying the transition(q0,0) = (q1,B,), ID: q1011 • Depict this as a move: q00011 |q1011 • Next 3 transitions:(q1,0) = (q1,0,), ID: 0q111(q1,1) = (q2,Y,), ID: q20Y1(q2,0) = (q2,0,), ID: q2B0Y1 • Eventually, ID will be YYBq4 (TM accepts)

  11. TM as recognizer • A TM accepts a string w if there exists a sequence of moves fromID q0w to ID uqfv (u,v  *, qf  F) • q0w |* uqfv • In the previous example, q00011 |* YYBq4 • Given a TM M, L(M) is the set of all strings that M accepts • A language recognized by a TM is called a recursively enumerable language

  12. TM halting on input • TMs are also useful for computation • In this case, what is important is the machine halts on input w (and leaves the appropriate output on the tape) • A TM halts on input w if there exists a sequence of moves fromID q0w to ID uqixv (u,v*, x, qiQ)& (qi,x) is undefined (no transition applies) • The TM can be viewed as a function; f(w) = uxv

  13. TM as decider • It could be arranged so that the TM either leaves a YES or a NO on the input tape after processing an input string • YES means accept, NO means reject • The TM decides whether a string is acceptable • The TM in this case defines a corresponding language, in a stronger sense than a TM recognizer, because it also halts for rejected strings • The language in this case is called a recursive language (different from recursively enumerable)

  14. Hierarchy of languages TM recognizer recursively enumerable type 0 recursive TM decider context-sensitive type 1 context-free type 2 type 3 regular

  15. About TMs • Church-Turing Thesis: TMs represent what can be solved by a computer program(a mathematically unprovable statement) • Some problems cannot be solved/decided by a TM (e.g., the Halting Problem) • TMs can be deterministic or nondeterministic; the variation helps in modeling problem complexity classes (P and NP)

More Related