Summary
This paper provides a formal complexity-theoretic proof that "Chain of Thought" (CoT) prompting is not merely a heuristic trick—it fundamentally expands the computational power of Transformers. By allowing a model to generate intermediate tokens, researchers demonstrate that the number of decoding steps acts as a computational resource. Logarithmic steps offer a slight boost, linear steps enable the simulation of finite-state machines, and polynomial steps make Transformers equivalent to the class of all polynomial-time solvable problems (P).
Introduction
Despite their massive empirical success, standard Transformers suffer from a "depth" problem. Because they process inputs in a fixed number of layers without recurrent connections, they are theoretically unable to solve simple sequential reasoning tasks, such as checking if two nodes in a graph are connected or simulating a basic finite-state machine. In complexity terms, standard Transformers are restricted to a relatively small class called TC⁰.
Practitioners have bypassed this limitation using "Chain of Thought" (CoT) or "scratchpads," where the model writes out its intermediate reasoning. While this works empirically, a rigorous understanding of why and how much it helps has been lacking. This paper asks: Does intermediate generation fundamentally change what a Transformer can compute? Furthermore, how does the length of that "thought" ($t$) relate to standard complexity classes like L (log-space) or P (polynomial time)?
Theoretical Framework & Methods
The authors analyze decoder-only Transformers through the lens of computational complexity. To prove what these models can do (establishing lower bounds), they construct a specific Transformer architecture utilizing a novel mechanism called a layer-norm hash.
The Layer-Norm Hash
Standard attention often struggles to retrieve specific values when keys are scaled by different denominators (a common issue with uniform attention). The authors show that by using "projected pre-norm" (applying a linear projection before layer normalization), a Transformer can create scale-invariant "hashes." This allows the model to use intermediate tokens as a recurrent state, effectively turning the Transformer into a simulator for a Turing Machine.
Formal Assumptions
To make the proofs tractable, the authors assume:
- Saturated Attention: An idealized version of attention where scores are essentially 0 or 1.
- Projected Pre-Norm: A slight generalization of standard layer-norm that allows the model to pick out specific subsets of the hidden state to normalize.
- Log-precision: The model uses a realistic amount of numerical precision (logarithmic relative to the number of steps).
(Note: As a theoretical paper focused on formal proofs, no empirical datasets or training benchmarks were used. Evaluation is performed against formal language classes and complexity classes.)
The Computational Power of CoT
Without CoT, a Transformer is a feed-forward circuit. With CoT, each new token generated becomes part of the context for the next step, creating a "loop" that allows for recurrence. The number of decoding steps $t(n)$ is directly analogous to the "time" allowed for a program to run.
The paper establishes a clear hierarchy based on the number of intermediate steps:
- Constant steps: No better than a standard Transformer (restricted to TC⁰).
- Logarithmic steps ($O(\log n)$): Expands power slightly to the class L, but still cannot solve graph connectivity.
- Linear steps ($O(n)$): Can simulate any finite-state machine and recognize all regular languages.
- Polynomial steps ($O(n^c)$): Reaches the full power of the class P.
Complexity Class Equivalences
The paper's findings are summarized in a central relationship between Transformer CoT steps and Turing Machine complexity:
$$\text{TIME}(t(n)) \subseteq \text{CoT}(t(n)) \subseteq \text{SPACE}(t(n) + \log n)$$
- Linear CoT ($t(n) = \Theta(n)$): These models fall between regular languages (Reg) and context-sensitive languages (CSL). They can solve problems that require "memory" of the entire input string but cannot solve every problem in P.
- Polynomial CoT ($t(n) = \text{poly}(n)$): These models are exactly as powerful as any algorithm that runs in polynomial time. This provides the first exact equivalence between a specific Transformer setup (polynomial CoT steps + projected pre-norm) and a standard complexity class (P). It implies that a Transformer with a long enough scratchpad can, in theory, solve any problem that a traditional computer can solve efficiently.
Limitations and Future Directions
- Expressivity vs. Learnability: The paper proves that these solutions exist within the Transformer's weight space, but it does not guarantee that Gradient Descent can find them. Learning to use a scratchpad effectively remains a separate, difficult challenge.
- Architectural Tweaks: The proofs rely on "projected pre-norm" and "saturated attention." While these are close to what is used in practice, they are not identical. Future work could investigate if standard, non-projected layer-norm provides the exact same power.
- The "Quadratic" Cost: While polynomial steps provide great power, the cost of running a Transformer for $n^2$ steps is computationally massive, suggesting a gap between theoretical possibility and practical efficiency.
Summary updated