Download presentation
1
CS 3240: Languages and Computation
Turing Machine
2
Turing and Turing Machine
Alan Turing (1912–1954), British mathematician/engineer. In 1936, Turing introduced his abstract model for computation in his article “On Computable Numbers, with an application to the Entscheidungsproblem” Near the same time, Alonzo Church published similar ideas and results. Turing machine is the ultimate model of computation.
3
Comparison of TM and FA TM has tape you can read from and write to
Read-write head can be moved in either direction Tape is infinite Accept and reject states take effect immediately
4
Example I Language { w#w | w {0,1}* }
How can we design a Turing machine to test its membership? Zig-zag across tape to corresponding positions on either side of # to check whether they contain same symbol. If not or if no # found, reject. Cross off symbols as they are checked When all symbols to the left of # are crossed off, if anything remain to the right o #, reject; otherwise, accept. Example: test on string $011001
5
Formal definition of TM
Definition: A Turing machine is a 7-tuple (Q,,,,q0,qaccept,qreject), where Q, , and are finite sets and Q is the set of states, is the input alphabet not containing the special blank symbol ~ is tape alphabet, where {~}, : QQ{L,R} is the transition function,
6
Formal definition of a TM
Definition: A Turing machine is a 7-tuple (Q,,,,q0,qaccept,qreject), where Q, , and are finite sets and q0Q is the start state, qacceptQ is the accept state, and qrejectQ is the reject state, where qrejectqaccept
7
More on Transition Function
Q = set of states, = tape alphabet : QQ{L,R} Given: The current internal state Q The symbol on the current tape cell Then tells us what the TM does: Changes to new internal state Q Either writes new symbol Or moves one cell left or right
8
Computing with TM M receives input w = w1w2…wn* on leftmost n squares of tape Rest of tape is blank (all ~ symbols) Head position begins at leftmost square of tape Computation follows rules of Head never moves left of leftmost square of the tape If says to move L, head stays put!
9
Completing computation
Continue following transition rules until M reaches qaccept or qreject Halt at these states May never halt if machine never reaches one of these states!
10
Turing machine notation
(qi,b)=(qk,c,D), where D = L or R, is represented by the following transition qi qk b c, D In the special case where (qi,b)=(qk,b,D), i.e., the tape is unchanged, the right-hand side will just display the direction
11
Revisiting Example I (q1, 0) = (q2, x, R);
(q2, 0) = (q2, 0, R); (q2, 1) = (q2, 1, R); (q2, #) = (q4, #, R) (q4, x)=(q4, x, R); (q4, 0)=(q6, x, L) (q1, 1) = (q3, x, R) (q3, 0) = (q3, 0, R); (q3, 1) = (q3, 1, R); (q3, #) = (q5, #, R) (q5, x)=(q5, x, R); (q5, 1)=(q6, x, L) (q6, a)=(q6, a, L) for a=0, 1, or x (q6, #)= (q7, #, L); (q7, 0)= (q7, 0, L); (q7, 1)= (q7, 1, L); (q7, x)= (q1, x, R) (q1, #) = (q8, #, R); (q8, x) = (q8, x, R); (q8, ~) = (qaccept, ~, R)
12
TM state diagram
13
Example E={#x1#x2#x3…#xn | xi {0,1}* and xi≠xj for i ≠ j}
Basic idea: Compare each pair of (xi , xj) by zig- zagging. Use special marks to replace # to indicate which pair of (xi , xj) is being compared Must take care special cases such as n=0, n=1, missing #, etc.
14
Question How to detect whether we have reached left- most cell?
Alternative 1: If leftmost cell marked by special symbol, then easy Alternative 2: Use special property that TM “stays put” at left-most cell by replacing cell with special symbol and then recover
15
TM configurations The configuration of a Turing machine is the current setting Current state Current tape contents Current tape location Notation uqv Current state = q Current tape contents = uv Only ~ symbols after last symbol of v Current tape location = first symbol of v
16
Configuration C1 yields C2
C1 yields C2 if the TM can legally go from C1 to C2 in one step Assume a, b and u, v * uaqibv yields uqkacv if (qi,b)=(qk,c,L) uaqibv yields uacqkv if (qi,b)=(qk,c,R)
17
Configuration C1 yields C2
Special cases if head is at beginning or end of tape uaqibv yields uqjacv if (qi,b)=(qk,c,L) uaqibv yields uacqkv if (qi,b)=(qk,c,R) Special case: qibv~ yields qkcv~ if (qi,b)=(qk,c,L) and tape head is at beginning of tape
18
Special configurations
Start configuration q0w Halting configurations Accepting configuration: uqacceptv Rejecting configuration: uqrejectv u, v *
19
Strings accepted by a TM
A Turing machine M accepts input sequence w if a sequence of configurations C1, C2, …, Ck exist, where C1 is the start configuration of M on input w each Ci yields Ci+1 for i = 1, 2, …, k-1 Ck is an accepting configuration
20
Language of a TM The language of M, denoted L(M), is
L(M) = {w | M accepts w} A language is called Turing-recognizable if some Turing machine recognizes it
21
Deciders A Turing machine is called a decider if every string in * is either accepted or rejected A language is called Turing-decidable if some Turing machine decides it These languages are often just called decidable
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.