Manuscript Offprint
arXiv:2610.35715Quantitative Generalization Bounds for Multi-Layer Transformers: A Few Long Strings can Beat Many Short Ones
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
ABSTRACT
Transformer-based language models exhibit an astonishing capacity to generalize to longer and more difficult problem instances than those seen in training. However, theoretical understanding of this phenomenon still lags behind. Unlike most machine learning models, the generalisation abilities of transformers inherently require considering two axes. On one hand, one must examine in-distribution statistical generalisation, which concerns the ability of a model to broaden a function from training samples to novel samples of the same distribution. On the other hand, given the sequential nature of language data, one must also consider length generalisation, which reflects whether a model trained on inputs of a given length can extrapolate to longer ones. These two notions have mostly been studied separately, leaving open how they interact. In this work, we give a joint treatment of both axes for fixed-precision transformers. We give generalisation guarantees in terms of the parameter sizes of the involved models, as well as the quantization space and the alphabet size that supply the sequences. Finally, we illustrate how the requirements in the sample count and training length trade off. In particular, we find that increasing training length can be exponentially more efficient than increasing the sample size. Experiments support predictions of the theory.
1 INTRODUCTION
The success of large language models (LLMs) has prompted research into the learning and generalization properties of the underlying transformer architecture. Classical statistical learning theory provides a wealth of techniques that bound the generalization error as a function of the data size and the complexity of the hypothesis class. Recent work has brought these to bear on transformers (Covering numbers: Edelman et al. (2022); Trauger & Tewari (2024), Bayesian methods: Lintilhac & Shaikh (2026); Rizvi-Martel et al. (2026), VC Dimension: Yang et al. (2026c), inter alia). These results primarily address the i.i.d. regime – for transformers, this in particular implies that the test inputs are drawn from the same length distribution as the training inputs.
However, for transformer learning theory, the i.i.d. paradigm is arguably insufficient: it is highly desirable to understand when transformers can extrapolate to sequences longer than seen during training. This phenomenon is referred to as length-generalization (e.g. Bhattamishra et al., 2020; Anil

Token Budget: 3k 5k 7k 9k 11k
Figure 1: Our results predict that increasing the length of the training words can be much more token-efficient than increasing their number; test accuracy for the language (Sec. 5) on words five times longer than the training length. We highlight in red the highest-accuracy cell at five different training token budgets.
et al., 2022; Kazemnejad et al., 2023), and is understood to be diagnostic of when a transformer actually learns an underlying algorithmic solution, as opposed to length-dependent heuristics (e.g. Zhou et al., 2024; Huang et al., 2026). It also indicates when LLMs can be expected to perform a task reliably across long contexts (Jobanputra et al., 2025).
Length generalization is governed by two quantities: the number of training samples, and their length. Sample count determines how reliably the training data pins down the target function, as in classical statistical learning theory; sample length determines how well the model extrapolates, since the longest input length at which the target function's behavior is observed dictates to which point a model will extrapolate beyond it. For a given target function and learning procedure, we thus need to consider not only its sample complexity (the required number of training samples), but also its length complexity (the required length of training samples).
Here, we take up the question of providing quantitative bounds on generalization along both axes for multi-layer transformers in the fixed-precision regime. We study the questions:
How do properties of a target function influence the length complexity and data complexity of the task?
When both sample size and length are bounded, how do they trade off? In particular, under a fixed token budget, how to best allocate sample size and length?
and address these by providing generalization bounds depending on both sample size and input length. The main idea is that training length determines which behaviors become observable; sample size determines how reliably those behaviors are learned. Below a task-dependent length threshold, some competing behaviors cannot be distinguished. Around the relevant transition, longer examples can make informative events much more common; increasing length can thus strongly reduce sample complexity in this regime. Beyond that transition, the benefit of additional length diminishes and additional independent examples matter more.
2.1 TRANSFORMERS
We study transformers in the fixed-precision regime, without positional encodings, as formalized by Li & Cotterell (2025; 2026) (see also Li et al. (2024); London & Kanade (2025)).
This class is expressive enough to accommodate key algorithmic primitives relevant to transformers, such as retrieving past symbols, checking global symbol alternation patterns, or the “induction head” construction. Fixed-precision transformers are less expressive than log- or unbounded-precision transformers; this turns out to be necessary for obtaining quantitative results, because length generalization bounds for the latter are known to be uncomputable in the worst case by results of Yang et al. (2026a). We discuss the detailed comparison across models of transformers in Appendix A.
Our model of transformers derives from Li & Cotterell (2025): we consider transformers with softmax attention, fixed precision, no positional encodings and strict causal masking. However, we generalize over Li & Cotterell (2025) in viewing transformers not as binary classifiers, but as providing an output at every position. We provide details in Appendix B.2. All activations are computed in F, a finite subset of R extended with and . The result of every operation is rounded to F.
Fix a finite alphabet . A fixed-precision transformer , also just called transformer consists of token embeddings in dimension , a sequence of layers each consisting of softmax attention heads with a ReLU feedforward network, and finally a linear output projection. Overall, it takes a word input and returns vectors of dimension at every input position: . We suppose that always divides , and that the dimension per head is uniform among the heads. We omit layer norm, as it is not essential to our results and requires extra care in fixed precision; see Appendix E.5 for more details. Assuming that , and the output dimension are shared, we refer to these transformers as . See Appendix B.2 for details.
2.2 LEARNING FRAMEWORK
We follow prior sample complexity bounds in studying an idealized learning model that abstracts away from the algorithmic process of learning. Capacity-based learning bounds (Edelman et al., 2022; Trauger & Tewari, 2024; Yang et al., 2026c) apply to Empirical Risk Minimization (ERM), which finds parameters minimizing training error under some constraint on the hypothesis class. We contrast it with the Guess & Check algorithm (G&C, Chiang et al., 2023; Buzaglo et al., 2024), which samples parameter settings from the parameter space until a setting interpolating the training set is found. Guess & Check expands over ERM by modeling the inductive bias of SGD-like optimizers towards solutions occupying large volumes in parameter space (Chiang et al., 2023; Buzaglo et al., 2024). This is an important difference over bounds based on ERM (Edelman et al., 2022; Yang et al., 2026c; Trauger & Tewari, 2024), as it (i) allows us to explicitly take into account the effect of both the hypothesis class and the ground-truth function, (ii) while bounds depend more mildly on the hypothesis model's size than capacity-based bounds. This enables stronger results when the target function can be represented by small models, and we find it to be borne out empirically in experiments. G&C is closely related to a Bayesian interpretation of learning, as it samples from a posterior over the parameter space conditional on the training set (e.g. Haussler et al., 1994). We throughout work in the realizable regime, where the training data can be exactly fitted by an element of the hypothesis class. Here, ERM and G&C can be defined as follows:
Definition 2.1. Let a hypothesis class (where “...s” stands for “student”), and a training set , be given.
The ERM Learner selects a transformer such that perfectly fits the training set: . The Guess & Check Learner returns a sample from the posterior
where is the uniform distribution over .
Intuitively, G&C adds an inductive bias towards hypotheses represented by a larger volume in parameter space. See Appendix A for discussion beyond the interpolating regime.
Remark 2.1. Throughout this paper, we consider the student–teacher learning framework between two transformers and , with , , and for realizability.
3 LENGTH GENERALIZATION
We first derive length generalization bounds when unbounded data samples are available (Section 3.1); and statistical generalization bounds at a fixed length (Section 4.1). We then derive joint generalization bounds (Section 4.2).
3.1 DETERMINISTIC LENGTH GENERALIZATION
Our first result states that, if two fixed-precision transformers exactly agree up to a certain length bound C, they must agree everywhere. We in fact obtain two distinct bounds with different rates:
Lemma 3.1 (Deterministic Length Generalization). Let be a well chosen constant and let and be fixed-precision transformers (2.1). Set
and let . Then, if and agree on every word in , they are identical on every word in :
This statement yields a first length generalization guarantee, in the setting where unbounded data samples are available: In this case, if a learned model exactly fits data representing a target function expressed by up to length , then we know even on longer length strings, i.e., length generalization occurs.
See Appendix D for the formal proof; here, we provide an informal discussion to build intuition. Given a teacher transformer implementing the target function and a student from the hypothesis class, we introduce the difference function, which checks for any given word if the output vectors of both transformers match at every position. Previously, Li & Cotterell (2025) showed that fixed-precision transformers with a binary classifying output layer are expressively equivalent to LTL[P], a fragment of linear temporal logic, and further can be represented as a partially-ordered deterministic finite automaton (poDFA) (Figure 2). A poDFA is a DFA where the reachability relation defines a partial order on the state set; intuitively, such automata have no nontrivial loops. Intuitively, the state space describes the dynamic of the transformer's KV-cache; as soon as some activation is added to the KV-cache, it cannot be removed anymore, giving rise to the partially ordered loop-free structure.
Building on this, we express the difference function between the student and the teacher as a logic formula in LTL[P], from which we obtain a poDFA . The student and the teacher transformers produce a different output somewhere on a word if and only if , run on the word, ends up in the unique absorbing disagreement state (Figure 2e). As a supplement, we mention in Appendix C, D how transformers exist as ordered Mealy machines (Def. C.5), providing a similar underlying ordered structure on individual transformers, even outside of the learning framework.
We then upper-bound the height of , the length of its longest transition chain. The key idea here is that observing behaviour on strings up to roughly this length should be important for length generalization, because strings of this length should be minimally required to be able to observe the whole state space of and thus the whole range of behaviour expressed by the student and teacher models. We obtain as two upper bounds on the height of (eq. 2); whichever bound is smaller provides a tighter bound in a given setting, though neither dominates the other globally. Notably, we show some kind of tightness in and of our bounds in Appendix D.5, where we prove that any upper bound on the height must depend at least linearly on and .
Now, if and agree up to length , cannot visit a state on any word of this length. But given that upper-bounds the height of the automaton, the state cannot be reachable even by longer inputs, and across .
The above entails a first length-generalization bound in the limiting case where all data up to some length is available; it is an illustrative first special case of our general result.
(a)
(b)

(c)
(d)
Figure 2: Examples of poDFAs; the vertices are the states and the arrows are the transition functions . Figure (a) represents the transformer that outputs “1” as soon as the input word has entered the language with (b) being the associated poDFA. Similarly, (c) depicts the transformer that recognizes the language and (d) is its corresponding poDFA. Figure (e) is the poDFA of the difference function between these two transformers. Any disagreement sends the run to the absorbing final state .
3.2 EXTENSION TO THE PROBABILISTIC FRAMEWORK
We next ask for a similar length generalization guarantee when and are equal only on most strings up to length . Setting the data distribution and using the bound from Lemma 3.1, we indeed find a probabilistic extension of the guarantee:
Lemma 3.2 (Probabilistic Length Generalization). Let , and consider the training words of length up to , with
Then
See Appendix D.4 for the formal proof. Intuitively, this holds for two reasons: (i) the poDFA ultimately reaches a sink absorbing state; (ii) the input distribution is uniform and so are the letters: this implies that for any non-absorbing state, the probability to leave the state by reading the next letter is at least of . Therefore, after a big enough number of steps , will be likely to live in an absorbing state. In particular, since the probability of a transition is at least , the overall probability of a word to reach an absorbing state after steps dominates the binomial law . The lemma follows from the application of a Chernoff bound.
4 JOINING LENGTH AND STATISTICAL GENERALIZATION
4.1 DATA COMPLEXITY
We lift the deterministic statement to a statistical generalization statement. The key here is to combine Lemma 3.1 with statistical in-distribution generalization on the strings up to length K:
Proposition 4.1 (Statistical Generalization for ERM and G&C). Fix and . Assume the target function is represented by a teacher , and the learner (G&C or ERM) selects a student from the hypothesis class . Let be an i.i.d. sample of strings from .
- Let be obtained by the G&C learner on S. If
then, with probability at least over S and the draw of ,
- Let be obtained by ERM on S. If
then, with probability at least over S,
Note here that absorbs constants depending on and . The ERM bound has a similar flavor to bounds using capacity-based arguments (Edelman et al., 2022; Trauger & Tewari, 2024; Yang et al., 2026c) in that it scales with parameters count of the hypothesis class. The G&C bound has a similar dependency but scales with rather than . This provides improved generalization when a large student network learns a low-complexity target.
This result extends the work of Rizvi-Martel et al. (2026) with some improvements; we give the exact values of B and and discuss the proof and extensions in Appendix E. For ERM, this is a straightforward application of Appendix B.1 in Buzaglo et al. (2024). For G&C, the proof strategy (Appendix E) is to show that low-complexity teachers can be embedded in many equivalent ways into the parameter space of a higher-complexity hypothesis class; this means that G&C is intrinsically more likely to find low-complexity interpolators. This insight (Buzaglo et al. (2024)) drives the appearance of a teacher complexity term, and a milder dependence on student complexity than based on hypothesis class parameter count alone.
4.2 MAIN RESULT: JOINT STATISTICAL AND LENGTH GENERALIZATION
We now combine length and statistical generalization to obtain our main result. The basic intuition is that generalization occurs when (i) the length is sufficiently long so that all representative behavior relevant at long lengths are already visible, (ii) the sample size is sufficient for achieving low test error at this length; combining (i) and (ii) then entails low test error at higher lengths. The result is:
Theorem 4.1 (Statistical and Length Generalization). Let the transformers student and teacher satisfying 2.1, C as in Eq. 2, and .
Let be given by the Guess & Check learner, agreeing with on N i.i.d. samples from , with
and
where
Then with probability , we have
See Appendix F.1 for the formal proof. For ERM, an analogous result ensues from bounding N appropriately, following Proposition 4.1. In addition, the theorem can be adapted to alternative distributions if they sample enough long words; we give an example in Appendix F.4.
4.3 TRADEOFF BETWEEN LENGTH AND DATA COMPLEXITY
The previous theorem provides conditions on the data complexity and the training length threshold , such that low loss can be achieved. Assuming the same learning framework for student , teacher and writing , we now investigate how these quantities trade off, by giving an error bound for any joint choice of and :
Theorem 4.2 (Joint Generalization Bound in Sample Size and Length). Define
where C is the bound given in Lemma 3.1 and B is the sample complexity term from Proposition 4.1.
Now assume that the student is trained on N random samples from and that K is big enough so that . Then with probability , for any length , the error rate between the student and the teacher is bounded as
See Appendix F.2 for the proof. This value lower-bounds the probability of reaching an absorbing state by time , and when . This theorem holds for either of the Guess & Check or the ERM learner, setting accordingly following Proposition 4.1. Moreover, under an appropriate definition of , the theorem even remains valid if the input strings are generated from appropriate nonuniform distributions (Appendix G.2). We further complement the upper bound (10) with a lower bound: there are families of target functions and input distributions such that the expected test error on long inputs is lower-bounded by for an appropriate choice of (Appendix, Theorem G.3).
Takeaway: Importance of Long Training Samples for Transformers. This implies the following: First, when , there is no assurance of length generalization. Second, when just slightly exceeds , length generalization can be guaranteed, but only at an extraordinary sample size on the order of , with the size of the alphabet. Namely, , leading to a sample size requirement where . Intuitively, this happens because only a small fraction of the samples will already have reached an absorbing state; most samples will thus not be informative about the target function's behavior on long strings.
Third, increasing K by a constant can reduce the required sample size by a multiplicative factor. Specifically, increasing length from C to sC reduces the required sample size by a factor of at least ; a linear increase of K permits an exponential saving on N.
Given a fixed training-token budget , the above considerations allow us to determine an optimal allocation to and ; we show in Appendix F.3 that, for , the following closed form achieves an error bound within a factor of the optimum:
provided Budget . Intuitively, this means that close-to-optimal budget allocation can be achieved at around , exponentially more efficient than at .
Our result reveals that there are several regimes of generalization. When K is too small, there is in general no hope of length generalization no matter how large N is. When K has just crossed the threshold given by the longest chain, one may need a very large N, because only few strings will have reached the final state. In this regime, increasing K further is much more efficient than increasing N: increasing K by an additive constant can cut down N by a multiplicative factor.
4.4 EXTENSION WITH LOCAL ATTENTION
Local attention has emerged as an effective and popular addition to transformers (e.g. Beltagy et al., 2020). It is also relevant because positional information often specifically introduces a locality bias favoring attention to recent position (Press et al., 2022; Su et al., 2024). Local attention thus simultaneously serves as a sim-

Figure 3: Schematic error-budget limit lines with linear axes. At , every budget can be respected with training samples. By length , at least half of the words have reached their terminal absorbing states, so each curve is within a factor 2 of its floor; further length gains saturate.
plified account of the role of positional information (similar to positional functions in Limit Transformers, Huang et al. (2025a); Izzo et al. (2025)). In each layer, we add a certain number of local attention heads at some window size W; for these heads, context positions at distance > W are masked. Both W and the number of local heads are hyperparameters. We refer to Li & Cotterell (2026) for the full formalization in the FPT context.
Formally, we can model an with local attention in terms of a more complex automaton that arises as a cascade product of a poDFA with a simple automaton that maintains the last symbols. That is, we can model the difference automaton in terms of the cascade product of a poDFA representing the output difference between the two transformers with a simple automaton that maintains the last symbols. More details in Appendix G.1.
The statistical generalization guarantee (Proposition 4.1) is unaffected, because the number of parameters does not change when making some heads local. The length generalization guarantee changes. First, the construction we provide is only valid for the bound in Eq. 2. Second this threshold receives a factor of . Third, the bounding binomial probability to go forward in the underlying poDFA is also reduced from to . Thus, as long as is fixed, we have the same qualitative predictions as above: model size impacts data and length complexity; and sample size and length trade off.
5 EXPERIMENTS
We introduce three families of tasks, and study (i) the impact of teacher and student complexity on length and data complexity, and (ii) the predicted interaction between length and sample size.
Tasks. We defined three task families, each along a complexity scale indexed by , as follows (i) Alternating languages : Detecting whether distinct blocks of 's and 's have occurred (Yang et al., 2025a) – that is, checking membership in the languages ; , etc. There is a teacher family with number of layers , embedding dimension , head count and fixed alphabet size . Specifically, the letter sampling is not uniform, with probability to alternate block set to 0.05. This still fits our theoretical framework, as explained in Appendix H.1.1. (ii) Alphabet languages : Detecting whether all symbols from a given alphabet have occurred. There is a teacher family with , , , . (iii) Induction Head tasks : Outputting which next tokens can follow the current token under the context's bigram distribution over the alphabet (cf. Edelman et al., 2024); that is, given the current token output a vector indicating for which symbols the bigram has contextually occurred. There is a teacher family with , , , , with local attention. See Appendix H for teacher constructions. Taken together, these tasks allow us to test the theoretical prediction that the teacher size (impacted by , , , ) impacts both length and data complexity.
Setup. To test our predictions against ordinary gradient-based training, we train FP32 transformers with Adam Kingma & Ba (2014) and binary cross-entropy over 10 seeds. We use binary classification because exact logit-equality in FP32 is not realistic. The difference function between the student and the teacher then checks for logit signs rather than exact values (Appendix H.2). In addition, we retain only runs with perfect training accuracy—that is, runs that correctly classify every supervised target on every training word. This enforces the interpolation conditioning of Guess & Check. Trained architectural sizes are fixed and common across a family, unless explicitly varied. When sweeping N, we adjust K across tasks to match the fraction of words exhibiting the required blocks, letters, or bigrams, making examples approximately comparable in informativeness (Appendix H.2). Sweeps of K instead compare tasks at common lengths.

Figure 4: Left: Impact of teacher's size on length complexity. Larger teachers require training samples to be longer. The abscissa scale is linear, as suggested by theory. Right: Impact of teacher's size on data complexity. Larger teachers require more training samples for similar length generalization performance. The abscissa scale is logarithmic, as suggested by theory. On both sides, the plotted tasks are respectively the Alternating , , , , the Alphabet , , , and the Induction Head , , , .
Effect of Transformers Size on Data and Length Complexity. Across the three families, increasing teacher size impacts the sample size N and training length K at which generalization becomes successful (Figure 4). This is in line with our theoretical predictions, in particular, the G&C-based bounds. Interestingly, the student size had relatively small impact on sample size and length (Appendix H.3.2). Thus, G&C-based bounds are successful in capturing the fact teacher size is an important factor beyond student size, but may still be overly pessimistic about the impact of student size.
Tradeoff between Sample Size and Length. Longer training words can substantially reduce the sample size needed for generalization (Figure 5). In particular, we find the non-linear interaction between the two quantities, qualitatively in line with the predictions from Figure 3. This backs the idea that an efficient token-budget allocation should ensure that training samples are long enough. See Appendix H.3.3 for further results showing the same pattern.

Training Length K
Figure 5: Tradeoff between the training length and the sample size for one task of each language class: Alternating , Alphabet and Induction Head . Evaluation at length 5 times the training length. Brown contouring around all cells with accuracy . Under this condition, the 3 cells with the smallest token-budget are framed.
6 DISCUSSION
Our result goes beyond established theory in two ways: First, it goes beyond statistical generalization bounds for transformers by guaranteeing length generalization. Prior learning results for transformers characterize generalization error and sample size when the test and train samples are at the same sequence length (Edelman et al., 2022; Trauger & Tewari, 2024; Li et al., 2026; Truong, 2024; Yang et al., 2026c; Li et al., 2025; Rizvi-Martel et al., 2026; Lintilhac & Shaikh, 2026; Mousavi-Hosseini et al., 2025; Hanneke et al., 2026; Joshi et al., 2025). Our results instead consider the more general case of length generalization, in the setting of fixed-precision transformers. We note that our main result ingests the statistical generalization bound essentially as a black box; hence, our results might analogously also be formalized on the basis of other statistical generalization bounds.
Second, our results go beyond prior work on length generalization by giving explicit and joint rates for sample size and length. So far, the most generally predictive account of length generalization has been the RASP-L Conjecture (Zhou et al., 2024) and its formalization via C-RASP and Limit Transformers (Huang et al., 2025a). This theory has been highly predictive of which tasks empirically show length generalization (Yang et al., 2026b), but provides no quantitative predictions. Notably, C-RASP is more powerful than FPT; e.g. it can model the MAJORITY language. However, C-RASP is a too loose target for quantitative learning bounds: Yang et al. (2026a) show that, beyond the shallow-depth case (Izzo et al., 2025; Chen et al., 2025), any length threshold would need to grow uncomputably with model complexity. The positive fragment C-RASP has expressivity equivalent to fixed-precision transformers and was studied in Yang et al. (2026a); Zetzsche et al. (2026). We compare with these results in detail in Appendix A. Importantly, our work innovates over these prior results by providing joint generalization guarantees in both sample size and length.
Like capacity-based generalization bounds (Edelman et al., 2022; Trauger & Tewari, 2024; Yang et al., 2026c), our work treats an idealized learning model that abstracts away from the computational process of finding a model fitting the training data. Understanding optimization dynamics for transformers has been difficult. Progress has been made for specific task families and restricted models, such as single layers (e.g. Yang et al., 2025b; Mwigo & Dasgupta, 2026; Huang et al., 2025b;
Wang et al., 2024) (including one-layer models performing chain-of-thought, Huang et al. (2025b)) or specific task families (e.g. Nichani et al., 2024). We view the study of G&C as an (imperfect) proxy for part of the implicit inductive bias of SGD-like learning; understanding of optimization dynamics for a general multi-layer model and a general hypothesis class will require new methods.
The main limitation of our results is that they predict asymptotic rates but not yet concrete realistic numerical bounds for specific tasks and models. The primary barrier here is that the bounds involve large constants involving the fixed-precision set , which is large at full-precision training. It is an interesting question whether realistic numerical bounds can be obtained when training with strong quantization. Further limitations are that fixed-precision transformers are less expressive than log-precision or infinite-precision transformers, we did not treat positional encodings, and studied G&C and ERM as opposed to optimization dynamics.
7 CONCLUSION
We have provided generalization bounds for multi-layer fixed-precision transformers that account for the roles of both the number and the length of training samples. We provided a joint treatment of both dimensions, showing that, under a given token budget, increasing length can sometimes be exponentially more efficient than increasing sample size.
ACKNOWLEDGMENTS
Funded in part by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – Project number 560456343. M.H. is supported by the Konrad Zuse School of Excellence in Learning and Intelligent Systems (ELIZA) through the DAAD programme Konrad Zuse Schools of Excellence in Artificial Intelligence, sponsored by the Federal Ministry of Education and Research.
CONTRIBUTIONS
Ma.H. led the project. Mi.R. contributed Proposition 4.1. Mi.H. supervised the project.
REFERENCES
Yotam Alexander, Yonatan Slutzky, Yuval Ran-Milo, and Nadav Cohen. Do neural networks need gradient descent to generalize? a theoretical study. In D. Belgrave, C. Zhang, H. Lin, R. Pascanu, P. Koniusz, M. Ghassemi, and N. Chen (eds.), Advances in Neural Information Processing Systems, volume 38, Main Conference, pp. 143774–143840. Curran Associates, Inc., 2025. doi: 10.52202/085713-4813. URL https://proceedings.neurips.cc/paper_files/paper/2025/file/d39fb2054215f07d1f90cc80c7a85edd-Paper-Conference.pdf.
Zeyuan Allen-Zhu, Yuanzhi Li, and Yingyu Liang. Learning and generalization in overparameterized neural networks, going beyond two layers. Advances in neural information processing systems, 32, 2019. URL https://proceedings.neurips.cc/paper_files/paper/2019/hash/62dad6e273d32235ae02b7d321578ee8-Abstract.html.
Cem Anil, Yuhuai Wu, Anders Andreassen, Aitor Lewkowycz, Vedant Misra, Vinay Ramasesh, Ambrose Slone, Guy Gur-Ari, Ethan Dyer, and Behnam Neyshabur. Exploring length generalization in large language models. Advances in Neural Information Processing Systems, 35:38546–38556, 2022. URL https://proceedings.neurips.cc/paper_files/paper/2022/hash/fb7451e43f9c1c35b774bcfad7a5714b-Abstract-Conference.html.
Sanjeev Arora, Simon Du, Wei Hu, Zhiyuan Li, and Ruosong Wang. Fine-grained analysis of optimization and generalization for overparameterized two-layer neural networks. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 322–332. PMLR, 09–15 Jun 2019. URL https://proceedings.mlr.press/v97/arora19a.html.
Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E. Hinton. Layer Normalization. arXiv preprint arXiv:1607.06450, 2016. URL https://arxiv.org/abs/1607.06450.
Peter L. Bartlett, Andrea Montanari, and Alexander Rakhlin. Deep learning: a statistical viewpoint, 2021. URL https://www.cambridge.org/core/journals/acta-numerica/article/deep-learning-a-statistical-viewpoint/7BCB89D860CEDDD5726088FAD64F2A5A.
Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020. URL https://arxiv.org/abs/2004.05150.
Satwik Bhattamishra, Kabir Ahuja, and Navin Goyal. On the ability and limitations of transformers to recognize formal languages. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 7096–7116, 2020. URL https://aclanthology.org/2020.emnlp-main.576/.
J. A. Brzozowski. Languages of R-Trivial Monoids. Journal of Computer and System Sciences, 20:32–49, 1980. URL https://www.sciencedirect.com/science/article/pii/0022000080900033.
Gon Buzaglo, Itamar Harel, Mor Shpigel Nacson, Alon Brutzkus, Nathan Srebro, and Daniel Soudry. How uniform random weights induce non-uniform bias: Typical interpolating neural networks generalize with narrow teachers. In Ruslan Salakhutdinov, Zico Kolter, Katherine Heller, Adrian Weller, Nuria Oliver, Jonathan Scarlett, and Felix Berkenkamp (eds.), Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 5035–5081. PMLR, 21–27 Jul 2024. URL https://proceedings.mlr.press/v235/buzaglo24a.html.
Thomas Chen, Tengyu Ma, and Zhiyuan Li. Non-asymptotic length generalization. In Aarti Singh, Maryam Fazel, Daniel Hsu, Simon Lacoste-Julien, Felix Berkenkamp, Tegan Maharaj, Kiri Wagstaff, and Jerry Zhu (eds.), Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Proceedings of Machine Learning Research, pp. 8621–8682. PMLR, 13–19 Jul 2025. URL https://proceedings.mlr.press/v267/chen25ar.html.
Ping-yeh Chiang, Renkun Ni, David Yu Miller, Arpit Bansal, Jonas Geiping, Micah Goldblum, and Tom Goldstein. Loss landscapes are all you need: Neural network generalization can be explained without the implicit bias of gradient descent. In The Eleventh International Conference on Learning Representations, 2023. URL https://openreview.net/forum?id=QC10RmRbZy9.
Benjamin L Edelman, Surbhi Goel, Sham Kakade, and Cyril Zhang. Inductive Biases and Variable Creation in Self-Attention Mechanisms. In Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvari, Gang Niu, and Sivan Sabato (eds.), Proceedings of the 39th International Conference on Machine Learning, volume 162 of Proceedings of Machine Learning Research, pp. 5793–5831. PMLR, 17–23 Jul 2022. URL https://proceedings.mlr.press/v162/edelman22a.html.
Ezra Edelman, Nikolaos Tsilivis, Benjamin L. Edelman, Eran Malach, and Surbhi Goel. The evolution of statistical induction heads: In-context learning markov chains. In 38th Conference on Neural Information Processing Systems (NeurIPS 2024), volume 37, 2024. URL https://openreview.net/forum?id=qaRT6QTIqJ.
Michael Hahn and Mark Rofin. Why are sensitive functions hard for transformers? In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 14973–15008, 2024. URL https://aclanthology.org/2024.acl-long.800.pdf.
Steve Hanneke, Idan Mehalel, and Shay Moran. Sample complexity of autoregressive reasoning: Chain-of-thought vs. end-to-end, 2026. URL https://arxiv.org/abs/2604.12013.
David Haussler, Michael Kearns, and Robert E Schapire. Bounds on the sample complexity of bayesian learning using information theory and the vc dimension. Machine learning, 14(1):83–113, 1994. URL https://link.springer.com/article/10.1007/BF00993163.
Xinting Huang, Andy Yang, Satwik Bhattamishra, Yash Sarrof, Andreas Krebs, Hattie Zhou, Preetum Nakkiran, and Michael Hahn. A formal framework for understanding length generalization in transformers. In International Conference on Learning Representations (ICLR 2025), 2025a. URL https://arxiv.org/abs/2410.02140.
Xinting Huang, Aleksandra Bakalova, Satwik Bhattamishra, William Merrill, and Michael Hahn. Discovering interpretable algorithms by decompiling transformers to RASP. In Forty-third International Conference on Machine Learning, 2026. URL https://openreview.net/forum?id=QnWjcTk14G.
Yu Huang, Zixin Wen, Aarti Singh, Yuejie Chi, and Yuxin Chen. Transformers provably learn chain-of-thought reasoning with length generalization. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025b. URL https://openreview.net/forum?id=aE0bCvXXBt.
Zachary Izzo, Eshaan Nichani, and Jason D. Lee. Quantitative bounds for length generalization in transformers, 2025. URL https://arxiv.org/abs/2510.27015.
Selim Jerad, Anej Svete, Jiaoda Li, and Ryan Cotterell. Disentangling the expressivity of rope. arXiv preprint arXiv:2608.11909, 2026. URL https://arxiv.org/abs/2608.11909.
Mayank Jobanputra, Yana Veitsman, Yash Sarrof, Aleksandra Bakalova, Vera Demberg, Ellie Pavlick, and Michael Hahn. Born a transformer—always a transformer? on the effect of pretraining on architectural abilities. Advances in Neural Information Processing Systems, 38:95463–95506, 2025. URL https://proceedings.neurips.cc/paper_files/paper/2025/hash/894403f9604374a7a003063e480f65b9-Abstract-Conference.html.
Nirmit Joshi, Gal Vardi, Adam Block, Surbhi Goel, Zhiyuan Li, Theodor Misiakiewicz, and Nathan Srebro. A theory of learning with autoregressive chain of thought, 2025. URL https://arxiv.org/abs/2503.07932.
R. Kaas and J.M. Buhrman. Mean, median and mode in binomial distributions. Statistica Neerlandica, 34(1):13–18, March 1980. doi: 10.1111/j.1467-9574.1980.tb00681.x. URL https://ideas.repec.org/a/bla/stanee/v34y1980ilp13-18.html.
Amirhossein Kazemnejad, Inkit Padhi, Karthikeyan Natesan Ramamurthy, Payel Das, and Siva Reddy. The impact of positional encoding on length generalization in transformers. Advances in Neural Information Processing Systems, 36:24892–24928, 2023. URL https://proceedings.neurips.cc/paper_files/paper/2023/hash/4e85362c02172c0c6567ce593122d31c-Abstract-Conference.html.
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. URL https://arxiv.org/abs/1412.6980.
Blanka Kövér, Alexandra Butoi, Anej Svete, Michael Hahn, and Ryan Cotterell. Understanding the parameter space volume of transformers encoding boolean functions. In Forty-third International Conference on Machine Learning, 2026. URL https://openreview.net/forum?id=rUZVcnQjYW.
Jiaoda Li and Ryan Cotterell. Characterizing the Expressivity of Fixed-Precision Transformer Language Models. In 39th Conference on Neural Information Processing Systems (NeurIPS 2025), volume 38, 2025. URL https://arxiv.org/pdf/2505.23623.
Jiaoda Li and Ryan Cotterell. Characterizing the Expressivity of Local Attention in Transformers. In Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 37485–37507, 2026. doi: 10.18653/v1/2026.acl-long.1739. URL https://aclanthology.org/2026.acl-long.1739/.
Yawen Li, Tao Hu, Zhouhui Lian, Wan Tian, Yijie Peng, Huiming Zhang, and Zhongyi Li. Sharper generalization bounds for transformer, 2026. URL https://arxiv.org/abs/2603.21541.
Zhihao Li, Xue Jiang, Liyuan Liu, Xuelin Zhang, Hong Chen, and Feng Zheng. On the generalization ability of next-token-prediction pretraining. In Aarti Singh, Maryam Fazel, Daniel Hsu, Simon Lacoste-Julien, Felix Berkenkamp, Tegan Maharaj, Kiri Wagstaff, and Jerry Zhu (eds.), Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Proceedings of Machine Learning Research, pp. 34943–34975. PMLR, 13–19 Jul 2025. URL https://proceedings.mlr.press/v267/li25ao.html.
Zhiyuan Li, Hong Liu, Denny Zhou, and Tengyu Ma. Chain of thought empowers transformers to solve inherently serial problems. In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=3EWTEy9MTM.
Paul Lintilhac and Sair Shaikh. A sharper picture of generalization in transformers, 2026. URL https://arxiv.org/abs/2605.20988.
Charles London and Varun Kanade. Pause tokens strictly increase the expressivity of constant-depth transformers. Advances in Neural Information Processing Systems, 38:89765–89795, 2025. URL https://proceedings.neurips.cc/paper_files/paper/2025/hash/817c0ed5303e396e803d6a972f83c475-Abstract-Conference.html.
Tomáš Masopust and Michaël Thomazo. On the complexity of k-piecewise testability and the depth of automata. In Igor Potapov (ed.), Developments in Language Theory, volume 9168 of Lecture Notes in Computer Science, pp. 364–376, Cham, 2015. Springer. doi: 10.1007/978-3-319-21500-6_29. URL https://doi.org/10.1007/978-3-319-21500-6_29.
Alireza Mousavi-Hosseini, Clayton Sanford, Denny Wu, and Murat A. Erdogdu. When do transformers outperform feedforward and recurrent networks? a statistical perspective, 2025. URL https://arxiv.org/abs/2503.11272.
Brian Mwigo and Anirban Dasgupta. Generalization bound for a shallow transformer trained using gradient descent. Transactions on Machine Learning Research, 2026. ISSN 2835-8856. URL https://openreview.net/forum?id=t3iUeMOT8Z.
John Myhill. Finite Automata and the Representation of Events. Technical Report TR-57-624, Wright Air Development Center, Wright-Patterson Air Force Base, Ohio, 1957.
Vaishnavh Nagarajan and J. Zico Kolter. Uniform convergence may be unable to explain generalization in deep learning, 2019. URL https://arxiv.org/abs/1902.04742.
Anil Nerode. Linear Automaton Transformations. Proceedings of the American Mathematical Society, 9(4):541–544, 1958. doi: 10.1090/S0002-9939-1958-0135681-9.
Eshaan Nichani, Alex Damian, and Jason D. Lee. How transformers learn causal structure with gradient descent. In Ruslan Salakhutdinov, Zico Kolter, Katherine Heller, Adrian Weller, Nuria Oliver, Jonathan Scarlett, and Felix Berkenkamp (eds.), Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 38018–38070. PMLR, 21–27 Jul 2024. URL https://proceedings.mlr.press/v235/nichani24a.html.
Ofir Press, Noah Smith, and Mike Lewis. Train short, test long: Attention with linear biases enables input length extrapolation. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=R8sQPpGCv0.
Michael Rizvi-Martel, Satwik Bhattamishra, Guillaume Rabusseau, and Michael Hahn. From expressivity to sample complexity: Narrow teachers for transformers via c-rasp, 2026. URL https://arxiv.org/abs/2607.11760.
Jianlin Su, Murtadha Ahmed, Yu Lu, Shengfeng Pan, Wen Bo, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. Neurocomputing, 568:127063, 2024. URL https://www.sciencedirect.com/science/article/pii/S0925231223011864.
Jacob Trauger and Ambuj Tewari. Sequence length independent norm-based generalization bounds for transformers. In Sanjoy Dasgupta, Stephan Mandt, and Yingzhen Li (eds.), Proceedings of The 27th International Conference on Artificial Intelligence and Statistics, volume 238 of Proceedings of Machine Learning Research, pp. 1405–1413. PMLR, 02–04 May 2024. URL https://proceedings.mlr.press/v238/trauger24a.html.
Lan V Truong. On rank-dependent generalisation error bounds for transformers. arXiv preprint arXiv:2410.11500, 2024. URL https://arxiv.org/abs/2410.11500.
Zixuan Wang, Stanley Wei, Daniel Hsu, and Jason D. Lee. Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannot. In Ruslan Salakhutdinov, Zico Kolter, Katherine Heller, Adrian Weller, Nuria Oliver, Jonathan Scarlett, and Felix Berkenkamp (eds.), Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 51854–51912. PMLR, 21–27 Jul 2024. URL https://proceedings.mlr.press/v235/wang24ca.html.
Andy Yang and David Chiang. Counting like transformers: Compiling temporal counting logic into softmax transformers. In First Conference on Language Modeling, 2024. URL https://openreview.net/forum?id=FmhPg4UJ9K.
Andy Yang, Michaël Cadilhac, and David Chiang. Knee-deep in c-rasp: A transformer depth hierarchy. In 39th Conference on Neural Information Processing Systems (NeurIPS 2025), volume 38, 2025a. URL https://proceedings.neurips.cc/paper_files/paper/2025/hash/354a6e7be4f1a35127746b8147a31bfe-Abstract-Conference.html.
Andy Yang, Pascal Bergsträßer, Georg Zetzsche, David Chiang, and Anthony Widjaja Lin. Length Generalization Bounds for Transformers. In Forty-third International Conference on Machine Learning, 2026a. URL https://openreview.net/forum?id=XNXU8BJRT7.
Andy Yang, Blerta Veseli, Corentin Barloy, Michaël Cadilhac, Andreas Krebs, Charles Paperman, Howard Straubing, and Michael Hahn. Algebraic decomposition theory for transformer length generalization, 2026b. URL https://arxiv.org/abs/2608.13433.
Chenxiao Yang, Nathan Srebro, and Zhiyuan Li. Tight Sample Complexity of Transformers. In Steve Hanneke and Tor Lattimore (eds.), Proceedings of Thirty Ninth Conference on Learning Theory, volume 336 of Proceedings of Machine Learning Research, pp. 6887–6923. PMLR, 29 Jun–03 Jul 2026c. URL https://proceedings.mlr.press/v336/yang26a.html.
Tong Yang, Yu Huang, Yingbin Liang, and Yuejie Chi. Multi-head Transformers Provably Learn Symbolic Multi-step Reasoning via Gradient Descent. In D. Belgrave, C. Zhang, H. Lin, R. Pascanu, P. Koniusz, M. Ghassemi, and N. Chen (eds.), Advances in Neural Information Processing Systems, volume 38, Main Conference, pp. 116194–116285. Curran Associates, Inc., 2025b. doi: 10.52202/085713-3875. URL https://proceedings.neurips.cc/paper_files/paper/2025/file/a8f123480ede36612314d013aba6340c-Paper-Conference.pdf.
Georg Zetzsche, Hongjian Jiang, Andy Yang, Pascal Bergsträßer, Marco Sälzer, David Chiang, and Anthony W. Lin. Length generalization for transformers via compression, 2026. URL https://arxiv.org/abs/2609.08851.
Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization, 2017. URL https://arxiv.org/abs/1611.03530.
Hattie Zhou, Arwen Bradley, Etai Littwin, Noam Razin, Omid Saremi, Josh Susskind, Samy Bengio, and Preetum Nakkiran. What algorithms can transformers learn? a study in length generalization. In The Twelfth International Conference on Learning Representations, volume 2024, pp. 15898–15926, 2024. URL https://openreview.net/forum?id=AssIuHnmHX.
Yijia Jessica Zhu and David Chiang. Exact-solution volume and length generalization in transformers. arXiv preprint arXiv:2610.07676, 2026. URL https://arxiv.org/abs/2610.07676.
CONTENTS
1 Introduction 1
2 Background 2
2.1 Transformers 2
2.2 Learning framework 3
3 Length Generalization 3
3.1 Deterministic Length Generalization 3
3.2 Extension to the probabilistic framework 4
4 Joining Length and Statistical Generalization 5
4.1 Data complexity 5
4.2 Main Result: Joint Statistical and Length Generalization 6
4.3 Tradeoff between Length and Data Complexity 6
4.4 Extension with Local Attention 7
5 Experiments 8
6 Discussion 9
7 Conclusion 10
A FAQ 17
B Conventions and Background 20
B.1 Fixed-precision arithmetic 20
B.2 Transformers 20
C Logic 22
C.1 Past temporal logic 22
C.2 Past two-variable first-order logic 23
C.3 Transformers as logic formulas 23
C.4 Partially ordered automata 25
C.5 Past subformulas and automaton height 27
D Length Generalization 30
D.1 Bounding the height with past subformulas 30
D.2 Bounding the height with temporal profiles 32
D.3 Deterministic length generalization 33
D.4 Probabilistic length generalization 34
D.5 Dependence of Chain Length on L and F 35
D.5.1 Necessity of precision dependence ..... 35
D.5.2 Necessity of linear depth dependence ..... 36
E Data Complexity Bound ..... 37
E.1 Main statement and proof sketch ..... 37
E.2 Absence of output projection matrices ..... 38
E.3 Per-position outputs ..... 38
E.4 Comparison to ERM ..... 39
E.5 Normalization within transformers in fixed precision ..... 39
F Main theorem and Tradeoff ..... 41
F.1 Main theorem ..... 41
F.2 Multiplicative upper bound ..... 41
F.3 Tradeoff between Length and Data Complexity ..... 43
F.4 Adaptive main theorem: uniform training length ..... 44
G Extensions ..... 46
G.1 Local Attention ..... 46
G.2 Generalization with Nonuniform Distribution over Vocabulary ..... 48
G.3 Lower Bound on Tradeoff ..... 49
H Experiments ..... 52
H.1 Task families ..... 52
H.1.1 : Alternating languages ..... 52
H.1.2 : Alphabet languages ..... 52
H.1.3 : Induction Head tasks ..... 53
H.2 Protocol and evaluation ..... 53
H.3 Results ..... 55
H.3.1 Impact of the teacher's size ..... 55
H.3.2 Impact of the student's size ..... 57
H.3.3 Tradeoff between training length and data complexity ..... 60
I AI Usage ..... 69
A FAQ
- How do the results relate to Yang et al. (2026a); Zetzsche et al. (2026)?
Yang et al. (2026a) give two core results: (i) an impossibility result for computable length generalization bounds for C-RASP, and (ii) a deterministic length generalization bound analogous to our Lemma 3.1 for C-RASP .
The first result indicates that C-RASP is too powerful a target for obtaining quantitative learning results for transformers: even though C-RASP has been successful in predicting generalization behaviour experimentally (Huang et al., 2025a; Yang et al., 2026b), there are C-RASP-expressible tasks where training data would need to include strings with astronomically large lengths. Yang et al. (2026a); Zetzsche et al. (2026) further show an analogue of our Lemma 3.1 for C-RASP , the positive fragment of C-RASP, giving a computable bound in the size of the defining C-RASP formula. Most recently, Zetzsche et al. (2026) have further studied the role of sample size. They show exponential sample size bounds for C-RASP and another fragment, called C-RASP .
C-RASP has the same expressivity as fixed-precision transformers, though there is no direct 1-to-1 link between the transformer size parameters (L, D, H) and the size of defining C-RASP formulas. As a consequence, length and sample complexities that we obtain may not be directly comparable to bounds obtained for C-RASP in Yang et al. (2026a); Zetzsche et al. (2026).
An important difference of our results, besides directly applying to a transformer model rather than the C-RASP logic, is that we obtain joint bounds allowing us to understand the tradeoff between sample length and sample size.
- How do the experiments differ from the theoretical learning model? What are the implications of these differences?
The point of our experiments is to test theoretical predictions (obtained for idealized learners G&C or ERM on fixed-precision transformers) in a realistic training setup using gradient-based optimization (Adam) on high-precision (FP32) transformers. Whereas the theoretical setup asks for exact match of the output vectors, the experiments instead train for per-dimension binary cross-entropy. In experiments, we select only runs with perfect training accuracy, enforcing interpolation, as assumed in theory.
- Why study fixed-precision transformers? Why not study C-RASP / Limit Transformers?
It is a well-established empirical finding that transformers show strong length generalization on the class of languages expressed by fixed-precision transformers (Li & Cotterell, 2025; Yang et al., 2026b). They are thus a natural target for joint treatment of sample and length complexity.
Fixed-precision transformers define a strict subset of C-RASP (Yang & Chiang, 2024) and Limit Transformers (Huang et al., 2025a; Izzo et al., 2025). On the one hand, there is empirical evidence that transformers also show length generalization on tasks that are expressible in C-RASP but not by fixed-precision transformers, such as MAJORITY or certain regular languages such as bounded-depth Dyck languages (Yang et al., 2026b), which require a transformer's numerical precision to grow with the input length. On the other hand, as discussed above, Yang et al. (2026a) show that C-RASP cannot admit computable length generalization bounds, i.e., any threshold C satisfying (3) for all of C-RASP must grow faster in the size of the C-RASP formula (or Limit Transformer) than any computable function. This indicates that C-RASP is too broad as a target for quantitative length generalization bounds (Yang et al., 2026a; Zetzsche et al., 2026). It is an interesting question for future work whether tractable generalization bounds exist for some natural class between fixed-precision transformers and C-RASP.
- How do the results relate to Izzo et al. (2025); Chen et al. (2025)?
Izzo et al. (2025); Chen et al. (2025) provide quantitative length generalization bounds for C-RASP or Limit Transformers fragments with only one or two layers. On the one hand, fixed-precision transformers form a strict subset of C-RASP/Limit Transformers; on the other hand, our results apply to the multi-layer setup, where computable quantitative bounds for C-RASP are impossible (see Items 1 and 3).
- The paper studies ERM and G&C. Why not study optimizers like SGD or Adam?
Our work follows prior work (e.g. Edelman et al., 2022; Yang et al., 2026a; Chen et al., 2025; Izzo et al., 2025; Trauger & Tewari, 2024) in studying idealized learners abstracting away from gradient dynamics. ERM in particular is a highly popular standard approach for deriving learning bounds. Guess-and-check models the inductive bias of realistic training towards solutions occupying high volume in parameter space (Buzaglo et al., 2024), unlike ERM. Prior and concurrent work has provided evidence that parameter space volume is useful for understanding transformer generalization, finding that certain hard-to-learn functions occupy small volume in parameter space (Hahn & Rofin, 2024; Kövér et al., 2026; Zhu & Chiang, 2026); G&C is consistent with this by predicting easier generalization for functions occupying high parameter space volume. Neither G&C nor ERM should be considered full models of learning. For instance, for matrix factorization, Alexander et al. (2025) show that SGD can in some cases of matrix factorization generalize even better than G&C. Understanding gradient dynamics for general multi-layer transformers is extremely difficult. Developing quantitative generalization bounds for gradient-based training is a major task for future work; the 1-layer setup might be a tractable starting point.
6. Could the framework be extended to handle positional encodings?
Prior bounds for statistical generalization (not length generalization) of transformers use fixed absolute positional encodings (Edelman et al., 2022; Yang et al., 2026c; Lintilhac & Shaikh, 2026). That would also be possible to include in our setup, though one would need to understand their effects on the automaton structure. Learnable absolute positional encodings are harder to account for as they lead to rapid growth of the parameter count with the input length (as acknowledged by Edelman et al. (2022)), and are inherently undefined outside of the training length range. Huang et al. (2025a) impose translation invariance constraints to constrain the hypothesis space in their analysis.
Relative positional encodings can be easier to account for, as they do not involve an unbounded number of parameters. Yang et al. (2025a) show that ALiBi (Press et al., 2022) can be understood (in the context of C-RASP) as the addition of local predicates; we expect the effect on fixed-precision transformers to be very similar to the effect provided by local attention. We opt to analyze local attention, as it is nowadays popular in LLM design and has been rigorously formalized in the fixed-precision setup by Li & Cotterell (2026). RoPE (Su et al., 2024) is harder to capture theoretically in the context of length generalization: while it can be formalized in terms of modular predicates (Yang et al., 2025a) (which admit exact automata-theoretic treatment in an appropriate extension of our poDFA framework, with appropriate modifications to the length complexity term), this does not characterize conventional RoPE implementation, which rather behave like fixed-length backwards-lookup operators (Jerad et al., 2026), and may in fact impair empirical length generalization (Jerad et al., 2026).
7. Can the theory predict specific numerical bounds?
Our aim is to predict qualitative rates and the shape of the tradeoff between sample size and input length. Predicting numerical bounds faces the challenge that constants depending on the precision set will be extremely large at full-precision training. Constants involving it are in general needed (Appendix D.5). It is a highly interesting (and challenging) problem for future work to make bounds numerically tighter.
8. Are the teacher constructions for the three task families minimal?
For the Alternation Languages, Yang et al. (2025a) show that transformer depth for must be under a more expressive formalization of transformers (fixed-precision residual stream, unbounded-precision attention). Thus, our teacher family with , , is optimal up to rates.
For the Alphabet Languages, we found models hard to train when head count was < k, though we do not have a proof that an requires heads. However, a simple information-theoretic argument shows that is unavoidable; hence, the teachers do need to grow with . For the Induction Head Languages, the same argument applies as .
9. Why are there missing points in some experimental plots?
As detailed in Appendix H.2, across all configurations, each run over 10 random seeds, we strictly retain only the runs that achieve 100% training accuracy, consistent with the Guess & Check conditioning assumption. Notably, we observe in Figure 8 that Alternating languages can’t reach 100% training accuracy when the trained student has less than layers, as expected (Yang et al. (2025a)). Similarly, students learning from Alphabet languages with head count struggle to fit the training data (Figure 10).
- What is strict causal masking? Why assume it?
Strict causal masking means that attention heads cannot attend to the query position, but only to strictly preceding positions. Strict causal masking increases expressivity compared to non-strict causal masking (Li & Cotterell, 2025). We believe that our techniques and main results would equally apply in the non-strict-masking setup, though then applying to a less expressive model and correspondingly a smaller class of functions.
- The theoretical bounds include effects of both teacher size (the transformer representing the target function) and the student size (the transformers in the learner's hypothesis class). Experiments show strong effects of the teacher but weak effects for the student. Why?
Our theoretical predictions provide worst-case sufficient upper bounds on the test error; practical learning outcomes may be better both because the theoretical analysis may not be tight and because gradient-based learning may generalize better than the theoretical idealizations ERM and G&C. Indeed, it is a common observation that key techniques for proving statistical learning bounds show an overly pessimistic dependency on the student size: overparameterized neural networks often generalize very well, far better than is accounted for by capacity-based bounds that guarantee learning for ERM via uniform convergence (e.g. Nagarajan & Kolter, 2019; Zhang et al., 2017; Bartlett et al., 2021). The G&C analysis as developed by Buzaglo et al. (2024), that we adopt in Section 4.1, goes some way towards ameliorating this, as its dependence on the student size is substantially milder than for the capacity-based ERM bounds. Some work has provided generalization bounds that scale very mildly in the student size for simpler neural networks (e.g. Allen-Zhu et al., 2019; Arora et al., 2019), though the extension of such results to transformers will likely require new techniques.
- The bound C on the height of the difference automata is chosen as the minimum of two bounds (Lemma 3.1). When is which bound stronger? What do we know about tightness? involves the layer count, hidden dimension, and per-head dimension of both student and teacher; it is exponential in the per-head dimension and linear in the others. involves only the student layer count and the alphabet size; it is exponential in either and becomes polynomial in when the alphabet is fixed. Importantly, C is the minimum both, i.e., our results always apply to the smaller of both bounds. Thus, even if our theorems were stated just for or , they would remain valid; giving two versions strengthens our results.
The two bounds have strengths in different hyperparameter regimes. In the regime where models are very deep, is asymptotically smaller, and remains linear in and . In the regime where models are very wide, is asymptotically smaller, as it does not depend on the hidden dimension. The exception is when the number of heads also increases: then, the per-head dimension decreases, and may become more favorable.
Notably, only two quantities enter both bounds: and ; both bounds additionally require other quantities, but they can trade off which each other; e.g., as discussed above, taking into account can turn the depth dependence from exponential (in ) to linear (in ). We show the unavoidability of including the two quantities and in Appendix D.5.
B CONVENTIONS AND BACKGROUND
We specify the fixed-precision transformer model used throughout the paper, following Li & Cotterell (2025, Section 3 and Appendix B). Our main adaptations are that we retain the number of attention heads explicitly and that we drop layer norm as well as the attention score normalization (see Appendix E.5 for more). In addition, we distinguish tokenwise vectorial outputs from their word-level binary satisfaction framework.
B.1 FIXED-PRECISION ARITHMETIC
Fixed-precision set. A fixed-precision set or finite-precision set is a finite ordered set, constructed from a subset of the real numbers containing 0 and 1, and extended with the two infinite limits:
The set F is equipped with deterministic rules for rounding every elementary operation back to F, including overflow and underflow. When we study transformers on a fixed-precision set F, all scalar parameters and intermediate calculation values must belong to F. The precision convention is fixed and independent of the input length.
We use the natural extended-real rules whenever defined, in particular
More details about the edge cases stemming from the finite-precision arithmetic can be found in Li & Cotterell (2025).
B.2 TRANSFORMERS
Transformers read words directly; throughout, refers to the length of an input word. Differently to Li & Cotterell (2025), no end-of-sequence token is appended and transformer computations are performed only at the ordinary positions . This allows for a broader definition of transformers, with vectorial outputs at every position.
We use i, j for positions, for layers, d for the vectorial dimension and h for heads.
Definition B.1 (Fixed-precision transformer). Fix a depth , a width , and a number of heads with ; put . A fixed-precision transformer assigns to each of length an output
It consists of a token embedding, transformer blocks, and a pointwise output layer. Thus is defined at every ordinary position . We use for the class of such transformers with the corresponding parameter sizes.
Remark. All calculations below use the fixed-precision convention of Definition B.1.
Embedding. A map determines the 0-th layer , with
There are no positional encodings.
For and , we define the attention mechanism of head with input . We sometimes omit and from the notation for readability purposes.
Attention. An attention mechanism is a map . First, choose and set
The attention mechanism has a strict causal masking: the visible positions at are . For , compute the attention score
For a given position , we consider the maximum of queried attention scores at position and define the stabilized attention weights
The attention map is consequently defined as
As there is no well-defined attention score for the first index , we set .
We define by extension the head-agnostic attention mechanism as the concatenation of the attention heads, with
For each intermediate sublayer , we define a position-wise feed-forward mechanism applied to this sublayer. We consider feed-forwards with one hidden layer of dimension . We set for the base case, but it can be changed without repercussions as long as the statistical complexity guarantees given in Appendix E.1 are adapted accordingly. We consider the ReLU activation function.
Feed-forward. Define , applied independently at every one of the positions, as
where , , and the biases have matching dimensions. The parameters are shared across all positions.
Transformer block. Transformer blocks are simply the composition of an attention mechanism with a feed-forward, involving residual streams at each intermediate step. Layer norm is omitted; explanations on this architecture choice can be found in Appendix E.5. Consequently, each of the L transformer block is
Output Layer The output layer is the pointwise map O : given by
where and are the parameters shared across positions. Thus
Attention arithmetic assumptions. For the transformers considered below, we impose the following conventions, motivated by the positive-sum argument of Li & Cotterell (2025, Appendix B.2, Lemma B.5). Attention sums depend only on the multiset of summands, and inserting zeros does not change them. Nonnegative summands have a nonnegative sum, with absorbing. There is an integer , independent of input length, such that any such sum containing more than copies of a strictly positive finite value is . We write
Stabilized exponentials are nonnegative; zero weights contribute zero even for infinite values. An empty prefix or a softmax denominator equal to 0 or gives the zero head output. All remaining arithmetic cases are resolved deterministically.
C LOGIC
In this section, we define the past fragments of the linear temporal logic and of a two-variable first-order logic, introduced by Li & Cotterell (2025). These fragments are expressively equivalent and provide the link between temporal formulas and the partially-ordered structure studied below, that applies to transformers.
Fix a finite nonempty alphabet and a word . The positions are the ordinary token positions. We additionally use as a virtual logical endpoint: it is an unlabelled position after the word, used only to evaluate word-level formulas.
C.1 PAST TEMPORAL LOGIC
First we introduce LTL[P], the past fragment of the full linear temporal logic LTL[N, U, S, P] that provides several operators, such as next, until, and their past-time counterparts since and past. In our situation, the temporality refers to the positions of a given word, earlier positions thought as being in the past of later positions. The fragment LTL[P] uses only the past operator P, read “at some strictly earlier position”. The restriction to the past operator reflects the strict masking of the attention mechanism. We use its pointed formulas to describe tokenwise transformer outputs, and evaluate word-level formulas at the virtual endpoint.
Definition C.1 (Syntax and semantics of LTL[P]). The formulas of LTL[P] are generated by
For any position , where is the virtual endpoint, satisfaction is defined inductively by
Thus P means “at some strictly earlier position”. The connectives are Boolean abbreviations. In particular, means that holds at every earlier position, and is vacuously true at position 1.
Definition C.2. For a logic formula , set
Every atomic formula , , is false at the virtual endpoint. In particular, the formula holds precisely at this endpoint. We also have .
Example 1. For ,
The last formula selects an with no predecessor, hence checking for first symbol. Note that we nevertheless can’t express the language in LTL[P].
Lemma C.1 (Prefix invariance). For , , and ,
Proof. Induct on . Atomic predicates depend only on the current symbol, and P quantifies only over positions strictly before i.
C.2 PAST TWO-VARIABLE FIRST-ORDER LOGIC
The second logic that we introduce, a first-order logic, is equivalent to LTL[P]. The two-variable fragment uses only the position variables , which may be reused under quantifiers. We then further restrict to its past fragment : each new occurrence of a free variable must be upper bounded by the other, again reflecting strict causal masking. We first give its pointed formulas, then its sentences. Naming two positions with the variables and is in particular useful for describing an attention query and a key.
The syntax mirrors the construction of LTL[P]: formulas are built from atomic statements using Boolean connectives and one restricted way of looking into the past.
Definition C.3 (Syntax and semantics of ). For and variables , formulas are generated by
where is always defined by a boolean combination of two unary formulas; e.g. . As in Appendix C.1, positions range over , with the virtual endpoint. For a current position and, when needed, an earlier position , satisfaction is defined inductively by
A formula with one free variable is a pointed formula; a formula with no free variables is a sentence. We use an unbounded existential quantifier only to close a pointed formula into a sentence, as in . Boolean connectives and bounded universal quantifiers are abbreviations as usual.
Example 2. The sentence
defines . The innermost quantifier reuses for the -position: within its scope, the outer -position is no longer named. This is the first-order analogue of in LTL[P].
Remark C.1. For every fixed and every one-variable formula , we can express that at least, or exactly, earlier positions satisfy . Define recursively
The recursive definition reuses and at each level, so it remains in . These are finite formulas for each fixed threshold ; they do not add an unbounded counting operation to the logic.
Lemma C.2 (Temporal–first-order correspondence). The logics LTL[P] and PFO²[<] have the same expressive power (Li & Cotterell, 2025, Theorem 2.1). More precisely, every LTL[P] formula is equivalent at each position to a PFO²[<] formula with one free variable, and every such PFO²[<] formula has an equivalent LTL[P] formula; consequently, their sentences define the same class of languages. Under this correspondence, the basic one-position past test, where has only y free, is translated as
C.3 TRANSFORMERS AS LOGIC FORMULAS
Under the attention arithmetic assumptions of Appendix B.2, fixed precision lets us describe every coordinate at every ordinary token position by a pointed formula. This is the tokenwise version of the compilation of Li & Cotterell (2025); in particular, it does not use an EOS token.
Proposition C.1 (Transformer-to-logic). Let have output dimension . For every output coordinate and , there is a pointed formula such that, for every and every ordinary position ,
More generally, the same statement holds for every coordinate and value of each residual layer .
Construction. For every layer , coordinate , and , construct so that
The embedding case is immediate:
Every pointwise map is a finite lookup table. If its input coordinates are described by , its -th output has value precisely when
Thus projections, residual connections, feed-forward maps, and the final output map preserve the construction using Boolean operations only.
It remains to consider one attention head. Its query, key, and value vectors are pointwise maps, so the preceding display gives formulas for every . Denote the corresponding formulas by
for example, if and only if . The relevant query-key/value relation is the two-variable formula
For each current query position x, the maximum score, softmax denominator, and weighted value sum are finite case distinctions over the multiplicities of earlier positions y satisfying these relations. In particular, the required fixed thresholds vary with the query position and are expressed directly in by
and their exact-count Boolean combinations, as in Remark C.1. Let denote the resulting finite Boolean combination that selects the cases in which head outputs value in coordinate for query . Its output formula is
Fixed precision gives finitely many query cases, and the arithmetic assumptions of Appendix B.2 let us clip multiplicities at . Thus only finitely many cases are needed.
Consequently, attention produces formulas satisfying equation 21 for the next sublayer, and the pointwise steps complete the induction over . Applying the final output lookup formula equation 23 yields equation 20.
All formulas in Proposition C.1 are evaluated at ordinary token positions. By Lemma C.2, each has an equivalent pointed LTL[P] formula, using the PFO [<] presentation to keep the current position x and the earlier position y explicit.
C.4 PARTIALLY ORDERED AUTOMATA
Word-level formulas define languages, whereas the pointed formulas equation 20 describe an output at each token. The corresponding automata verifying the formulas are respectively DFAs and Mealy machines.
Definition C.4 (Deterministic Finite Automaton). A DFA is a tuple , with finite state set , initial state , accepting set , and transition function . By abuse of notation, extend to words by iterating over their letters:
It recognises the language .
For our results, we do not need the following Mealy machine construction, as we work with the difference function which is expressed by a poDFA. Nevertheless, Mealy machines describe individual transformers: they process the input left to right and emit an output vector at every position. We shall see also that the height arguments can directly apply on Mealy machines. In general, Mealy machines provide the opportunity to deepen the ordered-automaton analyses of the transformers outside of the student–teacher learning framework.
Definition C.5 (Mealy Machine). A Mealy machine is an automaton in the same way as the DFA C.4, but has a finite output alphabet , an output map and no notion of accepting states. On input , it emits
Intuitively, Mealy machines are automata such that their restricted behaviour, with respect to one output symbol, resembles a DFA.
Definition C.6 (Partially ordered automata). A DFA A or a Mealy machine M, is said to be partially ordered if reachability of its states is antisymmetric, equivalently if it contains no cycles but self-loops. Its height is the largest number of strict state changes along a run:
with the same definition for A. It is reduced if all states are reachable and if two distinct states have different future behaviour.
Remark. Different future behaviours for DFAs means that for any two distinct states representers , there exists a suffix such that, w.l.o.g. while . For Mealy machines, it similarly means that for some suffix concatenation, the future emitted sequences must disagree.
We recall the language-level correspondence established by Li & Cotterell (2025, Section 4 and Appendix C).
Proposition C.2. For every , the language is regular and its reduced DFA is partially ordered. The same holds for the equivalent word-level formulas.
Proof. Li and Cotterell show that the syntactic monoid of an LTL[P]-definable language is -trivial (Li & Cotterell, 2025, Appendix C): distinct monoid elements have distinct principal right ideals. The characterisation of Brzozowski (1980) identifies these regular languages exactly with those whose reduced DFA is partially ordered. The statement follows from Lemma C.2.
The states of this automaton have the usual right-context interpretation given by Myhill–Nerode (Myhill, 1957; Nerode, 1958).
Proposition C.3. Let A be the reduced DFA of a regular language L. For any ,
Thus its states are precisely the classes of prefixes with the same accepting continuations. For , these classes form the states of the reduced poDFA above.
Proof. Prefixes reaching the same state have the same acceptance decision on every continuation, by determinism. Conversely, two distinct states of a reduced DFA admit a distinguishing continuation. Every state is reachable, so this identifies the states with the right-context classes.
We now apply this correspondence to the tokenwise transformer formulas 20. Their past tests are recognised by poDFAs, and the current letter determines the output together with the states of these automata.
Proposition C.4 (Transformers as partially-ordered Mealy machines). Every transformer admitting the formulas equation 20 is realised by a finite partially ordered Mealy machine with output alphabet :
In particular, Proposition C.1 provides these formulas for the transformers of Appendix B.2.
Proof. Translate the pointed formulas into equivalent formulas by Lemma C.2, and let collect their distinct past subformulas . For each , Proposition C.2 provides a reduced poDFA recognising . After a prefix , its acceptance bit gives exactly the corresponding past test at the next token:
Indeed, both sides ask whether holds at some position in ; prefix invariance preserves those truth values.
Take the reachable part of the product of these poDFAs, with
For each current letter , evaluate by replacing with and each past test with , respecting Boolean connectives. Set to the unique for which this evaluation is true. Equation equation 20 ensures existence and uniqueness on reachable states. The output uses the state before reading , so the past remains strict. Finally, every component can only advance in its reachability order; their finite product is therefore partially ordered. If is empty, the product has one state.
This proposition establishes the inherent ordered structure of the transformers, using Mealy machines. We shall see quickly that the difference function between two transformers translates naturally in the other ordered automaton that we defined earlier: the poDFA.
Remark C.2. Each gives a Boolean output on transitions of this machine. Testing it at the last ordinary token need not define a poDFA language: would give , whose reduced DFA has a nontrivial cycle when . The poDFAs used above instead recognise past tests at the virtual endpoint. Importantly, a fixed Mealy state may still emit different vectors on different input letters.
To identify the states intrinsically, write
This is the sequence emitted on the continuation z after reading u; it excludes the outputs already emitted on u.
Proposition C.5. For a transformer satisfying Proposition C.4, there is a unique reduced Mealy machine, up to isomorphism. Its states are the classes of
and its transitions and outputs are
This reduced machine is partially ordered. Consequently,
Proof. Causality gives , with concatenation of output sequences. Hence implies equal outputs on and , so the displayed maps are well defined. Equal states of the finite machine in Proposition C.4 imply equivalent prefixes; our construction is therefore a finite quotient. All classes are reachable and distinct classes have a distinguishing continuation. In any reduced realisation, these same classes correspond bijectively to states, proving reducedness and uniqueness.
Finally, reduction preserves partial order: repeatedly traversing a nontrivial quotient cycle would force infinitely many state changes in the original finite partially ordered machine, a contradiction.
C.5 PAST SUBFORMULAS AND AUTOMATON HEIGHT
We relate past subformulas to the height of their associated automata. Word satisfaction is always evaluated at the virtual endpoint of Appendix C.1.
Definition C.7 (Subformulas). For , let Sub( ) be the set of its syntactically distinct subformulas, including itself. Recursively,
The past subformulas are those whose outermost operator is : .
Definition C.8 (Past profile). For any formula , we define the past profile of a word as the vector
It records which past subformulas hold after reading u, at its virtual endpoint .
Example 3. For , order the profile coordinates as . For distinct , the profiles of are respectively .
For a language , we note the left residual at a prefix with respect to a language as
Lemma C.3. Let . If
(PR)
then,
equivalently for every ,
Proof. Write and . By structural induction on , we show that, for ,
First, the atomic case compares the same suffix symbol, or the two virtual endpoints; hence the equivalence holds. The Boolean cases follow immediately.
Now consider . For ,
The first case says that already has a witness in , which is stored in the profile. The second says that it has a witness in the first positions of . By (PR), the first cases agree; by the induction hypothesis, so do the second. Thus the equivalence holds. Taking and proves the claim.
Corollary C.1. Let and let be its minimal DFA. If two prefixes have the same past profile, then they reach the same state of .
Proof. Lemma C.3 gives us that for every suffix ,
This is precisely the characterisation of Proposition C.3.
Definition C.9. For , write when
Write when and .
Lemma C.4. For all ,
Proof. Let and suppose that . By definition, there is a position such that . By Lemma C.1, ; also . Hence , so . This holds for every coordinate.
Lemma C.5. Let S be a finite set and let
under the coordinate-wise order. Then .
Proof. For every , let be the support of , namely the set of coordinates on which is 1. The strict inequalities give
Every strict inclusion increases cardinality by at least one. Thus there are at most strict inclusions, proving .
Lemma C.6. Let be a sequence of prefixes such that, for every , there is a word satisfying
Then
Proof. By Lemma C.4,
If two consecutive profiles were equal, Lemma C.3 would imply , contrary to assumption. Hence each displayed relation is strict. Lemma C.5, applied with , gives the result.
We finally combine the previous definitions and results for the following result. In particular, the bound from Eq. 2 is an application of this theorem:
Theorem C.1 (Past subformulas bound automaton height). For , the reduced DFA of satisfies
Proof. The bound follows from Lemma C.6.
We can directly convey the above result to the Mealy machine. Intuitively, our transformers from Appendix B.2 are the Mealy machines made of the pointed formulas given in 20.
Corollary C.2. For a finite family of pointed LTL[P] formulas, the reduced Mealy machine emitting their truth values at each token similarly satisfies
Proof. For the Mealy bound, store the shared past profile over . Together with the next letter, it determines the current truth values and the updated profile: the bit for becomes its old value OR the current truth of . Thus these profiles form a Mealy realisation. Each bit changes at most once, giving the stated height; reduction cannot increase it.
D LENGTH GENERALIZATION
For two FPTs given by , sharing , , and output dimension , the difference function from Section 3.1 is
We give two height bounds for its reduced poDFA . We use the arithmetic assumptions of Appendix B.2, with and .
D.1 BOUNDING THE HEIGHT WITH PAST SUBFORMULAS
We count the past subformulas needed to describe one transformer's outputs, then combine the two families into a formula for the difference function.
Lemma D.1 (Simultaneous output representation). Under these arithmetic hypotheses, let have output dimension , and put . There are formulas , for and , such that, for every and ,
Their shared collection of distinct past subformulas satisfies
Proof. Follow the layerwise construction of Appendix C.3, now directly in LTL[P]. At layer 0, the embedding coordinates are described by
Moreover, if a pointwise map sends input coordinates with values to , then its output value is described by the Boolean combination
Thus projections, feed-forward maps, residuals, and the output map add no past operators. Only attention does.
Fix a layer and a head , suppressing these indices below. For each key vector , coordinate , and value , let describe the unary condition and . These pointwise predicates add no past operators. Writing for their unary form, we describe the clipped counts
using the threshold tests
By Remark C.1, each successive at-least threshold adds one outer P to the conjunction of with the previous threshold. Thresholds share their shorter expansions, and exact counts are Boolean combinations of successive thresholds (threshold 0 is ). Hence all tests for one add at most distinct past subformulas.
Fix an output coordinate . The current query and the clipped-count vector
determine the head output. Indeed, these data identify the present keys, the maximum score, and each stabilized exponential . If some , or if
then the denominator overflows and the head output is zero. Otherwise, every type with a positive exponential has its exact multiplicity recorded, while zero terms contribute nothing. Multiset summation then determines the denominator, the weights, and the weighted value sum. Hence, for a finite lookup function ,
Expanding this finite lookup into Boolean cases reuses only the threshold tests above, and so introduces no further past subformulas.
There are
key-coordinate-value types per head. Thus, if denotes the past subformulas available after layer , then
Summing this bound over the layers proves equation 30. All output coordinates and all reuse the same collection, so the final output map adds no factor.
Remark D.1. We count distinct past subformulas, not occurrences or Boolean formula size. A general need not translate into a single P-subformula. Here all counted predicates depend only on ; the current query is handled outside the past operators by Boolean cases.
The predicates describe the outputs of the Mealy machines from Appendix C.4. Comparing these predicates and checking for a mismatch anywhere in the word gives the difference function.
Proposition D.1 (Difference function as a logic formula). Let , be student and teacher transformers satisfying the preceding hypotheses, over the same alphabet and precision set, with the same output dimension . Using the formulas of Lemma D.1, define
Then
and
Moreover,
Proof. At each token, holds exactly when an output coordinate differs. Thus , evaluated at , expresses (and is false on ). Boolean operations add no past subformulas:
This proves the count. Causality preserves an existing mismatch under right concatenation, proving persistence.
Corollary D.1. The reduced DFA of is partially ordered and satisfies
If is not identically zero, has a unique accepting state, which is absorbing.
Proof. Apply Proposition C.2 and Theorem C.1 to , then use equation 34. Every accepted prefix has residual by persistence, so all accepting prefixes reach the same absorbing state by Proposition C.3.
Remark D.2 (Mealy-machine interpretation). Let be the reduced Mealy machine of . The shared-profile argument of Appendix C.5 gives . Running the two machines in parallel until their outputs differ gives
Each strict product transition advances at least one component; entering the absorbing bad state adds at most one. Reduction cannot increase height.
D.2 BOUNDING THE HEIGHT WITH TEMPORAL PROFILES
We bound the same difference-function poDFA using past nesting depth. This removes the exponential dependence on and gives a polynomial bound in depth, of degree .
Definition D.1 (Past depth and temporal profiles). The past depth of a formula is defined by
For , write and define
where is a fixed symbol. Unlike prof , the profile does not depend on a particular formula: it records which (letter, lower-depth-profile) pairs have occurred.
The profile records which letters have appeared in which past contexts. For fixed , there are finitely many profiles, and higher profiles determine all lower ones by forgetting their deepest context layer. For ,
Thus profiles grow by inclusion and update deterministically from the next letter. Structural induction shows that determines every formula of past depth at most at position . At the virtual endpoint, all letter atoms are false, so alone determines truth. Equal profiles therefore give equal residual languages.
Lemma D.2 (Counting strict profile changes). For every , along the prefixes of any word, changes at most
times. Consequently, if , the reduced DFA of has height at most .
Proof. For each , define its next-change rank after by
This is finite because distinguishes from at the virtual endpoint. In particular,
Initially, . If , the ranks update as
A letter not yet seen has rank 1. Otherwise, comparing with the prefix before its last occurrence shows that its rank is one plus the first depth at which the intervening profiles differ. Appending a changes profiles from depth t onwards, which gives equation 40.
For fixed k, let
If , Equation equation 40 replaces one entry by , leaves all entries below fixed, and leaves every other altered entry at least . Hence
If , both and are unchanged. Since there are exactly
nondecreasing s-tuples in , the profile changes at most times. The profile automaton recognises ; reduction cannot increase its height.
This counts profile changes along a run, not the total number of profiles.
Lemma D.3 (Past depth of transformer outputs). Under the stated assumptions, a transformer with output dimension admits coordinate/value formulas satisfying
for every , , and .
Proof. In the construction of Lemma D.1, embeddings have depth zero and pointwise maps do not increase depth. At each layer, the unary key/value predicates inherit the previous layer's depth. Counting their occurrences up to adds at most nested past operators; attention then uses only Boolean combinations of these tests and the current query predicates. Each layer therefore increases depth by at most .
Corollary D.2. Put . The reduced poDFA of the difference function satisfies
Proof. Set . Using the output formulas of Lemma D.3 in equation 32 gives . Construct a DFA that stores until the first mismatch. On reading , determines at the new position: if true, enter an accepting absorbing state; otherwise update . This recognises .
The profile grows by inclusion, so the DFA is partially ordered. Lemma D.2 allows at most profile changes, and entering the accepting state adds at most one. Reduction preserves partial order and cannot increase height.
For fixed and , this bound is polynomial in , of degree , and independent of widths, head counts, and output dimension. It bounds automaton height, not the size of the representing formulas.
Remark D.3 (Mealy-machine interpretation). The same profile , together with the next letter, determines all outputs of T. It therefore also realises T as a Mealy machine, giving
Summing the two individual bounds via equation 35 also bounds . The poDFA proof above is sharper because both transformers share on their common input.
Remark D.4. We remark that Masopust & Thomazo (2015) showed a related bound (also in terms of a binomial coefficient) on the height of the minimal DFA representing piecewise testable languages; such languages are expressible by fixed-precision transformers. Our result differs in applying to difference automata for general fixed-precision transformers, and in expressing the bound in terms of the size parameters of those transformers.
D.3 DETERMINISTIC LENGTH GENERALIZATION
Either height bound from Corollary D.1-D.2 gives a deterministic length cutoff: any nonzero difference function between two transformers has its behaviour controlled by height of its poDFA. Taking the smaller bound yields the following result.
Lemma D.4 (Deterministic length generalization). Let and satisfy the preceding hypotheses, with as in Remark 2.1. Using the arithmetic constant from Appendix B.2, set
For , agreement on all words of length at most implies agreement on every word:
Proof. Corollaries D.1 and D.2 give . If , let be a shortest word accepted by . Its run contains no self-loop as deleting the corresponding letter would give a shorter accepted word. Every letter therefore induces a strict transition, so , contradicting agreement on .
D.4 PROBABILISTIC LENGTH GENERALIZATION
We now show that low error up to a sufficiently large cutoff persists at all larger lengths. The argument is automata-theoretic: a random input makes uniformly positive progress through a partially ordered DFA until it reaches an absorbing state.
Let be a partially ordered DFA, with bad states , and let . Let be an integer upper bound on . For the difference function, take , with its accepting states and from equation 43. For an exact length , and for the distribution uniform over all words of length at most , respectively, write
Thus is the bad-state probability at one fixed length, whereas is the bad-state probability when every word of length at most K is equally likely. The mass that assigns to length K is
Write for the absorbing states of , namely those satisfying for every . All other states are called transient.
Lemma D.5 (Absorption tail). Let . If
(P)
then a uniformly random word ends in a transient state with probability at most .
Proof. If , the initial state is absorbing and the claim is immediate. At every transient state, at least one letter makes a strict transition. Count a step as successful if it makes a strict transition or the run was already absorbed. Each step has conditional success probability at least , so sequential coupling shows that the total success count stochastically dominates . If the run is still transient after steps, all successes were strict transitions and there were fewer than of them. Hence
We use Chernoff's inequality to obtain an explicit sufficient cutoff.
Put and . The displayed condition implies . With , the multiplicative Chernoff lower-tail bound gives
It remains to make the exponent at least . This is equivalent to
The larger root of the left-hand quadratic is
Condition (P) is exactly the assertion that is at least this root. Hence , and the preceding display is at most .
See Wikipedia, “Chernoff bound: Multiplicative form (relative error)”.
Theorem D.1 (Probabilistic length generalization). Let . Suppose that K satisfies (P) and that
Then the probability of reaching a bad state remains small both at every fixed length and over all words of length at most :
Proof. The bad absorbing states at time K account for at most the bad probability conditioned on length K. Hence
(A)
By Lemma D.5, the run is still transient at time K with probability at most . If a word of length ends in a bad state, then at time K its run was either transient or already in a bad absorbing state. Therefore, by (A),
The same bound holds for by (A). Finally, is a weighted average of and the fixed-length errors ; each of these terms is strictly below . Thus .
Remark D.5. Keeping the alphabet dependence in the proof gives . The upper-bound coefficient is 3 for binary alphabets and approaches 2 as grows; this does not assert that the bound is attained.
D.5 DEPENDENCE OF CHAIN LENGTH ON L AND F
We construct difference functions with unbounded poDFA height by varying either precision or depth, with the other architectural sizes fixed. Throughout, , and outputs are scalar.
Implementation convention. Both constructions use one head and arithmetic satisfying Appendix B.2, with attention sums rounded after summation.
To select specific positions with attention, we operate the following way. Choose a negative score such that rounds to zero. In particular, setting the convention that , can take the value . Selected positions then receive score 0 while unselected positions receive score and value 0. Thus attention averages the selected values unless the denominator overflows.
Both constructions keep track of a fixed number of Boolean values, such as whether a position is selected. We represent each Boolean value using two coordinates: for true and for false. A separate coordinate stores the attention output.
D.5.1 NECESSITY OF PRECISION DEPENDENCE
We create a family of framework where we increase precision while keeping both transformer architectures fixed. For each sufficiently large integer k, use the precision set
Here contains a bounded number of additional values needed for the attention scores and the Boolean encoding above, including its pointwise computations. Thus grows linearly with . Choose the arithmetic so that positive attention sums exceeding overflow to . Increasing therefore allows uniform attention to average more positions before overflowing.
Proposition D.2 (Precision can force linear height growth). For the precision structures above, there are pairs of transformers with fixed depths , fixed widths, and , whose reduced difference poDFAs satisfy
Thus the height can grow linearly with precision-set size while the architectures and alphabet remain fixed.
Proof. Both transformers first apply uniform attention with value 1 at every position. The resulting bit is
The teacher retains this bit through its second block. The student's second block attends only to earlier positions with , using value , and takes the Boolean OR with the current bit. At most k positions are selected, so this attention never overflows. Consequently,
The reduced DFA of counts length up to , then remains in an accepting sink. Its states are distinct: counts are distinguished by a suffix of length . Its height is therefore , giving here. Only Boolean attention outputs occur in this construction, so the encoding and feed-forward width are independent of . Their pointwise computations and the score maps require only a bounded number of additional scalar values, as claimed for .
Thus no height bound over arbitrary precision structures can ignore its precision set cardinality .
D.5.2 NECESSITY OF LINEAR DEPTH DEPENDENCE
Proposition D.3. For one fixed precision structure , there are transformers of depth , with fixed width and one head, whose difference poDFAs against an always-zero transformer have height .
Proof. Fix a cutoff and an adequate arithmetic with the same overflow as in the previous proposition. Its two-layer student computes . Taking the complement gives a marker .
Two further layers move a unique marker forward by one position. Indeed, suppose
Thus, is 1 only at position j.
The first added layer records whether the marker has appeared at the current position or earlier:
The second layer attends uniformly to the earlier positions selected by . At position , these are the positions . But only position has value ; all other selected positions have value 0. Hence the attention output is
In particular, holds exactly when . Setting
therefore creates a unique marker at position . This shift uses fixed parameters and can be repeated for every .
Starting from , and applying m - 1 shifts, uses 2m layers and gives
With , , , and fixed, this proposition proves the necessity in, at least, a linear dependence on depth in the bound on the height of a difference transformer.
E DATA COMPLEXITY BOUND
This appendix collects the statistical (in-distribution) generalization bound underlying Proposition 4.1. The core argument is imported from Rizvi-Martel et al. (2026), which studies the same student–teacher setting for single-output transformers; in order to keep the present paper self-contained, we restate the main result in our notation and sketch its proof (Appendix E.1), pointing the reader to Rizvi-Martel et al. (2026) for full details. We then describe the two modifications needed for our setting, stemming from the absence of attention output projection matrices in our transformers (Appendix E.2) and the fact our transformers produce vectorial outputs at every position (Appendix E.3). Furthermore, we contrast the resulting G&C bound with the analogous bound for ERM (Appendix E.4) and discuss the statistical bounds on transformer architectures that include attention score rescaling or layer norm (Appendix E.5).
Throughout, we write and for the per-head dimensions, and for the hidden widths of the feed-forward blocks. All parameters take values in the finite set , so that a transformer in has finitely many configurations and G&C samples uniformly among them.
E.1 MAIN STATEMENT AND PROOF SKETCH
We say that a student is teacher-equivalent (TE) to on if . Let denote the probability that a uniformly random is TE. The following is the general form of the G&C bound, as given by Rizvi-Martel et al. (2026), where the considered transformer class uses output projection matrices after attention, and assumes only one output value per word instead of our vectorial outputs at every position.
Theorem E.1 (Statistical generalization for G&C; adapted from Theorem B.1 and Corollary B.1 of Rizvi-Martel et al. (2026)). Fix and . Let be a teacher and a hypothesis class with
Then
where
Consequently, if is obtained by the G&C learner on an i.i.d. sample S of N strings from with
then, with probability at least over S and the draw of ,
One then has under the standard conventions and .
The output matrices term is removed from B in Appendix E.2 and the readout term required for per-position outputs is added in Appendix E.3; Proposition 4.1 is the combination of Theorem E.1 with these two modifications and with the ERM bound of Appendix E.4.
Proof sketch. The proof has two ingredients.
From to a sample-complexity bound. The main lemma of Buzaglo et al. (2024) states that, for any finite hypothesis class and any 0/1 loss, if the probability of sampling a TE hypothesis under the prior is , then G&C generalizes to error below with probability at least as soon as . Hence it suffices to lower bound , and yields the stated bound.
Lower bounding by constraint counting. We exhibit one explicit set of parameter values such that any student agreeing with them on those coordinates (and arbitrary elsewhere) computes exactly the function of . Since parameters are drawn uniformly from , this event has probability exactly , and is at least as large. The construction proceeds layer by layer and maintains the invariant that, at every position, the residual stream of the student has the form , where is the residual stream of the teacher and the remaining coordinates are zero.
• Embedding. The first embedding coordinates of every token are given by the teacher's embedding, and the bottom coordinates are set to zero; this contributes constraints.
• Teacher layers ( ). For each of the teacher heads, the top-left blocks of the student's , , are set to the teacher's matrices, and the blocks of , acting on the extra head coordinates are set to zero; since the query is zero on these coordinates, may be left free there. For the remaining heads only the top block of is zeroed, so that they contribute nothing to the teacher coordinates. The output projection and the feed-forward block are constrained analogously: their teacher blocks are copied and the blocks that would leak into (or read from) the extra coordinates are zeroed, including the biases. This preserves the invariant and contributes the term of ; see Lemma B.2 of Rizvi-Martel et al. (2026) for the block matrices.
• Weak-identity layers ( ). The extra layers need only preserve the top coordinates, not the full residual. Setting the first columns of the attention output projection, of the second feed-forward matrix, and of the corresponding bias to zero suffices; the bottom coordinates may then take arbitrary values without affecting the teacher block. This contributes ( ) constraints per layer, which is the last term of (Theorem B.1 of Rizvi-Martel et al. (2026)).
Summing the three contributions gives , and the asymptotic form follows by substituting and .
E.2 ABSENCE OF OUTPUT PROJECTION MATRICES
Unlike the architecture in Rizvi-Martel et al. (2026), neither our teacher nor our student has an attention output projection. In the first layers, there is therefore no output matrix to copy or pad with zeros. This removes constraints per layer.
For each of the remaining weak-identity layers, the source construction zeros the part of the output projection that writes to the teacher coordinates. We instead zero the rows of the value matrices that produce these coordinates. There are such rows in total, each with entries. The residual connection then preserves the first dimensions, and the count of fixed parameters on this layers is exactly as before.
We hence have for this distinction, a reduced constraint count
E.3 PER-POSITION OUTPUTS
Theorem E.1 is stated for a single output per string, as in Rizvi-Martel et al. (2026). transformers in FPT instead return a vector of dimension at every position through the pointwise affine output layer O (Definition 2.1). We write and for the student's output weights and bias, and , for the teacher's. Teacher-equivalence is understood in the strict per-string sense: is TE if, with probability one over , its output matches the teacher's at every position. The corresponding empirical loss on a sample is
which is -valued per string and therefore fits the G&C lemma of Buzaglo et al. (2024) without change.
The constraint-counting argument carries over verbatim: the construction of Appendix E.1 preserves the teacher’s residual stream in the top coordinates at every position, not only at the last one. The only additional constraints come from the output layer. Writing the student’s final residual stream at position as , matching the teacher’s output at every position requires the first columns of to equal , the remaining columns to be zero (so that does not leak into the output), and . This fixes every entry of the output layer, adding exactly constraints, so that the constraint count becomes
Since is fixed by the task, this term is subleading whenever , and the asymptotics of Theorem E.1 are unchanged.
E.4 COMPARISON TO ERM
An analogous sample-complexity bound holds under Empirical Risk Minimization, obtained by a standard uniform-convergence argument over the finite hypothesis class (Appendix B.1 of Buzaglo et al. (2024)). Counting parameters layer by layer under and ( for the embedding layer, for the query, key and value matrices, for the two feed-forward matrices, and for the biases), the total parameter count of the student, and hence the ERM complexity term, is
so that ERM generalizes to error below with probability at least whenever
Contrasting this with from Theorem E.1, ERM scales with the square of the student width, whereas G&C scales with the product of the student and teacher widths; when the teacher is genuinely narrow ( ), G&C therefore saves a factor on the order of over ERM. This narrow-teacher advantage is intrinsic to the volume-based argument underlying G&C, and is not captured by capacity-based bounds (Edelman et al., 2022; Trauger & Tewari, 2024; Yang et al., 2026c).
E.5 NORMALIZATION WITHIN TRANSFORMERS IN FIXED PRECISION
Our transformer model is inspired by Li & Cotterell (2025), but omits the attention-score factor and post layer normalization (Ba et al., 2016). Layer normalization and attention-score scaling can be seamlessly included in the ERM analysis of Appendix E.4. The argument counts the parameters of a finite hypothesis class and does not require a teacher–student embedding. Under the same realizability assumption, it is enough to include the learned normalization parameters in this count. As their number is linear in , the leading order of the ERM bound is unchanged.
Accounting for this factor and the normalization in the constructive Guess & Check argument of Rizvi-Martel et al. (2026) would require extra technical conditions on the fixed-precision arithmetic; by omitting them, we keep the assumptions on simple. The same counting method applies with normalization whenever the embedding preserves the teacher's computation exactly. But since both normalizations depend on the model dimensions, the embedding of the teacher in a larger student requires additional conditions on the fixed-precision arithmetic, as described below.
Attention-score scaling. The embedding pads the teacher's queries and keys with zeros to preserve their dot product. With attention-score scaling, the teacher and student divide this product by and , respectively. In infinite-precision arithmetic, these factors can be matched by rescaling the copied query projection matrix:
To use this rescaling in fixed precision, every entry of must belong to . Representability of is needed, but is not enough, as rounding within the projections, dot products, and score division can break the equality. Additional assumptions are hence required, ensuring that this rescaling preserves the rounded scores and controls the overflow and underflow.
Layer normalization. For a vector x, layer normalization takes the form
where and are the mean and variance across coordinates, and are learned vectors, and is a stabilization constant. Absorbing this operation into the embedding requires accounting for the mean and variance of the added coordinates. Writing zero padding as for and , we have in infinite-precision arithmetic,
The change thus depends on the input x, and cannot generally be corrected by fixed and . More elaborate padding schemes would need to preserve the teacher's normalized coordinates through every sublayer. Any compensating parameters must also be representable in F, and the correction must survive rounding for every residual vector the teacher can produce. Extra student layers pose a further problem: setting their attention and feed-forward to zero still leaves layer normalization acting on the residual. Thus, including layer normalization in the construction requires conditions on both the encoding and the arithmetic. Given the technical complexity, we prefer to formalize transformers without layer normalization for our results.
Remark E.1. These constraints concern our particular construction (Appendix E.1), rather than G&C itself. For ERM, the statistical bound applies directly to the normalized architecture, and Theorem 4.1 and Theorem 4.2 hold with the updated ERM statistical bound.
F MAIN THEOREM AND TRADEOFF
F.1 MAIN THEOREM
The main result given by Theorem 4.1 simply combines two results: sufficiently many samples give small error on , and a sufficiently large cutoff extends that guarantee to every with .
Theorem F.1. Fix , , and . Let the student and teacher satisfy the learning framework of Remark 2.1, and the arithmetic assumptions of Appendix B.2. Let be an admissible G&C complexity term from Proposition 4.1 and set as in equation 2.
If is given by the Guess & Check procedure, agreeing with on i.i.d. samples from , with
and
then, with probability at least over the training sample and the G&C draw, we have
Proof. By Proposition 4.1, the condition on N gives, with probability at least ,
Fix any student in this event. Its difference function’s poDFA has height at most C by Corollaries D.1 and D.2. The condition on K is exactly the cutoff required by Theorem D.1, which gives for every . This implication is deterministic once the student is fixed, so no additional failure probability or union bound over M is needed.
Hidden dependencies. Under the feed-forward width convention, a sufficient sample budget has order
This retains the embedding and output-layer terms; the implicit constants are those of the data-complexity bound. Additionally, for , , so the sufficient length cutoff from Theorem D.1 is .
For ERM, the same proof applies after replacing the sample condition by the ERM condition in Proposition 4.1; the length cutoff is unchanged.
F.2 MULTIPLICATIVE UPPER BOUND
We prove Theorem 4.2 from Section 4.3. For this, we importantly show that, whichever absorbing state the automaton eventually reaches, it has probability at least of reaching that state within K steps. This lets us control eventual disagreement using the disagreement already visible at length K.
Theorem F.2 (Joint generalization bound in sample size and length). Fix , , and integers and . Work under the learning and arithmetic assumptions of Remark 2.1 and Appendix B.2. Let be the teacher and let be obtained by G&C from a labeled sample , where . Let be an admissible G&C complexity term from Proposition 4.1, let be the uniform height bound in equation 43, and set
If , then, with probability at least over and the draw, for every integer ,
For ERM, the same statement holds with an admissible ERM complexity term from Proposition 4.1; the probability is then only over S.
We first establish the bound on the absorption time of an infinite run of letters.
Lemma F.1. Let A be a reduced poDFA of height at most C, driven by an infinite stream of i.i.d. uniform letters from . Write for its state after n letters, T for its first hitting time of its absorbing state, and the absorbing state eventually reached. Then and for every absorbing state z,
Proof. At each transient state, the probability of leaving is at least 1/s, so absorption must occurs within C strict transitions. A self-loop leaves the state unchanged, and future letters are independent; thus conditioning on Z = z does not change the self-loop probability. Even under this conditioning, each step before absorption therefore makes progress with probability at least 1/s. By coupling with independent Bernoulli(1/s) trials, absorption is no slower than obtaining C successes, giving
Proof of the theorem. For a fixed student, write
We have by convention that disagreement means a mismatch at any output position, so the difference poDFA has at most a unique absorbing accepting state , with its height bounded by .
Run on an i.i.d. uniform stream, with as in the lemma, and set the probability that the ultimate absorbing state is the disagreement one. Since is absorbing,
Moreover, persistence of disagreement makes nondecreasing, so for every M,
To connect the exact-length quantity to the training distribution, observe that
Therefore , which implies
Finally, Proposition 4.1 gives with probability at least , as we can apply the proposition with . Substituting into equation 48 proves the result simultaneously for every . The ERM version is obtained identically, thanks to .
The factor measures how much of the eventual disagreement is already visible at length K and the factor accounts for drawing training words uniformly from all words of length at most K.
F.3 TRADEOFF BETWEEN LENGTH AND DATA COMPLEXITY
We give the calculations behind the tradeoff discussed in Section 4.3 and its implications for the allocation of a given token-budget. Keep the notation of Theorem F.2, with , , and . Fix a target error and confidence . The theorem gives the sufficient sample size
Here is the limit sample size as , that would still satisfy the target error . Halving the target error doubles the 's and so it does for , at every length, without changing its dependence on .
Three length regimes. The following table summarizes the sample sizes certified by the bound and already discussed in Section 4.3.
Proposition F.1 (Sample size as a function of length).
Thus increasing length from C to sC reduces the sufficient sample size by a factor of at least .
Proof. For , , while . At , the binomial has integer mean , which is also a median (Kaas & Buhrman, 1980, Theorem 1), so . The last row follows because increases to one.
How to invest a fixed token budget. Write Budget = NK for the token budget, an upper bound on the total number of tokens when sampling from . We keep K integral and ignore rounding of N. Substituting into the theorem gives
with probability at least . Thus the best allocation must maximize .
Corollary F.1 (Optimal token allocation). Suppose Budget . The smallest value of the upper bound in equation 51 is
attained by
Moreover,
In particular, choosing gives an error bound within a factor two of the optimum.
Proof. Only depends on the allocation. For , Markov's inequality gives
Conversely, , so choosing gives .
There is no closed form formula to find the optimum, but the exact optimizer can be found by checking only : every has and cannot improve on . At , the same ratio is . For , choosing therefore improves the error bound at a fixed token budget by a factor of at least .
An explicit choice of . For , define
The Chernoff calculation in the proof of Lemma D.5, with tail probability , gives . If the budget allows , let be the bound obtained with and . Then
Hence is asymptotically optimal as . The simpler choice gives the uniform factor-two guarantee above. This supports the choice of the bound on in the joint statistical and length generalization main result given by Theorem 4.1.
Least token budget for a target error. The same calculation can be read in reverse. By equation 49, the least token budget certified for error is
Choose a minimizing length K and take . Thus both problems—minimizing error at a fixed budget and minimising budget at a fixed error—reduce to the same ratio optimization.
F.4 ADAPTIVE MAIN THEOREM: UNIFORM TRAINING LENGTH
We adapt Theorem 4.1 to the distribution that first chooses a length uniformly, then draws a word of that length:
The sample-size condition is unchanged. For the length transfer, we use the fact that at least half of the sampled lengths are at least .
Corollary F.2 (Main theorem for uniform training lengths). Fix , , and . Use the learning and arithmetic assumptions of Theorem F.1, with the same complexity term and height bound . Let be obtained by from a labeled sample . If
and
then, with probability at least over S and the G&C draw,
Proof. The statistical argument of Proposition 4.1 applies to any input distribution, so the condition on gives error at most on with probability at least . Fix a student in this event and write
Since contains at least half the lengths,
Hence some satisfies . The difference poDFA has height at most . By the condition on and Lemma D.5, it is still transient after letters with probability at most . Any disagreement at a later length either already occurred by , or the run was still transient then. Thus for every . Averaging gives, for every ,
This holds for all M on the same statistical event.
As usual, for ERM, use its sample-size condition from Proposition 4.1. Here, the see that the bound given on is roughly two times larger. However the rates do not change, and as in Theorem 4.1, the sufficient length remains .
Remark F.1. The multiplicative tradeoff bound from Theorem 4.2 also extends to . At least half of its mass lies on lengths between and . Thus, the same averaging argument finds a length in this interval with error at most twice the average error. Repeating the proof of Theorem F.2 therefore gives a bound of order
on every later error. The factor 2 replaces the factor as it represents the mass of the upper half of the length range.
G EXTENSIONS
G.1 LOCAL ATTENTION
We keep fixed precision and strict causal masking. Each head is either global or local; a local head at position attends only to , for a common window size . Let have depths and the same output dimension. Set
We consider disagreement at ordinary token positions,
By causality, implies . We do not include disagreement evaluated only at EOS.
Definition G.1 (Cache-poDFA cascade). Let retain the last symbols of . A cache-poDFA cascade is a DFA with states , initial state , and transitions
where is a finite partially ordered set. Its accepting states are those with , for a flag satisfying . The ordered component is a poDFA over : it reads the cache together with the next letter. Let be an integer bound on the number of strict changes of q along a run, including a change of the disagreement flag.
Proposition G.1 (Representation of disagreement). The language is recognized by a cache-poDFA cascade of radius R. In particular, the full DFA need not be partially ordered.
Proof. Write to mean that held positions earlier, with value false if that position does not exist. The finite-precision compilation of Li & Cotterell (2026) gives a pointed formula for disagreement at the current position. A local head uses the current representation and the previous representations, adding shifts with . Global heads introduce only Boolean operations and , as in Appendix C.3. Thus the total shift along any formula branch is at most .
Move every shift inward using
The resulting formula, still denoted , uses local atoms , with , Boolean operations, and . The cache and current letter determine all local atoms; also records which earlier positions exist.
Suppose symbols have been read, and the next symbol is . For each past subformula , store
This is the truth of before reading . The cache is .
For any normalized subformula , define as its truth value at the current position. With and positions in ca numbered from 1 to , compute it recursively as follows:
Here , , and is the identity.
The state update is
These updates record whether , or a disagreement, has occurred. Both use the old profile z, so past operators exclude the current position.
Starting from , induction gives the stated meaning of and . Each bit changes only from 0 to 1, so is partially ordered. Let count the distinct past subformulas before moving the shifts inward. Each gives at most shifted versions; adding the disagreement flag gives
Remark G.1 (Scope of the height bound). This construction extends the bound on the count of the past subformulas from Appendix D.1 which stems the threshold in Eq. 2. Each shifted past test changes from false to true at most once, so counting these tests bounds the ordered component's height. In particular, setting the cache window to 0 retrieves the global attention bound. However, we cannot extend the temporal-profile bound of Appendix D.2 with this method. Indeed, temporal profiles over do not record the recent suffix needed by local attention. Adding the cache changes the alphabet, so the original profile bound no longer applies.
Definition G.2 (Settled states and absorption). A reachable state is settled if either (disagreement has occurred), or every continuation keeps (disagreement is impossible). Otherwise it is transient. Merge the first kind into a bad sink and the second into a safe sink. Both sets are closed under transitions, so this preserves the language. The merged states are absorbing; let be the first time the run reaches either of them.
Both transformers share the same suffix cache, which depends only on the input. The cache may keep changing after the outcome is settled. If the ordered component can never advance, the state is settled.
Lemma G.1 (Progress in a fresh block). From every transient state, some word of length at most strictly advances the ordered component. Consequently, for independent uniform input symbols,
Proof. A transient state admits a continuation causing disagreement. Take a word ending at the first strict advance of the ordered component. If , use . Otherwise use its final symbols. Either this shorter word advances the ordered component within steps, or those steps restore the cache just before the last symbol of , while stays fixed. The last symbol then causes the same advance. This word has length and occurs at the start of the next block with probability , given any history.
Theorem G.1 (Absorption tail with local attention). For an i.i.d. uniform input stream, every integer satisfies
In particular, for , write . The right-hand side is at most whenever
This gives the sufficient scale .
Proof. Split the stream into blocks of length B. Count a block as successful if it contains an ordered advance or a settled state. By Lemma G.1, its success probability is at least , given all previous blocks. Coupling with independent Bernoulli( ) trials shows that the number of successes in n blocks stochastically dominates .
If , there are fewer than successful blocks: each contains a strict advance, and advances would leave the state settled. Taking proves Equation 57. For , the Chernoff bound gives
Condition equation 58 makes this at most .
Corollary G.1 (Length generalization). Let and . For every ,
Thus, if satisfies equation 58, then implies for all . Likewise, implies and for all .
Proof. Couple different lengths as prefixes of one infinite stream. If a disagreement occurs after time K but not by time K, the state at time K must be transient. This proves the first inequality. For bounded-length sampling,
The tail bound gives ; averaging the errors at lengths above together with gives the same bound for .
A uniform bound on lets us combine this corollary with statistical generalization, keeping the same confidence. Local attention replaces single-step progress by blocks of length , with progress probability at least .
G.2 GENERALIZATION WITH NONUNIFORM DISTRIBUTION OVER VOCABULARY
Our main length generalization bound is stated for a uniform distribution over the vocabulary for simplicity. In fact, the proof yields a generalization to a nonuniform distribution over . In fact, even dependencies between successive symbols are allowed; in this case we can consider distributions over semi-infinite strings . We only need to assume that every poDFA over reaches an absorbing state in finite time almost surely on ; this is satisfied, e.g., if for each and each :
for every , for some .
Definition G.3. Let A be a poDFA, and P be a distribution over semi-infinite strings in . Define the following random variables over semi-infinite strings :
-
: time of reaching an absorbing state
-
Z: the absorbing state eventually reached
Then define
where denotes the set of absorbing states of ; we restrict to states where .
To keep the same length distribution as , set and define by drawing and an independent length with
When P is the i.i.d. uniform source, .
Then the proof of our joint generalization bound (Theorem 4.2) carries through for , replacing the quantity used in that theorem with a quantity defined from :
Theorem G.2 (Joint Generalization Bound in Sample Size and Length, Version of Theorem 4.2 for General Input Distribution). Use the same hypotheses as Theorem F.2, with teacher and hypothesis class , and define
I.e., X has the form where represents the difference automaton for and .
Let be trained on i.i.d. samples from , with . Then, for every , the error rate on satisfies
with probability at least , where and .
The statement above assumes G&C; as usual, it also holds for ERM with from Proposition 4.1.
Proof. For a fixed student, write , and let be the error probability on the exact prefix . Let be the probability of ever disagreeing on . Since disagreement is absorbing, the definition of gives , while for every . The mass at length is
Thus , and
The statistical argument of Proposition 4.1 applies to and gives with probability at least (trivially if ). Substitution proves the claim, with the same ERM adaptation as in Theorem F.2.
G.3 LOWER BOUND ON TRADEOFF
We show a lower bound also exhibiting a multiplicative interaction between N and . Our lower bound on the tradeoff matches the more general version allowing nonuniform input distributions (Appendix G.2).
Theorem G.3. Let . There is a family of target functions representable by fixed-precision transformers, such that, for every , there is an input distribution satisfying:
Consider a learner with hypothesis class producing a hypothesis from i.i.d. samples at length (each sample the length- prefix of a sample from , labeled with the output provided by the target ).
Then, define the risk by averaging the test loss on very long test strings:
across targets and size-N i.i.d. datasets.
Then, for all N and all
where is as defined in Eq. 61.
Note here that, in the setting of the function classes built here, this bound closely resembles Theorem G.2: the numerator is the negative log probability that a uniform sample from H matches any given ground truth f – which is essentially the statistical complexity term B arising in the G&C bound (which is the negative log probability that a random sample from the hypothesis class matches the target, as per discussion in Appendix E) – whereas the denominator is proportional to
As in Corollary D.1 and Proposition D.1.
the product of and , as in Theorem G.2. Thus, any bound applying at the generality of (i) general hypothesis classes , (ii) general distributions over needs to have essentially this form, as we have both upper and lower bounds on of this form up to proportionality factors.
Proof. We define over so that successive symbols are always sampled independently; we thus specify the probability at the level of individual symbols (i.e., specify as a probability over ). Define
with elements , with
where
and is uniform.
We parameterize the family by (i) the parameter , (ii) the parameter , (iii) a bit vector , and (iv) a tilt , (v) a tilt . Here, (i)–(iii) jointly define ; (iv)–(v) define the distribution . We later choose based on , as .
Given a target , we first define a poDFA as follows. The state set is
-
Start in .
-
Consider the first token, of the form
(a) If , go to .
(b) Else, j indexes a chain to go into. That is, go to .
- Once we are in such a state
That is, each branch is where only advances the chain
Also, set for every .
- Every state , and with outputs 0. Endpoint outputs an indicator for ; that is for every ,
This is represented by a family of with , , .
Now for any two distinct elements of , we note that the difference automaton has a very similar structure: it consists of chains of length C again, and the symbols have the same effect of advancing in a chain as they have in the poDFAs given above.
Define
This in fact matches the definition of from Eq. 61.
A single example reveals with probability
After N independent examples, coordinate j remains “unrevealed” with prob
Consider test length . For a given coordinate , the chance of it becoming relevant on a test sample here is
The test error rate is:
Setting :
Take :
If TestErrorRate ≤ ε, then, dividing both sides by ε, and applying Bernoulli's Inequality
Hence,
Rearranging, and by monotonicity of ,
Now, by construction, . This concludes the result.
H EXPERIMENTS
We use three controlled synthetic task families to test the qualitative predictions of our theory. We choose these families for variety in teacher depth, width, number of heads, alphabet size, and associated automaton height. The induction-head task also tests local positional information provided by a local attention head. We use standard FP32 arithmetic and test whether the theoretical predictions carry over to real-world numerical implementations. First, the logarithmic–linear tradeoff between training length K and sample size N suggests that an additive increase in K can offset a multiplicative reduction in N: increasing training length can therefore be more effective than adding examples. Second, larger teacher and larger student depth L, width D, or alphabet size can increase the sufficient requirements on N and/or K, suggesting possible performance degradation at fixed training resources. These experiments also have an exploratory role: the two bounds on the automaton height C in Lemma 3.1 yield different dependencies on these quantities, and worst-case guarantees need not describe their empirical effects.
H.1 TASK FAMILIES
H.1.1 : ALTERNATING LANGUAGES
Let the alphabet be . The language consists of the words that begin with and that contain at least alternating constant blocks of 's or 's. Equivalently, writing the unique block decomposition of a nonempty word as , with and where the consecutive are distinct.
Thus accepts aaabbbbbba and ababa, but rejects aaaabb and bbbaabb. These tasks are inspired by the alternating-block depth hierarchy of Yang et al. (2025a); here we ask for at least k blocks rather than exactly k. Yang et al. (2025a) prove that, in a fixed-precision paradigm with infinite precision inside attention, the minimal number of transformer layers required for to express the alternating languages is k - 1. We use this family to study increasing sequential depth, and hence the dependence on teacher depth , while keeping the alphabet fixed.
Specifics. The residual stream gives access to the current token, which is included when counting blocks. The target at position i is 1 exactly when the prefix belongs to ; the EOS target is the membership label of the full word. Evaluation includes every ordinary position and EOS. Each new letter differs from the previous one with probability 0.05, rather than 0.5, and words start with a with probability 0.95. This makes alternations rarer and avoids early target saturation. The distribution still fits our uniform sampling framework: one can equivalently consider an alphabet of 20 symbols, extending with 18 padding symbols. Additionally, Appendix G.2 discusses the non-uniform extension for the sample-length tradeoff multiplicative bound in Equation 10.
Example. For , the target becomes 1 when the third block begins:
H.1.2 : ALPHABET LANGUAGES
Here . These Alphabet languages ask whether every letter has occurred at least once in the word:
For example, accepts precisely the words over in which no letter is missing. We assume a reference teacher construction, where one attention head monitors each letter, giving . With this hypothesis, increasing therefore varies , the corresponding residual width , and together, rather than isolating head count.
Remark. Unlike the Alternating languages, we have no proof that representing requires teacher heads. We nevertheless use as a heuristic, supported by two main reasons. First, we empirically observed that learning the Alphabet languages with less heads than alphabet symbols is difficult. Secondly, under a sufficiently skewed distribution, if one head monitors two letters , its attention mechanism may fail to detect a sporadic presence of letter among a word full of 's: indeed, most of the attention mass would be set on 's, while fixed-precision rounding and saturation would potentially leave undetected.
Specifics. Letters are sampled independently and uniformly. Each ordinary position is labelled by the membership of its prefix in , and EOS by the membership of the full word. Evaluation includes all these positions.
Example. For over , the target becomes 1 once every letter has appeared:
H.1.3 : INDUCTION HEAD TASKS
The Induction Head tasks have a vector-valued prediction at every ordinary token position; EOS is not supervised or evaluated. Here again, . For each , the target output is a vector , with one dimension per letter in , whose -th coordinate records whether the bigram has appeared strictly earlier in the word:
For instance, at the third position of abac, the current letter is and the earlier bigram has occurred, so the -coordinate is 1. Thus is the product of binary classification tasks, one for each possible successor . Distinct letters must have distinct embeddings, so fixed precision requires . This family therefore varies the alphabet size and the teacher's width requirement, as well as the output dimension .
Specifics. The induction-head task uses local positional information, unlike the preceding two families. A range-one local attention head can attend only to position at position , providing the information needed to form bigrams without a separate positional encoding. Appendix G.1 treats this extension through a finite suffix cache coupled to a partially ordered component. We use only its past-subformula-counting bound, corresponding to in Lemma 3.1, with the additional cache and block factors. The temporal-profile bound is not established for this extension.
Example. For over , write target coordinates in the order :
H.2 PROTOCOL AND EVALUATION
Binary loss and accuracy. Exact equality of FP32 outputs is not a useful experimental criterion, so we treat each target coordinate as a binary class. For a word , let be its supervised positions, let be the th target coordinate at position , and let be the corresponding model logit. We minimize
with . Note that the output dimension is only 1 for and , and for . Thus the first two tasks use one BCE term at every ordinary position and EOS, whereas averages BCE across all target coordinates at each ordinary position.
We classify a coordinate as and a word is correct if for every and . Accuracy is the fraction of correct words, and perfect accuracy means that every word is correct.
Remark. In the fixed-precision abstraction, the binary classifications given above, based on the logit regions and , are representable by boolean predicates in the same way as done in Proposition D.1. Equivalently, the binary classification framework naturally stems from an alternative definition of the difference function 29, checking on two logit regions rather than on exact equality.
Sampling and supervision. Unless stated otherwise, all ordinary input symbols are drawn independently and uniformly from the alphabet. Each sampled word has length exactly K, measured in ordinary symbols. Agreement requires an exact match at every supervised position, and the current letter can contribute through the residual stream.
For and , we additionally append and supervise an EOS token. These are language-recognition tasks, so the terminal readout of Li & Cotterell (2025) is natural, alongside our prefix-wise outputs. EOS is an experimental convention, not an assumption of our base framework. Requiring a correct EOS output adds a success condition, making evaluation at least as demanding as checking ordinary positions alone; we do not claim a measured effect on training difficulty. The persistent difference function in our bounds concerns ordinary positions, while EOS accuracy is an additional check.
Optimisation and repetitions. In all cases, optimisation uses Adam Kingma & Ba (2014) with a batch size of 32 and a learning rate searched , choosing the learning rate that induces the most seeds to fit perfectly the training data. Training lasts for at most 2,000 epochs and stops early when the epoch training loss is below 1e-5. Unless the quantity N is explicitly given, the training sets contains i.i.d. samples. All configurations in all the experiments were run 10 times over 10 different seeds, each seed affecting the initialization, the training dataset and the evaluation dataset. Finally, a model is selected in our analyses if and only if it achieves perfect accuracy on its training set. This matches the consistency requirement of Guess-and-Check, but not its distribution over hypotheses.
Choice of training length. For simplicity, generated datasets are made of samples of length exactly K, instead of words of different lengths smaller than K. All the results of this paper hold up to a slight constant adaptation, stemming immediately from the deletion of the weight factor in Section D.4. Unless K is swept, it is chosen using task-specific coverage criteria: approximately 80% of words starting with a contain the required blocks, 80% of words contain every letter, and 50% of words have exhibited every bigram before the final ordinary position. These criteria concern the target task. They were also partially selected empirically to make the experiments interesting (neither trivial nor impossible). The lower threshold for reflects the useful coordinate-wise supervision available before all bigrams have occurred. The and choices are guided by coupon-collector estimates.
Default student architectures. The trained transformers architecture is an enhanced version of the definition given in Appendix B.2, in order to closing in with real-world transformers. We use affine query, key, and value projections and apply an affine output projection after head concatenation. Attention scores are divided by as is customary. Furthermore, we apply Post LayerNorm (Ba et al., 2016) twice in each layer, once after the attention and once after the feed-forward. Local-attention heads are also added for the induction head tasks . The ReLU feed-forward layers have one hidden layer of width . Outputs are evaluated by coordinate-wise binary classification rather than exact equality of the logits. Computations use PyTorch's default FP32 precision, which naturally reflects the fixed-precision setting. We give the exact student parameter sizes of the experiments in the next section.
Remark. To prove that every LTL[P] formula can be simulated by a fixed-precision transformer despite vanishing attention weights, Li & Cotterell (2025, Section 3.3) provides a two-layer patch construction to implement the Past operator resilient to any input length. The first block identifies witnesses before attention weights vanish, and the second aggregates this set without saturation. Consequently, experimental and theoretical transformer depths for our tasks may differ by a constant; for example, the alphabet languages might theoretically require two layers to handle vanishment of attention weights. Since FP32 saturation arises only at lengths far beyond our experiments and might not follow the exact arithmetic assumption stated in Appendix B.2, we ignore this distinction.
In the end, the evaluated models were selected based on representational complexity and tractability, ensuring they were sufficiently expressive to yield meaningful insights while remaining learnable.
Evaluation. We evaluate at absolute test lengths, such as , or relative lengths, such as . These lengths count ordinary symbols, excluding EOS. Each model is evaluated on 2,000 independent test words of the specified length. The supervised positions are the ordinary positions and EOS for and , and the ordinary positions only for ; accuracy is as defined above.
To match the selection prior of Guess-and-Check, as noticed above, we retain for plotting only models with perfect training accuracy. Consequently, a reported point can aggregate fewer than the 10 attempted seeds and a blank region in a plot signals that no seed achieved perfect training accuracy for that configuration. In particular, some configurations may represent only one of the ten seeds if the training was difficult on this configuration.
H.3 RESULTS
We first examine whether increasing the teacher’s parameter size shifts the amount of data or training length needed for high test accuracy. Teacher sizes refer to realizations of the target functions. The three families probe different, sometimes coupled resources: depth for ; head count , width , and alphabet size for ; and width requirements, alphabet size, and output dimension for .
We then study how varying the student parameter sizes can impact the performance, and how it compares with theory.
Finally, we demonstrate how the required training length K and sample size N trade-off for the three task families.
H.3.1 IMPACT OF THE TEACHER'S SIZE
The two height bounds in Lemma 3.1 give different dependencies: grows with depth and width, but decreases with head count at fixed width (other quantities held fixed); depends on depth and alphabet size, not width or head count. The statistical bounds on depend on width and depth. In addition, a larger alphabet lowers the worst-case probability of making progress in the automaton, impacting , while also showing up in bounds on . These effects can increase the sufficient requirements on and . The experiments therefore give us insights on whether the empirically demanded quantities and pursue the theoretical sufficient requirements. For , only the local extension of the argument is used.
In this subsection studying the impact of teacher's size, student backbone is held fixed across tasks; input embeddings and output dimensions still follow the task alphabet and targets. Moreover, among each family, all students have the same parameter sizes, despite having different targets. This permits to restrain the variations induced by different student sizes. For every family of tasks, we set the student structure to be large enough so that all the targeted teachers are realizable.
• For the alternating languages, the studied tasks are . Every student has exactly layers, embedding dimension , and one attention head . When varying K, they all train on 256 samples. When varying N, the training length K is set, respectively for , to 86, 111, 135, 158 (c.f. Choice of training length H.2).
• For the alphabet languages, the tasks are . Every student has one layer and attention heads. The global embedding dimension is fixed to . When varying K, they all train on 256 samples. When varying N, the training length K is set, respectively for , to 37, 47, 62, 89.
• For the induction head tasks, the targets are , , , . Every student has two layers and embedding dimension and two heads per layer: one local head of range 1 and one global head. When varying K, they all train on 256 samples. When varying N, the training length K is set, respectively for , , , , to 92, 144, 211, 292.
Remark. While we set for alternating languages to correspond with the minimal realizable number of layers of the biggest task , we do not proceed accordingly for the alphabet languages
. Indeed, we set to 30 and not 20, as learnability was observed to be difficult when the number of heads is exactly the size of the alphabet. This choice does not alter the informative nature of the experiments or their relationship to the theoretical framework.
Required data complexity. We first vary N and compare task sizes within each family. The student backbone is fixed, while K is adjusted using the coverage criteria above. Larger tasks therefore receive longer, potentially more informative examples, which could partly offset their increased difficulty. Nevertheless, the observed sample requirement generally increases with task size. For and , this comparison does not separate teacher size from alphabet size or, for , the number of output coordinates that must all be correct.

(a) Evaluation on absolute lengths

(b) Evaluation on relative lengths
Figure 6: Impact of teacher’s size on data complexity. probes teacher depth ; jointly varies , , and ; varies alphabet size, width requirements, and output dimension. Student backbones are fixed within each family, while follows the task-specific coverage criterion.
Required training length. We similarly sweep K, comparing task sizes at each common training length, with N and the student backbone fixed. Larger tasks generally require longer training words for high test accuracy. We observe that this is qualitatively consistent with the increased sufficient length scales.

(a) Evaluation on absolute lengths

(b) Evaluation on relative lengths
Figure 7: Impact of teacher's size on length complexity. probes teacher depth ; jointly varies , , and ; varies alphabet size, width requirements, and output dimension. Tasks are compared at shared values of , with and student backbones fixed. For relative evaluations, early accuracy is sometimes high for tasks that are trivial on short words: words of length or might still be short and have a trivial target.
H.3.2 IMPACT OF THE STUDENT'S SIZE
We next vary the size of the student, , and , while holding the teacher and all other independent experimental parameters fixed. Conversely to the previous results studying the impact of the teacher sizes, we do not fix the student architecture within families. Instead for each task, we set parameters 'close' to the hypothesized minimal size for realizability. Hence, apart from explicit variations of architectural parameters, the trained students use the following default architectures.
• For the alternating languages , the tasks are , , , . By default, the students have layers, embedding dimension , and one attention head . and is set, respectively for , , , , to 86, 111, 135, 158 (c.f. Choice of training length H.2).
• For the alphabet languages , the tasks are . By default, the students have one layer and attention heads. The global embedding dimension is fixed to . and is set, respectively for , to 37, 47, 62, 89.
• For the induction head , the tasks are , , , . By default, the students have two layers and embedding dimension , with two heads per layer: one local head of range 1 and one global head. and is set, respectively for , , , , to 92, 144, 211, 292.
Overall, the effect of the student size is not consistently monotone. But the bounds describe worst-case sufficient resources and added capacity can also improve learning. This distinction is relevant in overparameterized models, as discussed in Appendix A.
Student depth. Increasing the number of student layers sometimes improves learning and length generalization. For , however, it substantially degrades length generalization. This ob-servation is consistent with the depth dependence of both height bounds and the resulting sufficient requirements on N and K.
Student embedding dimension. Varying the student embedding dimension has little visible effect on length generalization and, in some settings, improves learning. Thus, increasing does not appear to impose a systematic data or length-complexity cost in these experiments. At fixed , increases with , whereas is independent of width. The observations therefore do not support a simple monotone width penalty nor identify which bound is informative. For , the comparison remains with the local extension of , not .
Student head count. Although varying may violate the condition from Remark 2.1, the ERM learner depicted in Appendix E.4 does not require this condition as long as the target remains realizable. These experiments are therefore suitable for testing the theory's qualitative predictions. We observe that increasing the number of student attention heads appears to slightly harm learning in the and families, but substantially improves it in the family, including beyond the heads used in the reference construction. At fixed , increasing reduces and hence the student contribution to ; is unchanged. The improvement for is notably compatible with this direction. For , the sweep varies the total head count, always keeping equal numbers of local and global heads.

(a) Evaluation on absolute lengths

(b) Evaluation on relative lengths
Figure 8: Impact of the student's depth on length generalization. We vary while holding and fixed.

(a) Evaluation on absolute lengths

(b) Evaluation on relative lengths
Figure 9: Impact of the student’s embedding dimension on length generalization. We vary while holding and fixed.

(a) Evaluation on absolute lengths

(b) Evaluation on relative lengths
Figure 10: Impact of the student’s head count on length generalization. We vary while holding and fixed.
H.3.3 TRADEOFF BETWEEN TRAINING LENGTH AND DATA COMPLEXITY
For these tradeoff experiments, student models are set with the following parameter sizes.
• The alternating task has exactly 5 layers, and .
• The alphabet task has exactly 1 layer, and . The number of heads is 20 and not 15 no ease the learning procedure.
• The induction head task has exactly 2 layers, and it has two attention heads, one local head of range 1 and one global attention head.
We observe a tradeoff between training length K and sample size N: longer examples can substantially reduce the number needed for length generalization. Both axes use linear scales. The observed frontier is qualitatively consistent with the logarithmic–linear tradeoff illustrated in Figure 3. For a fixed accuracy threshold, the configurations that achieve the threshold with the smallest token budget typically use a larger K and a smaller N. Conversely, for a fixed token budget, the configurations with the best accuracy likewise favor a larger K over a much larger N. This resembles the allocation suggested by Corollary F.1. For , the relevant theoretical comparison uses the blockwise local-attention extension of the argument. The plotted budgets NK count ordinary tokens; and additionally use one supervised EOS position per word.
L6

A15
K
K
IH7
K
mean accuracy
(a) Evaluation at absolute test length 500
L6

K
A15
K
K
IH7
K
K
mean accuracy
(b) Evaluation at relative test length 5K
Sample Size N
Alternating

Alphabet
K
Training Length K
Induction Head
K
mean accuracy
(c) Here is Figure 5 for completeness. For a 0.75 minimum accuracy threshold, highlighted in red are the 3 configurations that have the smallest token-budget.
L6

K
A15
K
K
IH7
K
K
mean accuracy
(d) For a maximum token-budget threshold, respectively of 8000, 10000, 20000 tokens, highlighted in red are the 3 configurations that achieve the best accuracy
Figure 11: Tradeoff between training length and data complexity. One task of each family: , and to study the tradeoff between the two quantities.
We also include a control experiment in which the axis labelled N specifies a budget of supervised token positions rather than a number of words. Gains from increasing K at a fixed budget sug-gest a benefit from longer contexts beyond simply supplying more supervised positions. This is in agreement with theoretical predictions from Eq. 10.

Figure 12: Control experiment for , , and , with evaluation at relative test length 5K. The axis labelled gives the total token budget of the dataset rather than the number of words.
We have seen above the aggregation of the Length–Sample tradeoff of three distinct tasks , , and . We complete the collection with a compendium, of many combinations with increasing test lengths for each of three tasks.

(c) Induction Head task
Figure 13: Tradeoff between training length and data complexity: evaluation on absolute lengths, from length 50 to length 500 with additive incrementation of 50.

(a) Alternating language

(b) Alphabet language

(c) Induction Head task
Figure 14: Tradeoff between training length and data complexity: evaluation on relative lengths 1K, 2K, 3K, 4K, 5K, with K the training length of the involved cells configuration.

(a) Alternating language

(b) Alphabet language

(c) Induction Head task
Figure 15: Tradeoff between training length and data complexity: evaluation on absolute lengths, from length 50 to length 500 with additive incrementation of 50. Red contouring for accuracy 0.75; highlighted in red are the 3 configurations under this constraint that have the smallest token-budget.

(a) Alternating language

(b) Alphabet language

(c) Induction Head task
Figure 16: Tradeoff between training length and data complexity: evaluation on relative lengths 1K, 2K, 3K, 4K, 5K, with K the training length of the involved cells configuration. Red contouring for accuracy 0.75; highlighted in red are the 3 configurations under this constraint that have the smallest token-budget.

(a) Alternating language . Contouring cells with maximum token-budget 8000

(b) Alphabet language . Contouring cells with maximum token-budget 10000

(c) Induction Head task . Contouring cells with maximum token-budget 20000
Figure 17: Tradeoff between training length and data complexity: evaluation on absolute lengths, from length 50 to length 500 with additive incrementation of 50. For their respective maximum token-budget threshold, highlighted in red are the 3 configurations that achieve the best accuracy.

(a) Alternating language . Contouring cells with maximum token-budget 8000

(b) Alphabet language . Contouring cells with maximum token-budget 10000

(c) Induction Head task . Contouring cells with maximum token-budget 20000
Figure 18: Tradeoff between training length and data complexity: evaluation on relative lengths 1K, 2K, 3K, 4K, 5K, with K the training length of the involved cells configuration. For their respective maximum token-budget threshold, highlighted in red are the 3 configurations that achieve the best accuracy.
I AI USAGE
In this work, we used generative AI tools for proofreading the paper and its mathematical content, revising the phrasing of mathematical claims, providing ingredients for proving mathematical claims, and assisting in the writing and proofreading of proofs. Additionally, we used generative AI tools for creating and editing software code, assisting with literature research for related work, and proposing edits for improving readability.
We have not used generative AI tools to help develop theoretical models or conceptual frameworks, propose or refine hypotheses, design or provide feedback on research methodology or experiments, support qualitative and thematic data analysis, or interpret results.
We have reviewed all AI-assisted work. For example, we checked LLM-generated research advices for potential plagiarism through a manual literature survey, we checked mathematical soundness of every mathematical claims, we tested the soundness of the LLM-generated/assisted code experiments, and we supervised and/or overwrote AI drafted writing in the paper. We take responsibility for the final content of this work, including text, claims or artifacts produced with the aid of generative AI.