DeepONet: operator networks, Tauber–Wiener functions, sensors and the ODE solution operator
DefinitionDeepONetUniversal_BasicObjects of Theorem 1 (eq. (1)), Section 3 and Appendices A and B of Lu, Jin and Karniadakis (2019).
- Networks. For an activation , the branch network on sensor values is , and the trunk network on is . The stacked operator network of eq. (1) is
The network of Theorem 2 is with , , , and applied componentwise. is the Euclidean norm. 2. Activations. is a polynomial if for a real polynomial . is a Tauber–Wiener (TW) function (Definition 1) if for every interval , every continuous on and every there are and with on . means that the distribution on compactly supported test functions extends to a continuous linear functional on the Schwartz space. 3. Compactness in . A family of real functions on is uniformly bounded (Definition 3) if for all , , and equicontinuous (Definition 4) if for every there is with for all and . 4. Sensors and interpolation (Section 3). On the sensors are , . The interpolant is the piecewise-linear function with for . For , , and . The sensor values of are . 5. ODE operator (eq. (3)). is the solution operator of , , on a set of inputs: for , is integrable on and for . 6. Lipschitz condition (Section 3). For sets , : and for all , , . The value set of a family of functions on is .
Formalization Note is Mathlib's space of continuous maps on the subtype ; on compact its topology is that of the sup norm. Functions in are evaluated at a real point through a helper that returns off ; every statement evaluates only on . The segment of in the interpolant is , which agrees with the paper's formula on every closed segment. is with the dot product .
import Mathlib
/-!
Lu, Jin and Karniadakis, *DeepONet: Learning nonlinear operators for identifying differential
equations based on the universal approximation theorem of operators*, arXiv:1910.03193v3 (2019):
the stacked operator network of Theorem 1 (eq. (1)), the Tauber-Wiener functions, uniform
boundedness and equicontinuity of Appendix A, and the sensors, piecewise-linear interpolation,
compact set `W`, ODE operator and Lipschitz condition of Section 3 and Appendix B.
-/
open MeasureTheory
noncomputable section
namespace DeepONetUniversal
/-! ### Networks (Theorem 1, eq. (1); Theorems 4 and 5; Theorem 2) -/
/-- Theorem 1, eq. (1) ("branch"), and Theorem 4: the one-hidden-layer network
`∑_{i=1}^n c_i σ(∑_{j=1}^m ξ_{ij} v_j + θ_i)` applied to the sensor values `v = (u(x_1),…,u(x_m))`. -/
def branchNet {n m : ℕ} (σ : ℝ → ℝ) (c : Fin n → ℝ) (ξ : Fin n → Fin m → ℝ) (θ : Fin n → ℝ)
(v : Fin m → ℝ) : ℝ :=
∑ i, c i * σ (∑ j, ξ i j * v j + θ i)
/-- Theorem 1, eq. (1) ("trunk"): `σ(w · y + ζ)` for `y ∈ ℝ^d`. -/
def trunkNet {d : ℕ} (σ : ℝ → ℝ) (w : Fin d → ℝ) (ζ : ℝ) (y : Fin d → ℝ) : ℝ :=
σ (∑ l, w l * y l + ζ)
/-- Theorem 1, eq. (1), and Theorem 5 (the stacked DeepONet of Fig. 1C):
`∑_{k=1}^p [∑_{i=1}^n c_i^k σ(∑_{j=1}^m ξ_{ij}^k v_j + θ_i^k)] σ(w_k · y + ζ_k)`. -/
def operatorNet {n m p d : ℕ} (σ : ℝ → ℝ) (c : Fin p → Fin n → ℝ) (ξ : Fin p → Fin n → Fin m → ℝ)
(θ : Fin p → Fin n → ℝ) (w : Fin p → Fin d → ℝ) (ζ : Fin p → ℝ) (v : Fin m → ℝ)
(y : Fin d → ℝ) : ℝ :=
∑ k, branchNet σ (c k) (ξ k) (θ k) v * trunkNet σ (w k) (ζ k) y
/-- Theorem 2: the network `W₂ · σ(W₁ · v + b₁) + b₂` with `n` hidden units, `σ` applied
componentwise, `W₁ ∈ ℝ^{n×q}`, `b₁ ∈ ℝ^n`, `W₂ ∈ ℝ^{K×n}`, `b₂ ∈ ℝ^K`. -/
def shallowNet {n q K : ℕ} (σ : ℝ → ℝ) (W₁ : Matrix (Fin n) (Fin q) ℝ) (b₁ : Fin n → ℝ)
(W₂ : Matrix (Fin K) (Fin n) ℝ) (b₂ : Fin K → ℝ) (v : Fin q → ℝ) : Fin K → ℝ :=
W₂.mulVec (fun i => σ ((W₁.mulVec v) i + b₁ i)) + b₂
/-- The Euclidean norm `‖v‖₂ = (∑ v_i²)^{1/2}` on `ℝ^K` (Section 3, Theorem 2). -/
def eucNorm {K : ℕ} (v : Fin K → ℝ) : ℝ := Real.sqrt (∑ i, v i ^ 2)
/-! ### Activation functions (Theorem 1; Appendix A, Definition 1, Theorem 3) -/
/-- Theorem 1: `σ` is a polynomial function, `σ(x) = q(x)` for a real polynomial `q`. -/
def IsPolynomialFun (σ : ℝ → ℝ) : Prop :=
∃ q : Polynomial ℝ, ∀ x, σ x = q.eval x
/-- Appendix A, Definition 1 (TW): the linear combinations `∑_{i=1}^N c_i σ(λ_i x + θ_i)` are
dense, in the sup norm, in every `C([a,b])`. -/
def IsTauberWiener (σ : ℝ → ℝ) : Prop :=
∀ a b : ℝ, ∀ f : ℝ → ℝ, ContinuousOn f (Set.Icc a b) → ∀ ε > 0,
∃ N : ℕ, ∃ c lam θ : Fin N → ℝ, ∀ x ∈ Set.Icc a b, |f x - ∑ i, c i * σ (lam i * x + θ i)| < ε
/-- Appendix A, Theorem 3: `σ ∈ S'(ℝ)`, i.e. the distribution `φ ↦ ∫ σ φ` defined by `σ` on
compactly supported test functions extends to a continuous linear functional on the Schwartz
space. -/
def IsTemperedDistribution (σ : ℝ → ℝ) : Prop :=
∃ T : SchwartzMap ℝ ℝ →L[ℝ] ℝ, ∀ φ : SchwartzMap ℝ ℝ, HasCompactSupport (φ : ℝ → ℝ) →
T φ = ∫ x, σ x * φ x
/-! ### Compactness in `C(K)` (Appendix A, Definitions 3 and 4) -/
/-- Appendix A, Definition 3: `V` is uniformly bounded, `|f(x)| ≤ M` for all `f ∈ V`, `x ∈ K`. -/
def IsUniformlyBounded {K : Type*} (V : Set (K → ℝ)) : Prop :=
∃ M : ℝ, ∀ f ∈ V, ∀ x, |f x| ≤ M
/-- Appendix A, Definition 4: `V` is equicontinuous, for every `ε > 0` there is `δ > 0` with
`|f(x) - f(y)| < ε` for all `f ∈ V` and all `x, y` at distance `< δ`. -/
def IsEquicontinuousFamily {K : Type*} [PseudoMetricSpace K] (V : Set (K → ℝ)) : Prop :=
∀ ε > 0, ∃ δ > 0, ∀ f ∈ V, ∀ x y : K, dist x y < δ → |f x - f y| < ε
/-! ### Sensors and interpolation (Section 3, pp. 5-6) -/
open Classical in
/-- Section 3: the value at a real point `x` of a function `f ∈ C([a,b])` (`0` off `[a,b]`;
statements only evaluate on `[a,b]`). -/
def evalAt {a b : ℝ} {β : Type*} [TopologicalSpace β] [Zero β] (f : C(Set.Icc a b, β))
(x : ℝ) : β :=
if hx : x ∈ Set.Icc a b then f ⟨x, hx⟩ else 0
/-- Section 3, p. 6: the uniform sensors `x_j = a + j(b - a)/m`, `j = 0, 1, …, m`. -/
def sensor (a b : ℝ) (m j : ℕ) : ℝ := a + j * (b - a) / m
/-- Section 3, p. 6: the piecewise-linear interpolant
`u_m(x) = u(x_j) + (u(x_{j+1}) - u(x_j))/(x_{j+1} - x_j) · (x - x_j)` for `x_j ≤ x ≤ x_{j+1}`,
`j = 0, …, m-1`; the segment index of `x ∈ [a,b]` is `j = min(⌊(x-a)m/(b-a)⌋, m-1)`. -/
def interp (a b : ℝ) (m : ℕ) (u : ℝ → ℝ) (x : ℝ) : ℝ :=
let j : ℕ := min ⌊(x - a) * m / (b - a)⌋₊ (m - 1)
u (sensor a b m j) + (u (sensor a b m (j + 1)) - u (sensor a b m j)) /
(sensor a b m (j + 1) - sensor a b m j) * (x - sensor a b m j)
/-- Section 3, p. 6: `U_m = {L_m(u) | u ∈ V}`, the interpolants `u_m` of the functions of `V`,
as elements of `C([a,b])`. -/
def interpSet (a b : ℝ) (m : ℕ) (V : Set C(Set.Icc a b, ℝ)) : Set C(Set.Icc a b, ℝ) :=
{w | ∃ u ∈ V, ∀ x : Set.Icc a b, w x = interp a b m (evalAt u) x}
/-- Section 3, p. 6, and Lemma 7: `W = ⋃_{i ≥ 1} W_i` with `W_i = V ∪ U_i`. -/
def sensorHull (a b : ℝ) (V : Set C(Set.Icc a b, ℝ)) : Set C(Set.Icc a b, ℝ) :=
⋃ (i : ℕ) (_ : 1 ≤ i), (V ∪ interpSet a b i V)
/-- Theorem 2: the sensor values `[u(x_0), …, u(x_m)] ∈ ℝ^{m+1}`. -/
def sensorValues (a b : ℝ) (m : ℕ) (u : C(Set.Icc a b, ℝ)) : Fin (m + 1) → ℝ :=
fun j => evalAt u (sensor a b m j)
/-! ### The ODE operator (Section 3, eq. (3)) -/
/-- Section 3, eq. (3): on the set `D` of inputs, `G` is the solution operator of
`s' = g(s, u, x)`, `s(a) = s₀`, i.e. `(Gu)(x) = s₀ + ∫_a^x g((Gu)(t), u(t), t) dt` for
`x ∈ [a,b]`, the integrand being integrable on `[a,b]`. -/
def SolvesODE (a b : ℝ) {K : ℕ} (g : (Fin K → ℝ) → ℝ → ℝ → (Fin K → ℝ)) (s₀ : Fin K → ℝ)
(G : C(Set.Icc a b, ℝ) → C(Set.Icc a b, Fin K → ℝ)) (D : Set C(Set.Icc a b, ℝ)) : Prop :=
∀ u ∈ D, IntervalIntegrable (fun t => g (evalAt (G u) t) (evalAt u t) t) volume a b ∧
∀ x : Set.Icc a b, G u x = s₀ + ∫ t in a..(x : ℝ), g (evalAt (G u) t) (evalAt u t) t
/-- Section 3, p. 6: the set of values `{f(t) | f ∈ D, t ∈ [a,b]}` taken by a family of functions
on `[a,b]` (used for "on `G(W) × W`"). -/
def valueSet {a b : ℝ} {β : Type*} [TopologicalSpace β] (D : Set C(Set.Icc a b, β)) : Set β :=
{v | ∃ f ∈ D, ∃ t : Set.Icc a b, f t = v}
/-- Section 3, p. 6: `g(s, u, x)` is Lipschitz with constant `c` in `s` and in `u` for `s ∈ S`,
`u ∈ U`, `x ∈ [a,b]`: `‖g(s₁,u,x) - g(s₂,u,x)‖₂ ≤ c‖s₁ - s₂‖₂`,
`‖g(s,u₁,x) - g(s,u₂,x)‖₂ ≤ c|u₁ - u₂|`. -/
def IsLipschitzSU (a b : ℝ) {K : ℕ} (g : (Fin K → ℝ) → ℝ → ℝ → (Fin K → ℝ)) (c : ℝ)
(S : Set (Fin K → ℝ)) (U : Set ℝ) : Prop :=
(∀ s₁ ∈ S, ∀ s₂ ∈ S, ∀ r ∈ U, ∀ x ∈ Set.Icc a b,
eucNorm (g s₁ r x - g s₂ r x) ≤ c * eucNorm (s₁ - s₂)) ∧
(∀ s ∈ S, ∀ r₁ ∈ U, ∀ r₂ ∈ U, ∀ x ∈ Set.Icc a b,
eucNorm (g s r₁ x - g s r₂ x) ≤ c * |r₁ - r₂|)
end DeepONetUniversal
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Branch network . For natural numbers (number of hidden units) and (input dimension), an arbitrary function , coefficients , a weight array , biases , and an input vector , this is the real number
No regularity is assumed of . If the value is . If the inner sum is empty, so the value is .
Trunk network . For , an arbitrary , a weight vector , a bias and a point , this is
This is a single unit, not a sum of units. If the value is .
Stacked operator network . The parameters are:
- natural numbers ;
- an arbitrary , the same function used in every branch and trunk;
- for each : coefficients , weights , biases , a trunk weight and a trunk bias ;
- inputs and .
The value is
All branches share the same width and input dimension . If the value is .
Shallow vector network . The parameters are natural numbers , an arbitrary , real matrices and , and vectors and . The network sends to the vector in
where is applied separately to each of the coordinates of . If the output is .
Euclidean norm . For and ,
This is when .
Polynomial activation . For , this asserts that there is a real polynomial with for every real . Constant functions, including the zero function, qualify.
Tauber–Wiener property . For (no regularity assumed), this asserts the following. For all real , every function that is continuous on , and every , there exist:
- some ;
- vectors ,
such that
Edge cases:
- The value is allowed; the sum is then .
- When the interval is empty and the condition holds vacuously.
- When only the single point must be approximated.
Tempered-distribution condition . For , this asserts that there is a continuous real-linear functional on the Schwartz space with
for every compactly supported . The integral is the Lebesgue integral. By convention it is set to whenever is not Lebesgue integrable; in that case the requirement for that is . No measurability or local integrability of is assumed. Nothing is required of on Schwartz functions without compact support beyond linearity and continuity.
Uniform boundedness . For an arbitrary set and a set of functions (not required to be continuous), this asserts that there is a real with for all and all . It holds trivially when is empty.
Equicontinuity . Let be a pseudometric space with distance , and let be a set of functions . The condition is that for every there is such that
The same works for all functions and all points, so this is uniform equicontinuity.
Evaluation at a real point . Let be real and let be a topological space with a distinguished element . For a continuous map and a real , define
Below, always denotes this zero extension of .
Sensors . For reals and natural numbers , define
Here is any natural number and is not restricted to . Division by zero is taken to give , so when every equals .
Piecewise-linear interpolant . Let be real, , arbitrary, and . The segment index is
where is the floor truncated at (negative numbers give ) and is truncated subtraction ( when ). With the sensors above, the interpolant is
Edge cases:
- Degenerate denominators. If , the quotient is by the division-by-zero convention, so . If (which happens when or ), the fraction is and .
- Case . Here and for every .
- Outside the interval. The formula is defined for every real . For below it uses segment , and for large it uses segment , extending the endpoint segments linearly.
- Right endpoint. At (with , ) the floor equals and the minimum selects .
Interpolated family . Let be real, , and let be a set of continuous functions . Then
where is the interpolant above applied to the zero extension of . The elements are by definition continuous functions on ; the set consists of those that agree on with the interpolant of some .
Sensor hull . For real and ,
No closure is taken.
Sensor values . For real, and , this is the vector
where is the zero extension of and are the sensors with the same . For this is the single value .
ODE solution operator . The data are:
- reals and ;
- a function , written ;
- an initial value ;
- a map from continuous functions to continuous functions ;
- a set .
The condition asserts that for every two things hold. First, the function is Lebesgue integrable on the interval between and , with tildes denoting zero extensions outside . Second, for every ,
In particular . Nothing is assumed about outside , and no differentiability or uniqueness is stated; only this integral identity is required. If is empty, or if (so is empty), the condition is vacuous or nearly so.
Value set . For real, a topological space and a set of continuous maps , this is the union of their ranges on :
Lipschitz condition . The data are reals , , a function , a real constant , a set , and a set . The condition is the conjunction of:
- for all , and ,
- for all , and ,
Here is the Euclidean norm defined above. The constant is not required to be nonnegative. With the inequalities can only hold when and each contain at most one point (or when , or is empty). If , or is empty, the condition holds vacuously.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.