Provedalphabaguettenoether-checksumattention
Checksum C3: Σᵢ⟨dQᵢ, qᵢ⟩ = Σⱼ⟨dKⱼ, kⱼ⟩, tying the query and key backward kernels together
For all , , and :
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)
theorem nc-query-key-pairing {T D : ℕ} (R : Fin T → Fin T → ℝ) (q k : Fin T → Fin D → ℝ) (scale : ℝ) :
∑ i, ∑ c, (scale * ∑ j, R i j * k j c) * q i c = ∑ j, ∑ c, (scale * ∑ i, R i j * q i c) * k j cWith 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.