Skip to content

feat(Mathlib/Geometry/Manifold): Riemannian metrics exist II#33714

Open
idontgetoutmuch wants to merge 87 commits intoleanprover-community:masterfrom
idontgetoutmuch:master
Open

feat(Mathlib/Geometry/Manifold): Riemannian metrics exist II#33714
idontgetoutmuch wants to merge 87 commits intoleanprover-community:masterfrom
idontgetoutmuch:master

Conversation

@idontgetoutmuch
Copy link
Copy Markdown
Collaborator

Supersedes #33519


Open in Gitpod

@github-actions github-actions bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label Jan 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 7, 2026

PR summary 0e708caf75

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Geometry.Manifold.ExistsRiemannianMetric (new file) 2319

Declarations diff

+ VectorSpaceAux
+ VectorSpaceAux.ext_iff
+ aux_tvs
+ contMDiff_totalSpace_weighted_sum_of_local_sections
+ evalAt
+ exists_riemannian_metric
+ finsum_image_eq_sum
+ g_bilin
+ g_bilin_aux
+ g_bilin_smooth_on_chart
+ g_bilin_symm_aux
+ g_global_bilin
+ g_global_bilin_aux
+ g_global_bilin_aux_support_finite
+ g_global_bilin_eq
+ g_global_bilin_smooth
+ g_nonneg
+ g_pos
+ inCoordinates_apply_eq₂_spec
+ inCoordinates_apply_eq₂_spec_symm
+ my_dist_triangle
+ my_eq_of_dist_eq_zero
+ riemannian_metric_pos_def
+ riemannian_metric_pos_def_aux
+ riemannian_metric_symm
+ riemannian_metric_symm_aux
+ riemannian_unit_ball_bounded
+ riemannian_unit_ball_bounded_aux
+ seminormOfBilinearForm
+ seminormOfBilinearForm_sub_comm
+ seminormOfBilinearForm_sub_self
+ tangentSpaceEquiv
+ withSeminormsOfBilinearForm
++++++++++ instance {x : B} (φ : E x →L[ℝ] E x →L[ℝ] ℝ) (hpos : ∀ v, 0 ≤ φ v v)

You can run this locally as follows
## summary with just the declaration names:
./scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@idontgetoutmuch idontgetoutmuch marked this pull request as ready for review January 8, 2026 09:56
@idontgetoutmuch
Copy link
Copy Markdown
Collaborator Author

idontgetoutmuch commented Jan 9, 2026

From #33519 (comment)

(2) It would be good to generalise this argument to arbitrary vector bundles. Mathematically, there should be no meaningful difference. Would you like help with that/what happens when you try to do so?

Yes please but I do use the fact that the trivialisation of the bundle of bilinear forms is essentially given by the trivialisation of the tangent bundle. Maybe this can be generalised but off the top of my head, I don't know how.

I would think the analogous fact is true in any vector bundle (and this would be a useful lemma to have, independently of this PR --- i.e., a good pre-requisite PR).

@grunweg do you mean generalising this?

/-
Overloading the use of π, let φ : π⁻¹(U) → U × ℝⁿ and ψ : π⁻¹(U) → U × (ℝⁿ ⊗ ℝⁿ →ₗ ℝ) be local
trivialisations of the tangent bundle and the bundle of bilinear forms respectively and
w ∈ π⁻¹(U) and (x, u) and (y, v) ∈ U × ℝⁿ then ψ(w)(u, v) = w(φ⁻¹(x, u), φ⁻¹(x, v))
-/
lemma trivializationAt_tangentSpace_bilinearForm_apply (x₀ x : B)
    (w : (TangentSpace (M := B) IB) x →L[ℝ] (TangentSpace (M := B) IB) x →L[ℝ] ℝ)
    (u v : EB)
    (hx : x ∈ (trivializationAt EB (TangentSpace (M := B) IB) x₀).baseSet) :
  (trivializationAt (EB →L[ℝ] EB →L[ℝ] ℝ)
                    (fun x ↦ (TangentSpace (M := B) IB) x →L[ℝ]
                             (TangentSpace (M := B) IB) x →L[ℝ]
                              ℝ) x₀).continuousLinearMapAt ℝ x w u v =
  w ((trivializationAt EB (TangentSpace (M := B) IB) x₀).symm x u)
    ((trivializationAt EB (TangentSpace (M := B) IB) x₀).symm x v)

Code here:

lemma trivializationAt_tangentSpace_bilinearForm_apply (x₀ x : B)

@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Jan 9, 2026

You know what your comment refers to - but this seems about right.

@idontgetoutmuch
Copy link
Copy Markdown
Collaborator Author

See also #28056

Copy link
Copy Markdown
Contributor

@grunweg grunweg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR; this result is sorely missing from mathlib.
I have two kinds of comments. The first one is that the code is not yet at mathlib's quality bar; it can be shortened significantly, for instance. I have made some example comments below. The second, higher-level, comment is that this result holds on any finite rank vector bundle --- hence should be proven in that generality. Would you like to attempt this generalisation also? As-is, this PR probably should not get merged.

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 21, 2026
@grunweg grunweg assigned grunweg and unassigned PatrickMassot Jan 21, 2026
@idontgetoutmuch
Copy link
Copy Markdown
Collaborator Author

idontgetoutmuch commented Jan 24, 2026

I have been thinking about the comment on generalisation. But can this be generalised? What would the statement of a general theorem be? Existence of an n-form on a manifold?

/--
Existence of a smooth Riemannian metric on a manifold.
-/
public noncomputable
def riemannian_metric_exists
    (f : SmoothPartitionOfUnity B IB B)
    (h_sub : f.IsSubordinate (fun x ↦ (extChartAt IB x).source)) :
    ContMDiffRiemannianMetric (IB := IB) (n := ∞) (F := EB)
     (E := TangentSpace (M := B) IB) :=
  { inner := g_global_bilin_1 f
    symm := by
      exact riemannian_metric_symm_1 f
    pos := riemannian_metric_pos_def_1 f h_sub
    isVonNBounded := riemannian_unit_ball_bounded_1 f h_sub
    contMDiff := (g_global_bilin_1_smooth f h_sub)
     }

Moreover the proof relies on inCoordinates_apply_eq₂.

@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Jan 24, 2026

You want to prove the existence of a Riemannian metric, on any vector bundle. (Let's say finite-dimensional for now.)

import Mathlib.Geometry.Manifold.VectorBundle.Riemannian

open Bundle ContDiff Manifold

-- Let E be a smooth vector bundle over a manifold E
variable
  {EB : Type*} [NormedAddCommGroup EB] [NormedSpace ℝ EB]
  {HB : Type*} [TopologicalSpace HB] {IB : ModelWithCorners ℝ EB HB} {n : WithTop ℕ∞}
  {B : Type*} [TopologicalSpace B] [ChartedSpace HB B]
  {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F]
  {E : B → Type*} [TopologicalSpace (TotalSpace F E)]
  [∀ x, TopologicalSpace (E x)] [∀ x, AddCommGroup (E x)] [∀ x, Module ℝ (E x)]
  [FiberBundle F E] [VectorBundle ℝ F E]
  [IsManifold IB n B] [ContMDiffVectorBundle n F E IB]

noncomputable def foo
    [∀ x, FiniteDimensional ℝ (E x)] [∀ x, ContinuousAdd (E x)] [∀ x, ContinuousSMul ℝ (E x)] :
    ContMDiffRiemannianMetric IB ∞ F E where
  inner := sorry
  symm b := sorry
  pos b := sorry
  isVonNBounded b := sorry
  contMDiff := sorry

I don't see the issues with inCoordinates_apply_eq; it is already stated and proven for general Hom bundles.

@idontgetoutmuch
Copy link
Copy Markdown
Collaborator Author

You want to prove the existence of a Riemannian metric, on any vector bundle. (Let's say finite-dimensional for now.)

import Mathlib.Geometry.Manifold.VectorBundle.Riemannian

open Bundle ContDiff Manifold

-- Let E be a smooth vector bundle over a manifold E
variable
  {EB : Type*} [NormedAddCommGroup EB] [NormedSpace ℝ EB]
  {HB : Type*} [TopologicalSpace HB] {IB : ModelWithCorners ℝ EB HB} {n : WithTop ℕ∞}
  {B : Type*} [TopologicalSpace B] [ChartedSpace HB B]
  {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F]
  {E : B → Type*} [TopologicalSpace (TotalSpace F E)]
  [∀ x, TopologicalSpace (E x)] [∀ x, AddCommGroup (E x)] [∀ x, Module ℝ (E x)]
  [FiberBundle F E] [VectorBundle ℝ F E]
  [IsManifold IB n B] [ContMDiffVectorBundle n F E IB]

noncomputable def foo
    [∀ x, FiniteDimensional ℝ (E x)] [∀ x, ContinuousAdd (E x)] [∀ x, ContinuousSMul ℝ (E x)] :
    ContMDiffRiemannianMetric IB ∞ F E where
  inner := sorry
  symm b := sorry
  pos b := sorry
  isVonNBounded b := sorry
  contMDiff := sorry

I don't see the issues with inCoordinates_apply_eq; it is already stated and proven for general Hom bundles.

Thank you. I have been barking up the wrong generalisation tree (auf dem Holzweg). That feels like it should be easy enough. Yes inCoordinates_apply_eq should cause no problems,

@idontgetoutmuch
Copy link
Copy Markdown
Collaborator Author

@grunweg thanks for all the feedback - I am working through generalising everything and then I will address your feedback (which may no longer apply if we are lucky).

  [∀ x, TopologicalSpace (E x)] [∀ x, AddCommGroup (E x)] [∀ x, Module ℝ (E x)]

is replaced by

  [∀ x, NormedAddCommGroup (E x)]
  [∀ x, NormedSpace ℝ (E x)]
Copy link
Copy Markdown
Contributor

@grunweg grunweg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments about style and golfing --- it's making good progress!

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 21, 2026
@idontgetoutmuch idontgetoutmuch removed the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 28, 2026
@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 28, 2026
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Feb 28, 2026

(I haven't gone over all your commits yet. I will do so soon.)

@idontgetoutmuch idontgetoutmuch removed the awaiting-author A reviewer has asked the author a question or requested changes. label Mar 1, 2026
@mathlib-triage mathlib-triage bot assigned sgouezel and ocfnash and unassigned grunweg Mar 19, 2026
@sgouezel sgouezel removed their assignment Mar 27, 2026
Copy link
Copy Markdown
Collaborator

@Rida-Hamadani Rida-Hamadani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this! This PR needs some work before making it to mathlib, here are some comments:


variable
[∀ x, NormedSpace ℝ (E x)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the other variables to this section, and also don't break lines immediately after the keyword variable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what you mean here. If I move the other global(?) variables into this section then they are not visible in the other sections. I have not broken lines by doing this

variable {B : Type*}
  {E : B → Type*}
  [∀ x, NormedAddCommGroup (E x)]

section tangentSpaceEquiv

variable [∀ x, NormedSpace ℝ (E x)]

Maybe there is a formatter for Lean to avoid problems like this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is that
instead of

variable
  [∀ x, NormedSpace ℝ (E x)]

it must be:

variable [∀ x, NormedSpace ℝ (E x)]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That bit is done :-)

Comment on lines +28 to +31
structure VectorSpaceAux
(x : B) (φ : E x →L[ℝ] E x →L[ℝ] ℝ) (hpos : ∀ v, 0 ≤ φ v v)
(hsymm : ∀ u v, φ u v = φ v u) (hdef : ∀ v, φ v v = 0 → v = 0) where
val : E x
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what does this structure do? Preferably as a doc comment.

{HB : Type*} [TopologicalSpace HB]
{F : Type*} [NormedAddCommGroup F] [TopologicalSpace (TotalSpace F E)]

noncomputable section section1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this section or remove the name entirely?

Suggested change
noncomputable section section1
noncomputable section

Comment on lines +450 to +453
lemma g_bilin_1_smooth_on_chart (i : B) :
ContMDiffOn IB (IB.prod 𝓘(ℝ, F →L[ℝ] F →L[ℝ] ℝ)) ∞
(g_bilin_1 (F := F) (E := E) i)
((trivializationAt F E i).baseSet ∩ (chartAt HB i).source) := by
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain a bit what the proof strategy here is? Why do you need this lemma? It is a bit unclear at the moment.

Copy link
Copy Markdown
Collaborator Author

@idontgetoutmuch idontgetoutmuch Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that there are two equivalent ways of defining a bilinear positive definite form: 1) pull back the inner product on $\mathbb{R}^n$ via the inverse trivialisation 2) push forward vectors and then apply the inner product on $\mathbb{R}^n$.

It turns out that using (1) makes proving smoothness straightforward and g_bilin_1_smooth_on_chart proves that locally g_bilini_1 is smooth (the trick is to make the set on which this is true small enough hence the intersection ((trivializationAt F E i).baseSet ∩ (chartAt HB i).source)). This can then be used to prove global smoothness via a partition of unity.

However it is not so clear (to me at any rate) how one uses (1) to prove positive definiteness. This is where (2) comes in. With this definition, it is straightforward to prove positivity, definiteness and symmetry.

I then prove that the two definitions are equal which allows me to prove that (1) is symmetric positive and definite.

But one is still not done. Mathlib's definition requires von Neumann boundedness which is true for finite dimensional manifolds.

I should add a lot of the code, and you comment tangentially (pun intended) about this, is to do with the fact that we have two norms and Mathlib via type classes only allows one so I created a structure VectorSpaceAux with its own norm and showed that they are equivalent (generate the same topology). It is well known that all norms on finite dimensional metric spaces are equivalent but it seems Mathlib does things differently.

Here's a bit more detail:

Mathlib's type class system doesn't support having multiple norm structures on the same type.
As the mathlib documentation states (Analysis.NormedSpace.FiniteDimension):

"The fact that all norms are equivalent is not written explicitly, as it would mean having
two norms on a single space, which is not the way type classes work. However, if one has a
finite-dimensional vector space E with a norm, and a copy E' of this type with another
norm, then the identities from E to E' and from E' to E are continuous thanks to
LinearMap.continuous_of_finiteDimensional. This gives the desired norm equivalence."

See
https://leanprover-community.github.io/mathlib4_docs/Mathlib/Analysis/Normed/Module/FiniteDimension.html

What this description elides is that "this gives the desired norm equivalence" requires
creating this auxiliary type plus substantial additional work (see tangentSpaceEquiv,
withSeminormsOfBilinearForm, and aux_tvs) to establish the equivalence and derive the needed
WithSeminorms and IsVonNBounded properties.

In classical mathematics, "all norms on a finite-dimensional space are equivalent" is a
one-line citation. In Mathlib, making this work requires explicit construction and proof.

I did toy with the idea of a blog post on the whole proof but I wanted feedback on it first (for which I am very grateful) and I am now distracted with trying to proved that the exponential map on Lie algebras is smooth.

I fear I am in danger of writing a blog post here and will stop now but please ask anything if I have been insufficiently clear.

Comment on lines +352 to +355
def evalAt (b : B) (v w : E b) :
(E b →L[ℝ] (E b →L[ℝ] ℝ)) →+ ℝ where
toFun := fun f => (f.toFun v).toFun w
map_zero' := by simp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems out of scope of this file, can you move it to a different file? Perhaps a file related to ContinuousLinearMap? All lemmas related to this also need to be moved.

Comment on lines +402 to +403
letI h : (j : B) → (E b →L[ℝ] (E b →L[ℝ] ℝ)) := fun j ↦ (f j) b • g_bilin_2 F j b
letI h' x := f x b * ((g_bilin_2 F x b).toFun v).toFun v
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need to be let instead of letIs since this is not a definition.

@Rida-Hamadani Rida-Hamadani added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 1, 2026
idontgetoutmuch and others added 4 commits April 1, 2026 16:27
Co-authored-by: Rida Hamadani <mridahamadani@gmail.com>
Co-authored-by: Rida Hamadani <mridahamadani@gmail.com>
Co-authored-by: Rida Hamadani <mridahamadani@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author A reviewer has asked the author a question or requested changes. new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-differential-geometry Manifolds etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants