Turing Machines: Introduction
Turing Machines
A Turing machine (TM) consists of:
CSE303: Introduction to the
Theory of Computation
Spring 2016
An infinite tape: symbols can be read and written in any order.
• Initially the tape contains the input string.
• As the machine processes the input alphabets, it may write or read
back the previously-written information.
A deterministic, finite-state control.
C HEN -W EI WANG
• Output accept as soon as entering an accepting state.
• Output reject as soon as entering a rejecting state.
• Computation does not halt until entering an accepting or a reject state.
3 of 14
Models of Computation
• Finite Automata:
Machines with finite states.
• Pushdown Automata:
Finite automata extended with an infinite LIFO stack.
• Turing machines (TM) :
Finite automata extended with an infinite memory .
A TM can do everything that a real computer can do.
There are still certain problems that a TM cannot solve.
These problems are beyond the theoretical limits of computation .
2 of 14
Turing Machines: Formal Definition
A Turing machine (TM) is a 7-tuple (Q, ⌃, , , q0 , qaccept , qreject ):
• Q is a finite set of states.
• ⌃ is a finite set of input alphabets.
•
is a finite set of tape alphabets.
• q0 is the start state.
• qaccept is the accepting state.
[ 62 ⌃]
[ = ⌃ [ { }]
[q0 2 Q]
[qaccept 2 Q]
• qreject is the rejecting state.
[qreject 2 Q]
• is the deterministic transition function.
A TM halts its computation as soon as it enters qaccept or qreject .
: Q’ ⇥ ! Q ⇥ ⇥ {L, R}
[Q’ = Q \ {qaccept , qreject }]
4 of 14
Turing Machines: Configuration
Turing Machines: Computation (2)
• A TM configuration uqv denotes a status of computation:
q 2 Q is the current state of the finite automation.
uv represents the tape contents.
[u, v 2 ⇤ ]
The head location is at the first symbol of v .
The tape contains blank symbols following the last symbol of v .
• e.g., Configuration 1011q7 0111 denotes the following status:
• A configuration uqaccept v is an accepting configuration .
• A configuration uqreject v is a rejecting configuration .
• A halting configuration is either an accepting or a rejecting
configuration, which yields no further configurations.
• Given a TM M and an input w, if there exists a sequence
hC1 , C2 , . . . , ck i
C1 is the start configuration q0 w.
Each Ci yields Ci+1 .
IF:
Tape contents are 10110111.
Finite automation is in state q7 to process the second 0 in the tape.
Turing Machines: Computation (1)
• The start configuration is q0 w.
In both cases, we say M halts on w.
• 6 9 such sequence ) Computation loops .
Design a Turing machine M that describes
[w = w1 w2 . . . wn ]
n
L = {02 | n
) M receives input w on the leftmost n squares of the tape.
Rest of tape filled with the blank symbol .
The first blank symbol marks the end of the input.
0}
Hints:
• The tape head starts on the leftmost square of the tape.
• Given the current configuration uaqi bv
[a, b 2 , u, v 2 ⇤ ]
Leftward Move: uqj acv
[ (qi , b) = (qj , c, L)]
Rightward Move: uacqj v
[ (qi , b) = (qj , c, R)]
Sweep left to right to cross out half of the 0’s.
Sweep right to left to cross out half of the 0’s.
Keep crossing until all input alphabets are crossed out.
• # of 0’s crossed is odd ) Reject
• # of 0’s crossed is even ) Accept
In both moves, the input symbol b is overwritten by c.
6 of 14
[not halt/terminate]
7 of 14
Turing Machines: Examples (1.1)
Given a Turing machine M = (Q, ⌃, , , q0 , qaccept , qreject ) and
input string w 2 ⌃⇤ :
1]
• Ck is an accepting configuration ) M accepts w.
• Ck is a rejecting configuration ) M rejects w.
• Given a TM M, a configuration C1 yields a configuration C2 .
()
M can legally go from C1 to C2 in a single step as defined in
M’s transition function .
5 of 14
[1 i k
8 of 14
Turing Machines: Examples (1.2)
M = (Q, ⌃, , , q1 , qaccept , qreject )
• Q = {q1 , q2 , q3 , q4 , q5 , qaccept , qreject }
• ⌃ = {0}
• = {0, ⇥, }
Turing Machines: Examples (1.3)
⇥⇥q5 ⇥
⇥q5 ⇥⇥
q5 ⇥ ⇥ ⇥
q5 ⇥ ⇥ ⇥
q2 ⇥ ⇥ ⇥
⇥q2 ⇥⇥
⇥⇥q2 ⇥
⇥ ⇥ ⇥q2
⇥ ⇥ ⇥ qaccept
9 of 14
Turing Machines: Examples (1.3)
q1 0000
q2 000
⇥q3 00
⇥ 0q4 0
⇥ 0⇥q3
⇥ 0q5 ⇥
⇥q5 0⇥
q5 ⇥0⇥
q5 ⇥0⇥
q2 ⇥0⇥
⇥q2 0⇥
⇥⇥q3 ⇥
⇥ ⇥ ⇥q3
10 of 14
11 of 14
Turing Machines: Languages (1)
• Given a TM M = (Q, ⌃, , , q0 , qaccept , qreject ),
L(M) = {w : ⌃⇤ | M accepts w}
L(M) is the language of M, or the language recognized by M.
• A language L is Turing-recognizable if there exists a TM M s.t.
L(M) = L.
• A TM M is able to decide an input w if M either accepts or
rejects w, rather than looping on it.
• A language L is Turing-decidable if there exists a TM M s.t.
12 of 14
8w : L • M decides w
Turing Machines: Languages (2)
13 of 14
Index (1)
Models of Computation
Turing Machines: Introduction
Turing Machines: Formal Definition
Turing Machines: Configuration
Turing Machines: Computation (1)
Turing Machines: Computation (2)
Turing Machines: Examples (1.1)
Turing Machines: Examples (1.2)
Turing Machines: Examples (1.3)
Turing Machines: Examples (1.3)
Turing Machines: Languages (1)
Turing Machines: Languages (2)
14 of 14
© Copyright 2026 Paperzz