Download presentation
Presentation is loading. Please wait.
1
Computation Theory Introduction to Turing Machine
2
Turing Machines Proposed by Alan Turing, 1936. England “ Turing Award ” control ab ab BB BB … infinite tape B : blank symbol
3
Differences between finite automata and Turing machine 1.A Turing machine can both write on the tape and read from it. 2.The read-write head can move both to the left and to the right. 3.The tape is infinite. 4.The special states for rejecting and accepting take immediate effect.
4
Consider a Turing machine M 1 for testing membership in the language B={w#w : w {0,1} * } eg. 0 1 1 0 0 0 # 0 1 1 0 0 0 B … X 1 1 0 0 0 # 0 1 1 0 0 0 B … : X 1 1 0 0 0 # X 1 1 0 0 0 B … : X 1 1 0 0 0 # X 1 1 0 0 0 B … X X 1 0 0 0 # X 1 1 0 0 0 B … : X X X X X X # X X X X X X B …
5
M 1 = On input string w : 1.Scan the input to be sure that it contains a single # symbol. If not, reject. 2.Zig-zap across # on either side to check on whether these positions contain the same symbol. If not, reject. Cross off symbols as they checked. 3.If any symbols remain, reject; otherwise accept.
6
Formal definition of a Turing machine: δ : Q×Γ→ Q×Γ×{L,R} transition function. δ (q,a) = (r,b,L) q a r b
7
Def: A Turing Machine is a 7-tuple (Q, Σ, Γ, S, q 0, q accept, q reject ), where Q, Σ, Γ are all finite sets and 1.Q: set of states, 2.Σ: the input alphabet NOT containing the special blank symbol B, 3.Γ: the tape alphabet, where {B} Γ and Σ Γ, 4.δ:Q × Γ → Q × Γ ×{L,R} ~ transition func. 5.q 0 Q is the start state, 6.q accept Q is the accept state, and 7.q reject Q is the reject state, where q reject ≠ q accept
8
As a Turing machine computes, it may halt with ‘ accept ’ or ‘ reject ’, or it may never halt! During computation, changes occur in 1. the current state, 2. the current tape contents, and 3. the current head location. The above three items form a “ configuration ” of the Turing machine.
9
Write uqv for the configuration where q is the current state, uv is the current contents, the current head location is the first symbol of v. 1011q T 0111 Let C 1 and C 2 be two configurations. Say that C 1 yields C 2, if the Turing machine can legally go from C 1 to C 2 in a single step. 101101111B B…B… qTqT uaq i bv yeilds uq j acv if δ( q i, b )=( q j, c,L) a,b Γ, u,v Γ *
10
uaq i bv yields uacq j v if δ( q i, b )=( q j, c,R) q i bv yields q j cv if the transition is right moving. We don’t move the head out of bound! We don’t have configuration uaq i B. Starting configuration: q 0 w Accepting configuration: the state is q accept Rejecting configuration: the state is q reject
11
halting configurations A Turing machine M accepts input w if a seq. of configurations C 1, C 2, …, C k exists where 1. C 1 is the start conf. of M on input w, 2. each C i yields C i+1, and 3. C k is an accepting configuration. The collection of strings that M accepts is the language of M, denoted L(M).
12
Def: A language is Turing-recognizable if some Turing machine recognizes it. (or recursively enumerable) r.e. Def: A language is Turing-decidable or decidable if some Turing machine decides it. (or recursive) r.
13
eg. Show a TM M that recognizes the language A={0 2 n :n 0} M= “ On input string w : 1. Sweep left to right across the tape, crossing off every other 0. 2. If in stage 1 the tape contained a single 0, accept. 3. If in stage 1 the tape contained more than a single 0 and the number of 0s was odd, reject. 4. Return the head to the left-hand and of the tape. 5. Goto 1. ”
14
eg. (Element Distinctness problem) M= “ On input w : ” 1. Place a mark on top of the leftmost tape symbol. If that symbol was not a “ # ”, reject. 2. Scan right to the next # and place a second mark on top of it. If no # is encountered before a blank symbol, only x 1 was present, so accept.
15
3. By zig-zagging,compare the two strings to the right of the marked # ’ s.If they are equal reject. 4. Move the rightmost of the two marks to the next “ # ” symbol to the right. If no # symbol is encountered before a blank symbol, move the leftmost mark to next # to its right. 5. Goto step 3.
16
eg. For ={a,b}, design a Turing Machine that accepts L={a n b n : n 1} Sol: Q={q 0,q 1,q 2,q 3,q 4 }, ={a,b} ={a,b,x,y,B}, q 4 :accept state
17
(q 0,a)=(q 1,x,R) ; (q 1,a)=(q 1,a,R) (q 1,y)=(q 1,y,R) ; (q 1,b)=(q 2,y,L) (q 2,y)=(q 2,y,L) ; (q 2,a)=(q 2,a,L) (q 2,x)=(q 0,x,R) (q 0,y)=(q 3,y,R) ; (q 3,y)=(q 3,y,R) (q 3,B)=(q 4,B,R) q 0 aabb ├ xq 1 abb ├ xaq 1 bb ├ xq 2 ayb ├ q 2 xayb ├ xq 0 ayb ├ xxq 1 yb ├ xxyq 1 b ├ xxq 2 yy ├ xq 2 xyy ├ xxq 0 yy ├ xxyq 3 y ├ xxyyq 3 B ├ xxyyBq 4
18
Variants of Turing machine 1. Multi-tape Turing Machines a Turing Machine with several tapes.
19
Thm: Every multi-tape Turing machine has an equivalent single tape Turing machine. Pf: Idea: M 01010B aaaB baB S #01010#aaa#ba#B
20
q q 0 0 0 Non-deterministic Turing Machines: Thm: Every non-deterministic TM has an equivalent deterministic TM. Pf: q0 1 q 0 D 01 xx#0 00 1xB 0
21
1.Initially tape 1 contains the input w, and tapes 2 and 3 are empty. 2.Copy tape 1 to tape 2. 3.Use tape 2 to simulate N with input w on one branch of its non-det. computation. Before each step of N consult the next symbol on tape 3 to decide which branch to move. If no symbol remains or this choice is invalid goto step 4. If reject also goto 4. 4.Increase the count on tape 3. go to step 2.
22
Corollary: A language is Turing-recognizable if and only if some non-deterministic TM recognizes it. Corollary: A language is decidable if and only if some non-deterministic TM decides it
23
Enumerators A TM with an attached printer. The language enumerated by an enumerator is the collection of all the strings that it eventually prints out. Control 0010 … Work tape Enumerator
24
Theorem: A language is Turing-recognizable if and only if some enumerator enumerates it. Pf: If an enumerator E that enumerates a language A, a TM M recognizes A. M = “ on input w 1. Run E. Every time that E outputs an string, Compare it with w. 2. If w ever appears in the output of E, accept. ”
25
If TM M recognizes a language A, we can construct an enumerator E for A. Let S 1, S 2, …… be a list of all possible strings in *. E = “ Ignore the input. 1. Repeat the following for i = 1, 2, 3, … 2. Run M for i steps on each input, S 1, S 2, …, S i, 3. If any computations accept, print out the corresponding S i. ”
26
Definition of algorithm Hilbert ’ s problems: In 1900, mathematician David Hilbert delivered a famous address at the “ International congress of Mathematicians in Paris. ” He proposed 23 mathematical problems. Hilbert ’ s tenth problem: Design an algorithm that tests whether a multi- variable polynomial has an integral root.
27
The Church-Turing Thesis In 1970, Yuri Matijasevič, building on work of Martin Davis, Hilary Putnam, and Julia Robinson, Showed that no algorithm exists for testing whether a poly. Has integral roots. Intuitive notion of algorithms Turing machine algorithms = Necessary to resolve Hilbert ’ s tenth problem
28
D = { P | P is a polynomial with an integral root} Hilbert ’ s tenth problem: Is D decidable? A special case: D 1 ={ P | P is a polynomial over x with an integral root} D 1 is decidable !
29
M1 = “ The input is a polynomial P over x Evaluate P with x to the values 0, 1, -1, 2, -2, 3, -3, …. If at any point the polynomial evaluates to 0, accepts! ” Problem 3.18: All the roots of P is between Thus, D i is decidable!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.