Alphabeta Math
Pipeline-generated
How statement and proof provenance work

The first chip identifies the source of the statement or construction; the second identifies the source of its local proof or verification.

  • Literature-sourced: the exact statement appears in a cited source; only wording and notation differ.
  • AI-adapted: a semantically identical restatement of literature-sourced material, modulo indexing, notation, and boundary cases adopted by the library.
  • AI-generated: a genuinely novel statement formulated by AI, with no source for the claim itself.

These labels describe origin, not correctness: citations and verification chips remain separate evidence.

✓ 12 results · all verified · 3 also independently AI-judged
Every result on this page is machine-checked by a proof checker and read in full and owner-audited; the judge is an additional, independent cross-model AI review of the proofs. The 9 not AI-judged were verified by owner audit (typically over a confirmed judge false positive), not failures.

Attention, transformer universality, and sequence limits

1 · Prerequisites

2 · Logical flowchart

3 · Definitions, theorems and proofs

LemmaStatement: AI-adaptedProof: AI-adaptedprecheck pendingjudge pass (gpt-6-luna)Open item page →

Exact 2DYCK PCFG prefix laws and positive paired-prefix mass

Statement

Fix p∈(0,1). Independently expand each nonterminal of the grammar S→(S)S, S→[S]S, S→ϵ with respective probabilities p/2,p/2,1−p, and read the yield from left to right. Equivalently, start with an empty bracket stack and repeatedly choose an opening bracket of either type with probability p/2 each, pushing its type; with probability 1−p, close the top bracket when the stack is nonempty, or emit eos and stop when it is empty. This defines a probability law on finite words followed by eos and on infinite bracket streams. For a valid bracket prefix x, let o(x),c(x) and h(x)=o(x)−c(x) denote its opening count, closing count and final stack height. Its cylinder probability is

wp(x)=(p/2)o(x)(1−p)c(x).

For every k≥0, let sp,k=∑∣x∣=kwp(x), summing over valid prefixes, and define Dp,k(x)=wp(x)/sp,k. Thus Dp,k conditions only on having emitted at least k bracket tokens, without conditioning on eventual termination or exact total length. The target after a sampled prefix is its ordinary next token in the same process. At positive height its law assigns p/2 to each opening type and 1−p to the matching closing type.

For k≥3, let Ek consist of prefixes whose last three symbols are an opening of type a, an opening of type b, and the closing of type b, with a,b independently ranging over the two types. These prefixes have positive final height and end in a closing bracket. Flipping the opening type a at position k−2 is a fixed-point-free involution of Ek into equal-mass pairs; paired prefixes differ only at this nonfinal position and their top unmatched opening types are opposite. Moreover,

Dp,k(Ek)=p2(1−p)sp,k−3sp,k≥p2(1−p)>0.

The finite-word mass of a typed Dyck word of length 2m is (p/2)m(1−p)m+1. The total finite-word mass is qp=1 for p≤1/2 and qp=(1−p)/p for p>1/2. After conditioning on eventual termination, the finite-word probability law and all its prefix laws are exactly those of the preceding process with parameter a=pqp=min⁡(p,1−p); consequently its survival-conditioned prefixes have the same pairing bound a2(1−a). Conditioning instead on exact word length 2m yields the uniform law on typed Dyck words of that length, independently of p; that conditioning is different and does not retain the displayed next-token probabilities.

Facts & Assumptions

Given: The independent grammar choices, stack process, valid prefixes and conditioning conventions in the Statement.

Proof

1.1givenconstructalgebra

In a left-to-right grammar expansion, expanding the current S nontrivially emits its opening bracket and leaves an inner S, its matching closing bracket, and a following S. Choosing ϵ finishes the current S and either emits the pending matching close or, when no close is pending, ends the word. Thus each token is generated by precisely the stack transition stated above. The remaining choices after any finite emitted prefix are fresh independent choices. This constructs the stream law directly, including on nonterminating samples. Each valid prefix uniquely specifies the transition choices so far: every opening requires its type choice and every closing requires an epsilon choice. Their product is wp(x). In particular sp,k is the probability of reaching k bracket tokens, is positive (all-open prefixes have positive probability), and is nonincreasing in k. Conditioning on reaching k does not constrain the fresh choice after the prefix.

1.2givenconstructalgebra

The grammar is unambiguous: a nonempty Dyck word has a unique first opening, its matching closing, and the resulting inside and following Dyck words, which recursively determine the derivation. A word with m bracket pairs has m nonempty choices and m+1 epsilon leaves, proving its stated finite-word mass. To calculate total termination mass, the probabilities of trees having height below successive finite bounds start at q0=0 and satisfy qj+1=1−p+pqj2. Their increasing limit is the probability of a finite tree: every finite binary tree has finite height, and an infinite finitely branching tree cannot have bounded height. The limit is the least fixed point in [0,1], since iteration from zero stays below any nonnegative fixed point. The roots are 1 and (1−p)/p, giving the stated qp. The stream is finite exactly when the derivation is finite: every nonempty expansion emits an opening and any derivation with only finitely many nonempty expansions has only finitely many nodes.

2.1step 1.1givenconstructalgebra

Each prefix in Ek is uniquely u a b b‾, where u is a valid prefix of length k−3. Such an extension is always valid, has height h(u)+1, and has the a-opening as its top unmatched opening. Its cylinder weight is wp(u)(p/2)2(1−p). Summing the four choices of a,b and then all u gives p2(1−p)sp,k−3. Divide by sp,k and use monotonicity from step 1.1 to obtain the bound. Flipping a changes no count, leaves the suffix pattern valid, and changes only position k−2; applying the flip twice restores the prefix. There are no fixed points, so its orbits are disjoint equal-mass pairs with swapped closing targets.

3.1step 1.1step 2.1step 1.2algebra∎

After a valid prefix of height h, the left-to-right residual derivation contains exactly h+1 still independent S subtrees (and h pending closing brackets). Its probability of eventual termination is therefore qph+1. Consequently the termination-conditioned prefix cylinder is wp(x)qph(x)+1/qp=(pqp/2)o(x)((1−p)/qp)c(x). The fixed-point equation gives (1−p)/qp=1−pqp. This is exactly wa(x) with a=pqp. The finite-word laws likewise agree, either by the same calculation including the final epsilon or directly from step 1.2. Applying step 2.1 with a gives its pairing bound. Finally all typed Dyck words of a fixed length have the same mass by step 1.2 and there are finitely many of them, proving the uniform exact-length law and the asserted distinction of conditioning.

DefinitionDefinition: Literature-sourcedProof: Not applicablejudge pass (gpt-6-luna)Open item page →

Scaled dot-product attention

Definition

Let nq,nk,dk,dv be positive integers, let Q∈Rnq×dk and K∈Rnk×dk be query and key matrices, and let V∈Rnk×dv be a value matrix. For a real matrix S with nq rows and nk columns, define its row softmax by softmax⁡row(S)ij=exp⁡(Sij)/∑ℓ=1nkexp⁡(Siℓ). The scaled dot-product attention output is

Attn⁡(Q,K,V)=softmax⁡row ⁣(QKTdk)V∈Rnq×dv.

Each output row is the weighted average of the value rows, with weights given by the softmax of that query's scaled dot products with all keys. A mask is an array M∈(R∪{−∞})nq×nk whose entries are 0 for allowed query-key pairs and −∞ for disallowed pairs; masked attention replaces the score matrix by QKT/dk+M before row softmax and is defined only when every row has at least one allowed key. Here exp⁡(−∞)=0.

DefinitionDefinition: Literature-sourcedProof: Not applicableOpen item page →

Positional encodings and causal masks

Definition

For a sequence of length n with d-dimensional token representations, a positional encoding is a fixed or trainable matrix P∈Rn×d added rowwise to the token matrix X∈Rn×d, giving X+P. One fixed choice, with positions s∈N0 and coordinates indexed from 0, is Ps,2r=sin⁡(s/100002r/d) and Ps,2r+1=cos⁡(s/100002r/d) whenever the indicated coordinate is less than d.

For decoder self-attention on n positions indexed by 0,…,n−1, the causal mask is M∈(R∪{−∞})n×n with Mij=0 when j≤i and Mij=−∞ when j>i. Thus query position i can use keys at positions 0,…,i and cannot use a future position; every row has an allowed key because Mii=0.

LemmaStatement: AI-adaptedProof: AI-adaptedprecheck pendingjudge pass (gpt-6-luna)Open item page →

Close paired predictions incur mixture entropy

Statement

Let Σ be a finite alphabet of size m≥1. Let r,s,q,q′ be probability vectors on Σ, and let ϵ≥0 satisfy ∥q−q′∥1≤ϵ. For CE⁡(r,q)=−∑ar(a)log⁡q(a), with value +∞ if r(a)>0=q(a), and H(r)=−∑a:r(a)>0r(a)log⁡r(a), the paired loss satisfies

12CE⁡(r,q)+12CE⁡(s,q′)≥H ⁣(r+s2)−log⁡(1+mϵ).

In particular, predictions whose ℓ1 distance tends to zero cannot have asymptotic paired loss below the entropy of the mean target law.

Facts & Assumptions

Given: Probability vectors r,s,q,q′ on a finite alphabet, with ∥q−q′∥1≤ϵ.

Proof

1.1givenconstructalgebra

Put rˉ=(r+s)/2 and qˉ=(q+q′)/2. For every a∈Σ, q(a)≤qˉ(a)+ϵ and q′(a)≤qˉ(a)+ϵ. Define w(a)=(qˉ(a)+ϵ)/(1+mϵ); its coordinates are nonnegative and sum to one. Monotonicity of −log⁡ on positive reals gives 12CE⁡(r,q)+12CE⁡(s,q′)≥CE⁡(rˉ,w)−log⁡(1+mϵ). If a term on the left is infinite, the claimed inequality is immediate; otherwise this comparison is valid on each target-positive coordinate.

2.1step 1.1givenalgebra∎

For any probability vectors rˉ,w, if w(a)=0<rˉ(a) then CE⁡(rˉ,w)=+∞. Otherwise CE⁡(rˉ,w)−H(rˉ)=∑a:rˉ(a)>0rˉ(a)log⁡(rˉ(a)/w(a))≥0: applying log⁡t≤t−1 to t=w(a)/rˉ(a) gives the sum at least ∑a:rˉ(a)>0(rˉ(a)−w(a))≥0. Combining with step 1.1 proves the bound.

DefinitionDefinition: Literature-sourcedProof: Not applicablejudge pass (gpt-6-luna)Open item page →

Multi-head attention and self-attention

Definition

Let h,dq,dk,dv,dh,dvh,do,nq,nk be positive integers. For query, key, and value matrices Q∈Rnq×dq, K∈Rnk×dk, and V∈Rnk×dv, choose matrices WiQ∈Rdq×dh, WiK∈Rdk×dh, and WiV∈Rdv×dvh for each head i=1,…,h, and choose WO∈Rhdvh×do. The i-th head is

Hi=Attn⁡(QWiQ,KWiK,VWiV)∈Rnq×dvh,

where Attn⁡ is scaled dot-product attention, with any chosen mask applied to its score matrix. Multi-head attention is

MHA⁡(Q,K,V)=Concat⁡feature(H1,…,Hh)WO∈Rnq×do.

Self-attention is the specialization Q=K=V=X for a single token matrix X∈Rn×d; each row is one token representation. Unmasked self-attention permits every query row to use every key row. Masked self-attention applies one specified mask to every head.

DefinitionDefinition: Literature-sourcedProof: Not applicableOpen item page →

Hard and soft attention sequence models

Definition

Let Σ be a finite token alphabet, let eos∉Σ be an end-of-sequence symbol, and let d,L,H≥1 be fixed integers. For each length n≥1, an input is (x1,…,xn−1,eos). A symbol embedding assigns a vector va∈Rd to each a∈Σ∪{eos}; a positional embedding sequence assigns pi∈Rd independent of the input symbols. A fixed shared input map gives yi(0)=fin(vxi,pi). For each layer k=1,…,L and head h=1,…,H, a fixed score map sk,h:Rd×Rd→R gives scores ai,j(k,h)=sk,h(yi(k−1),yj(k−1)) for every query position i and key position j. In the soft model, a^i,⋅(k,h)=softmax⁡(ai,⋅(k,h)). In the hard model, a^i,j(k,h)=1 at the smallest index j attaining max⁡r≤nai,r(k,h) and is 0 at other indices. With fixed value maps Vk,h:Rd→Rd and fixed positionwise maps Fk:(Rd)H+1→Rd, the update is

bi,k,h=∑j=1na^i,j(k,h)Vk,h(yj(k−1)),yi(k)=Fk(yi(k−1),bi,k,1,…,bi,k,H).

Each score, value, and positionwise map is shared across positions and is fixed independently of n. In the hard-attention limit theorem, the score, value, and positionwise maps may be arbitrary fixed maps; no activation-function or parameter-norm bound is imposed. For the soft-influence theorem below, each score is a scaled dot product of fixed linear query and key projections, each value map is a fixed linear map, the token and positional embeddings are uniformly bounded over all positions and lengths, the combined initial states satisfy sup⁡i≥1, a∈Σ∪{eos}∥fin(va,pi)∥2<∞, and every positionwise map is globally Lipschitz. The initial-state bound holds for addition or concatenation of bounded embeddings, but must be imposed separately for an arbitrary input map. A hard-attention recognizer classifies the input from yn(L) after reading eos. A soft next-token predictor applies a fixed linear logit map and softmax to yn(L) to obtain a probability vector on a fixed finite alphabet.

Definition references

Hahn, §3: positionwise activations, softmax attention, hard attention, and end-of-sequence prediction

Vaswani et al., §3.2: query, key, value, and scaled dot-product attention conventions

Finite feedforward computation graphs and layered MLPs: finite feedforward graphs and layered MLPs specify positionwise maps when those implementations are chosen; the abstract hard-attention model above also permits arbitrary fixed maps.

Scaled dot-product attention: row softmax and scaled query-key products.

DefinitionDefinition: Literature-sourcedProof: Not applicableOpen item page →

Transformer encoder, decoder, and fixed-width expressivity blocks

Definition

Fix positive integers d,dff,n,m, where d is the model width, dff is the feedforward hidden width, and n,m are the encoder and decoder sequence lengths. A row-token matrix X∈Rn×d has one token in each row. Define ReLU⁡(t)=max⁡(0,t) and apply it coordinatewise to vectors and matrices. A positionwise feedforward network with parameters W1∈Rd×dff, b1∈Rdff, W2∈Rdff×d, and b2∈Rd maps each row x to ReLU⁡(xW1+b1)W2+b2, using the same parameters at every position. For z∈Rd, let zˉ=d−1∑r=1dzr and s2(z)=d−1∑r=1d(zr−zˉ)2. Layer normalization with parameters γ,β∈Rd and ϵ>0 is

LN⁡γ,β,ϵ(z)=γ⊙z−zˉ1s2(z)+ϵ+β,

applied rowwise; ⊙ is coordinatewise multiplication. The positive ϵ makes the denominator nonzero.

Every multi-head attention sublayer in the following post-normalized encoder and decoder layers has query, key, value, and output feature widths dq=dk=dv=do=d in def-multihead-self-attention, with its own projection parameters. The head count h and head widths dh,dvh remain arbitrary positive integers, and the output projection has shape WO∈Rhdvh×d. Thus each attention output has the same row count and feature width as its residual input. Any attention mask must leave at least one allowed key in every query row; positive key length supplies this for unmasked attention, and the decoder causal mask supplies it through its diagonal.

A post-normalized encoder layer is the composition

S=LN⁡γ1,β1,ϵ1 ⁣(X+MHA⁡(X,X,X)),Y=LN⁡γ2,β2,ϵ2 ⁣(S+FFN⁡(S)).

A post-normalized decoder layer takes decoder states U∈Rm×d and encoder states E∈Rn×d. It first applies masked self-attention to U using the causal mask, then cross-attention with queries from the resulting decoder states and keys and values from E, and then a positionwise feedforward network; each sublayer output is added to its own input and followed by layer normalization. The decoder's causal mask admits keys at positions j≤i for query position i. Encoder and decoder stacks are finite compositions of their respective layers, with positional encodings added to token embeddings before the stacks.

The diagram records the dataflow and residual branches of one encoder layer and one decoder layer. Each arrow is a tensor passed to the indicated sublayer; each “Add & LN” node adds its sublayer input to its output and applies the stated rowwise layer normalization. The encoder output E supplies the key and value rows for decoder cross-attention. The diagram illustrates the definition and is not used in any proof.

diagram failed to render:
\begin{tikzpicture}[>=stealth,scale=0.72,transform shape]
  \tikzstyle{blk}=[draw,rounded corners,align=center,font=\small,minimum width=1.35cm,minimum height=0.65cm]
  \node[blk] (ex) at (0,0) {$X$};
  \node[blk] (em) at (2.0,0) {MHA\\self-attn};
  \node[blk] (ea) at (4.0,0) {Add \& LN};
  \node[blk] (ef) at (6.0,0) {Positionwise\\FFN};
  \node[blk] (eo) at (8.0,0) {Add \& LN};
  \node[blk] (ey) at (10.0,0) {Encoder\\output $E$};
  \draw[->] (ex) -- (em);
  \draw[->] (em) -- (ea);
  \draw[->] (ex.south) to[bend right=28] (ea.south);
  \draw[->] (ea) -- (ef);
  \draw[->] (ef) -- (eo);
  \draw[->] (ea.south) to[bend right=28] (eo.south);
  \draw[->] (eo) -- (ey);

  \node[blk] (dx) at (0,-2.3) {$U$};
  \node[blk] (dm) at (2.0,-2.3) {Causal\\self-attn};
  \node[blk] (da) at (4.0,-2.3) {Add \& LN};
  \node[blk] (dc) at (6.0,-2.3) {Cross-attn\\to $E$};
  \node[blk] (db) at (8.0,-2.3) {Add \& LN};
  \node[blk] (df) at (10.0,-2.3) {Positionwise\\FFN};
  \node[blk] (do) at (12.0,-2.3) {Add \& LN};
  \draw[->] (dx) -- (dm);
  \draw[->] (dm) -- (da);
  \draw[->] (dx.south) to[bend right=25] (da.south);
  \draw[->] (da) -- (dc);
  \draw[->] (dc) -- (db);
  \draw[->] (da.south) to[bend right=25] (db.south);
  \draw[->] (db) -- (df);
  \draw[->] (df) -- (do);
  \draw[->] (db.south) to[bend right=25] (do.south);
  \draw[->] (ey.south) -- (dc.north);
\end{tikzpicture}

The fixed-width expressivity result uses a different, explicitly defined block without layer normalization. In the column-token convention X∈Rd×n, one Yun attention sublayer with two heads of size one is

Attn⁡Y(X)=X+∑i=12WOiWViX softmax⁡col ⁣((WKiX)T(WQiX+bQi1nT)),

where WQi,WKi,WVi∈R1×d, WOi∈Rd×1, and bQi∈R is a shared scalar query bias; softmax⁡col normalizes each column over its key positions. Its tokenwise feedforward sublayer is

FF⁡Y(Z)=Z+W2ReLU⁡(W1Z+b11nT)+b21nT,

with W1∈R4×d and W2∈Rd×4. A Yun block is FF⁡Y∘Attn⁡Y, and T2,1,4 is the set of all finite compositions of such blocks. Its positional class consists of maps X↦g(X+E) with g∈T2,1,4 and a trainable E∈Rd×n. This expressivity block has no layer normalization; its widths and head sizes are exactly as displayed.

LemmaStatement: Literature-sourcedProof: AI-adaptedprecheck pendingOpen item page →

Hard-attention depth reduction under input restrictions

Statement

Fix a finite content alphabet Σ with s=∣Σ∣≥2, a hard-attention model with fixed H≥1 heads per position and L≥1 layers, and an integer c≥1. At length n, the model input is (x1,…,xn−1,eos), with the end marker fixed at position n. An input restriction assigns each content position i<n either ∗ (free) or a fixed symbol of Σ; its free positions are precisely the content positions marked ∗. Say that a layer-zero activation, including the activation at the end-marker position, depends on at most c free positions if, with the restriction fixed, its value is determined by at most c of the remaining free input symbols. Suppose the current restriction leaves at least Cn content positions free for every sufficiently large n, where 0<C≤1, and every layer-zero activation depends on at most c free positions. For every 0<C′<C, there are an integer c′≥1 and a refinement, for every sufficiently large n, that leaves at least C′n content positions free and preserves the model's output on every completion, while absorbing the first remaining attention layer into new layer-zero activations that each depend on at most c′ original content positions. Repeating this conclusion through the fixed L layers gives a restriction with at least C′n free content positions on which the output depends on at most a constant number of original content positions. The constants and the length threshold may depend on the fixed model, c,C,C′, but not on n.

Facts & Assumptions

Given: A fixed hard-attention model, a current input restriction, and the free-input and c-dependence hypotheses in the Statement.

[F1]

Every hard-attention head selects the earliest key position attaining its maximal score, and each positionwise update is shared across positions and depends on its skip input and selected head values (Hard and soft attention sequence models).

[F2]

For a finite event family with dependency digraph D, if 0≤xi<1 and P(Ai)≤xi∏j∈ND+(i)(1−xj) for every event, then the probability that all events are avoided is positive (The asymmetric Lovász Local Lemma for finitely many events).

[A1]

In the probabilistic restriction stage, every still-free input symbol is independently fixed to each a∈Σ with probability q/s, and left as ∗ with probability 1−q; the finite input-coordinate sample space has the corresponding product law.

Proof

1.1givenconstructchoosealgebra

Choose 0<η<1/4 so that (1−2η)C>C′, then choose 0<δ<1 and 0<q<1/(1+δ) so that (1−(1+δ)q)(1−2η)C>C′. Put D=⌈c/(ηC)⌉ and regard k≥1 as an integer parameter whose finitely many lower bounds will be fixed after the local-lemma estimates. For each position j, choose a support Sj of at most c currently free input positions determining its layer-zero activation. There are at most cn incidences between supports and positions. Fix every free input position occurring in more than D supports, using any fixed symbol. At most cn/D≤ηCn positions are fixed; afterwards every free input position belongs to at most D supports.

2.1step 1.1F1constructalgebra

For a current restriction and query triple (i,h,z), where h is a head at position i and z is a possible layer-zero activation at i, at most cD key positions have supports intersecting Si; call these exceptional. For every other key position j, its support is disjoint from Si, so the maximum score mj for query value z is attainable by assigning its free support. Order these eligible positions by decreasing mj, breaking ties by position, and put R=⌈cD(k+1)⌉. For all sufficiently large n, at least R eligible positions exist. Greedily select k among the first R with pairwise disjoint supports: each choice removes at most cD candidates because its support has at most c symbols and each symbol occurs in at most D supports. Record for each selected position a support assignment attaining its maximum.

3.1step 2.1F1algebra

If a selected support is fixed to its recorded maximum-attaining assignment, that key's score is at least mR. Every eligible position after the first R has maximum score at most mR; equality is resolved in favor of a position among the first R by the chosen tie order. Hence a head's winner lies among the exceptional positions or the first R eligible positions. The first-layer output at position i is therefore determined by Si and the supports of at most Hsc(cD+R) candidate key positions, one set for each possible query activation, head, and key. It depends on at most c′=c+Hscc(cD+R) original input positions.

3.2step 1.1step 2.1algebrachoose

Starting from the restriction in step 1.1, repeatedly recompute the candidate sets in step 2.1 for every still-uncaptured triple. When a triple is captured, retain its current exceptional set and first-R eligible positions as its candidate set. Its assigned cutoff key remains at least as highly scored as every later position in the old eligible ordering, since refinements leave its score fixed and can only decrease other attainable maxima; any position that later leaves the eligible set was already in the retained exceptional set. If some key activation is selected in more than sckH uncaptured triples, one of its at most sc possible values is a recorded maximum for more than kH of them. Fix its at most c free input symbols to a support assignment producing that value. The query values of those triples remain unchanged, so all become captured. There are at most scHn triples, so this process has at most scn/k refinements and fixes at most sccn/k additional symbols. Require k large enough that scc/k≤ηC. At termination at least (1−2η)Cn inputs remain free, and each key activation is selected in at most T=sckH uncaptured triples.

4.1step 2.1step 3.2A1algebra

For each uncaptured triple t=(i,h,z), let Xt be the event that none of its k selected supports is fixed to its recorded maximum-attaining assignment by the random restriction [A1]. An assignment on r≤c free symbols has probability (q/s)r≥(q/s)c. The selected supports are pairwise disjoint, so these assignment events are independent and P(Xt)≤ak, where a=1−(q/s)c<1.

4.2givenstep 3.2A1algebra

Let m be the number of free inputs after step 3.2 and let X0 be the event that more than (1+δ)qm of them are fixed by [A1]. For Z∼Binomial⁡(m,q) and μ=mq, exponential Markov at t=log⁡(1+δ) gives P(Z≥(1+δ)μ)≤e−t(1+δ)μ(1−q+qet)m≤e−μ((1+δ)log⁡(1+δ)−δ)≤e−δ2μ/3. The middle inequality uses 1+u≤eu. For the last, g(δ)=(1+δ)log⁡(1+δ)−δ−δ2/3 has g(0)=0 and g′(δ)=log⁡(1+δ)−2δ/3≥0 on [0,1], since log⁡(1+δ)≥2δ/(2+δ)≥2δ/3. Consequently P(X0)≤e−αn, where α=δ2q(1−2η)C/3>0.

5.1step 4.1step 4.2A1F2algebrachoose

For each event Xt, take its defining-coordinate set to be the union of its query support and its k selected key supports. Join two Xt events when these sets overlap, and join X0 to every Xt. Each coordinate occurs in at most DHsc query supports: at most D position supports contain it, and each such position has at most Hsc head-and-query-value triples. It occurs in at most DscT selected key supports: each of at most D position supports has at most sc possible key activations, and each activation is selected in at most T triples by step 3.2. Each event uses at most c(k+1) coordinates, so its degree is at most f=1+c(k+1)D(Hsc+scT)=O(k2). Non-neighbours' defining-coordinate sets are disjoint from the event's set; product independence therefore gives independence from every conjunction of their complements, as required by [F2]. Set xX0=1/2 and xXt=1/k2. Since a=1−(q/s)c<1 and f=O(k2), the quantity k−2(1/2)(1−k−2)f is bounded below by a positive constant times k−2 for large k, whereas ak decays exponentially. Thus the local-lemma condition holds for every Xt once k is sufficiently large.

6.1step 3.2step 4.2step 5.1F2algebrachoose

There are at most scHn events other than X0. Its local-lemma condition follows if e−αn≤12(1−k−2)scHn. Choose k large enough that scH[−log⁡(1−k−2)]<α; the inequality then holds for all sufficiently large n. The stage-two, local-event, and X0 requirements are finitely many eventual lower bounds on k, so they hold simultaneously for sufficiently large k. By [F2], a refinement avoiding X0 and every Xt exists.

7.1step 1.1step 3.1step 3.2step 6.1givenalgebra

Avoiding X0 leaves at least (1−(1+δ)q)m≥(1−(1+δ)q)(1−2η)Cn>C′n free inputs by the choices in step 1.1. Avoiding every Xt captures each remaining triple. For a captured triple, its retained cutoff key and candidate set from step 3.2 continue to block every later eligible position; for an uncaptured triple, step 6.1 fixes a cutoff key from its final candidate set. Step 3.1 therefore confines each head's winner to at most cD+R candidate positions for each query value. Taking the union over at most sc query values and H heads, together with the query support, gives the dependence bound c′=c+Hscc(cD+R). Replacing each layer-zero activation by its first-layer output absorbs one layer while preserving the model's restricted computation.

8.1step 7.1inductionchoosedischarge-induction∎

Apply the one-layer reduction successively to the fixed L layers, choosing intermediate fractions C=C0>C1>⋯>CL=C′. Each stage has a finite dependence bound and a finite length threshold. Since L is finite, their maximum threshold is finite; beyond it, the final restriction leaves at least C′n inputs free and the final output depends on a bounded number of original inputs. This proves the Statement.

TheoremStatement: Literature-sourcedProof: AI-adaptedprecheck passOpen item page →

Fixed-depth hard attention cannot recognize PARITY or 2DYCK

Statement

Let PARITY={w∈{0,1}∗:w contains an even number of 1s}. Let 2DYCK be the language over {(,),[,]} of words whose brackets are correctly balanced and properly nested by type. No fixed finite-depth hard-attention sequence model with a fixed finite number of heads, fixed maps independent of input length, and a fixed classification readout from its end-marker state classifies every sufficiently long input exactly as a member or nonmember of PARITY; no such model recognizes 2DYCK either. Exact recognition means that the model's binary output equals the language membership indicator for every input word, with the end marker appended before the model is evaluated.

Facts & Assumptions

Given: A fixed hard-attention sequence model and the two language definitions in the Statement.

[F1]

For every finite input alphabet, hard-attention depth reduction can refine a restriction while retaining any specified smaller positive fraction of free positions; iterating through the fixed finite depth yields a restriction on which the output depends on a bounded number of original input positions (Hard-attention depth reduction under input restrictions).

[F2]

A hard-attention sequence model appends a fixed end marker, uses shared score, value, and positionwise maps fixed independently of input length, and classifies from the final state after reading that marker (Hard and soft attention sequence models).

Proof

1.1givenF1F2chooseinductiondischarge-induction

Let the model have L layers and let N=n+1 be the number of input positions for a word of length n, including its fixed end marker. Initially each free layer-zero state depends on its own input symbol. For all sufficiently large n, at least 0.99N positions are free, since only the end-marker position is fixed. Apply [F1] successively through the L layers, using free fractions 0.99=C0>C1>⋯>CL=0.9. For every sufficiently large n, this gives a restriction leaving at least 0.9N free word positions and a constant cL such that the classification output depends on at most cL input positions.

1.2givenF1F2algebrachoose

Now suppose the model recognizes 2DYCK. Its restriction to the two-symbol subalphabet consisting of one opening bracket and its matching closing bracket would recognize the one-type Dyck language, whose words have equal numbers of opening and closing brackets and nonnegative opening-minus-closing count at every prefix. Fix an even word length n, put N=n+1, and let m=⌊n/5⌋. Initially fix the first m word symbols to the opening bracket and the last m word symbols to the closing bracket; leave the middle symbols free and keep the end marker fixed. For all sufficiently large even n, at least 0.59N positions are free. By [F1], with final free fraction 0.55, refine this restriction so the model output depends on at most cL input positions and at least 0.55N word positions remain free. If t middle positions were additionally fixed, then t≤n−2m−0.55N≤0.06N for all sufficiently large N. Also m≥N/5−6/5, so m>t.

2.1step 1.1constructalgebra

Choose n large enough that 0.9N>cL. Some free bit position i is not among the at most cL positions determining the output. Complete the restriction arbitrarily to a word w, and let w′ be obtained by flipping bit i. Their model outputs agree because all input positions on which the output depends agree, but exactly one of w,w′ has an even number of ones. Thus no such model classifies all length-n words exactly as PARITY.

2.2step 1.2constructalgebra

Let fo be the number of additionally fixed middle symbols that are opening brackets, and let M=n−2m−t be the number of still-free middle positions. Assign an opening bracket to the first r=n/2−m−fo still-free positions in their order, and assign a closing bracket to the rest. Since m+t<n/2, we have r≥0 and M−r=n/2−m−t+fo>0. The completed word has exactly n/2 opening brackets, hence total balance zero. A prefix before the last of the assigned free opening brackets has height at least m−t>0, because at most t fixed middle symbols are closings. After that last free opening, every still-free middle symbol is a closing. For any later prefix ending in the middle segment, its remaining suffix contains the final m fixed closings and at most t fixed openings, so its net opening-minus-closing count is at most t−m<0. Since the whole word has total balance zero, every such middle prefix has positive height. The final m closing brackets decrease the height from m to zero. Thus this completion is a valid one-type Dyck word.

3.1step 1.2step 2.2algebra∎

At least 0.55N positions remain free, so for sufficiently large n there is a free word position i outside the at most cL positions determining the model output. Flip its bracket in the valid completion from step 2.2. The new word is unbalanced, while the model output is unchanged because position i does not affect that output. This contradicts recognition of the one-type Dyck language. Any exact recognizer for 2DYCK would restrict to an exact recognizer for this one-type sublanguage, so no such hard-attention model recognizes 2DYCK.

LemmaStatement: Literature-sourcedProof: AI-adaptedprecheck pendingOpen item page →

A nonfinal token has inverse-length influence under bounded soft attention

Statement

Fix a finite token alphabet and a fixed soft-attention sequence model with L layers, H heads per layer, fixed query/key/value matrices, and positionwise maps that are globally Lipschitz. Assume the layer-zero input states use the additive convention yj(0)=vxj+pj, where vxj is the embedding of token xj and pj is the position-j embedding. Assume the token embeddings are bounded, the positional embeddings satisfy sup⁡i∥pi∥2<∞, and all model parameters are independent of the input length n. For two length-n inputs with the same end marker at position n and differing in only one token at a position i<n, there is a constant C<∞, depending only on these bounds, matrices, maps, L, and H, such that their final hidden states satisfy

∥yn(L)(x)−yn(L)(x′)∥2≤Cn.

If a fixed globally Lipschitz map followed by softmax converts the final hidden state to next-token probabilities, then another constant C′<∞ with the same allowed dependence satisfies ∥qn(x)−qn(x′)∥1≤C′/n. No bound is asserted when the changed symbol is the final end marker, or when the number of layers, matrices, or their norms vary with n.

Facts & Assumptions

Given: A fixed soft-attention model satisfying the additive layer-zero convention and bounds in the Statement, an input length n≥2, and two inputs differing only at position i<n.

[F1]

In each soft-attention head, the row attention weights are the softmax of the query-key scores, sum to one, and the head output is their weighted sum of value vectors (Hard and soft attention sequence models).

[A1]

The finite matrices, layer count, number of heads, embedding bounds, and global Lipschitz constants are fixed independently of n, as required in the Statement.

Proof

1.1givenF1A1induction

There are constants Bk<∞ such that ∥yj(k)∥2≤Bk for every position j, input length n, and input pair. At layer zero this follows from yj(0)=vxj+pj and the bounded token and positional embeddings. If it holds at layer k−1, each value vector has norm at most ∥Vk,h∥Bk−1 and each attention output is a convex combination of those values by [F1]; the fixed globally Lipschitz positionwise map is bounded on this resulting bounded set. Induction gives all Bk.

2.1step 1.1F1A1algebra

Consequently every dot-product score at every layer has absolute value at most some Ak<∞. For any row with n keys, its softmax weight aj is at most e2Ak/n, since its numerator is at most eAk and its denominator is at least ne−Ak.

3.1givenstep 1.1step 2.1A1algebra

We prove by induction on k that for constants Dk,Ek independent of n, the changed position satisfies ∥yi(k)−yi′(k)∥2≤Dk, while every j≠i satisfies ∥yj(k)−yj′(k)∥2≤Ek/n. This holds at k=0 because only the bounded token embedding at i changes. Assume it holds at k−1 and fix a query position j≠i and one head. Its query changes by O(1/n). Its key at position i can change by O(1), while all other keys change by O(1/n), using the fixed linear matrices and the induction hypothesis. Hence its score-difference vector Δ has ∣Δi∣≤K and ∣Δr∣≤K/n for r≠i, for a constant K independent of n.

4.1step 2.1step 3.1algebra

Interpolate the two score vectors linearly. All interpolated scores remain in [−Ak,Ak], so the distinguished key has softmax weight at most e2Ak/n throughout by step 2.1. For softmax probabilities ar(t), differentiation gives ar′(t)=ar(t)(Δr−∑sas(t)Δs); therefore ∑r∣ar′(t)∣≤2∑rar(t)∣Δr∣=O(1/n), and integration yields ∥a−a′∥1=O(1/n).

5.1step 1.1step 4.1A1algebra

The head values are uniformly bounded by step 1.1. Splitting the difference of the two weighted sums into (i) the change of values under the first attention row and (ii) the change of attention weights applied to the second value list gives ∥bj,k,h−bj,k,h′∥2=O(1/n): the changed value at i has weight O(1/n), all other value changes are O(1/n), and the total weight change is O(1/n) by step 4.1. The positionwise map is Lipschitz, so ∥yj(k)−yj′(k)∥2=O(1/n) for every j≠i. At j=i, boundedness from step 1.1 gives a constant difference. This proves the induction claim.

6.1step 5.1A1algebra∎

Since i<n, the induction bound gives ∥yn(L)−yn′(L)∥2≤EL/n. For a logit perturbation Δ, the softmax derivative is pr(Δr−∑spsΔs), whose ℓ1 norm is at most 2∥Δ∥∞≤2∥Δ∥2; hence the prediction probabilities differ by at most a constant times 1/n. Taking C=EL completes the hidden-state bound and supplies the stated probability bound.

Remarks

The proof includes the change in softmax attention weights caused by the changed key. This term is necessary because attention scores depend on the hidden states; it is bounded using the O(1/n) mass of the one changed key and the O(1/n) changes of the remaining logits.

TheoremStatement: Literature-sourcedProof: AI-adaptedprecheck pendingOpen item page →

Fixed soft attention has no parity advantage over the unigram predictor

Statement

Fix p∈(0,1). Generate a bit string by a two-state process whose state is the parity of the number of emitted 1s: in the even state it terminates with probability p, and otherwise emits 0 or 1 with probability (1−p)/2 each; in the odd state it emits 0 or 1 with probability 1/2 each and cannot terminate. For each n≥2, let Dn be the law of length-(n−1) prefixes conditional on the process emitting at least n−1 bits, and ask a fixed soft-attention model to predict the next symbol in {eos,0,1} from that prefix followed by the end marker. Let rx be the true next-symbol distribution and let qn(x) be the model's predicted distribution. Define cross-entropy by CE⁡(r,q)=−∑ar(a)log⁡q(a), with value +∞ if r(a)>0=q(a), and entropy by H(r)=−∑a:r(a)>0r(a)log⁡r(a). Then every fixed soft-attention model satisfying the one-symbol influence hypotheses has

lim inf⁡n→∞Ex∼DnCE⁡(rx,qn(x))≥H(u),u(eos)=p/2,u(0)=u(1)=(2−p)/4. A constant predictor qn(x)=u attains H(u) for every n, so H(u) is the sharp unigram chance level. An arbitrary fixed predictor may have greater cross-entropy; this result gives no soft-attention exact-classification impossibility theorem.

Facts & Assumptions

Given: The parity source process and prefix law in the Statement, and a fixed soft-attention next-token predictor satisfying the one-symbol influence hypotheses.

[F1]

Changing one nonfinal token changes the predicted next-token probability vector by at most C/n for a constant independent of n (A nonfinal token has inverse-length influence under bounded soft attention).

[F2]

The model reads an end marker at its final input position, and the last bit of the prefix is therefore a nonfinal input token (Hard and soft attention sequence models).

[F3]

If two next-token predictions differ by at most ϵ in ℓ1, their average cross-entropy on target laws r,s is at least H((r+s)/2)−log⁡(1+∣Σ∣ϵ) (Close paired predictions incur mixture entropy).

Proof

1.1givenalgebra

If a prefix x has even parity, its next-symbol distribution is re=(p,(1−p)/2,(1−p)/2) in the coordinate order (eos,0,1). If it has odd parity, the distribution is ro=(0,1/2,1/2). Their equal mixture is u=(re+ro)/2 with the coordinates stated.

1.2givenconstructalgebra

Pair each prefix w0 with w1, where w has length n−2. Both extensions have equal probability: their shared first n−2 symbols fix the same pre-emission parity, and the source emits the final bit values with equal probability in either state, conditional on emitting a bit. Each pair contains one even and one odd prefix; conditioning on length at least n−1 uses one common normalizing constant, so the two members still have equal Dn mass.

2.1step 1.1step 1.2F1F2

Let q=qn(w0) and q′=qn(w1), and let r,r′ be their respective target laws. The pair (r,r′) equals (re,ro) or (ro,re) according to the parity of w. By [F1]–[F2], ∥q−q′∥1≤C/n. The pair's mean cross-entropy is 12CE⁡(r,q)+12CE⁡(r′,q′); its mean target is u in either order, so the symmetric bound [F3] applies.

3.1step 2.1step 1.1F3algebra

Applying [F3] with ϵ=C/n bounds the pair mean cross-entropy below by H(u)−log⁡(1+3C/n), which tends to H(u).

4.1step 3.1step 1.2algebra∎

Every prefix pair has the same limiting lower bound from step 3.1. Averaging over the equal-mass pairs in step 1.2 proves the expected cross-entropy lower bound. The constant predictor u has expected loss H(u) because the paired target marginal is u. It is realized within the stated model class as follows: let e1 be the first coordinate vector, take va=e1 and pi=0 for every token and position, choose zero query, key, and value maps, and let every positionwise map be the constant map with value e1. These choices obey the additive convention, boundedness, and global Lipschitz hypotheses, and give final hidden state e1 at every position. Choose the fixed linear readout whose row for token a is (log⁡u(a))e1T; its logits at the final state are exactly log⁡u, so softmax gives u. Thus the lower bound is sharp, while no upper bound at H(u) is asserted for every fixed model.

AlgorithmAlgorithm: Literature-sourcedProof: Not applicableOpen item page →

Transformer encoder-decoder forward pass

Definition

Inputs: A nonempty source token sequence (x1,…,xn), a target prefix (y0,…,ym−1) with m≥1 and a start token y0, source and target embedding maps into Rd, positional encoding matrices of compatible shapes, a finite encoder stack, a finite decoder stack, and a linear output map to a finite vocabulary of logits. Each layer has the parameters and conventions in the transformer encoder/decoder definition. All self-attention and cross-attention masks must leave at least one allowed key in every query row.

Procedure:

  1. Embed each source token and add its positional vector to form X∈Rn×d.
  2. Apply the encoder layers in order to X and call the final matrix E∈Rn×d.
  3. Embed each target-prefix token and add its positional vector to form U∈Rm×d.
  4. Apply each decoder layer in order. In every decoder layer, use the causal mask on decoder self-attention, use the current decoder rows as queries and E as keys and values for cross-attention, and then apply the positionwise feedforward sublayer.
  5. Apply the output linear map to each final decoder row and apply softmax over vocabulary coordinates. Return the encoder matrix E, the final decoder hidden matrix, and the rowwise next-token probability matrix.

Outputs: The source representations, decoder representations, and one probability vector for each target-prefix position. At position i, the decoder self-attention calculation uses only target-prefix positions j≤i; the encoder cross-attention may use every source position.

TheoremStatement: AI-adaptedProof: AI-adaptedprecheck passOpen item page →

Position-free unmasked self-attention is permutation equivariant

Statement

Let X∈Rn×d be a sequence matrix whose rows are token representations, and let P be any n×n permutation matrix. Every finite composition T of position-shared encoder layers built from unmasked multi-head self-attention, residual additions, rowwise layer normalization, and a shared positionwise feedforward map, with no positional encoding, satisfies

T(PX)=P T(X).

For a fixed attention mask M, the corresponding layer satisfies Layer⁡PMPT(PX)=PLayer⁡M(X). Hence every permutation that leaves a fixed mask M unchanged is an equivariance of the corresponding layer. The standard causal mask Mij=0 for j≤i and Mij=−∞ for j>i is preserved only by the identity permutation.

Facts & Assumptions

Given: A sequence matrix X, a permutation matrix P, shared projections and positionwise maps, and—when a mask is present—a mask transformed together with the token indices.

[F1]

Each multi-head self-attention head forms query, key, and value rows by applying the same matrices to every token; its output is scaled-dot-product attention followed by a shared output projection (Multi-head attention and self-attention).

[F2]

Residual addition, rowwise layer normalization, and a positionwise feedforward map apply the same vector function at every position (Transformer encoder, decoder, and fixed-width expressivity blocks).

Proof

1.1givenF1algebra

For one head, write Q=XWQ, K=XWK, and V=XWV. On input PX, the projections are PQ, PK, and PV. The unmasked score matrix therefore becomes (PQ)(PK)T=P(QKT)PT.

2.1step 1.1F1algebra

Row softmax commutes with simultaneous row and column permutation: every row's logits are merely reordered, so its normalized entries are reordered by the same permutation. Thus softmax⁡row(PSPT)=Psoftmax⁡row(S)PT; multiplying by PV gives Psoftmax⁡row(S)V. Concatenation and the shared output projection preserve this identity, and so does the residual addition.

3.1step 2.1F2induction

A shared positionwise map applies the same function to each row, hence maps PX to the permutation of its outputs. Rowwise layer normalization has the same property because each row's mean and variance are unchanged by reordering rows. Combining these identities with the attention and residual identity in step 2.1 shows that one encoder layer is equivariant; induction over the finite stack gives T(PX)=PT(X).

4.1step 1.1step 2.1givenalgebrainduction∎

For a masked head, transforming the mask to PMPT gives the same score-and-weight calculation as steps 1.1–2.1, proving the stated mask identity. A permutation preserving the causal mask must preserve the relation j≤i on the finite chain 1<⋯<n; its unique least element must map to itself, and then induction on the remaining ordered positions makes every position fixed. Therefore only the identity preserves the standard causal mask.

LemmaStatement: AI-adaptedProof: AI-adaptedprecheck pendingOpen item page →

Paired-prefix lower bound for soft-attention 2DYCK prediction

Statement

Fix p∈(0,1) and let Dn be a probability law on valid length-(n−1) prefixes over {(,),[,]}. Let En be a union of disjoint equal-mass pairs {x,x′} in the support of Dn such that each prefix in a pair ends in a closing bracket and has positive stack height after that bracket; x′ is obtained by changing the type of the top unmatched opening bracket in x, at a position before the final prefix symbol. Assume that, conditional on x, the next-symbol law assigns probability p/2 to each opening bracket and probability 1−p to the closing bracket matching its top unmatched opening, and that the law conditional on x′ swaps the two possible closing-bracket types while leaving the opening probabilities unchanged. If Dn(En)≥P0>0 for all sufficiently large n, then every fixed soft-attention predictor satisfying the one-symbol influence hypotheses has

lim inf⁡n→∞(Ln−Ln∗)≥P0(1−p)log⁡2,

where Ln is expected next-symbol cross-entropy and Ln∗=Ex∼DnH(rx) is the optimal conditional cross-entropy. This lemma requires the positive-mass paired-prefix hypothesis; it does not assert that a particular PCFG supplies that hypothesis.

Facts & Assumptions

Given: The probability law Dn, disjoint pairs En, next-symbol distributions described in the Statement, P0>0, and a fixed soft-attention predictor.

[F1]

Predictions on inputs differing at one nonfinal token differ in ℓ1 by at most C/n (A nonfinal token has inverse-length influence under bounded soft attention).

[F2]

If two target laws on a five-symbol alphabet have predictions within ϵ in ℓ1, their mean cross-entropy is at least the entropy of the mean target law minus log⁡(1+5ϵ) (Close paired predictions incur mixture entropy).

Proof

1.1givenalgebra

For one pair, write r for the target law at x and r′ for the law at x′. Both assign p/2 to each opening token; r assigns 1−p to one closing type and r′ assigns 1−p to the other. Thus H(r)=H(r′), while rˉ=(r+r′)/2 splits the close mass evenly between the two closing types, giving H(rˉ)−H(r)=(1−p)log⁡2.

2.1step 1.1F1F2algebra

Let q=qn(x) and q′=qn(x′). Because the changed opening position is nonfinal, [F1] gives ∥q−q′∥1≤C/n. Applying [F2] yields pair-mean loss at least H(rˉ)−log⁡(1+5C/n). Subtracting the pair's optimal mean loss H(r) gives excess at least (1−p)log⁡2−log⁡(1+5C/n).

3.1step 2.1givenF2algebra

At every context outside En, cross-entropy is at least its conditional entropy by the finite-distribution inequality proved in [F2]. The pair-mass condition and step 2.1 therefore give Ln−Ln∗≥P0((1−p)log⁡2−log⁡(1+5C/n)) for all sufficiently large n.

4.1step 3.1algebra∎

Since log⁡(1+5C/n)→0, taking the lower limit in step 3.1 proves the stated gap.

TheoremStatement: AI-adaptedProof: AI-adaptedprecheck pendingOpen item page →

Hard and soft attention limits for formal-language prediction

Statement

For PARITY, whose members are the bit strings with an even number of 1s, no fixed finite-depth hard-attention sequence model with fixed parameters recognizes every sufficiently long input exactly. For 2DYCK, whose words are correctly balanced and properly nested strings over two bracket types, no such hard-attention model recognizes the language. In both cases the model appends an end marker before classification.

For all soft-attention conclusions below, fix the parameter matrices, depth, and number of heads independently of length; use scaled dot-product scores with fixed linear query/key/value maps, uniformly bounded token and positional embeddings combined by addition, globally Lipschitz positionwise maps, and a fixed globally Lipschitz logit readout followed by softmax. Under these one-symbol influence assumptions, the parity source process with fixed p∈(0,1) has sharp unigram cross-entropy level

H(u),u(eos)=p/2,u(0)=u(1)=(2−p)/4.

Every such predictor has limiting lower cross-entropy at least H(u), and the constant predictor u attains it.

For the 2DYCK PCFG with rules S→(S)S and S→[S]S each of probability p/2, and S→ϵ of probability 1−p, fix any p∈(0,1). Read its left-to-right output as a finite or infinite bracket stream; sample a length-k prefix conditional on at least k bracket tokens having been emitted, and predict the ordinary next token, without conditioning on exact total length. Every fixed soft-attention predictor satisfying these one-symbol influence assumptions has

lim inf⁡k→∞(Lp,k−Lp,k∗)≥p2(1−p)2log⁡2>0,

where Lp,k is its expected next-token cross-entropy under this prefix law and Lp,k∗ is the corresponding optimal conditional cross-entropy.

The PCFG is a probability law on finite words precisely when p≤1/2. For all p∈(0,1) its finite output can instead be conditioned on eventual termination. For that finite-word probability law, sample prefixes conditional on reaching length k and predict the next token without any additional length conditioning. The same positive-gap conclusion holds with p replaced by a=min⁡(p,1−p):

lim inf⁡k→∞(Lp,kfin−(Lp,kfin)∗)≥a2(1−a)2log⁡2>0.

For p≤1/2 these two prefix laws agree. At p=1/2 finite words have infinite expected length, but the prefix bounds still hold. For p>1/2 the first law includes nonterminating streams and the second conditions them away; neither is an unconditioned probability distribution on finite words with the original parameter p. These are cross-entropy limits, not exact-classification impossibility theorems.

Statement references

Hahn, §§5–6: hard-attention language limits and soft-attention prediction bounds

A nonfinal token has inverse-length influence under bounded soft attention: the precise bounded dot-product model and globally Lipschitz readout followed by softmax.

Paired-prefix lower bound for soft-attention 2DYCK prediction: the paired-prefix soft-attention gap.

Exact 2DYCK PCFG prefix laws and positive paired-prefix mass: exact stream and finite-word prefix laws and a uniform equal-mass pairing.

Facts & Assumptions

Given: The formal-language definitions and model conventions in the Statement.

[F1]

Fixed-depth hard attention cannot recognize PARITY or 2DYCK with the stated end-marker convention (Fixed-depth hard attention cannot recognize PARITY or 2DYCK).

[F2]

For the stated parity source, every such soft predictor has limiting expected cross-entropy at least H(u), and the constant predictor u attains H(u) (Fixed soft attention has no parity advantage over the unigram predictor).

[F3]

Under a positive-mass disjoint equal-prefix pairing whose conditional closing targets are swapped, soft-attention next-token cross-entropy exceeds the conditional optimum by at least P0(1−p)log⁡2 in the limit (Paired-prefix lower bound for soft-attention 2DYCK prediction).

[F4]

The stream prefix law has disjoint equal-mass pairs of mass at least p2(1−p), obtained by flipping the outer opening in a final three-token opening-opening-closing pattern. Conditioning on finite output replaces the parameter by a=min⁡(p,1−p) and gives the same pairing with that parameter (Exact 2DYCK PCFG prefix laws and positive paired-prefix mass).

Proof

1.1givenF1construct

The hard-attention assertions are exactly [F1], proved by the iterated restriction reduction for the fixed finite depth and finite alphabet, with the end marker fixed.

1.2givenF2algebra

The parity cross-entropy lower bound and its sharpness are exactly [F2]. The probability vector u is the equal mixture of the even-parity target (p,(1−p)/2,(1−p)/2) and odd-parity target (0,1/2,1/2) in coordinate order (eos,0,1).

1.3givenF3F4constructalgebra

Put n=k+1 and append the fixed readout end marker to each sampled length-k prefix. By [F4], every prefix in the paired event ends with a closing bracket and has positive stack height; the flipped opening at position k−2 is nonfinal. The pair members have equal probability and ordinary next-token laws assigning p/2 to each opening and 1−p to opposite matching closing types. Hence all hypotheses of [F3] hold with P0=p2(1−p). It gives excess cross-entropy at least p2(1−p)2log⁡2 in the lower limit. The appended readout marker is an input convention and does not assert that the sampled source prefix terminates there.

2.1givenF4step 1.3algebrainduction∎

Under conditioning on eventual termination, [F4] identifies the entire prefix and target process with parameter a=min⁡(p,1−p). Repeat step 1.3 with a to prove the finite-word bound. The finite-word mass and extinction calculation in [F4] give the stated distinction between the two laws. At p=1/2, let Gj be the nodes in generation j of the derivation tree. A finite-generation induction gives E∣Gj∣=(2p)j=1 for every j. Hence the number ZN=∑j=0N∣Gj∣ of nodes through generation N has expectation N+1. The total node count Z is at least ZN, so monotonicity of expectation gives EZ≥N+1 for every N and therefore EZ=∞, without interchanging an expectation with an infinite sum. Finite derivations are full binary trees, and their word length is their node count minus one; thus the finite-word law has infinite expected length. Neither pairing proof uses finite expected length.

Remarks

The explicit prefix-sampling law resolves the conditioning left implicit in Hahn's Theorem 6. Its finite-mean Markov-chain sketch is unnecessary: extending any surviving prefix by two openings and the matching inner close supplies positive paired mass directly. Exact-total-length conditioning is a different prediction problem; its next-token probabilities are not generally p/2,p/2,1−p. The fixed-length universality theorem concerns a separate regime with resources allowed to grow.

LemmaStatement: Literature-sourcedProof: AI-adaptedprecheck passOpen item page →

Two-head fixed-width Transformers implement finite-grid lookups

Statement

Let d≥1, n≥2, m≥2 be integers, set δ=1/m and q=δ−d, and assume n≤q. Define Gδ={0,δ,…,1−δ}d×n,Gδ+={−δ−nd,0,δ,…,1−δ}d×n. Let G^δ consist of those L∈Gδ whose columns are pairwise distinct. For column-token matrices Z∈Rd×n, consider finite compositions of residual attention updates Z⟼Z+∑h=12oh(vhTZ) hmax⁡ ⁣((khTZ)T(rhTZ+bh1nT)) and residual tokenwise updates

Z⟼Z+w ϕ(vTZ+b1nT),

where all displayed vectors and scalars are fixed across columns, hmax⁡ assigns equal weights to all maximizing entries in each column, and each scalar ϕ is piecewise affine on at most three intervals with at least one constant piece. If A:G^δ→Rd×n satisfies A(LP)=A(L)P for every column-permutation matrix P, then such a composition maps each L∈G^δ to A(L) and each L∈Gδ+∖G^δ to 0.

There is also a position-tagged version. For each j=1,…,n, let Jj={j−1,j−1+δ,…,j−δ}d,Gδ,pos=J1×⋯×Jn, where the jth factor specifies column j. For every function A:Gδ,pos→Rd×n, with no permutation condition, a finite composition of the same updates maps each L∈Gδ,pos to A(L).

Facts & Assumptions

Given: The integer grids and finite tables in the Statement.

[F1]

The Yun expressivity block has two heads of size one, shared query/key/value and output maps, a shared scalar query bias, residual attention, and a tokenwise ReLU feedforward sublayer of width four; it has no layer normalization (Transformer encoder, decoder, and fixed-width expressivity blocks).

[F2]

Every finite composition of the unmasked Yun attention and shared tokenwise maps is permutation equivariant (Position-free unmasked self-attention is permutation equivariant).

[F3]

Positional encodings are added columnwise to the token matrix before the position-aware stack (Positional encodings and causal masks).

Proof

For the unpositioned equivariance used below, let P be any column-permutation matrix. In a shared Yun head, vTZP=(vTZ)P and the query and key projections transform the same way, so its score matrix satisfies S(ZP)=PTS(Z)P. Equal-weight hardmax acts columnwise and commutes with row and column permutations, giving hmax⁡(S(ZP))=PThmax⁡(S(Z))P. Multiplication by the permuted value row then gives the permuted attention output, and residual addition preserves this identity. A shared tokenwise update also commutes with column permutations because 1nTP=1nT and its coordinatewise activation is applied identically in every column. Thus every modified Yun attention or tokenwise update, and every finite composition of them, is permutation equivariant. This is the unnormalized, hardmax version of the supplier calculation in [thm-transformer-permutation-equivariance-without-position].

1.1givenalgebra

Put u=(1,δ−1,…,δ−d+1). For a grid column x=(a1δ,…,adδ), where ai∈{0,…,m−1}, its scalar code is ℓ(x)=uTx,ℓ(x)/δ=a1+a2m+⋯+admd−1. Thus the valid column codes are distinct multiples of δ in [0,B], where B=δ(q−1). If a column has a sentinel coordinate −δ−nd, the sum of all its other coordinate contributions is at most δ−d+1−1, so its code is at most −δ−nd+δ−d+1−1<0.

1.2givenF1algebra

For a scalar threshold b, the single-head update ψ(Z;b)=e1(uTZ)hmax⁡ ⁣((uTZ)T(uTZ−b1nT)) is an allowed attention update contribution: its key and value projections are u, its query projection is u with bias −b, and its output vector is e1. In query column j, if ℓj>b it returns the largest current scalar code, and if ℓj<b it returns the smallest. If ℓj=b, all query scores are zero and equal-weight hardmax returns the mean ℓˉ=n−1∑kℓk. Thus, writing ℓmax⁡=max⁡kℓk and ℓmin⁡=min⁡kℓk, the contribution ψ(Z;b)−ψ(Z;b′) for b<b′ is ℓmax⁡−ℓmin⁡ in the first coordinate when b<ℓj<b′, ℓˉ−ℓmin⁡ when ℓj=b, ℓmax⁡−ℓˉ when ℓj=b′, and zero when ℓj<b or ℓj>b′. In particular, if no current code equals either threshold, it shifts exactly the columns strictly between them by ℓmax⁡−ℓmin⁡.

2.1step 1.1step 1.2constructalgebra

Sweep the valid scalar codes 0,δ,…,B in increasing order, using the two-head update   Z↦Z+q(ψ(Z;ℓ−δ/2)−ψ(Z;ℓ+δ/2))   at code ℓ. All initial codes, including sentinel codes, are multiples of δ: every grid coordinate lies in δZ and every entry of u is an integer. Since q=md is an integer, each strict selective shift preserves this lattice; inductively no current code can equal any half-grid threshold ℓ±δ/2. This also applies to duplicate-column inputs and to the position-tagged lattice. For L∈G^δ, order its distinct column codes as ℓ1<⋯<ℓn. The first sweep shifts only ℓ1 to ℓ~1=ℓ1+q(ℓn−ℓ1)>B, since ℓn−ℓ1≥δ and qδ=B+δ. Each later sweep shifts the next unmodified code and gives ℓ~j=ℓj+q(ℓ~j−1−ℓj)>ℓ~j−1(2≤j≤n). Thus shifted columns leave all later threshold intervals, and the final scalar codes satisfy 0<ℓ~1<⋯<ℓ~n.

3.1step 2.1algebra

Write gj=ℓj+1−ℓj≥δ. Unrolling the recurrence in step 2.1 gives t:=ℓ~n=ℓn+∑j=1n−1(qn−qn−j)gj. Consequently δqn−1(q−1)≤t≤δqn(q−1)−δ(q−1)2. The lower bound follows from the j=1 term; the upper bound follows from ℓn≤B and ∑jgj≤B. The map (ℓ1,…,ℓn)↦t is injective: if two ordered tuples give the same t, put aj=(ℓj−ℓj′)/δ∈Z, so ∣aj∣≤q−1. The difference equation is an+q(an−1−an)+⋯+qn−1(a1−a2)+qn(an−a1)=0. Reduction modulo q first gives an=0; division by q and repeated reduction modulo q then gives an−1=0,…,a1=0. Hence distinct unordered column multisets have distinct t values, separated by at least δ.

4.1step 2.1step 3.1F2choosealgebra

Apply one final single-head update Z↦Z+Kψ(Z;0), with a positive integer K. For valid L, all ℓ~j>0, so it adds Kt to every first coordinate and changes the scalar codes to cL,j=Kt+ℓ~j. For different column multisets, their t values differ by at least δ, while 0<ℓ~j≤t. Choose K so that Kδ>max⁡t over the finite valid grid. The intervals [Kt,Kt+t] for different multisets are disjoint, and codes within one multiset are distinct by step 2.1. All resulting codes are multiples of δ, hence distinct codes are at least δ apart.

5.1step 1.1step 3.1step 4.1algebrachoose

If L has duplicate columns but no sentinel, its scalar codes have only r<n distinct levels. The same sweep shifts these r levels, and its largest value is at most δqr(q−1)−δ(q−1)2≤δqn−1(q−1)−δ(q−1)2, strictly below the lower bound for valid t in step 3.1. A sentinel column has a negative code by step 1.1 and remains the minimum throughout the sweep. If all codes are negative, the final update in step 4.1 shifts every code further negative. If some codes are nonnegative, the first nonnegative code is shifted by at least q(qn−B)>δqn+1; the later positive codes are shifted by still larger amounts. This exceeds every valid t in step 3.1. Thus, after the final update, each invalid scalar code has one of three forms: below every valid code, above every valid code, or negative. Since there are finitely many grid inputs and all codes are multiples of δ, choose K large enough that every invalid code lies at least δ outside the interval from the least to the greatest valid code.

6.1step 4.1step 5.1F2constructchoosealgebra

The preceding construction gives a finite scalar code for each token of each valid context; these codes are all distinct, and column permutations carry each code and its token to the corresponding permuted token by [F2]. Let λ− and λ+ be the least and greatest valid codes. Because the table A and grid are finite, enlarge K so that ∣uTA(L):,j∣<λ−−δ/3 for every valid L,j. A three-piece constant activation that is zero on [λ−−δ/3,λ++δ/3] and one outside this interval detects exactly the invalid codes. Subtracting a constant larger than the maximum absolute coordinate of every encoded grid state makes every invalid state strictly negative; for each coordinate r, the allowed residual update Z↦Z+erReLU⁡(−erTZ) replaces that coordinate by zr+max⁡(0,−zr)=max⁡(0,zr). These d updates send every invalid state to zero and leave every valid, coordinatewise nonnegative state unchanged. For each valid code cL,j, a three-piece pulse equal to one on [−δ/3,δ/3] and zero outside, applied to uTZ−cL,j, selects exactly its token. Add the vector A(L):,j−Z:,j at that token. The updated token has scalar value uTA(L):,j below every code, so later pulses cannot select it; the remaining tokens retain their codes until selected. Equivariance of A makes each update correct for every permutation of L. This yields A(L) on G^δ and zero on every other point of Gδ+.

7.1givenstep 1.2step 2.1step 3.1step 6.1F3choosealgebra

For the position-tagged grid, the scalar code of column j has the form ℓj=(j−1)S+rj,S=∑k=0d−1δ−k,0≤rj≤B,rj∈δZ. Since S−B≥δ, codes in a matrix satisfy ℓ1<⋯<ℓn and each individual code identifies its column vector. Choose an integer Q≥q with Qδ>(n−1)S+B. Sweep all possible position-tagged scalar codes in increasing order, replacing the shift multiplier q in step 2.1 by Q. All codes remain in δZ, so none equals a half-grid threshold. Since distinct initial codes differ by at least δ, the first shifted code exceeds the largest possible initial code, and each subsequent shifted code exceeds its predecessor. Thus the recurrence of step 2.1 holds with Q in place of q, and different matrices give different ordered tuples (ℓ1,…,ℓn). The divisibility argument in step 3.1 applies modulo Q: for each fixed position, the offsets (j−1)S cancel and the difference of two rj values divided by δ has magnitude at most q−1<Q. Thus the final maxima t distinguish all position-tagged matrices, and the codes Kt+ℓ~j distinguish every token in every matrix when Kδ>max⁡t. Choose K still larger so these positive codes exceed all finitely many target values ∣uTA(L):,j∣+δ/3. The pulse layers of step 6.1 then implement the arbitrary table A; no permutation condition is needed because the position offsets distinguish columns.

8.1step 1.2step 6.1step 7.1F1algebra∎

Each update used above is either a two-head attention update, a single-head attention update with the second head set to zero, or a tokenwise scalar piecewise-affine update; an unused attention or feedforward sublayer is made the identity by setting its output weights to zero. Therefore the finite constructions are compositions of the modified Yun blocks specified in the Statement, proving both lookup assertions.

LemmaStatement: Literature-sourcedProof: AI-adaptedprecheck pendingjudge pass (gpt-6-luna)Open item page →

Dense full-attention interaction cost and path length

Statement

Use the standard dense self-attention interaction with n token rows, model width d, and h heads whose total query/key/value width is d (for example, h heads of width d/h when h divides d). Counting scalar multiply-add operations in the direct matrix implementation, forming all query-key scores and applying the resulting dense weight matrix to all value rows costs O(n2d) per attention sublayer; row softmax adds O(n2). Every query position has a direct value path from every key position, so one unmasked self-attention sublayer gives path length one between any input token value and any output token. A fixed stack of L such layers has a position-to-position path of at most L attention edges, independent of n.

If each query, key, value, and output projection is a dense d×d linear map and the tokenwise feedforward width is dff, those operations add O(nd2+nddff) work per full Transformer layer. Thus the O(n2d) claim concerns the dense all-pairs attention interaction used in the source comparison; it does not assert that projections or the feedforward sublayer have that cost, and it makes no claim about sparse attention, linear attention, training work, memory traffic, or hardware speed.

Facts & Assumptions

Given: Positive integers n,d, the dense multi-head self-attention dimensions in the Statement, and the direct matrix implementation.

[F1]

The forward pass forms scaled query-key scores, applies row softmax, and multiplies the resulting attention weights by values (Transformer encoder-decoder forward pass).

Proof

1.1givenF1algebra

For one head of width dh, the score product has dimensions (n×dh)(dh×n) and therefore uses O(n2dh) scalar multiply-adds. The value product has dimensions (n×n)(n×dh) and also uses O(n2dh) operations.

1.2F1givenalgebra

For finite real scores, every softmax weight is strictly positive, so each output row uses the value row of every input position. This is one direct attention edge; composing L layers yields at most one such edge per layer, hence at most L attention edges independent of n.

2.1step 1.1algebra

Summing over h heads with total width ∑a=1hdh(a)=d gives O(n2d) score and value work. Normalizing n rows of n scores costs O(n2), which is at most O(n2d) because d≥1.

3.1givenF1algebra∎

A dense projection of an n×d matrix by a d×d matrix costs O(nd2), and a two-map positionwise feedforward network of hidden width dff costs O(nddff). Adding these separate terms gives the full-layer operation count stated in the Statement.

TheoremStatement: Literature-sourcedProof: AI-adaptedprecheck pendingOpen item page →

Fixed-width Transformer approximation on compact domains

Statement

Assume the Axiom of Countable Choice, fix integers d≥1 and n≥2, and fix 1≤p<∞. For a matrix Y∈Rd×n, let ∥Y∥p=(∑r=1d∑j=1n∣Yrj∣p)1/p, and for measurable maps on Rd×n define

dp(f,g)=(∫Rdn∥f(X)−g(X)∥pp dX)1/p,

using dn-dimensional Lebesgue measure. Let T2,1,4 be the finite compositions of the two-head, head-size-one Yun blocks with tokenwise ReLU feedforward width four and no layer normalization. If f:Rd×n→Rd×n is continuous, has compact support, and satisfies f(XP)=f(X)P for every n×n permutation matrix P, then for every ε>0 there is g∈T2,1,4 with dp(f,g)<ε.

For every compact K⊆Rd×n and every continuous f:K→Rd×n, with no permutation condition, there are a trainable positional matrix E∈Rd×n and g∈T2,1,4 such that

(∫K∥f(X)−g(X+E)∥pp dX)1/p<ε.

Facts & Assumptions

Given: Countable Choice, fixed d,n,p, the target maps in the Statement, and ε>0.

[F1]

Each block in T2,1,4 has two unmasked heads of size one, residual attention, a shared tokenwise ReLU feedforward sublayer of width four, and no layer normalization; a scalar query bias is allowed (Transformer encoder, decoder, and fixed-width expressivity blocks).

[F2]

The column-token Yun block and every unpositioned composition of it are permutation equivariant (Position-free unmasked self-attention is permutation equivariant).

[F3]

A two-head, head-size-one modified network with piecewise-affine scalar gates performs exact finite lookup on the distinct-column grid and on position-tagged grids; the first version returns zero on duplicate-column and sentinel grid points (Two-head fixed-width Transformers implement finite-grid lookups).

[F4]

A continuous map from a compact metric space to a metric space is uniformly continuous (Heine-Cantor: a continuous map from a compact metric space to any metric space is uniformly continuous).

[F6]

For decreasing measurable sets of finite measure, the measure of their intersection is the limit of their measures (Continuity from above when one set has finite measure).

Proof

1.1givenF1F2algebra

First consider the compactly supported equivariant map. If f=0, the zero Transformer suffices. Otherwise its support K is a nonempty compact permutation-invariant set. Compactness bounds all scalar entries of matrices in K; choose real a<b with every entry in [a,b]. Since a nonzero continuous function is nonzero on an open set, K has positive measure and the bounds can be chosen with a<b. The common affine map T(X)=(X−a1)/(b−a) sends K into [0,1]d×n and commutes with column permutations. A residual width-four ReLU sublayer implements z↦αz+β on every feature by z+(α−1)(ReLU⁡(z)−ReLU⁡(−z))+β=αz+β; two hidden units handle one feature and finitely many layers handle all d features. Thus T can be inserted in the Yun architecture.

1.2givenF1F3constructchoose

Now consider continuous f on compact K without symmetry. If K has zero Lebesgue measure, the integral is zero for any network. Otherwise let a,b be the minimum and maximum of its scalar entries; again a<b. Put α=(b−a)−1 and choose Erj=(b−a)(j−1)−a(1≤r≤d, 1≤j≤n). The first residual width-four sublayers scale X+E by α, producing entries (Xrj−a)/(b−a)+(j−1). For any mesh δ=1/m used below, put ηδ(t)=−t for 0≤t<δ and ηδ(t)=0 otherwise. For each feature row, apply the residual updates t↦t+ηδ(t−k) in increasing order for k=0,δ,…,n−δ. The kth update sends exactly [k,k+δ) to k and leaves values outside that interval unchanged; hence every column-j value in [j−1,j) is mapped to one of j−1,j−1+δ,…,j−δ. Entries exactly at an upper endpoint lie on finitely many coordinate hyperplanes of measure zero and do not affect the integral. Thus the quantized matrices lie in Gδ,pos from [F3], where position offsets make every column distinct. For each grid cell meeting K, choose a representative XL∈K and set A(L)=f(XL); set arbitrary values, for example zero, on cells disjoint from K. The position-tagged assertion of [F3] realizes this finite table exactly.

1.3F1F3algebra

It remains to replace the modified gates and uniform hardmax in [F3] by the standard ReLU and softmax of T2,1,4. Consider any scalar gate ϕ that is affine on the three intervals cut by c1<c2, with formulas a1t+b1, a2t+b2, and a3t+b3, and with at least one ai=0. Fix 0<ρ<(c2−c1)/2. Replace the parts on [c1−ρ,c1] and [c2−ρ,c2] by linear ramps joining the left, middle, and right affine pieces, and leave ϕ unchanged elsewhere. The resulting continuous piecewise-affine map has knots r1=c1−ρ, r2=c1, r3=c2−ρ, r4=c2 and successive slopes s0=a1, s1, s2=a2, s3, s4=a3. Put Δi=si−si−1. It is a constant plus four ReLUs: use ΔiReLU⁡(t−ri) at knots not in S and ΔiReLU⁡(ri−t) at knots in S, choosing any applicable case S=∅ if a1=0, S={1,2} if a2=0, or S={1,2,3,4} if a3=0; add the constant that matches the left affine piece. In each case the left-tail slope is −∑i∈SΔi=a1 and the right-tail slope is ∑i∉SΔi=a3, while the slope jump at each knot is Δi, so this formula is exact outside the two ramp intervals. It covers the middle-constant sentinel gate as well as the constant-ended pulse and clamp gates used below. The two-piece clipping gate ϕ(t)=−t for t<0 and 0 for t≥0 is exactly ReLU⁡(−t). A width-four ReLU sublayer realizes each ramped scalar gate, including its constant bias, in the modified residual update. On bounded input regions the ramp error is confined to strips whose widths tend to zero with ρ. For any finite score vector s, softmax of λs converges as λ→∞ to equal weights on its maximizing coordinates and zero elsewhere; hence it converges to the uniform hardmax used in [F3].

2.1step 1.1step 1.3F3F4constructchoose

Choose δ=1/m with integer m large enough that n≤δ−d, the duplicate-cell bound below is small, and M=δ−nd>d+1+log⁡(n)/λ for a fixed λ>0. In the modified unpositioned construction, first apply to each feature row the residual gate t↦t+χM(t), where χM(t)=−t−M for t<0, χM(t)=0 for 0≤t<1, and χM(t)=−t−M for t≥1. This sends every out-of-range coordinate to the sentinel −M. Then, in increasing order for k=0,1,…,m−1, apply t↦t+ηδ(t−kδ), with ηδ(s)=−s for 0≤s<δ and 0 otherwise. The kth clamp sends precisely [kδ,(k+1)δ) to kδ and leaves values below or above that interval unchanged; after all gates each coordinate is a grid value or the sentinel. These are finite compositions of the three-piece gates in step 1.3, so the exact modified quantizer maps into Gδ+. For the unpositioned branch, partition the normalized cube into half-open grid cells of side δ. Their preimages under T have side h=(b−a)δ. By [F4], the oscillation of f between two points of K at distance at most dn h tends to zero with δ. For each orbit of distinct-column grid matrices L under column permutations, if the closed preimage cell meets K, choose one representative XL in that intersection and put A(L)=f(XL); transport the choice by permutations and set A(L)=0 on orbits whose cells miss K. This is a finite choice and gives A(LP)=A(L)P. Apply the first assertion of [F3] to this table.

2.2step 1.2F4F5algebra

By [F4], for sufficiently small δ every point of K and the representative in its grid cell have outputs within any prescribed tolerance. The cell diameter in the original coordinates is at most dn(b−a)δ, and K has finite measure because it is compact and bounded. Thus the integrated Lp(K) error of the modified position-tagged lookup can be made arbitrarily small.

3.1step 2.1F3F5F6algebra

The table network agrees with f on every point of K in a distinct-column cell up to the oscillation in step 2.1. The union of cells whose grid matrices have duplicate columns has measure at most (n2) md(n−1)hdn=(n2)(b−a)dnδd, because for each pair of columns, equality leaves only md(n−1) grid matrices. The table is zero on cells not meeting K; cells meeting K but lying partly outside it are contained in the dn h-neighborhood of K. Intersect these neighborhoods with one fixed bounded box containing K. Along any sequence hj↓0, the resulting closed neighborhoods decrease to K and have finite measure; [F5]–[F6] imply that their excess measure over K tends to zero. The table values are bounded because f is continuous on compact K. Outside the normalized cube the sentinel branch of [F3] returns zero, as does f. Therefore the integrated Lp error of the modified lookup tends to zero as δ↓0.

3.2givenF1step 2.1algebra

To control the unbounded input domain in the first assertion, insert an exact sentinel gate before simulating the lookup. For a quantized matrix Z, put sj=∑r=1dZrj and wj=e−λsj∑k=1ne−λsk,sˉ=∑j=1nwjsj. A size-one softmax head with constant query 1, key −λsj, value sj, and output vector 1d sends Z to Z+sˉ1d×n. If all entries of Z are in [0,1], then every sj≥0, so every shifted entry is nonnegative. If any entry is the sentinel −M, then min⁡jsj≤−M+d−1. The entropy identity −∑jwjlog⁡wj=λsˉ+log⁡∑k=1ne−λsk and the bounds −∑jwjlog⁡wj≤log⁡n and ∑je−λsj≥e−λmin⁡jsj imply sˉ≤min⁡jsj+(log⁡n)/λ<−1, by the choice in step 2.1. Since every entry of Z is at most 1, every shifted entry is then negative. Apply coordinatewise ReLU, implemented by the residual update zr↦zr+ReLU⁡(−zr)=ReLU⁡(zr) one feature at a time. It leaves every shifted valid state unchanged and sends every shifted sentinel state to zero. A second size-one softmax head exactly inverts the shift on nonnegative states: the shifted column sums are sj+dsˉ, so their weights remain wj and their weighted mean is (d+1)sˉ; add −(d+1)−1 times this mean to each feature. This restores Z, and sends the zero state to zero. These two attention updates and the coordinatewise clipping are ordinary blocks in T2,1,4.

3.3step 1.2step 1.3step 2.1F3algebrachoose

Fix the mesh, finite table, and modified lookup from steps 1.2 and 2.1. Choose the lookup ramp widths so small that their ramp intervals avoid every scalar gate input on the finitely many exact lookup trajectories. The detector boundaries and pulse boundaries have positive clearance from these inputs, and clipping is the exact map zr↦zr+ReLU⁡(−zr). Replace each hardmax head by scaled softmax, scaling only its scores. In the contextual sweeps a query stays away from its half-grid thresholds; maximizing keys have the same scalar code, which is also their scalar value. Thus small perturbations of tied maximizing keys cannot change the limiting value. In the final head, the only zero-query state is the all-zero matrix, where all values vanish. Positive score gaps to nonmaximizing keys suppress their weights exponentially. These observations give convergence of each head output near each exact trajectory state; the fixed ramped tokenwise maps are continuous. Induction through the finite composition therefore approximates the lookup arbitrarily closely on all required finite grid states.

4.1step 3.3step 3.2F3algebrachoose

In the unpositioned branch, this simulation can and will fix the zero matrix exactly. Every contextual attention update sends zero to zero, for every softmax scale, since its value projection vanishes there. In the lookup construction of [F3], the invalid-code detector equals one at scalar code zero, since the interval of valid codes is strictly positive. Its ramped version also equals one there when its width is sufficiently small. Subtracting the detector's fixed positive constant makes every coordinate negative, and the exact coordinatewise clipping then returns the zero matrix. Every subsequent lookup pulse is zero at scalar code zero, as its positive center is at least the least valid code. Small enough pulse ramp widths preserve this equality. Thus the entire simulated lookup sends zero exactly to zero, including its detector layers; this is stronger than merely approximating zero. The exact filter in step 3.2 followed by this lookup consequently gives zero whenever the quantizer has an exact sentinel coordinate.

5.1step 1.2step 2.1step 2.2step 3.1step 3.2step 3.3step 4.1F1F5algebrachoose∎

Use a separate width ρ<min⁡(1,δ/2) for the quantizer ramps. Away from finitely many scalar boundary strips of width at most ρ, these quantizers give exactly the grids in steps 1.2 and 2.1; the upper-endpoint hyperplanes are null. The unpositioned quantizer has every output entry in [−M,1]: its initial residual sentinel ramp joins output values −M and 0, or 1−ρ and −M, and each later clamp ramp stays between its adjacent grid endpoints. A raw normalized coordinate outside [−ρ,1] is an exact sentinel and stays so through the clamps. By step 4.1, all inputs outside the fixed box [−1,1]d×n therefore have exactly zero output. Within this box, the set where the quantizer differs from its discrete version is contained in finitely many coordinate strips of total measure tending to zero with ρ; previously clamped grid points stay fixed under later clamps. The position-tagged input region is already bounded, and the same strip estimate applies there. There is a common bound on all simulated outputs, independent of ρ and of the attention scales: on any bounded scalar interval a ramped gate lies between values of its two fixed adjacent affine pieces; attention outputs are convex combinations of fixed linear value projections, irrespective of score scale. Residual addition and induction over the fixed finite list of layers give a finite common bound, including the exact filter. Thus each transition-region error integral is bounded by a fixed constant times its strip measure. First choose the mesh so the modified lookup error in steps 2.2 and 3.1 is small; fix its table and coefficients and the resulting common bound; then shrink the quantizer strips and choose lookup simulation accuracy on the finite states as in step 3.3. The finite-grid simulation error is integrated over a fixed finite-volume box, while the unbounded exterior contributes exactly zero by step 4.1. Taking all these contributions sufficiently small, with the affine volume factor (b−a)dn included, makes the total error less than ε in both assertions.

4 · Examples, counterexamples and false statements

None yet.

Sources