Zulip Chat Archive
Stream: mathlib4
Topic: Hyperbolic space
Oliver Nash (Aug 07 2025 at 13:28):
In an experiment to see if I could use the lovely work of @Patrick Massot @Michael Rothgang @SΓ©bastien GouΓ«zel and others to say something about hyperbolic space, I came up with the following (for the two-dimensional case):
import Mathlib.Analysis.Complex.UpperhalfPlane.Metric
import Mathlib.Geometry.Manifold.Riemannian.Basic
-- import Mathlib.Geometry.Manifold.Riemannian.PathELength
-- import Mathlib.Geometry.Manifold.VectorBundle.Tangent
noncomputable section
namespace UpperHalfPlane
open Bundle
open scoped ContDiff ENNReal UpperHalfPlane
local notation "πβ" => modelWithCornersSelf β β
local notation "Tβ" => fun x : β β¦ TangentSpace πβ x
instance : ChartedSpace β β := isOpenEmbedding_coe.toPartialHomeomorph.singletonChartedSpace rfl
instance : IsManifold πβ β β := isOpenEmbedding_coe.toPartialHomeomorph.isManifold_singleton rfl
def riemannianMetric : RiemannianMetric Tβ where
inner x := (1 / x.im ^ 2) β’ innerSL β (E := β) -- TODO Do this without defeq abuse
symm := sorry
pos := sorry
continuousAt := sorry
isVonNBounded := sorry
instance : RiemannianBundle Tβ := β¨riemannianMetricβ©
instance : IsRiemannianManifold πβ β := by
refine β¨fun x y β¦ ?_β©
rw [edist_dist, dist_eq]
-- Argue that length-minimising arcs are subsets of lines / circles perpendicular to real line.
-- Should be possible by arguing these are preserved by `SL(2, β)` action which we know is
-- isometric thanks to `UpperHalfPlane.instIsIsometricSMulSpecialLinearGroupFinOfNatNatReal`
sorry
-- After a long wait (~105 seconds on my fast MacBook) this says `(kernel) deterministic timeout`
-- instance : IsContMDiffRiemannianBundle πβ β β Tβ := sorry
end UpperHalfPlane
Oliver Nash (Aug 07 2025 at 13:31):
I have three questions:
- What is the right way to avoid the defeq abuse in
riemannianMetric. I was quite surprised that I could not find (the general version of)example (x : β) : Tβ x βL[β] β := sorryin the library. - If I uncomment the last statement
instance : IsContMDiffRiemannianBundle πβ β β Tβ := sorrythen as I remark in the comment, Lean pegs a CPU at 100% for nearly two minutes and then just says(kernel) deterministic timeout. Am I doing something wrong? - Does anyone want to try to prove the non-trivial
sorry?
Michael Rothgang (Aug 07 2025 at 13:36):
I may be interested in some of (3) --- but let me finish proving the existence of Riemannian metrics first. :-)
Michael Rothgang (Aug 08 2025 at 08:03):
For (1), I suspect the proper generality is proving
βis an open subset ofβ, henceTββL[β] Tβ- there's an isomorphism
Tπ βL[π] πfor any nontrivially normed fieldπ
and then composing these isomorphisms.
Patrick and I have the second one on our big branch; I could PR that soon. I'm really surprised that the first one is missing.
Michael Rothgang (Aug 08 2025 at 08:09):
For (2): what happens when you upgrade your sorry about to a ContMDiffRiemannianMetric?
Michael Rothgang (Aug 08 2025 at 08:16):
Update: that helps; here's my version
import Mathlib.Analysis.Complex.UpperHalfPlane.Metric
import Mathlib.Geometry.Manifold.Riemannian.Basic
import Mathlib.Geometry.Manifold.VectorBundle.Riemannian
-- import Mathlib.Geometry.Manifold.Riemannian.PathELength
-- import Mathlib.Geometry.Manifold.VectorBundle.Tangent
noncomputable section
namespace UpperHalfPlane
open Bundle
open scoped ContDiff ENNReal UpperHalfPlane
local notation "πβ" => modelWithCornersSelf β β
local notation "Tβ" => fun x : β β¦ TangentSpace πβ x
instance : ChartedSpace β β := isOpenEmbedding_coe.toPartialHomeomorph.singletonChartedSpace rfl
instance : IsManifold πβ β β := isOpenEmbedding_coe.toPartialHomeomorph.isManifold_singleton rfl
def riemannianMetric : ContMDiffRiemannianMetric πβ β β Tβ where
inner x := (1 / x.im ^ 2) β’ innerSL β (E := β) -- TODO Do this without defeq abuse
symm := sorry
pos := sorry
isVonNBounded := sorry
contMDiff := sorry
instance : RiemannianBundle Tβ := β¨riemannianMetric.toRiemannianMetricβ©
instance : IsRiemannianManifold πβ β := by
refine β¨fun x y β¦ ?_β©
rw [edist_dist, dist_eq]
-- Argue that length-minimising arcs are subsets of lines / circles perpendicular to real line.
-- Should be possible by arguing these are preserved by `SL(2, β)` action which we know is
-- isometric thanks to `UpperHalfPlane.instIsIsometricSMulSpecialLinearGroupFinOfNatNatReal`
sorry
#synth IsContMDiffRiemannianBundle πβ β β Tβ -- is really fast
instance : IsContMDiffRiemannianBundle πβ β β Tβ := by infer_instance -- is slow
-- After a long wait (~105 seconds on my fast MacBook) this says `(kernel) deterministic timeout`
--instance : IsContMDiffRiemannianBundle πβ β β Tβ := sorry
end UpperHalfPlane
Michael Rothgang (Aug 08 2025 at 08:16):
So, Lean can infer the instance just fine --- but putting a new instance is really slow. I have no idea why, but would be very interested in explanations!
SΓ©bastien GouΓ«zel (Aug 08 2025 at 09:22):
For 1, I'd say the defeq abuse is here to be abused -- in paper maths, you would write things exactly as you did here.
For 2, you are doing things perfectly right, and there is something fishy going on. I tried to investigate a little bit, but I couldn't understand what is wrong for now.
Michael Rothgang (Aug 08 2025 at 09:54):
About (2): since you're never stating continuity/smoothness of your metric, there's no way #synth IsContMDiffRiemannianBundle πβ β β Tβ can succeed. So, strengthening the statement still feels right to me.
Michael Rothgang (Aug 08 2025 at 09:54):
I don't think Lean should take so long to fail, though: that is definitely not good.
SΓ©bastien GouΓ«zel (Aug 08 2025 at 10:12):
Yes, for (2) I was talking about @Michael Rothgang's version, where the metric is defined as a ContMDiffRiemannianMetric.
SΓ©bastien GouΓ«zel (Aug 08 2025 at 13:26):
Somewhat minimized, still not there:
import Mathlib
noncomputable section
namespace UpperHalfPlane
open Bundle
open scoped ContDiff ENNReal UpperHalfPlane
local notation "πβ" => modelWithCornersSelf β β
local notation "Tβ" => fun x : β β¦ TangentSpace πβ x
instance : IsManifold πβ β β := isOpenEmbedding_coe.toPartialHomeomorph.isManifold_singleton rfl
irreducible_def riemannianMetric : ContMDiffRiemannianMetric πβ β β Tβ := sorry
lemma works : VectorBundle β β fun (x : β) β¦ TangentSpace πβ x := by infer_instance
instance : RiemannianBundle Tβ := β¨riemannianMetric.toRiemannianMetricβ©
def doesntwork : VectorBundle β β fun (x : β) β¦ TangentSpace πβ x := by
sorry
Michael Rothgang (Aug 08 2025 at 13:29):
Interesting, thanks for minimising! Is the upper half plane important for this example (or would e.g. working with C itself also work)?
Oliver Nash (Aug 08 2025 at 16:07):
Thank you both for corrections and investigations!
SΓ©bastien GouΓ«zel (Aug 08 2025 at 16:35):
ok, I found it.
import Mathlib
noncomputable section
namespace UpperHalfPlane
open Bundle
open scoped ContDiff ENNReal UpperHalfPlane
local notation "πβ" => modelWithCornersSelf β β
def foo (x : β) : AddCommMonoid (TangentSpace πβ x) := by infer_instance
#print foo
/- NormedAddCommGroup.toENormedAddCommMonoid.toAddCommMonoid : AddCommMonoid (TangentSpace πβ x) -/
Before any Riemannian stuff, the AddCommMonoid instance on the tangent space to β is inferred from a normed space structure. So when one registers another normed space structure on the tangent space through the Riemannian bundle business, we have two conflicting instances, and boom. The thing is that, initially, there shouldn't be any normed space structure on the tangent space. And in fact there isn't: if you ask for NormedAddCommGroup (TangentSpace πβ x), it fails as it should. But still this non-existing instance is summoned out of nowhere to construct the AddCommMonoid instance. This is a bug in Lean4, lean4#9077 striking again.
I could try to work around it by tweaking instances and so on, but I am afraid we will see it again and again, so I'm not sure it's worth it. Better fix it upstream, but @Sebastian Ullrich said on the issue that the bug won't be fixed. So I don't really know what to do, because I feel this bug should be really high-priority from the point of view of mathlib. Also, I don't know how much this is related to recent PRs by @Jovan Gerbscheid to fix some issue in typeclass inference (where the implementation doesn't really match the specs). @Kim Morrison, do you have an idea of how we could move forward on this?
SΓ©bastien GouΓ«zel (Aug 08 2025 at 17:31):
Another example of boom, more minimal than the one reported in the issue, but still depending on mathlib:
import Mathlib
def myFoo : Type := β
noncomputable instance : TopologicalSpace myFoo := inferInstanceAs (TopologicalSpace β)
noncomputable instance : ENormedAddCommMonoid myFoo := by infer_instance
myFoo is only endowed with a topological space instance, but it inherits the enormed structure from β.
Note that things are a little bit subtle here (and therefore hard to minimize) because, with β instead of β, the issue disappears.
Matthew Ballard (Aug 08 2025 at 18:09):
Has this been observed?
import Mathlib
def myFoo : Type := β
noncomputable instance : TopologicalSpace myFoo := inferInstanceAs (TopologicalSpace β)
set_option trace.Meta.synthInstance true in
-- uncomment below to get a failing #synth
-- noncomputable instance : NormedAddCommGroup myFoo := by infer_instance
#synth ENormedAddCommMonoid myFoo -- NormedAddCommGroup.toENormedAddCommMonoid
I can guess why but this is not ideal behavior.
Edward van de Meent (Aug 08 2025 at 18:34):
is this lean4#9077 ?
Matthew Ballard (Aug 08 2025 at 18:34):
Another incarnation, yes
Matthew Ballard (Aug 08 2025 at 18:35):
I think a reasonable invariant of typeclass synthesis is that if it succeeds returning X.toY to get Y then it should also succeed for X.
Sebastian Ullrich (Aug 08 2025 at 18:45):
We want to take another look at this issue but until that has concluded, I can't speculate on the outcome
Last updated: Dec 20 2025 at 21:32 UTC