Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 6 — chain rule for the Jacobian of a layered network

Proved
CertDRO.NNSmooth.lemma_6

by mikedeng1 · Oct 8, 2026 · Mathlib 0df444a (Lean v4.33.1)

chain-rulejacobianneural-networksp2o-batch-pfp2bp2o-gran-per-chapterp2o-plan-paperp2o-v1

Let Fl(θ;x)F_l(\theta;x)Fl​(θ;x) be the output of the first lll layers of a network of depth LLL, as in (20), and suppose every operation σl\sigma_lσl​, l=1,…,Ll=1,\dots,Ll=1,…,L, is differentiable. Then:

  1. for every l=0,…,Ll=0,\dots,Ll=0,…,L the map x↦Fl(θ;x)x\mapsto F_l(\theta;x)x↦Fl​(θ;x) is differentiable;
  2. for every l=1,…,Ll=1,\dots,Ll=1,…,L its Jacobian satisfies the recursion
JxFl(θ;x)=∇σl(θl⋅Fl−1(θ;x))⋅θl⋅JxFl−1(θ;x);J_xF_l(\theta;x)=\nabla\sigma_l\big(\theta_l\cdot F_{l-1}(\theta;x)\big)\cdot\theta_l\cdot J_xF_{l-1}(\theta;x);Jx​Fl​(θ;x)=∇σl​(θl​⋅Fl−1​(θ;x))⋅θl​⋅Jx​Fl−1​(θ;x);
  1. for every l=0,…,Ll=0,\dots,Ll=0,…,L, unrolling the recursion,
JxFl(θ;x)=∏k=1l∇σk(θk⋅Fk−1(θ;x))⋅θk,J_xF_l(\theta;x)=\prod_{k=1}^{l}\nabla\sigma_k\big(\theta_k\cdot F_{k-1}(\theta;x)\big)\cdot\theta_k,Jx​Fl​(θ;x)=k=1∏l​∇σk​(θk​⋅Fk−1​(θ;x))⋅θk​,

the product taken in network order Al⋯A1A_l\cdots A_1Al​⋯A1​ (the identity for l=0l=0l=0).

Here ∇σk\nabla\sigma_k∇σk​ denotes the Jacobian of σk\sigma_kσk​. The recursion is the basis of the smoothness bounds of Proposition 5 and of the telescoping representation (34).

Formalization Note Layers are 0-based in Lean (Lean layer l is the paper's l+1l+1l+1). Part 2 is a HasFDerivAt statement for Fl+1F_{l+1}Fl+1​ with the composed derivative; part 3 identifies fderiv (F l) x with the tail product of the definition file taken from layer 000 at the same input xxx. The paper prints the product with upper index LLL; it is read as lll.

Preamble
import Mathlib
import Definitions.Def_CertDRO_NNSmooth_Network
Formal statement
namespace CertDRO.NNSmooth

open Network

/-- Lemma 6 (§B.8, p. 44). If `σ_l` is differentiable for every layer of a depth-`L` network, then
every `x ↦ F_l(θ; x)`, `l ≤ L`, is differentiable; its Jacobian satisfies the chain-rule recursion
`J_x F_{l+1}(θ; x) = Jσ_{l+1}(θ_{l+1} · F_l(θ; x)) · θ_{l+1} · J_x F_l(θ; x)` (0-based: layer `l`);
and it equals the product `∏ ∇σ_k(θ_k · F_{k-1}(θ; x)) · θ_k` over all `l` layers, i.e. the tail
product `tailJac x 0 l` taken at the same input `x`. -/
theorem lemma_6 (N : Network) (L : ℕ) (hσ : ∀ l < L, Differentiable ℝ (N.σ l)) :
    (∀ l ≤ L, Differentiable ℝ (N.F l)) ∧
    (∀ l < L, ∀ x : E (N.dO 0),
      HasFDerivAt (N.F (l + 1))
        ((fderiv ℝ (N.σ l) (N.θ l (N.F l x))).comp ((N.θ l).comp (fderiv ℝ (N.F l) x))) x) ∧
    (∀ l ≤ L, ∀ x : E (N.dO 0), fderiv ℝ (N.F l) x = N.tailJac x 0 l) := by sorry

end CertDRO.NNSmooth
Source
Sinha, Namkoong, Volpi, Duchi, Certifying Some Distributional Robustness with Principled Adversarial Training, arXiv:1710.10571v5, p. 44, §B.8, Lemma 6
Human review
  • Endorsed by Shuze Chen · Oct 9, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 9, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me