TM_tutorial.py running, a first array based full TM implementation for Python
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Wed, 11 Feb 2026 09:56:16 +0000 (09:56 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Wed, 11 Feb 2026 09:56:16 +0000 (09:56 +0000)
developer/authored/TM.py
developer/authored/TM_module.c
developer/authored/TM_tutorial.py
developer/authored/build/temp.linux-x86_64-cpython-311/TM_module.o
document/TM.html
document/TM_reference.html [deleted file]
document/TM_sav.html [deleted file]
document/TM_user.html [deleted file]

index 24a262e..693b77b 100755 (executable)
-#!/usr/bin/env python3
-import sys
-
-try:
-  import TM_module
-except ImportError:
-  print("Error: Import failed. Run 'python3 setup.py build_ext --inplace'")
-  sys.exit(1)
-
-# ==========================================
-# TM Command Language (Explicit Types)
-# ==========================================
-
-# Import all C-defined types into this namespace
-_this_module = sys.modules[__name__]
-for name in dir(TM_module):
-    if name.startswith("TM_") or name.startswith("TMA_"):
-        setattr(_this_module, name, getattr(TM_module, name))
-
-# ==========================================
-# Defaults (Aliasing)
-# ==========================================
-
-# Pattern: TM_[Container]_[Direction]_[Entanglement]
-# Default Container: Arr
-# Default Entanglement: ND
-# Default Direction: SR
-
-# --- Global Default ---
-TM = TM_module.TM_Arr_SR_ND
-
-# --- Container Defaults (Dir=SR, Ent=ND) ---
-TM_Arr  = TM_module.TM_Arr_SR_ND
-TM_ArrV = TM_module.TM_ArrV_SR_ND
-TM_Gr   = TM_module.TM_Gr_SR_ND
-TM_Glr  = TM_module.TM_Glr_SR_ND
-TM_Set  = TM_module.TM_Set_SR_ND
-TM_Map  = TM_module.TM_Map_SR_ND
-TM_MapK = TM_module.TM_MapK_SR_ND
-TM_MapV = TM_module.TM_MapV_SR_ND
-TM_ASCII= TM_module.TM_ASCII_SR_ND
-TM_UTF8 = TM_module.TM_UTF8_SR_ND
-TM_BCD  = TM_module.TM_BCD_SR_ND
-
-# --- Direction Defaults (Cont=Arr, Ent=ND) ---
-TM_SR = TM_module.TM_Arr_SR_ND
-TM_SL = TM_module.TM_Arr_SL_ND
-
-# --- Entanglement Defaults (Cont=Arr, Dir=SR) ---
-TM_ND = TM_module.TM_Arr_SR_ND
-TM_SO = TM_module.TM_Arr_SR_SO
-TM_EA = TM_module.TM_Arr_SR_EA
-
-# --- Common Partials ---
-TM_Arr_SL = TM_module.TM_Arr_SL_ND
-TM_ASCII_SL = TM_module.TM_ASCII_SL_ND
+"""
+TM.py
+Wrapper for the C extension TM_module.
+"""
+import TM_module
+
+# -----------------------------------------------------------------------------
+# 1. Arr (Fixed Array)
+# -----------------------------------------------------------------------------
+TM_Arr_CR_ND = TM_module.TM_Arr_CR_ND
+TM_Arr_CR_SO = TM_module.TM_Arr_CR_SO
+TM_Arr_CR_EA = TM_module.TM_Arr_CR_EA
+
+TM_Arr_CLR_ND = TM_module.TM_Arr_CLR_ND
+TM_Arr_CLR_SO = TM_module.TM_Arr_CLR_SO
+TM_Arr_CLR_EA = TM_module.TM_Arr_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 2. ArrV (Variable Array / Vector)
+# -----------------------------------------------------------------------------
+TM_ArrV_CR_ND = TM_module.TM_ArrV_CR_ND
+TM_ArrV_CR_SO = TM_module.TM_ArrV_CR_SO
+TM_ArrV_CR_EA = TM_module.TM_ArrV_CR_EA
+
+TM_ArrV_CLR_ND = TM_module.TM_ArrV_CLR_ND
+TM_ArrV_CLR_SO = TM_module.TM_ArrV_CLR_SO
+TM_ArrV_CLR_EA = TM_module.TM_ArrV_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 3. Gr (Graph Right / Linked List)
+# -----------------------------------------------------------------------------
+TM_Gr_CR_ND = TM_module.TM_Gr_CR_ND
+TM_Gr_CR_SO = TM_module.TM_Gr_CR_SO
+TM_Gr_CR_EA = TM_module.TM_Gr_CR_EA
+
+TM_Gr_CLR_ND = TM_module.TM_Gr_CLR_ND
+TM_Gr_CLR_SO = TM_module.TM_Gr_CLR_SO
+TM_Gr_CLR_EA = TM_module.TM_Gr_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 4. Glr (Graph Left Right / Doubly Linked List)
+# -----------------------------------------------------------------------------
+TM_Glr_CR_ND = TM_module.TM_Glr_CR_ND
+TM_Glr_CR_SO = TM_module.TM_Glr_CR_SO
+TM_Glr_CR_EA = TM_module.TM_Glr_CR_EA
+
+TM_Glr_CLR_ND = TM_module.TM_Glr_CLR_ND
+TM_Glr_CLR_SO = TM_module.TM_Glr_CLR_SO
+TM_Glr_CLR_EA = TM_module.TM_Glr_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 5. Set (Unordered)
+# -----------------------------------------------------------------------------
+TM_Set_CR_ND = TM_module.TM_Set_CR_ND
+TM_Set_CR_SO = TM_module.TM_Set_CR_SO
+TM_Set_CR_EA = TM_module.TM_Set_CR_EA
+
+TM_Set_CLR_ND = TM_module.TM_Set_CLR_ND
+TM_Set_CLR_SO = TM_module.TM_Set_CLR_SO
+TM_Set_CLR_EA = TM_module.TM_Set_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 6. Map (Items)
+# -----------------------------------------------------------------------------
+TM_Map_CR_ND = TM_module.TM_Map_CR_ND
+TM_Map_CR_SO = TM_module.TM_Map_CR_SO
+TM_Map_CR_EA = TM_module.TM_Map_CR_EA
+
+TM_Map_CLR_ND = TM_module.TM_Map_CLR_ND
+TM_Map_CLR_SO = TM_module.TM_Map_CLR_SO
+TM_Map_CLR_EA = TM_module.TM_Map_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 7. MapK (Keys)
+# -----------------------------------------------------------------------------
+TM_MapK_CR_ND = TM_module.TM_MapK_CR_ND
+TM_MapK_CR_SO = TM_module.TM_MapK_CR_SO
+TM_MapK_CR_EA = TM_module.TM_MapK_CR_EA
+
+TM_MapK_CLR_ND = TM_module.TM_MapK_CLR_ND
+TM_MapK_CLR_SO = TM_module.TM_MapK_CLR_SO
+TM_MapK_CLR_EA = TM_module.TM_MapK_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 8. MapV (Values)
+# -----------------------------------------------------------------------------
+TM_MapV_CR_ND = TM_module.TM_MapV_CR_ND
+TM_MapV_CR_SO = TM_module.TM_MapV_CR_SO
+TM_MapV_CR_EA = TM_module.TM_MapV_CR_EA
+
+TM_MapV_CLR_ND = TM_module.TM_MapV_CLR_ND
+TM_MapV_CLR_SO = TM_module.TM_MapV_CLR_SO
+TM_MapV_CLR_EA = TM_module.TM_MapV_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 9. ASCII (String)
+# -----------------------------------------------------------------------------
+TM_ASCII_CR_ND = TM_module.TM_ASCII_CR_ND
+TM_ASCII_CR_SO = TM_module.TM_ASCII_CR_SO
+TM_ASCII_CR_EA = TM_module.TM_ASCII_CR_EA
+
+TM_ASCII_CLR_ND = TM_module.TM_ASCII_CLR_ND
+TM_ASCII_CLR_SO = TM_module.TM_ASCII_CLR_SO
+TM_ASCII_CLR_EA = TM_module.TM_ASCII_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 10. UTF8 (String)
+# -----------------------------------------------------------------------------
+TM_UTF8_CR_ND = TM_module.TM_UTF8_CR_ND
+TM_UTF8_CR_SO = TM_module.TM_UTF8_CR_SO
+TM_UTF8_CR_EA = TM_module.TM_UTF8_CR_EA
+
+TM_UTF8_CLR_ND = TM_module.TM_UTF8_CLR_ND
+TM_UTF8_CLR_SO = TM_module.TM_UTF8_CLR_SO
+TM_UTF8_CLR_EA = TM_module.TM_UTF8_CLR_EA
+
+# -----------------------------------------------------------------------------
+# 11. Abstract
+# -----------------------------------------------------------------------------
+TMA_NaturalNumber = TM_module.TMA_NaturalNumber
index abf3a9a..10c0f2a 100644 (file)
@@ -3,7 +3,7 @@
   CPython Extension: Tape Machine Factory
   
   Implements:
-    - 66 Concrete Machine Types
+    - 60 Concrete Machine Types (Chiral naming: CR/CLR)
     - TMA_NaturalNumber (Abstract Machine)
 
   Namespaces:
 /* UNIVERSAL HEAD STATE                                      */
 /* ========================================================= */
 
-/* LIMITATION OF C VOID POINTERS:
-   
-   In Standard ISO C, there is no way to "bind" a type to a void* pointer 
-   temporarily to perform arithmetic. A cast expression like '(Type*)ptr' 
-   yields a value (r-value), not a storage location (l-value), so we 
-   cannot perform operations like '((Type*)ptr)++'.
-   
-   To remain strictly ISO C compliant, we would have to define multiple 
-   structs (one for PyObject**, one for char*, etc.), which breaks our 
-   generic "Universal Head" architecture.
-   
-   DECISION: THE GCC/CLANG WAY
-   We utilize the common GCC/Clang extension that treats arithmetic on 
-   void* as byte-level arithmetic (i.e., sizeof(void) == 1).
-   
-   This allows us to write clean, polymorphic code:
-     self->head_ptr += sizeof(Element);
-*/
-
 typedef struct{
   PyObject_HEAD
   PyObject* tape_obj;      /* The Container */
@@ -88,53 +69,59 @@ static int TM·Arr·init(TM·Head* self, PyObject* args, PyObject* kwds){
   return 0;
 }
 
-/* Sync: Re-bases pointers after a List Reallocation */
 static void TM·Arr·sync(TM·Head* self){
-  /* 1. Calculate Logical Offset (Byte Distance) */
   Py_ssize_t byte_offset = self->head_ptr - self->start_ptr;
-
-  /* 2. Get NEW pointers */
   Py_ssize_t len = PyList_GET_SIZE(self->tape_obj);
   PyObject** new_items = ((PyListObject*)self->tape_obj)->ob_item;
-  
-  /* 3. Rebase */
   self->start_ptr = (void*)new_items;
   self->end_ptr   = (void*)(new_items + len);
-  
-  /* 4. Restore Head (Byte Arithmetic) */
   self->head_ptr  = self->start_ptr + byte_offset;
 }
 
-/* --- PRIMITIVES: NAVIGATION (The GCC Way) --- */
+static inline void TM·Arr·lazysync(TM·Head* self){
+  Py_ssize_t known_len = (self->end_ptr - self->start_ptr) / sizeof(PyObject*);
+  Py_ssize_t actual_len = PyList_GET_SIZE(self->tape_obj);
+  if (known_len != actual_len) {
+      TM·Arr·sync(self);
+  }
+}
+
+/* --- PRIMITIVES: NAVIGATION --- */
 
 static PyObject* TM·Arr·s(TM·Head* self){ 
+  TM·Arr·lazysync(self);
   self->head_ptr += sizeof(PyObject*);
   Py_RETURN_NONE; 
 }
 
-static PyObject* TM·Arr·ls(TM·Head* self){ 
+static PyObject* TM·Arr·Ls(TM·Head* self){ 
+  TM·Arr·lazysync(self);
   self->head_ptr -= sizeof(PyObject*);
   Py_RETURN_NONE; 
 }
 
 static PyObject* TM·Arr·sn(TM·Head* self, PyObject* args){
+  TM·Arr·lazysync(self);
   Py_ssize_t n; if(!PyArg_ParseTuple(args, "n", &n)) return NULL;
   self->head_ptr += n * sizeof(PyObject*);
   Py_RETURN_NONE;
 }
 
-static PyObject* TM·Arr·lsn(TM·Head* self, PyObject* args){
+static PyObject* TM·Arr·Lsn(TM·Head* self, PyObject* args){
+  TM·Arr·lazysync(self);
   Py_ssize_t n; if(!PyArg_ParseTuple(args, "n", &n)) return NULL;
   self->head_ptr -= n * sizeof(PyObject*);
   Py_RETURN_NONE;
 }
 
 static PyObject* TM·Arr·sR(TM·Head* self){ 
+  TM·Arr·lazysync(self);
   self->head_ptr = self->end_ptr - sizeof(PyObject*);
   Py_RETURN_NONE; 
 }
 
 static PyObject* TM·Arr·LsR(TM·Head* self){ 
+  TM·Arr·lazysync(self);
   self->head_ptr = self->start_ptr; 
   Py_RETURN_NONE; 
 }
@@ -142,16 +129,14 @@ static PyObject* TM·Arr·LsR(TM·Head* self){
 /* --- PRIMITIVES: ENTANGLEMENT --- */
 
 static PyObject* TM·Arr·e(TM·Head* self){
-  /* Create a new object of the same type */
+  TM·Arr·lazysync(self);
   PyTypeObject* type = Py_TYPE(self);
   TM·Head* new_tm = (TM·Head*)type->tp_alloc(type, 0);
   if (!new_tm) return NULL;
 
-  /* Share the tape */
   new_tm->tape_obj = self->tape_obj;
   Py_INCREF(new_tm->tape_obj);
 
-  /* Copy the pointers (Entangled start at same position) */
   new_tm->start_ptr = self->start_ptr;
   new_tm->end_ptr   = self->end_ptr;
   new_tm->head_ptr  = self->head_ptr;
@@ -162,13 +147,14 @@ static PyObject* TM·Arr·e(TM·Head* self){
 /* --- PRIMITIVES: I/O --- */
 
 static PyObject* TM·Arr·r(TM·Head* self){ 
-  /* Must cast to dereference the data */
+  TM·Arr·lazysync(self);
   PyObject* item = *(PyObject**)self->head_ptr; 
   Py_INCREF(item); 
   return item; 
 }
 
 static PyObject* TM·Arr·w(TM·Head* self, PyObject* val){
+  TM·Arr·lazysync(self);
   PyObject** p = (PyObject**)self->head_ptr;
   PyObject* old = *p; 
   Py_INCREF(val); 
@@ -180,78 +166,133 @@ static PyObject* TM·Arr·w(TM·Head* self, PyObject* val){
 /* --- PRIMITIVES: QUERY --- */
 
 static PyObject* TM·Arr·qR(TM·Head* self){ 
-  /* GCC Extension: void* comparison and arithmetic */
+  TM·Arr·lazysync(self);
   if(self->head_ptr >= self->end_ptr - sizeof(PyObject*)){
     Py_RETURN_TRUE;
   }
   Py_RETURN_FALSE;
 }
 
-static PyObject* TM·Arr·qL(TM·Head* self){ 
+static PyObject* TM·Arr·LqR(TM·Head* self){ 
+  TM·Arr·lazysync(self);
   if(self->head_ptr <= self->start_ptr){
     Py_RETURN_TRUE;
   }
   Py_RETURN_FALSE; 
 }
 
+static PyObject* TM·Arr·qnR(TM·Head* self){
+  TM·Arr·lazysync(self);
+  Py_ssize_t byte_diff = self->end_ptr - self->head_ptr;
+  /* If at Rightmost, diff is 1 item size. Result 0. */
+  Py_ssize_t count = (byte_diff / sizeof(PyObject*)) - 1;
+  return PyLong_FromSsize_t(count);
+}
 
-/* --- PRIMITIVES: DESTRUCTIVE (Variable Array Only) --- */
+static PyObject* TM·Arr·LqnR(TM·Head* self){
+  TM·Arr·lazysync(self);
+  Py_ssize_t byte_diff = self->head_ptr - self->start_ptr;
+  /* If at Leftmost, diff is 0. Result 0. */
+  Py_ssize_t count = byte_diff / sizeof(PyObject*);
+  return PyLong_FromSsize_t(count);
+}
 
-static PyObject* TM·Arr·d(TM·Head* self){
-  /* 1. Calc Index (Byte Diff / Element Size) */
-  Py_ssize_t idx = (self->head_ptr - self->start_ptr) / sizeof(PyObject*);
+/* --- PRIMITIVES: DESTRUCTIVE (SO Only) --- */
 
-  /* 2. API Call */
-  if (PyList_SetSlice(self->tape_obj, idx, idx+1, NULL) < 0) return NULL;
-  
-  /* 3. SYNC */
-  TM·Arr·sync(self);
-  
-  /* 4. Safety */
-  if (self->head_ptr >= self->end_ptr && self->start_ptr != self->end_ptr) {
-      self->head_ptr -= sizeof(PyObject*);
-  } else if (self->start_ptr == self->end_ptr) {
-      PyErr_SetString(PyExc_RuntimeError, "TM Empty: First Order Invariant Broken.");
+static PyObject* TM·Arr·dR(TM·Head* self){
+  TM·Arr·lazysync(self);
+  /* Delete from Current to Rightmost (inclusive) */
+  /* Guard: Must have a left neighbor to step back to. */
+  if (self->head_ptr <= self->start_ptr) {
+      PyErr_SetString(PyExc_RuntimeError, "Invariant Violation: Cannot dR from leftmost cell (tape would empty).");
       return NULL;
   }
+  Py_ssize_t idx = (self->head_ptr - self->start_ptr) / sizeof(PyObject*);
+  Py_ssize_t len = PyList_GET_SIZE(self->tape_obj);
+  
+  if (PyList_SetSlice(self->tape_obj, idx, len, NULL) < 0) return NULL;
+  
+  /* Current cell is gone. Step Left to valid neighbor. */
+  self->head_ptr -= sizeof(PyObject*);
+  TM·Arr·sync(self);
   Py_RETURN_NONE;
 }
 
-static PyObject* TM·Arr·a(TM·Head* self, PyObject* val){
+static PyObject* TM·Arr·LdR(TM·Head* self){
+  TM·Arr·lazysync(self);
+  /* Delete from Current to Leftmost (inclusive) */
+  /* Guard: Must have a right neighbor to step 'right' (reset) to. */
+  if (self->head_ptr >= self->end_ptr - sizeof(PyObject*)) {
+      PyErr_SetString(PyExc_RuntimeError, "Invariant Violation: Cannot LdR from rightmost cell (tape would empty).");
+      return NULL;
+  }
   Py_ssize_t idx = (self->head_ptr - self->start_ptr) / sizeof(PyObject*);
-
-  if (PyList_Insert(self->tape_obj, idx, val) < 0) return NULL;
   
+  if (PyList_SetSlice(self->tape_obj, 0, idx+1, NULL) < 0) return NULL;
+  
+  /* Head resets to 0 (the element that was to the right of deleted chunk) */
+  self->head_ptr = self->start_ptr; 
   TM·Arr·sync(self);
   Py_RETURN_NONE;
 }
 
 static PyObject* TM·Arr·esd(TM·Head* self){
+  TM·Arr·lazysync(self);
   if (self->head_ptr >= self->end_ptr - sizeof(PyObject*)) {
        PyErr_SetString(PyExc_IndexError, "esd: No right neighbor.");
        return NULL;
   }
-  
   Py_ssize_t idx = (self->head_ptr - self->start_ptr) / sizeof(PyObject*);
-  
   if (PyList_SetSlice(self->tape_obj, idx+1, idx+2, NULL) < 0) return NULL;
-  
   TM·Arr·sync(self);
   Py_RETURN_NONE;
 }
 
-static PyObject* TM·Arr·Lesd(TM·Head* self){
+static PyObject* TM·Arr·eLsd(TM·Head* self){
+  TM·Arr·lazysync(self);
   if (self->head_ptr <= self->start_ptr) {
-       PyErr_SetString(PyExc_IndexError, "Lesd: No left neighbor.");
+       PyErr_SetString(PyExc_IndexError, "eLsd: No left neighbor.");
        return NULL;
   }
-  
   Py_ssize_t idx = (self->head_ptr - self->start_ptr) / sizeof(PyObject*);
   if (PyList_SetSlice(self->tape_obj, idx-1, idx, NULL) < 0) return NULL;
   
-  /* Adjustment: Shift Left */
+  /* We removed item at idx-1. The item at idx is now at idx-1. */
   self->head_ptr -= sizeof(PyObject*);
+  TM·Arr·sync(self);
+  Py_RETURN_NONE;
+}
+
+static PyObject* TM·Arr·esa(TM·Head* self, PyObject* val){
+  TM·Arr·lazysync(self);
+  /* Insert after current (at idx+1) */
+  Py_ssize_t idx = (self->head_ptr - self->start_ptr) / sizeof(PyObject*);
+  if (PyList_Insert(self->tape_obj, idx+1, val) < 0) return NULL;
+  TM·Arr·sync(self);
+  Py_RETURN_NONE;
+}
 
+static PyObject* TM·Arr·eLsa(TM·Head* self, PyObject* val){
+  TM·Arr·lazysync(self);
+  /* Insert before current (at idx) */
+  Py_ssize_t idx = (self->head_ptr - self->start_ptr) / sizeof(PyObject*);
+  if (PyList_Insert(self->tape_obj, idx, val) < 0) return NULL;
+  
+  /* Current item shifts right to idx+1. Increment head to track it. */
+  self->head_ptr += sizeof(PyObject*);
+  TM·Arr·sync(self);
+  Py_RETURN_NONE;
+}
+
+static PyObject* TM·Arr·aR(TM·Head* self, PyObject* val){
+  if (PyList_Append(self->tape_obj, val) < 0) return NULL;
+  TM·Arr·sync(self);
+  Py_RETURN_NONE;
+}
+
+static PyObject* TM·Arr·LaR(TM·Head* self, PyObject* val){
+  if (PyList_Insert(self->tape_obj, 0, val) < 0) return NULL;
+  self->head_ptr += sizeof(PyObject*);
   TM·Arr·sync(self);
   Py_RETURN_NONE;
 }
@@ -262,59 +303,70 @@ static PyObject* TM·Arr·Lesd(TM·Head* self){
 /* ========================================================= */
 
 /* 1. NON-DESTRUCTIVE (ND) */
-static PyMethodDef Table·SR·ND[] = {
+static PyMethodDef Table·CR·ND[] = {
   {"s", (PyCFunction)TM·Arr·s, METH_NOARGS, ""},
   {"sn",(PyCFunction)TM·Arr·sn,METH_VARARGS,""},
   {"e", (PyCFunction)TM·Arr·e, METH_NOARGS, ""},
   {"r", (PyCFunction)TM·Arr·r, METH_NOARGS, ""},
   {"w", (PyCFunction)TM·Arr·w, METH_O,      ""},
   {"qR",(PyCFunction)TM·Arr·qR,METH_NOARGS, ""},
+  {"qnR",(PyCFunction)TM·Arr·qnR,METH_NOARGS,""},
+  {"LqnR",(PyCFunction)TM·Arr·LqnR,METH_NOARGS,""},
   {"LsR",(PyCFunction)TM·Arr·LsR,METH_NOARGS,""},
   {NULL}
 };
 
-static PyMethodDef Table·SL·ND[] = {
+static PyMethodDef Table·CLR·ND[] = {
   {"s", (PyCFunction)TM·Arr·s, METH_NOARGS, ""},
   {"sn",(PyCFunction)TM·Arr·sn,METH_VARARGS,""},
   {"e", (PyCFunction)TM·Arr·e, METH_NOARGS, ""},
-  {"ls",(PyCFunction)TM·Arr·ls,METH_NOARGS, ""},
-  {"lsn",(PyCFunction)TM·Arr·lsn,METH_VARARGS,""},
+  {"Ls",(PyCFunction)TM·Arr·Ls,METH_NOARGS, ""},
+  {"Lsn",(PyCFunction)TM·Arr·Lsn,METH_VARARGS,""},
   {"r", (PyCFunction)TM·Arr·r, METH_NOARGS, ""},
   {"w", (PyCFunction)TM·Arr·w, METH_O,      ""},
   {"qR",(PyCFunction)TM·Arr·qR,METH_NOARGS, ""},
-  {"qL",(PyCFunction)TM·Arr·qL,METH_NOARGS, ""},
+  {"LqR",(PyCFunction)TM·Arr·LqR,METH_NOARGS, ""},
+  {"qnR",(PyCFunction)TM·Arr·qnR,METH_NOARGS,""},
+  {"LqnR",(PyCFunction)TM·Arr·LqnR,METH_NOARGS,""},
   {"sR",(PyCFunction)TM·Arr·sR,METH_NOARGS, ""},
   {"LsR",(PyCFunction)TM·Arr·LsR,METH_NOARGS,""},
   {NULL}
 };
 
-/* 2. DESTRUCTIVE (SO) - For ArrV */
-static PyMethodDef Table·SR·SO[] = {
+/* 2. DESTRUCTIVE (SO) - No Entangle 'e' */
+static PyMethodDef Table·CR·SO[] = {
   {"s", (PyCFunction)TM·Arr·s, METH_NOARGS, ""},
   {"sn",(PyCFunction)TM·Arr·sn,METH_VARARGS,""},
-  {"e", (PyCFunction)TM·Arr·e, METH_NOARGS, ""},
   {"r", (PyCFunction)TM·Arr·r, METH_NOARGS, ""},
   {"w", (PyCFunction)TM·Arr·w, METH_O,      ""},
-  {"d", (PyCFunction)TM·Arr·d, METH_NOARGS, ""}, 
-  {"a", (PyCFunction)TM·Arr·a, METH_O,      ""}, 
+  {"dR",(PyCFunction)TM·Arr·dR,METH_NOARGS, ""},
   {"esd",(PyCFunction)TM·Arr·esd,METH_NOARGS,""},
+  {"esa",(PyCFunction)TM·Arr·esa,METH_O,     ""},
+  {"aR",(PyCFunction)TM·Arr·aR,METH_O,       ""},
   {"qR",(PyCFunction)TM·Arr·qR,METH_NOARGS, ""},
+  {"qnR",(PyCFunction)TM·Arr·qnR,METH_NOARGS,""},
+  {"LqnR",(PyCFunction)TM·Arr·LqnR,METH_NOARGS,""},
   {"LsR",(PyCFunction)TM·Arr·LsR,METH_NOARGS,""},
   {NULL}
 };
 
-static PyMethodDef Table·SL·SO[] = {
+static PyMethodDef Table·CLR·SO[] = {
   {"s", (PyCFunction)TM·Arr·s, METH_NOARGS, ""},
-  {"ls",(PyCFunction)TM·Arr·ls,METH_NOARGS, ""},
-  {"e", (PyCFunction)TM·Arr·e, METH_NOARGS, ""},
+  {"Ls",(PyCFunction)TM·Arr·Ls,METH_NOARGS, ""},
   {"r", (PyCFunction)TM·Arr·r, METH_NOARGS, ""},
   {"w", (PyCFunction)TM·Arr·w, METH_O,      ""},
-  {"d", (PyCFunction)TM·Arr·d, METH_NOARGS, ""},
-  {"a", (PyCFunction)TM·Arr·a, METH_O,      ""},
+  {"dR",(PyCFunction)TM·Arr·dR,METH_NOARGS, ""},
+  {"LdR",(PyCFunction)TM·Arr·LdR,METH_NOARGS,""},
   {"esd",(PyCFunction)TM·Arr·esd,METH_NOARGS,""},
-  {"Lesd",(PyCFunction)TM·Arr·Lesd,METH_NOARGS,""},
+  {"eLsd",(PyCFunction)TM·Arr·eLsd,METH_NOARGS,""},
+  {"esa",(PyCFunction)TM·Arr·esa,METH_O,     ""},
+  {"eLsa",(PyCFunction)TM·Arr·eLsa,METH_O,   ""},
+  {"aR",(PyCFunction)TM·Arr·aR,METH_O,       ""},
+  {"LaR",(PyCFunction)TM·Arr·LaR,METH_O,     ""},
   {"qR",(PyCFunction)TM·Arr·qR,METH_NOARGS, ""},
-  {"qL",(PyCFunction)TM·Arr·qL,METH_NOARGS, ""},
+  {"LqR",(PyCFunction)TM·Arr·LqR,METH_NOARGS, ""},
+  {"qnR",(PyCFunction)TM·Arr·qnR,METH_NOARGS,""},
+  {"LqnR",(PyCFunction)TM·Arr·LqnR,METH_NOARGS,""},
   {"sR",(PyCFunction)TM·Arr·sR,METH_NOARGS, ""},
   {"LsR",(PyCFunction)TM·Arr·LsR,METH_NOARGS,""},
   {NULL}
@@ -341,7 +393,7 @@ static PyObject* TM·Nat·sn(TM·Nat* self, PyObject* args){
   self->state += n; Py_RETURN_NONE;
 }
 
-static PyObject* TM·Nat·ls(TM·Nat* self){ 
+static PyObject* TM·Nat·Ls(TM·Nat* self){ 
   if(self->state > 0) self->state--; 
   Py_RETURN_NONE; 
 }
@@ -354,21 +406,36 @@ static PyObject* TM·Nat·w(TM·Nat* self, PyObject* val){
 }
 
 static PyObject* TM·Nat·qR(TM·Nat* self){ Py_RETURN_FALSE; }
-static PyObject* TM·Nat·qL(TM·Nat* self){ 
+static PyObject* TM·Nat·LqR(TM·Nat* self){ 
     if(self->state == 0){
       Py_RETURN_TRUE;
     }
     Py_RETURN_FALSE; 
 }
 
+/* Nat Query N: 
+   qnR -> Infinite? Or not supported. For now, max int?
+   LqnR -> Distance from 0. Equal to state.
+*/
+static PyObject* TM·Nat·qnR(TM·Nat* self){ 
+    /* Abstract number line is infinite. */
+    PyErr_SetString(PyExc_RuntimeError, "Natural Number tape is infinite to the right.");
+    return NULL;
+}
+static PyObject* TM·Nat·LqnR(TM·Nat* self){ 
+    return PyLong_FromUnsignedLongLong(self->state);
+}
+
 static PyMethodDef TM·Nat·methods[] = {
   {"s", (PyCFunction)TM·Nat·s, METH_NOARGS, ""},
   {"sn",(PyCFunction)TM·Nat·sn,METH_VARARGS,""},
-  {"ls",(PyCFunction)TM·Nat·ls,METH_NOARGS, ""},
+  {"Ls",(PyCFunction)TM·Nat·Ls,METH_NOARGS, ""},
   {"r", (PyCFunction)TM·Nat·r, METH_NOARGS, ""},
   {"w", (PyCFunction)TM·Nat·w, METH_O, ""},
   {"qR",(PyCFunction)TM·Nat·qR,METH_NOARGS, ""},
-  {"qL",(PyCFunction)TM·Nat·qL,METH_NOARGS, ""},
+  {"LqR",(PyCFunction)TM·Nat·LqR,METH_NOARGS, ""},
+  {"qnR",(PyCFunction)TM·Nat·qnR,METH_NOARGS, ""},
+  {"LqnR",(PyCFunction)TM·Nat·LqnR,METH_NOARGS, ""},
   {"LsR",(PyCFunction)TM·Nat·LsR,METH_NOARGS, ""},
   {NULL}
 };
@@ -386,7 +453,7 @@ static PyTypeObject TMA_NaturalNumber·Type = {
 
 
 /* ========================================================= */
-/* TYPE DEFINITIONS (The 66 Concrete Types)                  */
+/* TYPE DEFINITIONS (The 60 Concrete Types)                  */
 /* ========================================================= */
 
 #define DEFINE_TYPE(NAME, METHODS) \
@@ -404,114 +471,104 @@ static PyTypeObject NAME##·Type = { \
 /* ---------------------------------------------------------
    1. Arr (Fixed Array)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_Arr_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_Arr_SR_SO, Table·SR·ND) 
-DEFINE_TYPE(TM_Arr_SR_EA, Table·SR·ND)
+DEFINE_TYPE(TM_Arr_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_Arr_CR_SO, Table·CR·ND) 
+DEFINE_TYPE(TM_Arr_CR_EA, Table·CR·ND)
 
-DEFINE_TYPE(TM_Arr_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_Arr_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_Arr_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_Arr_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_Arr_CLR_SO, Table·CLR·ND)
+DEFINE_TYPE(TM_Arr_CLR_EA, Table·CLR·ND)
 
 /* ---------------------------------------------------------
    2. ArrV (Variable Array / Vector)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_ArrV_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_ArrV_SR_SO, Table·SR·SO) /* Destructive */
-DEFINE_TYPE(TM_ArrV_SR_EA, Table·SR·ND)
+DEFINE_TYPE(TM_ArrV_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_ArrV_CR_SO, Table·CR·SO) /* Destructive */
+DEFINE_TYPE(TM_ArrV_CR_EA, Table·CR·ND)
 
-DEFINE_TYPE(TM_ArrV_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_ArrV_SL_SO, Table·SL·SO) /* Destructive */
-DEFINE_TYPE(TM_ArrV_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_ArrV_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_ArrV_CLR_SO, Table·CLR·SO) /* Destructive */
+DEFINE_TYPE(TM_ArrV_CLR_EA, Table·CLR·ND)
 
 /* ---------------------------------------------------------
    3. Gr (Graph Right / Linked List)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_Gr_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_Gr_SR_SO, Table·SR·ND)
-DEFINE_TYPE(TM_Gr_SR_EA, Table·SR·ND)
-DEFINE_TYPE(TM_Gr_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_Gr_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_Gr_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_Gr_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_Gr_CR_SO, Table·CR·ND)
+DEFINE_TYPE(TM_Gr_CR_EA, Table·CR·ND)
+DEFINE_TYPE(TM_Gr_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_Gr_CLR_SO, Table·CLR·ND)
+DEFINE_TYPE(TM_Gr_CLR_EA, Table·CLR·ND)
 
 /* ---------------------------------------------------------
    4. Glr (Graph Left Right / Doubly Linked List)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_Glr_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_Glr_SR_SO, Table·SR·ND)
-DEFINE_TYPE(TM_Glr_SR_EA, Table·SR·ND)
-DEFINE_TYPE(TM_Glr_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_Glr_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_Glr_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_Glr_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_Glr_CR_SO, Table·CR·ND)
+DEFINE_TYPE(TM_Glr_CR_EA, Table·CR·ND)
+DEFINE_TYPE(TM_Glr_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_Glr_CLR_SO, Table·CLR·ND)
+DEFINE_TYPE(TM_Glr_CLR_EA, Table·CLR·ND)
 
 /* ---------------------------------------------------------
    5. Set (Unordered)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_Set_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_Set_SR_SO, Table·SR·ND)
-DEFINE_TYPE(TM_Set_SR_EA, Table·SR·ND)
-DEFINE_TYPE(TM_Set_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_Set_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_Set_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_Set_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_Set_CR_SO, Table·CR·ND)
+DEFINE_TYPE(TM_Set_CR_EA, Table·CR·ND)
+DEFINE_TYPE(TM_Set_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_Set_CLR_SO, Table·CLR·ND)
+DEFINE_TYPE(TM_Set_CLR_EA, Table·CLR·ND)
 
 /* ---------------------------------------------------------
    6. Map (Items)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_Map_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_Map_SR_SO, Table·SR·ND)
-DEFINE_TYPE(TM_Map_SR_EA, Table·SR·ND)
-DEFINE_TYPE(TM_Map_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_Map_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_Map_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_Map_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_Map_CR_SO, Table·CR·ND)
+DEFINE_TYPE(TM_Map_CR_EA, Table·CR·ND)
+DEFINE_TYPE(TM_Map_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_Map_CLR_SO, Table·CLR·ND)
+DEFINE_TYPE(TM_Map_CLR_EA, Table·CLR·ND)
 
 /* ---------------------------------------------------------
    7. MapK (Keys)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_MapK_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_MapK_SR_SO, Table·SR·ND)
-DEFINE_TYPE(TM_MapK_SR_EA, Table·SR·ND)
-DEFINE_TYPE(TM_MapK_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_MapK_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_MapK_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_MapK_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_MapK_CR_SO, Table·CR·ND)
+DEFINE_TYPE(TM_MapK_CR_EA, Table·CR·ND)
+DEFINE_TYPE(TM_MapK_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_MapK_CLR_SO, Table·CLR·ND)
+DEFINE_TYPE(TM_MapK_CLR_EA, Table·CLR·ND)
 
 /* ---------------------------------------------------------
    8. MapV (Values)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_MapV_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_MapV_SR_SO, Table·SR·ND)
-DEFINE_TYPE(TM_MapV_SR_EA, Table·SR·ND)
-DEFINE_TYPE(TM_MapV_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_MapV_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_MapV_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_MapV_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_MapV_CR_SO, Table·CR·ND)
+DEFINE_TYPE(TM_MapV_CR_EA, Table·CR·ND)
+DEFINE_TYPE(TM_MapV_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_MapV_CLR_SO, Table·CLR·ND)
+DEFINE_TYPE(TM_MapV_CLR_EA, Table·CLR·ND)
 
 /* ---------------------------------------------------------
    9. ASCII (String)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_ASCII_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_ASCII_SR_SO, Table·SR·ND) 
-DEFINE_TYPE(TM_ASCII_SR_EA, Table·SR·ND)
-DEFINE_TYPE(TM_ASCII_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_ASCII_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_ASCII_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_ASCII_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_ASCII_CR_SO, Table·CR·ND) 
+DEFINE_TYPE(TM_ASCII_CR_EA, Table·CR·ND)
+DEFINE_TYPE(TM_ASCII_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_ASCII_CLR_SO, Table·CLR·ND)
+DEFINE_TYPE(TM_ASCII_CLR_EA, Table·CLR·ND)
 
 /* ---------------------------------------------------------
    10. UTF8 (String)
    --------------------------------------------------------- */
-DEFINE_TYPE(TM_UTF8_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_UTF8_SR_SO, Table·SR·ND)
-DEFINE_TYPE(TM_UTF8_SR_EA, Table·SR·ND)
-DEFINE_TYPE(TM_UTF8_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_UTF8_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_UTF8_SL_EA, Table·SL·ND)
-
-/* ---------------------------------------------------------
-   11. BCD (String/Array)
-   --------------------------------------------------------- */
-DEFINE_TYPE(TM_BCD_SR_ND, Table·SR·ND)
-DEFINE_TYPE(TM_BCD_SR_SO, Table·SR·ND)
-DEFINE_TYPE(TM_BCD_SR_EA, Table·SR·ND)
-DEFINE_TYPE(TM_BCD_SL_ND, Table·SL·ND)
-DEFINE_TYPE(TM_BCD_SL_SO, Table·SL·ND)
-DEFINE_TYPE(TM_BCD_SL_EA, Table·SL·ND)
+DEFINE_TYPE(TM_UTF8_CR_ND, Table·CR·ND)
+DEFINE_TYPE(TM_UTF8_CR_SO, Table·CR·ND)
+DEFINE_TYPE(TM_UTF8_CR_EA, Table·CR·ND)
+DEFINE_TYPE(TM_UTF8_CLR_ND, Table·CLR·ND)
+DEFINE_TYPE(TM_UTF8_CLR_SO, Table·CLR·ND)
+DEFINE_TYPE(TM_UTF8_CLR_EA, Table·CLR·ND)
 
 
 /* ========================================================= */
@@ -532,48 +589,44 @@ PyMODINIT_FUNC PyInit_TM_module(void){
   if(!m) return NULL;
 
   /* Arr */
-  ADD_TYPE(TM_Arr_SR_ND) ADD_TYPE(TM_Arr_SR_SO) ADD_TYPE(TM_Arr_SR_EA)
-  ADD_TYPE(TM_Arr_SL_ND) ADD_TYPE(TM_Arr_SL_SO) ADD_TYPE(TM_Arr_SL_EA)
+  ADD_TYPE(TM_Arr_CR_ND) ADD_TYPE(TM_Arr_CR_SO) ADD_TYPE(TM_Arr_CR_EA)
+  ADD_TYPE(TM_Arr_CLR_ND) ADD_TYPE(TM_Arr_CLR_SO) ADD_TYPE(TM_Arr_CLR_EA)
   
   /* ArrV */
-  ADD_TYPE(TM_ArrV_SR_ND) ADD_TYPE(TM_ArrV_SR_SO) ADD_TYPE(TM_ArrV_SR_EA)
-  ADD_TYPE(TM_ArrV_SL_ND) ADD_TYPE(TM_ArrV_SL_SO) ADD_TYPE(TM_ArrV_SL_EA)
+  ADD_TYPE(TM_ArrV_CR_ND) ADD_TYPE(TM_ArrV_CR_SO) ADD_TYPE(TM_ArrV_CR_EA)
+  ADD_TYPE(TM_ArrV_CLR_ND) ADD_TYPE(TM_ArrV_CLR_SO) ADD_TYPE(TM_ArrV_CLR_EA)
 
   /* Gr */
-  ADD_TYPE(TM_Gr_SR_ND) ADD_TYPE(TM_Gr_SR_SO) ADD_TYPE(TM_Gr_SR_EA)
-  ADD_TYPE(TM_Gr_SL_ND) ADD_TYPE(TM_Gr_SL_SO) ADD_TYPE(TM_Gr_SL_EA)
+  ADD_TYPE(TM_Gr_CR_ND) ADD_TYPE(TM_Gr_CR_SO) ADD_TYPE(TM_Gr_CR_EA)
+  ADD_TYPE(TM_Gr_CLR_ND) ADD_TYPE(TM_Gr_CLR_SO) ADD_TYPE(TM_Gr_CLR_EA)
 
   /* Glr */
-  ADD_TYPE(TM_Glr_SR_ND) ADD_TYPE(TM_Glr_SR_SO) ADD_TYPE(TM_Glr_SR_EA)
-  ADD_TYPE(TM_Glr_SL_ND) ADD_TYPE(TM_Glr_SL_SO) ADD_TYPE(TM_Glr_SL_EA)
+  ADD_TYPE(TM_Glr_CR_ND) ADD_TYPE(TM_Glr_CR_SO) ADD_TYPE(TM_Glr_CR_EA)
+  ADD_TYPE(TM_Glr_CLR_ND) ADD_TYPE(TM_Glr_CLR_SO) ADD_TYPE(TM_Glr_CLR_EA)
 
   /* Set */
-  ADD_TYPE(TM_Set_SR_ND) ADD_TYPE(TM_Set_SR_SO) ADD_TYPE(TM_Set_SR_EA)
-  ADD_TYPE(TM_Set_SL_ND) ADD_TYPE(TM_Set_SL_SO) ADD_TYPE(TM_Set_SL_EA)
+  ADD_TYPE(TM_Set_CR_ND) ADD_TYPE(TM_Set_CR_SO) ADD_TYPE(TM_Set_CR_EA)
+  ADD_TYPE(TM_Set_CLR_ND) ADD_TYPE(TM_Set_CLR_SO) ADD_TYPE(TM_Set_CLR_EA)
 
   /* Map */
-  ADD_TYPE(TM_Map_SR_ND) ADD_TYPE(TM_Map_SR_SO) ADD_TYPE(TM_Map_SR_EA)
-  ADD_TYPE(TM_Map_SL_ND) ADD_TYPE(TM_Map_SL_SO) ADD_TYPE(TM_Map_SL_EA)
+  ADD_TYPE(TM_Map_CR_ND) ADD_TYPE(TM_Map_CR_SO) ADD_TYPE(TM_Map_CR_EA)
+  ADD_TYPE(TM_Map_CLR_ND) ADD_TYPE(TM_Map_CLR_SO) ADD_TYPE(TM_Map_CLR_EA)
 
   /* MapK */
-  ADD_TYPE(TM_MapK_SR_ND) ADD_TYPE(TM_MapK_SR_SO) ADD_TYPE(TM_MapK_SR_EA)
-  ADD_TYPE(TM_MapK_SL_ND) ADD_TYPE(TM_MapK_SL_SO) ADD_TYPE(TM_MapK_SL_EA)
+  ADD_TYPE(TM_MapK_CR_ND) ADD_TYPE(TM_MapK_CR_SO) ADD_TYPE(TM_MapK_CR_EA)
+  ADD_TYPE(TM_MapK_CLR_ND) ADD_TYPE(TM_MapK_CLR_SO) ADD_TYPE(TM_MapK_CLR_EA)
 
   /* MapV */
-  ADD_TYPE(TM_MapV_SR_ND) ADD_TYPE(TM_MapV_SR_SO) ADD_TYPE(TM_MapV_SR_EA)
-  ADD_TYPE(TM_MapV_SL_ND) ADD_TYPE(TM_MapV_SL_SO) ADD_TYPE(TM_MapV_SL_EA)
+  ADD_TYPE(TM_MapV_CR_ND) ADD_TYPE(TM_MapV_CR_SO) ADD_TYPE(TM_MapV_CR_EA)
+  ADD_TYPE(TM_MapV_CLR_ND) ADD_TYPE(TM_MapV_CLR_SO) ADD_TYPE(TM_MapV_CLR_EA)
 
   /* ASCII */
-  ADD_TYPE(TM_ASCII_SR_ND) ADD_TYPE(TM_ASCII_SR_SO) ADD_TYPE(TM_ASCII_SR_EA)
-  ADD_TYPE(TM_ASCII_SL_ND) ADD_TYPE(TM_ASCII_SL_SO) ADD_TYPE(TM_ASCII_SL_EA)
+  ADD_TYPE(TM_ASCII_CR_ND) ADD_TYPE(TM_ASCII_CR_SO) ADD_TYPE(TM_ASCII_CR_EA)
+  ADD_TYPE(TM_ASCII_CLR_ND) ADD_TYPE(TM_ASCII_CLR_SO) ADD_TYPE(TM_ASCII_CLR_EA)
 
   /* UTF8 */
-  ADD_TYPE(TM_UTF8_SR_ND) ADD_TYPE(TM_UTF8_SR_SO) ADD_TYPE(TM_UTF8_SR_EA)
-  ADD_TYPE(TM_UTF8_SL_ND) ADD_TYPE(TM_UTF8_SL_SO) ADD_TYPE(TM_UTF8_SL_EA)
-
-  /* BCD */
-  ADD_TYPE(TM_BCD_SR_ND) ADD_TYPE(TM_BCD_SR_SO) ADD_TYPE(TM_BCD_SR_EA)
-  ADD_TYPE(TM_BCD_SL_ND) ADD_TYPE(TM_BCD_SL_SO) ADD_TYPE(TM_BCD_SL_EA)
+  ADD_TYPE(TM_UTF8_CR_ND) ADD_TYPE(TM_UTF8_CR_SO) ADD_TYPE(TM_UTF8_CR_EA)
+  ADD_TYPE(TM_UTF8_CLR_ND) ADD_TYPE(TM_UTF8_CLR_SO) ADD_TYPE(TM_UTF8_CLR_EA)
 
   /* Abstract */
   if (PyType_Ready(&TMA_NaturalNumber·Type) < 0) return NULL;
index 3af9f14..6ce3a0d 100755 (executable)
@@ -4,17 +4,17 @@ import sys
 
 def print_tape(tm):
   """
-  Prints tape contents using the First/Rest pattern and vertical comma format.
+  Prints tape contents using the First/Rest pattern.
+  
+  WARNING: This function moves the head!
+  It rewinds to the start (LsR) and traverses to the end.
+  To preserve head state on ND machines, pass 'tm.e()'.
   """
-  # Reset head to start
+  # Reset head to start (Leftmost)
   tm.LsR()
   
-  if tm.qR() and tm.qL():
-    # Handle single element or empty case (qL returns true at start)
-    # Check if we have at least one element by trying to read?
-    # Actually qL and qR being true means 1 element or 0?
-    # qL=True (at start). qR=True (at end). => 1 element.
-    # We rely on 'r' to throw/work.
+  # Handle single element case
+  if tm.qR() and tm.LqR():
     try:
       print(tm.r())
     except:
@@ -33,7 +33,7 @@ def print_tape(tm):
 def tm_loops_tutorial():
   print("--- 1. The Standard Traversal (Read -> Process -> Step) ---")
   data = [10, 20, 30, 40, 50]
-  tm = TM.TM_Arr_SR_ND(data)
+  tm = TM.TM_Arr_CR_ND(data)
   
   while True:
     val = tm.r()
@@ -42,7 +42,7 @@ def tm_loops_tutorial():
     tm.s()
 
   print("\n--- 2. The Accumulator (Initialized First) ---")
-  tm = TM.TM_Arr_SR_ND([1, 2, 3, 4, 5])
+  tm = TM.TM_Arr_CR_ND([1, 2, 3, 4, 5])
   
   total = tm.r()      # Process First
   while not tm.qR():  # Guard
@@ -51,51 +51,77 @@ def tm_loops_tutorial():
       
   print(f"Total: {total}")
 
-  print("\n--- 3. Destructive Filter (Entangled Copy) ---")
-  # We use TM_ArrV_SR_SO because we need 'd' (delete).
-  # We added 'e' (entangle) to the SO table to support this specific workflow.
+  print("\n--- 3. Destructive Filter (Variable Tape) ---")
+  # We use TM_ArrV_CLR_SO (Chiral Left Right, Solitary).
+  # We need CLR to support 'eLsd' (Delete Left Neighbor).
   original_data = [1, 2, 3, 4, 5, 6, 7]
-  tm_master = TM.TM_ArrV_SR_SO(original_data)
+  tm = TM.TM_ArrV_CLR_SO(original_data)
+  
+  # 1. Process First (Index 0) - Special Case
+  # We check the start. If odd, we must delete it.
+  # Since we are at the start, we cannot use eLsd (no left neighbor).
+  # We must Step then eLsd? No, that deletes 0.
+  # If we Step, 0 becomes the left neighbor.
+  
+  tm.LsR() # Ensure start
   
-  # Create an entangled copy for the deletion work
-  tm_worker = tm_master.e()
+  first_val = tm.r()
+  if first_val % 2 != 0:
+      print(f"Deleting odd start: {first_val}")
+      if tm.qR(): 
+          # Single element list. Cannot step.
+          print("(Cannot delete last remaining element)")
+      else:
+          tm.s()    # Step to 1
+          tm.eLsd() # Delete Left Neighbor (Index 0)
+          # Head is now at Index 0 (the element that shifted down).
+          # We must NOT step in the loop immediately, or we skip the new First.
+          # To handle this cleanly in a loop, we align the head to "Previous" logic?
+          # Easier: Just restart logic from the new current.
+          
+          # Since we deleted 0, the loop below starts at the *new* 0.
+          # We just need to make sure we don't double step.
+          # The simplest way is to handle the deletion, then let the loop 
+          # run normally from the current head position.
   
-  # Work on the worker
+  # Main Loop
+  # Invariant: Head is on a valid cell we want to inspect.
   while True:
-    val = tm_worker.r()
-    
-    if val % 2 != 0:
-      print(f"Deleting odd: {val}")
-      # Unguarded delete: We must guarantee we don't delete the final cell
-      # in a way that breaks the invariant for the *other* machine if it were
-      # elsewhere. But here they are entangled.
-      # Note: If we delete the last element, the C logic steps back.
-      tm_worker.d()
-      
-      # Since d() is in-place, the 'next' element slides into the current spot.
-      # We do NOT step. But we must check if we hit the end of the tape
-      # (i.e. we deleted the tail and stepped back, or the tape is empty).
-      
-      # Safety check for end of tape after delete
-      if tm_worker.qR():
-        # We are at the right edge. Check if the current (last) element
-        # also needs deleting.
-        val = tm_worker.r()
-        if val % 2 != 0:
-           print(f"Deleting last odd: {val}")
-           try:
-             tm_worker.d()
-           except RuntimeError:
-             print("(Tape became empty)")
-             break
-        break
-    else:
-      print(f"Keeping even: {val}")
-      if tm_worker.qR(): break
-      tm_worker.s()
+      val = tm.r()
+      if val % 2 != 0:
+          # Found odd. Delete it.
+          print(f"Deleting odd: {val}")
+          
+          if not tm.qR():
+              # Case: Not at end.
+              # Step Right, then delete the item to our Left (which is 'val').
+              tm.s()     
+              tm.eLsd()  
+              # Head is now on the next item (shifted left into current slot).
+              # We continue loop to inspect *this* item.
+          else:
+              # Case: At End (Tail).
+              # Cannot use eLsd strategy because we can't step right.
+              # Must use esd strategy: Step Left, delete Right Neighbor.
+              if tm.LqR():
+                  print("(Last item, cannot empty tape)")
+                  break
+              
+              tm.Ls()  # Step Left
+              tm.esd() # Delete Right Neighbor (Tail)
+              # Tail deleted. We are at new tail.
+              # We inspected this even number already (presumably), so we break?
+              # Actually, if we stepped left, we are on a number we already kept.
+              break
+      else:
+          print(f"Keeping even: {val}")
+          if tm.qR(): break
+          tm.s()
 
   print("Final Tape Content:")
-  print_tape(tm_master)
+  # Pass the SO machine directly. 
+  # This will consume/rewind the head, but that is acceptable here.
+  print_tape(tm) 
 
 if __name__ == "__main__":
   tm_loops_tutorial()
index d4993d1..0a4bc2f 100644 (file)
Binary files a/developer/authored/build/temp.linux-x86_64-cpython-311/TM_module.o and b/developer/authored/build/temp.linux-x86_64-cpython-311/TM_module.o differ
index 13555e3..d6e2a40 100644 (file)
@@ -14,7 +14,7 @@
     <RT-article>
       <RT-title 
         author="Thomas Walker Lynch" 
-        date="2026-02-04
+        date="2026-02-11
         title="Tape Machine">
       </RT-title>
 
         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>
-        A TM is constructed with a set of feature symbols that select which parts of the interface are available.  When no feature symbols are supplied, the result is a non-destructive step right machine with no indexing.  Feature symbols can enable step left behavior (via the mirror view), enable random access indexing functions, and accounting for a shared tape, among other things.
-      </p>
-
       <p>
         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>
         These are selected at TM construction time. In one approach, no methods are placed on the interface that can destroy tape cells. This supports a non-destructive programming paradigm, so such machines are said to be <RT-term>non-destructive</RT-term>. Without destructive operations, entangled machines simply do not have the ability to break each other.  In a second approach, the interface is configured so there are no functions for entangling machines in the first place. Each <RT-neologism>solitary machine</RT-neologism> can safely perform destructive operations because no other machine shares its tape.  As a third approach, each group of entangled machines shares a catalog listing all machines in the group. Caller code can guard operations by querying whether a planned operation is safe before attempting it. This third strategy is called <RT-neologism>entanglement accounting</RT-neologism>. During the time of execution of the guard and operation, each tape machine must be able to lockout others from access to the catalog.  Yet another approach is for the programmer, compiler, or external function to prove code is safe, which is the same as proving that guard code is not needed. An alternative is to use a compiler that only produces correct code in the first place.  This is the approach of <RT-term>correct by construction</RT-term>.
       </p>
 
+      <h1>Machine Naming Convention</h1>
+
+      <p>
+        Concrete Tape Machine classes follow a strict naming grammar. This grammar acts as a feature descriptor, allowing the programmer to select a machine by constructing its name.
+      </p>
+
+      <p>
+        The name is composed of three feature segments: the <RT-term>Container Type</RT-term>, the <RT-term>Chirality</RT-term>, and the <RT-term>Entanglement Approach</RT-term>.
+      </p>
+
+      <h3>grammar</h3>
+      <RT-code>
+        class_name   :: TM [ _container ] [ _chirality ] [ _entanglement ]
+        container    :: ARR | ARRV | GR | GLR | SET | MAP | MAPK | MAPV 
+                      | ASCII | UTF8 
+        chirality    :: CR | CLR
+        entanglement :: ND | SO | EA
+      </RT-code>
+
+      <p>
+        Segments are separated by underscores. The default configuration for a segment is used if that segment is omitted.
+        The default machine is <RT-code>TM_ARR_CR_ND</RT-code> (Fixed Array, Chiral Right, Non-Destructive).
+      </p>
+
+      <h4>container</h4>
+      <ul>
+        <li><RT-code>ARR</RT-code> <strong>Arr</strong>ay Fixed (Default). A contiguous sequence of fixed length (e.g., Python List, C Array).</li>
+        <li><RT-code>ARRV</RT-code> <strong>Arr</strong>ay <strong>V</strong>ariable. A contiguous sequence that may resize (e.g., Vector).</li>
+        <li><RT-code>GR</RT-code> <strong>G</strong>raph <strong>R</strong>ight. A node-based sequence with a single right neighbor (Singly Linked List).</li>
+        <li><RT-code>GLR</RT-code> <strong>G</strong>raph <strong>L</strong>eft <strong>R</strong>ight. A node-based sequence with left and right neighbors (Doubly Linked List).</li>
+        <li><RT-code>SET</RT-code> <strong>Set</strong>. Iteration over the elements of a Set.</li>
+        <li><RT-code>MAP</RT-code> <strong>Map</strong>. Iteration over the items (Key-Value pairs) of a Map.</li>
+        <li><RT-code>MAPK</RT-code> <strong>Map</strong> <strong>K</strong>eys. Iteration over the keys of a Map.</li>
+        <li><RT-code>MAPV</RT-code> <strong>Map</strong> <strong>V</strong>alues. Iteration over the values of a Map.</li>
+        <li><RT-code>ASCII</RT-code> <strong>Ascii</strong>. A sequence of 1-byte characters.</li>
+        <li><RT-code>UTF8</RT-code> <strong>Utf8</strong>. A sequence of variable-width Unicode characters.</li>
+      </ul>
+
+      <h4>chirality</h4>
+      <ul>
+        <li><RT-code>CR</RT-code> <strong>C</strong>hiral <strong>R</strong>ight (Default). The machine head can only be moved to the right.</li>
+        <li><RT-code>CLR</RT-code> <strong>C</strong>hiral <strong>L</strong>eft <strong>R</strong>ight. The machine is bidirectional, supports stepping either right or left.</li>
+      </ul>
+
+      <h4>entanglement</h4>
+      <ul>
+        <li><RT-code>ND</RT-code> <strong>N</strong>on-<strong>D</strong>estructive (Default). Safe for entanglement.</li>
+        <li><RT-code>SO</RT-code> <strong>So</strong>litary. Exclusive ownership; supports destructive ops.</li>
+        <li><RT-code>EA</RT-code> <strong>E</strong>ntanglement <strong>A</strong>ccounting. Shared access guarded by a catalog.</li>
+      </ul>
+
+      <h3>Abstract and Traversal Machines</h3>
+      <p>
+        The naming convention extends to Abstract and Traversal machines using specific prefixes.
+      </p>
+      <ul>
+        <li><RT-code>TMA</RT-code> <strong>TM</strong> <strong>A</strong>bstract. Virtual tapes computed over state.
+          <br><em>Example:</em> <RT-code>TMA_Natural_Number</RT-code> (Iterates 0, 1, 2...).</li>
+        <li><RT-code>TMT</RT-code> <strong>TM</strong> <strong>T</strong>raversal. Algorithmic traversals over non-linear structures.
+          <br><em>Example:</em> <RT-code>TMT_Tree_DepthFirst</RT-code> (Linearizes a tree via stack/recursion).</li>
+      </ul>
+
       <h1>Command language</h1>
 
       <p>
       </p>
 
       <p>
-        A TM is constructed with a set of feature symbols that select which parts of the language are available.
-        When no feature symbols are supplied, the result is a non-destructive step right machine with no indexing.
-        Feature symbols can enable step left behavior (via the mirror view) and can independently enable indexing commands.
+        The grammar selects which parts of the language are available based on the machine's configuration (CR or CLR).
       </p>
 
-
       <h2>For the non-destructive step right machine</h2>
 
       <h3>grammar</h3>
       <p>
         The query command, <RT-code>q</RT-code>, reports head state.
         With no <RT-code>arg</RT-code> descriptor it returns a boolean value.
-        With an <RT-code>R</RT-code> <RT-code>arg</RT-code> descriptor it returns true iff the head is on the rightmost cell. With an <RT-code>I</RT-code> <RT-code>arg</RT-code> descriptor it returns an index.
+        With an <RT-code>R</RT-code> <RT-code>arg</RT-code> descriptor it returns true iff the head is on the rightmost cell.
       </p>
 
       <p>
       </ul>
 
       <p>
-        The <RT-code>n</RT-code> <RT-code>arg</RT-code> descriptor supplies a repetition count.
+        The <RT-code>n</RT-code> <RT-code>arg</RT-code> descriptor supplies a repetition count or implies a distance query.
       </p>
 
       <p>
       <h4>Query</h4>
       <RT-code>
         qR        ; true iff head is on rightmost
+        qnR       ; returns number of steps to rightmost
       </RT-code>
 
       <h4>Copying to and from tape cells and python variables</h4>
       </p>
 
       <p>
-        Step left support does not imply index space.
-        A machine can support <RT-code>L</RT-code> while still omitting index operations.
-        When index space is enabled as an additional feature, the <RT-code>I</RT-code> <RT-code>arg</RT-code> descriptor becomes available and index based cue and query forms become legal.
         When <RT-code>L</RT-code> is available, <RT-code>n</RT-code> can also be negative, with the sign selecting the direction in the base view.
       </p>
 
         statement  :: ( [machine] command [arg]* )+
         machine    :: L
         command    :: e | q | r | s | w
-        arg        :: R | I | n
+        arg        :: R | n
       </RT-code>
 
       <p>
-        Index space, as defined in the TTCA book, is a natural number sequence machine that walks the tape of a base machine and establishes a one to one correspondence between natural numbers and tape cells.
-        That correspondence belongs to the tape and stays fixed when we change the view.
-        For example, consider a tape with cells <RT-code>[c_0 ,c_1 ,c_2 ,c_3 ,c_4]</RT-code>, where <RT-code>c_4</RT-code> is rightmost and has index 4.
+        Consider a tape with cells <RT-code>[c_0 ,c_1 ,c_2 ,c_3 ,c_4]</RT-code>, where <RT-code>c_4</RT-code> is rightmost.
         In the mirror view we write the same cells as <RT-code>[c_4 ,c_3 ,c_2 ,c_1 ,c_0]</RT-code>.
-        In the mirror view <RT-code>c_4</RT-code> sits at the left edge, and it still has index 4.
+        In the mirror view <RT-code>c_4</RT-code> sits at the left edge.
         A right step from <RT-code>c_4</RT-code> in the mirror view lands on <RT-code>c_3</RT-code>, which matches a left step from <RT-code>c_4</RT-code> in the base view.
       </p>
 
         sn(2)     ; step to right neighbor twice
       </RT-code>
 
-      <h4>Head movement relative to leftmost</h4>
-      <RT-code>
-        sI(0)     ; cue the head to the leftmost cell by index
-        sI(3)     ; cue the head to tape[3]
-      </RT-code>
-
-      <p>
-        <RT-code>LsI(k)</RT-code> and <RT-code>sI(k)</RT-code> cue the head to the same indexed cell.
-        <RT-code>L</RT-code> flips direction and the meaning of <RT-code>R</RT-code>, not the index to cell correspondence.
-        Thus <RT-code>LsI(0)</RT-code> cues the cell with index zero, which is rightmost in the mirror view and leftmost in the base view.
-      </p>
-
       <h4>Absolute head movement</h4>
       <RT-code>
         LsR       ; cue the head to leftmost
         sR        ; cue the head to rightmost
       </RT-code>
 
-      <p>
-        Without code optimization <RT-code>LsR</RT-code> will be faster than <RT-code>sI(0)</RT-code>, because <RT-code>sI</RT-code> requires passing and processing an argument.
-      </p>
-
       <h4>Query</h4>
       <RT-code>
         LqR       ; head is on leftmost
         qR        ; head is on rightmost
-        qI        ; index of the head
-        qIR       ; index of rightmost
-        LqIR      ; index of leftmost, typically zero
+        qnR       ; steps to rightmost
+        LqnR      ; steps to leftmost
       </RT-code>
 
-      <p>
-        The <RT-code>I</RT-code> <RT-code>arg</RT-code> descriptor causes <RT-code>q</RT-code> to return an index.
-        By default <RT-code>q</RT-code> returns a boolean value.
-        In other commands, an <RT-code>I</RT-code> <RT-code>arg</RT-code> descriptor indicates that an index argument is supplied.
-      </p>
-
       <p>
         The <RT-code>R</RT-code> <RT-code>arg</RT-code> descriptor focuses the command on the selected view rightmost cell.
         For <RT-code>qR</RT-code>, the result is true iff the head is on rightmost.
-        For <RT-code>qIR</RT-code>, the result is the index of rightmost.
-        Under <RT-code>L</RT-code>, that rightmost cell is the base view leftmost cell, so <RT-code>LqIR</RT-code> returns the index of leftmost, typically zero.
+        Under <RT-code>L</RT-code>, that rightmost cell is the base view leftmost cell, so <RT-code>LqR</RT-code> returns true iff the head is on the leftmost cell.
       </p>
 
       <h4>Copying to and from tape cells and python variables</h4>
       <p>
         The <RT-code>L</RT-code> prefix is not implemented as a distinct family of primitives.
         In the command language it selects the mirror view.
-        In the API the same effect is provided by explicit left primitives such as <RT-code>ls()</RT-code> and <RT-code>lsn(n)</RT-code>, or by allowing a signed <RT-code>n</RT-code> on machines that support step left.
-      </p>
-
-      <h2>Feature symbols and primitive availability</h2>
-
-      <p>
-        A TM is constructed with feature symbols that select which primitive families are present.
-        With no feature symbols, the result is a non-destructive step right machine with no indexing.
-        Enabling step left adds left motion primitives (or signed <RT-code>n</RT-code> support) and mirror view semantics in the command language.
-        Indexing is an independent feature: when enabled, index based query and cue forms become legal and corresponding primitives become available.
+        In the API the same effect is provided by explicit left primitives such as <RT-code>Ls()</RT-code> and <RT-code>Lsn(n)</RT-code>, or by allowing a signed <RT-code>n</RT-code> on machines that support step left.
       </p>
 
       <h2>Navigation primitives</h2>
       </p>
 
       <ul>
-        <li><RT-code>ls()</RT-code> steps to the left neighbor. (Command form: <RT-code>Ls</RT-code>.)</li>
-        <li><RT-code>lsn(n)</RT-code> steps left <RT-math>n</RT-math> times. (Command form: <RT-code>Lsn(n)</RT-code>.)</li>
-        <li><RT-code>lsR()</RT-code> cues the head to leftmost. (Command form: <RT-code>LsR</RT-code>.)</li>
+        <li><RT-code>Ls()</RT-code> steps to the left neighbor. (Command form: <RT-code>Ls</RT-code>.)</li>
+        <li><RT-code>Lsn(n)</RT-code> steps left <RT-math>n</RT-math> times. (Command form: <RT-code>Lsn(n)</RT-code>.)</li>
+        <li><RT-code>LsR()</RT-code> cues the head to leftmost. (Command form: <RT-code>LsR</RT-code>.)</li>
       </ul>
 
       <p>
         Note the correspondence: <RT-code>sR</RT-code> cues rightmost in the base view, and <RT-code>LsR</RT-code> cues leftmost of that same underlying tape.
-        The primitives <RT-code>sR()</RT-code> and <RT-code>lsR()</RT-code> are optimized cues.
+        The primitives <RT-code>sR()</RT-code> and <RT-code>LsR()</RT-code> are optimized cues.
       </p>
 
       <h2>Input and output primitives</h2>
         <li><RT-code>wn(list)</RT-code> writes a list of values.</li>
       </ul>
 
-<h2>Destructive Primitives</h2>
+      <h2>Destructive Primitives</h2>
 
       <p>
         Machines configured with the <RT-code>SO</RT-code> (Solitary) entanglement approach may expose primitives that modify the tape structure.
         <strong>Note:</strong> Not all container types support all destructive operations. For example, <RT-code>ARR</RT-code> (Fixed Array) does not support deletion or insertion, whereas <RT-code>ARRV</RT-code> (Variable Array) does.
       </p>
 
-      <h3>Delete (<RT-code>d</RT-code>)</h3>
-      <p>
-        Removes cells from the tape. The head typically lands on the right neighbor of the deleted segment.
-      </p>
-      <ul>
-        <li><RT-code>d()</RT-code>: Deletes the current cell.</li>
-        <li><RT-code>dn(n)</RT-code>: Deletes <RT-code>n</RT-code> cells starting from current.</li>
-        <li><RT-code>dR()</RT-code>: Deletes from current to Rightmost (inclusive).</li>
-        <li><RT-code>dL()</RT-code>: Deletes from current to Leftmost (inclusive).</li>
-      </ul>
-
       <h3>Delete Neighbor (<RT-code>esd</RT-code>)</h3>
       <p>
         A compound-style primitive that deletes a neighbor without moving the active head.
       </p>
       <ul>
         <li><RT-code>esd()</RT-code>: Deletes the immediate right neighbor. Guard: Requires <RT-code>not qR()</RT-code>.</li>
-        <li><RT-code>esdn(n)</RT-code>: Deletes <RT-code>n</RT-code> right neighbors.</li>
-        <li><RT-code>Lesd()</RT-code>: Deletes the immediate left neighbor. Guard: Requires <RT-code>not qL()</RT-code>.</li>
+        <li><RT-code>eLsd()</RT-code>: Deletes the immediate left neighbor. Guard: Requires <RT-code>not LqR()</RT-code>.</li>
+      </ul>
+
+      <h3>Delete to Bound (<RT-code>dR</RT-code>)</h3>
+      <ul>
+        <li><RT-code>dR()</RT-code>: Deletes from current to Rightmost (inclusive). Head steps left. Guard: Requires <RT-code>not LqR()</RT-code>.</li>
+        <li><RT-code>LdR()</RT-code>: Deletes from current to Leftmost (inclusive). Head lands on right neighbor. Guard: Requires <RT-code>not qR()</RT-code>.</li>
       </ul>
 
-      <h3>Insert/Append (<RT-code>a</RT-code>)</h3>
+      <h3>Insert/Append (<RT-code>esa</RT-code>)</h3>
       <ul>
-        <li><RT-code>a(v)</RT-code>: Inserts value <RT-code>v</RT-code> at the current head position. The old current cell shifts right.</li>
-        <li><RT-code>an(list)</RT-code>: Splices a list of values at the current position.</li>
+        <li><RT-code>esa(v)</RT-code>: Appends value <RT-code>v</RT-code> after the current head position.</li>
+        <li><RT-code>eLsa(v)</RT-code>: Appends value <RT-code>v</RT-code> before the current head position.</li>
+        <li><RT-code>aR(v)</RT-code>: Appends value <RT-code>v</RT-code> to the Rightmost end of the tape.</li>
+        <li><RT-code>LaR(v)</RT-code>: Appends value <RT-code>v</RT-code> to the Leftmost end of the tape.</li>
       </ul>
 
       <h2>Query primitives</h2>
       <p>
         Query primitives are built from the <RT-code>q</RT-code> command.
         On the step right only machine, the primitive set covers the boolean query forms.
-        When indexing is enabled as an additional feature, index valued query forms become available.
       </p>
 
       <ul>
         <li><RT-code>qR()</RT-code> returns whether the head is on the selected view rightmost cell. (Command form: <RT-code>qR</RT-code>.)</li>
+        <li><RT-code>qnR()</RT-code> returns number of steps to rightmost cell. (Command form: <RT-code>qnR</RT-code>.)</li>
       </ul>
 
       <p>
-        If indexing is enabled, the API also exposes index query primitives.
-        These correspond to the <RT-code>I</RT-code> arg descriptor in the command language.
+        Mirror view query forms follow the same rule in the command language.
+        For example, <RT-code>LqR</RT-code> tests the leftmost of the underlying tape.
       </p>
-
+      
       <ul>
-        <li><RT-code>qI()</RT-code> returns the current head index. (Command form: <RT-code>qI</RT-code>.)</li>
-        <li><RT-code>qIR()</RT-code> returns the index of the selected view rightmost cell. (Command form: <RT-code>qIR</RT-code>.)</li>
+        <li><RT-code>LqR()</RT-code> returns whether the head is on the leftmost cell. (Command form: <RT-code>LqR</RT-code>.)</li>
+        <li><RT-code>LqnR()</RT-code> returns number of steps to leftmost cell. (Command form: <RT-code>LqnR</RT-code>.)</li>
       </ul>
 
-      <p>
-        Mirror view query forms follow the same rule in the command language.
-        For example, <RT-code>LqR</RT-code> tests the leftmost of the underlying tape, and <RT-code>LqIR</RT-code> returns its index, typically zero.
-      </p>
-
       <h2>Entanglement primitives</h2>
 
       <p>
       </ol>
 
       <p>
-        In order to maintain these properties, a TM uses inclusive bounds for intervals, including intervals of cells, and intervals of indexes.
+        In order to maintain these properties, a TM uses inclusive bounds for intervals, including intervals of cells.
       </p>
 
       <h2>Contract with the programmer</h2>
 
       <p> The Region Machine implements the standard TM interface but constrains movement based on the boundary heads. </p>
 
-      <ul> <li><strong>Step (<RT-code>s</RT-code>):</strong> The Active Head performs a step only if it is not currently on the Right Boundary cell. <ul> <li><RT-code>s()</RT-code> requires <RT-code>not qR()</RT-code>.</li> </ul> </li> <li><strong>Step Left (<RT-code>ls</RT-code>):</strong> The Active Head performs a left step only if it is not currently on the Left Boundary cell. <ul> <li><RT-code>ls()</RT-code> requires <RT-code>not qL()</RT-code>.</li> </ul> </li> <li><strong>Query Bounds (<RT-code>qR</RT-code>, <RT-code>qL</RT-code>):</strong> <ul> <li><RT-code>qR()</RT-code> returns true if the Active Head is on the same cell as the Right Boundary Head.</li> <li><RT-code>qL()</RT-code> returns true if the Active Head is on the same cell as the Left Boundary Head.</li> </ul> </li> <li><strong>Cue Bounds (<RT-code>sR</RT-code>, <RT-code>lsR</RT-code>):</strong> <ul> <li><RT-code>sR()</RT-code> moves the Active Head to the cell occupied by the Right Boundary Head.</li> <li><RT-code>lsR()</RT-code> moves the Active Head to the cell occupied by the Left Boundary Head.</li> </ul> </li> </ul>
+      <ul> <li><strong>Step (<RT-code>s</RT-code>):</strong> The Active Head performs a step only if it is not currently on the Right Boundary cell. <ul> <li><RT-code>s()</RT-code> requires <RT-code>not qR()</RT-code>.</li> </ul> </li> <li><strong>Step Left (<RT-code>Ls</RT-code>):</strong> The Active Head performs a left step only if it is not currently on the Left Boundary cell. <ul> <li><RT-code>Ls()</RT-code> requires <RT-code>not LqR()</RT-code>.</li> </ul> </li> <li><strong>Query Bounds (<RT-code>qR</RT-code>, <RT-code>LqR</RT-code>):</strong> <ul> <li><RT-code>qR()</RT-code> returns true if the Active Head is on the same cell as the Right Boundary Head.</li> <li><RT-code>LqR()</RT-code> returns true if the Active Head is on the same cell as the Left Boundary Head.</li> </ul> </li> <li><strong>Cue Bounds (<RT-code>sR</RT-code>, <RT-code>LsR</RT-code>):</strong> <ul> <li><RT-code>sR()</RT-code> moves the Active Head to the cell occupied by the Right Boundary Head.</li> <li><RT-code>LsR()</RT-code> moves the Active Head to the cell occupied by the Left Boundary Head.</li> </ul> </li> </ul>
 
       <h2>Boundary Management</h2>
 
 
       <p> Because the TMS implements the TM interface, it can be passed directly to these algorithms. However, if the status is <RT-code>Empty</RT-code>, the first operation attempted by the algorithm (usually <RT-code>r()</RT-code>) will trigger a "second order" error, alerting the programmer that they neglected the guard. </p>
 
-      <h1>Machine Naming Convention</h1>
-
-      <p>
-        Concrete Tape Machine classes follow a strict naming grammar. This grammar acts as a feature descriptor, allowing the programmer to select a machine by constructing its name.
-      </p>
-
-      <p>
-        The name is composed of three feature segments: the <RT-term>Container Type</RT-term>, the <RT-term>Step Direction</RT-term>, and the <RT-term>Entanglement Approach</RT-term>.
-      </p>
-
-      <h3>grammar</h3>
-      <RT-code>
-        class_name   :: TM [ _container ] [ _direction ] [ _entanglement ]
-        container    :: ARR | ARRV | GR | GLR | SET | MAP | MAPK | MAPV 
-                      | ASCII | UTF8 | BCD
-        direction    :: SR | SL
-        entanglement :: ND | SO | EA
-      </RT-code>
-
-      <p>
-        Segments are separated by underscores. The default configuration for a segment is used if that segment is omitted.
-        The default machine is <RT-code>TM_ARR_SR_ND</RT-code> (Fixed Array, Step Right, Non-Destructive).
-      </p>
-
-      <h4>container</h4>
-      <ul>
-        <li><RT-code>ARR</RT-code> <strong>Arr</strong>ay Fixed (Default). A contiguous sequence of fixed length (e.g., Python List, C Array).</li>
-        <li><RT-code>ARRV</RT-code> <strong>Arr</strong>ay <strong>V</strong>ariable. A contiguous sequence that may resize (e.g., Vector).</li>
-        <li><RT-code>GR</RT-code> <strong>G</strong>raph <strong>R</strong>ight. A node-based sequence with a single right neighbor (Singly Linked List).</li>
-        <li><RT-code>GLR</RT-code> <strong>G</strong>raph <strong>L</strong>eft <strong>R</strong>ight. A node-based sequence with left and right neighbors (Doubly Linked List).</li>
-        <li><RT-code>SET</RT-code> <strong>Set</strong>. Iteration over the elements of a Set.</li>
-        <li><RT-code>MAP</RT-code> <strong>Map</strong>. Iteration over the items (Key-Value pairs) of a Map.</li>
-        <li><RT-code>MAPK</RT-code> <strong>Map</strong> <strong>K</strong>eys. Iteration over the keys of a Map.</li>
-        <li><RT-code>MAPV</RT-code> <strong>Map</strong> <strong>V</strong>alues. Iteration over the values of a Map.</li>
-        <li><RT-code>ASCII</RT-code> <strong>Ascii</strong>. A sequence of 1-byte characters.</li>
-        <li><RT-code>UTF8</RT-code> <strong>Utf8</strong>. A sequence of variable-width Unicode characters.</li>
-        <li><RT-code>BCD</RT-code> <strong>Bcd</strong>. A sequence of Binary Coded Decimal values.</li>
-      </ul>
-
-      <h4>direction</h4>
-      <ul>
-        <li><RT-code>SR</RT-code> <strong>S</strong>tep <strong>R</strong>ight (Default). The machine head can only be moved to the right.</li>
-        <li><RT-code>SL</RT-code> <strong>S</strong>tep <strong>L</strong>eft. The machine is bidirectional, supports stepping either right or left.</li>
-      </ul>
-
-      <h4>entanglement</h4>
-      <ul>
-        <li><RT-code>ND</RT-code> <strong>N</strong>on-<strong>D</strong>estructive (Default). Safe for entanglement.</li>
-        <li><RT-code>SO</RT-code> <strong>So</strong>litary. Exclusive ownership; supports destructive ops.</li>
-        <li><RT-code>EA</RT-code> <strong>E</strong>ntanglement <strong>A</strong>ccounting. Shared access guarded by a catalog.</li>
-      </ul>
-
-      <h3>Abstract and Traversal Machines</h3>
-      <p>
-        The naming convention extends to Abstract and Traversal machines using specific prefixes.
-      </p>
-      <ul>
-        <li><RT-code>TMA</RT-code> <strong>TM</strong> <strong>A</strong>bstract. Virtual tapes computed over state.
-          <br><em>Example:</em> <RT-code>TMA_Natural_Number</RT-code> (Iterates 0, 1, 2...).</li>
-        <li><RT-code>TMT</RT-code> <strong>TM</strong> <strong>T</strong>raversal. Algorithmic traversals over non-linear structures.
-          <br><em>Example:</em> <RT-code>TMT_Tree_DepthFirst</RT-code> (Linearizes a tree via stack/recursion).</li>
-      </ul>
-
-
     </RT-article>
   </body>
 </html>
diff --git a/document/TM_reference.html b/document/TM_reference.html
deleted file mode 100644 (file)
index 83b3073..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <meta charset="UTF-8">
-    <title>TM Reference</title>
-    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap" rel="stylesheet">
-
-    <script src="style/body_visibility_hidden.js"></script>
-    <script>
-      window.StyleRT.body_visibility_hidden();
-    </script>
-
-    <script src="style/utility.js"></script>
-    <script src="style/theme_dark_gold.js"></script>
-    <script src="style/article_tech_ref.js"></script>
-    <script src="style/RT_math.js"></script>
-    <script src="style/RT_code.js"></script>
-    <script src="style/RT_term.js"></script>
-    <script src="style/RT_TOC.js"></script>
-  </head>
-  <body>
-    <RT-article>
-      <RT-title 
-        author="Thomas Walker Lynch" 
-        date="2026-02-11" 
-        title="Tape Machine Reference">
-      </RT-title>
-
-      <RT-TOC level="2"></RT-TOC>
-
-      <h1>Machine names</h1>
-
-      <h2>Concrete first order machines</h2>
-
-      <RT-code>
-        TM_&lt;CONTAINER&gt;_&lt;TRAVERSAL&gt;_&lt;ENTANGLEMENT&gt;
-      </RT-code>
-
-      <h3>CONTAINER</h3>
-
-      <ul>
-        <li><RT-code>ARRAY</RT-code> Python array of cell payload pointers (default)</li>
-        <li><RT-code>BCD</RT-code> reserved. Planned view over a bit vector that groups bits into 4 bit digits</li>
-      </ul>
-
-      <h3>TRAVERSAL</h3>
-
-      <ul>
-        <li><RT-code>SR</RT-code> step right only</li>
-        <li><RT-code>SL</RT-code> step left and right, via mirror view operations</li>
-      </ul>
-
-      <h3>ENTANGLEMENT</h3>
-
-      <ul>
-        <li><RT-code>ND</RT-code> non destructive</li>
-        <li><RT-code>SO</RT-code> solitary</li>
-        <li><RT-code>EA</RT-code> entanglement accounting</li>
-      </ul>
-
-      <h2>Abstract machines</h2>
-
-      <RT-code>
-        TMA_&lt;ABSTRACT_NAME&gt;
-      </RT-code>
-
-      <p>
-        Abstract machines do not bind to a data object.
-        They are placeholders for virtual tapes and for higher order machinery.
-      </p>
-
-      <h1>Command language grammar</h1>
-
-      <h2>Command groups</h2>
-
-      <RT-code>
-        command_group := [view] command {arg}
-        view          := "L"
-        command       := "e" | "q" | "r" | "s" | "w" | "d" | "a"
-        arg           := "R" | n
-      </RT-code>
-
-      <p>
-        A method name is a sequence of command groups.
-        Each command letter begins a new group.
-        Argument descriptors attach to the command group that precedes them.
-      </p>
-
-      <h2>Mirror view mapping</h2>
-
-      <p>
-        The command language uses <RT-code>L</RT-code> to select mirror view.
-        The Python API uses explicit left method names.
-        The mapping is:
-      </p>
-
-      <ul>
-        <li><RT-code>Ls</RT-code> becomes <RT-code>ls()</RT-code></li>
-        <li><RT-code>Lsn(n)</RT-code> becomes <RT-code>lsn(n)</RT-code></li>
-        <li><RT-code>LsR</RT-code> becomes <RT-code>lsR()</RT-code></li>
-        <li><RT-code>Ld</RT-code> becomes <RT-code>ld()</RT-code></li>
-        <li><RT-code>Lesd</RT-code> becomes <RT-code>lesd()</RT-code></li>
-      </ul>
-
-      <h2>Traversal and repetition</h2>
-
-      <p>
-        On <RT-code>SR</RT-code> machines, <RT-code>sn(n)</RT-code> expects a non negative integer.
-        On <RT-code>SL</RT-code> machines, <RT-code>sn(n)</RT-code> accepts a signed integer, where negative counts step left.
-      </p>
-
-      <h1>Primitive method availability</h1>
-
-      <p>
-        The second column uses machine name patterns.
-        The wildcard <RT-code>*</RT-code> stands for any container.
-      </p>
-
-      <h2>Navigation</h2>
-
-      <table>
-        <thead>
-          <tr>
-            <th>Method</th>
-            <th>Available on</th>
-          </tr>
-        </thead>
-        <tbody>
-          <tr>
-            <td><RT-code>s()</RT-code></td>
-            <td><RT-code>TM_*_SR_*</RT-code> ,<RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>sn(n)</RT-code></td>
-            <td><RT-code>TM_*_SR_*</RT-code> ,<RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>sR()</RT-code></td>
-            <td><RT-code>TM_*_SR_*</RT-code> ,<RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>ls()</RT-code></td>
-            <td><RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>lsn(n)</RT-code></td>
-            <td><RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>lsR()</RT-code></td>
-            <td><RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-        </tbody>
-      </table>
-
-      <h2>Read and write</h2>
-
-      <table>
-        <thead>
-          <tr>
-            <th>Method</th>
-            <th>Available on</th>
-          </tr>
-        </thead>
-        <tbody>
-          <tr>
-            <td><RT-code>r()</RT-code></td>
-            <td><RT-code>TM_*_SR_*</RT-code> ,<RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>w(v)</RT-code></td>
-            <td><RT-code>TM_*_SR_*</RT-code> ,<RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-        </tbody>
-      </table>
-
-      <h2>Queries</h2>
-
-      <table>
-        <thead>
-          <tr>
-            <th>Method</th>
-            <th>Available on</th>
-          </tr>
-        </thead>
-        <tbody>
-          <tr>
-            <td><RT-code>qR()</RT-code></td>
-            <td><RT-code>TM_*_SR_*</RT-code> ,<RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>lqR()</RT-code> mirror rightmost</td>
-            <td><RT-code>TM_*_SL_*</RT-code></td>
-          </tr>
-        </tbody>
-      </table>
-
-      <h2>Entanglement</h2>
-
-      <table>
-        <thead>
-          <tr>
-            <th>Method</th>
-            <th>Available on</th>
-          </tr>
-        </thead>
-        <tbody>
-          <tr>
-            <td><RT-code>e()</RT-code></td>
-            <td><RT-code>TM_*_*_ND</RT-code> ,<RT-code>TM_*_*_EA</RT-code></td>
-          </tr>
-        </tbody>
-      </table>
-
-      <h2>Structural mutation</h2>
-
-      <table>
-        <thead>
-          <tr>
-            <th>Method</th>
-            <th>Available on</th>
-          </tr>
-        </thead>
-        <tbody>
-          <tr>
-            <td><RT-code>d()</RT-code> delete current</td>
-            <td><RT-code>TM_*_*_SO</RT-code> ,<RT-code>TM_*_*_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>dn(n)</RT-code> delete current repeated</td>
-            <td><RT-code>TM_*_*_SO</RT-code> ,<RT-code>TM_*_*_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>dR()</RT-code> cue delete to rightmost</td>
-            <td><RT-code>TM_*_*_SO</RT-code> ,<RT-code>TM_*_*_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>ld()</RT-code> mirror delete current</td>
-            <td><RT-code>TM_*_SL_SO</RT-code> ,<RT-code>TM_*_SL_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>ldn(n)</RT-code> mirror delete repeated</td>
-            <td><RT-code>TM_*_SL_SO</RT-code> ,<RT-code>TM_*_SL_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>ldR()</RT-code> cue delete to leftmost</td>
-            <td><RT-code>TM_*_SL_SO</RT-code> ,<RT-code>TM_*_SL_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>esd()</RT-code> entangle, step, delete neighbor</td>
-            <td><RT-code>TM_*_*_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>esdn(n)</RT-code> repeated neighbor delete</td>
-            <td><RT-code>TM_*_*_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>esdR()</RT-code> cue neighbor delete to rightmost</td>
-            <td><RT-code>TM_*_*_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>lesd()</RT-code> mirror neighbor delete</td>
-            <td><RT-code>TM_*_SL_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>a(v)</RT-code> insert one value</td>
-            <td><RT-code>TM_*_*_SO</RT-code> ,<RT-code>TM_*_*_EA</RT-code></td>
-          </tr>
-          <tr>
-            <td><RT-code>an(list)</RT-code> insert list values</td>
-            <td><RT-code>TM_*_*_SO</RT-code> ,<RT-code>TM_*_*_EA</RT-code></td>
-          </tr>
-        </tbody>
-      </table>
-
-            <script src="style/style_orchestrator.js"></script>
-      <script>
-        window.StyleRT.style_orchestrator();
-      </script>
-
-    </RT-article>
-  </body>
-</html>
diff --git a/document/TM_sav.html b/document/TM_sav.html
deleted file mode 100644 (file)
index 13555e3..0000000
+++ /dev/null
@@ -1,681 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta charset="UTF-8">
-    <title>Tape Machine</title>
-    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap" rel="stylesheet">
-    
-    <script src="style/body_visibility_hidden.js"></script>
-    <script>
-      window.StyleRT.body_visibility_hidden();
-    </script>
-  </head>
-  <body>
-    <RT-article>
-      <RT-title 
-        author="Thomas Walker Lynch" 
-        date="2026-02-04" 
-        title="Tape Machine">
-      </RT-title>
-
-      <RT-TOC level="1"></RT-TOC>
-
-      <h1>Introduction</h1>
-
-      <p>
-        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 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 a TM packages both data, and all pointers into that data, within one structure.
-      </p>
-
-      <p>
-        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 presents the same TM 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>
-        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>
-        A TM is constructed with a set of feature symbols that select which parts of the interface are available.  When no feature symbols are supplied, the result is a non-destructive step right machine with no indexing.  Feature symbols can enable step left behavior (via the mirror view), enable random access indexing functions, and accounting for a shared tape, among other things.
-      </p>
-
-      <p>
-        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>
-
-      <p>
-        If an operation were permitted to remove the last remaining cell of a tape, 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>
-        Tape machines that share a tape are said to be <RT-neologism>entangled</RT-neologism>. There will be both data and structure hazards among entangled machines. Data hazards have to do with the misuse of locks or other mistakes in cooperation between machines that cause a machine to read the wrong data. Data hazards can lead to incorrectly computed results, but they will not break the machines. In contrast, structure hazards lead to broken machines. The principle structure hazard is that of one entangled TM deleting a cell that another TM has its head on. That orphans the head of that other machine and leads to a violation of the <em>a tape machine head is always on a valid cell</em> invariant. 
-      </p>
-
-      <p>
-        We leave the data hazard management to the programmer; however, we provide specific features for avoiding  structure hazards.
-        These are selected at TM construction time. In one approach, no methods are placed on the interface that can destroy tape cells. This supports a non-destructive programming paradigm, so such machines are said to be <RT-term>non-destructive</RT-term>. Without destructive operations, entangled machines simply do not have the ability to break each other.  In a second approach, the interface is configured so there are no functions for entangling machines in the first place. Each <RT-neologism>solitary machine</RT-neologism> can safely perform destructive operations because no other machine shares its tape.  As a third approach, each group of entangled machines shares a catalog listing all machines in the group. Caller code can guard operations by querying whether a planned operation is safe before attempting it. This third strategy is called <RT-neologism>entanglement accounting</RT-neologism>. During the time of execution of the guard and operation, each tape machine must be able to lockout others from access to the catalog.  Yet another approach is for the programmer, compiler, or external function to prove code is safe, which is the same as proving that guard code is not needed. An alternative is to use a compiler that only produces correct code in the first place.  This is the approach of <RT-term>correct by construction</RT-term>.
-      </p>
-
-      <h1>Command language</h1>
-
-      <p>
-        The command language is not used directly, rather it describes the letter patterns used to form TM interface function names.
-        Such an approach can be found in LISP language list access function names, and its extension is described in the paper "Towards a Better Understanding of CAR, CDR, CADR and the Others".
-      </p>
-
-      <p>
-        The actual function names found on TM interfaces are listed in later sections of this guide. The ultimate authority is the source code itself. Later we can add a compiler for creating new functions based on this language. Such a compiler would be a function that adds functions to a TM interface.
-      </p>
-
-      <p>
-        A TM is constructed with a set of feature symbols that select which parts of the language are available.
-        When no feature symbols are supplied, the result is a non-destructive step right machine with no indexing.
-        Feature symbols can enable step left behavior (via the mirror view) and can independently enable indexing commands.
-      </p>
-
-
-      <h2>For the non-destructive step right machine</h2>
-
-      <h3>grammar</h3>
-      <RT-code>
-        statement  :: ( command [arg]* )+
-        command    :: e | q | r | s | w
-        arg        :: R | n
-      </RT-code>
-
-      <h4>statement</h4>
-      <p>
-        A statement is parsed left to right. Each command letter begins a new command group.  All following <RT-code>arg</RT-code> descriptors attach to that command until the next command letter appears.  There are no spaces. Arguments are given to the resulting function in the order that the command and its descriptors require them.
-      </p>
-
-      <p>
-        Accordingly, a function name such as <RT-code>snr(i)</RT-code> denotes two command groups:
-        <RT-code>sn(i)</RT-code> steps right <RT-code>i</RT-code> times, then <RT-code>r</RT-code> copies out the current cell.
-      </p>
-
-      <h4>command</h4>
-      <ul>
-        <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</li>
-        <li><RT-code>w</RT-code> <strong>w</strong>rite</li>
-      </ul>
-
-      <p>
-        Two or more machines are entangled when they share one tape.
-        Entangle differs from clone because the tape is shared rather than copied.
-        What is duplicated is the head state, so entangled heads move independently.
-        A machine produced by <RT-code>e</RT-code> begins with its head on the same cell as the machine it was created from.
-      </p>
-
-      <p>
-        The query command, <RT-code>q</RT-code>, reports head state.
-        With no <RT-code>arg</RT-code> descriptor it returns a boolean value.
-        With an <RT-code>R</RT-code> <RT-code>arg</RT-code> descriptor it returns true iff the head is on the rightmost cell. With an <RT-code>I</RT-code> <RT-code>arg</RT-code> descriptor it returns an index.
-      </p>
-
-      <p>
-        TM uses a guard approach for end cases. Query commands appear in control flow so caller code can select the guards it needs and handle end cases explicitly.
-        When guards are unnecessary, caller code can omit them.
-      </p>
-
-      <p>
-        The <RT-code>r</RT-code> and <RT-code>w</RT-code> commands copy values to and from the current cell.
-        As of the time of this writing they are cell local operations, so direction does not enter.
-      </p>
-
-      <p>
-        The <RT-code>s</RT-code> step command moves the head to the right neighbor cell.
-        When <RT-code>s</RT-code> is given an <RT-code>n</RT-code> <RT-code>arg</RT-code> descriptor, it performs <RT-code>n</RT-code> right steps.
-        On a step right only machine, <RT-code>n</RT-code> must be positive.
-      </p>
-
-      <h4>arg</h4>
-      <ul>
-        <li><RT-code>n</RT-code> <strong>n</strong></li>
-        <li><RT-code>R</RT-code> <strong>R</strong>ightmost</li>
-      </ul>
-
-      <p>
-        The <RT-code>n</RT-code> <RT-code>arg</RT-code> descriptor supplies a repetition count.
-      </p>
-
-      <p>
-        The <RT-code>R</RT-code> <RT-code>arg</RT-code> descriptor focuses the command on the rightmost cell.
-        For <RT-code>qR</RT-code>, the result is true iff the head is on rightmost.
-        For <RT-code>sR</RT-code>, the effect is to cue the head to rightmost.
-      </p>
-
-      <h3>Examples</h3>
-
-      <h4>Relative head movement</h4>
-      <RT-code>
-        s         ; step to right neighbor
-        sn(1)     ; step to right neighbor
-        sn(2)     ; step to right neighbor twice
-      </RT-code>
-
-      <h4>Absolute head movement</h4>
-      <RT-code>
-        sR        ; cue the head to rightmost
-      </RT-code>
-
-      <h4>Query</h4>
-      <RT-code>
-        qR        ; true iff head is on rightmost
-      </RT-code>
-
-      <h4>Copying to and from tape cells and python variables</h4>
-      <RT-code>
-        r          ; copies cell contents to the LHS of an assignment
-        w(v)       ; copies v into the cell
-      </RT-code>
-
-
-      <h2>For the non-destructive machine that has step left</h2>
-
-      <p>
-        The step right grammar extends to left going behavior by introducing a mirror view of a machine.
-        In the mirror view, every rightward operation corresponds to the base machine’s leftward operation, so new command letters are unnecessary.
-        What is rightmost in the base view becomes leftmost in the mirror view, and vice versa.
-      </p>
-
-      <p>
-        In this extended grammar, the <RT-code>L</RT-code> prefix selects the mirror view for the command group that follows it.
-        <RT-code>L</RT-code> affects direction sensitive operations such as stepping, moving to rightmost, and scans.
-        Today <RT-code>r</RT-code> and <RT-code>w</RT-code> are cell local, so <RT-code>L</RT-code> does not change their behavior.
-      </p>
-
-      <p>
-        Step left support does not imply index space.
-        A machine can support <RT-code>L</RT-code> while still omitting index operations.
-        When index space is enabled as an additional feature, the <RT-code>I</RT-code> <RT-code>arg</RT-code> descriptor becomes available and index based cue and query forms become legal.
-        When <RT-code>L</RT-code> is available, <RT-code>n</RT-code> can also be negative, with the sign selecting the direction in the base view.
-      </p>
-
-      <h3>grammar</h3>
-      <RT-code>
-        statement  :: ( [machine] command [arg]* )+
-        machine    :: L
-        command    :: e | q | r | s | w
-        arg        :: R | I | n
-      </RT-code>
-
-      <p>
-        Index space, as defined in the TTCA book, is a natural number sequence machine that walks the tape of a base machine and establishes a one to one correspondence between natural numbers and tape cells.
-        That correspondence belongs to the tape and stays fixed when we change the view.
-        For example, consider a tape with cells <RT-code>[c_0 ,c_1 ,c_2 ,c_3 ,c_4]</RT-code>, where <RT-code>c_4</RT-code> is rightmost and has index 4.
-        In the mirror view we write the same cells as <RT-code>[c_4 ,c_3 ,c_2 ,c_1 ,c_0]</RT-code>.
-        In the mirror view <RT-code>c_4</RT-code> sits at the left edge, and it still has index 4.
-        A right step from <RT-code>c_4</RT-code> in the mirror view lands on <RT-code>c_3</RT-code>, which matches a left step from <RT-code>c_4</RT-code> in the base view.
-      </p>
-
-      <h3>Examples</h3>
-
-      <p>
-        In these examples, the comments discuss what happens on the base machine. Effects in the mirror view match the same command without the <RT-code>L</RT-code> prefix.
-      </p>
-
-      <h4>Relative head movement</h4>
-      <RT-code>
-        Ls        ; step to left neighbor
-        Lsn(2)    ; step to left neighbor twice
-        sn(-2)    ; step to left neighbor twice
-        sn(2)     ; step to right neighbor twice
-      </RT-code>
-
-      <h4>Head movement relative to leftmost</h4>
-      <RT-code>
-        sI(0)     ; cue the head to the leftmost cell by index
-        sI(3)     ; cue the head to tape[3]
-      </RT-code>
-
-      <p>
-        <RT-code>LsI(k)</RT-code> and <RT-code>sI(k)</RT-code> cue the head to the same indexed cell.
-        <RT-code>L</RT-code> flips direction and the meaning of <RT-code>R</RT-code>, not the index to cell correspondence.
-        Thus <RT-code>LsI(0)</RT-code> cues the cell with index zero, which is rightmost in the mirror view and leftmost in the base view.
-      </p>
-
-      <h4>Absolute head movement</h4>
-      <RT-code>
-        LsR       ; cue the head to leftmost
-        sR        ; cue the head to rightmost
-      </RT-code>
-
-      <p>
-        Without code optimization <RT-code>LsR</RT-code> will be faster than <RT-code>sI(0)</RT-code>, because <RT-code>sI</RT-code> requires passing and processing an argument.
-      </p>
-
-      <h4>Query</h4>
-      <RT-code>
-        LqR       ; head is on leftmost
-        qR        ; head is on rightmost
-        qI        ; index of the head
-        qIR       ; index of rightmost
-        LqIR      ; index of leftmost, typically zero
-      </RT-code>
-
-      <p>
-        The <RT-code>I</RT-code> <RT-code>arg</RT-code> descriptor causes <RT-code>q</RT-code> to return an index.
-        By default <RT-code>q</RT-code> returns a boolean value.
-        In other commands, an <RT-code>I</RT-code> <RT-code>arg</RT-code> descriptor indicates that an index argument is supplied.
-      </p>
-
-      <p>
-        The <RT-code>R</RT-code> <RT-code>arg</RT-code> descriptor focuses the command on the selected view rightmost cell.
-        For <RT-code>qR</RT-code>, the result is true iff the head is on rightmost.
-        For <RT-code>qIR</RT-code>, the result is the index of rightmost.
-        Under <RT-code>L</RT-code>, that rightmost cell is the base view leftmost cell, so <RT-code>LqIR</RT-code> returns the index of leftmost, typically zero.
-      </p>
-
-      <h4>Copying to and from tape cells and python variables</h4>
-      <RT-code>
-        r          ; copies cell contents to the LHS of an assignment
-        w(v)       ; copies v into the cell
-      </RT-code>
-
-      <p>
-        The current <RT-code>r</RT-code> and <RT-code>w</RT-code> are cell local and are unaffected by <RT-code>L</RT-code>.
-        If we later support list forms or repetition forms for copy, <RT-code>L</RT-code> will affect the scan direction for those operations.
-      </p>
-
-      <h1>TM interface functions</h1>
-
-      <p>
-        This section lists the concrete methods exposed by the Python/C implementation.
-        These methods implement a selected subset of the command grammar.
-        The grammar defines a command language, while the primitive set defines the operations the library exposes directly.
-        Later sections can introduce a compile layer that accepts additional command combinations.
-      </p>
-
-      <p>
-        The <RT-code>L</RT-code> prefix is not implemented as a distinct family of primitives.
-        In the command language it selects the mirror view.
-        In the API the same effect is provided by explicit left primitives such as <RT-code>ls()</RT-code> and <RT-code>lsn(n)</RT-code>, or by allowing a signed <RT-code>n</RT-code> on machines that support step left.
-      </p>
-
-      <h2>Feature symbols and primitive availability</h2>
-
-      <p>
-        A TM is constructed with feature symbols that select which primitive families are present.
-        With no feature symbols, the result is a non-destructive step right machine with no indexing.
-        Enabling step left adds left motion primitives (or signed <RT-code>n</RT-code> support) and mirror view semantics in the command language.
-        Indexing is an independent feature: when enabled, index based query and cue forms become legal and corresponding primitives become available.
-      </p>
-
-      <h2>Navigation primitives</h2>
-
-      <p>
-        Navigation primitives implement the <RT-code>s</RT-code> command with the argument forms <RT-code>ε</RT-code>, <RT-code>n</RT-code>, and <RT-code>R</RT-code>.
-        On a step right only machine, <RT-code>n</RT-code> is constrained to positive values.
-        On a machine that supports step left, <RT-code>n</RT-code> can be negative, with the sign selecting direction in the base view.
-      </p>
-
-      <ul>
-        <li><RT-code>s()</RT-code> steps to the right neighbor. (Command form: <RT-code>s</RT-code>.)</li>
-        <li><RT-code>sn(n)</RT-code> steps by <RT-code>n</RT-code> cells. On a step right only machine, <RT-code>n</RT-code> must be positive. (Command form: <RT-code>sn(n)</RT-code>.)</li>
-        <li><RT-code>sR()</RT-code> cues the head to the selected view rightmost cell. (Command form: <RT-code>sR</RT-code>.)</li>
-      </ul>
-
-      <p>
-        If step left is enabled, left motion is available either as explicit primitives, or via negative <RT-code>n</RT-code> on <RT-code>sn(n)</RT-code>, depending on the configured interface.
-        When explicit left primitives exist, they correspond to the mirror view command forms.
-      </p>
-
-      <ul>
-        <li><RT-code>ls()</RT-code> steps to the left neighbor. (Command form: <RT-code>Ls</RT-code>.)</li>
-        <li><RT-code>lsn(n)</RT-code> steps left <RT-math>n</RT-math> times. (Command form: <RT-code>Lsn(n)</RT-code>.)</li>
-        <li><RT-code>lsR()</RT-code> cues the head to leftmost. (Command form: <RT-code>LsR</RT-code>.)</li>
-      </ul>
-
-      <p>
-        Note the correspondence: <RT-code>sR</RT-code> cues rightmost in the base view, and <RT-code>LsR</RT-code> cues leftmost of that same underlying tape.
-        The primitives <RT-code>sR()</RT-code> and <RT-code>lsR()</RT-code> are optimized cues.
-      </p>
-
-      <h2>Input and output primitives</h2>
-
-      <p>
-        The I/O primitives implement <RT-code>r</RT-code> and <RT-code>w(value)</RT-code>.
-        In the command language, <RT-code>r</RT-code> reads the current cell payload, and <RT-code>w(v)</RT-code> writes a payload to the current cell.
-        As of the time of this writing, these operations are cell local, so mirror view does not change their behavior.
-      </p>
-
-      <ul>
-        <li><RT-code>r()</RT-code> reads the current cell.</li>
-        <li><RT-code>w(v)</RT-code> writes <RT-code>v</RT-code> to the current cell.</li>
-      </ul>
-
-      <p>
-        Bulk forms can exist in the API, but they are not represented in the current command grammar.
-        They are library level conveniences built on top of repeated primitive behavior.
-        If bulk copy forms become part of the command grammar later, mirror view will affect scan direction for those operations.
-      </p>
-
-      <ul>
-        <li><RT-code>rn(n)</RT-code> reads <RT-math>n</RT-math> cells.</li>
-        <li><RT-code>wn(list)</RT-code> writes a list of values.</li>
-      </ul>
-
-<h2>Destructive Primitives</h2>
-
-      <p>
-        Machines configured with the <RT-code>SO</RT-code> (Solitary) entanglement approach may expose primitives that modify the tape structure.
-        These are distinct from <RT-code>w</RT-code> (which modifies cell <em>content</em>) because they change the cell <em>count</em> or <em>sequence</em>.
-      </p>
-
-      <p>
-        <strong>Note:</strong> Not all container types support all destructive operations. For example, <RT-code>ARR</RT-code> (Fixed Array) does not support deletion or insertion, whereas <RT-code>ARRV</RT-code> (Variable Array) does.
-      </p>
-
-      <h3>Delete (<RT-code>d</RT-code>)</h3>
-      <p>
-        Removes cells from the tape. The head typically lands on the right neighbor of the deleted segment.
-      </p>
-      <ul>
-        <li><RT-code>d()</RT-code>: Deletes the current cell.</li>
-        <li><RT-code>dn(n)</RT-code>: Deletes <RT-code>n</RT-code> cells starting from current.</li>
-        <li><RT-code>dR()</RT-code>: Deletes from current to Rightmost (inclusive).</li>
-        <li><RT-code>dL()</RT-code>: Deletes from current to Leftmost (inclusive).</li>
-      </ul>
-
-      <h3>Delete Neighbor (<RT-code>esd</RT-code>)</h3>
-      <p>
-        A compound-style primitive that deletes a neighbor without moving the active head.
-        Mnemonic: <em>Entangle-Step-Delete</em> (conceptually acts on the neighbor).
-      </p>
-      <ul>
-        <li><RT-code>esd()</RT-code>: Deletes the immediate right neighbor. Guard: Requires <RT-code>not qR()</RT-code>.</li>
-        <li><RT-code>esdn(n)</RT-code>: Deletes <RT-code>n</RT-code> right neighbors.</li>
-        <li><RT-code>Lesd()</RT-code>: Deletes the immediate left neighbor. Guard: Requires <RT-code>not qL()</RT-code>.</li>
-      </ul>
-
-      <h3>Insert/Append (<RT-code>a</RT-code>)</h3>
-      <ul>
-        <li><RT-code>a(v)</RT-code>: Inserts value <RT-code>v</RT-code> at the current head position. The old current cell shifts right.</li>
-        <li><RT-code>an(list)</RT-code>: Splices a list of values at the current position.</li>
-      </ul>
-
-      <h2>Query primitives</h2>
-
-      <p>
-        Query primitives are built from the <RT-code>q</RT-code> command.
-        On the step right only machine, the primitive set covers the boolean query forms.
-        When indexing is enabled as an additional feature, index valued query forms become available.
-      </p>
-
-      <ul>
-        <li><RT-code>qR()</RT-code> returns whether the head is on the selected view rightmost cell. (Command form: <RT-code>qR</RT-code>.)</li>
-      </ul>
-
-      <p>
-        If indexing is enabled, the API also exposes index query primitives.
-        These correspond to the <RT-code>I</RT-code> arg descriptor in the command language.
-      </p>
-
-      <ul>
-        <li><RT-code>qI()</RT-code> returns the current head index. (Command form: <RT-code>qI</RT-code>.)</li>
-        <li><RT-code>qIR()</RT-code> returns the index of the selected view rightmost cell. (Command form: <RT-code>qIR</RT-code>.)</li>
-      </ul>
-
-      <p>
-        Mirror view query forms follow the same rule in the command language.
-        For example, <RT-code>LqR</RT-code> tests the leftmost of the underlying tape, and <RT-code>LqIR</RT-code> returns its index, typically zero.
-      </p>
-
-      <h2>Entanglement primitives</h2>
-
-      <p>
-        Entanglement primitives implement the <RT-code>e</RT-code> command.
-        The entangled machine shares the tape with the original machine and and initially have their head on the same cell.
-        In entanglement accounting configurations, entangled machines also share the group catalog used by guard predicates.
-      </p>
-
-      <ul>
-        <li><RT-code>e()</RT-code> returns a new entangled machine sharing the same tape. (Command form: <RT-code>e</RT-code>.)</li>
-      </ul>
-
-      <p>
-        Combined command forms such as <RT-code>es</RT-code> are legal in the grammar, but they are not required as primitives.
-        The library can expose such combinations as convenience calls, or generate them through a compile layer.
-        The core model remains that a statement is a sequence of commands applied to a selected view.
-      </p>
-
-      <h1>Usage</h1>
-
-      <h2>First order TM properties</h2>
-
-      <p>
-        For a first order TM these properties are always true.
-      </p>
-
-      <ol>
-        <li>The head is always on a valid cell.</li>
-        <li>All cells return a value when read.</li>
-      </ol>
-
-      <p>
-        In order to maintain these properties, a TM uses inclusive bounds for intervals, including intervals of cells, and intervals of indexes.
-      </p>
-
-      <h2>Contract with the programmer</h2>
-
-      <p>
-        Some first order TM types rely upon the caller to maintain a contract.
-        Such machines typically have debug variants that add contract checks.
-        For some machines, breaking the contract limits compiler optimization.
-        For other machines, breaking the contract causes program bugs.
-      </p>
-
-      <p>
-        <strong>Contract:</strong>
-      </p>
-
-      <ol>
-        <li>When there is a right bound, the caller guarantees that he will never command the machine to step beyond the rightmost cell.</li>
-        <li>When there is a left bound, the caller guarantees that he will never command the machine to step left of the leftmost cell.</li>
-      </ol>
-
-      <p>
-        When traversing a tape, the contract is fulfilled by a First Rest pattern.
-      </p>
-
-      <h1>First Rest pattern with initialization</h1>
-
-      <RT-code>
-        # Pattern 1: First Rest (Initialize with First)
-        # Useful when the accumulator starts with the first value.
-        total = tm.r()      # Process First
-        while not tm.qR():  # Guard: Is there a Rest?
-          tm.s()          # Step (Protected)
-          total += tm.r() # Process Next
-      </RT-code>
-
-      <p>
-        Here <RT-code>tm.qR()</RT-code> queries whether the head is on the selected view rightmost cell.
-        It guards the step in the loop.
-        No redundant tests are done, and the loop ends without stepping off the tape.
-      </p>
-
-      <h1>First Rest pattern without initialization</h1>
-
-      <p>
-        Sometimes the accumulator is initialized to an identity value (such as zero) before the loop starts.
-        In that form, the loop and a half structure is natural.
-      </p>
-
-      <RT-code>
-        # Conceptual "do" loop
-        do:
-          total += tm.r()   # Always process the current cell
-          if tm.qR() break  # protects increment from spilling over
-          tm.s()            # Step only when not at the end
-      </RT-code>
-
-      <p>
-        Python has no <RT-code>do</RT-code> statement, so the same logic is written explicitly:
-      </p>
-
-      <RT-code>
-        # Python implementation
-        while True:
-          total += tm.r()
-          if tm.qR(): break
-          tm.s()
-      </RT-code>
-
-      <p>
-        The middle test <RT-code>tm.qR()</RT-code> guards <RT-code>tm.s()</RT-code>, so the machine never steps beyond rightmost.
-      </p>
-
-      <h1>Region Machine</h1>
-
-      <p> A <RT-term>Region Machine</RT-term> is a composite structure built from three entangled tape machines. It enforces the invariant that the active head remains within a specified closed interval of the tape. </p>
-
-      <h2>Structure</h2>
-
-      <p> The Region Machine consists of: </p> <ul> <li><strong>Left Boundary Machine:</strong> A TM marking the leftmost valid cell of the region.</li> <li><strong>Right Boundary Machine:</strong> A TM marking the rightmost valid cell of the region.</li> <li><strong>Active Machine:</strong> The TM interface exposed to the user for navigation and I/O.</li> </ul>
-
-      <p> Because the Region Machine relies on the First Order invariant (head always on a valid cell), a region cannot be empty. The minimum region size is one cell, where the Left Boundary, Right Boundary, and Active Head all occupy the same cell. </p>
-
-      <h2>Behavior</h2>
-
-      <p> The Region Machine implements the standard TM interface but constrains movement based on the boundary heads. </p>
-
-      <ul> <li><strong>Step (<RT-code>s</RT-code>):</strong> The Active Head performs a step only if it is not currently on the Right Boundary cell. <ul> <li><RT-code>s()</RT-code> requires <RT-code>not qR()</RT-code>.</li> </ul> </li> <li><strong>Step Left (<RT-code>ls</RT-code>):</strong> The Active Head performs a left step only if it is not currently on the Left Boundary cell. <ul> <li><RT-code>ls()</RT-code> requires <RT-code>not qL()</RT-code>.</li> </ul> </li> <li><strong>Query Bounds (<RT-code>qR</RT-code>, <RT-code>qL</RT-code>):</strong> <ul> <li><RT-code>qR()</RT-code> returns true if the Active Head is on the same cell as the Right Boundary Head.</li> <li><RT-code>qL()</RT-code> returns true if the Active Head is on the same cell as the Left Boundary Head.</li> </ul> </li> <li><strong>Cue Bounds (<RT-code>sR</RT-code>, <RT-code>lsR</RT-code>):</strong> <ul> <li><RT-code>sR()</RT-code> moves the Active Head to the cell occupied by the Right Boundary Head.</li> <li><RT-code>lsR()</RT-code> moves the Active Head to the cell occupied by the Left Boundary Head.</li> </ul> </li> </ul>
-
-      <h2>Boundary Management</h2>
-
-      <p> The boundaries of a region are themselves Tape Machines. This allows the region to expand or contract dynamically. Moving a boundary head changes the effective range of the Active Machine immediately. </p>
-
-      <p> <strong>Safety Constraint:</strong> A boundary head cannot step past the other boundary head. The Left Boundary must always be to the left of or on the same cell as the Right Boundary. Furthermore, the Active Head must not be orphaned by boundary movement. If the Right Boundary steps left past the Active Head, the Active Head is no longer valid. Therefore, boundary contraction requires checking or moving the Active Head to maintain the invariant. </p>
-
-      <h1>TM Workspace functions</h1>
-
-      <p> The <RT-code>TM_workspace</RT-code> namespace contains higher-level functions that coordinate multiple machines. These functions are not part of the core TM interface but operate on TMs to implement common algorithms. </p>
-
-      <h2>Tandem operations</h2>
-
-      <p> Tandem operations drive multiple machines simultaneously. They are useful for copying, comparing, or parallel processing. </p>
-
-      <ul> <li><RT-code>step_tandem(tm1, tm2)</RT-code>: Steps both machines to their respective right neighbors. Requires that neither machine is at its rightmost bound.</li> <li><RT-code>zip_apply(f, tm1, tm2)</RT-code>: Applies function <RT-code>f</RT-code> to the values read from <RT-code>tm1</RT-code> and <RT-code>tm2</RT-code>, then steps both.</li> </ul>
-
-      <h2>Predicates</h2>
-
-      <p> Predicates test relationships between entangled machines. </p>
-
-      <ul> <li><RT-code>head_on_same_cell(tm1, tm2)</RT-code>: Returns true if the heads of two entangled machines are on the same cell. This is the fundamental primitive used to implement <RT-code>qR</RT-code> in Region Machines.</li> </ul>
-
-
-      <script src="style/style_orchestrator.js"></script>
-      <script>
-        window.StyleRT.style_orchestrator();
-      </script>
-
-      <h1>Second Order Machine (TMS)</h1>
-
-      <p> A <RT-term>Second Order Machine</RT-term>, or <RT-code>TMS</RT-code> (Tape Machine Status), is a wrapper that manages the lifecycle of a First Order Tape Machine. It introduces the concept of <RT-term>status</RT-term> to handle conditions that violate First Order invariants, specifically the absence of valid cells (emptiness). </p>
-
-      <h2>Status definitions</h2>
-
-      <p> The TMS manages a state machine where the states are called <RT-term>statuses</RT-term> to distinguish them from the internal state of the tape or head. The current status determines which interface functions are available to the programmer. </p>
-
-      <ul> <li><RT-code>Active</RT-code>: The machine contains cells. The underlying First Order TM is valid. All standard TM navigation and I/O commands function normally.</li> <li><RT-code>Empty</RT-code>: The machine contains no cells. There is no tape and no head position. First Order operations like <RT-code>r</RT-code> or <RT-code>s</RT-code> are invalid and will raise errors if called. Only status-query and insertion operations are available.</li> <li><RT-code>Parked</RT-code>: The machine contains cells, but the head is effectively "lifted" from the tape. The head is not on any valid cell. This status is often used during initialization or after a search fails to find a target.</li> </ul>
-
-      <h2>Dynamic interface dispatch</h2>
-
-      <p> The TMS implementation uses dynamic dispatch (or mixin replacement) to enforce status constraints. When the status changes, the interface functions are swapped. </p>
-
-      <p> For example, in the <RT-code>Empty</RT-code> status, the <RT-code>r()</RT-code> function is mapped to an error handler: <RT-code>Error: Attempted to read from an empty machine.</RT-code> This prevents the programmer from accidentally running First Order logic on a machine that does not satisfy the First Order invariant. </p>
-
-      <h2>Transitions</h2>
-
-      <p> Status changes occur when operations alter the cell count to or from zero, or when the head is explicitly parked or unparked. </p>
-
-      <h3>Promotion (Empty to Active)</h3> <p> When a TMS is <RT-code>Empty</RT-code>, calling an insertion function (e.g., <RT-code>append(v)</RT-code>) creates the first cell. The status transitions to <RT-code>Active</RT-code>. The interface is updated to expose standard TM behaviors. The head is placed on the newly created cell. </p>
-
-      <h3>Demotion (Active to Empty)</h3> <p> If a deletion operation removes the last remaining cell of an <RT-code>Active</RT-code> machine, the First Order invariant is broken. The TMS detects this event, destroys the underlying First Order TM, and transitions the status to <RT-code>Empty</RT-code>. The interface is updated to the restricted Empty set. </p>
-
-      <h2>Usage with algorithms</h2>
-
-      <p> Algorithms requiring a First Order TM (such as <RT-code>foreach</RT-code> loops or First Rest patterns) must effectively be guarded by a status check. </p>
-
-      <RT-code> if tms.is_active(): # Safe to treat as a First Order TM run_algorithm(tms) else: # Handle empty case pass </RT-code>
-
-      <p> Because the TMS implements the TM interface, it can be passed directly to these algorithms. However, if the status is <RT-code>Empty</RT-code>, the first operation attempted by the algorithm (usually <RT-code>r()</RT-code>) will trigger a "second order" error, alerting the programmer that they neglected the guard. </p>
-
-      <h1>Machine Naming Convention</h1>
-
-      <p>
-        Concrete Tape Machine classes follow a strict naming grammar. This grammar acts as a feature descriptor, allowing the programmer to select a machine by constructing its name.
-      </p>
-
-      <p>
-        The name is composed of three feature segments: the <RT-term>Container Type</RT-term>, the <RT-term>Step Direction</RT-term>, and the <RT-term>Entanglement Approach</RT-term>.
-      </p>
-
-      <h3>grammar</h3>
-      <RT-code>
-        class_name   :: TM [ _container ] [ _direction ] [ _entanglement ]
-        container    :: ARR | ARRV | GR | GLR | SET | MAP | MAPK | MAPV 
-                      | ASCII | UTF8 | BCD
-        direction    :: SR | SL
-        entanglement :: ND | SO | EA
-      </RT-code>
-
-      <p>
-        Segments are separated by underscores. The default configuration for a segment is used if that segment is omitted.
-        The default machine is <RT-code>TM_ARR_SR_ND</RT-code> (Fixed Array, Step Right, Non-Destructive).
-      </p>
-
-      <h4>container</h4>
-      <ul>
-        <li><RT-code>ARR</RT-code> <strong>Arr</strong>ay Fixed (Default). A contiguous sequence of fixed length (e.g., Python List, C Array).</li>
-        <li><RT-code>ARRV</RT-code> <strong>Arr</strong>ay <strong>V</strong>ariable. A contiguous sequence that may resize (e.g., Vector).</li>
-        <li><RT-code>GR</RT-code> <strong>G</strong>raph <strong>R</strong>ight. A node-based sequence with a single right neighbor (Singly Linked List).</li>
-        <li><RT-code>GLR</RT-code> <strong>G</strong>raph <strong>L</strong>eft <strong>R</strong>ight. A node-based sequence with left and right neighbors (Doubly Linked List).</li>
-        <li><RT-code>SET</RT-code> <strong>Set</strong>. Iteration over the elements of a Set.</li>
-        <li><RT-code>MAP</RT-code> <strong>Map</strong>. Iteration over the items (Key-Value pairs) of a Map.</li>
-        <li><RT-code>MAPK</RT-code> <strong>Map</strong> <strong>K</strong>eys. Iteration over the keys of a Map.</li>
-        <li><RT-code>MAPV</RT-code> <strong>Map</strong> <strong>V</strong>alues. Iteration over the values of a Map.</li>
-        <li><RT-code>ASCII</RT-code> <strong>Ascii</strong>. A sequence of 1-byte characters.</li>
-        <li><RT-code>UTF8</RT-code> <strong>Utf8</strong>. A sequence of variable-width Unicode characters.</li>
-        <li><RT-code>BCD</RT-code> <strong>Bcd</strong>. A sequence of Binary Coded Decimal values.</li>
-      </ul>
-
-      <h4>direction</h4>
-      <ul>
-        <li><RT-code>SR</RT-code> <strong>S</strong>tep <strong>R</strong>ight (Default). The machine head can only be moved to the right.</li>
-        <li><RT-code>SL</RT-code> <strong>S</strong>tep <strong>L</strong>eft. The machine is bidirectional, supports stepping either right or left.</li>
-      </ul>
-
-      <h4>entanglement</h4>
-      <ul>
-        <li><RT-code>ND</RT-code> <strong>N</strong>on-<strong>D</strong>estructive (Default). Safe for entanglement.</li>
-        <li><RT-code>SO</RT-code> <strong>So</strong>litary. Exclusive ownership; supports destructive ops.</li>
-        <li><RT-code>EA</RT-code> <strong>E</strong>ntanglement <strong>A</strong>ccounting. Shared access guarded by a catalog.</li>
-      </ul>
-
-      <h3>Abstract and Traversal Machines</h3>
-      <p>
-        The naming convention extends to Abstract and Traversal machines using specific prefixes.
-      </p>
-      <ul>
-        <li><RT-code>TMA</RT-code> <strong>TM</strong> <strong>A</strong>bstract. Virtual tapes computed over state.
-          <br><em>Example:</em> <RT-code>TMA_Natural_Number</RT-code> (Iterates 0, 1, 2...).</li>
-        <li><RT-code>TMT</RT-code> <strong>TM</strong> <strong>T</strong>raversal. Algorithmic traversals over non-linear structures.
-          <br><em>Example:</em> <RT-code>TMT_Tree_DepthFirst</RT-code> (Linearizes a tree via stack/recursion).</li>
-      </ul>
-
-
-    </RT-article>
-  </body>
-</html>
diff --git a/document/TM_user.html b/document/TM_user.html
deleted file mode 100644 (file)
index 62993d5..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <meta charset="UTF-8">
-    <title>TM User Guide</title>
-    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap" rel="stylesheet">
-
-    <script src="style/body_visibility_hidden.js"></script>
-    <script>
-      window.StyleRT.body_visibility_hidden();
-    </script>
-
-    <script src="style/utility.js"></script>
-    <script src="style/theme_dark_gold.js"></script>
-    <script src="style/article_tech_ref.js"></script>
-    <script src="style/RT_math.js"></script>
-    <script src="style/RT_code.js"></script>
-    <script src="style/RT_term.js"></script>
-    <script src="style/RT_TOC.js"></script>
-  </head>
-  <body>
-    <RT-article>
-      <RT-title 
-        author="Thomas Walker Lynch" 
-        date="2026-02-11" 
-        title="Tape Machine User Guide">
-      </RT-title>
-
-      <RT-TOC level="1"></RT-TOC>
-
-      <h1>Introduction</h1>
-
-      <p>
-        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), maps (given an ordering function), and 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 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>
-        A defining invariant of a <RT-term>first order</RT-term> TM is:
-        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>Choosing a machine</h1>
-
-      <p>
-        In the current implementation, you choose a TM by choosing a concrete TM class.
-        Machine capabilities are encoded in the class name.
-        Concrete machines require a <RT-term>data object</RT-term> at construction time.
-        Abstract machines do not require a data object, but they come later.
-      </p>
-
-      <p>
-        The default concrete machine is <RT-code>TM_ARRAY_SR_ND(data_obj)</RT-code>.
-        It treats the data object as a Python array of cell payload pointers.
-      </p>
-
-      <h2>Machine naming convention</h2>
-
-      <p>
-        First order concrete machines use this name form:
-      </p>
-
-      <RT-code>
-        TM_&lt;CONTAINER&gt;_&lt;TRAVERSAL&gt;_&lt;ENTANGLEMENT&gt;
-      </RT-code>
-
-      <p>
-        Abstract machines (virtual tapes) use:
-      </p>
-
-      <RT-code>
-        TMA_&lt;ABSTRACT_NAME&gt;
-      </RT-code>
-
-      <h2>Field meanings</h2>
-
-      <ul>
-        <li><strong>CONTAINER</strong>: the backing data substrate.</li>
-        <li><strong>TRAVERSAL</strong>: which directions the head can move.</li>
-        <li><strong>ENTANGLEMENT</strong>: what sharing and structural mutation rules apply.</li>
-      </ul>
-
-      <h1>Command language</h1>
-
-      <p>
-        The command language is not used directly.
-        It describes the letter patterns used to form TM interface method names.
-        The approach began with LISP, and its extension is described in the paper
-        "Towards a Better Understanding of CAR, CDR, CADR and the Others".
-      </p>
-
-      <p>
-        A method name is a sequence of command groups.
-        Parsing is left to right.
-        Each command letter begins a new group.
-        Any argument descriptors that follow attach to that group until the next command letter appears.
-      </p>
-
-      <p>
-        Example: <RT-code>snr(i)</RT-code> denotes two groups.
-        <RT-code>sn(i)</RT-code> steps right <RT-code>i</RT-code> times, then <RT-code>r()</RT-code> reads the current cell.
-      </p>
-
-      <h2>Core commands</h2>
-
-      <ul>
-        <li><RT-code>e</RT-code> entangle</li>
-        <li><RT-code>q</RT-code> query</li>
-        <li><RT-code>r</RT-code> read</li>
-        <li><RT-code>s</RT-code> step</li>
-        <li><RT-code>w</RT-code> write</li>
-      </ul>
-
-      <h2>Argument descriptors</h2>
-
-      <ul>
-        <li><RT-code>n</RT-code> repetition count</li>
-        <li><RT-code>R</RT-code> selected view rightmost</li>
-      </ul>
-
-      <h2>Mirror view</h2>
-
-      <p>
-        Some machines support stepping left as well as right.
-        In the command language, the <RT-code>L</RT-code> prefix selects the mirror view for the command group that follows it.
-        In the mirror view, rightward operations correspond to leftward operations in the base view.
-        What is rightmost in the base view becomes leftmost in the mirror view, and vice versa.
-      </p>
-
-      <p>
-        In the Python API, mirror view forms are exposed as explicit left methods, such as <RT-code>ls()</RT-code> for <RT-code>Ls</RT-code> and <RT-code>lsR()</RT-code> for <RT-code>LsR</RT-code>.
-      </p>
-
-      <h1>Entanglement and safety</h1>
-
-      <p>
-        Tape machines that share a tape are said to be <RT-neologism>entangled</RT-neologism>.
-        There are both data hazards and control hazards among entangled machines.
-        Data hazards relate to unexpected writes and reads and can lead to incorrect results.
-        Control hazards can break machines.
-        The primary control hazard is one machine deleting a cell that another machine is visiting, which violates
-        <em>a tape machine head is always on a valid cell</em>.
-      </p>
-
-      <p>
-        Entanglement policy is encoded in the machine name:
-      </p>
-
-      <ul>
-        <li><RT-code>ND</RT-code> non destructive. No structural deletion or insertion exists on the interface, so entangled machines cannot break each other.</li>
-        <li><RT-code>SO</RT-code> solitary. The interface has structural mutation, but no entanglement operations exist, so machines do not share tapes.</li>
-        <li><RT-code>EA</RT-code> entanglement accounting. Structural mutation and entanglement exist, and caller code uses guard predicates to avoid control hazards.</li>
-      </ul>
-
-      <h1>Usage patterns</h1>
-
-      <h2>First Rest pattern with initialization</h2>
-
-      <RT-code>
-        # Pattern 1: First Rest (Initialize with First)
-        # Useful when the accumulator starts with the first value.
-        total = tm.r()      # Process First
-        while not tm.qR():  # Guard: Is there a Rest?
-          tm.s()            # Step (Protected)
-          total += tm.r()   # Process Next
-      </RT-code>
-
-      <h2>First Rest pattern without initialization</h2>
-
-      <RT-code>
-        while True:
-          total += tm.r()
-          if tm.qR(): break
-          tm.s()
-      </RT-code>
-
-      <h1>Composite machines</h1>
-
-      <h2>Region Machine</h2>
-
-      <p>
-        A <RT-term>Region Machine</RT-term> is a composite built from three entangled tape machines.
-        It enforces the invariant that the active head stays within a specified closed interval of the tape.
-      </p>
-
-      <ul>
-        <li><strong>Left boundary machine</strong>: marks the leftmost valid cell of the region.</li>
-        <li><strong>Right boundary machine</strong>: marks the rightmost valid cell of the region.</li>
-        <li><strong>Active machine</strong>: the interface exposed to caller code.</li>
-      </ul>
-
-      <p>
-        In the command language, the active head is on the left boundary iff <RT-code>LqR</RT-code> is true in the active view.
-        In the Python API, that corresponds to an explicit left query helper, or to a predicate that tests whether two entangled heads are on the same cell.
-      </p>
-
-      <h2>TM workspace functions</h2>
-
-      <p>
-        The <RT-code>TM_workspace</RT-code> namespace contains higher level functions that coordinate multiple machines.
-        These functions are not part of the core TM interface.
-      </p>
-
-      <h1>Second order machine</h1>
-
-      <p>
-        A <RT-term>second order</RT-term> TM, <RT-code>TMS</RT-code> (Tape Machine Status), is a wrapper that manages the lifecycle of a first order TM.
-        It introduces explicit <RT-term>status</RT-term> values to represent conditions that violate first order invariants, such as emptiness.
-      </p>
-
-            <script src="style/style_orchestrator.js"></script>
-      <script>
-        window.StyleRT.style_orchestrator();
-      </script>
-
-    </RT-article>
-  </body>
-</html>