mlsanityData to 14 Oct 2026

Logical Languages Accepted by Transformer Encoders with Hard Attention

arXiv 2310.03817 ↗First posted 5 Oct 2023cs.FL cs.LGcited by 38

Not on the map. Why?

Abstract (arXiv)

We contribute to the study of formal languages that can be recognized by transformer encoders. We focus on two self-attention mechanisms: (1) UHAT (Unique Hard Attention Transformers) and (2) AHAT (Average Hard Attention Transformers). UHAT encoders are known to recognize only languages inside the circuit complexity class sf AC0, i.e., accepted by a family of poly-sized and depth-bounded boolean circuits with unbounded fan-ins. On the other hand, AHAT encoders can recognize languages outside sf AC0), but their expressive power still lies within the bigger circuit complexity class sf TC0, i.e., sf AC0-circuits extended by majority gates. We first show a negative result that there is an sf AC0-language that cannot be recognized by an UHAT encoder. On the positive side, we show that UHAT encoders can recognize a rich fragment of sf AC0-languages, namely, all languages definable in first-order logic with arbitrary unary numerical predicates. This logic, includes, for example, all regular languages from sf AC0. We then show that AHAT encoders can recognize all languages of our logic even when we enrich it with counting terms. We apply these results to derive new results on the expressive power of UHAT and AHAT up to permutation of letters (a.k.a. Parikh images).

Key facts. Cited by 38 papers in the map (data through 14 Oct 2026). Builds on 7 of its 22 references that are in the map. First posted on arXiv 5 Oct 2023.

Builds on

7 of 22 references.

References · 7

  1. 2017Attention Is All You Needcited by 60,361
  2. 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 288
  3. 2021Thinking Like Transformerscited by 184
  4. 2022Overcoming a Theoretical Limitation of Self-Attentioncited by 113
  5. 2021Self-Attention Networks Can Process Bounded Hierarchical Languagescited by 105
  6. 2022Formal Language Recognition by Hard Attention Transformers: Perspectives from Circuit Complexitycited by 93
  7. 2023Tighter Bounds on the Expressivity of Transformer Encoderscited by 66

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2023: 2; 2024: 6; 2025: 17; 2026: 13.

38 papers.

Sort:

By area:

  1. 2023What Formal Languages Can Transformers Express? A Surveycited by 124
  2. 2023Masked Hard-Attention Transformers Recognize Exactly the Star-Free Languagescited by 49
  3. 2024Counting Like Transformers: Compiling Temporal Counting Logic Into Softmax Transformerscited by 39
  4. 2025A Theory of Learning with Autoregressive Chain of Thoughtcited by 23
  5. 2024Simulating Hard Attention Using Soft Attentioncited by 15
  6. 2025Characterizing the Expressivity of Fixed-Precision Transformer Language Modelscited by 14
  7. 2024An Examination on the Effectiveness of Divide-and-Conquer Prompting in Large Language Modelscited by 12
  8. 2025Knee-Deep in C-RASP: A Transformer Depth Hierarchycited by 12
  9. 2025Unique Hard Attention: A Tale of Two Sidescited by 10
  10. 2025The Counting Power of Transformerscited by 9
  11. 2025Softmax Transformers are Turing-Completecited by 9
  12. 2024Transformers as Transducerscited by 8
26 more
  1. 2025Ehrenfeucht-Haussler Rank and Chain of Thoughtcited by 6
  2. 2025The Transformer Cookbookcited by 6
  3. 2024Learning Linear Attention in Polynomial Timecited by 5
  4. 2026Parity, Sensitivity, and Transformerscited by 5
  5. 2025Transformers are Inherently Succinctcited by 4
  6. 2025Efficient Turing Machine Simulation with Transformerscited by 4
  7. 2026Context-Free Recognition with Transformerscited by 4
  8. 2026Length Generalization Bounds for Transformerscited by 4
  9. 2024A Transformer with Stack Attentioncited by 2
  10. 2025Rosetta-PL: Propositional Logic as a Benchmark for Large Language Model Reasoningcited by 2
  11. 2025The Logical Expressiveness of Temporal GNNs via Two-Dimensional Product Logicscited by 2
  12. 2025Probability Distributions Computed by Autoregressive Transformerscited by 2
  13. 2026On the Expressiveness of State Space Models via Temporal Logicscited by 2
  14. 2025On the Existence of Universal Simulators of Attentioncited by 1
  15. 2025From Neural Networks to Logical Theories: The Correspondence between Fibring Modal Logics and Fibring Neural Networkscited by 1
  16. 2025The Role of Logic and Automata in Understanding Transformerscited by 1
  17. 2026An expressivity analysis of hierarchical modelling in deep transformers via bounded-depth grammarscited by 1
  18. 2025Comparison of different Unique hard attention transformer models by the formal languages they can recognizecited by 0
  19. 2026Synthesis and Verification of Transformer Programs (Technical Report)cited by 0
  20. 2026Average Attention Transformers and Arithmetic Circuitscited by 0
  21. 2026Encoder-Decoder Transformers: Logical Characterizations and Periodicitycited by 0
  22. 2026The Polynomial Counting Capabilities of Message Passing Neural Networkscited by 0
  23. 2026A Hierarchical Language Model with Predictable Scaling Laws and Provable Benefits of Reasoningcited by 0
  24. 2026Provably Shorter Scratchpads in Hybrid DeltaNet-Attention Decoderscited by 0
  25. 2026On the Expressive Power of Transformerscited by 0
  26. 2026Training Dynamics of Transformers on Unbounded Inputs: Attention Learning Can Lag Output Layer Learningcited by 0