CSCI 2670
Introduction to Theory of
Computing
October 6, 2005
Agenda
• Yesterday
– Variants of Turing machines
• Allow “stay put” state
• Multiple tapes
• Today
– Quick revisit of multiple tapes
– Non-determinism
• Prove equivalence of deterministic and
nondeterministic Turing machines
– Enumerators
• Prove equivalence of enumerators and
deterministic Turing machines
October 6, 2005
2
Announcements
• Homework due next Tuesday
– 3.7, 3.15 b & c, 3.16 d
• 3.7 and 3.15 are same in both texts
• 3.16 d – Show the collection of Turingrecognizable languages is closed under the
operation of intersection.
October 6, 2005
3
Corollary
Corollary: A language is Turingrecognizable if and only if some
multitape Turing machine recognizes
it.
October 6, 2005
4
Example
• Using 2-tape Turing machine, write a
copy machine
• Copy tape 1 to tape 2
• Move tape 1 to beginning
• Copy tape 1 to tape 2
• Accept
October 6, 2005
5
Copy machine
{a,~}→ {a,a},{R,R}
{b,~}→ {b,b},{R,R}
{a,~}→ {x,a},{R,R}
{b,~}→ {y,b},{R,R}
qreject
{a,~}→ {L,S}
{a,~}→ {a,a},{R,R}
{b,~}→ {L,S}
~,~ → {L,S}
{b,~}→ {b,b},{R,R}
{x,~} → {a,a},{R,R}
{y,~} → {b,b},{R,R}
{~,~} → {L,L}
{~ ,~}→ {R,R}
qaccept
October 6, 2005
6
Copy machine
qreject
a→R
b→R
a→ x,R
~ → x,R
b→ y,R
a→R
b→R
~ → a,R
a→L
b→L
~→L
x→L
y→L
a→L
b→L
x → a,R
y → b,R
a→ x,R
b→ y,R
~ → y,R
~→L
a,b,x,y → R
~ → b,R
a,b,x,y → R
x → a,R
y → b,R
qaccept
October 6, 2005
7
Nondeterministic Turing machines
• Same as standard Turing machines,
but may have one of several choices
at any point
δ : Q × Г → P(Q × Г × {L,R})
October 6, 2005
8
Equivalence of machines
Theorem: Every nondeterministic
Turing machine has an equivalent
deterministic Turing machine
Proof method: construction
Proof idea: Use a 3-tape Turing
machine to deterministically simulate
the nondeterministic TM. First tape
keeps copy of input, second tape is
computation tape, third tape keeps
track of choices.
October 6, 2005
9
Proof idea
M
0 1 0 1 ~ ~~ ~
Input tape
never changes
a a # 0 1 ~ ~ ~
Computation
tape
1 1 2 1 3~ ~ ~
Decision path
Try new decision paths until the string is accepted
October 6, 2005
10
Intuition
• Consider the nondeterministic
calculations as a tree
– Each node represents a configuration
– A node for configuration C1 has one child
for each configuration C2 such that C1
yields C2
– Root of tree is configuration q1w
– A configuration may appear more than
once in the tree
October 6, 2005
11
Example
• Nondeterministic TM that accepts
{ww | w {a,b}*}
• Use 2 tapes
• Copy input to tape 2
• Position heads at beginning of tapes
• Move both heads right simultaneously
October 6, 2005
12
Nondeterministic solution
• Nondeterministically choose the
midpoint
– Mark this point on tape 2 and return
tape 2’s head to beginning
• Compare strings
– If tape head points to ~ on tape 1 and
midpoint marker on tape 2 then accept
– Otherwise, if all possible midpoints have
been tried then reject
– Otherwise, try a new midpoint
October 6, 2005
13
…
Tree representation
October 6, 2005
14
Deterministic equivalent
• Assume midpoint is at beginning
– If so accept
– If not …
• Assume midpoint is after first symbol
– If so accept
– If not …
• Assume midpoint is after second symbol
– If so accept
– If not …
• etc. …
October 6, 2005
15
How should it search the tree?
• Breadth first search
– Search all possibilities involving k steps
before searching any possibilities
involving (k+1) steps
• What’s wrong with depth first
search?
– If some sequence of choices results in
never reaching a halting state, we will
never get to the accept state
October 6, 2005
16
When does it halt?
• When it reaches an accept state
– Return accept
October 6, 2005
17
Will it halt on strings in the language?
• Yes
– Let b be the largest number of children
of any node
• Can we be sure b is finite?
– Let k be the minimum number of steps it
takes to get to the accept state
– This method will take at most bk steps to
get to the accept state
October 6, 2005
18
What about strings not in the language?
• Won’t halt
– That’s okay
October 6, 2005
19
Equivalence of approaches
Corollary: A language is Turingrecognizable if and only if some
nondeterministic Turing machine
recognizes it.
October 6, 2005
20
Equivalence of approaches
Corollary: A language is Turingdecidable if and only if some
nondeterministic Turing machine
decides it.
Proof: Very similar to the proof we
just did
October 6, 2005
21
Enumerators
• Instead of reading an input and
processing it, enumerators start with
an empty tape and print out strings in
aaba
Σ*
bbcc
aaaaabb
M
Printer
1 1 2 1 3~ ~ ~
October 6, 2005
22
Machine equivalence
Theorem: A language is Turingrecognizable if and only of some
enumerator enumerates it.
Proof technique: Construction in each
direction
October 6, 2005
23
TM accept enumerator language
• TM = “On input w:
– Run enumerator E. Every time E prints a
string, compare it to w.
– If w appears in the output, accept.”
October 6, 2005
24
© Copyright 2025 Paperzz