arXiv:2610.25341cs.CCOct 2026

Manuscript Offprint

arXiv:2610.25341

Formally Verified Autoresearch for Analyzing the Expressivity of Multi-Head Attention

Karthik Viswanathan, Plamen Dimitrov, Stefano Rocca, Sarayu Sirikonda

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Multi-head attention is a central component of the transformer architecture, yet how its expressivity depends on the number of heads remains poorly understood. We study a one-layer, attention-only transformer with additive positional embeddings and define the head complexity H∗(f)H^{*}(f) of a Boolean function ff as the minimum number of attention heads required to represent it. We derive an exact linear-fractional normal form for head complexity, prove a general threshold-degree lower bound, and give an explicit ten-bit function for which this bound is strict. For symmetric Boolean functions, we independently show that head complexity equals the number of times the function changes value between consecutive Hamming-weight levels, even when positional embeddings are allowed. This agrees with the concurrent characterization of Hsu and Xu [2026] in a model without positional embeddings. The symmetric lower bound combines our general threshold-degree bound with the classical result of Aspnes et al. [1994]. These results were discovered and formalized by a frontier model through conjecture generation, theorem proving, and machine verification, while human researchers asked the high-level questions and reviewed the generated theorems. We make the Lean formalization and research traces publicly available to support agent-assisted theorem proving and formal verification in mechanistic interpretability. This work provides a proof of concept for using the capabilities of frontier models, grounded by formal verification, to develop an understanding of transformer architectures.

Keywords: mechanistic interpretability, expressivity, formal verification, autonomous research.

1 Introduction

Mechanistic interpretability is an important component of a broader toolkit for AI safety and oversight Bengio et al. [2026]. Theoretical mechanistic interpretability works Elhage et al. [2021, 2022], Geshkovski et al. [2025] have shaped empirical interpretability Olsson et al. [2022], Cunningham et al. [2023], Viswanathan et al. [2026] by providing useful abstractions, and principled starting points for experimentation. However, developing this kind of theory has been demanding, requiring sustained expert effort to work through the underlying mathematics. Recent advances in language models for mathematical reasoning and formal theorem proving Tsoukalas et al. [2026], Alon et al. [2026], Yang et al. [2023] create an opportunity to accelerate the development of rigorous theory for mechanistic interpretability.

Such theory would be especially valuable for multi-head attention [Vaswani et al., 2017], since a more fundamental account of how it transforms the residual stream could support mechanistic interpretability in both models at scale and toy models. In models at scale, a theory of how attention heads transform and combine features could inform theoretically grounded feature-decomposition

∗^{*}Correspondence to vkarthik095@gmail.com.

40th Conference on Neural Information Processing Systems (NeurIPS 2026). Workshop: Autonomous Machine Learning Research.

tools [Cunningham et al., 2023, Shafran et al., 2026], by relating the features the probes recover to computations that the architecture can implement. For toy models, a theory of multi-head attention can provide a principled basis for interpreting and generalizing empirical findings about how learned computations are distributed across attention heads [Nanda et al., 2023, Piotrowski et al., 2025]. For instance, the problem studied here arose from an empirical finding in a one-layer transformer trained on modular addition Nanda et al. [2023]: parity was only weakly linearly decodable from individual head outputs, but became nearly perfectly decodable when the head outputs were combined. This suggested that parity was implemented as a distributed computation across heads, motivating us to ask whether single-head attention faces a structural expressivity barrier.

Related work Transformer expressivity has been studied through logical characterizations, approximation theory, and analyses of formal languages and Boolean functions [Weiss et al., 2021, Yang and Chiang, 2024, Sälzer et al., 2026, Kajitsuka and Sato, 2024, Hahn, 2020, Kozachinskiy et al., 2026, Hsu, 2026, Köver et al., 2026]. Yu et al. [2026] establish upper and lower bounds on the parameter complexity required for ϵ\epsilon-approximation as the number of heads varies, while Hsu [2026] establishes lower bounds on the head count for representing n-bit parity with one-layer transformers. In concurrent work, Hsu and Xu [2026] also obtain the exact head-count characterization for symmetric functions in a model without positional embeddings. Rajaraman et al. [2026] also study head complexity, proving that n-bit parity requires exactly n heads and establishing upper and lower bounds for general Boolean functions. Appendix D compares these concurrent results with our work.

Despite this progress, deriving general expressivity guarantees for multi-head attention remains technically demanding because tracking even a single layer involves multiple attention head updates and their interactions. Agent-assisted mathematical reasoning can help navigate this analytical complexity, while formal verification provides a rigorous check on the resulting claims. We apply this framework to a concrete expressivity question for Boolean functions:

For a Boolean function ff, what is the minimum number of attention heads needed to represent ff in a single attention layer?