Provedalphabaguettealgorithm-ideaa3
Shared computation: the gradient of Σₖ ℓₖ(h(θ)) is (Σₖ ℓₖ′)·h′(θ)
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. (
ℕ) - RReal numbers
- The real numbers: every point on the number line. (
ℝ) - ⟹Implies
- If ℝ, then ℝ. (Between types, A → B is the type of functions from A to B.) (
ℝ → ℝ) - x ∈ TVariables
- h', θ range over real numbers: the statement must hold for every choice. (
(h' θ : ℝ)) - 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) - HasDerivAt
- HasDerivAt: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
HasDerivAt) - ∀For all
- The statement after the comma holds for every k. (
∀ k, HasDerivAt (ℓ k) (ℓ' k) (h θ)) - x ↦ f(x)Function (λ-abstraction)
- The function sending t to ∑ k, ℓ(k, h(t)). Lean writes fun x => …; papers write x ↦ …. (
fun t => ∑ k, ℓ k (h t)) - ∑Summation
- Add up ℓ(k, h(t)) for every k. (
∑ k, ℓ k (h t)) - ·Multiplication
- ∑ k, ℓ'(k) times h'. (
(∑ k, ℓ' k) * h')
theorem dedup-shared-cotangent-sum {K : ℕ} (h : ℝ → ℝ) (h' θ : ℝ) (ℓ : Fin K → ℝ → ℝ) (ℓ' : Fin K → ℝ) (hh : HasDerivAt h h' θ) (hℓ : ∀ k, HasDerivAt (ℓ k) (ℓ' k) (h θ)) :
HasDerivAt (fun t => ∑ k, ℓ k (h t)) ((∑ k, ℓ' k) * h') θIdea A3. When K duplicate prefixes share one computed activation h(θ), backpropagating once with the summed cotangent Σₖ ℓₖ′ gives exactly the gradient of the sum of their losses. This is the exactness of dedup in the backward pass.
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
- 13 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.