CSCI 2670
Introduction to Theory of
Computing
October 5, 2004
Agenda
• This week
– Turing machines
– Read section 3.1
October 5, 2004
2
Announcements
• Tests will be returned tomorrow
• Tutorial sessions are suspended until
further notice
– Extended office hours while tutorials
are suspended
• Monday 11:00 – 12:00
• Tuesday 3:00 – 4:00
• Wednesday 3:00 – 5:00
October 5, 2004
3
Recap to date
• Finite automata (both deterministic
and nondeterministic) machines
accept regular languages
– Weakness: no memory
• Pushdown automata accept contextfree grammars
– Add memory in the form of a stack
– Weakness: stack is restrictive
October 5, 2004
4
Turing machines
• Similar to a finite automaton
– Unrestricted memory in the form of a
tape
• Can do anything a real computer can
do!
– Still cannot solve some problems
October 5, 2004
5
Touring machine schematic
Control
a b a ~
• Initially tape contains the input string
– Blanks everywhere else (denoted ~ in
class … different symbol in book)
• Machine may write information on the
tape
October 5, 2004
6
Touring machine schematic
Control
a b a ~
• Can move tape head to read
information written to tape
• Continues computing until output
produced
– Output values accept or reject
October 5, 2004
7
Touring machine schematic
Control
a b a ~
• Turing machine results
– Accept
– Reject
– Never halts
October 5, 2004
8
Differences between TM and FA
1. TM has tape you can read from and
write to
2. Read-write head can be moved in
either direction
3. Tape is infinite
4. Accept and reject states take
immediate effect
October 5, 2004
9
Example
• How can we design a Turing machine
to find the middle of a string?
– If string length is odd, return middle
symbol
– If string length is even, reject string
• Make multiple passes over string Xing
out symbols at end until only middle
remains
October 5, 2004
10
Processing input
1.
Check if string is empty
If so, return reject
2. Write X over first and last non-X
symbols
After this, the head will be at the second X
3. Move left one symbol
If symbol is an X, return reject (string is
even in length)
4. Move left one symbol
If symbol is an X, return accept (string is
even in length)
5. Go to step 2
October 5, 2004
11
Example
• 00110~
– First check if string is empty
– X first and last non-X symbols
• X011X~
– Move left one symbol
• X011X~
– Is symbol an X? No
– Move left one symbol
• X011X~
– Is symbol an X? No
– Write X over first and last non-X symbols
October 5, 2004
12
Example
• XX1XX~
– Move left one symbol
• XX1XX~
– Is symbol an X? No
– Move left one symbol
• XX1XX~
– Is symbol an X? Yes
– Return accept
October 5, 2004
13
Formal definition of a TM
Definition: A Turing machine is a 7tuple (Q,,,,q0,qaccept,qreject), where
Q, , and are finite sets and
1. Q is the set of states,
2. is the input alphabet not
containing the special blank symbol ~
3. is the tape alphabet, where ~
and ,
4. : QQ{L,R} is the transition
function,
October 5, 2004
14
Formal definition of a TM
Definition: A Turing machine is a 7tuple (Q,,,,q0,qaccept,qreject), where
Q, , and are finite sets and
5. q0Q is the start state,
6. qacceptQ is the accept state, and
7. qrejectQ is the reject state, where
qrejectqaccept
October 5, 2004
15
Computing with a 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!
October 5, 2004
16
Completing computation
• Continue following transition rules
until M reaches qaccept or qreject
– Halt at these states
• May never halt if the machine never
transitions to one of these states!
October 5, 2004
17
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
October 5, 2004
18
© Copyright 2026 Paperzz