Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ON TURING MACHINES
b7
A MASTER'S THESIS
'
MASTER OF SCIENCE
•/
(^u^L\^ 1 L- ' TABLE OF CONTENTS
d 5/
urraoDucTioN ^
CoBDputable Nunibers
^
ELEMENTARY PROGRAMS
23
BOOLEAN FUNCTIONS ON lURING mCHINES
23
Finite Automata, Restricted Turing Machines
2U
Automata Flow Charts and Sibprograms
BOOLEAN TRANSFORMATIONS
36
ARITHMETIC OPERATIONS WITH OTHER CODES
Binary Addition, ,
Binary Division •• • • •
SUMMARY •
ACKNOWIiDGMENTS ^7
INTRODUCTION
and a confuting element. The paper tape is divided into squares urtiich
initially have zero printed on each square. The coiiputing element has a
will be reading the entry on a particular square of the tape. The next
operation will be determined by the current state and the syntool being read
scanned square, shifting to the right square or left square and then as-
Con5)utable Nunibers
.^idered as those numbers for which an algorithm exists that can be used to
compute their values. The class of computable numbers is quite large. Two
particular classes are real algebraic numbers and real transcendental niun-
no algorithm for calculating the value of the number, but yet the nunfcer
has a very definite small or large value associated with it. An example
program and the input tape of a Turing machine there is no algorithm for
determining the number of squares that will be overprinted. The tape must
be run through the given Turing machine and the overprinted squares counted
It follows that all ordinary digital computers which do not contain random
for solving the problem, while a negative solution consists of showing that
no solution exists,
problem. Finally, in 1931 Gbdel (2) showed that there were propositions U
such that neither U nor -U is provable. This in itself was not a solution
set the basis for the eventual solution of the problem by Turing,
The paper tape which moves through the computing element is potentially
infinite in length. This means that if the tape needs to be longer more
may be needed. The tape has squares into which are entered the symbols
zero or one dictated by the computing element. The initial entries are
zeros.
The con^juting element contains the states of the Turing machine. These
Card k
aero line — Po So Co
one line 1 Ci
Pq, and S^^ all can assume values of zero and one, while both C^
scanning a square which has a zero printed upon it. Card k's instructions
are to overprint the aero with P^ (either a zero or a one) and shift the
tape one square so that the machine scans the square immediately on the
5
of state k is for the machine to assume state C^. Had the original scanned
square contained a one instead of a zero the instructions on the one line
of card one on the original square it was scanning and then assuming dif-
There are several codes which can be used to represent numbers -on
machine' s tape.
does not inpose ar^ serious restrictions, since most mathematical operations
Most authors consider Turing machines from different viewpoints and use
many different representations for Turing machines. There are two main
the state of the machine. The S. refers to the scanned aymbol and the
to the symbol printed. The D refers to shifting right or left one square
or not moving at all. The state the machine will go into next is given by
^n-
The other way of defining a Turing machine follows Davis (1). Davis'
definition differs from Turing' s in that Davis does not consider the pos-
sibility of both overprinting a symbol and shifting one square in the same
operation.
machines is the clearest and most straight forward of any available in the
literature
The main difference between Turing' s approach and Rado' s is that Tur-
ing considered the reading and printing of symbols other than zero or one,
Turing also allowed the machine to scan the same square after it had printed
This machine has the property that if a suitably coded description of any
Tiiring machine is printed on its input tape, it will act like the machine
suitable state. The machines act in the same manner because the universal
machine will compute the same number as the described machinej but normally
at a much slower rate. Universal Turing machines generally use more than
two symbols (say, zero and one) and are quite con^slex in their structure.
At the present time the smallest universal machine uses five symbols and
ELEMENTARY PROGRAMS
generates the copying machine. A copying machine will copy any string of
ones on the input tape to the right of the given string with one separating
zero between the two strings. The scanning should start at the rightmost
one of the string of ones when the program begins. This is the standard
starting position of a Turing machine. When the machine has copied the
string it will stop at the rightmost one of the copied string. This is
illustrated as follows:
8
^2 ^3
12 10 17 1 U 10$
110 1 110 13 1113 1 1 1 U
^5 ^6 ^7
6 1
1 1 2
110 5 '
110 6 1117
the Turing machine. The price that is paid for this clear picture of the
The time of execution of the program is related to the number of states and
Turing machine which takes fewer cards than the equivalent program obtained
nine cards, but the operation of the Turing machine is much clearer than the
putable number.
There are ten basic machines or subprograms from which larger programs
can be constructed. These ten subprograms and their designations are shown
below:
1 2
1 1 2 110
3) FZR (Find the first zero to the right and stop there.)
12 |0 1 3 i 0;
1112 11112 1 110 0}
k) FONER (Find the first one to the right and stop there.)
Cl C2
12 iO 1 2 i
1112 illl3i 1 1 1
)
10
6) FZZR (Find the first pair of zeros to the right and stop under
C2 ^3 %
12 13 jo 1 U! !
1112 1112 11 1 1 2 1
i 1 1
10
1110
of sequence.
ITOR (Shift right one square; stop at the right end of Xjj.
Input
st
I 1 1 l]
;1012 111121 Output "foTo |Xnl —
st Ft
9) MOPR (Erase all ones in the string to the right and stop at the
last one»)
Input
S
Output oTo"-
10 11 T t
s F
and ones in the shift column of the cards by ones and zeros respectively.
The subprograms will then work to the left instead of the right. FZR,
for example, becomes FZL vriiich finds the first zero to the left.
We can now discuss the construction of the program from the ten basic
programs.
Input [
-10 Output |0 1
iHl I I
ll-ll i
0'
F
12
•5t Start
com
FZL 1-3
If
GOTOR k
5-7
PONE 16-17
ZI
PONE 2U-25
Starting with the first instruction, FZL, the subprograms are followed
of the boxes indicate the card numbers of the particular subprogram. The
double arrows aid the assignment of card nunbers to the subprograms, be-
cause they link non-looping subprograms. The card numbers are assigned to
tF
Xjj is any sequence of seros and ones irtiich does not contain two zeros
sequence. The i-th string of ones in Xj^ is x^. The program can be said
to compute {x-^,X2,--' ^±,'" Xj^) = x^^. When n=i=l the program is equivalent
to COPYR.
1n-i+1
(fzl)
n
Igqtor
IfzzrI (_PZ
2 I
|(GQTOR) (FZR)""^"^^!
[
_±
PONE !
n-i+2
(FZL)
j PONE
Input Output jo I
oi-"|oi x„i ojo
k zeroS^ ^F
it
1
j
(U^) I
n(9n+22) cards required
f2
n(9n+3k+19)+3(k-l)
Gi, k
cards required
k-1
IliFZL)^ GQTOR -» ITOr]
Input I
Vm i
Q '
% 0- Output \Y-^
i
X]_
t
!
T
at least two ieros S F
The WNDUP program erases the sequence Vj^ and moves X-^ over within one
in the sequence of the upper case letter. Vjjj generally represents "scratch
FZL
GOTOL
WNDUP
29 cards required
FONER |MOPL
j
I
FZR
GOTOL FONER
noL FZR
2
(GOTOL) GOTOL
Input |0 I
x| 0[ y I I
0-" j Output jO I xj | y! |
(x+y) |
|
t t
ADDITION FZL
HZ
PONE
FZR
95 cards required
GOTOL
(PZ -» GOTOL)'
Input y X Output
t
S
'O if x<y
*«y =
x-y if xs^y
program finds frequent usage. The absolute value of the difference of two
PROPER SUBTRACTION
required
Input i
Xn •
•
Output I X'^n
j
t
F
18
MNIMALIZATION
FZZR
PONE
Cards required:
— s
n(9rw-2$)+50+ cards of
GOTOL machine f.
1 ^
GOTOR GOTOR
PZ MOPL
1
FONEL GOTOL
WNDUP
Input xj i y I I
»" ; Output |o i
X I I y 1
(xy) [0 t.o.
I
t t
S
2 2
19
1
FZL
MULTIPLICATION
zm
GOTOR
I
PZ
HZ
GOTOR (FZL)'
irz
GOTOL PONE GOTOR
zn
PONE FONEL GOTOR
irz
FZL
ZI
GOTOR
GOTOR
RSTRR
A
PZ
I
PZ GOTOR J
(FZZR)^
I X
m
FZR
PONE
FZR
FZR
j
III
(GOTOL)
COPYR
2 ;
i
(7card)
ITOL GOTCR
i^ZL
3_r:
(GOTOL)'
I 1 iFZL^
GOTOL X
zzz
PONE 106 cards required
(FZR) FZZR
zn.
zirr FZL
GOTOL (GOTOL)
IT
GOTOR
PZ
20
f(X„,0)=X(x„) f(Xn,yM)=A[x^,y,f(X^,y)]
FZZL
GOTOL
PONE
FZL
X
GOTOR \TODUP
ze:
PZ FZL
I
(FZZR)' (GOTOR)'
GOTOR PZ
i PONE j
FZR
PONE
I
GOTOR i
Input Xri Oi y oi y| oi 1 o| ^
sT
ROW©
FZZL
~T~
(GOTOR)^
—
PZ
I
GOTOR
^ 1
FZZR
FZZR L
I
i (GOTOL)'
(GOTOL)^ I
i
i
M
WNDUP
I
(FZL)^
I
PONE
98 + cards of
MOPR
I
zm:
FZZR j
(GOTOL)'
WNDUP
23
PREP
GERF
«
Cards required:
ROUND 1
n(9n+6U)+27U+ cards of
and
Turing machines which are not allowed to shift to the left form a
are called finite automata (U). Generally speaking, Turing machines have
two main features: their ability to make decisions and their access to an
limited memory, rather simple tasks lie beyond the reach of finite automata.
For instance, there is no finite automaton which will perform in the manner
of the COPYR Turing machine. This excludes finite automatons with an in-
Because finite automata cannot scan any square on the tape more than
once they require a prepared Irtpnt tape which is not initially filled with
same state the automaton will never stop printing symbols. Such an initial
1
2h
the same manner as unrestricted Turing machines. The finite automata sub-
1
1 1
t
10 S F
111
C-.
1
1 1
)
25
2
111 1 1 1
110
8) AITOR (Shift right one square; stop two squares to the right
Oil
1 2 112
9) AiiOPR (Erase all ones in the string; stop two squares to the
C-,
1 1
10)
(Branching instruction)
1
0^1
If a zero is seen, overprint with an "a", shift right and go to
a P^
1 b Pi
—
26
which will compute the value of any Boolean function given the functional
ate 2"-valued Boolean functions make use of the fact that it is possible
Since finite automata always move to the right, they start at the
leftmost one of the input tape instead of the rightmost one. Another dif-
Boolean algebra elements (say, zero and one) are not represented on a tape
represented by a zero on the tape and the element one by a single one.
Also, the shift column is omitted from the state cards because of the right
For two literals x and y the Boolean function automaton will perform
Input |x j y i i
0|... Output f(x,y )
T f'
27
^2
2 1
f(0,0) 1 f(l,0)
10 3 1
1 f(o,i) 1 1 f(i,i)
automaton.
Ir^ut I
X i
y I z I
w Output 1 { f(x,y,z,w) I i
^2 '=3
C6 '8
f(l,l,0,0) f(l,l,l,0)
1 f(l,l,0,l) 1 f(l,l,l,l)
In general the n literal case will take 2*^-1 cards, but some of the
cards with the functional values will be the same for four or more literals
2"-^3.
with electronic circuits which only recognize two voltage levels. Con-
one bit changes at a time. For devices which measure angular displacements
such as shaft encoders, this is a very desirable property. For in the case
of an anbiguous reading the error in resolution will not exceed the value of
Input o!'"iO 1
APZ
BINARY
* '
Oj 3
01 h
!0
1
output i|o|i|oio[o^i|Ho^o|oJo IE
r
F
30
If the output tape is cut at the end of every n-th square starting
with the first square at the left and the resulting q sections placed on
top of each other (with the leftmost section on top) the first n binary
nunbers will be at hand. If this is done for the example (n = 5) the result
will be:
1 2 3 U
First section 1 1
Second sectior 1 1 0.
Third section ! 1
position and are read from the bottom up with the least significant bit
at the top.
The program generating the first n Gray numbers is very similar to the
program used to generate the binary numbers. However, this program takes
5*2'^-.(U+q) cards. The integer q which is the number of ones on the tape
n-1
zeros zeros zeros
31
GRAY
IT
AFZ
^0 !0
01 2^-^-1
ol
2^-1
If the first 5 Gray numbers were desired the output tape would be:
32
The output tape shown is then cut into q sections of length n squares
starting with the first five squares at the left end. The result of placing
these sections on top of each other with the leftmost section on top is
shown below.
1 2 3 h
First section — 1 1 .
Second section- 1 1 1
Third section 9 i
read from the bottom up with the least significant bit at the top.
The fact that the first 2" binary numbers form a Boolean algebra can
Boolean functions. A 2^-valued Boolean algebra will exist for any set of
1) The U and n operations are closed. Given any two elements of the
set, say a and b, a(Jb - c and a(^ b = d where c and d are also
b Ua and aOb = b P a.
3) There exists an identity element for the U operation and an
h) The U ope ration must distribute over the O operation and the O
operation must distribute over the U operation such that
aU(bnc) = (a \jb) n(a Uc) and a O (b (jc) = (a Ob) ij(a n c).
5) For each element b there must exist an element b' such that b Ub' =
and b /^b' = 0.
The fact that the elements and 1 can have cup and cap operation
2^^
tables which form a Boolean algebra can be used to show that the first
1 ' n 1
i
1
1 1 1 1 1
Consider two binary numbers of the same length (say, abed and efgh).
The cup and cap operations between these two binary numbers are defined
as follows:
The first 2" binary numbers contain all possible sequences of elements
zero and one which are of length n. Consequently the postulate of closure
is satisfied because of closure of the two elements zero and one which are
involved in every cup and cap operation between binary numbers. All of the
other postulates are satisfied by this same reasoning. The cup identity
is the binary number zero and the cap identity is the binary number 2'^-l,
31*
BOOLEAN TRANSFORMATIONS
xq = ©
yn© yn-1©- y3 © y2 © yi © yo-
Input
|yn|yn|yn-iiyn!yn-ityn-2|-"iyntyn-iiyn-2l-iy2l yilyn^n-il yn-2l-|y2|yil yo
I
s
1
(ADD
~1
(ADD©).
I
(ADD©),
(ADD©)
n+1
(ADD©)j^ refers to the number of digits being added modulo two. The
2 3
(ADI®)k 2 3 U
1 (k+2) 1 (k+3)
x^l 1
i 1
1 1
i ^.3\-h
n-1 zeros n zeros F
The digit is found on the l/2(n-i+2) (n-i+l)th square from the first
square on the left. The number of cards needed for the entire program is
n+1
Yl (2k-l) = n(nf2).
k=2
The relation between the binary code and the Gray code (8) is:
yo
= x^Qxq.
The given binary number is entered onto the tape in the following
manner.
This tape is then run through the (ADD©)2 program. The resulting
36
output is:
Output yn-1
The Gray digits occupy every other square of the output tape. This
Binary Addition
+ X,
n,l ^-1,1- \i ^3,1 ^2,1 ^1,1 ^0,1 x^^o = ^n,l =
n n-1 h ^3 ^2 '^O
Finite automata may be used in determining this sum. Enter the two
Input
^,o|^,il^i,o|^,i Ii2 n-1,0 n-1,1
n
This input tape is run through the program (ADD0)2
(ADD©), C3
3 1 j
10 2 1 !
1 1
resulting in
Output
^0,0© ^0,1 ° ^1,0© ^1,1 ^n-l,0©^-l,l
MULT 3 }
10 2 1 1
37
Cn-l(xn-l,0©xn-l,l)-
The parameters Cq and c-^ have already been determined. The other c's
To determine C2 run the input tape below through the following program
C.
Input X3^^^^|x^^Q©x^^^
Program C:
06
002 3 006 1 0!
105 1 U 1 1 1 106 1 1 ol
The output is 10 C2 •
1
now put on this output tape and then run throixgh program C. This deter-
mines c^.
F
This procedure is followed until all of the c parameters have been
determined.
A tape may now be prepared which when run through the (ADD©)" program
Input Cq Xo^o(j)Xo^i|C3_|xi^o(gxi^lj...|c^_j^ix^.-^^o(V)x„~ 01
^n
Output
n
Z3 2-]^
Zq. This program requires 6(n+l) cards and is completed in n+-2
Lucal (5) modified the Gray code to find the sum of two Gray numbers.
Consider addition of the following two modified n-1 bit Gray numbers:
si Sq
These Gray numbers are modified because extra bits Jq q and have
y^ -j^
been added to the Gray numbers. The Gray code with the even parity check
bits (yo^o
yo,l) is known as the modified reflected binary code. The
^0,0 = yi,o©y2,o©y3,o©-©yn,o
^0,1 = y],i©y2,i©y3,i®'"®yn,i
Si = %-iFi.i©yi,i©yi,o
%= %-l Fi-i©yi,o©Ei-l
Fi= Ei_-LFi.i©yi^-L©Fi,l
39
The problem is to find S^, and Fi. To find first start with
input tape
^"p^^ I %-il^i-ilyi,ilyi.o|_°l~:
S
This is then run through a finite automaton using the following program
(a combination of a two digit product and a three term sum modulo two):
1 2 3 h 5 6 7
003i jOOlii jOOU '005! iooo 7 1 1 j
10 2 I j
1 6 I
!1 U I
1 7 1
jl
I
jl 5
i
l£ o_o
| j
This same program is used to determine Ej_ and F^. The tape must be
run through the automaton 3(n+l) times, but the program only requires
seven cards.
replacing all ones in the number by zeros and all zeros by ones and by
prefacing the number with a otie. Positive numbers are prefaced with a
followed. If two n bit binary numbers are added and the resulting sum
has n*-l bits with a one in the most significant place, replace the
one
Uo
by a zero and add the binary number one to this result. Negative numbers
in the number n places to the left. Since a binary number has the form of
Binary Division
Wilson and Ledley (13) devised an algorithm for binary division which
ones including isolated zeros, and strings of zeros including isolated ones.
The binary nunber 0.1111 0000 11011 00100 has a decimal representation as
2°-2-^2-8-2-ll-2-13+2-l^
The first step in finding the quotient Q = N/D is to make sure that the
bit one by a shift of the decimal point. The numerator N shovild also be
positive with N<D and either normalized or with a single zero after the
binary point.
The first remainder N' = N-D which is negative is now found. If N' has
<^-^ zeros to the right of the binary point, then the quotient Q has at least
e<-l ones to the right of the point. N' is now normalized to N' , and the
N
second remainder N" = N'^^ + D is formed. N" is now normalized to W'^ by
moving the binary point ©(^ bits to the right. If N" is negative then the
la
oC-^-th bit of the quotient Qq^.^^^ = and the following ^-1 bits are ones.
This procedure is continued until the quotient has the desired number of
bits in it.
+ 0.01011011 N
- 0.10110000 D
- 0.0^1010101 N' Qj_ = o;?
- 0.1010101
+ 0.1011000 D
+ 0.00000^1 N" = 0.10000?
+ 0.11 N}J
- 0.1011 D
+ 0.0001 N' = 0.10000100?
1/2
As an example consider the square root of 121 = (0.01111001) '
2-(j^l)
X. A.
J J
A^ = 0.1011
A Two-square Automaton
right square of a scanned pair (x^,Xj) and shift one square to the right
The overprints, P^^, are either zero or one and the C^^'s are the called
states.
the right and the overprinted symbol could not be seen again. The program
kept track of this overprinted symbol by having the machine go into one
state if the symbol was a zero or another state if the symbol was a one.
to the next state. Because of this, the machine does not need to keep track
A binary adder modulo two provides a good example of the card reduction
quires 2k-l cards to add k binary bits modulo two. A two-square finite
automaton only requires k-1 cards. The binary bits are entered on the tape
in the same manner as a regular finite automaton, but the standard starting
position is the square to the right of the leftmost bit on the tape. The
two-square finite automaton program for the sum of k binary bits modulo two
is:
^1 ^2 ^k-1
1 1 1
fewer cards than a regular finite automaton. For n-variables the regular
finite automaton required 2""-^+3 cards for the standard unreduced form.
literal is entered on the tape as it appears in the canonical form from left
Two-square finite automata use four types of cards and require two
card and the last transfers a symbol one square to the right. On the first
pass the individual rainterms of maxterms are evaluated. The next pass forms
the sum of minterms or product of maxterms which evaluates the function. The
S
C3 Ci "5
1 1 1 1 1
0/ 0/ 0/ 0/ 0/
A 72 0/ 0/
/o /o,
0/ 1/
% 2 /5 A /o /o
The output tape is then run through the program below irtiich evaluates the
^1 ^5
1 1 1 1
0/ 1/ 0/
A %
1/
A
0/
^2i/2 X X
The value of f is found in the square which previously had the last literal
of £ printed on it.
flow chart. The next section discusses another aspect of two-square finite
automata capabilities.
Some very interesting results evolve from a one card two-square finite
finite number of squares. The machine always remains in the one state and
will print symbols indefinitely. Depending upon the input sequence and the
SUMMARY
machine was required to prepare the tape and keep track of the output data
of the machine. The large amount of work performed by the operator was
representing the Boolean elements by binary elements and then using the
1*6
2-valued Boolean operations. In general, finite automata can work with any
mathematical system which has a finite set of elements and is closed under
n\imbers. These machines work like the automata which compute 2-valued
from that of present day digital computers. A digital computer has a conplex
physical structure which enables the use of rather simple programs. On the
The reason is that the "physical structure" of a Turing machine is the pro-
ACKNOWLEDGMENTS
advisor, for the suggestion of the thesis topic and guidance in preparing
State University for giving much insight and information on Turing machines.
U8
REFERENCES
(3) Lee, C, Y.
Automata and finite automata. BSTJ. 39:1267-1295. i960,
ih) .
by
MASTER OF SCIENCE
1962
This thesis describes the nature and operation of Turing machines
along with a machine that will conpute any general recursive function.
Finite automata which are but a subclass of Turing machines are in-
in their operations because they are not allowed to scan previously com-
puted data. This reduces them to a madiine without any memory. Finite