Академический Документы
Профессиональный Документы
Культура Документы
10/23/2019 1
Why Turing Machines?
• Observations from the two computation models
(FA and PDA):
– Limited amount of memory (can remember only their
current state).
– The way the memory is accessed (can access only from
Top of Stack).
So, neither FA nor PDA can recognize only simple
Languages (less powerful in terms of language
acceptance).
10/23/2019 2
Why Turing Machines?
• This prompts us to introduce a more powerful
model of automata approach, which recognizes
more languages that a PDA, called Turing Machine.
10/23/2019 4
Comparison with Previous Models
10/23/2019 8
Representation of
Turing Machine
There are two different to describe the
task of a Turing Machine:
–Transition Diagram
–Transition Table
10/23/2019 9
Transition Diagram
Read Write
Move Left
q1 a b, L q
2
Move Right
q1 a b, R q2
10/23/2019 10
Example:
Time 1
...... a b a c ......
q1
Time 2
...... a b b c ......
q2
q1 a b, R q2
10/23/2019 11
Transition Table
state For all Tape Symbols
(a)
Where:
qi qj, b, D qi is the current state
qj is the next state
a is the current symbol
b is the symbol to be write
D is the direction of move
10/23/2019 12
Important Definitions
• Moves of a TM
• Language Accepted by TM
10/23/2019 13
ID of Turing Machine
10/23/2019 14
Moves of Turing Machine
x1x2…xnq |— x1x2…xnyp
10/23/2019 15
Language Acceptance
• Definition: Let M = (Q, Σ, Г, δ, q0, B, F) be a TM, and let w be a
string in Σ*. Then w is accepted by M iff
q0w |—* X p Y
{w | w is in Σ* and w is accepted by M}
10/23/2019 16
Language Acceptance
• Turing Acceptable Language: A Language over some alphabet is
said to be Turing Acceptable, if there exists a TM M such that
L=L(M).
10/23/2019 17
Important observations
on TM
• Something strange can happen in a Turing
Machine:
☐/☐R = {0, 1}
qacc
input: e
q0 This machine
qrej never halts
qacc qrej
10/23/2019 19
Function 1: Language Acceptor
Three possibilities occur on a given input w :
1. The TM M eventually enters qacc and therefore halts and
accepts. (w L(M) )
10/23/2019 20
Description of Turing Machine for L1 = {w#w: w ∈ {a, b}*}
10/23/2019 21
Description of Turing Machine for L1 = {w#w: w ∈ {a, b}*}
a/aR
b/bR x/xR
#/#R a/aL
qa1 qa2 a/aL
4 b/bL
x/xR x/xL b/bL
#/#L
q0 #/#R
1 q1 ☐/☐R qacc q2 q3 qrej
8
7
everything else
4
qb1 qb2
#/#R
a/aR x/xR
b/bR
x/xR
10/23/2019 22
Function 2: Computing Device
• A function : N N is said to be computable function of
k arguments if there exists a Turing machine M halts with
a tape consisting of 0m for some m, where (i1, i2, … , ik) =
m.
10/23/2019 23
Description of Turing Machine for f(x)=x+1
Unary representation is used in order to do any arithmetic operations on a TM.
Unary representation looks as follows
0 1
1 11
2 111
3 1111
4 11111
Example: Design a Turing Machine to add 1 to any number
start in state 1
if the state is 1 and current input is 1, write 1 and move right and stay in state 1
if the current state is 1 and current input is b, write 1 and move to state 2 and move right and HALT
TM instructions:
(1,1,1,R,1)
(1,b,1,R,2)
1/1
state 2 does not exist, so halt
Let the initial configuration be: ... b 1 1 1 b ... b/1
s1 ... b 1 1 1 b ... 2 in unary representation 1 R
2 Halt
s1 ... b 1 1 1 b ...
s1 ... b 1 1 1 b ...
s1 ... b 1 1 1 b ...
s2 ... b 1 1 1 1 b ... 3 in unary representation
10/23/2019 24
Turing Machines Variants
10/23/2019 25
Variants of TM
10/23/2019 26
Two-way Infinite tape TM
a b b c c a b c c a a b b c c b b • • •.......
[
a b a • • • • • • • • • • • • • • • ...
10/23/2019 28
Non-Deterministic TM’s
Recognizers vs. Deciders
10/23/2019 29
Non-Deterministic TM
Example
Consider the non-deterministic method:
void nonDeterministicCrossOut(char c)
while()
if (read blank) go left
else
if (read c)
cross out, go right, return
OR go right// even when reading c
OR go left // even when reading c
10/23/2019 30
Non-Deterministic TM
Example
Using randomCross() put together a non-deterministic
program:
10/23/2019 32
Non-Deterministic TM
Example
A: 0XX1Xq12X2
0XX1qX12X2 | 0XX1X1q2X2 | 0XX1XXq’ 2X2
These define 3 branches of computation tree:
0XX1Xq12X2
10/23/2019 33
Non-Deterministic TM
Example
A: No. This is a TM recognizer, but not a decider.
nonDeterministicCrossOut() often enters an infinite
branch of computation since can see-saw from right to
left to right, etc. ad infinitum without ever crossing out
anything. I.e., computation tree is infinite!
Note: If you draw out state-diagrams, you will see that the
NTM is more compact, than TM version so there are
some advantages to non-determinism! Later, will
encounter examples of “efficient” nondeterministic
programs for practically important problems, with no
known efficient counterpart: The P vs. NP Problem.
10/23/2019 34
Multi-tape TM’s
A TM with more than one tape and each tape having its
own independent head is said to be a multi-tape TM.
tape 1 0 1 0 …
control …
tape 2 0 1
tape 3 1 0 0 …
10/23/2019 35
Multi-tape TM’s
0/1R
0 1 0 … 1 1 0 …
☐/1R
0/0L
0 1 … q3 q7 0 1 1 …
1 0 0 … 1 0 0 …
10/23/2019 36
Equivalence of MTM and STM
Multi-tape Turing Machines are equivalent
to single-tape Turing Machines
10/23/2019 37
Equivalence of MTM and STM
Multitape Turing Machines are equivalent
to single-tape Turing Machines
0 1 0 … G = {0, 1, ☐}
M …
0 1
1 0 0 …
S # 0 1 0 # 0 1 # 1 0 0 # …
G’ = {0, 1, ☐, 0, 1, ☐, #}
10/23/2019 38
Multitape TM’s
Formal Notation
δ : Q G Q G {L, R}
k k k
10/23/2019 39
Multitape TM’s
Conventions
10/23/2019 40
A Universal Turing Machine
10/23/2019 41
A limitation of Turing Machines:
Turing Machines are “hardwired”
Solution: UTM
• Reprogrammable machine
10/23/2019 42
Universal Turing Machine
Universal Turing Machine simulates any Turing Machine M
Input of Universal Turing Machine:
Description of transitions of M
Input string of M
M Universal Output Tape
Turing Machine for running TM-M
starting on tape w
w
10/23/2019 43
Tape 1
Three tapes
Description of M
Universal
Turing
Machine Tape 2
Tape Contents of M
Tape 3
State of M
10/23/2019 44
Alphabet Encoding
Symbols: a b c d
10/23/2019 45
State Encoding
States: q1 q2 q3 q4
Move: L R
Encoding: 1 11
10/23/2019 46
Transition Encoding
Encoding: 1 0 1 0 11 0 11 0 1
separator
10/23/2019 47
Turing Machine Encoding
Transitions:
Encoding:
Tape 1
10/23/2019 49
Language of Turing Machines
00100100101111,
(Turing Machine 2)
111010011110010101,
…… } ……
10/23/2019 50