Data and latent metric measure spaces, couplings and alignment objectives
DefinitionIdentifiableAlignment_BasicObjects of Sections 2–4 and Appendices A–B of Syrota, Lopez i Serrano, Franck and Hauberg (2026).
- Manifolds. Every manifold is a smooth manifold of dimension , possibly with smooth boundary (modelled on the half-space ), with a smooth Riemannian metric ; its distance is the Riemannian (shortest-path) distance , and it carries its Borel -algebra. denotes the Riemannian inner product on .
- Data and latent mm-spaces (H1, H2). The data manifold is compact and connected, and is a probability measure with a smooth positive density: with . A model is a diffeomorphism such that the Riemannian metric of the latent space is the pullback , i.e. ; the latent distance is the Riemannian distance of this metric and . The alignment map is (Definition 2.1).
- Isomorphisms and symmetries. is an isomorphism of mm-spaces if it is a distance-preserving bijection with . A symmetry of is an isomorphism of the space with itself. C1 (symmetry breaking): the identity is the only symmetry of .
- Couplings and objectives. is the set of measures on with marginals ; is the coupling induced by . The Gromov–Wasserstein objective is (eq. 2).
- LDDs. The local distance distribution of is , the distribution function of , . for laws on , . The LDD-LP cost is , (eq. 3), and (eq. 4). C2 (distinguishable points): the collision set is -null.
- Samples. The empirical distribution of is . Weak convergence means for all bounded continuous . The fitting objective is .
- Quantitative objects (Appendix B.3). ; the margin (Definition 4.3); the Lipschitz condition for (eq. 11); the LDD estimation error .
- Densities (Proposition 3.2). is the set of smooth positive functions, the associated measure, and the set of for which . in the Whitney topology if, in every chart, every derivative of converges uniformly on compact subsets of the chart image to that of (Definition A.23).
Formalization Note The data manifold is an abstract compact connected Riemannian manifold rather than a submanifold of ; by the Nash embedding theorem the two settings describe the same metric measure spaces, and none of the statements refers to the ambient space. The reference measure is taken to be the -dimensional Hausdorff measure of the Riemannian distance, which is a positive constant (depending only on ) times the Riemannian volume; this changes neither "has a smooth positive density" nor any automorphism group. All costs are valued in . The margin is used only for .
import Mathlib
/-!
Syrota, Lopez i Serrano, Franck and Hauberg, *Identifiable alignment of unpaired representations*,
arXiv:2611.11460v1 (2026): the data and latent metric measure spaces of Section 2 (hypotheses H1,
H2, Definition 2.1), the symmetry-breaking and distinguishable-points conditions C1 and C2 of
Sections 3 and 4.1, the Gromov--Wasserstein, LDD-LP and fused objectives (equations (2), (3), (4)),
the margin (Definition 4.3, eq. (5)), the growth bound of eq. (11), and the Whitney topology on densities (Appendix A, Definition A.23).
Manifolds are smooth, of dimension `d ≥ 1`, possibly with boundary, modelled on the Euclidean
half-space `𝓡∂ d`; their distance is the Riemannian distance (`IsRiemannianManifold`).
-/
open MeasureTheory Set Filter Topology Bundle
open scoped ENNReal ContDiff Manifold
noncomputable section
namespace IdentifiableAlignment
section MetricMeasure
variable {X Y : Type*} [MetricSpace X] [MeasurableSpace X] [MetricSpace Y] [MeasurableSpace Y]
/-- Appendix A, Definition A.9: `T` is an isomorphism of the mm-spaces `(X, d_X, μ)` and
`(Y, d_Y, ν)`: a distance-preserving bijection with `T_# μ = ν`. -/
def IsMMIso (μ : Measure X) (ν : Measure Y) (T : X → Y) : Prop :=
Function.Bijective T ∧ Isometry T ∧ μ.map T = ν
/-- Section 3 (p. 4) and Definition A.9: a symmetry of `(X, d_X, μ)`, i.e. an element of
`Aut(X, d_X, μ)`: a distance-preserving bijection of `X` that preserves `μ`. -/
def IsSymmetry (μ : Measure X) (S : X → X) : Prop :=
IsMMIso μ μ S
/-- Condition C1 (symmetry breaking, Section 3, p. 5): the identity is the only symmetry. -/
def SymmetryBreaking (μ : Measure X) : Prop :=
∀ S : X → X, IsSymmetry μ S → S = id
/-- Section 4 (p. 5) and Appendix A, Definition A.18: the couplings `Π(μ, ν)`, the measures on
`X × Y` with marginals `μ` and `ν`. -/
def couplings {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] (μ : Measure X)
(ν : Measure Y) : Set (Measure (X × Y)) :=
{η | η.map Prod.fst = μ ∧ η.map Prod.snd = ν}
/-- `η` is an optimal coupling of the problem `min_{η ∈ Π(μ, ν)} J(η)`. -/
def IsOptimalCoupling (J : Measure (X × Y) → ℝ≥0∞) (μ : Measure X) (ν : Measure Y)
(η : Measure (X × Y)) : Prop :=
η ∈ couplings μ ν ∧ ∀ η' ∈ couplings μ ν, J η ≤ J η'
/-- Section 4 (p. 5): the coupling `(id × T)_# μ` induced by a map `T`. -/
def inducedCoupling (μ : Measure X) (T : X → Y) : Measure (X × Y) :=
μ.map (fun x => (x, T x))
/-- Equation (2), Section 4, p. 5: the Gromov--Wasserstein objective
`J_GW(η) = ∬ |d_X(x, x') - d_Y(y, y')|² dη(x, y) dη(x', y')`. -/
def gwCost (η : Measure (X × Y)) : ℝ≥0∞ :=
∫⁻ p, ∫⁻ q, ENNReal.ofReal ((dist p.1 q.1 - dist p.2 q.2) ^ 2) ∂η ∂η
/-- Section 4.1, p. 6: the local distance distribution (LDD) `Φ(x, r) = μ(B̄(x, r))`. -/
def ldd (μ : Measure X) (x : X) (r : ℝ) : ℝ :=
(μ (Metric.closedBall x r)).toReal
/-- The law of `d_X(x, x')` for `x' ∼ μ`; its distribution function is `ldd μ x`. -/
def distLaw (μ : Measure X) (x : X) : Measure ℝ :=
μ.map (fun y => dist x y)
/-- The squared quadratic Wasserstein distance between two laws on `ℝ`,
`W₂²(α, β) = inf_{γ ∈ Π(α, β)} ∫ (s - s')² dγ(s, s')`. -/
def w2sq (α β : Measure ℝ) : ℝ≥0∞ :=
⨅ γ ∈ couplings α β, ∫⁻ p, ENNReal.ofReal ((p.1 - p.2) ^ 2) ∂γ
/-- The quadratic Wasserstein distance `W₂` between two laws on `ℝ`. -/
def w2 (α β : Measure ℝ) : ℝ≥0∞ :=
w2sq α β ^ (1 / 2 : ℝ)
/-- Equation (3), Section 4.1, p. 6: the LDD-LP cost `c(x, y) = W₂²(Φ_X(x, ·), Φ_Y(y, ·))`, where
`Φ_X` and `Φ_Y` are the LDDs of `μ` and `ν`. -/
def lddCost (μ : Measure X) (ν : Measure Y) (x : X) (y : Y) : ℝ≥0∞ :=
w2sq (distLaw μ x) (distLaw ν y)
/-- Equation (3), Section 4.1, p. 6: the LDD-LP objective `J_LDD(η) = ∫ c dη`, with the LDDs of
`μ` and `ν`. -/
def lddLP (μ : Measure X) (ν : Measure Y) (η : Measure (X × Y)) : ℝ≥0∞ :=
∫⁻ p, lddCost μ ν p.1 p.2 ∂η
/-- Equation (4), Section 4.1, p. 6: the fused objective `J_β = (1 - β) J_GW + β J_LDD`. -/
def fusedCost (β : ℝ) (μ : Measure X) (ν : Measure Y) (η : Measure (X × Y)) : ℝ≥0∞ :=
ENNReal.ofReal (1 - β) * gwCost η + ENNReal.ofReal β * lddLP μ ν η
/-- Condition C2, Section 4.1, p. 6: the collision set
`C = {x : Φ(x', ·) = Φ(x, ·) for some x' ≠ x}`. -/
def collisionSet (μ : Measure X) : Set X :=
{x | ∃ x', x' ≠ x ∧ ldd μ x' = ldd μ x}
/-- Condition C2 (distinguishable points, Section 4.1, p. 6): the collision set is `μ`-null. -/
def DistinguishablePoints (μ : Measure X) : Prop :=
μ (collisionSet μ) = 0
/-- Section 4.2, p. 7: the empirical distribution `(1/n) ∑ᵢ δ_{zᵢ}` of a sample `z₁, …, zₙ`. -/
def empMeasure {Z : Type*} [MeasurableSpace Z] {n : ℕ} (z : Fin n → Z) : Measure Z :=
(n : ℝ≥0∞)⁻¹ • ∑ i, Measure.dirac (z i)
/-- Weak convergence of measures: `∫ f dηₙ → ∫ f dη` for every bounded continuous `f`. -/
def WeakTendsto (ηs : ℕ → Measure X) (η : Measure X) : Prop :=
∀ f : BoundedContinuousFunction X ℝ, Tendsto (fun n => ∫ x, f x ∂(ηs n)) atTop (𝓝 (∫ x, f x ∂η))
/-- Proposition B.14 (iii), p. 28: the fitting objective `F_η(T) = ∫ d_Y(T(x), y)² dη(x, y)`. -/
def fitCost (η : Measure (X × Y)) (T : X → Y) : ℝ≥0∞ :=
∫⁻ p, ENNReal.ofReal (dist (T p.1) p.2 ^ 2) ∂η
/-- Proposition B.14 (iii), p. 28: `T` minimises `F_η` over the class `𝒯`. -/
def IsFitMinimizer (𝒯 : Set C(X, Y)) (η : Measure (X × Y)) (T : C(X, Y)) : Prop :=
T ∈ 𝒯 ∧ ∀ T' ∈ 𝒯, fitCost η T ≤ fitCost η T'
/-- Proposition B.15, p. 30: the Wasserstein distance `W₁(μ, ν) = inf_{γ ∈ Π(μ, ν)} ∫ d dγ`. -/
def w1 (μ ν : Measure X) : ℝ≥0∞ :=
⨅ γ ∈ couplings μ ν, ∫⁻ p, edist p.1 p.2 ∂γ
/-- The supremum distance `‖Φ(x, ·) - Φ(x', ·)‖_∞` between two LDDs. -/
def lddSupDist (μ : Measure X) (x x' : X) : ℝ :=
⨆ r : ℝ, |ldd μ x r - ldd μ x' r|
/-- Definition 4.3, eq. (5), p. 6: the margin
`m(t) = inf {‖Φ(x, ·) - Φ(x', ·)‖_∞ : d(x, x') ≥ t}` (used for `0 < t ≤ diam`). -/
def margin (μ : Measure X) (t : ℝ) : ℝ :=
⨅ p : {p : X × X // t ≤ dist p.1 p.2}, lddSupDist μ p.1.1 p.1.2
/-- Equation (11), Appendix B.3, p. 30: ball masses grow at rate at most `K`,
`|Φ(x, r) - Φ(x, r')| ≤ K |r - r'|` for all `x` and `r, r' ≥ 0`. -/
def IsLddLipschitz (μ : Measure X) (K : ℝ) : Prop :=
∀ x r r', 0 ≤ r → 0 ≤ r' → |ldd μ x r - ldd μ x r'| ≤ K * |r - r'|
/-- Appendix B.3, p. 30: the LDD estimation error
`δ = sup_x W₂(Φ̂_X(x, ·), Φ_X(x, ·)) + sup_y W₂(Φ̂_Y(y, ·), Φ_Y(y, ·))`, where `Φ_X, Φ̂_X` are the
LDDs of `μ, μhat` and `Φ_Y, Φ̂_Y` those of `ν, νhat`. -/
def lddEstError (μ μhat : Measure X) (ν νhat : Measure Y) : ℝ≥0∞ :=
(⨆ x, w2 (distLaw μhat x) (distLaw μ x)) + ⨆ y, w2 (distLaw νhat y) (distLaw ν y)
end MetricMeasure
section Riemannian
variable {d : ℕ} [NeZero d]
/-- The Riemannian inner product `g_z(v, w)` on the tangent space `T_z Z`. -/
def riemInner {Z : Type*} [TopologicalSpace Z] [ChartedSpace (EuclideanHalfSpace d) Z]
[IsManifold (𝓡∂ d) ∞ Z] [RiemannianBundle (fun z : Z => TangentSpace (𝓡∂ d) z)]
(z : Z) (v w : TangentSpace (𝓡∂ d) z) : ℝ :=
(RiemannianBundle.g (E := fun z : Z => TangentSpace (𝓡∂ d) z)).inner z v w
variable {Z Z' M : Type*}
[TopologicalSpace Z] [ChartedSpace (EuclideanHalfSpace d) Z] [IsManifold (𝓡∂ d) ∞ Z]
[RiemannianBundle (fun z : Z => TangentSpace (𝓡∂ d) z)]
[TopologicalSpace Z'] [ChartedSpace (EuclideanHalfSpace d) Z'] [IsManifold (𝓡∂ d) ∞ Z']
[TopologicalSpace M] [ChartedSpace (EuclideanHalfSpace d) M] [IsManifold (𝓡∂ d) ∞ M]
[RiemannianBundle (fun x : M => TangentSpace (𝓡∂ d) x)]
/-- Hypothesis H2 (model coordinates, Section 2, p. 3) and the pullback metric
`g_Z = f^* g^M` (Section 2, "Latent metric measure spaces", p. 4): `f : Z → M` is a diffeomorphism and the Riemannian metric of
the latent space `Z` is `g_Z(v, w) = g^M(df v, df w)`. -/
def IsModelCoordinates (f : Z ≃ₘ^∞⟮𝓡∂ d, 𝓡∂ d⟯ M) : Prop :=
∀ (z : Z) (v w : TangentSpace (𝓡∂ d) z),
riemInner z v w =
riemInner (f z) (mfderiv (𝓡∂ d) (𝓡∂ d) f z v) (mfderiv (𝓡∂ d) (𝓡∂ d) f z w)
/-- Definition 2.1, eq. (1), p. 3: the alignment map `A = f_b⁻¹ ∘ f_a : Z_a → Z_b`. -/
def alignMap (fa : Z ≃ₘ^∞⟮𝓡∂ d, 𝓡∂ d⟯ M) (fb : Z' ≃ₘ^∞⟮𝓡∂ d, 𝓡∂ d⟯ M) : Z → Z' :=
fb.symm ∘ fa
variable [MeasurableSpace Z] [MeasurableSpace M]
/-- Section 2, p. 4: the distribution of representations `P_a = (f_a⁻¹)_# P_M`. -/
def latentLaw (P : Measure M) (f : Z ≃ₘ^∞⟮𝓡∂ d, 𝓡∂ d⟯ M) : Measure Z :=
P.map f.symm
end Riemannian
section Densities
variable (d : ℕ) [NeZero d] (M : Type*) [MetricSpace M] [ChartedSpace (EuclideanHalfSpace d) M]
[MeasurableSpace M] [BorelSpace M]
/-- Hypothesis H1 (ii) and Proposition 3.2: the measure `ρ dVol_g` of a density `ρ`. The reference
measure is the `d`-dimensional Hausdorff measure of the Riemannian distance, which equals the
Riemannian volume `dVol_g` up to a positive factor depending only on `d`. -/
def densityMeasure {M : Type*} [MetricSpace M] [MeasurableSpace M] [BorelSpace M] (ρ : M → ℝ) :
Measure M :=
(μH[(d : ℝ)] : Measure M).withDensity (fun x => ENNReal.ofReal (ρ x))
/-- Proposition 3.2, p. 5: the smooth positive functions `C^∞_{>0}(M)`. -/
def smoothPosDensities : Set (M → ℝ) :=
{ρ | ContMDiff (𝓡∂ d) 𝓘(ℝ) ∞ ρ ∧ ∀ x, 0 < ρ x}
/-- Hypothesis H1 (ii), Section 2, p. 3: `P` has a smooth positive density on `M`. -/
def HasSmoothPosDensity {M : Type*} [MetricSpace M] [ChartedSpace (EuclideanHalfSpace d) M]
[MeasurableSpace M] [BorelSpace M] (P : Measure M) : Prop :=
∃ ρ ∈ smoothPosDensities d M, P = densityMeasure d ρ
/-- Proposition B.8, p. 23: `D_rigid`, the smooth positive densities `ρ` for which
`Aut(M, g, ρ dVol_g)` is trivial. -/
def rigidDensities : Set (M → ℝ) :=
{ρ | ρ ∈ smoothPosDensities d M ∧ SymmetryBreaking (densityMeasure d ρ)}
/-- Definition A.23, p. 20: convergence `ρₙ → ρ` in the Whitney `C^∞` topology of the compact
manifold `M`: in every chart, every derivative converges uniformly on every compact subset of the
chart's image. -/
def CinfTendsto {M : Type*} [MetricSpace M] [ChartedSpace (EuclideanHalfSpace d) M]
(ρs : ℕ → M → ℝ) (ρ : M → ℝ) : Prop :=
∀ (x : M) (k : ℕ) (K : Set (EuclideanSpace ℝ (Fin d))), IsCompact K →
K ⊆ (extChartAt (𝓡∂ d) x).target →
TendstoUniformlyOn
(fun n y => iteratedFDerivWithin ℝ k (ρs n ∘ (extChartAt (𝓡∂ d) x).symm)
(extChartAt (𝓡∂ d) x).target y)
(fun y => iteratedFDerivWithin ℝ k (ρ ∘ (extChartAt (𝓡∂ d) x).symm)
(extChartAt (𝓡∂ d) x).target y)
atTop K
end Densities
end IdentifiableAlignment
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Standing conventions (apply to every item below). Unless stated otherwise:
- are arbitrary metric spaces, with distances .
- Each carries an arbitrary σ-algebra. It is not assumed to be the Borel σ-algebra, so isometries, distance functions and closed balls need not be measurable.
- "Measure" means an arbitrary measure on that σ-algebra. It need not be finite, a probability measure, or nonzero.
- All integrals are lower Lebesgue integrals of -valued functions, with values in . They agree with the usual integral when the integrand is measurable.
- Arithmetic in uses .
- Pushforward convention. denotes the pushforward when is -almost-everywhere measurable. When is not, is by convention the zero measure.
Isomorphism of metric measure spaces. Let be a measure on , a measure on , and any map. is an mm-isomorphism from to when all three of the following hold:
- is a bijection.
- for all .
- , with the pushforward convention above.
By that convention, if is not -a.e. measurable, condition 3 says .
Symmetry. For a measure on , a map is a symmetry of when it is an mm-isomorphism from to . That is, is a distance-preserving bijection of with . If , every distance-preserving bijection of is a symmetry, since every pushforward of is .
Symmetry breaking (C1). A measure on is symmetry breaking when every symmetry of , in the sense just defined, equals the identity map of . For example, if , this says that has no distance-preserving bijection other than the identity.
Couplings. For measurable spaces (no metric needed) and measures on , on , the set consists of all measures on with the product σ-algebra such that
No normalisation is imposed. If , the set is empty.
Optimal coupling. Let be any function from measures on to . A measure is an optimal coupling for between and when:
- , and
- for every .
If on , every coupling is optimal. If , nothing is.
Induced coupling. For a measure on and any map , the induced coupling is
the pushforward of under . It is the zero measure if this map is not -a.e. measurable.
Gromov–Wasserstein objective. For a measure on ,
The inner integral is over and the outer over , both with respect to the same .
Local distance distribution. For a measure on , a point and any real ,
where . The extended real value is converted to a real number with , so a closed ball of infinite mass gets the value . Further edge cases:
- For the ball is empty and .
- If the ball is not measurable, here means its outer-measure value.
Distance law. For a measure on and , is the measure on (Borel σ-algebra) obtained by pushing forward under . It is the zero measure if this map is not -a.e. measurable.
Squared 2-Wasserstein distance on . For measures on ,
The infimum over an empty set is ; this happens, for example, when .
2-Wasserstein distance on . , computed in , with .
LDD-LP cost. For measures on , on and points , ,
It is defined through the distance laws, not through the functions .
LDD-LP objective. For a measure on ,
Here is not required to lie in .
Fused objective. For any real ,
where . Consequently:
- For the Gromov–Wasserstein term has coefficient .
- For the LDD term has coefficient .
- A zero coefficient kills even an infinite term.
Collision set. For a measure on ,
Equality is of the whole real-valued functions , which include the convention above.
Distinguishable points (C2). A measure on has distinguishable points when , using the outer measure if is not measurable.
Empirical measure. For a measurable space , and points ,
Repeated points are counted with multiplicity. For this is the zero measure, because and .
Weak convergence. A sequence of measures on converges weakly to a measure when, for every bounded continuous ,
The integrals are ordinary signed (Bochner) integrals, which by convention equal whenever is not integrable. This happens, for example, if is not measurable for the given σ-algebra, or if the measure is infinite and is not integrable.
Fitting objective. For a measure on and any map ,
Fit minimiser. Let be a set of continuous maps and let be a continuous map. is a fit minimiser over for when:
- , and
- for every .
1-Wasserstein distance. For measures on the same space ,
The infimum is if no coupling exists.
Sup-distance between LDDs. For a measure on and ,
This is a real-valued supremum over all real , including negative , where both terms are . By convention, if the set of values is unbounded above the supremum is . This can occur when is infinite but has finite, unbounded ball masses.
Margin. For a measure on and any real ,
This is a real-valued infimum with the following conventions and consequences:
- The infimum of the empty set is . So whenever no pair is at distance at least , e.g. larger than every distance in , or .
- For the diagonal pairs are admissible and contribute , so when .
- The definition places no restriction on .
Lipschitz growth of ball masses. For a measure on and a real , the condition is
is not required to be nonnegative. If , the condition can hold only when is empty.
LDD estimation error. For measures on and on ,
The suprema are taken in ; the supremum over an empty space is . Nothing relates to or to .
Riemannian inner product. Throughout the Riemannian items:
- is a natural number.
- is the Euclidean half-space.
- is a manifold modelled on , so it may have boundary.
- carries an assignment of an inner product to each tangent space . These declarations impose no smoothness or continuity of in , and no link to any metric on ; has no metric here.
The inner product is for and .
Model coordinates (H2). Let and both be manifolds modelled on , each with a fibrewise inner product , as above, and let be a diffeomorphism. The condition is that, for every and ,
where is the manifold derivative of at . The definition involves only the two inner-product fields, not any distance on or .
Alignment map. For diffeomorphisms and between manifolds modelled on , the alignment map is
Latent law. Let be as above, each with an arbitrary σ-algebra (not assumed Borel). For a measure on and a diffeomorphism , the latent law is
a measure on . It is the zero measure if is not -a.e. measurable.
Density measure. In the density items:
- .
- is a metric space with its Borel σ-algebra, together with an atlas of charts into (for the metric topology).
- No smoothness of the atlas, compactness, Riemannian structure, or relation between the metric and the charts is assumed.
For any function , the density measure is
where is the -dimensional Hausdorff measure of the metric of and , so negative values count as .
Smooth positive densities. The set consists of all such that:
- is with respect to the charts into , and
- for every .
Smooth positive density (H1 ii). A measure on has a smooth positive density when there exists with , i.e. . is not required to be finite or a probability measure.
Rigid densities. The set consists of those for which is symmetry breaking in the sense of C1. That is, the identity is the only bijection that:
- preserves the metric distance of , and
- satisfies , with the pushforward convention above.
convergence of densities. For each , let be the distinguished chart at of the given atlas (one chart per point, not all charts of the atlas), viewed as a map into , with image . A sequence converges to when the following holds for every , every and every compact with :
where:
- is the -th iterated derivative taken within the set , so derivatives are one-sided at boundary points.
- At any point where a function fails to be differentiable within , its derivative is by convention .
- Uniformity is in the operator norm on -linear maps.
- No smoothness of or , and no compactness of , is assumed.
- The condition is vacuous for .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.