A Measure-Theoretic Analysis of Reasoning in Transformers: Structural Generalization and Approximation Limits
Yuyang Zhang ⋅ Yifu Zhang ⋅ Xuehai Zhou ⋅ Xiaoyin Chen
Abstract
While empirical scaling laws for reasoning in large language models (LLMs) are well established, it remains unclear when a model trained on one class of search traces can generalize to structurally different out-of-distribution (OOD) problems. We study this question by projecting each discrete search trajectory into a twelve-dimensional space of structural coordinates—such as tree depth and backtracking rate—and quantifying task shifts via the Wasserstein-1 ($W_1$) distance. Using Kantorovich duality, we bound OOD generalization risk in terms of this transport distance, the architecture's structural Lipschitz constant, and capacity lower bounds from network depth and width. This analysis yields two main architectural conclusions. First, under absolute positional encoding (APE), translating a reasoning sub-trajectory to later token positions almost surely alters its internal attention scores. When these perturbations misroute greedy exact-match search, the structural Lipschitz constant is $\Omega(1)$, and target risk has an order-one lower bound whenever misrouted structures carry enough target mass to exceed the approximation error by a fixed margin. By contrast, rotary position embedding (RoPE) preserves local attention scores under translation for fixed content vectors; under our baseline smoothness assumption, its transport penalty scales as $\mathcal{O}(W_1/T_{\max})$, where $T_{\max}$ is the maximum sequence length. Second, by reducing sequential backtracking to a Dyck-$k$ language under an implicit-depth assumption, we prove that fixed-depth Transformers face an irreducible risk floor when sufficiently many target searches exceed a multiple of their layer count. Adding layers removes this bottleneck, whereas widening the network only reduces a separate Barron-space term in the risk lower bound. Experiments on 54 Transformers trained from scratch on Countdown support these predictions. Further evaluations in the appendix extend our framework to broader settings: we quantify structural shifts across public agent, embodied, and robotic trajectories; evaluate 33 open-weight LLMs under global position-index shifts; and test when splitting nested tasks across model calls improves final-answer accuracy.
Successful Page Load