Lune

NeurIPS2024Top-tier venue

Masked Hard-Attention Transformers Recognize Exactly the Star-Free Languages

Andy Yang, David Chiang, Dana Angluin

Abstract

The expressive power of transformers over inputs of unbounded size can be studied through their ability to recognize classes of formal languages. In this paper, we establish exact characterizations of transformers with hard attention (in which all attention is focused on exactly one position) and attention masking (in which each position only attends to positions on one side). With strict masking (each position cannot attend to itself) and without position embeddings, these transformers are expressively equivalent to linear temporal logic (LTL), which defines exactly the star-free languages. A key technique is the use of Boolean RASP as a convenient intermediate language between transformers and LTL. We then take numerous results known for LTL and apply them to transformers, showing how position embeddings, strict masking, and depth all increase expressive power.

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.

25 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Characterizing the Expressivity of Fixed-Precision Transformer Language Models cites The Expressive Power of Transformers with Chain of Thought
  • Characterizing the Expressivity of Fixed-Precision Transformer Language Models cites Logical Languages Accepted by Transformer Encoders with Hard Attention
  • Characterizing the Expressivity of Fixed-Precision Transformer Language Models cites Tighter Bounds on the Expressivity of Transformer Encoders
  • Constant Bit-size Transformers Are Turing Complete cites The Expressive Power of Transformers with Chain of Thought
  • The Expressive Power of Transformers with Chain of Thought cites Tighter Bounds on the Expressivity of Transformer Encoders
  • Exact Expressive Power of Transformers with Padding cites The Expressive Power of Transformers with Chain of Thought
  • Exact Expressive Power of Transformers with Padding cites Tighter Bounds on the Expressivity of Transformer Encoders
  • Logical Languages Accepted by Transformer Encoders with Hard Attention cites Thinking Like Transformers
  • Logical Languages Accepted by Transformer Encoders with Hard Attention cites Tighter Bounds on the Expressivity of Transformer Encoders
  • Benefits and Limitations of Communication in Multi-Agent Reasoning cites The Expressive Power of Transformers with Chain of Thought
  • Learning Transformer Programs cites Thinking Like Transformers
  • Tighter Bounds on the Expressivity of Transformer Encoders cites Thinking Like Transformers
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers25

  1. Constant Bit-size Transformers Are Turing CompleteQian Li, Yuyi WangNeurIPS 2025 · 21 citations
  2. Exact Expressive Power of Transformers with PaddingWilliam Merrill, Ashish SabharwalNeurIPS 2025 · 21 citations
  3. Characterizing the Expressivity of Fixed-Precision Transformer Language ModelsJiaoda Li, Ryan CotterellNeurIPS 2025 · 18 citations
  4. Type-Constrained Code Generation with Language ModelsNiels Mündler, Jingxuan He, Hao Wang, Koushik Sen et al.PLDI 2025 · 10 citations
  5. Benefits and Limitations of Communication in Multi-Agent ReasoningMichael Rizvi-Martel, Satwik Bhattamishra, Neil Rathi, Guillaume Rabusseau et al.ICLR 2026 · 9 citations

Builds on10

  1. The Expressive Power of Transformers with Chain of ThoughtWilliam Merrill, Ashish SabharwalICLR 2024 · 243 citations
  2. Thinking Like TransformersGail Weiss, Yoav Goldberg, Eran YahavICML 2021 · 183 citations
  3. Tighter Bounds on the Expressivity of Transformer EncodersDavid Chiang, Peter Cholak, Anand PillayICML 2023 · 80 citations
  4. Learning Transformer ProgramsDan Friedman, Alexander Wettig, Danqi ChenNeurIPS 2023 · 59 citations
  5. Logical Languages Accepted by Transformer Encoders with Hard AttentionPablo Barceló, Alexander Kozachinskiy, Anthony Widjaja Lin, Vladimir V. PodolskiiICLR 2024 · 36 citations

Related papers

  1. The Power of Hard Attention Transformers on Data Sequences: A formal language theoretic perspectivePascal Bergsträßer, Chris Köcher, Anthony Widjaja Lin, Georg ZetzscheNeurIPS 2024 · 7 citations
  2. Knee-Deep in C-RASP: A Transformer Depth HierarchyAndy Yang, Michaël Cadilhac, David ChiangNeurIPS 2025 · 15 citations
  3. On the Expressiveness of State Space Models via Temporal LogicsEric Alsmann, Lowejatan Noori, Martin LangeICLR 2026 · 2 citations
  4. Characterizing the Expressivity of Local Attention in TransformersJiaoda Li, Ryan CotterellACL 2026 · 2 citations
  5. Transformers are Inherently SuccinctPascal Bergsträßer, Ryan Cotterell, Anthony W. LinICLR 2026 · 5 citations
Dusk over the sea between two cliffs drawn in fine vertical lines