On Formalism For Turing Machine
On Formalism For Turing Machine
PAT[RICK ~. ~i~ISCHER
Harvard Unive~'~'ily, Cambridge, Ma.~sachu.~et~s
;I. Introduction
The term "Turing machine" has been applied to several different characterizations
of an abstract computing machine. Since each of the formalisms has been adequate
for a development of recursive function theory, no serious trouble has arisen from the
multiple use of the term. In this paper w~rious formal definitions for the notion of a
general-purpose abstract computer are compared, and some new alternative deft-
nitions are introduced. Particular attention is paid to one of Turing's original
formalisms and to one by Post; the latter has been used extensively by Davis in [2].
Most of the theorems below assert that a certain kind of machine simulates am
other kind of machine. However, the concept of simulation of one machine by
another is extremely difficult to define precisely. Too stringent a definition excludes
cases in which one intuitively feels a bona fide simulation is being performed. Too
liberal a definition allows the use of encodings of input and output in which the
real computational work is done by the encoding and decoding algorithms and not
by the machine which is supposedly performing the simulation.
The notion of simulation of one machine by another used here requires that
intermediate results of the computations by the two machines be closely related as
well as the outputs of the computations; i.e., the simulation is "step by step." An
attempt at a precise definition is given in the Appendix, and it is hoped that the
notion of simulation is correctly captured by the definition. However, the theorems
of this paper clearly satisfy any reasonable definition of simulation, and the author
invites suggestions for improving the definition.
Theorem 2 is due jointly to S. Aanderaa and the auttmr [1], and Theorem 8 is
due to P. K. Hooper [4]. The author is also indebted to the referee for his comments
and for his suggestion of a way to strengthen the originally submitted version of
Theorem 3.
2. Turing Machines
A Turing machine is usually regarded as a small computer with a finite number
of states and a (potentially) infinite tape marked off into discrete squares. Upon
each square of the tape is written one symbol selected from a finite alphabet; all
but a finite number of the squares contain the same symbol, B (blank).
In Turing's original formulation in [8], the operation of a Turing machine was
An earlier version of this work was presented under the same title to the Fifth Annual
Symposium on Switching Circuit Theory and Logical Design, Princeton, November, 1964.
This work was partially supported by Bell Telephone Laboratories and by a grant from the
National Science Foundation.
570
ON FORMALISMS FOR TURING MACHINES 571
the following. At a given time, the machine would be in some state and would be
scanning a square on the tape. For each state-symbol pair there would be either a
well defined operation or a command to halt. A nonhalting operation (step) would
consist of three suboperations:
(1) A new symbol (possibly the s:~me as the previous one) would be written (m
the square being scanned.
(2) The scanning head of the machine would move to the left or to the right
one square on the tape. (Turing also allowed the machine to stay" on the same
square.)
(3) The machine would enter a new state (possibly the same as the previous
one).
The machine would then be scanning a new symbol, and to the new state-symbol
pair there would correspond another operation, etc.
A slightly more formal approach to the above version of a Turing machine is to
define a machitte as a set of quintuples <qi, S j , Sk, D, q~} with the five components
of the quintuple representing present state, present symbol being scanned, new
symbol written, direction moved oft tape, and next state. (By cor~.vetttion, the
machine halts if it reaches a state-symbol configuration for which there is no
quintuple.) In order for the machine to be well defined, q~ and q~ must be selected
fronl a finite set of states {q~, q~, ... , %}, Si arid S~ nmst be selected from a finite
set of symbols {So( = B), $1, $2, ... , S,~_1}, and D must be either L, R or N
(left, right or tlo tape motion). Furthermore, no two distinct quintuples of the
machine may have as their leftmost two compottents the same state-symbol pair.
Often the possibility D = N is excluded from the characterization of Turing
machines. I t is well known that this entails no loss of generality. For the sake of
completeness of the discussion, a proof is given below.
Definition. A Turing machine has a blocking-loop if for some k there exist
integers i~, i~, . . . ,'ik and j l , j ~ , " " ,jk such that the machine includes the k
quintuples:
(qh, Sj,, ~%'j~,N, q~}, <q~, Sh, Sj3, N, q~3), "", (q~*, $5,0, Sh, N, qh)
Clearly, one can tell effectivdy whether or not a Turing machine has a blocking
loop, although one cannot in general tell whether or not the loop will ever be entered.
A machine in a blocking loop is not halted, but except for the square being scanned
at that time, the tape will undergo no further changes. Therefore, one can disperise
with the ability of a machine to enter a blocking loop without weakening its com-
puting ability.
LEMMA. For each Turing machine without any blocking loops, there exists a Turing
machine with the same sets of states and symbols, which simulates the first machine and
which has no quintuples with D = N.
PROOF. Whenever there exist two quintuples of the machine of the form
(q~, S~, Sk, N, q~} and (qt, S~, S~, D, qt} where D ~ N, let the first of these be
replaced by (qi, S¢, S~, D, qt}. This results in the elimination of a quintuple with
D = N. The absence of blocking loops guarantees that every quintuple with
D = N will eventually be eliminated. It is clear that the new machine simulates the
original machine.
Henceforth, the term "Turing machine" will denote a quintuple machine in
which there are no quintuples with D = N.
Shannon has shown in [7] that, given enough symbols, one can construct a uni-
572 P A T R I C K C. F I S C H E R
versal Turing machine with only two states. Furthermore, given enough states, one
can construct a universal Turing machine with only two symbols (by using the
procedure of encoding 2k symbols as binary sequences of length k). Thus, there is a
certain symmetry between states and symbols, or in the parlance of computing,
between instructions and data.
3. Post Machines
A popular variant on Turing's formalism is due to Post [6] arid is the model used
by Davis in [2]. In this formalism a machine is represented by a set of quadruples
of tile form <qi, S j , X, ql} where qi, 85 and ql have the same interpretations as in
the quintuple model and X is either L, R or some symbol Sk. Other criteria for
"well definedness" are as before. If X is L or R the machine leaves the symbol under
scan alone and moves left or right on the tape. If X is a symbol Sk then Sk is written
on the square being scanned but the machine does not move. Thus in a single
operation a Post machine can only perform two of tile three possible suboperations
of a Turing machine and it can never perform both suboperations (1) and (2) on
the same step.
Since many of the operations in a "typical" Tm'ing machine program tend to be
searches along the tape for a specific symbol or combination of symbols, one seldom
takes advantage of the quintuple machine's ability to write and to move on the
same step. Thus the number of quadruples in a Post machine would often be of the
same order of magnitude as the number of quintuples in an equivMent Tm.ing
machine, and the description of the Post machine would take fewer characters thart
the description of the Turing machine. For this reason the Post formulation has
been used relatively often in the literature of computability theory.
Let us now seek some more wecise statements about the relationship between
Turing machines and Post machines. The first theorem is elementary.
THEOREM 1. For every m-symbol n-state Turing machine there exists a Post machine
with m symbols and at most 3n states which simulates the Turing machine.
PROOF. Let So, S ~ , . . . , S,,-1 be the symbols of the Turing machine al~d
q,, q2, • • • , q,~ be its states. Then the Post machine will have the same symbols as
the Turing machine and will have as states q,, q=, • • • , qn ; q~,L, q2.L, • • • , q,,~ ;
q,.~, q2,~ • • • , q~.R • For each quintuple @ , S i , Sk, D, qz) in the Turing machine,
the Post machine will have a quadruple <q~, S j , Sk, qa.D). In addition, the Post
machine will have mn quadruples of the form (qa.L, Sk, L, qz} and mn quadruples
o f t h e f o r m @ . x ~ , S k , R , qz) ( l = 1,2, . . . , n ; k = 0 , 1 , . . . , m - 1 ) . T h e v e r i f i c a -
tion that the Post machine is well defined and exhibits the correct computational
behavior (when given the same initial instantaneous description as the Tm'ing
machine) is trivial.
As an immediate consequence of the above we have the well known
Remark. There exists a 2-symbol universal Post machine.
Although one can map Turing machines into equivalent Post machines without
increasing the number of symbols, it is not possible in general to find equivalent
Post machines for Turing machines without increasing the number of states. In
pm'ticular, the 2-state universal Turing machine of Shannon must map into a Post
tnachine of more than two states. The main result in this area is Theorem 2 below.
THEOREM 2 (with S. Aanderaa). The halting problem for the class of 2-state Post
~nachines is reeursively solvable.
ON FORMALISMS FOR TURING M.~CHINES 573
4. D-Machines
There are clearly other quadruple formalisms for abstract computing machines,
since one might invoke other restrictions than those of Post on the possible sub-
operations performed on a given step. These cases are considered below.
Definition. A D-machine is a set of quadruples of the form (q/, S j , X, D} where
D is either L, R or N, and X is either a symbol & or a state qz. The restrictions
on the quadruples of a well defined D-machine are analogous to those for well
defined Turing machines.
574 PATRICK C, FISCHER
The state-symbol pah' (qx, S j} has the usual interpretation. If X is a symbol S~:
then Sk is written on the scamped square and the machine moves in direction D but
remains in the sarne state. If X is a state qz the machine does not write a new symbol,
but moves in direction D and enters state q~. Thus a D-machine can never perform
suboperations (1) and (3) on the same step.
THEORE~t 4. For every m-symbol n-state Turing machine there exists a D-machine
with m symbols and at most ( m + l ) n states which simulates the Turing machine.
PROOF. Let the symbols and states of the Turing machine be as in Theorem 1.
The D-machine will have the same symbols. Its states will be q~, q2, - • • , q~ plus
mn additional states of the form q~,i ( i = 1, 2, . . . , n ; j = 0,1, . . . , m - 1 ) .
For each quintuple (q~, S i , Sk, D, qz} of the Turing machine, if j ¢ k the D-
machine will have the three quadruples @ , S¢, qi.~, N}, (q~,i, S j , Sk,N},
(q~.i, Sk, ql, D). If j -- k the D-machine will simply have the quadruple
@ , S i , qz, D}, a,ld state q~,i will not be used. The D-machine will have the same
initial instantaneous description as the Turing machine.
In operation, the D-machine first changes to a state which represents uniquely
the three suboperations that must be done to simulate the effect of the given Turiag
machine quintuple. Then the D-machine writes the proper symbol. Finally, it
changes to the correct state and makes the correct move. Whenever the D-machine
is in one of the states q~, q~, • • • , q~, its instantaneous description is the same as
the appropriate one of the Turing machine.
COROImA~Y. There exists a 2-symbol universal D-machine.
Theorem 4 made use of the ability of a D-machine to have D -- N. If a D-machitte
is restricted so that all quadruples have D ~ N, then the above method of proof
will not go through. In particular, fit the ease of a 2-symbol restricted D-machine,
the number of Mternations of blanks and l's on the tape cannot be increased over
the number on the tape at the start of the computation. However, a 2-symb01
restricted D-machine can be shown universal via the simulation of a 2-counter
machine, which Minsky has shown can simulate a universal Turing machine.
Definition. A 2-counter machine is a set of triples of the form @ , X, qi} where
X is either I 1 , / 2 , of the form D~qk, or of the form D~qk. No two triples begin with
the same q~, and q~, qj and qk are all members of the same finite set Q. The machine
has two counters; the value of each is a non-negative integer. When the machine is
in state q~, its behavior is determined b y the triple beginning with q~. If X is I~ the
value of the first counter is increased by 1 and the machine enters state qi. If X
is D,q~ and the value of the first counter is 0 the machine enters state qk; otherwise,
the value of the first counter is decreased by 1 and the machine enters state qj.
Operations/2 and D2qk similarly affect the second counter.
[INEOREM 5. "For any 2-counter machine there exists a 2-symbol D machine which
simulates the 2-counter machine and which has no quadruples with D = iV.
PROOF. Denote So by B and S~ by 1. The tape of the D-machine will always be
of the form ...BBB1B'~iB~iBBB..., where B ~ means m consecutive B's. The values
of the first and second counters will be represented by m - 1 and n - 1 , respectively.
Constructions will be given to handle operations /2 and D2qk; I~ and D~qk are
handled by a symmetrical construction.
At the start of a cycle, the D-machine is either scanning the square to the left or
the square to the right of the middle 1, depending on whether the operation to be
simulated affects the first or second counter, respectively. States of the form q~.p
ON FORMALISMS FOR TURING MACHINES 575
are used for simulating the action of the trit)le beginning with q,. The quadruples
used for the simulation of (q~, Le, qa} are the following:
(q~.~ , B, B, R} <q~,~ , 1, q,',a , R} <q~.~ , B, q~,~ , L)
(q~.~ , l, q~,~ , R} (q~,~ , l, q~.~ , L} (q~,~ , B, B, L>
(q¢.~ , B, 1, L) (q~.~ , 1, B, L) (q¢,~ , 1, q j A , D)
where D = L if the triple beginning with q~ affects the first counter and D = R if
it affects the second counter.
T h e quadruples used for the simulation of (q~, D~q~, q:i) are the following:
(qi,1 , B , qi,~ , R } (q~,~ , [B, q i A , [~} (q~,~,l, q~.~,L) (q~,~,B, B, L}
(q~.~ , l, q~.~ , L} (q~.~ , B, B, R) (q~'.~ , 1, q,'.~ , R} (q~,s , 1, q~,~ , L)
(q~,~ , B, B, L) (ql.4 , 1, qi.s , L} (q~.~, 1, B, R} (q~.~, B, B, L}
(q~.~ , 1, q~.~ , D) (q~.~ , B, 1, R) (q~.~ , B, q~.s , L} <q~,~ , 1, q~.~ , D'}
where D arid D' depend on the counters affected by the triples beginning with q~
and q~ respectively.
COROLLARY. There exists a 2-symbol universal D ,machine in which, all quadruple.~
have D ~ N .
PROOF. T h e proof follows from Theorem 5 and fl'om Minsky's T h e o r e m tlu~t
there exists a universal 2-counter machine (see [5]).
T u r n i n g now to the question of the existence of a 2-state universal D-machiae,
one can give a positive answer via a more tightly coded version of Shaunou's
ingenious proof in [7]. T h e proof does not need quadruples with D = N.
THEOREM 6. F o r every m - s y m b o l n-state T u r i n g machir~e, there exists a D - m a c h i n e
with only 2 slates a n d at ,most m(4n + 7) symbols w h i c h simulates the T u r i n g m a c h i n e .
P~tOOF. Let the states and symbols of the Turing machine be as in T h e o r e m 1.
The D-machine will have states q, and q2 • Its symbols will be S o , S , , . . . , S , , - ~ ,
plus 4 r e ( n - t - i ) symbols of the form Si,5,..D ( i = 0 , 1 , ' ' ' , m - - 1 ; j =0,1,
2, - - • , n; • = -t-, -- ; D = L, R), and 2m symbols of the form S¢,,~+,,+,r, (i = 0,
1, . . " , m - l ; D = L,R). For each Turing machine quintuple of the form
(q.i, S i , S k , L, qz} the D-machine will have the two quadruples
(ql,S~j.-.R,S~.~+I,+.L,L} and (qo, S~.j.-,L , S.~.~.+.L , R}.
For each quintuple of the form {qj, S~, S , , R, q~) the D-machine will h~tve the
two quadruples
(ql , Sid,-.n , Sk.z.+.~ , L) and (q~ , Si.j.-.L , S~.~+t.+.re , R}.
In addition, the machine will have the following sets of quadruples for
each/ (i=O, 1,...,m-1):
Quadruples Used when the Turing Mochine is Movino to the Right
(ql , S~.i.+.R , q2 , R} (1 N j ~ n)
(ql , Si.o,+.R , S~ , R)
(~/~, S i , S~.o.-.~, L)
(q~ , S~d,+,R , Sid-l,+,R , R) (1 ~ j _~ n + l )
(q~ , S~,o,+,~ , ql , R)
(q.~ , Si.~'.-.~ , S~.i+~.-.~ , L) (0 N j N n - l )
Quadruples Used when the Turin~ Machine is Moving to the Left
(q~, S ~ d . + . ~ , q~, L) (1 _<- j N n)
(q~ , Si.o,+.~ , S~ , L)
(q~ , S~ , S~,o,-.L , R)
(qt , S¢.i.+.~ , S~./-~.+.~ , L) (1 ~ j ~ nq-1)
(q~ , S~.o.+.~ , q'~ , L)
<q~ , S~d.-,L , S~d+~.-.L , R) (0 NN j ~ n - l )
576 PATn~CK C. F~SC~En
5. S - M a c h i n e s
each quintuple (q~, S j , Sk, D, qz) of tile Turing machine the S-machine will have
a quadruple (q~, Sj, Sk,v, q~). In addition, the S-machine will have me quadruples
of the form (q~ , Sk.L , Sk , L} and mn quadruples of the form (qt , S~.R , Sk , R}
(1 = 1, 2, -.., n; k = 0, 1, -.-, m - 1 ) . The initial instantaneous description of the
S-machine will be the same as that of the Turing machine.
COROLLARY. There exists a 2-state universal S-machine.
THEOREM 8 (P. K. ttooper). The halting problem for the class of 2-symbol S-ma-
chines is recursively solvable.
PROOF. Given a 2-symbol S-machine, add a new state qx and add two quadruples
which begin with q~ and are otherwise the same as the two quadruples associated
with the initial state of the machine. Redesignate q~ as the initial state of the
machine. Now let the machine be further modified as follows: Whenever a quad-
ruple of the form @ , Si, S~, qz} is found where there is no quadruple beginning
with (q~, S~}, delete the quadruple; whenever two quadruples of the form {q~, S j ,
Sk, ql} and @ , Sk, S~, q~} are found, replace the first quadruple by (qi, S~, S~,,
q~}. Whenever a noninitial state becomes inaccessible, eliminate it and its quad-
ruples. Continue until no further transformations can be made,
The process will eventuMly terminate, and the modified S-machine will halt if
and only if the original machine halts. Since state changes can be caused only by
quadruples of the form (q~, Sj, Sk, ql} it follows that with each qi (i ~ I) there
will be associated at most one such quadruple, else q~ would have been made in-
accessible by the above procedure. Thus, each noninitiM state in the modified
machine can have at most one successor state. Consequently, after leaving q~, the
machine will begin to follow a path of potential state changes involving a finite
number of states. If the path camlot lead to a hMting situation (because every
state in the path has a successor state), then the halting question can be answered
in the negative. If the path eventually leads to a state with no successor, one can
still solve the halting problem, for it is clear that, having reached a given state,
one can effectively determine whether or not the successor of that state will ever be
reached. The machine halts only if the end of the path is attained.
THEOREM9. For every m-symbol n-state Turing machine there exists an S machine
with m-~ l symbols and at most (m--t-1)n states which simulates the Turing machine.
PRooF. Let the symbols and states of the Turing machine be as in Theorem 1.
The S-machine will have the same symbols plus an additional symbol, S,~. The
states will be q~, q2, • • ", q,~ plus mn additional states of the form q~.~ (i = i, 2,
• . . , n ; j = 0, 1, . . . , m - l ) . For each quintuple @ , S~, Sk, D, qt) of the Turing
machine the S-machine will have the quadruple (q~, S j , S ~ , q~.i), m quadruples
of the form {q~.i, Sp, S,~, q~.~} (p = 0, 1, . . . , m - l ) , and the quadruple (q~.i,
S,~, Sk, D}. The initial instantaneous description of the S-machine will be the
same as that of the Turing machine.
A state qi,i in conjunction with S~ causes the symbol and move specified by the
quintuple (q~, S~., Sk, D, flz). When the S-machine is in state qi.~ and not scanning
an S~, it behaves as though it were in the state q~ determined by the Turing
machine quintuple. The mapping h: qz --~ qz ; ql.i --~ ql ; S~ ~ Sk yields the instan-
iii! taneous description of the Turing machine whenever the S-machine is not scanning
an S~.
!ii;~ COROLLARY. There exists a 3-symbol universal S machine.
Theorems 7, 8 and 9 are essentially the duals of Theorems 1, 2 and 3.
578 PATRICK C. F I S C H E Y ¢
6. U-machines
The initial instantaneous description of the U-machine will be the same as that
of the Turing machine except that the symbol on the square being scanned will be
primed and the initial state will be q<L instead of q~. Whenever the U-machine is
in an unprimed state scanning ~ primed symbol, the instantaneous description of
the Turing machine can be recovered via the mapping h: q<D ~ qi ; Sj' + S~;
Si ~ Si •
To understand the opcration of the U-machine, consider the following example.
Let the Turing machine have instantaneous description . . . q ~ S j S , . . . and let the
appropriate quintuple be <q~, S j , & , R, q~>. Following the machine specifications
given above in order, regarding the variables i, j, /c, l and p as free rather than
bound and setting D = R. The successive instantaneous descriptions of the U-ma-
chine will be as follows, where D is the direction of the previous move of the Turing
ON FORMALISMS FOR TUIIING MACHINES 579
machine:
• • •q,,DS/Sp. • .
REFERENCES
1. AANDERAA,S., AND FISCHER, P.C. The solvability of the halting problem for 2-state Post
machines. Ia preparation.
2. DAws, M. Computability and Unsolvability. McGraw-Hill, New York, 1958.
3. - - . A note on universal Turiag machines. Automata Studies, Princeton U. Press, Prince-
ton, N. J., 1956.
4. HOOPER, P . K . A note on Turing machines. Amer. Math Soc. Notices (Jan. 1965).
5. MINSKY, M. L. Recursive unsolvability of Post's problem of "tag" and other topics in
theory of Turing machines. A n n a l . Math• 74 (1961), 437-455.
6. PosT, E . L . Recursive unsolvability of a problem of Thue. J. Symbolic Logic. I2 (1947),
1-11.
7. SHANNON, C. E. A universal Turiag machine with two internal states• Automata Studies,
Princeton U. Press, Princeton, N. J., 1956.
8. TURING, A. M. On computable numbers, with an application to the Entscheidungs-
problem. Proc. London Math• Soc. 42-2 (1936-37), 230-265; Correction, ibid•, 43 (1937),
544-546.
APPENDIX
I. S i m u l a t i o n of One Machine by Another
The terminology below is that in [2]. Let M1 and Ms be two machines. Let. p be a
characteristic function defined over the set C~ of all possible instantaneous descrip-
tions of M2. Let h be a m~tpping from C2 onto C~, the set of all possible instantaneous
descriptions of M i , and f be a 1-1 function from C~ into C~. Let C 1 ( I , t) be the
instantaneous configuration of M~ at time t if M~ was started in instantaneous
configm'aMon I at time 0 (thus C I ( I , O) = I ) . C 2 ( I , t) is defined in a similar faslfion.
Definition. For every initial instantaneous configuration I for M1 let a fimction
g be defined on the non-negative integers by the following recursion equations:
g(O) = vz[p(C~(f(I), z)) = 1]
e(t + 1) = vz[z > g ( t ) and p(C2(f(I), z)) = 1]
Then M 2 s i m u l a t e s M i with respect to a class of functions ¢ if and only if for every
initiM instantaneous description I of M~ aim every time t ~ 0: (1) C t ( I , t) =
h ( C ~ ( f ( I ) , g ( t ) ) ) ; (2) C x ( I , t) is final if and only if C ~ ( f ( i ) , g ( t ) ) is final; and
(3) f, p and h q ¢. T h e class C should consist of functions which are ia some
580 PATRICK C. FISCIffER
sense "easy to compute." A reasonable candidate for ¢ might be the class of ele-
mentary functions of Kalmgr.