Turing's Universal Machine
Total Page:16
File Type:pdf, Size:1020Kb
Appendix Turing’s Universal Machine This appendix gives the complete table for the universal Turing machine U. There were a number of errors in Turing’s original paper, as pointed out by Emil Post and Donald Davies.1 These errors have been corrected in the tables below. A.1 General Purpose m-functions The tape of the universal machine uses the convention of alternating F-squares and E-squares, described in Sect. 4.5, where the E-squares are used to mark, or label, symbols on the preceding F-squares. The leftmost point of the portion of the tape used in the computation is identified by means of the symbol e placed in a pair of adjacent squares. f(C, B,α): find The m-function f(C, B,α) finds the leftmost occurrence on the tape of the symbol α, and then moves to m-configuration C. If there is no occurrence of α on the tape, the machine moves to m-configuration B. m-config. symbol operations final m-config. e L f1(C, B,α) f(C, B,α) e not L f(C, B,α) ⎧ ⎨ α C f1(C, B,α) ⎩ not αR f1(C, B,α) None R f (C, B,α) ⎧ 2 ⎨ α C f2(C, B,α) ⎩ not αR f1(C, B,α) None R B 1See Post (1947) and Davies (2004). Davies describes Turing’s “impatience” when these errors were pointed out, remembering that he “made it clear that I was wasting my time and his by my worthless endeavors”. M. Priestley, A Science of Operations, History of Computing, 307 DOI 10.1007/978-1-84882-555-0, © Springer-Verlag London Limited 2011 308 Turing’s Universal Machine e(C, B,α): erase The m-function e(C, B,α)erases the leftmost occurrence on the tape of the symbol α, and then moves to m-configuration C. If there is no occurrence of α on the tape, the machine moves to m-configuration B. m-config. symbol operations final m-config. e(C, B,α) f(e1(C, B,α),B,α) e1(C, B,α) E C e(B,α): erase all The m-function e(B,α) erases all occurrences on the tape of the symbol α, and then moves to m-configuration B. m-config. symbol operations final m-config. e(B,α) e(e(B,α),B,α) pe(C,β): print at end The m-function pe(C,β) prints the symbol β at the end of the sequence of symbols on the tape, and then moves to m-configuration C. m-config. symbol operations final m-config. pe(C,β) f(pe1(C,β),C, )e Any R,R pe (C,β) pe (C,β) 1 1 None Pβ C pe(C,β)moves to the start of the tape, and then pe1(C,β)searches for the first blank F-square before printing β. A variant of this m-function prints two symbols at the end of the tape: m-config. symbol operations final m-config. pe2(C,α,β) pe(pe(C,β),α) l(C): move left The m-function l(C) performs the basic operation L, and then moves to m-configuration C. m-config. symbol operations final m-config. l(C)LC f(C, B,α): find and move left The m-function f(C, B,α) finds the leftmost oc- currence on the tape of the symbol α, moves one square to the left, and then moves to m-configuration C. If there is no occurrence of α on the tape, the machine moves to m-configuration B. m-config. symbol operations final m-config. f(C, B,α) f(l(C), B,α) c(C, B,α): copy The m-function c(C, B,α)finds the leftmost symbol on the tape marked with the symbol α, copies it to the end of the tape, and then moves to m- configuration C. If there is no symbol marked with α on the tape, the machine moves to m-configuration B. m-config. symbol operations final m-config. c(C, B,α) f (c1(C), B,α) c1(C)β pe(C,β) A.1 General Purpose m-functions 309 ce(C, B,α): copy and erase The m-function c(C, B,α)finds the leftmost symbol on the tape marked with the symbol α, copies the symbol to the end of the tape, and then erases the symbol and moves to m-configuration C. If there is no symbol marked with α on the tape, the machine moves to m-configuration B. m-config. symbol operations final m-config. ce(C, B,α) c(e(C, B,α),B,α) ce(B,α): copy and erase all The m-function ce(B,α)copies all symbols marked with α to the end of the tape, erases them, and then moves to m-configuration B. m-config. symbol operations final m-config. ce(B,α) ce(ce(B,α),B,α) The table for the universal machine uses a variant of this m-function which will copy and erase symbols marked with five different symbols. This can be defined in terms of ce(C, B,α)as follows: m-config. symbol operations final m-config. ce5(B,α,β,γ,δ,ε) ce(ce(ce(ce(ce(B,ε),δ),γ),β),α) cp(C, U, G,α,β): compare The m-function cp(C, U, G,α,β) compares the first symbol on the tape marked with α and the first symbol marked with β. If there are no symbols marked with α or β, the machine moves to m-configuration G;if both exist, and the marked symbols are the same, it moves to m-configuration C; otherwise, it moves to m-configuration U. m-config. symbol operations final m-config. cp(C, U, G,α,β) f (cp1(C, U,β),f(U, G,β),α) cp (C, U,β) γ f(cp (C, U,γ),U,β) 1 2 γ C cp (C, U,γ) 2 not γ U cpe(C, U, G,α,β): compare and erase The m-function cpe(C, U, G,α,β) does the same as cp(C, U, G,α,β), but if symbols marked with α and β exist and are the same, the α and β are erased. m-config. symbol operations final m-config. cpe(C, U, G,α,β) cp(e(e(C, C,β),C,α),U, G,α,β) cpe(U, G,α,β): compare and erase all The m-function cpe(U, G,α,β)compares the sequences of symbols on the tape marked with α and β. So long as they are the same, the αs and βs are erased. If the sequences are identical, the machine moves to m-configur ation G when all the marks have been removed; it moves to m-configur- ation U when a difference is detected. m-config. symbol operations final m-config. cpe(U, G,α,β) cpe(cpe(U, G,α,β),U, G,α,β) 310 Turing’s Universal Machine q(C): find end of tape The m-function q(C) moves to the end of the tape, identi- fied by two consecutive blank squares, and then moves to m-configuration C. m-config. symbol operations final m-config. Any R q(C) q(C) None R q (C) 1 Any R q(C) q (C) 1 None C q(C,α): find last The m-function q(C,α) finds the last occurrence of α on the tape, and then moves to m-configuration C. m-config. symbol operations final m-config. q(C,α) q(q (C,α)) 1 α C q1(C,α) not αL q1(C,α) If there is no occurrence of α on the tape, the machine will endlessly search left- wards, moving beyond the beginning of tape markers. e(C): erase marks The m-function e(C) erases all marks from the tape, and then moves to m-configuration C. m-config. symbol operations final m-config. e R e1(C) e(C) e not L e(C) Any R,E,R e (C) e (C) 1 1 None R C A.2 The Contents of the Tape It is assumed that an enumeration q1,...,qm is given of the m-configurations used in the table of T , the machine to be simulated, along with an enumeration S0,...,Sn of the symbols which can appear on its tape. S0 is a ‘blank’ symbol, which is thought of as appearing in empty squares; S1 is the digit 0 and S2 the digit 1. The table of T is assumed to have been reduced to standard form, consisting of a number of instructions each of which has one of the following forms: qiSj SkLqm, qiSj SkRqm, qiSj SkNqm. Each instruction has five components: a configuration, consisting of the initial m- configuration and the symbol in the scanned square, the symbol that will be written in the scanned square (this will be the blank symbol S0 if the existing symbol is to be erased), the move that the machine will make, and the final m-configuration. A.2 The Contents of the Tape 311 Coding Instructions The table of T is written on the tape of U as a standard description; this is an encoding of its standard form using a limited set of symbols, namely ;, A, C, D, L, R and N.Them-configuration qi is coded by a D followed by a sequence of iAs, and the symbol Si by a D followed by a sequence of iCs.