Ask, and it shall be given: On the Turing completeness of prompting

Ruizhong Qiu, Zhe Xu, Wenxuan Bao, Hanghang Tong

Introduction: The "One-Model-Many-Tasks" Paradigm

In the modern era of generative AI, machine learning operates largely under a "one-model-many-tasks" paradigm. We train a single, massive Large Language Model (LLM) and use different text prompts to make it perform entirely different tasks—from translation and coding to complex mathematical reasoning.

However, existing theoretical studies on the computational power of Transformers have mostly focused on the classic "one-model-one-task" paradigm, analyzing what specific, custom-built Transformers can achieve. This leaves a massive theoretical gap: fundamentally, how powerful is the act of prompting a single, general-purpose model? Can one finite-size Transformer truly be universal, or are there hard limits to what prompt engineering can achieve? This paper establishes the mathematical underpinning for the empirical success of prompting, providing the first theoretical proof that the LLM prompting paradigm is Turing-complete.

Methodology: Bridging Turing Machines and Transformers

This research is a purely theoretical computer science paper based on constructive mathematical proofs. To prove that prompting is Turing-complete, the authors demonstrate that a single Transformer can simulate any Turing Machine (TM) through four main steps:

  1. A New Computational Model (2-PTMs): Standard Turing Machines have an unbounded number of states and tapes, making them incredibly difficult to encode into a finite prompt alphabet. To solve this, the authors invent 2-tape Post-Turing machines (2-PTMs). This model uses a finite set of simple imperative instructions (e.g., move left, write 1, go-to) operating over two bi-infinite tapes.
  2. Prompt Encoding: Because 2-PTMs use a finite instruction set, any computable function can be translated into a 2-PTM program. This program is then easily encoded into a finite text string, which serves as the prompt.
  3. Transformer Construction: The authors mathematically construct a specific, finite-size, decoder-only Transformer utilizing ReLU activations, layer normalization, and hardmax causal attention. This Transformer acts as an "interpreter" that reads the 2-PTM prompt and executes it step-by-step.
  4. Chain-of-Thought (CoT) as Memory: To execute the program, the Transformer uses CoT generation as a scratchpad. It generates tokens that record the current execution state (the current instruction, tape head positions, and cell values), effectively using the generated text as the working "tape" of the Turing machine.

Key Insights and Theoretical Results

The paper's constructive proofs yield several profound insights into the nature of LLMs and prompt engineering:

  • Prompting is Universally Powerful (Theorem 3.1): You do not need an infinite family of different Transformers to compute all computable functions. A single, finite-size model with fixed weights is sufficient, provided it receives the right prompt and utilizes autoregressive CoT generation.
  • CoT is the Engine of Universality: It is already known that Transformers without Chain-of-Thought are strictly limited in what they can compute. This paper reinforces that CoT is what elevates a Transformer to Turing completeness, allowing the context window to act as an unbounded working memory.
  • Remarkable Efficiency: One might expect that forcing a single model to simulate any program via text prompts would be incredibly inefficient. Surprisingly, the authors prove that their single Transformer achieves nearly the same complexity bounds as the theoretical class of all unbounded-size Transformers. Specifically, it can compute any function that takes $\mathcal{O}(t(n))$ time on a standard Turing Machine using $\mathcal{O}(t(n) \log t(n))$ Chain-of-Thought steps—representing only a logarithmic slowdown.
  • Precision Complexity: The model requires only $\mathcal{O}(\log(n + t(n)))$ bits of numerical precision to process a length-$n$ input. Consequently, it can decide any problem in the complexity class P (polynomial time) using only logarithmic precision.

Limitations and Future Directions

While groundbreaking, the authors are transparent about the theoretical abstractions used in their proofs, which point to exciting future work:

  • Hardmax vs. Softmax: The proof relies on "hardmax" attention to simplify the mathematics, whereas real-world LLMs use softmax attention. Extending the proof to softmax remains a noted limitation.
  • Infinite Context Windows: The construction assumes the Transformer has an unbounded context window to allow for arbitrarily long CoT generation. In practice, real LLMs are constrained by strict memory limits.
  • Expressivity vs. Learnability: This paper proves that a universal Transformer exists. However, it does not prove that standard gradient descent training will actually learn to structure its weights in this universal way. Investigating the learnability of universal simulation is a major next step.
  • CoT Lower Bounds: The construction requires long CoTs for complex problems. Future work will look into establishing tight lower bounds to determine if these lengthy CoTs are strictly necessary for computation.

Summary updated

BibTeX
@inproceedings{qiu2025ask,
  author = {Ruizhong Qiu and Zhe Xu and Wenxuan Bao and Hanghang Tong},
  title = {{Ask, and it shall be given: On the Turing completeness of prompting}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=AS8SPTyBgw},
}
Figure