Introduction
The meteoric rise of Transformer architectures has predominantly been analyzed through the lens of Natural Language Processing (NLP). In this context, theoretical research typically treats the input as a sequence of discrete tokens from a finite alphabet—essentially a string. However, Transformers are increasingly applied to "data sequences" in domains such as finance, meteorology, and sensor monitoring. In these applications, the input consists of arbitrary numerical values where the magnitude and arithmetic relationships between elements are as important as their order.
This paper investigates the expressive power of Transformers when operating over these infinite numerical alphabets. By shifting the focus from strings to data sequences, the authors demonstrate that the architecture gains significant computational capabilities, moving beyond the limitations previously established in string-based theoretical models.
The Unique Hard Attention Transformer (UHAT)
The study focuses on the Unique Hard Attention Transformer (UHAT). Unlike the standard Softmax attention which distributes weights across multiple positions, the UHAT employs a "hard" selection mechanism. For any given query, the model identifies exactly one position in the sequence that maximizes the attention score. This simplification allows for a rigorous mathematical analysis using circuit complexity and formal logic.
From $AC^0$ to $TC^0$: A Complexity Jump
One of the most striking findings of this research is the jump in circuit complexity. In the realm of string processing, UHATs are known to be contained within the complexity class $AC^0$ (constant-depth circuits with AND, OR, and NOT gates). A well-known limitation of $AC^0$ is its inability to perform basic counting—for instance, determining if the number of '1's in a bitstring is even or odd (the Parity problem).
However, when the Transformer is allowed to process numerical data, its power expands to the class $TC^0$. This class includes "majority" gates, which are capable of counting and performing more complex arithmetic. The authors show that by leveraging the numerical values in the input, the UHAT can "encode" counts and other aggregate information that is impossible to represent in a purely symbolic, finite-alphabet setting. This proves that numerical Transformers are strictly more powerful than their text-processing counterparts.
Formal Logic and $(LT)^2L$
To bridge the gap between neural architectures and human-understandable rules, the authors introduce a new logical framework: Locally Testable LTL ($(LT)^2L$). This is an extension of Linear Temporal Logic (LTL) that incorporates linear rational arithmetic and unary numerical predicates.
This logic allows for the description of complex temporal patterns based on numerical thresholds, such as "the current value is greater than the average of the previous window." The paper proves that UHATs can recognize any language definable within this $(LT)^2L$ logic, providing a formal language for the types of patterns these models can detect in time-series data.
Breaking the Regular Language Barrier
In traditional formal language theory, "regular languages" represent the simplest class of patterns, recognizable by finite automata. Previous work suggested that Transformers without positional encodings are largely restricted to a subset of regular languages.
This paper shatters that assumption for data sequences. The authors demonstrate that a masked UHAT, even without positional encoding, can recognize non-regular properties. For example, it can identify sequences where every number is more than twice the previous number (the Double language). This ability to handle non-regular patterns stems directly from the model's capacity to perform affine transformations (multiplication and addition) on the input values.
Key Theoretical Results
The paper establishes three foundational theorems:
- Complexity Bound: UHAT over data sequences is contained in $TC^0$ but resides outside of $AC^0$. This confirms a strict increase in power when moving to numerical data.
- Non-Regularity: There exist non-regular languages over infinite numerical alphabets that a masked UHAT can recognize without any positional encoding.
- Logical Expressivity: UHAT can capture the full range of properties definable in the $(LT)^2L$ logic, including linear recurrence sequences and moving averages.
Conclusion and Future Directions
This research highlights that the "data type" of the input is not just a preprocessing detail but a fundamental determinant of a model's expressive power. By treating inputs as numbers rather than symbols, Transformers unlock a higher tier of computational complexity.
While this work focuses on Hard Attention, it opens several avenues for future study. The most pressing question is whether "Soft" (Softmax) attention provides even greater power or if it remains within the same complexity bounds. Additionally, while $(LT)^2L$ provides a strong lower bound for what UHAT can do, a complete logical characterization—an "if and only if" relationship—remains an open challenge for the community.
Summary updated