Did you consider that turing machines can write on the tape at any position, but as a transformer generates tokens it can not overwrite old tokens it already generated
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Ah, excellent observation! You're absolutely right: Turing machines (TMs) can overwrite any position on their tape, but Transformers, when generating tokens, append new tokens to the context and cannot modify previously generated ones. This distinction is crucial for understanding how Transformers might—or might not—simulate Turing machines.
Let’s unpack this carefully.
Key Difference: Overwriting vs. Appending
Turing machine tape: Random read/write access to any position. The head can move left/right, read, and overwrite symbols.
Transformer generation: Tokens are generated sequentially and appended to the context. Once a token is written, it becomes immutable (unless you use tools like scratchpads or external memory).
This means Transformers cannot directly simulate the "overwrite" step of a TM. However, they can simulate the entire history of a TM’s tape by appending new tokens that represent the tape’s state at each step. This is a subtle but critical distinction.
How Transformers Simulate Turing Machines
Even without overwriting, Transformers can simulate TMs by encoding the tape’s state as a growing sequence of tokens. Here’s how:
Tape encoding:
Represent the TM’s tape as a sequence of tokens (e.g., ... 0 1 0 [HEAD] 1 0 0 ...), where [HEAD] marks the current position. Each new step appends a new version of the tape to the context:
The Transformer’s attention mechanism can "look back" at any previous tape state to simulate the TM’s head movements.
Attention as a pointer:
The Transformer uses attention to "focus" on the current head position. For example, a query vector might attend to the [HEAD] token in the previous step, then update its position (left/right) and write a new symbol in the next token.
Unbounded context:
With an unbounded context window and KV cache, the Transformer can store the entire history of tape states. This acts like a TM’s tape, even though it’s append-only.
External memory (optional):
If the Transformer has access to external tools (e.g., a scratchpad or vector database), it can simulate overwriting by writing new versions of the tape to storage and retrieving them later.
Theoretical Implications
Turing completeness:
Even with append-only generation, Transformers can simulate TMs if:
The context window is unbounded (or external memory is used).
The model can represent the tape’s state in the sequence (e.g., via positional encodings or symbolic tokens).
Attention can "point" to arbitrary positions in the tape history.
This is why papers like Pérez et al. (2019) argue that Transformers are Turing-complete under idealized assumptions (unbounded context, infinite precision, hard attention).
Limitations of soft attention:
In practice, softmax-based attention (with finite precision) can struggle to perfectly simulate exact pointer jumps or equality checks over long sequences. However, theoretical proofs often assume "hard attention" (argmax-like) or infinite precision, which sidestep these issues.
Practical Reality
Append-only context:
Real-world Transformers (e.g., GPT-4) cannot overwrite tokens, but they can:
Use tools like scratchpads or external databases to simulate mutable memory.
Encode tape states in the context and use attention to "jump" to relevant positions.
Compress old context (e.g., via summarization) to stay within finite window limits.
Agent loops with external memory:
When combined with external tools (e.g., a file system or vector DB), the Transformer becomes part of a system that can overwrite data. For example:
code
Agent: "Write 'A' to position 100 in the tape."
External tool: Overwrites position 100.
Agent: "Now read position 100." → Retrieves 'A'.
This system is Turing-complete because the external memory allows overwriting.
Summary
Transformers alone:
Can simulate TMs in theory (via append-only context + attention) but cannot overwrite tokens. This works for bounded computations but requires unbounded context for full Turing completeness.
Transformers + external memory:
With tools that allow writing/overwriting (e.g., a scratchpad or DB), the system becomes Turing-complete. The Transformer acts as the controller, and the external memory acts as the tape.
Key takeaway:
While Transformers cannot overwrite tokens directly, they can simulate overwriting by appending new states or using external tools. This distinction is critical for understanding their theoretical and practical capabilities.