</p>
-<RT·chapter>The computation theory Turing Machine</RT·chapter>
+<RT·chapter>The computation theoretic Turing Machine</RT·chapter>
+
+ <h2>The Hopcroft and Ullman Turing Machine</h2>
+
+ <p>This definition comes from Hopcroft and Ullman's book with minor terminology changes to make it flow into the text here <RT·endnote>John E. Hopcroft and Jeffrey D. Ullman, <em>Introduction to Automata Theory, Languages, and Computation</em> (Reading: Addison Wesley, 1979).</RT·endnote>.
+ </p>
+
+ <RT·math>
+ M = (Q, Σ, Γ, δ, q_0, □, F)
+ </RT·math>
+
+ <p>Where the components have the following meanings:</p>
+
+ <ul>
+ <li><RT·math>Q</RT·math>: The finite set of <em>states</em> of the programmed finite state machine controller.</li>
+ <li><RT·math>Σ</RT·math>: The finite set of <em>input symbols</em>.</li>
+ <li><RT·math>Γ</RT·math>: The complete set of <em>tape symbols</em>; <RT·math>Σ</RT·math> is always a subset of <RT·math>Γ</RT·math>.</li>
+ <li><RT·math>□</RT·math>: The <em>empty</em> symbol. This symbol belongs exclusively to <RT·math>Γ</RT·math>, serving as a distinct tape marker rather than an input symbol. The empty symbol initially populates all cells except the finite number containing the input symbols.</li>
+ <li><RT·math>δ</RT·math>: The next state function. The arguments of <RT·math>δ(q, X)</RT·math> are a state <RT·math>q</RT·math> and a tape symbol <RT·math>X</RT·math>. The value of <RT·math>δ(q, X)</RT·math>, if it is defined, is a triple <RT·math>(p, Y, D)</RT·math>, where:
+ <ol>
+ <li><RT·math>p</RT·math> is the next state in <RT·math>Q</RT·math>.</li>
+ <li><RT·math>Y</RT·math> is the symbol in <RT·math>Γ</RT·math> written in the scanned cell, replacing the previous symbol.</li>
+ <li><RT·math>D</RT·math> is a <em>direction</em>, either <RT·math>L</RT·math> or <RT·math>R</RT·math>, standing for "left" or "right," respectively, directing the head to move either left or right.</li>
+ </ol>
+ </li>
+ <li><RT·math>q_0</RT·math>: The <em>initial state</em>, a member of <RT·math>Q</RT·math>, in which the finite control is found.</li>
+
+ <li><RT·math>F</RT·math>: The set of <em>final</em> or <em>accepting</em> states, a subset of <RT·math>Q</RT·math>.</li>
+ </ul>
+
+ <p>I have introduced the qualifier <em>programmed</em> in front of the <em>finite state machine controller</em> because each Turing Machine that accomplishes a different task has a different finite state machine controller. The rest of the Turing Machine remains fixed. Hence, when a mathematician defines a custom task controller, he is essentially programming the machine.</p>
+
+ <p>Here the <em>input</em> alphabet is said to be a subset of a larger alphabet. This allows some symbols to be set aside and only used by the machine. In the architecture description given below, those symbols exclusive to the larger set are called <RT·term>control symbols</RT·term>. Hopcroft and Ullman include the empty symbol as a control symbol. However, they have simultaneously listed it as a separate component.</p>
+
+ <p>State transitions are gated by the read value from the tape. Each state transition function includes actions to be taken; hence, their programmable controller is a Mealy style state machine. The step action is mandatory, though it can be in either direction. The write action must be specified, but the write could be the same symbol that is read, making it effectively an optional action.</p>
+
+ <p>Hopcroft and Ullman explain a step of the machine by showing a representation of the tape with the state variable melded in to the left of the currently scanned symbol. Suppose <RT·math>δ(q, X_i) = (p, Y, L)</RT·math>; i.e., the next move is leftward. Then,
+ </p>
+
+ <RT·math>
+ X_1 X_2 \cdots X_{i-1} q X_i X_{i+1} \cdots X_n \underset{M}{\vdash} X_1 X_2 \cdots X_{i-2} p X_{i-1} Y X_{i+1} \cdots X_n
+ </RT·math>
+
+ <p>So first the tape is <RT·math>X_1 X_2 \cdots X_{i-1} X_i X_{i+1} \cdots X_n</RT·math>, with the head over <RT·math>X_i</RT·math>, and in state <RT·math>q</RT·math>. Then after a step of the machine, the tape is <RT·math>X_1 X_2 \cdots X_{i-1} Y X_{i+1} \cdots X_n</RT·math>, with the head over <RT·math>X_{i-1}</RT·math>, and in state <RT·math>p</RT·math>. Thus <RT·math>X_i</RT·math> was overwritten with <RT·math>Y</RT·math>, and the head stepped left.
+ </p>
+
+ <p>Here is the programmed controller for a Turing Machine that reverses a binary string.</p>
+
+ <img src="HU_reverse_machine.png" class="rt-diagram" alt="HU reverse machine">
+
+ <p>Provided the site is still alive, the following YAML can be entered at TuringMachine.io to watch the machine run.</p>
+
+ ```yaml
+ # Reverses a binary string using a single marker and an EOM terminator.
+ input: '11001'
+ blank: ' '
+ start state: q0
+ table:
+ # scan to the rightmost digit and place the EOM terminator 'E'
+ q0:
+ [0, 1]: R
+ ' ' : {write: 'E', L: q1}
+
+ # process the rightmost unmarked digit, writing the uniform marker '*'
+ q1:
+ 0 : {write: '*', R: q2}
+ 1 : {write: '*', R: q3}
+ ' ': {R: q6} # all digits processed, begin cleanup
+
+ # carry '0' to the right end
+ q2:
+ ['*', 'E', 0, 1]: R
+ ' ' : {write: 0, L: q4}
+
+ # carry '1' to the right end
+ q3:
+ ['*', 'E', 0, 1]: R
+ ' ' : {write: 1, L: q4}
+
+ # return all the way to the left blank space
+ q4:
+ ['*', 'E', 0, 1]: L
+ ' ' : {R: q5}
+
+ # step right to find the next unmarked digit
+ q5:
+ [0, 1] : R
+ ['*', 'E']: {L: q1}
+
+ # erase the markers and EOM terminator, leaving only the reversed string
+ q6:
+ ['*', 'E'] : {write: ' ', R: q6}
+ [0, 1, ' ']: {L: done}
+
+ done:
+ ```
+
+ <p>This machine starts with the head on the leftmost symbol of the input string, requiring an empty symbol on both sides to operate. The machine begins by sweeping right to place an end of message marker, E, immediately after the string. It then enters a repetitive process: it walks left to locate the next unprocessed input symbol, overwrites it with an asterisk to mark it as read, and then carries that remembered value rightward to deposit it at the new end of the sequence. By executing this back-and-forth shuttle, the machine systematically builds the reversed string to the right of the E, finishing by sweeping through to erase its temporary markers.</p>
+
+ <p>Reversing a string does not in general require knowing the constituent symbols; however, a Turing Machine is incapable of ignoring their actual values. The 1 and 0 here are explicitly stated in the state transitions, and specific states are reserved to keep track of which symbol is being transferred. Had the input alphabet been large, this controller would have required proportionally more states.</p>
+
+ <p>Although by definition each state transition matches one value under the head, as a practical matter, disjunctive selection is allowed via a comma list. A conjunctive phrasing for the state transition proposition would require stringing intermediate states in series.</p>
+
+ <h2>The empty symbol</h2>
+
+ <p>Turing described a clerk writing symbols into squares, with the option to erase them. He states, "In some of the configurations in which the scanned square is blank (i.e. bears no symbol) the machine writes down a new symbol on the scanned square: in other configurations it erases the scanned symbol."<RT·endnote>Alan M. Turing, "On Computable Numbers, with an Application to the Entscheidungsproblem," Proceedings of the London Mathematical Society, Series 2, Volume 42 (1936): 231.</RT·endnote> So Turing's original article uses <em>blank</em> to mean <em>no symbol</em>. Turing fairly consistently refers to "blanks" rather than to a symbol that represents a blank. However, thirty pages in, he does say this, "for in the complete configuration the symbols are all blanks"<RT·endnote>Alan M. Turing, "On Computable Numbers, with an Application to the Entscheidungsproblem," Proceedings of the London Mathematical Society, Series 2, Volume 42 (1936): 261.</RT·endnote>.</p>
+
+ <p>The more abstract concept here is that of a container. A piece of paper is a container for symbols. When it contains no symbols, the container is empty. Only when we say the container is a piece of paper does it make sense to call it blank. But we are speaking of abstractions, not of paper. The question is not one of blankness, rather it is the more abstract question of emptiness. When computation theory texts are translated into French, the blank symbol is called the "symbole vide", or literally "empty symbol". Hence, in the French context, paper as a container does not carry with it a distinct terminology.
+ </p>
+
+ <p>So the actual question, which dates back to the very definition of the Turing Machine, is this: when a <em>square</em> from Turing's paper has not yet been written to, does it hold an empty symbol, or is it actually empty?</p>
+
+ <p>As defined in texts such as Hopcroft and Ullman, a Turing Machine cannot function when a tape cell does not read a symbol, because the next state function is defined such that it must be given a symbol. A machine simply fails if a scanned cell is void of symbols.</p>
+
+ <p>Imagine a tape machine, called machine A, where, upon attempting to read an empty cell, the machine head instead returns a control symbol representing that the cell was empty. To accomplish this, the head would have to do some work; it would have to be able to detect emptiness, and then choose to return the empty symbol instead of a read value. This feature would fix the problem of not having any defined next state behavior for an empty cell. Furthermore, suppose the inverse process was also special in that upon attempting to write the empty symbol, the machine takes action, emptying the cell out. This would facilitate an erase operation.</p>
+
+ <p>Now imagine machine B, where a yet-to-be-used cell on a tape directly holds the symbol. Because it is merely another symbol, reads and writes occur exactly as they do for other symbols.</p>
+
+ <p>As long as the cost of the empty cell fix is constant time, the differences between machine A and machine B are computationally inconsequential. However, for machine A, the mathematician is greatly inconvenienced if he cares to write down the contents of the tape, as he will need some means of communicating that a tape cell is empty. A mathematician is wont to invent a symbol to express this meaning. The cup, empty box, or null set symbol are all possible choices. Let us not lose sight of the level of analysis, however. We are discussing the computation theoretic Turing Machine, and doing so in the realm of forms. Given that our discussion is in the abstract, machines A and B are in fact the same, the only difference being that the description for machine A is less elegant. Thus, we will recognize that an empty tape, one that has not been written to, is full of empty symbols.</p>
+
+ <p>Computational theorists often describe a two-step process. First, a Turing Machine writes a string to be studied onto a tape initially filled with all empty symbols; second, the tape is moved to another Turing Machine whose purpose is to recognize a property of the string being studied. In this process, a tape is used as a communication medium, and it follows that communication theory can be applied to this messaging scenario. Messages sent on a channel must be formatted so they can be placed on the channel and later recovered. The specification for such structuring is called a communication <RT·term>protocol</RT·term>. The protocol implies a higher authority, as both the sender and the receiver must have knowledge of the same designed-in protocol. In a sense, a protocol is the meta-message sent before the message itself.</p>
+
+ <p>The intention of placing the empty symbol in <RT·math>Γ</RT·math> but not in <RT·math>Σ</RT·math> appears to be that of making the empty symbol serve double duty: firstly as a default value for a cell that has never been written, and secondly as a control component of a communications protocol. This protocol was designed by mathematicians with the intention of making it impossible for programmers to send studied string messages that cannot always be recovered by a receiving recognizer Turing Machine. In short, the empty symbol is also being used as an in-band EOT (end of transmission) symbol.</p>
+
+ <p>However, if this is the intention, the protocol is flawed, because Turing Machines are bestowed with the ability to erase characters. An input machine could, for example, happily output an array of strings while using an arbitrary number of empty symbols to separate the elements of a variable-length array. A receiving machine could then not know how many elements it should try to recover, or when to say a separator is sufficiently long to no longer be considered a separator. Nothing in the Turing Machine definition prevents this.</p>
+
+ <p>Furthermore, the Universal Turing Machine can act as the aforementioned higher authority. In this case, Turing Machines, and sometimes their tapes, are written to a Universal Turing Machine's tape. Consequently, it is not only possible to want to terminate multiple strings in series, as mentioned in the prior paragraph; the termination issue itself is embedded in proofs such as the Halting Problem.</p>
+
+ <p>A common technique programmers use for embedding strings with terminators within other strings is to embed escape characters. This is another in-band protocol, and it is inefficient. The escape sequences grow exponentially with nesting levels. Also, such strings with embedded escape sequences cannot be interpreted without knowledge of the intended nesting level of the string author, which requires the interpreter of the string to know the author's intentions.</p>
+
+ <p>For the modified computational Turing machine presented later in this chapter, there will be a separate control alphabet, as for the Hopcroft-Ullman interpretation. However, due to the reasons presented in this section, that alphabet will be part of the alphabet <RT·math>Σ</RT·math> rather than distinct from it. Programmers then must explicitly design communication protocols that suit the problem they are working on, and those protocols become opaque for examination by a higher authority.</p>
+
+ <h2>The <RT·code>unspecified</RT·code></h2>
+
+ <p>In the first edition of this book, I introduced a "no read until after write" rule while working towards an architectural Turing Machine so as to sideline the empty symbol, because real machines do not have them. This did not replace the need for a communication protocol for sending messages between machines, but it did make it possible to remove the empty symbol from programmed controller definitions.</p>
+
+ <p>The standard 9-track tape introduced by IBM in 1964 came from the factory unformatted. The format operation would write a header and an EOF marker to mark the end of the device file. Then, a standard library call such as open(), followed by write(), would write over the EOF marker, continue writing data, and finally append a new EOF marker, essentially pushing the EOF boundary back. EOF could be pushed back until the physical EOT marker was struck. This matches, in some ways, how the empty symbol is used on the computation theoretic Turing Machine in the Hopcroft and Ullman book if we consider it to be an EOF marker. However, a difference exists in that the real machine would never use an EOF to erase data characters.</p>
+
+ <p>While using the standard library to write tapes, the empty part of the tape could not be read until after it was written, so early tape machines indeed enforced the "no read until after a write" rule. However, if the programmer were to seek the head back into the device file to do fresh work and perform reads and writes, the device EOF would be nowhere in sight. The burden of the "no read until after a write" rule would then fall on the shoulders of the programmer, as would the structuring of the data.</p>
+
+ <p>Core memory, and later system memory, was random access and initially fully accessible. The data would be whatever scrambled mess the machine booted with, or in early virtual memory systems, whatever was left over from the prior use of the page. The approach of recycling pages was a security hazard, so today a page is initially allocated from a read-only zero page, and due to a copy-on-write trap, a new page will be created in memory then scrubbed with zeros. If the computational Turing Machine's empty symbol maps to a word of zeros, then the empty symbol remains a poor model, because generally the data message, say sent between the <em>input</em> writer and the <em>recognizer</em> receiver, will also contain many zeros. The advantage is that if a programmer attempts to dereference a zero pointer, a segmentation fault occurs. So in this system, the program is again burdened with maintaining the "no read until after a write" rule.</p>
+
+ <p>A violation of "read only after a write" could be detected by a modified computation theoretic Turing Machine if, instead of an empty symbol, the initial tape is filled with the <RT·code>unspecified</RT·code> symbol. The end objective is to detect an erroneous condition, which is useful for debugging and testing. Normally, Turing Machine design does not concern itself with those design steps, as it is busy answering questions about known working programs. Though perhaps an algorithm could be studied for this very quality of not ever making decisions based on unspecified data. Nor do real machines have an <RT·code>unspecified</RT·code> symbol; rather, a program reads garbage from memory locations with unspecified data. However, there is some precedent with hardware simulators, which typically support an <RT·code>x</RT·code> standing for an 'unknown' logic value.</p>
+
+ <p>Like the <RT·code>empty</RT·code> symbol, <RT·code>unspecified</RT·code> is a meta-symbol. It describes the data, or lack thereof, rather than being the data. Specifically, the <RT·code>unspecified</RT·code> symbol says that there is a singular alphabet symbol at the memory location, but the machine is not being instructed as to which symbol it is. Because the Turing Machine state transition function requires a specific symbol value, reading an <RT·code>unspecified</RT·code> symbol would break the machine. Of course, that would be a bad thing, so some sort of modification to the Turing Machine definition is required for working with an <RT·code>unspecified</RT·code> symbol.</p>
+
+ <p>The three reasons that data can be unspecified are that it was not initialized, that the history that led up to it is unknown by the program doing the read, or that it was written from the output of a true random number generator. Technically, the output of a pseudo-random number generator belongs in the 'unknown history' category. An example of purposefully ignoring history would be a program that reverses a string without looking at the values being reversed. A string reverse function need not be apprised of the value of the string being reversed; it need only be aware of the structure given to it according to the protocol followed by the machine that wrote the string.</p>
+
+ <p>Given the conventional Turing Machine definition, it is impossible to write a string reverse function that does not look at the value of the data being reversed. This is because reading the value under the head is integrated into the machine definition, so it always happens, and it always gates the next state transition function.</p>
+
+ <h2>The TTCA computation theoretic Turing Machine</h2>
+
+ <p>A goal of the computation theorist in defining a Turing Machine is to make the math concise and elegant. This notation qualifies. However, the goal of the computer architect is to define a machine that is intuitive to design and test, and that performs well. Perhaps if a computer architect were to define the computational Turing Machine, this change in emphasis would favor a different definition.</p>
+
+ <p>The following modifications will be made to the computation theoretic Turing Machine definition so as to support the <RT·code>unspecified</RT·code> symbol.</p>
+ <ol>
+ <li>Move to a Moore style programmed state controller, so that actions can be managed separately from state transitions.</li>
+ <li>Among the new explicit actions, have two read instructions—a state transition gating symbol read, and a data symbol read—along with two variables to hold the read results.</li>
+ <li>To match the two read functions, the write function can specify which of the read buffer contents to put on the tape.</li>
+ <li>If the <RT·code>unspecified</RT·code> symbol is read into a register, the machine transitions to the predefined unspecified-decision state rather than failing.</li>
+ </ol>
+
+ <p>For ease of programming, the new machine will have three layers of next-state functions. First used is the state function that takes into account both the current state and the control read value. If no next state is defined by it, then a second next-state function is called; in this case, the current state is not an operand. This is for defining default arcs. If a next state is still not defined, then we move to a third next-state function which is unconditional. This is the state the machine goes to if there is no next state specified and there is no default next state defined.</p>
+
+ <p>For clarity of presentation, the definition will be split into two parts: that which is fixed as part of the Turing Machine definition, and that which is programmable.</p>
+
+ <p>There is a mechanical procedure for converting a Moore Machine into a Mealy Machine, and the reverse. Two such converted machines are equally expressive. Making the read operation an explicit action, instead of having it implied by a state transition, increases the number of states in a controller, and consequently the number of steps that must be taken. However, the new machine can do in two steps anything the former machine could do in one; consequently, this change affects the multiplier constant on the linear term of the step count formula but does not change the computation complexity class determined from such a step count. The three layers of next-state functions are equivalent to one layer where the missing arguments are filled in with all possible values. This potentially increases the number of state transition arcs that must be specified, but the state transition logic and the number of states remain unchanged. Giving the specification in two parts does not change the total specification. Hence, these modifications are computationally inconsequential.</p>
+
+ <h3>The TTCA Turing Machine fixed part</h3>
+
+ <p><RT·math>
+ MF = (QF, ΣF, AF, λF)
+ </RT·math></p>
+
+ <p><RT·math>QF</RT·math>: The set of predefined <em>states</em>, including <RT·math>QF.\mathtt{initial}</RT·math> and <RT·math>QF.\mathtt{unspecified\_decision}</RT·math>.</p>
+
+ <p><RT·math>ΣF</RT·math>: The set of predefined symbols, including <RT·math>ΣF.\mathtt{unspecified}</RT·math> and <RT·math>ΣF.\mathtt{left\_of\_leftmost}</RT·math>.</p>
+
+ <p><RT·math>AF</RT·math>: The set of available actions {<RT·math>\mathtt{no\_op}</RT·math>, <RT·math>\mathtt{left}</RT·math>, <RT·math>\mathtt{right}</RT·math>, <RT·math>\mathtt{write\_σ}(σ)</RT·math>, <RT·math>\mathtt{write\_d}</RT·math>, <RT·math>\mathtt{write\_g}</RT·math>}, where <RT·math>σ</RT·math> must be in <RT·math>Σ</RT·math>.</p>
+
+ <p><RT·math>λF</RT·math>: The predefined action table. A set of pairs of the form <RT·math>\langle q_0, a \rangle</RT·math>, where <RT·math>q_0</RT·math> is the current state, and <RT·math>a</RT·math> is a member of <RT·math>AF</RT·math>.</p>
+
+ <h3>The TTCA Turing Machine variables</h3>
+
+ <RT·math>
+ MV = (q, d, g)
+ </RT·math>
+
+ <p><RT·math>q</RT·math>: is the current state of the machine.</p>
+ <p><RT·math>d</RT·math>: is the data register.</p>
+ <p><RT·math>g</RT·math>: is the gate register.</p>
+
+ <h3>The TTCA Turing Machine programmable part</h3>
+
+ <p><RT·math>
+ MP = (QP, ΣP, λP, δ, δ_0, δ_{00})
+ </RT·math></p>
+
+ <p><RT·math>QP</RT·math>: A set of programmed <em>state</em> symbols.</p>
+
+ <p><RT·math>ΣP</RT·math>: A set of programmed data symbols.</p>
+
+ <p><RT·math>λP</RT·math>: The programmed actions. A set of pairs of the form <RT·math>\langle q_0, a \rangle</RT·math>, where <RT·math>q_0</RT·math> is the current state, and <RT·math>a</RT·math> is a member of <RT·math>AF</RT·math>.</p>
+
+ <p><RT·math>δ</RT·math>: A set of state transition triples; each triple is of the form <RT·math>\langle q_0, r.σ, q_1 \rangle</RT·math>. <RT·math>q_0</RT·math> is matched to the current state of the machine. <RT·math>r.σ</RT·math> is a symbol in register <RT·math>r</RT·math>. <RT·math>q_1</RT·math> is the next state. <RT·math>q_0</RT·math> and <RT·math>q_1</RT·math> come from the total set <RT·math>Q</RT·math>. <RT·math>σ</RT·math> comes from the total set <RT·math>Σ</RT·math>. <RT·math>r</RT·math> is either <RT·math>d</RT·math> or <RT·math>g</RT·math>.</p>
+
+ <p><RT·math>δ_0</RT·math>: The default transition table. A set of state transition pairs; each pair is of the form <RT·math>\langle r.σ, q_1 \rangle</RT·math>. <RT·math>r.σ</RT·math> is a symbol found in the specified register, either <RT·math>d</RT·math> or <RT·math>g</RT·math>. <RT·math>q_1</RT·math> will be taken as the next state.</p>
+
+ <p><RT·math>δ_{00}</RT·math>: A default next state.</p>
+
+ <h3>The TTCA Turing Machine in total</h3>
+
+ <p><RT·math>
+ M = (Q, Σ, A, λ, δ, δ_0, δ_{00})
+ </RT·math></p>
+
+ <p><RT·math>Q</RT·math>: The complete set of states, uniting the fixed predefined states and the programmed states (<RT·math>QF \cup QP</RT·math>).</p>
+
+ <p><RT·math>Σ</RT·math>: The complete set of symbols, uniting the fixed control symbols and the programmed data symbols (<RT·math>ΣF \cup ΣP</RT·math>).</p>
+
+ <p><RT·math>A</RT·math>: The complete set of available actions the machine can execute. Because the operational mechanics are strictly architectural, this is exactly the fixed set <RT·math>AF</RT·math>.</p>
+
+ <p><RT·math>λ</RT·math>: The complete action table mapping states to actions, uniting the predefined actions and the programmed actions (<RT·math>λF \cup λP</RT·math>).</p>
+
+ <p><RT·math>δ</RT·math>: The highest priority programmed next-state transition rules, requiring both a matching state and a matching read symbol to gate the transition.</p>
+
+ <p><RT·math>δ_0</RT·math>: The secondary default transition rules, evaluated solely on the read symbol if <RT·math>δ</RT·math> yields no next state.</p>
+
+ <p><RT·math>δ_{00}</RT·math>: The final unconditional next state, taken if neither <RT·math>δ</RT·math> nor <RT·math>δ_0</RT·math> provides a valid transition.</p>
+
+
+-----
+
+ <RT·chapter>The computation theoretic Turing Machine</RT·chapter>
<h2>The Hopcroft and Ullman Turing Machine</h2>