doc
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Thu, 5 Feb 2026 15:06:10 +0000 (15:06 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Thu, 5 Feb 2026 15:06:10 +0000 (15:06 +0000)
document/TM.html
document/style_manual.html

index 4bd3978..cae883c 100644 (file)
 
       <RT-TOC level="1"></RT-TOC>
 
+
       <h1>Introduction</h1>
 
       <p>
-        A <RT-term>Tape Machine</RT-term> (TM) is used to manipulation data found in a sequences. Such sequences include lists, arrays, sets according to an ordering function, and maps also against an ordering function. Also included are linear traversals of more complex data structures. TM is discussed in detail in the <RT-term>TTCA</RT-term> book.
+        A <RT-term>Tape Machine</RT-term> (TM) is an abstract mechanism for manipulating data found in sequences.
+        Such sequences include lists, arrays, sets (given an ordering function), and maps (also given an ordering function).
+        Also included are linear traversals of more complex structures.
+        The theory underpinning the TM is discussed in the <RT-term>TTCA</RT-term> book.
       </p>
 
       <p>
-        Unlike standard arrays (which are stateless) or iterators (which are transient), a TM combines a data container with a persistent <RT-term>head</RT-term>. The head maintains a positional state on the tape, allowing for navigation, reading, and writing of cells.
+        Unlike standard arrays (which are stateless) or iterators (which are transient), a TM combines a data substrate with a persistent <RT-term>head</RT-term>.
+        The head maintains positional state, allowing the programmer to navigate, read, and write tape cells.
       </p>
 
       <p>
-        Thus each TM type has the nice property of encompassing both data and pointers into that data within one structure.
+        Thus a TM packages both data, and all pointers into that data, within one structure.
       </p>
 
       <p>
-        A first order TM is characterized by having only interface functions that manipulate the
-        data found on the tape.   There are multiple types of first order TMs based on how we view the tape topology, on whether multiple machines can share a tape, and whether tape structure can be changed. Tape topology includes things such as singleton, finite bound sequences, circular sequences, tapes that are open on one or both ends, and tapes which can only be traversed in one direction.
+        A TM can have a concrete tape or a <RT-term>virtual tape</RT-term>.
+        A concrete tape is backed by a container.
+        A virtual tape exposes the same tape machine interface, but its cells and motion are implemented by functions over some internal state.
+        For example, an abstract <RT-term>Counting Number</RT-term> tape machine can use a big integer as its state and implement stepping and reading over that state, instead of traversing an array of numbers.
       </p>
 
       <p>
-        An abstract tape machine has a TM interface, but the behavior is determined through functions rather than through data found in a container being used as a tape. A simple abstract tape machine could be, for example, a counting number machine that makes use of a big integer as the data instead of an array of numbers.
-       </p>
+        A defining invariant of all Tape Machines is that cell contents are cargo.
+        The TM reads and writes cell payload, but it does not interpret that payload as control.
+        The decisions are made above the TM, by the programmer’s algorithm.
+      </p>
 
       <p>
-        When multiple machines share the same tape, we say the machines are <RT-term>entangled</RT-term>. For analysis to remain first order, when machines are entangled, we must be careful with destructive operations. There are multiple approaches to this, each corresponding to a different type of first order TM. One approach is the <RT-code>TM_ND</RT-code> which has no tape structure modifying operations.  Another approach is the <RT-code>TM_SOLO</RT-code> which does not allow more than one machine on its tape.  Yet another approach is the <RT-code>TM_EA</RT-code>, where <RT-term>EA</RT-term> means 'entanglement accounting'.  With entanglement accounting all the machines that share a tape also share the catalog of entangled machines.  Each destructive operation then checks the listed machines and their head positions to assure that no machine is structurally broken by the operation.
-        For example, before deleting a cell, a machine checks that no machine has a head on the specified cell, and thus would become orphaned when the cell is removed from the tape.
+        A <RT-term>first order</RT-term> TM is defined by a single invariant: the head is always on a valid cell.
+        This invariant makes the primitive interface total: every move, read, write, and query has a clean, well defined meaning, and caller code stays free of scattered end case tests.
       </p>
 
-      <h1>Command reference for the ND-TM</h1>
+      <p>
+        If an operation were permitted to remove the last remaining cell, said first order invariant would be broken and the interface would stop being total.
+        A working TM that supported such a deletion would need status logic that represents the empty state.
+        That status logic would either be embedded inside the TM operations as edge handling, or be represented explicitly as a separate status machine layered above the base TM.
+        Either choice represents a shift in level of analysis being done, and therefore would lead to the construction of a distinct <RT-term>second order</RT-term> tape machine.
+      </p>
+
+      <p>
+        When multiple machines share one tape, the machines are <RT-term>entangled</RT-term>.
+        The TM_EA maintains first order analysis by managing a catalog of the entangled machines, and providing a guard predicate for checking it. Any questionable operations must be guard checked before being called.  This is in analogy to the first rest pattern where 
+        <RT-code>qR()</RT-code> guards <RT-code>s()</RT-code>, as seen further below.
+      </p>
+
+      <p>
+        Thus, the library provides three TM variations related to tape entanglement:
+        <RT-code>TM_ND</RT-code> disallows tape structure changes and thus the machines run independently.
+        <RT-code>TM_SOLO</RT-code> disallows more than one machine per tape, precluding entanglement issues entirely.
+        <RT-code>TM_EA</RT-code> uses <RT-term>entanglement accounting</RT-term>.
+        With entanglement accounting, all machines on a shared tape share one catalog of entangled machines, and the interface exposes predicates that query the catalog.
+        Caller code uses those predicates to guard against structure changes that would break machines.
+      </p>
+
+
+      <h1>Command reference for the <RT-code>TM_ND</RT-code></h1>
 
       <p>
         The following commands are available for the Nondestructive First Order Machine. In this version the notation uses strictly ASCII characters.
       </p>
 
-      <h2>The grammar</h2>
+      <h2>Grammar</h2>
       <RT-code>
-statement  :: [location]command+[quantifier]*[arg]*
-location   :: l | L | R  default is right cell
-command    :: r | w | s | q | e 
-quantifier :: A | R | n  default n is one, default A is the head position
+        statement  :: [machine] (command arg_type* )+
+        command    :: e | q | r | s | w 
+        arg_type   :: A | n | R
+        machine    :: L
+
       </RT-code>
 
-      <h2>The definitions</h2>
+      <h2>Definitions</h2>
 
-      <h3>The location</h3>
+      <h3>Machine</h3>
       <ul>
-        <li><RT-code>ε</RT-code> (Empty) implies a step to the right, forward, or plus.</li>
-        <li><RT-code>l</RT-code> moves to the <strong>l</strong>eft neighbor.</li>
-        <li><RT-code>L</RT-code> moves to the <strong>L</strong>eftmost position.</li>
-        <li><RT-code>R</RT-code> moves to the <strong>R</strong>ightmost position.</li>
+        <li><RT-code>L</RT-code> <strong>L</strong>eft machine</li>
       </ul>
 
-      <h3>The commands</h3>
+      <p>
+        Each tape machine can be thought of as the composition of two machines, one starts at the head and extends to the right.  The other starts at the head and extends left.
+        This prefix determines which of the two of these machines the command is to be applied to. If it is set to <RT-code>L</RT-code> then the command applies to the left going machine.
+      </p>
+
+      <p>
+        The left going machine is not a separate machine from the right going machine, rather it is a mirrored view. Hence, leftmost cell for the right going machine, is the rightmost cell for the left going machine. Etc. 
+      </p>
+
+      <p>
+        Address space, as defined in the TTCA book, is a natural number sequence machine that walks in lock step with the right going machine. Thus, by definition, it is a separate machine. So independent of the view we chose, that of the right going machine, or its mirror image, each cell continues to correspond to the same address as it did for the right going machine.  However, as the sequence of cells is reversed on the left going machine, the sequence of addresses will also be reversed.  Thus, rightmost will have address 0 on the left going machine.
+      </p>
+
+
+      <h3>command</h3>
       <ul>
-        <li><RT-code>r</RT-code> <strong>r</strong>eads the cell under the head.</li>
-        <li><RT-code>w</RT-code> <strong>w</strong>rites to the cell under the head.</li>
-        <li><RT-code>s</RT-code> <strong>s</strong>teps the head position.</li>
-        <li><RT-code>q</RT-code> <strong>q</strong>ueries the machine state.</li>
-        <li><RT-code>e</RT-code> <strong>e</strong>ntangles and spawns a new head on the same tape.</li>
+        <li><RT-code>e</RT-code> <strong>e</strong>ntangle</li>
+        <li><RT-code>q</RT-code> <strong>q</strong>uery</li>
+        <li><RT-code>r</RT-code> <strong>r</strong>ead</li>
+        <li><RT-code>s</RT-code> <strong>s</strong>tep to place.</li>
+        <li><RT-code>w</RT-code> <strong>w</strong>rite</li>
       </ul>
 
-      <h3>The quantifiers</h3>
+      <p>
+        The result of the entangle command is a new TM that is entangled with the interfaced machine. By definition, the new entangled machine shares the tape with the original interface machine. Both machines initially have the head on the same cell.
+      </p>
+
+      <h3>Machine</h3>
       <ul>
-        <li><RT-code>A</RT-code> returns the <strong>A</strong>ddress or head index.</li>
-        <li><RT-code>R</RT-code> returns the <strong>R</strong>ightmost address or extent.</li>
-        <li><RT-code>n</RT-code> repeats <strong>n</strong> times.</li>
+        <li><RT-code>L</RT-code> <strong>L</strong>eft machine</li>
       </ul>
 
-      <h2>The examples</h2>
+      <h3>arg_type</h3>
+      <ul>
+        <li><RT-code>A</RT-code> <strong>A</strong>dress</li>
+        <li><RT-code>n</RT-code> <strong>n</strong></li>
+        <li><RT-code>R</RT-code> <strong>R</strong>ightmost</li>
+      </ul>
+
+      <p>
+        Note that here <RT-code>R</RT-code> refers to the rightmost cell as an
+        argument. It does not mean right going machine, as one might surmise given
+        that <RT-code>L</RT-code> means left going machine.
+      </p>
+
+      <h2>Examples</h2>
       
+      <h3>Relative head movement</h3>
+
       <RT-code>
-ls    ; Step to left neighbor
-Ls    ; Cue Leftmost (Go to index 0)
-Rs    ; Cue Rightmost (Go to last index)
-qA    ; Query Address (What is the head index?)
+s         ; step to right neighbor
+Ls        ; step to left neighbor (stepping right on the mirror image machine)
+sn(0)     ; no-op
+sn(2)     ; step to right neighbor twice
+Lsn(2)    ; step to left neighbor twice (stepping right on the mirror image machine)
       </RT-code>
 
-      <h1>The primitive method reference</h1>
+      <h3>Head movement relative to leftmost</h3>
+
+      <RT-code>
+sA(0)     ; step to the leftmost cell by address
+sA(3)     ; step to tape[3]
+      </RT-code>
+
+      <p>If an <RT-code>LsA(3)</RT-code> command existed, it would return the same value as
+        <RT-code>LsA(3)</RT-code>, because mirroring does not change the correspondence between addresses and cells. For the same reason, <RT-code>LsA(0)</RT-code> would still be the leftmost cell of the right going machine.
+      </p>
+
+      
+      <h3>Absolute head movement</h3>
+      <RT-code>
+sR         ; step to rightmost
+LsR        ; step to leftmost (rightmost on the mirror machine)
+      </RT-code>
+
+      <p>Without code optimization <RT-code>sR</RT-code>   will
+        be faster than its counterpart <RT-code>sA(0)</RT-code> because the latter
+        form requires passing and processing an argument.
+        </p>
+
+      <h3>Query</h3>
+      <RT-code>
+qR        ; head is on rightmost
+LqR       ; head is on leftmost
+qA        ; returns address of the head
+qAR       ; returns address of rightmost
+      </RT-code>      
+
+      <h3>Copying to and from the tape machine cells and python variables.</h3>
+
+      <RT-code>
+r          ; copies cell contents to the LHS of an assignment
+w(v)       ; copies v into the cell
+      </RT-code>      
+
+    
+
+      <h1>Primitive method reference</h1>
 
       <p>
         This section details the actual methods exposed by the First Order TM implementation (Python/C). These primitives map directly to the command language.
       </p>
 
-      <h2>The navigation primitives</h2>
+      <h2>Navigation primitives</h2>
       <ul>
         <li><RT-code>s()</RT-code> steps right.</li>
         <li><RT-code>sn(n)</RT-code> steps right <RT-math>n</RT-math> times.</li>
@@ -115,7 +217,7 @@ qA    ; Query Address (What is the head index?)
         <li><RT-code>Rsn(n)</RT-code> cues rightmost with offset <RT-math>n</RT-math>.</li>
       </ul>
 
-      <h2>The input and output primitives</h2>
+      <h2>Input and output primitives</h2>
       <ul>
         <li><RT-code>r()</RT-code> reads the current cell.</li>
         <li><RT-code>rn(n)</RT-code> reads <RT-math>n</RT-math> cells.</li>
@@ -123,7 +225,7 @@ qA    ; Query Address (What is the head index?)
         <li><RT-code>wn(list)</RT-code> writes a list of values.</li>
       </ul>
 
-      <h2>The query primitives</h2>
+      <h2>Query primitives</h2>
       <p>
         Introspection commands used to check machine state without side effects.
       </p>
@@ -131,7 +233,7 @@ qA    ; Query Address (What is the head index?)
         <li><RT-code>qA()</RT-code> queries the address to return the current head index.</li>
       </ul>
 
-      <h2>The entanglement primitives</h2>
+      <h2>Entanglement primitives</h2>
       <ul>
         <li><RT-code>e()</RT-code> entangles a new machine instance sharing the same tape and safety catalog.</li>
         <li><RT-code>es()</RT-code> entangles and steps right.</li>
@@ -144,9 +246,9 @@ qA    ; Query Address (What is the head index?)
         <li><RT-code>eRsn(n)</RT-code> entangles and cues rightmost with an offset.</li>
       </ul>
 
-      <h1>The usage</h1>
+      <h1>Usage</h1>
 
-      <h2>The first order TM properties</h2>
+      <h2>First order TM properties</h2>
 
       <p>
       For a first order TM these properties are always true.
@@ -162,7 +264,7 @@ qA    ; Query Address (What is the head index?)
       the interval, and on an entangled machine on the rightmost cell of the interval.
       </p>
 
-      <h2>The contract with the programmer</h2>
+      <h2>Contract with the programmer</h2>
 
       <p>
         Some first order TM types rely upon the programmer to maintain a contract in order to maintain the first order TM properties. Such machines typically have debug variants that add contract checks. For some machines breaking the contract can limit the ability of the compiler to optimize code, for other machines breaking the contract can lead
@@ -170,7 +272,7 @@ qA    ; Query Address (What is the head index?)
       </p>
 
       <p>
-        <strong>The Contract:</strong>
+        <strong>Contract:</strong>
       </p>
       <ol>
         <li>When there is a right bound, the caller guarantees they will never command the machine to step beyond the rightmost cell.</li>
@@ -181,7 +283,7 @@ qA    ; Query Address (What is the head index?)
       When traversing a tape, this contract can be fulfilled by using a first rest pattern.
       </p>
 
-      <h1>The First-Rest pattern with initialization</h1>
+      <h1>First-Rest pattern with initialization</h1>
 
       <RT-code>
 # Pattern 1: First-Rest (Initialize with First)
@@ -197,7 +299,7 @@ while not tm.qR():  # Guard: Is there a Rest?
        the head is on the rightmost cell. It guards the step within the loop. Note no redundant tests are done, and the loop ends are clean without stepping off the end of a tape. (And thus not stepping off the end of a memory page or often, of a cache line.)
       </p>
 
-      <h1>The First-Rest pattern without initialization</h1>
+      <h1>First-Rest pattern without initialization</h1>
 
       <p>
         Sometimes we initialize the accumulator to an identity value (like 0) before the loop starts. In this case, the most natural structure is the "Loop-and-a-Half" (middle-exit loop).
index afb7e69..cf6e7f2 100644 (file)
 
     <RT-TOC level="1"></RT-TOC>
 
+    <h1> Table of Custom Tags </h1>
+
+    <h2>Style Tag Reference</h2>
+
+<table>
+  <thead>
+    <tr>
+      <th>Tag</th>
+      <th>Description</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr>
+      <td><RT-code>&lt;RT-article&gt;</RT-code></td>
+      <td>Article container.</td>
+    </tr>
+
+    <tr>
+      <td><RT-code>&lt;RT-title&gt;</RT-code></td>
+      <td>
+        Title block and metadata.
+      </td>
+    </tr>
+
+    <tr>
+      <td><RT-code>&lt;RT-TOC&gt;</RT-code></td>
+      <td>Generates TOC.</td>
+    </tr>
+
+    <tr>
+      <td><RT-code>&lt;RT-term&gt;</RT-code></td>
+      <td>Conventional term.</td>
+    </tr>
+
+    <tr>
+      <td><RT-code>&lt;RT-term-em&gt;</RT-code></td>
+      <td>Forces emphasis for a term even after first occurrence.</td>
+    </tr>
+
+    <tr>
+      <td><RT-code>&lt;RT-neologism&gt;</RT-code></td>
+      <td>Project specific term.</td>
+    </tr>
+
+    <tr>
+      <td><RT-code>&lt;RT-neologism-em&gt;</RT-code></td>
+      <td>Forces emphasis for a neologism even after first occurrence.</td>
+    </tr>
+
+    <tr>
+      <td><RT-code>&lt;RT-code&gt;</RT-code></td>
+      <td>Code span or code block.</td>
+    </tr>
+
+    <tr>
+      <td><RT-code>&lt;RT-math&gt;</RT-code></td>
+      <td>Inline or block math.</td>
+    </tr>
+
+    <tr>
+      <td><RT-code>&lt;RT-page&gt;</RT-code></td>
+      <td>Automatically inserted pagination tag.</td>
+    </tr>
+  </tbody>
+</table>
+
     <h1>Architecture Overview</h1>
     <p>
       The <RT-term>RT Style System</RT-term> is a client-side, JavaScript-driven publishing framework designed to turn raw HTML into high-readability technical documentation. Unlike standard CSS frameworks, RT uses JavaScript to handle complex layout tasks like <RT-neologism>ink-ratio balancing</RT-neologism> and dynamic pagination.