Presentation is loading. Please wait.

Presentation is loading. Please wait.

Turing Machines.

Similar presentations


Presentation on theme: "Turing Machines."— Presentation transcript:

1 Turing Machines

2 Turing-Machine Theory
The purpose of the theory of Turing machines is to prove that certain specific languages have no algorithm. Reductions are used to prove more common questions are undecidable.

3 Turing Machines Regular and CF languages are both recognized by a particular type of machine. Regular: Finite Automata (Deterministic, Nondeterministic). Context Free: Pushdown Automata, CFG. Both types of machine are limited. Regular: No memory. Context Free: A restricted type of memory (first-in, last-out). Neither model is acceptable as a general model of computation Clearly some machine should be able to recognize strings in {w#w|w ∈ {0, 1}* } (which is not a CFL). Turing Machines (TMs) are. They are the canonical model for computation. To be computable means to be computable by a Turing Machine

4 Picture of a Turing Machine
Action: based on the state and the tape symbol under the head: change state, rewrite the symbol and move the head one square. State . . . . . . A B C A D Infinite tape with squares containing tape symbols chosen from a finite alphabet

5 Why Turing Machines? Why not deal with C programs or something like that? Answer: You can, but it is easier to prove things about TM’s, because they are so simple. And yet they are as powerful as any computer. More so, in fact, since they have infinite memory.

6 Finite automata to Turing Machines
A Turing machine can both write on the tape and read from it The read write head can move both to left and right The tape is infinite Once accept/reject states are reached, the computation terminates at once

7 Turing-Machine Formalism
A TM is described by: A finite set of states (Q, typically). An input alphabet (Σ, typically). A tape alphabet (Γ, typically; contains Σ). A transition function (δ, typically). A start state (q0, in Q, typically). A blank symbol (B, in Γ- Σ, typically). All tape except for the input is blank initially. A set of final states (F ⊆ Q, typically).

8 The Transition Function
Takes two arguments: A state, in Q. A tape symbol in Γ. δ(q, Z) is either undefined or a triple of the form (p, Y, D). p is a state. Y is the new tape symbol. D is a direction, L or R.

9 Actions of the TM If δ(q, Z) = (p, Y, D) then, in state q, scanning Z under its tape head, the TM: Changes the state to p. Replaces Z by Y on the tape. Moves the head one square in direction D. D = L: move left; D = R; move right.

10 Example: Turing Machine
This TM scans its input right, looking for a 1. If it finds one, it changes it to a 0, goes to final state f, and halts. If it reaches a blank, it changes it to a 1 and moves left.

11 Example: Turing Machine – (2)
States = {q (start), f (final)}. Input symbols = {0, 1}. Tape symbols = {0, 1, B}. δ(q, 0) = (q, 0, R). δ(q, 1) = (f, 0, R). δ(q, B) = (q, 1, L).

12 Simulation of TM δ(q, 0) = (q, 0, R) δ(q, 1) = (f, 0, R)
δ(q, B) = (q, 1, L) q B B B B

13 Simulation of TM δ(q, 0) = (q, 0, R) δ(q, 1) = (f, 0, R)
δ(q, B) = (q, 1, L) q B B B B

14 Simulation of TM δ(q, 0) = (q, 0, R) δ(q, 1) = (f, 0, R)
δ(q, B) = (q, 1, L) q B B B B

15 Simulation of TM δ(q, 0) = (q, 0, R) δ(q, 1) = (f, 0, R)
δ(q, B) = (q, 1, L) q B B B

16 Simulation of TM δ(q, 0) = (q, 0, R) δ(q, 1) = (f, 0, R)
δ(q, B) = (q, 1, L) q B B B

17 Simulation of TM δ(q, 0) = (q, 0, R) δ(q, 1) = (f, 0, R)
δ(q, B) = (q, 1, L) f No move is possible. The TM halts and accepts. B B B

18 Example 2 B = {w#w | w Є {0,1}* Repeatedly do: Mark the first “unmarked” symbol from the beginning and zig-zag across the tape to its corresponding position on the other side of the # to check if they are same (need to remember what you see). If so mark, otherwise reject Stop when there are no unmarked symbols remaining to the left of #. If there are still symbols left on the right, reject. Else accept.

19

20 δ 1 # B x q0 (start) (q1,x,R) (q2,x,R) (q3,#,R) q_rej (q0,x,R) q1 (see 0) (q1,0,R) (q1,1,R) (q4,#,R) q2 (see 1) (q2,0,R) (q2,1,R) (q5,#,R) q3 (left input finished) q_acc (q3,x,R) q4 (match 0) (q6,x,L) (q4,x,R) q5 (match 1) (q5,x,R) q6 (go back) (q6,0,L) (q6,1,L) (q6,#,L) (q0,B,R)

21 Instantaneous Descriptions of a Turing Machine
Initially, a TM has a tape consisting of a string of input symbols surrounded by an infinity of blanks in both directions. The TM is in the start state, and the head is at the leftmost input symbol.

22 TM ID’s – (2) An ID is a string q,x, where x is the tape between the leftmost and rightmost nonblanks (inclusive). The current state is q x is the tape symbol scanned (marked with an arrow). If arrow is at the right end, it is scanning B.

23 TM ID’s – (3) As for PDA’s we may use symbols ⊦ and ⊦* to represent “becomes in one move” and “becomes in zero or more moves,” respectively, on ID’s. Example: The moves of the previous TM are q,00⊦q,00⊦q,00 ⊦q,001⊦q,001⊦f,000

24 ID’s for w#w Initial tape: …BB01#01BB…
q0,01#01 ⊦ q1, x1#01 ⊦* q4,x1#01 ⊦q6,x1#x1 ⊦* q0,x1#x1 ⊦* q2,xx#x1 ⊦* q5,xx#x1 ⊦q6,x1#xx ⊦* q0,xx#xx ⊦* q3,xx#xx ⊦* qacc,xx#xx

25 Languages of a TM A Turing Machine M defines a language by final state, as usual. L(M) = {w | q0w⊦*I, where I is an ID with a final state}. L(M), language of M (the language recognized by M), is the set of strings accepted by M

26 Recursive vs Recursively Enumerable
Turing recognizable or Recursively enumerable A language is Turing recognizable or Recursively Enumerable if there is a Turing machine accepting it Turing decidable or recursive A language is decidable (or recursive) if there is a Turing machine accepting it, which has the additional property that it halts on all possible inputs

27 Recursive vs Recursively Enumerable
It is possible for a TM to never reach a halting configuration. It might instead infinitely loop there are 3 outcomes: accept, reject, loop If TM accepts or rejects for all inputs then it is a decidable (recursive) language. Every decidable lang. is R.E. but not the converse

28 decidable  RE  all languages
Decidability regular languages context free languages all languages decidable RE decidable  RE  all languages undecidable

29 Extentions to Turing Machine
Multitape TM Nondeterministic TM Multihead TM Multistack PDA All are equivalent, any language accepted by a TM is accepted by any of them and vice versa

30


Download ppt "Turing Machines."

Similar presentations


Ads by Google