Abstract
Recent empirical success in Large Language Models (LLMs) has demonstrated that a single pre-trained model can perform a vast array of tasks through prompting. This paper, presented at ICLR 2025, provides the first rigorous theoretical proof that a single, finite-size Transformer is Turing-complete when guided by prompts. By utilizing Chain-of-Thought (CoT) as a dynamic working memory, the authors show that a fixed set of weights can be "programmed" to execute any computable function with near-optimal efficiency.
Introduction
In the traditional machine learning paradigm, architectures were typically designed for specific tasks—one model for translation, another for classification. Theoretical work followed this trend, proving that for any given computable function, there exists some Transformer architecture capable of approximating it. However, modern AI operates under a "one-model-many-tasks" paradigm: a single, frozen model (such as GPT-4) handles diverse operations based solely on the input prompt.
This shift raises a fundamental question: Is a single, finite-size Transformer actually a universal computer? Or are there inherent limits to what one fixed set of weights can achieve? This research bridges the gap between empirical observation and theoretical foundation, proving that prompting is not just a heuristic, but a Turing-complete programming method.
The 2-PTM Framework
To prove universality, the authors avoid the complexity of mapping a standard Turing Machine (TM) directly to a Transformer. Instead, they introduce an intermediary computational model: the Two-tape Post-Turing Machine (2-PTM).
A 2-PTM is an imperative model featuring:
- Two bi-infinite tapes: Used for data storage and manipulation.
- A simple instruction set: Commands such as moving the head (left/right), writing symbols (0/1), and conditional branching.
The researchers prove that 2-PTMs are Turing-complete and can simulate standard TMs with minimal overhead. This intermediary step allows for a more straightforward construction of the "Universal Transformer."
Constructing the Universal Transformer
The core of the proof lies in the construction of a specific decoder-only Transformer, denoted as $\Gamma$. This model uses standard components: ReLU activations, Layer Normalization, and causal attention.
Prompting as Programming
In this framework, the prompt $\pi_\phi$ acts as the "software." It encodes the specific instructions of a 2-PTM designed to compute a function $\phi$. When the Transformer $\Gamma$ receives this prompt along with an input $x$, it begins executing the encoded instructions. This demonstrates that a prompt is not merely context, but a program that configures the fixed hardware of the Transformer weights.
Chain-of-Thought as Memory
A critical insight of the paper is the role of Chain-of-Thought (CoT). Because a Transformer's weights are fixed during inference, it cannot store new information within its parameters. Instead, it uses the generated output tokens (the CoT) as its "tape" or working memory. Each step of the computation is recorded in the context, allowing the model to maintain and update its state across arbitrarily long sequences. This confirms that CoT is a mathematical necessity for achieving Turing completeness in finite-size models, providing the mechanism to store and update state.
Efficiency and Precision
The authors establish that this prompting paradigm is remarkably efficient, incurring only a logarithmic slowdown compared to multi-tape Turing Machines:
- Time Complexity: A function requiring $t(n)$ steps on a standard TM can be computed by the prompted Transformer in $O(t(n) \log t(n))$ CoT steps.
- Precision: The model only requires $O(\log(n + t(n)))$ bits of precision. This suggests that even with the finite numerical resolution inherent in digital hardware, the model can decide any language in the complexity class P.
Discussion and Limitations
While this work provides a landmark proof for the expressivity of Transformers, it relies on several theoretical abstractions:
- Hardmax Attention: The proof utilizes "hardmax" (selecting the maximum value) rather than the "softmax" function used in real-world models. Bridging this gap remains a subject for future research.
- Context Window: The construction assumes an unbounded context window to act as the TM tape. In reality, LLMs have finite context limits, which would technically restrict them to being Linear Bounded Automata rather than full Turing Machines.
- Expressivity vs. Learnability: The paper proves that a universal Transformer exists, but it does not guarantee that standard training objectives (like next-token prediction on internet text) will naturally produce such a model. Investigating the "learnability" of these universal prompts is a key next step.
Conclusion
By proving the Turing completeness of prompting, this research formalizes the intuition that LLMs are more than just statistical mimics; they are programmable engines. This foundation opens new avenues for understanding how prompts function as code and how the "Chain-of-Thought" serves as the essential bridge between static weights and dynamic computation.
Summary updated