Document

Other Models of Turing Machines
Wen-Guey Tzeng
Computer Science Department
National Chiao Tung University
1
TM with ‘stay’
• A Turing machine M with stay is defined by
M=(Q, , , , q0, , F)
– : Q Q{L, R, S}
2
TM with ‘multi-tracks’
• A Turing machine M with multi-tracks is
defined by, for n tracks,
M=(Q, , , , q0, , F)
– : Qn  Qn{L, R, S}
3
TM with ‘semi-infinite tape’
• A Turing machine M with semi-tape is defined
by M=(Q, , , , q0, , F)
– No moves to left are allowed at the left boundary
4
Off-line TM
• Off-line Turing machine M
– A read-only input tape
– A read-write tape
– : Q  Q{L, R}
5
TM with ‘multi-tapes’
• A Turing machine M with multi-tapes is
defined by M=(Q, , , , q0, , F)
– : Qn  Qn{L, R,}n
6
TM with ‘multi-dimensions’
• A Turing machine M with multi-dimensions is
defined by M=(Q, , , , q0, , F)
– : Q  Q{L, R, U, D}
7
Comments on variant models of TM
• Why so many models ?
– Easier to design a TM conceptually.
• They are all equivalent.
– One model can simulate another model.
8
Nondeterministic TM (NTM)
• A nondeterministic Turing machine (NTM) M
is defined by
M=(Q, , , , q0, , F)
–: Q  2Q{L, R}
9
NTM as acceptors
• w is accepted if some sequence of moves
q0w├* x1 qf x2
where qf is a final state.
• M stops (halts) and enters a final state.
10
• Example
• (q0, a)={(q1, b, R), (q2, c, L)}
q0aaa├ bq1 aa
or q0aaa├ q1 caa
11
• Computation tree for NTM
q0aaa
bq1 aa
q1caa
12
Acceptance of w by NTM
• w is accepted by NTM if
– there is a path that leads to “halt” and enters a final
state in the computation tree
q0w
x1 q f x2
z 1q 2 z 2
qf: final
13
• w is not accepted by NTM if
– NO path halts and enters a final state.
– Some paths lead to halt and enter non-final states
– Some paths does not halt
q0w
zz1qq2z2z
1 2 2
y1q3y2
q2, q3 are non-final
14
The language accepted by NTM
• The language accepted by NTM M is
L(M) = {w* : one path of q0w leads to halt
and enter a final state}
15
Equivalence of NTM and TM
• For each NTM M=(Q, , , , q0, , F), there is
another TM M’ such that L(M’)=L(M)
• Proof
– The following TM M’:
– Input: w
1. Consider the computation tree rooted at q0w
2. Expand (visit) the tree in breadth-first order
– Check the currently visited node with x1qx2
– If x1qx2 is a halting configuration and qF
then halt and enter qf (a final state in M’)
else if there are still nodes to visit, then go to the next node
3. Halt and enter a non-final state
16
q0w
...
...
...
...
x1qfx2
halt
17
• Reasoning
– If w is accepted by M
– If w is not accepted by M
18
Universal TM
• A TM M=(Q, , , , q0, , F) is a special purpose
(hardwired) computer.
– Once  is fixed, the functionality of M is fixed.
– A TM is a program
• A Universal TM Mu is a TM
– Input: TM M and w (after encoding)
– Output: M(w)
19
• A universal TM Mu simulates any other TM M.
– Take input <M, w>
– Output <M(w)>
• A general-purpose computer is actually a TMU
– It takes input a program p and runs it on w
20
Universal TM Mu
21
Three tapes
Tape 1
Description of M
Universal
Turing
Machine
Tape 2
Tape Contents of M
Tape 3
State of M
22
Encoding of TM as 0-1 string
Tape 1
Description of M
We describe Turing machine M
as a string of symbols: <M>
We encode M as a string of symbols
23
Alphabet Encoding
Symbols:

a
b
Encoding:
1
11
111
c

1111
24
State Encoding
States:
q1
q2
q3
q4
Encoding:
1
11
111
1111
Head Move Encoding
Move:
L
R
Encoding:
1
11

Transition Encoding
Transition:
Encoding:
 (q1, a)  (q2 , b, L)
1 0 11 0 11 0 1110 1
separator
26
Machine Encoding
Transitions:
 (q1, a)  (q2 , b, L)
 (q2 , b)  (q3 , c, R)
Encoding:
1 0 110 11 0 1110 1
00
11 0 1110 111 0 1111 0 11
separator
27
Example:
M=({q1, q2}, {a,b}, {a, b, }, , q1, , {q2})
• (q1, a)=(q1, b, R)
• (q1, b)=(q1, b, R)
• (q1,  )=(q2, , L)
<M> =
28
How does a TMU run?
• Search and copy
<M>
… 00 11010101101 00 …
TMU
… 01010111011010 …
current cell
11
current state
29
The set of all encoded TMs
L = { 101010101,
(Turing Machine 1)
10101011010011010110101, (Turing Machine 2)
111010111101010010101101011,
. . .
. . . }
= {<M1>, <M2>, <M3>, <M4>, … }
30
Number of elements in a set
countable
infinite
uncountable
Sets
finite
31
Countable set
• S is countable (enumerable) if
– There is a way to list (enumerate) all elements
in S
– Every element in S is listed (enumerated) in
finite steps
32
• The set of natural numbers:
N = {1, 2, 3, …} is countable
• The set of (positive) quotients:
Q+= {p/q: p and q are integers} is countable.
wrong enumeration
1/1, 1/2, 1/3, 1/4, 1/5, …, 2/1, 2/2, 2/3, …, 3/1, 3/2, 3/3…,
cannot be listed in finite steps !!
33
correct enumeration
• 1/1, 1/2, 2/1, 3/1, 2/2, 1/3, 2/3, 3/2, …
• Every element p/q is listed within (p+q)2/2 steps
34
• The set of real numbers: R is uncountable.
– Can you think of a way to list all reals and every
real is listed within finite steps ?
35
The set of all TMs is countable
• Write all 0-1 strings in the alphabetical order and
remove strings that are not encodings of TMs
• Every TM M is encoded as 0-1 string <M> of finite
length. Thus, it is listed within finite steps.
• We only have a countable number of TM’s
36