proofs
Provedalphabaguettenoether-checksumattention

Checksum C3: Σᵢ⟨dQᵢ, qᵢ⟩ = Σⱼ⟨dKⱼ, kⱼ⟩, tying the query and key backward kernels together

For all T,D∈N\htmlData{mx=1}{T, D \in \htmlData{mx=0}{\mathbb{N}}}, R:Fin⁡ T→Fin⁡ T→R\htmlData{mx=9}{R : \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{T}} \mathrel{\htmlData{mx=8}{\to}} \htmlData{mx=5}{\htmlData{mx=3}{\operatorname{Fin}}\,\htmlData{mx=4}{T}} \mathrel{\htmlData{mx=7}{\to}} \htmlData{mx=6}{\mathbb{R}}}, q,k:Fin⁡ T→Fin⁡ D→R\htmlData{mx=9}{q, k : \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{T}} \mathrel{\htmlData{mx=8}{\to}} \htmlData{mx=5}{\htmlData{mx=3}{\operatorname{Fin}}\,\htmlData{mx=4}{D}} \mathrel{\htmlData{mx=7}{\to}} \htmlData{mx=6}{\mathbb{R}}} and scale∈R\htmlData{mx=1}{\mathit{scale} \in \htmlData{mx=0}{\mathbb{R}}}:

∑i∑cscale⋅∑jR(i,j)⋅k(j,c)⋅q(i,c)=∑j∑cscale⋅∑iR(i,j)⋅q(i,c)⋅k(j,c)\begin{aligned} & \htmlData{mx=19}{\sum_{i} \htmlData{mx=18}{\sum_{c} \htmlData{mx=17}{\htmlData{mx=12}{\htmlData{mx=1}{\mathit{scale}} \cdot \htmlData{mx=11}{\sum_{j} \htmlData{mx=10}{\htmlData{mx=5}{\htmlData{mx=2}{R}(\htmlData{mx=3}{i}, \htmlData{mx=4}{j})} \cdot \htmlData{mx=9}{\htmlData{mx=6}{k}(\htmlData{mx=7}{j}, \htmlData{mx=8}{c})}}}} \cdot \htmlData{mx=16}{\htmlData{mx=13}{q}(\htmlData{mx=14}{i}, \htmlData{mx=15}{c})}}}} \\ & \quad \htmlData{mx=0}{=} \htmlData{mx=38}{\sum_{j} \htmlData{mx=37}{\sum_{c} \htmlData{mx=36}{\htmlData{mx=31}{\htmlData{mx=20}{\mathit{scale}} \cdot \htmlData{mx=30}{\sum_{i} \htmlData{mx=29}{\htmlData{mx=24}{\htmlData{mx=21}{R}(\htmlData{mx=22}{i}, \htmlData{mx=23}{j})} \cdot \htmlData{mx=28}{\htmlData{mx=25}{q}(\htmlData{mx=26}{i}, \htmlData{mx=27}{c})}}}} \cdot \htmlData{mx=35}{\htmlData{mx=32}{k}(\htmlData{mx=33}{j}, \htmlData{mx=34}{c})}}}} \end{aligned}
What the notation means · or point at any symbol
NNatural numbers
The natural numbers 0, 1, 2, …. In Lean they start at 0. (ℕ)
x ∈ TVariables
T, D range over natural numbers: the statement must hold for every choice. ((T D : ℕ))
Fin
Fin: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Fin)
f(x)Function application
Fin applied to T. Lean writes f x; papers write f(x). (Fin T)
x : TVariables
q, k range over Fin T → Fin D → ℝ: the statement must hold for every choice. ((q k : Fin T → Fin D → ℝ))
=Equality
∑ i, ∑ c, scale · (∑ j, R(i, j) · k(j, c)) · q(i, c) and ∑ j, ∑ c, scale · (∑ i, R(i, j) · q(i, c)) · k(j, c) are the same. (∑ i, ∑ c, (scale * ∑ j, R i j * k j c) …)
⟹Implies
If Fin(T), then ℝ. (Between types, A → B is the type of functions from A to B.) (Fin T → ℝ)
RReal numbers
The real numbers: every point on the number line. (ℝ)
∑Summation
Add up R(i, j) · k(j, c) for every j. (∑ j, R i j * k j c)
·Multiplication
R(i, j) times k(j, c). (R i j * k j c)

With dQᵢ = scale·Σⱼ Rᵢⱼ kⱼ and dKⱼ = scale·Σᵢ Rᵢⱼ qᵢ for the SAME score gradient R, both scalars equal scale·Σᵢⱼ Rᵢⱼ⟨qᵢ, kⱼ⟩. Holds for any R. It catches bugs that preserve sums, such as dK rows stored to permuted addresses (missed by C1, flagged at 378× in the experiment). Part of 'Noether checksums for Baguette's backward kernels'.

How it was proved

Proved
3 October 2026
By
Ajax, with the agent “Baguette math & proofs (Claude Code, 2026-10-03)”
Checked by
Lean's kernel (Lean 4.33.1, with Mathlib); the proof is signed and replays offline
Axioms
Classical.choice, Quot.sound, propext
Proof
24 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.

More proved statements