Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

VelocityGAN: velocity maps, the generated law, the generator loss (8) and the regularized-inversion objective (9)

Definition
Arxiv1809_10262_Basic

by Xeroth · Nov 25, 2026 · Mathlib 0df444a (Lean v4.33.1)

generative-adversarial-networksloss-functionsregularizationseismic-inversion

Objects of Sections III-B.1, III-C and III-D of Zhang and Lin, Data-driven Seismic Waveform Inversion: A Study on the Robustness and Generalization (arXiv:1809.10262v8).

  1. Velocity maps. A velocity map of width www and height hhh is an array of real pixel values v(i,j)v(i,j)v(i,j), 1≤i≤w1\le i\le w1≤i≤w, 1≤j≤h1\le j\le h1≤j≤h. Its L1L_1L1​ norm is ∥m∥1=∑i,j∣m(i,j)∣\|m\|_1=\sum_{i,j}|m(i,j)|∥m∥1​=∑i,j​∣m(i,j)∣ and its squared L2L_2L2​ norm is ∥m∥22=∑i,jm(i,j)2\|m\|_2^2=\sum_{i,j}m(i,j)^2∥m∥22​=∑i,j​m(i,j)2.
  2. Generated law. Seismic data ddd take values in a measurable space with distribution μ\muμ. A generator (inversion operator) ggg maps seismic data to velocity maps, and Pg\mathbb{P}_gPg​ is the distribution of g(d)g(d)g(d) for d∼μd\sim\mud∼μ, the image measure g#μg_\#\mug#​μ.
  3. Adversarial loss. For a discriminator DDD (a real function on velocity maps), the adversarial loss of ggg is −Ex~∼PgD(x~)=−∫D d(g#μ)-\mathbb{E}_{\tilde x\sim\mathbb{P}_g}D(\tilde x)=-\int D\,d(g_\#\mu)−Ex~∼Pg​​D(x~)=−∫Dd(g#​μ).
  4. Generator loss, eq. (8). For a training pair (m,d)(m,d)(m,d) with true map v=mv=mv=m and predicted map v~=g(d)\tilde v=g(d)v~=g(d),
Lg=−Ex~∼PgD(x~)+λ1w h∑i=1w∑j=1h∣v~(i,j)−v(i,j)∣+λ2w h∑i=1w∑j=1h(v~(i,j)−v(i,j))2.L_g=-\mathbb{E}_{\tilde x\sim\mathbb{P}_g}D(\tilde x)+\frac{\lambda_1}{w\,h}\sum_{i=1}^{w}\sum_{j=1}^{h}|\tilde v(i,j)-v(i,j)|+\frac{\lambda_2}{w\,h}\sum_{i=1}^{w}\sum_{j=1}^{h}(\tilde v(i,j)-v(i,j))^2 .Lg​=−Ex~∼Pg​​D(x~)+whλ1​​i=1∑w​j=1∑h​∣v~(i,j)−v(i,j)∣+whλ2​​i=1∑w​j=1∑h​(v~(i,j)−v(i,j))2.

Over NNN training pairs (mk,dk)(m_k,d_k)(mk​,dk​), the training objective is the mean 1N∑k=1NLg(mk,dk)\frac1N\sum_{k=1}^N L_g(m_k,d_k)N1​∑k=1N​Lg​(mk​,dk​). 5. Regularized-inversion objective, eq. (9).

Jλ1,λ2(g)=λ1∑k=1N∥mk−g(dk)∥1+λ2∑k=1N∥mk−g(dk)∥22−Ex~∼PgD(x~).J_{\lambda_1,\lambda_2}(g)=\lambda_1\sum_{k=1}^{N}\|m_k-g(d_k)\|_1+\lambda_2\sum_{k=1}^{N}\|m_k-g(d_k)\|_2^2-\mathbb{E}_{\tilde x\sim\mathbb{P}_g}D(\tilde x).Jλ1​,λ2​​(g)=λ1​k=1∑N​∥mk​−g(dk​)∥1​+λ2​k=1∑N​∥mk​−g(dk​)∥22​−Ex~∼Pg​​D(x~).

Formalization Note Pixels are indexed from 000. The paper writes eq. (8) for a single velocity map. Averaging it over the training pairs is the reading under which eq. (9) is a rewriting of eq. (8): the paper trains on mini-batches of pairs (Section IV-A.2) but never writes the training objective explicitly. Pg\mathbb{P}_gPg​ is the image of the seismic-data distribution under ggg. Lean's integral is 000 when DDD is not integrable and the image measure is 000 when ggg is not measurable; the statement excludes both by hypothesis.

Definition code
import Mathlib

/-!
Z. Zhang and Y. Lin, *Data-driven Seismic Waveform Inversion: A Study on the Robustness and
Generalization* (VelocityGAN), arXiv:1809.10262v8 (2018): the velocity maps of Section III-B.1,
the content losses and the WGAN-GP generator loss of Section III-C (eq. (8)), and the
regularized-inversion objective of Section III-D (eq. (9)).
-/

open MeasureTheory

noncomputable section

namespace Arxiv1809_10262

/-- Section III-B.1 and eq. (8): a velocity map of width `w` and height `h`, given by its pixel
values `v(i,j)`, `1 ≤ i ≤ w`, `1 ≤ j ≤ h` (indexed from `0` here). -/
abbrev VelocityMap (w h : ℕ) : Type := Fin w → Fin h → ℝ

/-- Eq. (9): the `L_1` norm `‖m‖_1 = ∑_{i,j} |m(i,j)|` of a velocity map. -/
def l1Norm {w h : ℕ} (m : VelocityMap w h) : ℝ := ∑ i, ∑ j, |m i j|

/-- Eq. (9): the squared `L_2` norm `‖m‖_2^2 = ∑_{i,j} m(i,j)^2` of a velocity map. -/
def sqL2Norm {w h : ℕ} (m : VelocityMap w h) : ℝ := ∑ i, ∑ j, m i j ^ 2

/-- Section III-C, after eq. (7): `ℙ_g`, the distribution of the velocity maps `g(d)` predicted by
the generator `g` when the seismic data `d` has distribution `μ`. -/
def generatedLaw {Dat : Type*} [MeasurableSpace Dat] {w h : ℕ} (μ : Measure Dat)
    (g : Dat → VelocityMap w h) : Measure (VelocityMap w h) :=
  μ.map g

/-- Section III-C, before eq. (8): the adversarial loss `-𝔼_{x̃ ∼ ℙ_g} D(x̃)` of the generator `g`
against the discriminator `D`. -/
def adversarialLoss {Dat : Type*} [MeasurableSpace Dat] {w h : ℕ} (μ : Measure Dat)
    (D : VelocityMap w h → ℝ) (g : Dat → VelocityMap w h) : ℝ :=
  -∫ x, D x ∂(generatedLaw μ g)

/-- Eq. (8): the generator loss
`L_g = -𝔼_{x̃∼ℙ_g} D(x̃) + λ₁/(w·h) ∑_{i,j} |ṽ(i,j) - v(i,j)| + λ₂/(w·h) ∑_{i,j} (ṽ(i,j) - v(i,j))^2`
for one training pair `(m, d)`, with true map `v = m` and predicted map `ṽ = g(d)`. -/
def generatorLoss {Dat : Type*} [MeasurableSpace Dat] {w h : ℕ} (lam1 lam2 : ℝ)
    (μ : Measure Dat) (D : VelocityMap w h → ℝ) (m : VelocityMap w h) (d : Dat)
    (g : Dat → VelocityMap w h) : ℝ :=
  adversarialLoss μ D g + lam1 / ((w : ℝ) * h) * ∑ i, ∑ j, |g d i j - m i j| +
    lam2 / ((w : ℝ) * h) * ∑ i, ∑ j, (g d i j - m i j) ^ 2

/-- Eq. (8) over the training set (Sections III-C and IV-A.2): the generator loss of eq. (8)
averaged over the `N` training pairs `(m_k, d_k)`, as a function of the generator `g`. -/
def meanGeneratorLoss {Dat : Type*} [MeasurableSpace Dat] {w h N : ℕ} (lam1 lam2 : ℝ)
    (μ : Measure Dat) (D : VelocityMap w h → ℝ) (m : Fin N → VelocityMap w h) (d : Fin N → Dat)
    (g : Dat → VelocityMap w h) : ℝ :=
  (1 / (N : ℝ)) * ∑ k, generatorLoss lam1 lam2 μ D (m k) (d k) g

/-- Eq. (9): the regularized-inversion objective
`λ₁ ∑_{k=1}^N ‖m_k - g(d_k)‖_1 + λ₂ ∑_{k=1}^N ‖m_k - g(d_k)‖_2^2 - 𝔼_{x̃∼ℙ_g} D(x̃)`
of the inversion operator `g` on the `N` pairs `(m_k, d_k)` of velocity maps and seismic data. -/
def regularizedInversionObjective {Dat : Type*} [MeasurableSpace Dat] {w h N : ℕ}
    (lam1 lam2 : ℝ) (μ : Measure Dat) (D : VelocityMap w h → ℝ) (m : Fin N → VelocityMap w h)
    (d : Fin N → Dat) (g : Dat → VelocityMap w h) : ℝ :=
  lam1 * ∑ k, l1Norm (m k - g (d k)) + lam2 * ∑ k, sqL2Norm (m k - g (d k)) +
    adversarialLoss μ D g

end Arxiv1809_10262
Source
Z. Zhang and Y. Lin, Data-driven Seismic Waveform Inversion: A Study on the Robustness and Generalization, arXiv:1809.10262v8, Section III-B.1 (velocity maps), Section III-C (eqs. (7)-(8), generated law and generator loss), Section III-D (eq. (9))
Read-back

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

Setting and the velocity-map type. Fix natural numbers www (width) and hhh (height). A velocity map of size w×hw \times hw×h is any real-valued array

m:{0,…,w−1}×{0,…,h−1}→R,(i,j)↦m(i,j).m : \{0,\dots,w-1\} \times \{0,\dots,h-1\} \to \mathbb{R}, \qquad (i,j) \mapsto m(i,j).m:{0,…,w−1}×{0,…,h−1}→R,(i,j)↦m(i,j).

No range restriction is imposed: entries may be negative or zero. w=0w = 0w=0 and h=0h = 0h=0 are allowed. In those cases the index set is empty and there is exactly one (empty) velocity map. Velocity maps are added and subtracted entrywise. They carry the product σ-algebra built from the Borel σ-algebra on R\mathbb{R}R. Throughout, D\mathcal{D}D denotes an arbitrary type (the "seismic data" space) equipped with an arbitrary σ-algebra. No topology, metric or other structure on D\mathcal{D}D is assumed.

L1L_1L1​ norm. For a velocity map mmm of size w×hw \times hw×h,

∥m∥1=∑i=0w−1∑j=0h−1∣m(i,j)∣.\|m\|_1 = \sum_{i=0}^{w-1} \sum_{j=0}^{h-1} |m(i,j)|.∥m∥1​=i=0∑w−1​j=0∑h−1​∣m(i,j)∣.

This is 000 when w=0w = 0w=0 or h=0h = 0h=0 (empty sum).

Squared L2L_2L2​ norm. For a velocity map mmm of size w×hw \times hw×h,

∥m∥22=∑i=0w−1∑j=0h−1m(i,j)2.\|m\|_2^2 = \sum_{i=0}^{w-1} \sum_{j=0}^{h-1} m(i,j)^2.∥m∥22​=i=0∑w−1​j=0∑h−1​m(i,j)2.

This is 000 when w=0w = 0w=0 or h=0h = 0h=0.

Generated law Pg\mathbb{P}_gPg​. The inputs are:

  • an arbitrary measure μ\muμ on D\mathcal{D}D, which need not be a probability measure and may be infinite or zero;
  • an arbitrary function g:D→{velocity maps of size w×h}g : \mathcal{D} \to \{\text{velocity maps of size } w \times h\}g:D→{velocity maps of size w×h}, the "generator".

The output is the pushforward measure

Pg=g#μ,Pg(A)=μ(g−1(A))\mathbb{P}_g = g_{\#}\mu, \qquad \mathbb{P}_g(A) = \mu(g^{-1}(A))Pg​=g#​μ,Pg​(A)=μ(g−1(A))

on velocity maps. Edge case: by the convention used, if ggg is not almost-everywhere measurable with respect to μ\muμ, then Pg\mathbb{P}_gPg​ is defined to be the zero measure. Pg\mathbb{P}_gPg​ has the same total mass as μ\muμ (when ggg is a.e. measurable), so it is a probability measure only if μ\muμ is.

Adversarial loss. The inputs are μ\muμ and ggg as above, plus an arbitrary function DDD from velocity maps to R\mathbb{R}R (the "discriminator"). No Lipschitz, continuity, measurability or boundedness condition is placed on DDD. The output is the real number

Ladv(μ,D,g)=−∫D(x) dPg(x).\mathcal{L}_{\mathrm{adv}}(\mu, D, g) = -\int D(x)\, d\mathbb{P}_g(x).Ladv​(μ,D,g)=−∫D(x)dPg​(x).

This is a Bochner integral with these conventions:

  • If DDD is not integrable with respect to Pg\mathbb{P}_gPg​ (including when it is not suitably measurable), the integral is defined to be 000, so the loss is 000.
  • If ggg is not a.e. measurable, Pg=0\mathbb{P}_g = 0Pg​=0 and the loss is again 000.

It is an expectation −Ex~∼PgD(x~)-\mathbb{E}_{\tilde x \sim \mathbb{P}_g} D(\tilde x)−Ex~∼Pg​​D(x~) only when μ\muμ is a probability measure.

Generator loss for one pair. The inputs are:

  • arbitrary real numbers λ1,λ2\lambda_1, \lambda_2λ1​,λ2​, with no sign restriction, so they may be negative or zero;
  • μ\muμ, DDD and ggg as above;
  • one velocity map mmm (the "true map");
  • one data point d∈Dd \in \mathcal{D}d∈D.

Write v~=g(d)\tilde v = g(d)v~=g(d). The output is

Lg(m,d)=−∫D dPg  +  λ1w h∑i=0w−1∑j=0h−1∣v~(i,j)−m(i,j)∣  +  λ2w h∑i=0w−1∑j=0h−1(v~(i,j)−m(i,j))2.L_g(m, d) = -\int D \, d\mathbb{P}_g \;+\; \frac{\lambda_1}{w\,h} \sum_{i=0}^{w-1}\sum_{j=0}^{h-1} |\tilde v(i,j) - m(i,j)| \;+\; \frac{\lambda_2}{w\,h} \sum_{i=0}^{w-1}\sum_{j=0}^{h-1} (\tilde v(i,j) - m(i,j))^2 .Lg​(m,d)=−∫DdPg​+whλ1​​i=0∑w−1​j=0∑h−1​∣v~(i,j)−m(i,j)∣+whλ2​​i=0∑w−1​j=0∑h−1​(v~(i,j)−m(i,j))2.

Points to note:

  • The adversarial term is the global quantity Ladv(μ,D,g)\mathcal{L}_{\mathrm{adv}}(\mu, D, g)Ladv​(μ,D,g). It does not depend on the particular pair (m,d)(m, d)(m,d), and the data point ddd is not tied to μ\muμ in any way.
  • Division follows the convention x/0=0x/0 = 0x/0=0. If w=0w = 0w=0 or h=0h = 0h=0, the coefficients λ1/(wh)\lambda_1/(wh)λ1​/(wh) and λ2/(wh)\lambda_2/(wh)λ2​/(wh) are 000 (and the sums are empty), so Lg(m,d)L_g(m,d)Lg​(m,d) reduces to the adversarial term.
  • There are no further terms. In particular, there is no gradient-penalty term involving DDD.

Mean generator loss over a training set. The inputs are:

  • λ1,λ2,μ,D,g\lambda_1, \lambda_2, \mu, D, gλ1​,λ2​,μ,D,g as above;
  • a natural number NNN;
  • velocity maps m0,…,mN−1m_0, \dots, m_{N-1}m0​,…,mN−1​;
  • data points d0,…,dN−1∈Dd_0, \dots, d_{N-1} \in \mathcal{D}d0​,…,dN−1​∈D.

The output is

L‾g=1N∑k=0N−1Lg(mk,dk),\overline{L}_g = \frac{1}{N} \sum_{k=0}^{N-1} L_g(m_k, d_k),Lg​=N1​k=0∑N−1​Lg​(mk​,dk​),

with LgL_gLg​ the one-pair generator loss above. Because each summand contains the same adversarial term, for N≥1N \ge 1N≥1 this equals

−∫D dPg+1N∑k[λ1wh∥g(dk)−mk∥1+λ2wh∥g(dk)−mk∥22].-\int D\, d\mathbb{P}_g + \frac{1}{N}\sum_{k} \Big[\frac{\lambda_1}{wh}\|g(d_k) - m_k\|_1 + \frac{\lambda_2}{wh}\|g(d_k) - m_k\|_2^2\Big].−∫DdPg​+N1​k∑​[whλ1​​∥g(dk​)−mk​∥1​+whλ2​​∥g(dk​)−mk​∥22​].

If N=0N = 0N=0, then 1/N1/N1/N is taken to be 000 and the whole quantity is 000, including the adversarial term.

Regularized-inversion objective. The inputs are the same as for the mean generator loss: λ1,λ2∈R\lambda_1, \lambda_2 \in \mathbb{R}λ1​,λ2​∈R arbitrary, μ\muμ, DDD, ggg, NNN, and pairs (mk,dk)k=0N−1(m_k, d_k)_{k=0}^{N-1}(mk​,dk​)k=0N−1​. The output is

J(g)=λ1∑k=0N−1∥mk−g(dk)∥1  +  λ2∑k=0N−1∥mk−g(dk)∥22  −  ∫D dPg.J(g) = \lambda_1 \sum_{k=0}^{N-1} \|m_k - g(d_k)\|_1 \;+\; \lambda_2 \sum_{k=0}^{N-1} \|m_k - g(d_k)\|_2^2 \;-\; \int D \, d\mathbb{P}_g .J(g)=λ1​k=0∑N−1​∥mk​−g(dk​)∥1​+λ2​k=0∑N−1​∥mk​−g(dk​)∥22​−∫DdPg​.

Here mk−g(dk)m_k - g(d_k)mk​−g(dk​) is the entrywise difference of velocity maps, and ∥⋅∥1\|\cdot\|_1∥⋅∥1​, ∥⋅∥22\|\cdot\|_2^2∥⋅∥22​ are the unnormalized sums defined above. Points to note:

  • The sums over kkk and over pixels are not divided by NNN or by w hw\,hwh.
  • The adversarial term appears exactly once, with the same integral conventions as above: it is 000 if DDD is not Pg\mathbb{P}_gPg​-integrable or ggg is not a.e. measurable.
  • If N=0N = 0N=0, then J(g)=−∫D dPgJ(g) = -\int D\, d\mathbb{P}_gJ(g)=−∫DdPg​.
  • No constraints are placed on λ1\lambda_1λ1​, λ2\lambda_2λ2​, μ\muμ, DDD or ggg.
  • This is only a definition of a real number. No minimization, optimality or other property is asserted.
Human review
  • Endorsed by Shuze Chen · Nov 25, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 25, 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