From: Thomas Walker Lynch Date: Wed, 4 Feb 2026 17:08:46 +0000 (+0000) Subject: doc X-Git-Url: https://git.reasoningtechnology.com/sitemap.xml?a=commitdiff_plain;h=aec21335a3b0cdeeb31d754ca247236228102b13;p=Epimetheus%2F.git doc --- diff --git a/document/TM.html b/document/TM.html index a5a3d9e..4bd3978 100644 --- a/document/TM.html +++ b/document/TM.html @@ -23,7 +23,7 @@

Introduction

- A Tape Machine (TM) is an abstract mechanism for the manipulation of data found in sequences. Such sequences include lists, arrays, sets according to an ordering function, and maps also against an ordering function. Also included are linear traversals of more complex data structures. TM is discussed in detail in the TTCA book. + A Tape Machine (TM) is used to manipulation data found in a sequences. Such sequences include lists, arrays, sets according to an ordering function, and maps also against an ordering function. Also included are linear traversals of more complex data structures. TM is discussed in detail in the TTCA book.

@@ -31,7 +31,7 @@

- Thus each TM type has the nice property of encompassing both data and pointers within one structure. + Thus each TM type has the nice property of encompassing both data and pointers into that data within one structure.

@@ -45,60 +45,50 @@

When multiple machines share the same tape, we say the machines are entangled. For analysis to remain first order, when machines are entangled, we must be careful with destructive operations. There are multiple approaches to this, each corresponding to a different type of first order TM. One approach is the TM_ND which has no tape structure modifying operations. Another approach is the TM_SOLO which does not allow more than one machine on its tape. Yet another approach is the TM_EA, where EA means 'entanglement accounting'. With entanglement accounting all the machines that share a tape also share the catalog of entangled machines. Each destructive operation then checks the listed machines and their head positions to assure that no machine is structurally broken by the operation. - For example, before deleting a cell, a machine checks that no machine has a head on the specified cell, and thus would become orphaned by the operation. + For example, before deleting a cell, a machine checks that no machine has a head on the specified cell, and thus would become orphaned when the cell is removed from the tape.

-

Command reference (ND-TM)

+

Command reference for the ND-TM

- The following commands are available for the Non-Destructive First Order Machine. The notation uses strictly ASCII characters. + The following commands are available for the Nondestructive First Order Machine. In this version the notation uses strictly ASCII characters.

-

Grammar

+

The grammar

-statement :: [location]command+[quantifier]*[&contract]*[arg]* -location :: l | L | R | ε +statement :: [location]command+[quantifier]*[arg]* +location :: l | L | R default is right cell command :: r | w | s | q | e -quantifier :: A | R | n -contract :: hL | hR +quantifier :: A | R | n default n is one, default A is the head position -

Definitions

+

The definitions

-

Location

+

The location

-

Command

+

The commands

-

Quantifier

+

The quantifiers

-

Contracts

-

- Contracts assert the state of the machine before execution. -

- - -

Examples

+

The examples

ls ; Step to left neighbor @@ -107,56 +97,56 @@ Rs ; Cue Rightmost (Go to last index) qA ; Query Address (What is the head index?) -

Primitive method reference

+

The primitive method reference

This section details the actual methods exposed by the First Order TM implementation (Python/C). These primitives map directly to the command language.

-

Navigation primitives

+

The navigation primitives

-

I/O primitives

+

The input and output primitives

-

Query primitives

+

The query primitives

Introspection commands used to check machine state without side effects.

-

Entanglement primitives

+

The entanglement primitives

-

Usage

+

The usage

-

First order TM properties

+

The first order TM properties

For a first order TM these properties are always true. @@ -172,7 +162,7 @@ qA ; Query Address (What is the head index?) the interval, and on an entangled machine on the rightmost cell of the interval.

-

Contract with the programmer

+

The contract with the programmer

Some first order TM types rely upon the programmer to maintain a contract in order to maintain the first order TM properties. Such machines typically have debug variants that add contract checks. For some machines breaking the contract can limit the ability of the compiler to optimize code, for other machines breaking the contract can lead diff --git a/document/TM0.html b/document/TM0.html deleted file mode 100644 index 8dbd43f..0000000 --- a/document/TM0.html +++ /dev/null @@ -1,212 +0,0 @@ - - - - - TM First Order - - - - - - - - - - - - -

Introduction

- -

- The First Order Tape Machine (TM) is a high-performance mechanism for navigating and manipulating data sequences. -

- -

- If you are coming from standard programming, you are likely used to arrays (which just sit there) or iterators (which disappear after one use). A Tape Machine is different: it is a persistent agent that lives on your data. It has a "head" (a position) that stays where you put it until you tell it to move. -

- -

- Think of it like a cursor in a text editor, but for data. You can read what's under the cursor, overwrite it, move left or right, or even spawn a second cursor ("entangle") to work on the same text at the same time. -

- -

The First-Rest Pattern

- -

- To use a Tape Machine effectively, you must understand the First-Rest pattern. This is the fundamental way TMs view data recursion and iteration. -

- -

- At any moment, a Tape Machine divides the world into two parts: -

-
    -
  1. First: The single cell currently under the head. This is the "Now."
  2. -
  3. Rest: Everything else to the right of the head. This is the "Future."
  4. -
- -

- The standard processing loop acts on the First item, and then checks if a Rest exists. Crucially, the programmer uses the query qR() (Query Rightmost) to protect the step command s(). If qR() is false, it is safe to step into the Rest. -

- - -# Example: Summing a list using First-Rest -total = tm.r() # Process the "First" -while not tm.qR(): # Guard: Is there a "Rest"? - tm.s() # Safe to step - total += tm.r() # Process the new "First" - - -

Contract with the Programmer

- -

- The Tape Machine is a precision tool. To achieve its speed and safety, it adheres to a strict contract. -

- -

The Machine Guarantees:

- - -

You Guarantee:

- - -

Command Reference

- -

- The Tape Machine is controlled via a formal command language. This section defines the abstract commands available to the machine. The notation uses strictly ASCII characters. -

- -

Grammar

- -statement :: [location]command+[quantifier]*[arg]* -location :: l | L | R | ε -command :: r | w | s | q | e -quantifier :: A | R | n - - -

Definitions

- -

Location

- - -

Command

- - -

Quantifier

- - -

Examples

- - -ls ; Step to left neighbor -Ls ; Cue Leftmost (Go to index 0) -Rs ; Cue Rightmost (Go to last index) -qA ; Query Address (What is the head index?) - - -

Primitive Method Reference

- -

- This section details the actual methods exposed by the First Order TM implementation (Python/C). These primitives map directly to the command language. -

- -

Navigation Primitives

- - -

I/O Primitives

- - -

Query Primitives

-

- Introspection commands used to check machine state without side effects. -

- - -

Entanglement Primitives

- - -

Architecture

- -

Behavior Selection (Flags)

-

- The First Order TM is designed to be flexible. When creating a machine, you can pass a set of Flags to the constructor to select specific behaviors or safety checks. This allows the core machine to remain fast (zero overhead) while providing options for debugging or specialized topologies. -

- - -# Example: Creating a machine with Safety Checks and Debug Messages -tm = TM(data_list, flags={Debug.safe, Debug.message}) - - - - -

Entanglement

-

- A critical feature of the TM is Entanglement. Multiple TMs can operate on the same underlying tape memory simultaneously. -

- -

- To ensure safety, the TM implements an Entanglement Catalog in the C layer. While structural modification (allocation/deletion) is disallowed in the First Order machine, the Catalog remains the system of record for tracking all active heads on a shared tape, providing the foundation for future synchronization primitives. -

- - - - - - diff --git a/document/TM_First_Order.html b/document/TM_First_Order.html deleted file mode 100644 index 5f4c80e..0000000 --- a/document/TM_First_Order.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - - TM First Order - - - - - - - - - - - - -

Introduction

- -

- The First Order Tape Machine (TM) is a fundamental mechanism for sequence manipulation. It is a concrete implementation of the Tape Machine abstraction defined in the TTCA. -

- -

- While modern programming languages offer various containers (Lists, Arrays, Vectors), the First Order TM unifies them under a single interface that emphasizes positional state. Unlike a standard iterator which consumes data, a TM persists. Unlike a raw array which is stateless, a TM maintains a head. -

- -

Command Reference

- -

- The Tape Machine is controlled via a formal command language. This section defines the abstract commands available to the machine. The notation uses strictly ASCII characters. -

- -

Grammar

- -statement :: [direction]command+[modifier][&contract]*[arg]* -direction :: l | ε -command :: r | w | s | a | d | q | m | e | t -modifier :: L | R | A | AR | n - - -

Definitions

- -

Direction

- - -

Abstract Commands

- - -

Modifiers

- - -

Contracts

-

- Contracts assert the state of the machine before execution. -

- - -

Examples

- - -ls ; Step left -aL ; Allocate (create) a new leftmost cell -aR ; Allocate (append) to rightmost -qA ; Query Address (What is the head index?) -qAR ; Query Extent (What is the max index?) - - -

Primitive Method Reference

- -

- This section details the actual methods exposed by the First Order TM implementation (Python/C). These primitives map directly to the command language or provide optimized compound operations. -

- -

Navigation Primitives

- - -

I/O Primitives

- - -

Allocation Primitives

- - -

Deletion Primitives

- - -

Compound Primitives

-

- These methods combine multiple abstract commands into a single atomic C-operation for performance and safety. -

- - -

Query Primitives

-

- Introspection commands used to check machine state without side effects. -

- - -

Entanglement Primitives

- - -

Architecture

- -

The Hybrid Model

-

- For maximum performance in high-frequency loops, the First Order TM is implemented using a Direct Execution architecture. -

- - - -

Entanglement Safety

-

- A critical feature of the TM is Entanglement. Multiple TMs can operate on the same underlying tape memory simultaneously. This is efficient, but dangerous: if one machine deletes a cell that another machine is looking at, the system could crash or corrupt state. -

- -

- To prevent this, the TM implements an Entanglement Catalog in the C layer. -

- - - \text{Safe}(op) \iff \forall \text{peer} \in \text{Catalog}, \text{Head}(\text{peer}) \notin \text{VictimRange}(op) - - -

- Before any destructive operation (like delete), the machine checks the catalog. If any peer's head is currently positioned on a cell scheduled for deletion, the operation is blocked with a RuntimeError. -

- - - -
- - diff --git a/document/TM_first_order.html b/document/TM_first_order.html deleted file mode 100644 index 6706343..0000000 --- a/document/TM_first_order.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - 02 - The First Order Tape Machine - - - - - - - - - - - - -

Introduction

- -

- The First Order Tape Machine (TM) is the foundational mechanism for sequence manipulation. It is a concrete implementation of the Tape Machine abstraction defined in the TTCA. -

- -

- While modern programming languages offer various containers (Lists, Arrays, Vectors), the First Order TM unifies them under a single interface that emphasizes positional state. Unlike a standard iterator which consumes data, a TM persists. Unlike a raw array which is stateless, a TM maintains a head. -

- -

Architecture

- -

The Hybrid Model

-

- For maximum performance in high-frequency loops, the First Order TM is implemented using a Direct Execution architecture. -

- - - -

- This hybrid approach allows the TM to execute simple steps like s() (step right) in nanoseconds, comparable to native pointer arithmetic in compiled languages. -

- -

Entanglement Safety

-

- A critical feature of the Epimetheus TM is Entanglement. Multiple TMs can operate on the same underlying tape memory simultaneously. This is efficient, but dangerous: if one machine deletes a cell that another machine is looking at, the system could crash or corrupt state. -

- -

- To prevent this, the TM implements an Entanglement Catalog in the C layer. -

- - - \text{Safe}(op) \iff \forall \text{peer} \in \text{Catalog}, \text{Head}(\text{peer}) \notin \text{VictimRange}(op) - - -

- Before any destructive operation (like delete), the machine checks the catalog. If any peer's head is currently positioned on a cell scheduled for deletion, the operation is blocked with a RuntimeError. -

- -

Interface

- -

Movement

-

- The TM maintains a Head index. Movement is relative. -

- - - -

Read / Write

-

- Data access occurs at the current head position. -

- - -# Read current cell -val = tm.r() - -# Bulk read next 3 cells -chunk = tm.rn(3) - -# Write to current cell -tm.w(42) - -# Bulk write (overwrite sequence) -tm.wn([10, 20, 30]) - - -

Allocation

-

- New cells can be created at the boundaries. -

- - -

Deletion

-

- Deletion is the only operation restricted by Entanglement Safety. -

- -

Delete Current (d)

-

- d() removes the cell currently under the head. After deletion, the head index remains unchanged, but it now points to the next cell in the sequence (the one that shifted into the slot). -

- -

Delete Neighbor (esd)

-

- esd() (Entangle, Step, Delete) removes the cell immediately to the right of the head. This is the primitive operation for Singly Linked Tapes, but is offered on the First Order TM for symmetry. -

- -

Implementation Detail

- -

The C Module

-

- The C module TM_module.c defines the FastTM struct. -

- - -typedef struct { - PyObject_HEAD - PyObject* tape_obj; /* Shared Python List */ - PyObject* peer_list; /* Shared WeakRef List */ - Py_ssize_t head; /* C-Level Integer */ - PyObject* weakreflist; /* Garbage Collection Support */ -} FastTM; - - -

- By keeping the head as a native C integer Py_ssize_t, arithmetic operations avoid the boxing/unboxing cost of Python Integers. -

- - - -
- -