proofs
Provedalphabaguetteoptimizerclipping

Global-norm clipping on gradients pre-scaled by 1/N makes the same decision with the same coefficient

For all k∈N\htmlData{mx=1}{k \in \htmlData{mx=0}{\mathbb{N}}}, g:Fin⁡ k→R\htmlData{mx=5}{g : \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{k}} \mathrel{\htmlData{mx=4}{\to}} \htmlData{mx=3}{\mathbb{R}}} and N,c∈R\htmlData{mx=1}{N, c \in \htmlData{mx=0}{\mathbb{R}}}, if 0<N0 \mathrel{\htmlData{mx=1}{<}} \htmlData{mx=0}{N}, then

(∑i(g(i)N)2≤cN  ⟺  ∑ig(i)2≤c)∧cN∑i(g(i)N)2=c∑ig(i)2\begin{aligned} & \left(\htmlData{mx=8}{\sqrt{\htmlData{mx=7}{\sum_{i} \htmlData{mx=6}{\left(\htmlData{mx=5}{\frac{\htmlData{mx=3}{\htmlData{mx=1}{g}(\htmlData{mx=2}{i})}}{\htmlData{mx=4}{N}}}\right)^{2}}}}} \mathrel{\htmlData{mx=12}{\leq}} \htmlData{mx=11}{\frac{\htmlData{mx=9}{c}}{\htmlData{mx=10}{N}}} \mathrel{\htmlData{mx=21}{\iff}} \htmlData{mx=18}{\sqrt{\htmlData{mx=17}{\sum_{i} \htmlData{mx=16}{\htmlData{mx=15}{\htmlData{mx=13}{g}(\htmlData{mx=14}{i})}^{2}}}}} \mathrel{\htmlData{mx=20}{\leq}} \htmlData{mx=19}{c}\right) \\ & \htmlData{mx=0}{\land} \htmlData{mx=33}{\frac{\htmlData{mx=24}{\frac{\htmlData{mx=22}{c}}{\htmlData{mx=23}{N}}}}{\htmlData{mx=32}{\sqrt{\htmlData{mx=31}{\sum_{i} \htmlData{mx=30}{\left(\htmlData{mx=29}{\frac{\htmlData{mx=27}{\htmlData{mx=25}{g}(\htmlData{mx=26}{i})}}{\htmlData{mx=28}{N}}}\right)^{2}}}}}}} \mathrel{\htmlData{mx=42}{=}} \htmlData{mx=41}{\frac{\htmlData{mx=34}{c}}{\htmlData{mx=40}{\sqrt{\htmlData{mx=39}{\sum_{i} \htmlData{mx=38}{\htmlData{mx=37}{\htmlData{mx=35}{g}(\htmlData{mx=36}{i})}^{2}}}}}}} \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. (ℕ)
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 k. Lean writes f x; papers write f(x). (Fin k)
⟹Implies
If Fin(k), then ℝ. (Between types, A → B is the type of functions from A to B.) (Fin k → ℝ)
x ∈ TVariables
N, c range over real numbers: the statement must hold for every choice. ((N c : ℝ))
<Less than
0 is strictly smaller than N. (0 < N)
∧And
Both hold: √(∑ i, (g(i)/N)^2) ≤ c/N ↔ √(∑ i, g(i)^2) ≤ c, and c/N/√(∑ i, (g(i)/N)^2) = c/√(∑ i, g(i)^2). ((Real.sqrt (∑ i, (g i / N) ^ 2) ≤ c / N…)
√Square root
The non-negative number whose square is ∑ i, (g(i)/N)^2. (Real.sqrt (∑ i, (g i / N) ^ 2))
≤At most
√(∑ i, (g(i)/N)^2) is less than or equal to c/N. (Real.sqrt (∑ i, (g i / N) ^ 2) ≤ c / N)
⟺If and only if
√(∑ i, (g(i)/N)^2) ≤ c/N holds exactly when √(∑ i, g(i)^2) ≤ c holds. (Real.sqrt (∑ i, (g i / N) ^ 2) ≤ c / N …)
RReal numbers
The real numbers: every point on the number line. (ℝ)
∑Summation
Add up (g(i)/N)^2 for every i. (∑ i, (g i / N) ^ 2)
aᵇPower
g(i)/N raised to the power 2. ((g i / N) ^ 2)
a/bDivision
g(i) divided by N. In Lean, dividing by 0 gives 0. (g i / N)
=Equality
c/N/√(∑ i, (g(i)/N)^2) and c/√(∑ i, g(i)^2) are the same. ((c / N) / Real.sqrt (∑ i, (g i / N) ^ 2…)

To avoid overflow when squaring F32 gradients, Baguette scales every gradient by 1/N (N = parameter count) before the global-norm tree and compares against c/N (baguetteGradientNormScaleWord, baguetteGradientScaledClipLimitWord; Alpha commit e3330947, systems/baguette/src/Baguette/Learner.alpha). The comment claims this preserves "the unscaled L2 clipping decision". Over ℝ, for N > 0: ‖g/N‖ ≤ c/N ⇔ ‖g‖ ≤ c, and the clip coefficient (c/N)/‖g/N‖ = c/‖g‖ (with Lean's x/0 = 0 for a zero gradient).

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
18 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.

More proved statements