Zulip Chat Archive

Stream: mathlib4

Topic: Instances for EuclideanSpace


Sebastian Kumar (Aug 10 2025 at 17:03):

I was working with EuclideanSpace and I would like to have access to the following instances:

import Mathlib

variable {𝕜 : Type*} [RCLike 𝕜]

instance (n : ) : Infinite (EuclideanSpace 𝕜 (Fin (n + 1))) :=
  PreconnectedSpace.infinite

instance (n : ) : Fact (Module.finrank 𝕜 (EuclideanSpace 𝕜 (Fin n)) = n) :=
  finrank_euclideanSpace_fin

In particular, the second allows the use of stereographic projection in EuclideanSpace (stereographic' from Mathlib.Geometry.Manifold.Instances.Sphere). However, @Kenny Lau pointed out to me why certain theorems aren't given instances. Do the above instances have the right level of generality to be added to Mathlib? If so, where would I add them? I was thinking the second could go after the definition of finrank_euclideanSpace_fin in Mathlib.Analysis.InnerProductSpace.PiL2, but I wasn't sure about the first.

Kenny Lau (Aug 10 2025 at 17:03):

See the comment I left on your PR for the first one

Kenny Lau (Aug 10 2025 at 17:04):

I don't see the point of the second one. We shouldn't just add every Fact to Mathlib

Sebastian Kumar (Aug 10 2025 at 17:05):

The second one was because the definition of stereographic' needs such a Fact as an implicit argument. Is there a better way to get around this?

Kenny Lau (Aug 10 2025 at 17:06):

aha, in that case, yes, please PR with that justification

Wuyang (Aug 11 2025 at 19:05):

Sounds like the first instance needs revisiting per Kenny’s earlier comment, but the second seems justified if it enables stereographic' directly, worth a PR with that reasoning. Also, try searching related usage patterns on LeanFinder.

Wuyang (Aug 11 2025 at 19:06):

@leanfinder Adding Infinite and finrank Fact instances for EuclideanSpace to support stereographic projection in Lean Mathlib

leanfinder (Aug 11 2025 at 19:06):

Here’s what I found:

This is obtained by composing:

  1. The standard stereographic projection stereographic (which maps to the orthogonal complement (Rv)(\mathbb{R}\cdot v)^\perp)
  2. A linear isometry from (Rv)(\mathbb{R}\cdot v)^\perp to Rn\mathbb{R}^n given by an orthonormal basis" (score: 0.767)

Sebastian Kumar (Aug 11 2025 at 22:00):

I thought I should update that I made the PR: https://github.com/leanprover-community/mathlib4/pull/28198. However, it seems to be falling to the CI bug from #mathlib4 > Failing CI :(.

Bryan Gin-ge Chen (Aug 11 2025 at 22:36):

You can try merging master into your branch again; hopefully the error will go away. If not, please report it again!


Last updated: Dec 20 2025 at 21:32 UTC