Tighter Bounds on the Expressivity of Transformer Encoders
David ChiangPeter CholakAnand Pillay
Establishes tight expressivity bounds for transformer encoders by proving that a specific variant of first-order logic with counting quantifiers acts simultaneously as an upper bound for fixed-precision encoders and a lower bound for standard encoders.
Modern natural language processing relies heavily on transformer neural networks, yet theoretical understanding of what these architectures can and cannot compute remains incomplete. Prior research established broad outer bounds, showing that transformer encoders can simulate simple counting mechanisms while being constrained within general circuit complexity classes. However, these boundaries left a significant gap, making it difficult for researchers and practitioners to predict the fundamental capabilities and algorithmic limitations of transformer-based systems.
The article establishes tight, counterbalance mathematical bounds on the expressivity of transformer encoders by mapping their computing capabilities directly to a specific formal system: first-order logic with counting quantifiers and modular position predicates, designated as FOC[+; MOD]. The authors demonstrate that this logic serves simultaneously as an upper bound for practical, fixed-precision transformer encoders and as a lower bound for general transformer encoders.
To establish these bounds, the authors employed formal mathematical and theoretical computer science methods. They proved a normal form theorem for FOC[+; MOD] that separates position properties from arithmetic counts. For the upper bound, they simulated the components of fixed-precision transformers—such as word embeddings, periodic positional encodings, feed-forward networks, and self-attention averaging—directly within the logic. For the lower bound, they constructed explicit transformer encoders with rational weights that evaluate positional predicates, aggregate occurrences using uniform self-attention, and verify linear constraints via feed-forward layers, extending the proof to accommodate standard layer normalization.
The analysis yielded three core findings. First, practical fixed-precision transformer encoders are strictly bounded by FOC[+; MOD], demonstrating that they are less powerful than previously conjectured and cannot recognize certain structured patterns (such as strings of identical counts of zeros followed by ones). Second, standard transformer encoders can express any property formulable in FOC[+; MOD], proving that this logic contains no non-transformer-like behavior. Third, this logical framework strictly refines prior work, providing a strictly tighter upper bound than general circuit complexity classes (uniform TC0) and a strictly tighter lower bound than simplified stateless counter machines.
These findings imply that transformer encoders excel primarily at computing global aggregate counts and periodic positional patterns, but they possess inherent structural limitations when resolving strict sequential orderings without causal masking or specialized positional mechanisms. For engineering and AI architecture teams, this formalization clarifies which sequence-processing tasks can be reliably solved by standard transformer encoders without requiring empirical trial-and-error, thereby mitigating the risk of misapplying standard encoders to fundamentally incompatible tasks.
Moving forward, researchers and system designers should investigate architectural extensions—such as relative or rational-position representations (e.g., position-to-length ratios)—that bridge the gap between counting and sequential order. Furthermore, research should focus on obtaining an exact, complete characterization of unrestricted rational-weight transformers and extending this formal logical framework to include causal masking and full encoder-decoder architectures.
These conclusions are established with high theoretical confidence under explicit formal conditions: the upper bound assumes fixed-precision numerical representations with bounded activations, while the lower bound assumes rational-frequency positional encodings and rational network weights. Readers should exercise caution when extrapolating these results to generative autoregressive decoders or multi-step reasoning systems, as unmasked encoders represent single-step classification capabilities rather than iterative computation.
- Paper: Attention Is All You Need, Ashish Vaswani et al. (2017). Introduces the foundational self-attention and Transformer encoder architecture whose theoretical expressivity and circuit complexity bounds are characterized in the source.
- Paper: Deep Sets, Manzil Zaheer et al. (2017). Provides the foundational theoretical framework for permutation-equivariant and permutation-invariant operations on sets that underlies formal analysis of attention mechanisms.
- Paper: The Topological Trouble With Transformers, Michael C. Mozer et al. (2026). Investigates how the expressivity constraints of feedforward Transformer encoders manifest as topological state-tracking limitations over multi-step tasks.
- Paper: Fixed-Point Reasoners: Stable and Adaptive Deep Looped Transformers, Sajad Movahedi et al. (2026). Extends standard bounded-depth Transformer expressivity to arbitrary multi-step reasoning by incorporating adaptive looping and fixed-point state iterations.
