arXiv:2610.25998cs.CCOct 2026

Manuscript Offprint

arXiv:2610.25998

Internalizing Chain-of-thought into Looped Transformers

Kehang Zhou, Pinyan Lu

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 L=L(n)L = L(n) and a fixed integer k≥1k \geq 1 satisfying s(n)1/k=Ω(L)s(n)^{1/k} = \Omega(L), our transformer simulates a time-t(n), space-s(n) Turing machine using a context window of O(s(n)/L)O(s(n)/L) and O(t(n)s(n)1/k/L)O(t(n)s(n)^{1/k}/L) generated tokens, reducing both resources by a factor of LL 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 O(s(n))O(s(n)) [Schuurmans et al., 2024, Yang et al., 2025, Brösamle and Eckstein, 2026], while precision is reduced first to O(log⁡(n+t(n)))O(\log(n + t(n))) 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 O(s(n)1/k)O(s(n)^{1/k}) 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 Θ(s(n))\Theta(s(n)) machine cells, and attention at that iteration reads only O(s(n)/L)O(s(n)/L) positions. A context window of that length therefore completes the simulation of an s(n)s(n)-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, k′k' is the number of tapes of the simulated machine and k is the hierarchy parameter of the queue simulation (Section 2).

Theorem (informal). Any (t(n),s(n))(t(n), s(n)) 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 K=8kk′K = 8kk' and context window length O(s(n)/L)O(s(n)/L), that takes O(s(n)1/k/L)O(s(n)^{1/k}/L) CoT steps for each simulated TM step, leading to a total CoT length of O(t(n)⋅s(n)1/k/L)O(t(n) \cdot s(n)^{1/k}/L), for every loop count L=L(n)L = L(n) and every fixed integer k≥1k \geq 1 with s(n)1/k=Ω(L)s(n)^{1/k} = \Omega(L). At L=1L = 1, 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.

References (44)