check point
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Fri, 7 Aug 2026 09:11:07 +0000 (09:11 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Fri, 7 Aug 2026 09:11:07 +0000 (09:11 +0000)
document/book/TM-2026.html
setup [changed mode: 0644->0755]

index f169f17..0bec940 100644 (file)
 
       <p>Here is the programmed controller for a Turing Machine that reverses a binary string. Although by definition each state transition matches exactly one value under the head, as a practical matter, disjunctive selection is allowed via a comma list. A conjunctive phrasing for a state transition proposition would require stringing intermediate states in series.</p>
 
-      <img src="HU_style_TM_reverse.png" class="rt-diagram" alt="HU reverse machine">
+      <img src="HU_style_TM_reverse.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>
 
 
       <p>The total number of steps for reversing an <RT·math>n</RT·math> symbol string:</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          \text{steps} =
-          \begin{cases}
-            2 & \text{if } n = 0 \\
-            3n^2 + 6n + 5 & \text{if } n \ge 1
-          \end{cases}
-        </RT·math>
-      </div>
+      <RT·math>
+        \text{steps} =
+        \begin{cases}
+        2 & \text{if } n = 0 \\
+        3n^2 + 6n + 5 & \text{if } n \ge 1
+        \end{cases}
+      </RT·math>
 
       <p>This shows string reversal to be an <RT·math>O(n^2)</RT·math> complexity problem, which might appear to some programmers as a peculiar result, as the same problem can be solved in <RT·math>O(n)</RT·math> time with a C program. This justifies further analysis.</p>
 
 
       <p>For a real machine, symbols are machine word encodings. For example, ASCII uses 7 data bits, so there are 128 symbols available. If the width of the word for encoding symbols is <RT·math>n</RT·math> bits, then the total number of states required for this string reverse machine is:</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          \text{states} = 2^n + 8
-        </RT·math>
-      </div>
+      <RT·math>
+        \text{states} = 2^n + 8
+      </RT·math>
 
       <p>The number of arcs in the machine:</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          \text{arcs} = 2^{2n} + 9(2^n) + 12
-        </RT·math>
-      </div>
+      <RT·math>
+        \text{arcs} = 2^{2n} + 9(2^n) + 12
+      </RT·math>
 
       <p>These equations show that the state controller size explodes with word width. It would be impractical to implement for all but the smallest of word sizes. This is one of the reasons that computation theory books use modest-sized symbol alphabets in their examples, perhaps the first few letters of the Latin alphabet, or the letter 's' for unary arithmetic. Previous sections discussed challenges transitioning the Turing Machine to a real architecture due to the tape length, and discussed how this could be mitigated. In contrast, there is no practical mediation for implementing a Turing Machine controller even for modest-sized real problems.</p>
 
 
       <p>Because emptiness is a property of a container, Turing's first statement can be modeled with a sequence of sets. For a Turing Machine tape, each sequence member is either an empty set or a singleton set. In the language of mathematics an empty tape can be defined as a empty sets:</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          T_0 = [ \{ \}, \{ \}, \{ \}, \dots ]
-        </RT·math>
-      </div>
+      <RT·math>
+        T_0 = [ \{ \}, \{ \}, \{ \}, \dots ]
+      </RT·math>
 
       <p>Here, each tape member set is called a <RT·term>cell</RT·term>. This definition for an empty tape is specific to Turing Machines, as in mathematics an empty sequence has zero length. An empty tape is not an empty sequence, rather it is an infinite sequence where every member is an empty set. In one sense this is a little peculiar that something said to be empty is infinite, in another sense it is consistent for the model that an empty Turing Machine tape keeps its defining characteristics. That is, it remains a single ended Turing Machine tape, where any cell of the tape could be written with a symbol value, while the basic form of the tape will not change.</p>
 
 
       <p>Now imagine machine B, where the concept of an empty cell is jettisoned, and what remains is the mere memory of emptiness, a symbol called <RT·code>empty</RT·code>. Then using the language of mathematics, the mathematician defines an initial empty tape as:</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          T_0 = [ \mathtt{empty}, \mathtt{empty}, \mathtt{empty}, \ldots ]
-        </RT·math>
-      </div>
+      <RT·math>
+        T_0 = [ \mathtt{empty}, \mathtt{empty}, \mathtt{empty}, \ldots ]
+      </RT·math>
 
       <p>For machine B, no modifications are required to the native <RT·code>read</RT·code> and <RT·code>write</RT·code> functions.</p>
 
 
       <h2>The TTCA Machine fixed part</h2>
 
-      <div style="margin-left: 2em;">
-        <RT·math> \mathit{MF} = (\mathit{QF}, \mathit{ΣF}, \mathit{AF}) </RT·math>
-      </div>
+      <RT·math> 
+        \mathit{MF} = (\mathit{QF}, \mathit{ΣF}, \mathit{AF}) 
+      </RT·math>
 
       <p>In the following, the middle dot acts as a namespace operator, <RT·math>N{·}x</RT·math>. By doing this we assure there will be no aliasing with the symbols provided by the programmer when he defines a programmed state controller.</p>
 
       <p>The set of predefined <em>states</em>:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>\mathit{QF} = \{\mathit{QF}{·}\mathtt{initial}\}</RT·math>
-      </div>
+
+      <RT·math>
+        \mathit{QF} = \{\mathit{QF}{·}\mathtt{initial}\}
+      </RT·math>
+
 
       <p>The state controller always starts in the <RT·code>QF·initial</RT·code> state. This is a symbol representing the state; it is not a register that holds a state. The 'F' values are all fixed.</p>
 
       <p>The programmer cannot add instructions to the machine definition, so there are no symbol aliasing issues here:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>
-          \begin{aligned}
-            \mathit{AF} = \{& \\
-              & \mathtt{no\_op} \\
-             ,& \mathtt{left} \\
-             ,& \mathtt{right} \\
-             ,& \mathtt{read}(\mathtt{d} \mid \mathtt{s}) \\
-             ,& \mathtt{status} \\
-             ,& \mathtt{write}(\mathtt{d} \mid \mathtt{s} \mid \mathtt{σ}, [σ]) \\
-             \}
-          \end{aligned}
-        </RT·math>
-      </div>
+
+      <RT·math>
+        \begin{aligned}
+        \mathit{AF} = \{& \\
+        & \mathtt{no\_op} \\
+        ,& \mathtt{left} \\
+        ,& \mathtt{right} \\
+        ,& \mathtt{read}(\mathtt{d} \mid \mathtt{s}) \\
+        ,& \mathtt{status} \\
+        ,& \mathtt{write}(\mathtt{d} \mid \mathtt{s} \mid \mathtt{σ}, [σ]) \\
+        \}
+        \end{aligned}
+      </RT·math>
+
       <p>where <RT·math>σ</RT·math> must be in <RT·math>Σ</RT·math>.</p>
 
       <p>The set of predefined symbols:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>\mathit{ΣF} = \{\mathit{ΣF}{·}\mathtt{leftmost}\}</RT·math>
-      </div>
+
+      <RT·math>
+        \mathit{ΣF} = \{\mathit{ΣF}{·}\mathtt{leftmost}\}
+      </RT·math>
 
       <h2>Machine variables</h2>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          \mathit{MV} = (q, s, d)
-        </RT·math>
-      </div>
+      <RT·math>
+        \mathit{MV} = (q, s, d)
+      </RT·math>
 
       <p><RT·code>q</RT·code>: is the current state of the machine.</p>
 
 
       <h2>Programmable part</h2>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          \mathit{MP} = (\mathit{QP}, \mathit{ΣP}, \mathit{ΛP}, Δ_0, Δ_1, Δ_2, Δ_3, \mathit{HP})
-        </RT·math>
-      </div>
+      <RT·math>
+        \mathit{MP} = (\mathit{QP}, \mathit{ΣP}, \mathit{ΛP}, Δ_0, Δ_1, Δ_2, Δ_3, \mathit{HP})
+      </RT·math>
 
       <p>A set of programmed <em>state</em> symbols:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>\mathit{QP}</RT·math>
-      </div>
+
+      <RT·math>
+        \mathit{QP}
+      </RT·math>
+
 
       <p>A set of programmed data symbols:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>\mathit{ΣP}</RT·math>
-      </div>
+
+      <RT·math>
+        \mathit{ΣP}
+      </RT·math>
 
       <p>The programmed instructions. A set of pairs of the form:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>\mathit{ΛP} = \{ \langle q_i, a \rangle, \dots \}</RT·math>
-      </div>
+      
+      <RT·math>
+        \mathit{ΛP} = \{ \langle q_i, a \rangle, \dots \}
+      </RT·math>
+
       <p>where <RT·math>q_i</RT·math> is matched to the current state, and <RT·math>a</RT·math> is a member of <RT·math>\mathit{A}</RT·math>.
       </p>
 
       <p>The conditional transition table. A set of state transition triples; each triple is of the form:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>Δ_0 = \{ \langle q_i, σ, q_{i+1} \rangle, \dots \}</RT·math>
-      </div>
+
+      <RT·math>
+        Δ_0 = \{ \langle q_i, σ, q_{i+1} \rangle, \dots \}
+      </RT·math>
+
       <p>Here <RT·math>q_i</RT·math> and <RT·math>q_{i+1}</RT·math> are two states from the total set of <RT·math>Q</RT·math>. They need not be distinct.  While the machine is running, state <RT·math>q_i</RT·math> is to be matched against the contents of the <RT·code>q register</RT·code>, the current state. Symbol <RT·math>σ</RT·math> is a member of the total set <RT·math>Σ</RT·math> and is to be matched against the contents of the <RT·code>s register</RT·code>, the machine status. When <RT·math>q_i</RT·math> matches the current state and <RT·math>σ</RT·math> matches the current status, then <RT·math>q_{i+1}</RT·math> becomes the next state.</p>
 
       <p>The state default transition table. A set of state transition pairs; each pair is of the form:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>Δ_1 = \{ \langle q_i, q_{i+1} \rangle, \dots \}</RT·math>
-      </div>
+
+      <RT·math>
+        Δ_1 = \{ \langle q_i, q_{i+1} \rangle, \dots \}
+      </RT·math>
+
       <p>where <RT·math>q_i</RT·math> is matched to the current state, and upon a match <RT·math>q_{i+1}</RT·math> will be taken as the next state.</p>
 
       <p>The status default transition table. A set of state transition pairs; each pair is of the form:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>Δ_2 = \{ \langle σ, q_{i+1} \rangle, \dots \}</RT·math>
-      </div>
+
+      <RT·math>
+        Δ_2 = \{ \langle σ, q_{i+1} \rangle, \dots \}
+      </RT·math>
+
       <p>where <RT·math>σ</RT·math> matches the symbol in <RT·code>s register</RT·code>, and upon a match <RT·math>q_{i+1}</RT·math> will be taken as the next state.</p>
 
       <p>The global default next state:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>Δ_3 = q_{i+1}</RT·math>
-      </div>
+
+      <RT·math>
+        Δ_3 = q_{i+1}
+      </RT·math>
+
       <p>This is the transition of last resort. It is unconditional; the next state becomes <RT·math>q_{i+1}</RT·math>.</p>
 
       <p>A set of programmer-defined halting states:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>\mathit{HP}</RT·math>
-      </div>
+
+      <RT·math>
+        \mathit{HP}
+      </RT·math>
+
 
       <h2>The TTCA Machine definition in total</h2>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          M = (q, s, d, Q, Σ, A, Λ, Δ, H)
-        </RT·math>
-      </div>
+      <RT·math>
+        M = (q, s, d, Q, Σ, A, Λ, Δ, H)
+      </RT·math>
+
 
       <p>The variables used by the executor, <RT·math>\mathit{MV} = (q, s, d)</RT·math>.</p>
 
       <p>The complete set of states, uniting the fixed predefined states and the programmed states:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>Q = \mathit{QF} \cup \mathit{QP}</RT·math>
-      </div>
+
+      <RT·math>
+        Q = \mathit{QF} \cup \mathit{QP}
+      </RT·math>
 
       <p>The complete set of symbols, uniting the fixed control symbols and the programmed data symbols:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>Σ = \mathit{ΣF} \cup \mathit{ΣP}</RT·math>
-      </div>
+
+      <RT·math>
+        Σ = \mathit{ΣF} \cup \mathit{ΣP}
+      </RT·math>
 
       <p>All members of the set of available instructions are fixed:</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>A = \mathit{AF}</RT·math>
-      </div>
+      <RT·math>
+        A = \mathit{AF}
+      </RT·math>
 
       <p>The table of state-instruction pairs is strictly programmed.</p>
-      <div style="margin-left: 2em;">
-        <RT·math>Λ = \mathit{ΛP}</RT·math>
-      </div>
+
+      <RT·math>
+        Λ = \mathit{ΛP}
+      </RT·math>
 
       <p>The ordered sequence of next state transition rules:</p>
-      <div style="margin-left: 2em;">
-        <RT·math>Δ = [Δ_0 \mid Δ_1 \mid Δ_2 \mid Δ_3]</RT·math>
-      </div>
+
+      <RT·math>
+        Δ = [Δ_0 \mid Δ_1 \mid Δ_2 \mid Δ_3]
+      </RT·math>
 
       <p>The set of halt states is strictly programmed, and thus could be empty.</p>
-      <div style="margin-left: 2em;">
-        <RT·math>H = \mathit{HP}</RT·math>
-      </div>
+
+      <RT·math>
+        H = \mathit{HP}
+      </RT·math>
+
 
       <h2>Computation theoretic TTCA Machine executor</h2>
 
             Q·Done
       </RT·code>
 
-      <img src="TTCA_style_TM_reverse.png" class="rt-diagram" alt="TTCAM reverse machine">
+      <img src="TTCA_style_TM_reverse.png" class="RT-diagram" alt="TTCAM reverse machine">
 
       <h2>Analysis of the TTCA reverse machine</h2>
 
 
       <p>The total number of steps for reversing an <RT·math>n</RT·math> symbol string using the TTCA Machine:</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          \text{steps} =
-          \begin{cases}
-            7 & \text{if } n = 0 \\
-            4.5n^2 + 11.5n + 5 & \text{if } n \ge 1
-          \end{cases}
-        </RT·math>
-      </div>
+      <RT·math>
+        \text{steps} =
+        \begin{cases}
+        7 & \text{if } n = 0 \\
+        4.5n^2 + 11.5n + 5 & \text{if } n \ge 1
+        \end{cases}
+      </RT·math>
+
 
       <h2>Two-headed reverse string example</h2>
 
             Q·Done
       </RT·code>
 
-      <img src="TTCA_2_hd_reverse.png" class="rt-diagram" alt="TTCAM 2 hd reverse machine">
+      <img src="TTCA_2_hd_reverse.png" class="RT-diagram" alt="TTCAM 2 hd reverse machine">
 
       <h2>Analysis of the two-headed reverse string machine</h2>
 
       <p>The number of states has dropped from 24 to 18, while the speed increase is dramatic, with the former quadratic performance becoming linear performance. The total number of steps for reversing an <RT·math>n</RT·math> symbol string using a two-head TTCA architecture:</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>
-          \text{steps} =
-          \begin{cases}
-            4 & \text{if } n = 0 \\
-            9n + 4 & \text{if } n \ge 1
-          \end{cases}
-        </RT·math>
-      </div>
+
+      <RT·math>
+        \text{steps} =
+        \begin{cases}
+        4 & \text{if } n = 0 \\
+        9n + 4 & \text{if } n \ge 1
+        \end{cases}
+      </RT·math>
 
       <p>The two paths through the state machine, and the one loop, translate well into code:</p>
 
       <!--------------------------------------------------------------------------------->
       <RT·chapter>The TTCA Machine design</RT·chapter>
 
-      <figure>
-        <img src="machine fig.png" class="rt-diagram" alt="Figure 1: A Turing Machine">
-        <figcaption>Figure 1: A Turing Machine</figcaption>
-      </figure>
+      <img src="machine fig.png" class="RT-diagram" alt="Figure 1: A Turing Machine">
+      <!--<figcaption>Figure 1: A Turing Machine</figcaption>-->
 
       <p>The prior chapter on the computation theoretic TTCA machine serves as the architectural template, with only a few modifications. The architecture requires explicit data rather than accepting meta-symbols like 'unspecified' as presumed initial values 'by definition'. Actual values are transacted. Now that data and control have been separated, the controller is practical to implement, and even more so because it was defined in terms of tables that can be built in hardware. As the read status instruction returns the cell type, it will in its current form be able to return 'rightmost', so the right end of the tape can be detected. In order to extend the tape, the machine will stop and ask the operator to mount a new reel. This could be signaled when the user attempts to step right of rightmost, either by a panel light that illuminates upon the machine finding a rightmost status, or by the program printing a message on the console teletype. As this is a constant-time operation, it is computation theoretic inconsequential.</p>
 
       <h2>The machine block diagram</h2>
 
       <figure>
-        <img src="TTCA_machine.svg" class="rt-diagram" alt="Figure: TTCA block diagram">
+        <img src="TTCA_machine.svg" class="RT-diagram" alt="Figure: TTCA block diagram">
         <figcaption>Figure: TTCA block diagram</figcaption>
       </figure>
 
@@ -1941,9 +1946,7 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
 
       <p>A person interprets these sequences as numbers by using a weighted sum.</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>a = \sum_{i=0}^n x_i \cdot ten^i</RT·math>
-      </div>
+      <RT·math>a = \sum_{i=0}^n x_i \cdot ten^i</RT·math>
 
       <p>Here <RT·math>a</RT·math> is a numeric value, so it is written in lower case. Each <RT·math>x_i</RT·math> is the <RT·math>i</RT·math>th component of the sequence <RT·math>X</RT·math>. The value <RT·math>x_i</RT·math> is also known as the '<RT·math>i</RT·math>th digit' of the number. The value ten is called the base or the radix of the number. It is fortunate that ten is so well known that it has a name, because otherwise an author is tempted to write the base while using the exact representation that he is trying to define. Although this function gives numeric meaning to our digit sequences, performing the suggested computation is pointless. The result is a number, and a person must represent that number, resulting in the exact sequence that was given as the input to the function in the first place.</p>
 
@@ -2011,9 +2014,7 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
 
       <p>A person interprets a sequence of <RT·math>n</RT·math> bits as a number by using this function:</p>
 
-      <div style="margin-left: 2em;">
-        <RT·math>\sum_{i=0}^n x_i \cdot two^i</RT·math>
-      </div>
+      <RT·math>\sum_{i=0}^n x_i \cdot two^i</RT·math>
 
       <p>As with sequences of decimal digits, a person drops the sequence notation to yield strings of bits. Similar to decimal digit strings, there are two options for writing the string: most-significant-digit-first, or least-significant-digit-first.</p>
 
@@ -2107,14 +2108,14 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
       <p>Figure 10 depicts a word featuring byte addresses represented in hexadecimal, running from c0 to c3. (In decimal these addresses represent 192, 193, 194, 195). The address of the byte before c0 is bf. The address after c3 is c4. The address for the word itself evaluates to c0, as it is the minimum byte address. This word holds a little-endian number. Treating a byte as an octet digit, the binary encoding for the least-significant digit of this number is 0001 1000. The most-significant digit is 1010 1110.</p>
 
       <figure>
-        <img src="Hindu-Arabic number fig 1.png" class="rt-diagram" alt="Figure 10: Left justified, least-significant-digit-first">
+        <img src="Hindu-Arabic number fig 1.png" class="RT-diagram" alt="Figure 10: Left justified, least-significant-digit-first">
         <figcaption>Figure 10: Left justified, least-significant-digit-first</figcaption>
       </figure>
 
       <p>In Figure 11, the same number populates the word using big-endian architecture. For all but very large numbers, the digit pointed at by the allocation pointer evaluates to zero. A system continues to scan zeros until reaching either the end of the allocation or the most-significant digit. If it reaches the end of the allocation, the contained number evaluates to zero. Because this is the exact same number shown in the prior figure, it retains the identical least-significant digit and most-significant digit.</p>
 
       <figure>
-        <img src="Hindu-Arabic number fig 2.png" class="rt-diagram" alt="Figure 11: Same number using big-endian digit order">
+        <img src="Hindu-Arabic number fig 2.png" class="RT-diagram" alt="Figure 11: Same number using big-endian digit order">
         <figcaption>Figure 11: Same number using big-endian digit order</figcaption>
       </figure>
 
@@ -2149,14 +2150,14 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
       <p>The following figure displays a stream of bytes arriving as data and being copied into a word. The digits of the word (the bytes) arrive in little-endian order and target a little-endian machine, so they are written in the exact order they are scanned off the channel.</p>
 
       <figure>
-        <img src="Hindu-Arabic number fig 3.png" class="rt-diagram" alt="Figure 12: In-address-order byte by byte copy">
+        <img src="Hindu-Arabic number fig 3.png" class="RT-diagram" alt="Figure 12: In-address-order byte by byte copy">
         <figcaption>Figure 12: In-address-order byte by byte copy</figcaption>
       </figure>
 
       <p>In the second case, the identical data stream arrives with words serialized as bytes in little-endian order, but the receiving machine is big-endian. The system must reverse the bytes strictly on a word-by-word basis.</p>
 
       <figure>
-        <img src="Hindu-Arabic number fig 4.png" class="rt-diagram" alt="Figure 13: Reverse order byte copy for words">
+        <img src="Hindu-Arabic number fig 4.png" class="RT-diagram" alt="Figure 13: Reverse order byte copy for words">
         <figcaption>Figure 13: Reverse order byte copy for words</figcaption>
       </figure>
 
@@ -3054,17 +3055,17 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
         The exact algebraic composition of this mechanical expansion is formalized by Newton's calculus of finite differences <RT·endnote>Isaac Newton formalized this interpolation method in 1675, later published in his <em>Methodus Differentialis</em> (1711). For a comprehensive foundational treatment, see George Boole, <em>A Treatise on the Calculus of Finite Differences</em> (Cambridge: Macmillan and Co., 1860), Chapter II.</RT·endnote>. Instead of executing the machine incrementally, a person can calculate the function value at call <RT·math>\omega</RT·math> directly as a linear combination of the initial tape components using Newton's forward difference formula:
       </p>
 
-      <p>
-        <RT·math>D_{\omega, 0} = \sum_{j=0}^{\omega} \binom{\omega}{j} D_{0, j}</RT·math>
-      </p>
+      <RT·math>
+        D_{\omega, 0} = \sum_{j=0}^{\omega} \binom{\omega}{j} D_{0, j}
+      </RT·math>
 
       <p>
         Because the binomial coefficient <RT·math>\binom{\omega}{j}</RT·math> evaluates to exactly zero for any integer <RT·math>j > \omega</RT·math>, the summation naturally truncates at index <RT·math>\omega</RT·math>. This algebraic property perfectly mirrors the physical boundary established by the machine execution trace. Furthermore, the relationship is symmetric. A person can compute the specific components of the initial tape, <RT·math>D_{0, n}</RT·math>, directly from the sequence of evaluated function calls, <RT·math>D_{k, 0}</RT·math>, using the alternating binomial sum:
       </p>
 
-      <p>
-        <RT·math>D_{0, n} = \sum_{k=0}^{n} (-1)^{n-k} \binom{n}{k} D_{k, 0}</RT·math>
-      </p>
+      <RT·math>
+        D_{0, n} = \sum_{k=0}^{n} (-1)^{n-k} \binom{n}{k} D_{k, 0}
+      </RT·math>
 
       <p>
         As a consequence of this lemma, we know that for any finite number of calls, i.e. finite <RT·math>\omega</RT·math>, that a finite prefix of <RT·math>D_0</RT·math> is used.
@@ -3173,9 +3174,9 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
         The main diagonal contains strictly non zero factorials, ensuring the matrix is invertible. By inverting this matrix, a person replaces the cascading back substitution with a direct, closed form equation to recover any constant <RT·math>a_i</RT·math>. The inversion utilizes the signed Stirling numbers of the first kind, denoted <RT·math>s(n,i)</RT·math> (see the Appendix on Stirling numbers).
       </p>
 
-      <p>
-        <RT·math>a_i = \sum_{n=i}^{\omega} \frac{s(n,i)}{n!} D_{0,n}</RT·math>
-      </p>
+      <RT·math>
+        a_i = \sum_{n=i}^{\omega} \frac{s(n,i)}{n!} D_{0,n}
+      </RT·math>
 
       <p>
         Thus, extending this procedure <RT·math>\omega</RT·math> times definitively recovers the constants for exactly a polynomial of degree <RT·math>\omega</RT·math>.
@@ -3185,9 +3186,9 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
         This mechanical recovery of standard polynomial constants is completely analogous to Newton's interpolation formula <RT·endnote>Ibid.</RT·endnote>. Instead of resolving the standard constants <RT·math>a_i</RT·math> through an upper triangular matrix, a person can construct the polynomial directly by treating the initial tape components as the exact coefficients for a basis of binomial terms:
       </p>
 
-      <p>
-        <RT·math>f(t) = \sum_{n=0}^{\omega} D_{0, n} \binom{t}{n}</RT·math>
-      </p>
+      <RT·math>
+        f(t) = \sum_{n=0}^{\omega} D_{0, n} \binom{t}{n}
+      </RT·math>
 
       <p>
         Because the <RT·math>n</RT·math>th binomial coefficient expands into a polynomial of exactly degree <RT·math>n</RT·math>, and the summation is bounded by the finite extent <RT·math>\omega</RT·math> where <RT·math>D_{0, \omega}</RT·math> is definitively nonzero, the constructed function <RT·math>f(t)</RT·math> is structurally guaranteed to be a polynomial of degree <RT·math>\omega</RT·math>.
@@ -3284,7 +3285,7 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
         h(t) = \frac{f(t)}{g(t)} = \frac{2^t - 32}{3t - 15}
       </RT·math>
 
-      <img src="singularity_plot.png" class="rt-diagram" alt="Figure singularity plot">
+      <img src="singularity_plot.png" class="RT-diagram" alt="Figure singularity plot">
 
 
       <p>
@@ -3386,7 +3387,7 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
         So then, perhaps we set the value at the singularity to <RT·math>x</RT·math> build out the difference table, then solve for <RT·math>x</RT·math>?
       </p>
 
-      <img src="with_x_variable.png" class="rt-diagram" alt="Figure with x variable.">
+      <img src="with_x_variable.png" class="RT-diagram" alt="Figure with x variable.">
 
 
       <p>
@@ -3415,9 +3416,9 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
 
       <p>The resulting <RT·math>D_0</RT·math> vector for the quotient is:</p>
 
-      <img src="D_10.png" class="rt-diagram" alt="Figure D_0 h(t)">
+      <img src="D_10.png" class="RT-diagram" alt="Figure D_0 h(t)">
 
-      <img src="h_of_t_D_table.png" class="rt-diagram" alt="Figure D table for h(t)">
+      <img src="h_of_t_D_table.png" class="RT-diagram" alt="Figure D table for h(t)">
 
       <p>
         I find it fascinating to watch the transcendental difference values march down the table, then all cancel out after <RT·math>h(5)</RT·math> is generated.
@@ -3514,7 +3515,7 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
       </p>
 
       <p>None of these computation systems, that of Boehm and Cartwright, Mathematica, nor my error analysis approach, makes use of the IEEE 754 standard floating point arithmetic. Rather they all require the use of variable precision. In the case of Boehm and Cartwright's this occurs through the serialization implied through lazy calls for more precision. In the case of Mathematica it is explicit in the significance arithmetic. In my error analysis approach, the means for variable precision was the High Radix Online Arithmetic <RT·endnote>Thomas W. Lynch, "High Radix On Line Arithmetic for Credible and Accurate Computing," Real Numbers and Computers, École des Mines de Saint Étienne, France, 1995, pp. 78 89.</RT·endnote> <RT·endnote>Thomas W. Lynch and Michael J. Schulte, "Software for High Radix On Line Arithmetic," Reliable Computing, vol. 2, no. 2, 1996, pp. 133 138. DOI: 10.1007/BF02425915.</RT·endnote>.
-        </p>
+      </p>
 
       <p>Hence what would be useful for a replacement of the IEEE 754, would be a variable precision number standard. There is one being proposed by John Gustafson called the Posit number representation <RT·endnote>John L. Gustafson, <em>The End of Error: Unum Computing</em>, Chapman and Hall/CRC, 2015. Posits serve as a hardware friendly alternative to IEEE 754 floating point numbers, providing variable precision mechanics.</RT·endnote>.
       </p>
@@ -3727,9 +3728,9 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
         However, in the calculus of finite differences, standard exponents are clumsy. Because the Turing Machine evaluates discrete jumps, the natural basis is the falling factorial, denoted as <RT·math>t^{\underline{n}}</RT·math>:
       </p>
 
-      <p>
-        <RT·math>t^{\underline{n}} = t(t - 1)(t - 2) ⋯ (t - n + 1)</RT·math>
-      </p>
+      <RT·math>
+        t^{\underline{n}} = t(t - 1)(t - 2) ⋯ (t - n + 1)
+      </RT·math>
 
       <p>
         When a person applies the discrete forward difference operator, <RT·math>δ</RT·math>, to a falling factorial, it behaves identically to the continuous derivative: <RT·math>δ(t^{\underline{n}}) = n t^{\underline{n - 1}}</RT·math>.
@@ -3759,9 +3760,9 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
         The signed Stirling numbers of the first kind perform the exact inverse operation. They reconstruct standard continuous powers from falling factorials:
       </p>
 
-      <p>
-        <RT·math>t^{\underline{n}} = \sum_{k=0}^n s(n,k) t^k</RT·math>
-      </p>
+      <RT·math>
+        t^{\underline{n}} = \sum_{k=0}^n s(n,k) t^k
+      </RT·math>
 
       <p>
         Combinatorially, the unsigned magnitude of <RT·math>s(n,k)</RT·math> represents the number of ways to arrange <RT·math>n</RT·math> items into <RT·math>k</RT·math> disjoint cycles. The alternating signs account for the algebraic expansion of the falling factorial terms <RT·math>(t - 1)(t - 2)</RT·math>, etc.
@@ -3840,17 +3841,18 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
         Recall the convolution formula for component <RT·math>k</RT·math> of the product:
       </p>
 
-      <p>
-        <RT·math>I_{0, k} = \sum_{i=0}^{k} \sum_{j=0}^{k} A_{0, i} C_{0, j} \binom{k}{i} \binom{i}{k-j}</RT·math>
-      </p>
+      <RT·math>
+        I_{0, k} = \sum_{i=0}^{k} \sum_{j=0}^{k} A_{0, i} C_{0, j} \binom{k}{i} \binom{i}{k-j}
+      </RT·math>
+
 
       <p>
         To perform the deconvolution, we isolate the unknown component <RT·math>C_{0, k}</RT·math>. This term occurs in the summation strictly when <RT·math>j = k</RT·math>. When <RT·math>j = k</RT·math>, the term <RT·math>k-j</RT·math> equals 0, making the binomial coefficient <RT·math>\binom{i}{0} = 1</RT·math>. Factoring <RT·math>C_{0, k}</RT·math> out of the sum yields:
       </p>
 
-      <p>
-        <RT·math>C_{0, k} \sum_{i=0}^{k} A_{0, i} \binom{k}{i}</RT·math>
-      </p>
+      <RT·math>
+        C_{0, k} \sum_{i=0}^{k} A_{0, i} \binom{k}{i}
+      </RT·math>
 
       <p>
         A person familiar with Newton's forward difference formula will recognize that the summation <RT·math>\sum_{i=0}^{k} A_{0, i} \binom{k}{i}</RT·math> is exactly the evaluation of the original function at step <RT·math>k</RT·math>, or <RT·math>f(k)</RT·math>.
@@ -3860,9 +3862,9 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
         We can now solve for <RT·math>C_{0, k}</RT·math> recursively. For the base case <RT·math>k = 0</RT·math>, where <RT·math>I_{0, 0} = 1</RT·math>:
       </p>
 
-      <p>
-        <RT·math>C_{0, 0} = \frac{1}{A_{0, 0}}</RT·math>
-      </p>
+      <RT·math>
+        C_{0, 0} = \frac{1}{A_{0, 0}}
+      </RT·math>
 
       <p>
         For all subsequent components where <RT·math>k > 0</RT·math> and <RT·math>I_{0, k} = 0</RT·math>, we subtract the previously known terms of the convolution and divide by <RT·math>f(k)</RT·math>:
@@ -3886,4 +3888,4 @@ Now suppose defining a Turing Machine that initially has the head on the leftmos
 <!--  LocalWords:  Hopcroft Ullman endnote unformatted dereference
 <!--  LocalWords:  computable cardinality uniquifier namespace
  -->
- -->
+
diff --git a/setup b/setup
old mode 100644 (file)
new mode 100755 (executable)
index 7603f3e..f750f1d
--- a/setup
+++ b/setup
@@ -1,61 +1,70 @@
-#!/usr/bin/env bash
+#!/usr/bin/env python3
 # setup - enter a project role environment
-# (must be sourced)
-
-script_afp=$(realpath "${BASH_SOURCE[0]}")
-if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
-  echo "${script_afp}:: This script must be sourced, not executed."
-  exit 1
-fi
-
-project_roles="administrator consumer developer tester"
-
-print_usage(){
-  echo "usage: . setup <role>"
-  echo "known roles: ${project_roles}"
-}
-
-if [ -z "${1:-}" ] || [ "${1}" == "-h" ] || [ "${1}" == "--help" ]; then
-  print_usage
-  return 0
-fi
-
-role_is_valid=false
-for r in ${project_roles}; do
-  if [ "${1}" == "${r}" ]; then
-    role_is_valid=true
-    break
-  fi
-done
-
-if [ "${role_is_valid}" == "false" ]; then
-  echo "setup: unrecognized role or option '${1}'"
-  print_usage
-  return 1
-fi
-
-# setup the project
-#
-  source shared/tool/setup
-  if [[ -f "shared/authored/setup" ]]; then
-    source shared/authored/setup
-  fi
-
-# setup the role
-#
-  export ROLE="${1}"
-
-  tool="${REPO_HOME}/${ROLE}/tool"
-  if [[ ":${PATH}:" != *":${tool}:"* ]]; then
-    export PATH="${tool}:${PATH}"
-  fi
-
-  export SETUP="${ROLE}/tool/setup"
-
-  cd "${ROLE}" || return 1
-  if [ -f "tool/setup" ]; then
-    source "tool/setup"
-    echo "in environment: ${SETUP}"
-  else
-    echo "not found: ${SETUP}"
-  fi
+
+import os
+import sys
+import argparse
+import tempfile
+
+PROJECT_ROLES = ["administrator", "consumer", "developer", "tester"]
+
+def main():
+    parser = argparse.ArgumentParser(
+        description="Enter a project role environment by spawning an isolated subshell."
+    )
+    parser.add_argument("role", choices=PROJECT_ROLES, help="The project role to assume.")
+    args = parser.parse_args()
+
+    env = os.environ.copy()
+
+    # Python-domain logic: Variables and Paths
+    repo_home = env.get("REPO_HOME", os.getcwd())
+    role = args.role
+    role_home = os.path.join(repo_home, role)
+    tool_dir = os.path.join(role_home, "tool")
+    setup_file = os.path.join(role, "tool", "setup")
+
+    env["ROLE"] = role
+    env["ROLE_HOME"] = role_home
+    env["SETUP"] = setup_file
+
+    print(f"ROLE_HOME {role_home}")
+
+    # Python-domain logic: PATH injection
+    path_parts = env.get("PATH", "").split(os.pathsep)
+    if tool_dir not in path_parts:
+        env["PATH"] = f"{tool_dir}{os.pathsep}{env.get('PATH', '')}"
+
+    # Python-domain logic: Directory validation
+    if not os.path.isdir(role):
+        print(f"setup: failed to locate directory for role '{role}'")
+        sys.exit(1)
+
+    # Bash-domain logic: The rcfile only handles operations Python cannot inherit 
+    # (sourcing bash functions) and performs the directory change internally to 
+    # guarantee the shared scripts are sourced from the project root.
+    bash_logic = [
+        'if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi',
+        'if [[ -f "shared/tool/setup" ]]; then source "shared/tool/setup"; fi',
+        'if [[ -f "shared/authored/setup" ]]; then source "shared/authored/setup"; fi',
+        f'cd "{role}"',
+        'if [[ -f "tool/setup" ]]; then',
+        '    source "tool/setup"',
+        f'    echo "in environment: {setup_file}"',
+        'else',
+        f'    echo "not found: {setup_file}"',
+        'fi',
+        'if [[ -n "${INSIDE_EMACS}" ]] && command -v env_to_emacs >/dev/null 2>&1; then',
+        '    env_to_emacs',
+        'fi',
+        'rm -f "${BASH_SOURCE[0]}"'
+    ]
+
+    fd, rcfile_path = tempfile.mkstemp(suffix="-rt-setup.sh")
+    with os.fdopen(fd, "w") as f:
+        f.write("\n".join(bash_logic) + "\n")
+
+    os.execvpe("bash", ["bash", "--rcfile", rcfile_path], env)
+
+if __name__ == "__main__":
+    main()