<img src="TTCA_style_TM_reverse.png" class="rt-diagram" alt="HU reverse machine">
+ <p>With data payload examination removed from the controller, long strings of states with a few decision points emerge. There is a loop on the left, and a tail leading to <RT·code>done</RT·code>, on the right. The number of states and arcs is a constant independent of how much data is to be reversed.</p>
+
<RT·code>
void TTCA·reverse_string() {
- // Phase 1: Scan right to EOM and initialize the EOR marker
+ // Initialization: Scan to EOM and setup the EOR boundary
read_g();
while(g != EOM){right(); read_g();}
right();
write_σ(EOR);
- // Phases 2 through 5: The main shuttle cycle
while(true){
-
- // Phase 2: Fetch next unprocessed character and check boundaries
+ // The Fetch Pivot: Locate the next unprocessed character
left();
read_g();
while(g == EOM || g == SP){
status();
- if(g == on_leftmost) return;
+ // Termination: Short-circuit for empty string
+ if(g == on_leftmost) return;
left();
read_g();
}
read_d();
status();
- // Phase 6: Final character carry and clean halt
- if(g == on_leftmost){
- write_σ(SP);
- right();
- read_g();
- while(g != EOR){right(); read_g();}
- write_d();
- right();
- write_σ(EOR);
- return;
- }
+ // Center Break: Q·Check_Last_Char routes to the final chain
+ if(g == on_leftmost) break;
- // Phase 3 & 4: Mark location, carry opaque data, advance EOR
+ // Main Carry Loop: Mark, carry, drop, and return to pivot
write_σ(SP);
right();
read_g();
right();
write_σ(EOR);
- // Phase 5: Return left to EOM to begin the next fetch cycle
left();
read_g();
while(g != EOM){left(); read_g();}
}
+
+ // Final Character Chain: Handle the last payload without a return sweep
+ write_σ(SP);
+ right();
+ read_g();
+ while(g != EOR){right(); read_g();}
+ write_d();
+ right();
+ write_σ(EOR);
+
+ // Termination: Q·Done
+ return;
}
</RT·code>
+ <p>The total number of steps for reversing an <RT·math>n</RT·math> character string using the TTCA architecture:</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>
+
+ <p>This machine spends a lot of time shuttling the head between two context area. One with the original string, and one with the result reverse machine. This suggests that a two head version would be faster.</p>
+
+
<RT·chapter>The Turing Machine architecture/organization</RT·chapter>
<p>