A Logic for Expressing Log-Precision Transformers
William Merrill, Ashish Sabharwal
Abstract
One way to interpret the reasoning power of transformer-based language models is to describe the types of logical rules they can resolve over some input text. Recently, Chiang et al. (2023) showed that finite-precision transformer classifiers can be equivalently expressed in a generalization of first-order logic. However, finite-precision transformers are a weak transformer variant because, as we show, a single head can only attend to a constant number of tokens and, in particular, cannot represent uniform attention. Since attending broadly is a core capability for transformers, we ask whether a minimally more expressive model that can attend universally can also be characterized in logic. To this end, we analyze transformers whose forward pass is computed in log n precision on contexts of length n. We prove any log-precision transformer classifier can be equivalently expressed as a first-order logic sentence that, in addition to standard universal and existential quantifiers, may also contain majority-vote quantifiers. This is the tightest known upper bound and first logical characterization of log-precision transformers. Any log-precision transformer can be re-expressed as a sentence in FO(M) logic, e.g.: Mi. a(i) ∧ Mj. b(j) ∧ ¬∃k, ℓ. (a(k) ∧ b(ℓ) ∧ ℓ < k) (m a's followed by m b's, i.e., a m b m ) aaaabbbb ✓ aaabbbbb ✗ baaaabbb ✗ Figure 1: A first-order logic with majority (FO(M)) sentence for a m b m . In addition to standard ∀ and ∃ quantifiers over string indices, FO(M) allows majority quantifiers (M) that take a majority-vote across indices. a(i) indicates whether token i is a (and analogously for b). We prove FO(M) can express any function computed by a log-precision transformer.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
37 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- The Expressive Power of Transformers with Chain of Thought cites Transformers Learn Shortcuts to Automata
- The Expressive Power of Transformers with Chain of Thought cites Tighter Bounds on the Expressivity of Transformer Encoders
- The Expressive Power of Transformers with Chain of Thought cites On Layer Normalization in the Transformer Architecture
- The Expressive Power of Transformers with Chain of Thought cites Faith and Fate: Limits of Transformers on Compositionality
- Chain of Thought Empowers Transformers to Solve Inherently Serial Problems cites Transformers Learn Shortcuts to Automata
- Chain of Thought Empowers Transformers to Solve Inherently Serial Problems cites Tighter Bounds on the Expressivity of Transformer Encoders
- Chain of Thought Empowers Transformers to Solve Inherently Serial Problems cites On Layer Normalization in the Transformer Architecture
- Transformers Learn Shortcuts to Automata cites On the Ability and Limitations of Transformers to Recognize Formal Languages
- The Illusion of State in State-Space Models cites The Expressive Power of Transformers with Chain of Thought
- The Illusion of State in State-Space Models cites Transformers Learn Shortcuts to Automata
- The Illusion of State in State-Space Models cites Tighter Bounds on the Expressivity of Transformer Encoders
- Understanding Transformer Reasoning Capabilities via Graph Algorithms cites The Expressive Power of Transformers with Chain of Thought
- Understanding Transformer Reasoning Capabilities via Graph Algorithms cites Transformers Learn Shortcuts to Automata
- Understanding Transformer Reasoning Capabilities via Graph Algorithms cites Language Models are Few-Shot Learners
- Tighter Bounds on the Expressivity of Transformer Encoders cites On the Ability and Limitations of Transformers to Recognize Formal Languages
- Faith and Fate: Limits of Transformers on Compositionality cites Transformers Learn Shortcuts to Automata
- Faith and Fate: Limits of Transformers on Compositionality cites Language Models are Few-Shot Learners
- Faith and Fate: Limits of Transformers on Compositionality cites Tighter Bounds on the Expressivity of Transformer Encoders
Cited by top-tier papers37
- Faith and Fate: Limits of Transformers on CompositionalityNouha Dziri, Ximing Lu, Melanie Sclar, Xiang Lorraine Li et al.NeurIPS 2023 · 728 citations
- Chain of Thought Empowers Transformers to Solve Inherently Serial ProblemsZhiyuan Liu, Hong Liu, Denny Zhou, Tengyu MaICLR 2024 · 259 citations
- The Expressive Power of Transformers with Chain of ThoughtWilliam Merrill, Ashish SabharwalICLR 2024 · 243 citations
- The Illusion of State in State-Space ModelsWilliam Merrill, Jackson Petty, Ashish SabharwalICML 2024 · 157 citations
- Understanding Transformer Reasoning Capabilities via Graph AlgorithmsClayton Sanford, Bahare Fatemi, Ethan Hall, Anton Tsitsulin et al.NeurIPS 2024 · 84 citations
Builds on6
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- On Layer Normalization in the Transformer ArchitectureRuibin Xiong, Yunchang Yang, Di He, Kai Zheng et al.ICML 2020 · 1,388 citations
- Tighter Bounds on the Expressivity of Transformer EncodersDavid Chiang, Peter Cholak, Anand PillayICML 2023 · 80 citations
- Transformers Learn Shortcuts to AutomataBingbin Liu, Jordan T. Ash, Surbhi Goel, Akshay Krishnamurthy et al.ICLR 2023 · 11 citations
- On the Ability and Limitations of Transformers to Recognize Formal LanguagesSatwik Bhattamishra, Kabir Ahuja, Navin GoyalEMNLP 2020 · 7 citations
Related papers
- Characterizing the Expressivity of Fixed-Precision Transformer Language ModelsJiaoda Li, Ryan CotterellNeurIPS 2025 · 18 citations
- Characterizing the Expressivity of Local Attention in TransformersJiaoda Li, Ryan CotterellACL 2026 · 2 citations
- Revisiting Padded Transformer Expressivity: Which Architectural Choices Matter and Which Don'tAnej Svete, William Merrill, Ryan Cotterell, Ashish SabharwalICML 2026 · 3 citations
- Expressive Power of Graph Transformers via LogicVeeti Ahvonen, Maurice Funk, Damian Heiman, Antti Kuusisto et al.AAAI 2026
- Not all quantifiers are equal: Probing Transformer-based language models' understanding of generalised quantifiersTharindu Madusanka, Iqra Zahid, Hao Li, Ian Pratt-Hartmann et al.EMNLP 2023 · 2 citations
