Paper commentary
Ehrenfeucht-Haussler Rank and Chain of Thought
Chain-of-thought steps equal rank for single-layer hard-attention transformers
- Problem Rank measures how hard a Boolean function is for decision trees, but nobody had linked it to chain-of-thought steps in Transformers. So it was unclear how many steps a small Transformer needs for a given function.
- Method The authors show that rank equals the minimum number of chain-of-thought steps a single-layer hard-attention Transformer needs. Each step asks one assignment query, which the decoder answers by attending to the earliest consistent position.
- Results The authors prove that the H-head rank of t-Comp equals t for all but finitely many input lengths. So adding attention heads does not reduce the number of chain-of-thought steps needed for t-Comp.
Why rank needs a Transformer reading
Rank is a decision-tree complexity measure that Ehrenfeucht and Haussler defined for Boolean functions. A Boolean decision tree queries one coordinate of the input at each node. The rank of a non-leaf node is computed from the ranks of its two children, and the rank of the tree is the rank of its root. Its main payoff is in learning theory, since for any constant r, functions of rank at most r are properly PAC-learnable in polynomial time.
Ehrenfeucht and Haussler also derived a quasipolynomial-time PAC-learning algorithm for polynomial-size decision trees from this result.
The authors connect this measure to decoders, where each iteration appends a new output to the input sequence. Those iterations are the chain-of-thought steps that the literature studies. Earlier work asked what decoders can compute as the number of iterations grows, with results for unbounded iterations. Merrill and Sabharwal showed that polynomially many iterations with constant layers and softmax attention compute any polynomial-time language.
Those results don't say how many iterations a fixed-size decoder needs for a given function. The present answer covers a single layer with hard attention, and it is the first exact characterization of that kind. Peng et al. showed that a single-layer decoder with soft attention requires Ω( t) iterations to compute t-Comp.
Hard attention is a theoretical stand-in for the soft attention used in practice. The authors chose hard attention because it is amenable to formal analysis. Hard attention makes the decoder-depth question tractable, since the attention layer picks a single element per head.
Assignment queries and the rank of a function
The key tool is the assignment query, which scans a fixed ordering of assignments and returns the first one consistent with the input. An assignment is a pair (i, σ), and it is consistent with an input when the i-th letter equals σ. The query is defined by a permutation τ of all assignments, so every input gets exactly one answer. Think of it as asking a person who knows the input whether letter i1 equals σ1, then i2 equals σ2, and so on.
The process stops at the first YES, and the answer is that assignment. A decision tree over such queries has a depth, and rk(f) is the minimal depth over all trees computing f. This extends the rank from Boolean decision trees, where each query reads one coordinate, to arbitrary alphabets.
For Boolean functions the new definition agrees with Ehrenfeucht and Haussler's rank, and the paper proves this in Proposition 1. The proof converts a Boolean decision tree of rank r into a depth-r tree over assignment queries. Each step asks one assignment query, and the node reached after t queries is tracked for every input. On the Transformer side, one attention layer scores every earlier position against the last token and keeps the highest scorer.
Ties go to the leftmost position, so unique hard attention always picks a single index. The selected vectors are then combined through the matrix WO and a ReLU step. A decoder runs this layer over its input and appends each output, so every new output is one chain-of-thought step. The decoder depth dd(H)(f) is the least number of such steps needed to compute f with H heads.
Why decoder depth equals rank
A decoder can simulate one assignment query per iteration, and a decision tree over assignment queries can be run back as a decoder. With one head, knowing the first t outputs lets the decoder compute the next head value by asking one assignment query about the input. Each decoder step appends its output to the sequence, so the input to the next step contains all earlier answers.
In the decoder construction, each output vector stores the current tree node as a one-hot pattern over the output coordinates. The positional encoding of each assignment is set so that the attention head returns the assignment that the current node's query would return. For a non-leaf node v and head i, the coordinate of an assignment is 1 over the position of that assignment in the permutation, so the earliest consistent assignment gets the highest score.
With H heads, the positional and assignment coordinates are multiplied by H, and the output matrix copies each head's one-hot answer into its own block. The sum of the state and the merged heads then has exactly H + 1 ones, one-hot encoding the current node and the H answers. The next output is a child of the current node followed by the labeled edge, and W1 expresses each output bit as a conjunction of H + 1 inputs using ReLU.
Theorem 2 states that for any H, the H-head rank equals the H-head decoder depth. The direction rk(H)(f) at most dd(H)(f) follows from the single-head argument, with H a-queries composed into one H-degree a-query per step. As a concrete case, the authors build a one-head layer of embedding dimension six that computes t-Comp in t iterations.
The attention score of position i equals a cosine difference that peaks at i equal to f applied to 1 at the current step, so the head reads off the next iterate.
Multi-head lower bound for t-Comp
The authors show that extra heads cannot shorten the t-Comp chain, by turning a fast multi-head decoder into a cheap two-party protocol. Proposition 5 gives a first bound: the H-head rank is at least the standard rank divided by H, since each H-degree query is H sequential queries. That bound alone is too weak for t-Comp, because the standard rank only gives a lower bound up to a factor of H.
So the authors turn to communication complexity, a method they use for the iterated composition function.
In this setting, Alice and Bob each know part of the input word, and they want to compute the output together. Lemma 1 bounds the protocol cost for any split S of the input by 2Hr times the ceiling of log2 of the number of assignments, in both Alice-first and Bob-first form. Each player sends indices of H assignments, so one H-degree query costs H times the ceiling of log2 a bits.
The protocol runs in r+1 rounds, because the two players alternate who sends first from query to query.
The authors reduce from pointer chasing, a problem where Alice holds fA and Bob holds fB. Alice-first protocols solve the k-step pointer chase with O(k log m) bits, since Alice sends m1 = fA(1) and Bob replies. For any constant k, however, Bob-first protocols need Ω(m) bits, and this gap is what the reduction exploits. The pointer chase PC with n/2t steps is a special case of t-Comp, with Alice holding the first half of ϕ and Bob the second half.
Corollary 3 concludes that for every H and t, the H-head rank of t-Comp equals t for all but finitely many n. The upper bound rk(t-Comp) at most t holds for every n, so the equality makes the bound tight. The result answers the section question: adding attention heads does not reduce the number of CoT steps needed for t-Comp. The lower bound is proved for every fixed H, and it holds for large enough input lengths only.
Why k-thOne needs k steps
The first step finds the first one, the second step finds the next one, and so on. The authors prove that, for large enough n, extra attention heads don't lower this count below k.
The upper bound uses a permutation that starts after the last position found, so each query returns the next one. The first a-query uses the ordering that lists the assignments (1, 1) through (n, 1) before the zeros. If the input has no ones, the query returns (1, 0), and the algorithm outputs n + 1 at once. For the lower bound, the proof assumes a depth-d tree with k greater than d and n at least k squared plus k minus 1.
It fixes at most d positions so that many inputs reach the same leaf of the tree. Because the fixed positions split the rest into at most k intervals, one interval has length at least k + 1. Filling the first k minus 1 minus s positions of that interval with ones makes both the k-th and the (k+1)-st positions possible answers. Two inputs reaching one leaf with different answers is a contradiction, so the depth must be at least k.
The authors note that this result cannot be obtained with the communication techniques used for t-Comp. Their proof therefore relies on a purely combinatorial argument.
PAC learning with bounded multi-head rank
Proper PAC learning reduces to the consistency problem, where one asks whether some hypothesis fits a given labeled sample. The authors' version of this result covers the 1-head rank, which coincides with the Ehrenfeucht and Haussler rank. The classes of functions with H-head rank at most k are the objects the authors study here.
The proof is an induction on k, with the base case k = 0 covering only the all-0 and all-1 functions. A lemma shows that a rank-(k+1) consistent sample has some assignment whose subsample is rank-k consistent. The algorithm recurses on the sample with that assignment's subsample removed, and it fills in the subtree under that assignment with a rank-k tree.
Each recursive call runs on a strictly smaller sample, which keeps the algorithm polynomial.
For H heads, Proposition 5 places the class inside functions of 1-head rank at most kH, so the class is improperly learnable. The authors show that deciding consistency for 2-head rank at most 1 over the binary alphabet is NP-complete. So functions of 2-head rank at most 1 are not properly PAC-learnable in polynomial time unless NP is contained in BPP.
This is adjacent to, but not the same as, the Pitt and Valiant result on 2-term DNFs.
The hardness proof reduces from the 2-order separability problem, which is NP-complete by a reduction from monotone NAE-3-SAT. The reduction maps each set to a characteristic vector, and the 0-assignments are placed below the 1-assignments in both orders. A gadget forces all but one 1-assignment in the working coordinates to sit above the 0-assignments in both orders.
The construction uses 3n+3 coordinates for a universe of size n: 3n working coordinates and 3 auxiliary ones.
Limitations and open directions
The exact results cover only single-layer decoders with hard attention, so the authors name extending the characterization to more layers or to soft attention as a challenging future direction. Their characterization is an exact one for a fixed number of iterations, but it does not reach the soft-attention case. The authors' main claims hold for unique hard attention, where each head selects one position.
Ties in the attention score are broken by taking the leftmost maximizing index.
The t-Comp lower bound holds for all but finitely many n, so small input lengths fall outside it. The k-thOne equality rk(k-thOne) = k needs n to be at least k squared plus k, and it doesn't cover smaller inputs. The lower bounds do not require assumptions on the embedding dimension or the number of bits of precision, unlike the soft-attention bound of Peng et al., which needs Ω(t) iterations for t equal to the square root of n divided by dHp.
The decoder construction behind the upper bounds uses one head and embedding dimension six for t-Comp.
The hardness result for 2-head rank-1 functions is conditional, holding unless NP is a subset of BPP. The authors plan to check whether the techniques of Chen et al. can strengthen their results.
Paper info
- Authors
- Pablo Barceló, Alexander Kozachinskiy, Tomasz Steifer
- Venue
- arXiv · Preprint
- First published
- 2025-1-22
- Added
- 2026-10-30
- Updated
- 2025-8-11
- Version
- v2
- arXiv
- 2501.12997
- Category
- cs.LG · cs.AI
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
The notion of \emph{rank} of a Boolean function has been a cornerstone in PAC learning theory, enabling quasipolynomial-time learning algorithms for polynomial-size decision trees. We present a novel characterization of rank, grounded in the well-known Transformer architecture. We show that the rank of a function $f$ corresponds to the minimum number of \emph{Chain of Thought} (CoT) steps required by a single-layer Transformer with hard attention to compute $f$. Based on this characterization we establish tight bounds on the number of CoT steps required for specific problems, showing that \(\ell\)-fold function composition necessitates exactly \(\ell\) CoT steps. Furthermore, we analyze the problem of identifying the position of the \(k\)-th occurrence of 1 in a Boolean sequence, proving that it requires \(k\) CoT steps. Finally, we introduce the notion of the multi-head rank that captures multi-head single-layer transformers, and perform the analysis of PAC-learnability of the classes of functions with bounded multi-head rank.
Quote from the paper
Pablo Barceló, Alexander Kozachinskiy, Tomasz Steifer (2025). Ehrenfeucht-Haussler Rank and Chain of Thought. arXiv:2501.12997v2. https://arxiv.org/abs/2501.12997v2
BibTeX
@misc{barcel2025ehrenfeucht,
title = {{Ehrenfeucht-Haussler Rank and Chain of Thought}},
author = {Pablo Barceló and Alexander Kozachinskiy and Tomasz Steifer},
year = {2025},
eprint = {2501.12997},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2501.12997v2}
}