Number-Theoretic Structure for Positions and Arithmetic in Language Models
Two ingredients of large language models (LLMs) have a hidden number-theoretic structure: the way attention is biased by the \emph{offset} between two positions, and the way numbers are written and generated digit by digit. We make this structure explicit around one object, the divisibility lattice of the positive integers. First, attention biases that depend on the divisibility of the offset admit a \emph{M"obius parametrisation} through Ramanujan sums, which gives an exact criterion for positive semidefiniteness (nonnegative spectral weights) and a two-way transform of cost $O(Q\log Q)$; the $p$-adic ultrametric kernels are the special case of the chain of powers of a prime. Second, the digit-by-digit generation of an arithmetic result is causal exactly when the operation is $1$-Lipschitz for the $b$-adic metric, which holds for addition, subtraction and multiplication when digits are produced least-significant first, and fails for most-significant-first order, where the probability that a carry is not determined by the $w$ digits below is exactly $b^{-w}$. We test these statements in three computational experiments, with no LLM trained. Divisibility-structured relative-position targets are extrapolated to four times the training horizon with a normalised error of $0.04$--$0.08$ using 48 Ramanujan features, against $1.1$--$1.6$ for sinusoidal/RoPE-style frequencies, $0.5$--$0.8$ for a period-48 DFT on targets whose periods do not divide 48, and about $1.0$ for bucketed and linear biases; a control target that is not a function of the gcd is \emph{not} learned (error $\approx1.0$). The positive-semidefiniteness criterion agrees with an eigenvalue computation in 2400 of 2400 random trials, and the carry-lookahead probabilities match $b^{-w}$ within sampling error in bases 2, 10 and 16. The study is a mathematical and numerical analysis; its relevance to trained LLMs is supported only by the cited empirical literature and is left to future experiments.
Authors
- Aishwarya Ram
Publication Details
- Journal
- Figshare
- Published
- 2026-12-01
- DOI
- https://doi.org/10.6084/m9.figshare.35172682
- Primary Topic
- p-Adic Analysis and Mathematical Physics
- Type
- preprint