Flow matching: marginal density, flux, and classical regularity
DefinitionFlowMatchingT1Let , represented as a finite product of real lines. For a measure on conditioning points, a conditional density , and a conditional velocity , define
Divergence is the sum of diagonal derivative coordinates. A probability density is a pointwise nonnegative, Lebesgue-integrable real function with integral one. The classical continuity-equation predicate requires spatial differentiability of the flux and time derivative at every spatial point and every .
The time and space regularity predicates each require integrability at the base point, local almost-everywhere strong measurability of integrands, almost-everywhere strong measurability of derivatives at the base point, and a common neighborhood on which almost every conditional function is differentiable with derivative norm bounded by one integrable function of . The derivative in time is scalar; the spatial derivative is a continuous linear map.
The density hypotheses require strict positivity, joint measurability in , normalization in for every , and integrability in for every , at every . Analytic hypotheses require time regularity of the density and spatial regularity of the conditional flux at interior times. Neither bundle assumes a marginal continuity equation or an interchange identity. A probability-measure assumption on is supplied separately in the theorems that need it.
Formalization Note. These are definitions and explicit sufficient analytic hypotheses. They impose no ODE-flow interpretation, and are defined for as well as positive dimensions. The definitions alone do not assert that the displayed integrals exist or that the denominator is positive; theorem hypotheses and conclusions supply those guarantees on their stated domains.
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.MeasureTheory.Integral.Prod
import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar
open MeasureTheory Filter
open scoped Topology
namespace FlowMatchingT1
abbrev Space (d : ℕ) := Fin d → ℝ
noncomputable def divergence {d : ℕ} (f : Space d → Space d) (x : Space d) : ℝ :=
∑ i, (fderiv ℝ f x (Pi.single i 1)) i
noncomputable def conditionalFlux {d : ℕ}
(ρ : ℝ → Space d → Space d → ℝ) (v : ℝ → Space d → Space d → Space d)
(t : ℝ) (x z : Space d) : Space d := ρ t x z • v t x z
noncomputable def marginalDensity {d : ℕ} (Q : Measure (Space d))
(ρ : ℝ → Space d → Space d → ℝ) (t : ℝ) (x : Space d) : ℝ :=
∫ z, ρ t x z ∂Q
noncomputable def marginalFlux {d : ℕ} (Q : Measure (Space d))
(ρ : ℝ → Space d → Space d → ℝ) (v : ℝ → Space d → Space d → Space d)
(t : ℝ) (x : Space d) : Space d := ∫ z, conditionalFlux ρ v t x z ∂Q
noncomputable def marginalVelocity {d : ℕ} (Q : Measure (Space d))
(ρ : ℝ → Space d → Space d → ℝ) (v : ℝ → Space d → Space d → Space d)
(t : ℝ) (x : Space d) : Space d :=
(marginalDensity Q ρ t x)⁻¹ • marginalFlux Q ρ v t x
def ProbabilityDensity {d : ℕ} (p : Space d → ℝ) : Prop :=
(∀ x, 0 ≤ p x) ∧ Integrable p volume ∧ (∫ x, p x) = 1
def ContinuityEquation {d : ℕ} (p : ℝ → Space d → ℝ)
(u : ℝ → Space d → Space d) : Prop :=
∀ t ∈ Set.Ioo (0 : ℝ) 1, ∀ x,
DifferentiableAt ℝ (fun y => p t y • u t y) x ∧
HasDerivAt (fun s => p s x) (-divergence (fun y => p t y • u t y) x) t
def TimeRegularAt {d : ℕ} (Q : Measure (Space d))
(f : ℝ → Space d → ℝ) (t : ℝ) : Prop :=
Integrable (f t) Q ∧
(∀ᶠ s in 𝓝 t, AEStronglyMeasurable (f s) Q) ∧
AEStronglyMeasurable (fun z => deriv (fun s => f s z) t) Q ∧
∃ N ∈ 𝓝 t, ∃ b : Space d → ℝ, Integrable b Q ∧
(∀ᵐ z ∂Q, ∀ s ∈ N, ‖deriv (fun r => f r z) s‖ ≤ b z) ∧
(∀ᵐ z ∂Q, ∀ s ∈ N, DifferentiableAt ℝ (fun r => f r z) s)
def SpaceRegularAt {d : ℕ} (Q : Measure (Space d))
(F : Space d → Space d → Space d) (x : Space d) : Prop :=
Integrable (F x) Q ∧
(∀ᶠ y in 𝓝 x, AEStronglyMeasurable (F y) Q) ∧
AEStronglyMeasurable (fun z => fderiv ℝ (fun y => F y z) x) Q ∧
∃ N ∈ 𝓝 x, ∃ b : Space d → ℝ, Integrable b Q ∧
(∀ᵐ z ∂Q, ∀ y ∈ N, ‖fderiv ℝ (fun w => F w z) y‖ ≤ b z) ∧
(∀ᵐ z ∂Q, ∀ y ∈ N, DifferentiableAt ℝ (fun w => F w z) y)
structure DensityHypotheses {d : ℕ} (Q : Measure (Space d))
(ρ : ℝ → Space d → Space d → ℝ) : Prop where
positive : ∀ t ∈ Set.Icc (0 : ℝ) 1, ∀ x z, 0 < ρ t x z
measurable : ∀ t ∈ Set.Icc (0 : ℝ) 1, Measurable (fun p : Space d × Space d => ρ t p.1 p.2)
normalized : ∀ t ∈ Set.Icc (0 : ℝ) 1, ∀ z, ProbabilityDensity (fun x => ρ t x z)
integrable : ∀ t ∈ Set.Icc (0 : ℝ) 1, ∀ x, Integrable (fun z => ρ t x z) Q
structure AnalyticHypotheses {d : ℕ} (Q : Measure (Space d))
(ρ : ℝ → Space d → Space d → ℝ) (v : ℝ → Space d → Space d → Space d) : Prop where
time_regular : ∀ t ∈ Set.Ioo (0 : ℝ) 1, ∀ x, TimeRegularAt Q (fun s z => ρ s x z) t
space_regular : ∀ t ∈ Set.Ioo (0 : ℝ) 1, ∀ x, SpaceRegularAt Q (conditionalFlux ρ v t) x
end FlowMatchingT1
Read-back
What the Lean code literally says, in plain math · gpt-6-astra
Space. For each natural number , including , is the real vector space of functions from to , with coordinatewise operations and its usual finite-product topology and measurable structure. Its norm is the maximum of the absolute values of its coordinates, with norm zero in dimension zero. For this space has exactly one element, the empty function.
divergence. For any natural number , any function , and any , where means the coordinate-function space with its maximum norm, define . Here has coordinate at and elsewhere, and is the real Fréchet derivative, interpreted as the zero continuous linear map when is not differentiable at . No differentiability assumption is imposed by this definition. When the sum is empty and the divergence is zero.
conditionalFlux. For any natural number , any functions and , any real , and any , define the conditional flux to be , using ordinary real scalar multiplication of coordinate vectors. There are no assumptions on positivity, measurability, or regularity, and no restriction on . Dimension zero is included, in which case the result is the unique vector.
marginalDensity. For any natural number , any measure on the standard Borel measurable space , any function , any real , and any , define . This is the real Bochner integral, whose value is defined to be zero when the integrand is not Bochner integrable. No finiteness or probability assumption on , or positivity, measurability, or integrability assumption on , is part of the definition. Dimension zero is included.
marginalFlux. For any natural number , any measure on the standard Borel measurable space , any functions and , any real , and any , define . The integral is the vector-valued Bochner integral, with zero vector as its value when the integrand is not Bochner integrable. No positivity, regularity, measurability, integrability, or probability assumptions are imposed. Dimension zero is included and gives the unique vector.
marginalVelocity. For any natural number , any measure on the standard Borel measurable space , any functions and , any real , and any , define . Both integrals are Bochner integrals, defined to be zero if their respective integrands are not integrable, and the real inverse of zero is defined to be zero. Consequently the resulting vector is zero whenever the scalar integral is zero, regardless of the vector integral. No assumption that the denominator is positive or nonzero, or that is a probability measure, is made. All real times and dimension zero are included.
ProbabilityDensity. For any natural number and any function , this predicate means the conjunction of pointwise nonnegativity for every , Bochner integrability of with respect to the canonical volume measure on the coordinate space , and . Canonical volume here is the product of the copies of real Lebesgue measure. Nonnegativity is required everywhere, rather than merely almost everywhere. When , volume is the unit mass on the unique point, so the predicate holds exactly when at that point is .
ContinuityEquation. For any natural number , any scalar function , and any vector function , this predicate says that for every real with and every , the function is real Fréchet differentiable at , and the function has real derivative at equal to , where is the th coordinate unit vector. The derivative assertions concern the functions on their full ambient real vector spaces. There are no requirements at , , or times outside the open interval, and no positivity, normalization, integrability, or separate differentiability requirements on or on the spatial dependence of . For , the spatial flux is the unique vector and the condition reduces to the real time derivative of at the unique spatial point being zero at every .
TimeRegularAt. For any natural number , any measure on , any function , and any real , this predicate means that is Bochner integrable with respect to ; there exists a neighborhood of on which every slice is almost everywhere strongly measurable with respect to ; the function is almost everywhere strongly measurable with respect to ; and there exist a set that contains an open neighborhood of and a Bochner-integrable real function on such that, for -almost every , for every , and, for -almost every , the full real function is differentiable at every . The two last almost-everywhere assertions may initially use different null exceptional sets, but each assertion uses a single exceptional set valid for all . The neighborhood for slice measurability need not equal , and need not itself be open. Almost everywhere strongly measurable means equal almost everywhere to a strongly measurable function. The derivative notation uses the total real derivative, whose value is zero wherever differentiability fails; actual differentiability on is separately imposed almost everywhere as stated. No pointwise nonnegativity of is separately required, though the bound forces almost everywhere since . There is no restriction on or requirement that be nonzero, finite, or a probability measure; the zero measure satisfies this predicate for every and . Dimension zero is included.
SpaceRegularAt. For any natural number , any measure on , any function , and any , this predicate means that is Bochner integrable with respect to ; there exists a neighborhood of on which every slice is almost everywhere strongly measurable with respect to ; the continuous-linear-map-valued function is almost everywhere strongly measurable with respect to ; and there exist a set containing an open neighborhood of and a Bochner-integrable real function on such that, for -almost every , for every , and, for -almost every , the function is real Fréchet differentiable at every . The norm on derivatives is the operator norm induced by the coordinate maximum norms. Each of the last two almost-everywhere assertions has an exceptional set independent of ; those two exceptional sets need not initially be identical. The neighborhood for slice measurability need not be , and need not itself be open. Almost everywhere strongly measurable means equal almost everywhere to a strongly measurable function. Fréchet derivatives are assigned the zero map at nondifferentiable points, while differentiability on is separately required almost everywhere. No global pointwise nonnegativity of is stipulated, although the bound implies its nonnegativity almost everywhere. No finiteness, nonzeroness, or probability condition on is imposed; the zero measure satisfies the predicate for every and . Dimension zero is included, and in that dimension the predicate holds for every , , and because all vector values and derivatives are zero.
DensityHypotheses. For any natural number , any measure on , and any function , this proposition consists of four requirements: for every real with and every , ; for every such , is measurable on the product Borel measurable space ; for every such and every , is everywhere nonnegative, is Bochner integrable with respect to canonical product Lebesgue volume, and has integral ; and for every such and every , is Bochner integrable with respect to . All spatial points and conditioning points are quantified pointwise, not almost everywhere. There are no conditions at times outside , no joint measurability requirement involving time, and no requirement that be a probability measure or a finite measure. Dimension zero is included: then at the unique pair of spatial points must equal for each , and the last requirement forces to have finite total mass.
AnalyticHypotheses. For any natural number , any measure on , and any functions and , this proposition requires the following for every and every . First, is Bochner integrable with respect to ; the slices are almost everywhere strongly measurable for every in some neighborhood of ; is almost everywhere strongly measurable; and there exist a neighborhood set of and an integrable real function of such that, almost everywhere in , for all , and, almost everywhere in , is differentiable at every . Second, writing , the vector function is Bochner integrable; the slices are almost everywhere strongly measurable for every in some neighborhood of ; is almost everywhere strongly measurable as a continuous-linear-map-valued function; and there exist a neighborhood set of and an integrable real function of such that, almost everywhere in , for all , and, almost everywhere in , is real Fréchet differentiable at every . Derivative norms are operator norms for the coordinate maximum norm; the scalar derivative uses absolute value. Almost everywhere strong measurability means agreement almost everywhere with a strongly measurable function. Neighborhood sets contain open neighborhoods and need not be open themselves; the measurability neighborhoods may differ from the derivative neighborhoods. Each displayed uniform almost-everywhere requirement has one null exceptional set valid throughout its neighborhood, and the choices of neighborhoods, bounds, and exceptional sets may depend on and . Both derivative operations return zero at points of nondifferentiability, with differentiability additionally required as specified. No conditions at the endpoints or outside , positivity, normalization, continuity equation, or probability assumption on are included. The zero measure makes all these requirements hold for arbitrary and . Dimension zero is included; its spatial requirements are automatic and its temporal requirements remain as stated on the one-point measured space.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.