Skip to content

feat: add instances of MetricSpace, NormedAddGroup, and NormedAddCommGroup for DirectLimit#39673

Open
drocta wants to merge 36 commits into
leanprover-community:masterfrom
drocta:NormedAddGroup-direct-limit
Open

feat: add instances of MetricSpace, NormedAddGroup, and NormedAddCommGroup for DirectLimit#39673
drocta wants to merge 36 commits into
leanprover-community:masterfrom
drocta:NormedAddGroup-direct-limit

Conversation

@drocta
Copy link
Copy Markdown
Contributor

@drocta drocta commented May 21, 2026

add files Topology/MetricSpace/DirectLimit.lean (with an instance of MetricSpace for a DirectLimit of a directed system of MetricSpaces with IsometryClass map types between them) and Analysis/Normed/Group/DirectLimit.lean (with instances of NormedAddGroup and NormedAddCommGroup on DirectLimit)
also lemmas dist_def and norm_def for these.


This PR is part of a project of adding support for direct limits of $C^*$-algebras (as I described on Zulip ).
This PR uses IsometryClass to implement the requirement that the directed systems preserve the Norm on the NormedAddGroups, following the advice I got this Zulip thread .

Use of AI:
I again used ChatGPT a bit for some advice when writing this (for example, for ideas for simplifying parts of proofs that I suspected could be simpler/shorter, and for advice on which of a couple options would be more idiomatic).
I can personally vouch for all of these contributions, and that I understand this code.

drocta added 21 commits May 19, 2026 14:58
… MetricSpace for a DirectLimit of MetricSpace s
…ription and unnecessary arguments x y in rw step
@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 May 21, 2026
@github-actions
Copy link
Copy Markdown

Welcome new contributor!

Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests.

We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the awaiting-author tag, or another reason described in the Lifecycle of a PR. The review dashboard has a dedicated webpage which shows whether your PR is on the review queue, and (if not), why.

If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR.

Thank you again for joining our community.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

PR summary 47f4c30346

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Topology.MetricSpace.DirectLimit (new file) 1070
Mathlib.Analysis.Normed.Group.DirectLimit (new file) 1226
Mathlib.Analysis.Normed.Ring.DirectLimit (new file) 1293

Declarations diff

+ dist_def
+ edist_def
+ instance : EMetricSpace (DirectLimit G f)
+ instance : MetricSpace (DirectLimit G f)
+ instance : NonUnitalNormedRing (DirectLimit G f)
+ instance : NormedCommGroup (DirectLimit G f)
+ instance : NormedGroup (DirectLimit G f)
+ instance : NormedRing (DirectLimit G f)
+ instance : PseudoEMetricSpace (DirectLimit G f)
+ instance : PseudoMetricSpace (DirectLimit G f)
+ instance : SeminormedCommGroup (DirectLimit G f)
+ instance : SeminormedGroup (DirectLimit G f)
+ mul_enorm_def
+ mul_nnnorm_def
+ mul_norm_def
+ nndist_def

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

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

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.


No changes to strong technical debt.
No changes to weak technical debt.

@github-actions github-actions Bot added the t-topology Topological spaces, uniform spaces, metric spaces, filters label May 21, 2026
Comment on lines +42 to +44
lemma norm_def (i : ι) (x : G i) : ‖(⟦⟨i, x⟩⟧ : DirectLimit G f)‖ = ‖x‖ := by
change DirectLimit.lift f (ih := fun i x ↦ ‖x‖) _ ⟦⟨i, x⟩⟧ = ‖x‖
apply DirectLimit.lift_def
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add the nnnorm and enorm lemmas too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For nnnorm_def/enorm_def, it looks like NormedGroup does not provide an NNNorm/ENorm instance?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SeminormedGroup.toNNNorm exists, so I'm not sure I agree.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Whoops, I assumed that if the instance existed it would already be in the scope of what I already had imported. Silly me. Thanks for the correction.

Comment on lines +30 to +36
namespace NormedAddGroup

variable [∀ i, NormedAddGroup (G i)]
variable [∀ i j h, AddMonoidHomClass (T h) (G i) (G j)]
variable [∀ i j h, IsometryClass (T h) (G i) (G j)]

noncomputable instance instNormedAddGroup : NormedAddGroup (DirectLimit G f) where
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this also hold for SeminormedAddGroup? Can you to_additive it and use SeminormedGroup?

Comment thread Mathlib/Topology/MetricSpace/DirectLimit.lean
Comment thread Mathlib/Topology/MetricSpace/DirectLimit.lean Outdated
Comment on lines +31 to +34
variable [∀ i, MetricSpace (G i)]
variable [∀ i j h, IsometryClass (T h) (G i) (G j)]

noncomputable instance : MetricSpace (DirectLimit G f) where
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this genrealize to PseudoMetricSpace?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It does, yes. Will do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you also want the instances for PseudoEMetricSpace and EMetricSpace?
(I believe copy/pasting the code and adding a handful of "e"s before things would make that work. I don't see a way to reduce redundancy by making the (Pseudo)MetricSpace instances use the (Pseudo)EMetricSpace code, or visa versa though. )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, those would be great too; though perhaps slightly more work.

Copy link
Copy Markdown
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

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

I think it should be pretty easy to add the normed ring instances too, assuming they work how I think they do. Could you do that in this PR as well?

@drocta
Copy link
Copy Markdown
Contributor Author

drocta commented May 22, 2026

I think it should be pretty easy to add the normed ring instances too, assuming they work how I think they do. Could you do that in this PR as well?

Sure, can do, I was planning to make that be in a separate PR, but happy to do it in this one.

@j-loreaux
Copy link
Copy Markdown
Contributor

I think this looks good modulo Eric's suggestions. Thanks!

@j-loreaux j-loreaux added the awaiting-author A reviewer has asked the author a question or requested changes. label May 22, 2026
drocta added 5 commits May 21, 2026 19:25
… PseudoMetricSpace and MetricSpace into section blocks
…move the separate instance (and namespace) specific to the NormedAddGroup version
…nce for NormedAddCommGroup with section and instance with to_additive of NormedCommGroup
Comment on lines +64 to +65
dist := DirectLimit.lift₂ f f (fun i ↦ dist (α := G i))
(fun i j h x y ↦ (IsometryClass.dist_eq (f i j h) x y).symm)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would guess you can drop this line now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can, if I replace the rw [lift₂_def] at h' with rw [dist_def] at h' .
Happy to make that change if preferred.
I had guessed (with low confidence) that it might be preferable to leave the definition of dist more directly exposed by doing it this way, but sounds like the other way around maybe?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't define the distance twice, so please make that change.

apply DirectLimit.lift_def

end SeminormedGroup

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you're missing SeminormedCommGroup?


See also `Metric.InductiveLimit` in `Mathlib/Topology/MetricSpace/Gluing.lean`, which
handles sequential inductive limits of metric spaces.
-/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's add a remark that for now the only uniform space and bornology available on a DirectLimit are the ones induced through the metric.

Comment on lines +34 to +39
noncomputable instance : PseudoMetricSpace (DirectLimit G f) where
dist := DirectLimit.lift₂ f f (fun i ↦ dist (α := G i))
(fun i j h x y ↦ (IsometryClass.dist_eq (f i j h) x y).symm)
dist_self := DirectLimit.induction f fun i x ↦ by rw [← dist_self x, lift₂_def]
dist_comm := DirectLimit.induction₂ f fun i x y ↦ by simp_rw [lift₂_def, dist_comm x y]
dist_triangle := DirectLimit.induction₃ f fun i x y z ↦ by simp_rw [lift₂_def, dist_triangle]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here you also need toTopologicalSpace := inferInstance, which will no doubt create a headache.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The test you need to pass (which we should commit) is:

example : (UniformSpace.toTopologicalSpace : TopologicalSpace (DirectLimit G f)) = instTopologicalSpaceQuotient :=
  rfl

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I'm a bit confused here.
When I try to set toTopologicalSpace := inferInstance in there, it tells me that "toTopologicalSpace is not a field of structure PseudoMetricSpace" .

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-topology Topological spaces, uniform spaces, metric spaces, filters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants