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.

✓ 2 results · all verified · 2 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; all 2 also cleared it.

Exact tiled attention and memory-aware differentiation

1 · Prerequisites

2 · Logical flowchart

3 · Definitions, theorems and proofs

DefinitionDefinition: Literature-sourcedProof: Not applicableOpen item page →

Stable summary of an attention key block

Definition

Let n,d,v be positive integers, let Q,K∈Rn×d and V∈Rn×v, let c∈R, and for each query row i∈{1,…,n} let Ai⊆{1,…,n} be a nonempty set of allowed keys. Write qi for row i of Q, kj for row j of K, vj for row j of V, and sij=c∑r=1dQirKjr for j∈Ai. For a nonempty finite set S⊆Ai, its attention summary is

Σi(S)=(mi(S),ℓi(S),zi(S)),mi(S)=max⁡j∈Ssij,ℓi(S)=∑j∈Sesij−mi(S),zi(S)=∑j∈Sesij−mi(S)vj.

The empty set has the separate state ⊥ and has no maximum or numeric summary coordinates. For disjoint nonempty S,T⊆Ai, define their merge by

m′=max⁡(mi(S),mi(T)),ℓ′=emi(S)−m′ℓi(S)+emi(T)−m′ℓi(T),z′=emi(S)−m′zi(S)+emi(T)−m′zi(T).

and set Σi(S)⋆Σi(T)=(m′,ℓ′,z′). This summary stores the maximum score, a positive shifted normalizer, and the correspondingly shifted weighted value sum; dividing its third coordinate by its second gives the attention output on S.

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

Exact tiled softmax attention with block-recomputed vector-Jacobian products

Definition

Inputs: Positive integers n,d,v, finite real matrices Q,K∈Rn×d and V∈Rn×v, a real scale c, a positive integer key-block size b, and fixed nonempty allowed-key sets A1,…,An⊆{1,…,n}. The algorithm reads membership in each Ai on demand; any caller-owned representation of the mask is input storage. All operations below are in exact real arithmetic. Set Jt={(t−1)b+1,…,min⁡(tb,n)} for t=1,…,⌈n/b⌉.

Forward procedure:

  1. For each query row i, set the current summary to ⊥.
  2. For t=1,…,⌈n/b⌉, form I=Jt∩Ai. If I=∅, skip this block and leave the summary unchanged. Otherwise compute Σi(I). If the current summary is ⊥, copy Σi(I); otherwise merge the current summary with Σi(I) using ⋆.
  3. After the final block, write Yi=zi/ℓi and retain the final mi and ℓi for a later reverse pass.
  4. Return Y∈Rn×v and the retained row statistics.

Reverse procedure: Given a forward run with the same Q,K,V,c,A1,…,An and an upstream matrix G∈Rn×v, initialize dQ,dK,dV to zero. For each query row i, compute δi=∑a=1vGiaYia. For every block Jt and each j∈Jt∩Ai, recompute sij from Q,K and set

pij=esij−miℓi,γij=pij(∑a=1vGiaVja−δi).

Then, for r=1,…,d, add to the query and key gradient arrays, and for a=1,…,v, add to the value gradient array:

(dQ)ir+=cγijKjr,(dK)jr+=cγijQir,(dV)ja+=pijGia.

Return dQ,dK,dV. Do not store a full score or probability matrix: the reverse procedure recomputes one block's scores from the same inputs and fixed allowed-key sets. The prescribed reverse procedure treats the forward maxima and normalizers as frozen scaling statistics; it does not differentiate a maximum operation. The base algorithm has no dropout. Any dropout extension must replay the same realized dropout mask in its reverse pass.

TheoremStatement: Literature-sourcedProof: AI-generatedprecheck passjudge pass (gpt-6-luna)Open item page →

Tiled attention and its recomputed reverse pass are exact

Statement

Let n,d,v be positive integers, Q,K∈Rn×d and V∈Rn×v be finite real matrices, c∈R, b a positive integer, and Ai⊆{1,…,n} a fixed nonempty set of allowed keys for every query row i. Write Qi for row i of Q, and Kj,Vj for row j of K,V. Let Y,mi,ℓi be the forward outputs and row statistics of the exact tiled softmax attention algorithm, and fix an upstream matrix G∈Rn×v. Then each row of Y equals the dense masked attention row

Yi=∑j∈AiecQiKjTVj∑j∈AiecQiKjT,

and the algorithm's recomputed reverse procedure returns the Euclidean gradients of the scalar function Φ(Q,K,V)=∑i=1n∑a=1vGiaYia with respect to Q,K,V, while holding c, the sets Ai, and G fixed. Its reverse rule treats the stored maxima as fixed normalization shifts, so the conclusion also holds when scores tie at a row maximum. Every row is defined because Ai is nonempty; no convention for an all-masked row is asserted.

Facts & Assumptions

Given: The finite real inputs, the fixed nonempty allowed-key sets, the positive block size, the forward and reverse procedures, and the upstream matrix G.

[F1]

Scaled dot-product attention: masked attention uses row softmax of the scaled query-key scores and is defined only when each row has an allowed key.

[F2]

Stable summary of an attention key block: for nonempty S, the summary coordinates are max⁡j∈Ssij, ∑j∈Sesij−mi(S), and ∑j∈Sesij−mi(S)Vj; the empty set is the separate symbol ⊥.

[F3]

Exact tiled softmax attention with block-recomputed vector-Jacobian products: the forward pass skips empty allowed blocks, copies the first nonempty block summary, merges later summaries, and the reverse pass recomputes pij and accumulates the stated dQ,dK,dV entries.

[F4]

Finite straight-line computational programs and real-arithmetic tapes: a finite topologically ordered real-arithmetic graph has differentiable primitive maps on open domains and repeated input uses are separate parent slots.

[F5]

Reverse mode computes the exact gradient of the real-arithmetic graph: for a finite C1 program with one scalar output on a fixed strict branch, reverse mode returns the exact derivative of that output.

[F6]

The chain rule for total derivatives: D(g∘f)(a)=Dg(f(a))∘Df(a): for totally differentiable finite-dimensional maps, the derivative of a composition is the ordered composition of the derivatives.

[F7]

Backpropagation through a finite shared-parameter recurrence: the same parameter vector is supplied to every transition.

[F8]

Reverse accumulation sums gradients over shared parameter uses: the gradient formula includes a pullback term for each transition using the shared parameter.

Proof

technique · identify the exact summary invariant, then differentiate the equivalent dense masked attention map and group repeated input contributions
1.1F2F3givenconstruct

Fix a query row i and let S be the union of the allowed keys in the blocks processed so far. Initially S=∅ and the algorithm's state is ⊥. An empty allowed block leaves both S and the state unchanged. If S=∅ and the next allowed block I is nonempty, copying Σi(I) gives the defining summary of S∪I. If S and I are both nonempty, the merged maximum is max⁡(mi(S),mi(I))=mi(S∪I), and emi(S)−mi(S∪I)ℓi(S)=∑j∈Sesij−mi(S∪I) while emi(I)−mi(S∪I)ℓi(I)=∑j∈Iesij−mi(S∪I). The same two identities with Vj inside each sum give the merged z coordinate. Disjoint blocks therefore preserve the summary invariant.

2.1F1F2F3step 1.1algebra

The key blocks partition {1,…,n}, so after the last block S=Ai≠∅. The maximum mi is finite and at least one term in ℓi=∑j∈Aiesij−mi equals 1, hence ℓi>0. Dividing zi by ℓi and multiplying numerator and denominator by emi gives the displayed dense masked attention row. This also proves every retained mi,ℓi is defined.

3.1F4F5F6step 2.1given

With the allowed sets fixed, every score is a polynomial in the entries of Q,K; finite exponentials, sums, and division by the strictly positive dense denominator make the dense row map smooth on all of Rn(2d+v). Its scalarization Φ is therefore a finite C1 real-arithmetic graph. The reverse-mode theorem and chain rule apply to this dense graph; the maximum used only to scale the tiled forward computation is not a primitive of this graph.

4.1F5F6step 2.1step 3.1algebra

For j,k∈Ai, write pij=esij/∑ℓ∈Aiesiℓ, as justified by step 2.1. Direct quotient differentiation gives ∂pik∂sij=pik(1{k=j}−pij). Thus for Φi=∑aGiaYia the score derivative is ∂Φi∂sij=∑k∈Ai(∑aGiaVka)∂pik∂sij=pij(∑aGiaVja−∑aGiaYia)=γij. The direct value derivative is ∇VjΦi=pijGi.

5.1F6step 4.1algebra

Since sij=c∑rQirKjr, its coordinate derivatives are ∂sij/∂Qir=cKjr and ∂sij/∂Kjr=cQir. The chain rule therefore gives the row-i contributions c∑j∈AiγijKj to Qi, cγijQi to Kj, and pijGi to Vj. Entries of other query rows receive no contribution from this row.

6.1F7F8step 3.1step 5.1algebra

Set Θ=R2nd+nv, H=R, h0(θ)=0, Fi(θ,h)=h+∑aGiaYia(θ) for i=1,…,n, and terminal loss λ(θ,h)=h. Step 3.1 makes every Fi continuously differentiable on the open domain Θ×H. By induction on i, the recurrence state after i transitions is hi=∑r=1i∑aGraYra(θ): the formula holds at i=0 because h0=0, and adding the ith transition term proves it at i from its value at i−1. Thus its scalar output is hn=Φ(θ). The same parameter θ=(Q,K,V) is supplied at every transition, and the shared-parameter gradient formula sums each transition's parameter pullback. It therefore adds each row's pullback at the common K,V inputs, while the row-specific Qi pullbacks occupy their corresponding rows. There is no direct loss or initial-state parameter term because λ is h and h0 is constant. Thus the algorithm's reverse updates give ∇QΦ,∇KΦ,∇VΦ.

7.1F2F3step 2.1step 3.1step 4.1step 5.1step 6.1algebra∎

At the forward values, the summary invariant in steps 1.1–2.1 gives ℓi=∑j∈Aiesij−mi. Therefore, for each j∈Ai, pij=esij−miℓi=esij∑ℓ∈Aiesiℓ. This is the dense softmax probability evaluated at the current scores. Steps 4.1–6.1 differentiate the smooth dense attention map and show that substituting these probabilities into the reverse updates gives its exact gradient at these inputs. The stored mi and ℓi are used as normalization shifts in those updates; no derivative of either statistic is needed. The argument applies whether or not the maximum score is tied.

TheoremStatement: Literature-sourcedProof: AI-generatedprecheck passjudge pass (gpt-6-luna)Open item page →

Tiled attention uses linear retained memory and quadratic arithmetic

Statement

In the unit-cost real-arithmetic model where scalar arithmetic, exponential evaluation, comparisons, and one allowed-key membership query each cost O(1), the forward and reverse procedures of the exact tiled softmax attention algorithm use O(n2(d+v)) arithmetic operations. The forward procedure retains the Q,K,V inputs, the n×v output, and two scalar statistics per query, requiring O(n(d+v)) stored input and output scalars, with at most O(b+v) additional live scalars for one block's scores and weighted-value summary. The reverse procedure additionally takes G and returns dQ,dK,dV; counting these as input and output arrays, it also uses O(n(d+v)) stored input and output scalars and at most O(b+v) additional live scalars. Neither procedure materializes an n×n score or probability array. Storage for a caller-owned mask representation is input storage and is not part of the additional workspace; if it is a dense array, its own O(n2) entries must be counted separately. The exactness of the forward and reverse outputs is the assertion of the tiled-attention exactness theorem. No hardware I/O or floating-point operation count is asserted.

Facts & Assumptions

Given: The positive integers n,d,v,b, fixed allowed-key sets, and the two procedures of the exact tiled softmax attention algorithm.

[F1]

Exact tiled softmax attention with block-recomputed vector-Jacobian products: the forward procedure processes one query row and one key block at a time, while the reverse procedure recomputes each permitted score and accumulates gradients into output arrays.

[F2]

Stable summary of an attention key block: a nonempty block summary stores one scalar maximum, one scalar normalizer, and one vector in Rv; an empty block stores no numeric state.

[F3]

Tiled attention and its recomputed reverse pass are exact: the two procedures return the dense masked attention and its exact vector-Jacobian product.

[F4]

Exact tiled softmax attention with block-recomputed vector-Jacobian products: the reverse procedure recomputes each block's scores and does not store a full score or probability matrix.

[A1]

The mask membership accessor is read-only, has O(1) query cost, and any storage for its representation is caller-owned input storage rather than algorithmic scratch.

[A2]

The operation count is scalar arithmetic, exponential evaluation, comparisons, and mask membership queries; all are unit cost in this model.

Proof

technique · count the live arrays, block workspace, and operations in the explicit loops
1.1F1F2A1givenalgebra

The forward procedure retains Q,K,V,Y and (mi,ℓi)i=1n. Their scalar counts are nd+nd+nv+nv+2n=O(n(d+v)) because d,v≥1. At any query and key block it stores at most b scores and the current and block weighted-value vectors of length v, plus a constant number of scalars. This is O(b+v) extra live storage, and it discards the block workspace before moving to the next block.

1.2F1F2A2givenalgebra

The forward loops examine at most n2 query-key pairs. For each pair, the score dot product uses O(d) operations; its normalized exponential and weighted-value contribution use O(1+v) operations. Block maxima, membership queries, and scalar loop overhead cost O(n2) in total. There are at most n⌈n/b⌉≤n2 block visits, each summary copy or merge costs O(v), and final row divisions cost O(nv). Thus forward arithmetic is O(n2(d+v)). Only one block's scores and weighted-value summaries are live, so no n×n score or probability array is allocated.

1.3F4A1givenalgebra

The reverse procedure's retained arrays are Q,K,V,Y,G,dQ,dK,dV and the 2n row statistics. Their scalar counts are all O(n(d+v)). For one row and one key it recomputes one score and one probability, forms scalar inner products, and updates entries in the already allocated gradient arrays; it needs only a constant number of additional scalars, which is within O(b+v). It does not store the recomputed probabilities across pairs.

2.1F3F4A2givenalgebra∎

Each query-key pair in the reverse pass costs O(d+v) operations: one score, one inner product with Vj, and vector updates with lengths d and v. There are at most n2 pairs, and the finite loop overhead is at most O(n2), so reverse arithmetic is O(n2(d+v)). Since scores and probabilities are recomputed one at a time, this pass also creates no n×n array. The separate exactness claim is supplied by [F3].

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

The scalar workspace result is not a hardware I/O bound

Remarks

The workspace theorem counts scalar storage and operations for the explicitly defined real-arithmetic procedure. It does not count reads and writes between GPU high-bandwidth memory and on-chip SRAM, and it gives no hardware speedup claim. The FlashAttention paper's Θ(n2d2/M) HBM-access result assumes its stated memory model, block schedule, and range d≤M≤nd; its endpoint input-size argument is not a lower bound for every fixed memory size. Neither claim follows from the scalar workspace theorem here.

The maximum shift makes every exact-real exponent argument sij−mi nonpositive, but this does not specify rounded arithmetic or rule out underflow of very small finite-precision terms. Different floating-point accumulation orders can return different bit patterns. The base procedure includes no dropout; if an extension uses dropout, its fixed realized mask must be reused in the reverse pass because a different mask changes the differentiated function.

4 · Examples, counterexamples and false statements

None yet.

Sources