Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The ResNet as an Euler scheme, and the weight-interpolated residual

Definition
SanderAblinPeyre2022_Defs

by Meshaal Alenezi · Dec 2, 2026 · Mathlib 0df444a (Lean v4.33.1)

euler-methodgronwallneural-oderesnet

Over a real normed space EEE: euler φ x0 N is the sequence x0x_0x0​, xn+1=xn+1Nφ(xn,nN)x_{n+1}=x_n+\frac1N\varphi(x_n,\frac nN)xn+1​=xn​+N1​φ(xn​,Nn​) (the ResNet of eq. (1) with φ(⋅,n/N)=f(⋅,θn)\varphi(\cdot,n/N)=f(\cdot,\theta_n)φ(⋅,n/N)=f(⋅,θn​), i.e. the Euler scheme for eq. (2) with step 1/N1/N1/N). wInterp N s =(2Ns−(2⌊Ns⌋+1))2=(2Ns-(2\lfloor Ns\rfloor+1))^2=(2Ns−(2⌊Ns⌋+1))2, the weight-interpolated residual of the second example on p. 4.

Definition code
import Mathlib

namespace SanderAblinPeyre2022

variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]

/-- The ResNet of depth `N` (eq. (1)), i.e. the Euler scheme for eq. (2) with step `1/N`:
`x_{n+1} = x_n + (1/N) φ(x_n, n/N)`. -/
noncomputable def euler (φ : E → ℝ → E) (x0 : E) (N : ℕ) : ℕ → E
  | 0 => x0
  | n + 1 => euler φ x0 N n + (1 / (N : ℝ)) • φ (euler φ x0 N n) ((n : ℝ) / N)

/-- The weight-interpolated residual of the second negative example (p. 4):
`φ(·, s) = (2Ns - (2n + 1))²` on `[n/N, (n+1)/N]`, written with `n = ⌊N s⌋`. -/
noncomputable def wInterp (N : ℕ) (s : ℝ) : ℝ := (2 * N * s - (2 * ⌊(N : ℝ) * s⌋ + 1)) ^ 2

end SanderAblinPeyre2022
Source
M. E. Sander, P. Ablin, G. Peyre, Do Residual Neural Networks discretize Neural Ordinary Differential Equations?, NeurIPS 2022, arXiv:2205.14612v2, Section 3.1, eq. (1)-(2), p. 4
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Throughout, EEE is any real normed vector space. Definition euler. Given a map φ:E×R→E\varphi : E \times \mathbb{R} \to Eφ:E×R→E (written φ(u,s)\varphi(u, s)φ(u,s)), a starting point x0∈Ex_0 \in Ex0​∈E and a natural number NNN, euler is the sequence (xn)n∈N(x_n)_{n \in \mathbb{N}}(xn​)n∈N​ in EEE defined recursively for every n∈Nn \in \mathbb{N}n∈N (not only n≤Nn \le Nn≤N) by

x0=x0,xn+1=xn+1N φ ⁣(xn,nN),x_0 = x_0, \qquad x_{n+1} = x_n + \frac{1}{N}\,\varphi\!\left(x_n, \frac{n}{N}\right),x0​=x0​,xn+1​=xn​+N1​φ(xn​,Nn​),

where NNN and nnn are taken as real numbers and division is real division. Edge case: when N=0N = 0N=0, the convention 1/0=01/0 = 01/0=0 and n/0=0n/0 = 0n/0=0 applies, so the update term is 0⋅φ(xn,0)=00 \cdot \varphi(x_n, 0) = 00⋅φ(xn​,0)=0 and xn=x0x_n = x_0xn​=x0​ for all nnn. Definition wInterp. For a natural number NNN and a real sss,

wN(s)=(2Ns−(2⌊Ns⌋+1))2,w_N(s) = \bigl(2 N s - (2\lfloor N s \rfloor + 1)\bigr)^2,wN​(s)=(2Ns−(2⌊Ns⌋+1))2,

where ⌊Ns⌋\lfloor N s \rfloor⌊Ns⌋ is the integer floor of the real number NsN sNs, then regarded as a real number. This is defined for all real sss (not only s∈[0,1]s \in [0,1]s∈[0,1]) and all N∈NN \in \mathbb{N}N∈N, including N=0N = 0N=0, where w0(s)=1w_0(s) = 1w0​(s)=1.

Human review
  • Endorsed by Shuze Chen · Dec 2, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Meshaal Alenezi · Dec 2, 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