Manuscript Offprint
arXiv:2610.25998Internalizing Chain-of-thought into Looped Transformers
Abstract
Chain-of-thought (CoT) enables constant-bit-size transformers to perform general-purpose computation through generated tokens [Li and Wang, 2025a], whereas looped transformers carry out the same computation by recurrence in hidden states (latent thought). We construct a family of constant-bit-size looped transformers that interpolates between CoT and latent thought. For a prescribed loop count and a fixed integer satisfying , our transformer simulates a time-t(n), space-s(n) Turing machine using a context window of and generated tokens, reducing both resources by a factor of relative to the corresponding unlooped queue-machine simulation. The construction also holds with softmax attention at constant bit-size, under the finite-precision kernel specified in this paper.
1 Introduction
Transformers [Vaswani et al., 2017] can perform general-purpose computation through recurrence. A central notion is Turing completeness: the ability to simulate any Turing machine, the standard mathematical model of algorithmic computation. Informally, a Turing-complete model can carry out any computation that a computer program can perform, given sufficient time and memory.
One form of recurrence is autoregressive generation, in which the model repeatedly appends a token to its sequence and uses the resulting sequence to generate the next token. Chain-of-thought (CoT) uses these generated tokens for intermediate computation [Wei et al., 2022]. The context window—the range of token positions accessible to attention—serves as the visible workspace.
Pérez et al. [2021] proved that transformers with autoregressive generation are Turing-complete. The earliest constructions use precision that grows with the input, together with a full-history context that scales with running time [Bhattamishra et al., 2020, Merrill and Sabharwal, 2024]. The full-history regime has a provable ceiling: with a polynomial-time next-token map and polynomial context, standard full-history CoT decides only languages in P, hence not all of PSPACE unless P = PSPACE [Yang et al., 2025]. Sliding-window attention and summarized CoT then bring the visible context down from the running time to the space bound [Schuurmans et al., 2024, Yang et al., 2025, Brösamle and Eckstein, 2026], while precision is reduced first to and then to a constant [Merrill and Sabharwal, 2024, Li et al., 2024]. Li and Wang [2025a] complete this line: a constant-bit-size transformer that attends only at fixed relative offsets is Turing-complete. Li and Wang [2025b] then bring the cost down to CoT tokens per simulated machine step by increasing the head-layer product.
Looped transformers provide the complementary form of recurrence, in depth: a shared block is applied repeatedly to the hidden state, performing multiple iterations before emitting a token and carrying intermediate
Corresponding author.
results in latent representations rather than an explicit CoT trace [Giannou et al., 2023, Yang et al., 2024, Geiping et al., 2025]. This internal reasoning is a form of latent thought [Saunshi et al., 2025, Xu and Sato, 2026], and Saunshi et al. [2025] show that loop iterations can simulate CoT steps one-for-one. How does moving computation from generated tokens into hidden-state recurrence change the context window and the number of generated tokens required for Turing-machine simulation?
Our contribution. We construct a family of constant-bit-size looped transformers that interpolates between explicit CoT and latent thought. One shared decoder block is applied L times per generated token, so part of the computation moves from the generated trace into hidden activations. An intermediate queue machine represents the Turing-machine computation, and each of its transitions can be realized either as an explicit CoT step or as one iteration of that block. Relative to the queue-machine simulations of Li and Wang [2025a,b], grouping L simulated transitions into each generated token reduces both the context window and the CoT length by a factor of L.
The mechanism is a per-iteration KV cache read through a sliding window. Iteration l writes its result into the iteration-l cache, the cached entries together hold the machine cells, and attention at that iteration reads only positions. A context window of that length therefore completes the simulation of an -space machine. The learned parameters are fixed, machine-dependent constants: they do not grow with n or with L. The positional encoding, the context length, the loop count, and the initial cache are instantiated from the resource bounds. The same construction holds with softmax attention under the finite-precision kernel of Section 5. In the statement below, is the number of tapes of the simulated machine and k is the hierarchy parameter of the queue simulation (Section 2).
Theorem (informal). Any time-space bounded Turing machine can be simulated by a constant-bit-size looped transformer (with its input pre-loaded into the initial KV cache as specified in Section 4.3) with head-layer product and context window length , that takes CoT steps for each simulated TM step, leading to a total CoT length of , for every loop count and every fixed integer with . At , the bounds recover [Li and Wang, 2025b, Thm 1].
For the constructed simulation, explicit and latent reasoning are not two capabilities but two placements of the same general-purpose computation realized by recurrence. Decreasing L externalizes that computation as generated tokens. Increasing L folds that many consecutive CoT steps into each token as latent iterations. The loop count is the exchange rate between the external trace and the internal computation.
Proof idea. We fold L consecutive machine steps of an existing CoT simulation into L iterations of the shared block, replacing L generated tokens by one. The obstacle is layer alignment: in ordinary CoT every past token is visible to every attention layer, whereas iteration l of a looped block reads only iteration-l cache entries of earlier positions, so the inputs consumed at a simulated step must sit in the cache at the layer that executes it. Li–Wang’s queue-machine simulation admits the required reorganization: each simulated step’s queue fronts are cached at the iteration that consumes them. Section 4.5 shows the alignment on one queue.
• Looped transformers have the expressive capacity to internalize a substantial part of a chain of thought into recurrent state. Raising the loop count replaces generated reasoning tokens by computation inside the loop, and general-purpose computation is preserved. The loop count is then a way to separate reasoning computation from the tokens a reader sees.
• The number of generated CoT tokens need not measure the serial computation a model performs. In the simulation, one generated token summarizes L consecutive steps, and the intermediate states stay in the recurrent state. Visible length and underlying computation can therefore diverge.
-
At large L this creates a learning difficulty. The explicit trace is strided: only every L-th state is emitted as a token, and the steps in between stay latent. Next-token prediction does not supervise those latent steps, so the computation may be difficult to acquire from pretraining alone.
-
The decoupling of explicit reasoning trace and latent computation exposes a potential learning challenge at large L: the explicit reasoning trace becomes increasingly strided, since only every L-th computational state is exposed as a token, while intermediate computation remains latent. Such a trajectory is not directly supervised by the standard next-token prediction objective, which conjecturally could make this form of computation difficult to acquire through pretraining alone.
-
The construction also suggests how a long-reasoning model might control latent computation, persistent state, and visible tokens separately: take the loop count as an explicit budget for latent computation, and supervise only selected boundary states, so that not every internal step has to be written out as text.
Section 2 fixes the models of computation, and Section 3 the looped transformer. Section 4 gives the hardmax construction and its main theorem, with the initialization interface stated explicitly (Section 4.3) and a worked example at the end (Section 4.5). Section 5 lifts it to softmax at constant bit-size. Section 6 discusses related work; Appendix A constructs congruent queue lengths, Appendix B records the transformer components, Appendix C the exact softmax kernel contract, and Appendix D the detailed comparison table; Appendix E collects notation.
2 Models of computation
We simulate Turing machines through an intermediate model, a synchronous multi-queue machine, following Li and Wang [2025a,b].
2.1 Turing machines and queue machines
Multi-tape Turing machine. A -tape Turing machine (TM; is the tape count) is a tuple where
• is a finite tape alphabet, including 0, 1, and a blank symbol #.
• Q is a finite set of states, including a start state and halting states .
• is a transition function.
The first tape is a read-only input tape, initially holding a finite -string of input ; the remaining tapes start empty. A TM is time-space bounded if, on every input of length , it halts within steps and visits at most distinct cells across the tapes. Throughout the paper, always denotes the tape count, leaving free for the hierarchy exponent of Fact 2.2 below.
Synchronous multi-queue machine. The intermediate model is a synchronous multi-queue machine: the multi-queue form of the Post machine [Post, 1936] in the variant of Li and Wang [2025b, §2.2]. Each queue is a first-in, first-out tape, read at the front and written at the rear. At every step every queue pops its front symbol and appends one symbol, so the queues move in lockstep. There is no separate stay-or-move choice; every front advances by one cell.
• is a finite alphabet, containing 0, 1, and the blank #.
• Q is a finite state set, containing the start state and the halting states .
- reads the front symbols and returns the next state together with the symbols appended at the rears.
Initially the input queue holds the input string and the other K-1 queues hold only blanks. The space of a queue machine is the maximum number of symbols stored in its queues during the computation, over inputs of length n. In the rest of the paper, is only the simulated Turing machine's space bound; the queue machine uses space.
We take queue 0 to be the input queue, and it is the longest. Every halting state is absorbing: for and every K-tuple , set . The convention makes every run an infinite log. It adds at most extra transitions in the final pass; the halting verdict is unchanged (Proposition 4.2).
Definition 2.1 (K-queue execution log). Let be a synchronous K-queue machine with fixed queue lengths , on input of length , and let . Its execution log is , where . The entries with are given directly: the input feed, for ,
and the padding, for ,
For ,
every front index being given or previously produced; the absorbing convention makes the log infinite. The remaining run length after the cache is filled is
The step-m front of queue is the symbol appended at step ; counts the transitions from step , the first step whose fronts are available, to the first halting state.
The conversion from Turing machines to this model is cited, not re-derived:
Fact 2.2 (Queue Turing machines are Turing-complete [Li and Wang, 2025b, Thm. 2, Step I]). For every fixed integer , a -time, -space -tape Turing machine converts to a synchronous -queue machine running in steps and total queue space. Each tape becomes two stacks and each stack levels of queues. Writing , level ( ) uses two content-half queues of length and one buffer of length ; consecutive half lengths divide one another, and the cost analysis is in terms of these lengths [Li and Wang, 2025b, §3].
Two remarks on scope. First, the level structure and the cost bounds are what we cite; the congruent base , the single length per level, the buffer split, and the resource bookkeeping are argued in Appendix A. Second, is fixed before instantiation (it sets the head count ) and is prescribed afterwards, subject to .
3 The model: looped transformers with a per-iteration cache
3.1 Decoder-only transformers with sliding-window attention
A decoder-only transformer [Vaswani et al., 2017] is a parameterized next-token map . The forward pass for position sets and applies, at each layer , an attention sublayer followed by a feed-forward network, both with residual connections:
where the inner sums range over the context window and the concatenation runs over the heads. The learned parameters comprise the embedding and output head, query and key matrices , value matrices , output matrices , biases , and feed-forward networks . A relative positional function is specified separately and enters the key side of the scores: the weights form the hardmax distribution (all weight on the score's maximizer) over scores . The next token is at the last layer, for a decoder of depth .
In the sliding-window setting with window , position attends to . The KV cache is indexed by (position, layer): and are written and fixed when position completes layer .
Remark. With sliding-window attention and a persistent KV cache, a layer-L transformer can depend on positions, more than the visible window. This span alone does not provide the alignment needed for simulation: each queue value must still sit in the correct iteration's cache (Section 4.5).
3.2 Looped transformers
Looped transformers re-apply a fixed unit instead of stacking independently parameterized layers [Giannou et al., 2023, Yang et al., 2024, Geiping et al., 2025]. We adopt a weight-tying version [Dehghani et al., 2019, Lan et al., 2020]: the unit acts L times on the current position's residual stream per generated token, with a separate per-iteration KV cache carrying state across positions.
Definition 3.1 (looped transformer). A looped transformer is a decoder-only transformer consisting of
• a loop unit : a stack of decoder layers specified by the shared weights ;
• the embedding emb and the output head , applied outside the loop;
together with a loop count . Given , the forward pass computes
the l-th application of being iteration l (layer and iteration are used interchangeably). Unrolling the loop yields a pL-layer transformer in which each iteration applies the same p layers. Shared parameters are independent of L.
Reading rule (per-iteration cache). The cache holds the iteration-l key and value entries of the retained positions . Iteration of position attends only to those same-iteration entries; the current position’s key and value are computed from and are frozen when written. A fixed iteration never reads another iteration’s cache. Section 4.5 shows the discipline on one queue, and the construction has to follow it.
A looped transformer is constant-bit-size if the number of distinct learned parameters, their bit precision, and the bit precision of scalar intermediate values are all , independently of input length, loop count, and generation length.
4 The hardmax construction
We first construct the simulation with hardmax attention; Section 5 realizes the same selection exactly under a finite-precision softmax kernel. Throughout this section, queue has length (queue lengths satisfying this congruence are constructed in Appendix A). Set and . Each forward pass executes consecutive machine steps. Head reads the front of queue at distance : attention retrieves that front by a fixed relative offset, and the feed-forward network applies the transition.
4.1 Tokens and residual layout
At nonterminal position , the token is , where is the tuple appended at log index . Generated tokens are thus machine-state symbols, not natural-language steps.
The embedding uses the layout specified in Appendix B:
The blocks store respectively a constant, the current state, the appended tuple, and scratch registers for retrieved fronts, giving . At iteration , attention writes the fronts and the feed-forward network applies , leaving the residual equal to the embedding of . After iteration , the output head emits , or ACCEPT/REJECT if the state is halting, and the generation stops.
4.2 Positional encoding and the attention heads
The relative positional encoding is the simplified form of Li and Wang [2025b, Eq. (2)]: writing for the basis vector of indexed by head number (Appendix B fixes the indexing conventions), ,
whose -th coordinate is exactly at distance . The query of head is the constant and the key is set to be 0. The positional encoding enters the key side of the scores (Section 3). Thus
For every pass , is the unique maximizer, so hardmax selects queue 's designated position: the offset encodes “front of queue at the current iteration,” and Lemma 4.1 proves that the entry selected is the front consumed at step . Equal-length queues remain separate via distinct heads and value projections. Appendix B gives the matrices.
Value entries and transition. Let , , be head 's cached value at position and iteration , and let denote the represented -tuple. Each projects symbol block ; writes the selected values into the front blocks, and the feed-forward network applies . All iterations share the same positional encoding, value projections, and lookup, so the construction satisfies Definition 3.1.
4.3 The loop invariant
Initialization. Generation begins at pass with a loaded cache: for and , set the cached value entry , and set the current token to . Since , the first simulated transition occurs at step ; the remaining run length is (Definition 2.1).
We treat this initialization as an explicit interface assumption. It prescribes which entries a working system must place in the cache before generation; the cost of producing them is not included in any bound of this paper, and we do not prove that a natural-order prompt prefill computes them.
Lemma 4.1. For every position and iteration , the value entry encodes the -tuple at log index : block holds .
Proof. The initialization gives the claim for and all , and the token at position supplies its iteration-0 entry .
Consider pass and iteration , and suppose the residual entering iteration contains . Head attends to position , whose iteration- entry was written in an earlier pass and is therefore the log entry
the front of queue for step , because . The residual stream supplies , and the feed-forward network computes
For , this result is cached as , and the residual entering iteration contains ; for , the output head emits , whose embedding supplies . Every value entry is therefore the corresponding log entry, as claimed.
Figure 1 illustrates one pass.
4.4 The main theorem
Proposition 4.2 (queue-level construction). Let be a synchronous K-queue machine over a fixed alphabet , with absorbing halting states and lengths . Under the initialization of Section 4.3, the construction of Sections 4.1–4.3 gives a decoder-only looped transformer with one shared block, K heads, window , embedding dimension , and constant bit-size. It emits the execution log at stride L and therefore uses
generated tokens, including at most L - 1 absorbing transitions in the final pass.
Proof. The decoder block, K heads, window w, dimension , and constant bit-size are those of Sections 4.1–4.2. By Lemma 4.1, at every pass and every iteration l the cached values are the log entries , so head r retrieves the front of queue r at machine step and the feed-forward network

Figure 1: One pass at position i. At iteration l, head r retrieves queue s front from , and the feed-forward network advances the machine by one step. The final write is emitted as the token at position .
applies . After iterations the residual is therefore the embedding of . Appendix B (B.6) emits this pair as the token at position , or ACCEPT/REJECT if the state is halting. Generation thus starts from the initialization of Section 4.3 at index and follows the log at stride for the remaining steps, giving with at most absorbing transitions in the final pass.
Theorem 4.3. Any time-space bounded -tape Turing machine can be simulated by a constant-bit-size looped transformer (with its input encoded in the initial KV cache as specified in Section 4.3) with head-layer product and context window length , that takes CoT steps for each simulated TM step, leading to a total CoT length of , for every loop count and every fixed integer with .
Proof. For the prescribed and the given fixed satisfying , the congruent lengths supplied by Appendix A (Lemma A.1) give a step-equivalent -queue simulation with run length and window . Proposition 4.2 yields
Multiplying by gives the serial-work bound. The cache stores positions at each of iterations, so total KV state is .
Resource accounting. The factor-L reduction applies to visible resources only: generated tokens and the visible window shrink by , while the total cached KV state and the serial block work are unchanged from . Table 1 tabulates both regimes. The heads of the single shared block are re-applied at each iteration, so the head-layer product does not grow with .
A concrete instance: the balanced point , , is admissible because , and it gives generated tokens, a window of positions, cached entries, and loop executions.
| Quantity | admissible | |
|---|---|---|
| Generated tokens | ||
| Visible positions (window) | ||
| Loop executions (serial block work) | ||
| Total cached KV state | ||
| Learned model size |
Table 1: The construction at the endpoint (which recovers the bounds of Li and Wang, 2025b) and at a general admissible loop count. The simulated Turing machine is the same, while the queue lengths are re-instantiated for each ; only the first two rows shrink with .
4.5 A worked example
Take one queue of length and loop count . The window is then : at pass and iteration , the head reads position , at relative distance , in the same iteration. Since , the entry at position and iteration is the front consumed at step . The construction keeps a separate copy of this bookkeeping for every queue. One queue is enough to see the alignment.
Before generation, the loaded cache of Section 4.3 must already hold for and : at position and at position , together with the token at position . Here , and is the length of this queue, so generation begins at step , the first step whose front is already in the cache.
Table 2 lists the first passes. At pass the three iterations execute steps 9, 10, and 11, and iteration reads . On a queue of length 7, the symbol consumed at step was appended at step , so those fronts are the symbols appended at steps 3, 4, and 5. In general, the symbol read at pass and iteration has log index
Each pass advances the machine from log index to and emits the state at the boundary. The visible tokens are the log sampled at stride . Intermediate steps, such as steps 7 and 8 inside pass 2, are never emitted.
| Pass | Window | Steps executed | Reads | Residual advances from | Emits |
|---|---|---|---|---|---|
| 2 | |||||
| 3 | |||||
| 4 |
Table 2: One queue with , , and . At pass and iteration , the head reads position in iteration , which is log index . The pass advances the machine by three steps and emits every third log state.
Three features of the example are what the construction uses. First, iteration 1 of pass 3 reads : the same iteration of an earlier position. It does not read an iteration-0 entry, and it does not mix iterations. Section 3 states this per-iteration rule. Second, a value entry is frozen once written. Initialization supplies ; pass 2 writes , and pass 4 reads that same entry. Third, the window has to be the one the congruence gives. The front required at step 11 is , written at position 1, exactly positions back. With a window of 2, position 1 would already lie outside the positions pass 3 can read. We call a representation layer-aligned when, at every simulated step, the inputs that step consumes already sit in the KV cache at the iteration, or layer, that executes the step.
5 Softmax simulates hardmax at constant bit-size
Section 4 uses hardmax attention. Theorem 4.3 also holds for a max-first binary32 softmax kernel, with no growth in precision as the window or the loop count grows. The five-clause kernel contract, the underflow arithmetic, and the complete proof are in Appendix C.
Write for the attention score of candidate position j in the row of query position i. For a row with unique maximizer , define the attention score gap
the score separation of [Brösamle and Eckstein, 2026, Def. D.1].
The kernel, in words. The kernel evaluates the exponential only on inputs shifted by the row maximum, using a fixed binary32 exponential that returns exactly 1 at 0 and +0 at every input at most -256; numerator and denominator are accumulated in binary32 and divided once; the quotient is cast once at the output boundary, to a fixed format that contains 0 and 1 exactly. The role of the threshold is arithmetic: since , we have , the round-to-nearest midpoint between 0 and the least positive binary32 subnormal, so a correctly rounded binary32 exponential returns +0 on every input at most -256 (Appendix C).
Lemma 5.1 (softmax implements unique hardmax exactly). Let be a score row with unique maximizer and score gap at least 256. Then the max-first kernel's computed attention output is exactly , independently of the row length, provided is exactly representable in the accumulation format and preserved by the output cast—in particular for the values in used in this construction.
Proof. By the kernel, the shifted inputs are and for every . The exponential row is exactly the one-hot indicator of : and for every . Numerator and denominator are therefore the exact sums and 1, each partial sum containing only zeros and one nonzero term. Division and the single boundary cast preserve the result.
Corollary 5.2 (the main results hold under softmax). Set in Section 4.2. Then every score row has scores in , a unique maximizer at distance , and shifted losers exactly -256, all exactly representable in binary32. The value vectors are one-hot, and the remaining parameters and feed-forward computations use a fixed machine-dependent format as specified in Appendix B. By Lemma 5.1 every attention output equals the hardmax one-hot of Section 4.2 bit for bit, so Theorem 4.3 and Proposition 4.2 hold with softmax attention under the max-first kernel: the parameters are those of the hardmax construction rescaled by the fixed ratio between its score gap and the kernel constant 256 (here 1, since ), the resources are unchanged, and the bit-size is still , independent of n and L.
Remark (scope). The result is conditional on the stated kernel, in three ways. First, it requires a binary32 exponential that returns +0 below a fixed threshold, without a positive floor, logit soft-capping, or an additive in the normalizer; the exact contract is Appendix C. Second, the arithmetic is fixed-format: values not exactly representable in it (arbitrary real value vectors, for instance) are outside the exactness statement. Third, no claim is made about kernels beyond the contract: subtract-max is standard in production softmax implementations (Appendix C records examples), but that observation is context, not a conformance proof, and in particular online and fused attention kernels with their own epilogues are not thereby covered. Appendix C also treats two variants: a kernel that does not subtract the maximum (then Section 4.2 can set the winner's score to 0 and every other score to -256), and a kernel with a positive scale, canonically (then instantiate ; here is a machine constant, so remains ). Nothing generalizes to exact-real softmax.
The comparison with exact-real arithmetic is a comparison of assumptions. Brösamle and Eckstein [2026] simulate Turing machines with low-precision softmax and summarized CoT, separating the winner from the other scores with depth, width, and precision that grow logarithmically. The present construction fixes a constant score gap and lets finite-format underflow make the selection exact; the only added cost is that constant gap . These are different precision and architecture assumptions. We do not claim that their arithmetic implements exact hard selection.
6 Related work
We keep this section argument-driven; Appendix D carries the detailed comparison table of transformers simulating -bounded Turing machines, with per-row notes and normalized notation.
Transformer expressivity. RASP models transformers as readable programs [Weiss et al., 2021, Lindner et al., 2023]. Variants such as B-RASP, C-RASP, and RASP-L, together with subsequent formal-language analyses, characterize the languages recognized under different architectural restrictions [Angluin et al., 2024, Yang and Chiang, 2024, Zhou et al., 2024, Strobl et al., 2024, 2025, Huang et al., 2025]; see Strobl et al. [2024] for a survey. On the circuit side, Merrill and Sabharwal [2023] show that constant-depth, log-precision transformers without CoT are limited to TC -style shallow circuits. Feng et al. [2023] connect CoT length to circuit depth: polynomially long CoT lifts transformers from shallow-circuit problems to all of P.
Looped transformers and latent thought. Looped transformers extend serial computation by re-applying a shared block [Giannou et al., 2023, Yang et al., 2024, Geiping et al., 2025]; Merrill and Sabharwal [2025] show that logarithmically deep looped transformers recognize regular languages and solve graph connectivity without CoT. Saunshi et al. [2025] study how latent thought can simulate computations expressed through CoT. Xu and Sato [2026] establish simulation results and complexity-class characterizations for CoT and latent thought, together with conditional separations: latent iterations support more efficient parallel computation in their deterministic setting, while stochastic CoT has advantages for approximate counting and sampling under their stated assumptions. Their deterministic comparison allows the embedding dimension to grow with input length. Our result is complementary: for a fixed Turing machine and hierarchy parameter, we construct a family with fixed machine-dependent learned size and precision in which varying L exchanges explicit CoT steps for latent iterations. We account for generated tokens, visible context, serial loop work, and persistent per-iteration KV state under the loaded-cache interface. This is an interpolation for the constructed recurrent simulation, not an equivalence of arbitrary CoT and latent-thought models or a claim that all intermediate tokens can be eliminated.
Autoregressive Turing-machine simulations. Autoregressive transformers are Turing-complete [Pérez et al., 2021, Bhattamishra et al., 2020, Merrill and Sabharwal, 2024, Li et al., 2024, Qiu et al., 2025], with precisions and dimensions ranging from unbounded to constant. Jiang et al. [2026] establish softmax Turing completeness via counter machines with full-history attention and no fixed numerical-precision bound. Two later lines of work bring the context down to the space bound. Context-management schemes erase or summarize intermediate CoT: PENCIL [Yang et al., 2025] achieves maximal context , and Cui et al. [2026] show that the management policy itself determines the computable class; Brösamle and Eckstein [2026] keep every segment at with low-precision softmax, at logarithmically growing depth, width, and precision. Sliding-window attention uses locality in place of erasure: Schuurmans et al. [2024] gave the earliest bounded-window universality, with a circular-queue context; Li and Wang [2025a] prove constant-bit-size Turing completeness for an window via a Post-machine simulation and characterize WINDOW[ ] = SPACE[ ]; Li et al. [2026] remove the need for positional encodings; and Li and
Wang [2025b] reach CoT tokens per TM step, with window , by increasing the head–layer product. Our construction starts from that last simulation and folds L of its transitions into each token by making the queue representation layer-aligned (Section 4.5). At L = 1 it recovers that simulation’s bounds.
7 Discussion
The following limitations bound the result.
• Loaded cache. The input is pre-loaded into the initial KV cache (Section 4.3); the initialization cost is excluded from all bounds, and ordinary prompt prefill is not proved to produce the required entries.
• Visible resources only. The factor-L reduction applies to generated tokens and to the visible window only; total cached KV state and serial block work are unchanged from L = 1.
• Kernel-conditional softmax. The softmax result holds only under the max-first binary32 contract of Appendix C, for values exactly representable in the accumulation and output formats; it does not extend to exact-real softmax, to kernels with positive floors or logit soft-capping, or to production kernels beyond that contract.
• Generated tokens are machine states. The visible trace is a sequence of internal machine-state symbols at stride L, not a natural-language chain of thought; CoT-length statements concern this trace.
• No learning claims. Nothing here shows that such computations are learned by pretraining, reinforcement learning, or any other training signal; the messages of Section 1 are conjectural, and the supervision question for strided traces is open.
• Bounds, not measurements. All quantitative statements are asymptotic bounds of the construction; no experiment, speedup, or deployment claim is made.
AI use statement
We used generative AI tools to improve the readability of the manuscript and to identify relevant literature. We also used the Paper Assistant Tool (PAT) to review the paper's technical content. After assessing its feedback, we corrected errors it identified and cited relevant papers it suggested. The authors reviewed the AI-assisted revisions and take responsibility for the final text, citations, and mathematical claims.
References
Dana Angluin, David Chiang, and Andy Yang. Masked hard-attention transformers recognize exactly the star-free languages. In Proceedings of the Conference on Language Modeling (COLM), 2024. arXiv:2310.13897; introduces Boolean RASP (B-RASP).
Satwik Bhattamishra, Arkil Patel, and Navin Goyal. On the computational power of transformers and its implications in sequence modeling. In Proceedings of the 24th Conference on Computational Natural Language Learning (CoNLL), pages 455–475, 2020.
Moritz Brösamle and Stephan Eckstein. The expressive power of low precision softmax transformers with (summarized) chain-of-thought, 2026. arXiv:2605.18079.
Guanyu Cui, Zhewei Wei, and Kun He. Position: The Turing-completeness of real-world autoregressive transformers relies heavily on context management, 2026. arXiv:2605.19514, accepted to the ICML 2026 Position Paper Track.
Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Łukasz Kaiser. Universal transformers. In Proceedings of the 7th International Conference on Learning Representations (ICLR), 2019.
Guhao Feng, Bohang Zhang, Yuntian Gu, Haotian Ye, Da-Wei He, and Liwei Wang. Towards revealing the mystery behind chain of thought: a theoretical perspective. In Advances in Neural Information Processing Systems 36 (NeurIPS 2023), pages 70757–70798, 2023.
Jonas Geiping, Sean McLeish, Neel Jain, John Kirchenbauer, Siddharth Singh, Brian R. Bartoldson, Bhavya Kailkhura, Abhinav Bhatele, and Tom Goldstein. Scaling up test-time compute with latent reasoning: A recurrent depth approach. In Advances in Neural Information Processing Systems 38 (NeurIPS 2025), pages 46242–46293, 2025.
Angeliki Giannou, Shashank Rajput, Jy-yong Sohn, Kangwook Lee, Jason D. Lee, and Dimitris Papailiopoulos. Looped transformers as programmable computers. In Proceedings of the 40th International Conference on Machine Learning (ICML 2023), volume 202 of Proceedings of Machine Learning Research, pages 11398–11442, 2023.
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 Proceedings of the 13th International Conference on Learning Representations (ICLR), 2025. arXiv:2410.02140.
Hongjian Jiang, Michael Hahn, Georg Zetzsche, and Anthony Widjaja Lin. Softmax transformers are Turing-complete. In Proceedings of the 14th International Conference on Learning Representations (ICLR), 2026. arXiv:2511.20038.
Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. ALBERT: A lite BERT for self-supervised learning of language representations. In Proceedings of the 8th International Conference on Learning Representations (ICLR), 2020.
Qian Li and Yuyi Wang. Constant bit-size transformers are Turing complete. In Advances in Neural Information Processing Systems 38 (NeurIPS 2025), pages 69254–69273, 2025a. doi: 10.52202/085713-2083.
Qian Li and Yuyi Wang. Efficient Turing machine simulation with transformers, 2025b. arXiv:2512.00003.
Qian Li, Xinyu Mao, and Shang-Hua Teng. Rethinking the role of positional encoding: Sliding-window transformers without PE remain Turing complete, 2026. arXiv:2606.01532.
Zhiyuan Li, Hong Liu, Denny Zhou, and Tengyu Ma. Chain of thought empowers transformers to solve inherently serial problems. In Proceedings of the 12th International Conference on Learning Representations (ICLR), 2024. arXiv:2402.12875.
David Lindner, János Kramár, Matthew Rahtz, Thomas McGrath, and Vladimir Mikulik. Tracr: Compiled transformers as a laboratory for interpretability. In Advances in Neural Information Processing Systems 36 (NeurIPS 2023), 2023. arXiv:2301.05062.
William Merrill and Ashish Sabharwal. The parallelism tradeoff: Limitations of log-precision transformers. Transactions of the Association for Computational Linguistics, 11:531–545, 2023.
William Merrill and Ashish Sabharwal. The expressive power of transformers with chain of thought. In Proceedings of the 12th International Conference on Learning Representations (ICLR), 2024. arXiv:2310.07923.
William Merrill and Ashish Sabharwal. A little depth goes a long way: The expressive power of log-depth transformers. In Advances in Neural Information Processing Systems 38 (NeurIPS 2025), 2025. arXiv:2503.03961.
Jorge Pérez, Pablo Barceló, and Javier Marinkovic. Attention is Turing-complete. Journal of Machine Learning Research, 22(75):1–35, 2021.
Emil L. Post. Finite combinatory processes — formulation 1. Journal of Symbolic Logic, 1(3):103–105, 1936.
Ruizhong Qiu, Zhe Xu, Wenxuan Bao, and Hanghang Tong. Ask, and it shall be given: On the Turing completeness of prompting. In Proceedings of the 13th International Conference on Learning Representations (ICLR), 2025. arXiv:2411.01992.
Nikunj Saunshi, Nishanth Dikkala, Zhiyuan Li, Sanjiv Kumar, and Sashank J. Reddi. Reasoning with latent thoughts: On the power of looped transformers. In Proceedings of the 13th International Conference on Learning Representations (ICLR), 2025. arXiv:2502.17416.
Dale Schuurmans, Hanjun Dai, and Franco Zanini. Autoregressive large language models are computationally universal, 2024. arXiv:2410.03170.
Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), pages 464–468, 2018.
Lena Strobl, William Merrill, Gail Weiss, David Chiang, and Dana Angluin. What formal languages can transformers express? A survey. Transactions of the Association for Computational Linguistics, 12: 543–561, 2024.
Lena Strobl, Dana Angluin, David Chiang, Jonathan Rawski, and Ashish Sabharwal. Transformers as transducers. Transactions of the Association for Computational Linguistics, 13:200–219, 2025. doi:10.1162/tacl_a_00736. arXiv:2404.02040; extends B-RASP to transductions.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems 30 (NIPS 2017), 2017.
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed H. Chi, Quoc V. Le, and Denny Zhou. Chain-of-thought prompting elicits reasoning in large language models. In Advances in Neural Information Processing Systems 35 (NeurIPS 2022), pages 24824–24837, 2022.
Gail Weiss, Yoav Goldberg, and Eran Yahav. Thinking like transformers. In Proceedings of the 38th International Conference on Machine Learning (ICML 2021), volume 139 of Proceedings of Machine Learning Research, pages 9979–9991, 2021.
Kevin Xu and Issei Sato. A formal comparison between chain of thought and latent thought. In Proceedings of the 43rd International Conference on Machine Learning (ICML), 2026. arXiv:2509.25239, camera-ready version.
Andy Yang and David Chiang. Counting like transformers: Compiling temporal counting logic into softmax transformers. In Proceedings of the Conference on Language Modeling (COLM), 2024. arXiv:2404.04393; introduces C-RASP.
Chenxiao Yang, Nathan Srebro, David McAllester, and Zhiyuan Li. PENCIL: Long thoughts with short memory. In Proceedings of the 42nd International Conference on Machine Learning (ICML 2025), volume 267 of Proceedings of Machine Learning Research, pages 71092–71156. PMLR, 2025.
Liu Yang, Kangwook Lee, Robert D. Nowak, and Dimitris Papailiopoulos. Looped transformers are better at learning learning algorithms. In Proceedings of the 12th International Conference on Learning Representations (ICLR), 2024. arXiv:2311.12424.
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 Proceedings of the 12th International Conference on Learning Representations (ICLR), 2024. arXiv:2310.16028; introduces RASP-L.
A Congruent queue lengths
Grouping consecutive steps of a synchronous -queue machine into a single block requires that the front of queue at global step be the symbol written at the same intra-block offset of an earlier block. That symbol was written at step , so the alignment
holds for all and if and only if
In the conversion of Fact 2.2, level has two content-half queues of length and one buffer queue of length , where . We split the buffer into two queues of length , so that all four physical queues per stack at the level have the same length.
Lemma A.1. Prescribe and choose a fixed integer satisfying . Let and
Then the conversion can be implemented with queues, all four queues per stack at level g having length . Every queue length satisfies , and the resulting machine runs in steps using queue space. Moreover,
Proof. Run the conversion of Fact 2.2 with geometric base . Replacing by preserves the divisibility between consecutive levels and provides at least the original capacity. Split each length- buffer, as any queue of length can be simulated step-for-step by two queues of lengths and ; each stack now uses four length- queues per level, so a -tape machine uses queues. The split simulation is step-for-step equivalent to the original one.
By minimality,
because . Together with , this gives and . The conversion therefore takes steps and queue space. Finally, implies , while gives ; hence .
The construction introduces no additional transitions, so , the run length used in Proposition 4.2 and Theorem 4.3.
B Transformer components
This appendix specifies the transformer of Theorem 4.3 / Proposition 4.2 in full. Throughout, is the congruent synchronous -queue machine of Proposition 4.2, with a fixed alphabet , , halting states normalized as absorbing (Section 2), and lengths with integers ; , , so . The model is the looped transformer of Definition 3.1 with one decoder layer (), heads (head serves queue ), key dimension , value dimension , and loop count ; the same block, embedding, and output head are reused at every iteration and every pass. Fix an indexing map .
Indexing conventions. Coordinates of the residual stream are numbered from 0, as in the table of B.1: coordinate 0 holds the constant, the state block occupies coordinates with state (states counted from 0) at coordinate , and each symbol or front block occupies consecutive coordinates whose within-block offsets are the 1-based positions of symbols . Coordinates of value space and the concatenated head outputs are numbered from 1, while coordinates of key space are indexed by the head number : denotes the standard basis vector with index , and exists. Matrix entries are written , using the conventions of the respective spaces. The attention projections take the residual stream as input: thus reads the constant (residual coordinate 0) into key coordinate , while reads symbol block , offset , into value coordinate .
B.1 Vocabulary and embedding
. The generated token at position is — the state and the -tuple appended at log index — or, at halting, one of the two terminal tokens (B.6).
, laid out in blocks:
| coordinates | block | content |
|---|---|---|
| constant | ||
| state | one-hot of the state | |
| symbol | one-hot of | |
| front | one-hot of the attention-retrieved front; at embedding |
equals the displayed row of the table above,
terminal tokens take and (generation stops at either).
B.2 Relative positional encoding
The relative positional encoding (the form of Shaw et al., 2018; Li and Wang, 2025b, Eq. (2)): for distance ,
where is the fixed constant of Section 4.2 and is the basis vector of head coordinate . Head retrieves offset by the query , so . The encoding is unlearnable and depends on only — the learnable parameter vector is one and the same for all input lengths, the analogue of [Li and Wang, 2025b, Remark 2].
B.3 The attention heads
For head , the matrices and :
• Query : single nonzero entry , copying the constant coordinate of onto key coordinate . Then for every token, every iteration.
• Key : the keys carry no content; the positional encoding pos( ) of B.2 enters the key side of the scores (Section 3). In the cache only the value entries are informative.
• Score: . Over the window this is at the single position (in range at every pass, since and ) and 0 elsewhere. Self-attention has score 0 because . The unique maximum has gap (Section 4.2), so hardmax returns the one-hot vector .
• Value : for — the projection onto symbol block . With the write-time invariant (Lemma 4.1), , hence the head output
the front of queue r at machine step — the retrieval identity, using .
B.4 Head combination
with for every and , all other entries . The residual update concat writes the retrieved fronts into the front blocks; the constant, state, and symbol blocks pass through unchanged.
B.5 Feed-forward network: the transition
FF is a two-layer ReLU network of width (a machine constant) realizing where , with in the state block, in the symbol blocks, and in the front blocks of . For the transition lookup, define
equal to 1 exactly on the table row matching ; then
where onehot(f) is the concatenation of the K one-hot front blocks. The linear subtraction is implemented inside the two-layer ReLU network by passthrough units: every relevant coordinate of is nonnegative on the invariant domain, so . Coordinate 0 is left unchanged. Weights and biases belong to a fixed machine-dependent set, including the threshold bias ; total parameter bit-size is , constant for a fixed machine and independent of n and L. On invariant states, all intermediate sums range over a fixed finite set of half-integers, so a fixed machine-dependent numerical format suffices for exact evaluation. The absorbing convention for halting states (Section 2) is part of ; mid-pass halting needs no extra machinery.
B.6 Output head
. For each : and for every ; terminal rows . Since has exactly one nonzero per one-hot block, the ordinary row of the emitted token scores , every other ordinary row less, and the terminal rows score exactly when the state block is halting (and 0 otherwise): the argmax is at non-halting passes and ACCEPT/REJECT at halting ones. Entries are , constant for a fixed machine.
B.7 The loop and the input interface
One layer per unit (Definition 3.1 with ): for , the matrices of B.1–B.6 identical at every iteration. The per-iteration KV cache (Section 3) holds, for each position and iteration , the value entries — the keys are zero (B.3), the positional encoding entering only the scores (B.2). The input interface is the initialization of Section 4.3: the value entries of positions at all iterations contain the -tuples of the log, and the current token at position is . Generation starts at pass .
B.8 Faithfulness
Proposition B.1. Under the initialization of Section 4.3, the transformer of B.1–B.7 emits, at each pass , the token , and after passes the terminal token matching 's verdict on ; there is no other behavior.
Proof. The proof of Lemma 4.1 (Section 4.3) rests on two structural facts that hold verbatim for the components above: (a) within a pass, state moves only through the residual stream — the attention reads same-iteration value entries only, and each iteration's feed-forward network consumes the fronts its attention wrote; (b) value entries are frozen at write time. With the base case supplied by the initialization of Section 4.3 and the retrieval identity of B.3, the two-stage induction of Section 4.3 goes through unchanged; the output head of B.6 turns the final residual into the token or the verdict, and the absorbing convention makes mid-pass halting consistent.
C The exact softmax kernel contract
This appendix records the kernel contract of Section 5 exactly, the arithmetic behind the threshold, and the two kernel variants. Every attention score is a finite binary32 value (IEEE single precision; denotes round-to-nearest in binary32). Given a score row and value vectors , the kernel computes the attention output as follows:
• (i) compute the row maximum ;
• (ii) form the shifted inputs ;
• (iii) apply a fixed binary32 exponential primitive with and for every ;
• (iv) accumulate the numerator and the normalizer in binary32, dividing only after both sums;
• (v) cast the quotient once, at the output boundary, to a fixed format containing 0 and 1 exactly.
The exactness of Lemma 5.1 additionally requires the winner's value to be exactly representable in the accumulation format and preserved by the boundary cast; the fixed format of (v) contains 0 and 1 exactly, which covers the one-hot values used in this construction (Corollary 5.2), and not arbitrary real value vectors.
The threshold. Since , we have , the round-to-nearest midpoint between 0 and the least positive binary32 subnormal , so a correctly rounded binary32 exponential returns +0 on every input at most -256. Flush-to-zero only strengthens the property. Any cutoff larger than in magnitude has the same property; is chosen so that the rescaling factor of Corollary 5.2 is a power of two.
Remark. (1) The lemma requires a binary32 exponential that returns +0 below a fixed threshold, without positive floor or logit soft-capping. (2) Subtracting the maximum converts overflow into underflow and thereby helps to simulate hard selection. We include it in our softmax kernel because it is standard in production implementations. For a kernel that does not subtract the maximum, the positional encoding of Section 4.2 can set the winner’s score to 0 and every other score to -256. (3) If the kernel includes a positive scale, canonically , instantiate . Here is a machine constant, so remains .
D Detailed comparison of Turing-machine simulations
Table 3 compares transformers simulating -bounded Turing machines, extending the pointer given in Section 6.
Notation normalization. The rows “Li & Wang 2025a” and “Li & Wang 2025b” abbreviate Li and Wang [2025a] and Li and Wang [2025b], respectively; the row “Jiang et al. 2026” carries the venue year of Jiang et al. [2026]. Depth is printed as L for this work, where the source of each competitor row uses its own layer-count symbol; the main text likewise uses L for the generic decoder depth, which coincides with the loop count for the one-layer loop unit. This work’s window and CoT bounds presuppose the admissibility condition and the loaded-cache interface of Section 4.3; the initialization cost is excluded from this work’s bounds (the comparison rows report the sources’ own generation accounting).
PyTorch’s CPU and CUDA softmax kernels (host_softmax and SoftMax.cu’s epilogue exp(input - max)/sum), FlashAttention’s online softmax (exponentiating score · scale - max · scale), Triton’s fused-softmax kernel (“subtract maximum for numerical stability”), and TensorFlow’s softmax op (shifted_logits = logits - max) all evaluate the exponential only on inputs shifted by the row maximum. This observation concerns that one step; it does not establish full conformance of any production kernel, in particular not of online or fused implementations with their own epilogues.
| Source | Precision | Dim. | Depth | Window | CoT per TM-step |
| Pérez et al. 2021 | |||||
| Bhattamishra et al. 2020 | unbounded | ||||
| Merrill & Sabharwal 2024 | |||||
| Li et al. 2024 | amort. | ||||
| Qiu et al. 2025 | amort. | ||||
| Li & Wang 2025a | |||||
| Li & Wang 2025b | |||||
| Jiang et al. 2026 | unbounded | per counter step | |||
| Brösamle & Eckstein 2026 | (SCoT) | amort. | |||
| This work |
◇ marks constructions using softmax attention (this work via the finite-precision kernel of Section 5).
Li & Wang 2025b report only the head-layer product ; their depth is left unspecified.
Li et al. [2024] state embedding dimension under the assumption that is polynomial, so .
Table 3: Comparing transformers simulating -bounded Turing machines. Depth is the number of sequential decoder layers as reported by each source; for this work it is the loop count —one shared decoder block executed times per generated token. This work prescribes and chooses subject to ; Li & Wang 2025b is the endpoint .
E Notation
| Symbol | Formally defined | Meaning |
|---|---|---|
| , | time and space bounds of the simulated Turing machine | |
| fixed hierarchy exponent ; tape count | ||
| queue count ; number of attention heads | ||
| loop count, and the decoder depth: one shared block executed times per token | ||
| execution-log step index | ||
| hierarchy level index () | ||
| execution log: -tuple appended and state at step | ||
| run length after the cache is filled | ||
| generated tokens; exactly , asymptotically | ||
| pass (position) and iteration indices | ||
| length of queue ; ; | ||
| congruent queue base; (cited conversion) | ||
| residual dimension ; key dim. ; value dim. | ||
| attention score (row , candidate ) | ||
| score gap; set to 256 in Corollary 5.2 | ||
| kernel row maximum; shifted input; binary32 exponential | ||
| layers per loop unit ( in the construction) |