Skip to content

feat(Topology,Analysis): discrete topology metric space and normed groups#27664

Open
pechersky wants to merge 7 commits into
leanprover-community:masterfrom
pechersky:discrete-metric-normed
Open

feat(Topology,Analysis): discrete topology metric space and normed groups#27664
pechersky wants to merge 7 commits into
leanprover-community:masterfrom
pechersky:discrete-metric-normed

Conversation

@pechersky
Copy link
Copy Markdown
Contributor

Explicit construction of the discrete topology metric space and normed groups where dist x y = 1 for all x != y
Provide PseudoMetricSpace, MetricSpace, Seminormed(Add)Group, and Normed(Add)Group constructions


Open in Gitpod

…oups

Explicit construction of the discrete topology metric space and normed groups
where `dist x y = 1` for all `x != y`
Provide PseudoMetricSpace, MetricSpace, Seminormed(Add)Group, and Normed(Add)Group constructions
@pechersky pechersky added the t-topology Topological spaces, uniform spaces, metric spaces, filters label Jul 30, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 30, 2025

PR summary bd4da70be5

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ NormedGroup.ofDiscreteTopology
+ NormedGroup.ofDiscreteTopology_norm_def
+ SeminormedGroup.ofDiscreteTopology
+ SeminormedGroup.ofDiscreteTopology_norm_def
++ ofDiscreteTopology
++ ofDiscreteTopology_discreteUniformity
++ ofDiscreteTopology_dist_def
++ ofDiscreteTopology_uniformSpace_eq_bot

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

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

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


No changes to technical debt.

You can run this locally as

./scripts/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).

Comment on lines +246 to +247
This takes an explicit `DiscreteTopology` instance to ensure that the forgetful
inheritance to topology matches. -/
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.

Why do we need this?

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.

Because I don't want people installing this discrete metric space unless they really mean to.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do you replace the topology but not the uniformity?

Comment on lines +410 to +411
def NormedGroup.ofDiscreteTopology [TopologicalSpace G] [DiscreteTopology G]
[Group G] [DecidableEq G] : NormedGroup G where
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.

Does this one imply SeminormedGroup.ofDiscreteTopology?

@kckennylau
Copy link
Copy Markdown
Collaborator

I guess I don't understand why we need to do everything for MetricSpace etc. and then do it again for PseudoMetricSpace. Does MetricSpace not imply PseudoMetricSpace?

@mathlib4-merge-conflict-bot mathlib4-merge-conflict-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 31, 2025
@mathlib4-merge-conflict-bot
Copy link
Copy Markdown
Collaborator

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 31, 2025
@pechersky
Copy link
Copy Markdown
Contributor Author

Why do it for PseudoMetricSpace when we did it for MetricSpace? Because I want the construction to be available earlier in import tree without having to bring in metric spaces.

One could also ask, why have it for MetricSpace if we have it for PseudoMetricSpace? And that's so that there are shortcut constructions that give as rich of an object as possible.

Comment thread Mathlib/Topology/MetricSpace/Pseudo/Constructions.lean Outdated
@kckennylau
Copy link
Copy Markdown
Collaborator

I see, I missed the fact that MS depends on PMS because github orders files alphabetically

Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Comment on lines +249 to +252
dist_self := by simp
dist_comm := by intros; split_ifs <;> simp_all
dist_triangle := by intros; split_ifs <;> simp_all
edist_dist := by intros; split_ifs <;> simp_all
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.

Suggested change
dist_self := by simp
dist_comm := by intros; split_ifs <;> simp_all
dist_triangle := by intros; split_ifs <;> simp_all
edist_dist := by intros; split_ifs <;> simp_all
dist_self := by grind
dist_comm := by grind
dist_triangle := by grind
edist_dist := by aesop

if you want

def ofDiscreteTopology [TopologicalSpace X]
[DiscreteTopology X] [DecidableEq X] : MetricSpace X where
__ := PseudoMetricSpace.ofDiscreteTopology (X := X)
eq_of_dist_eq_zero := by simp [PseudoMetricSpace.ofDiscreteTopology_dist_def]
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.

Suggested change
eq_of_dist_eq_zero := by simp [PseudoMetricSpace.ofDiscreteTopology_dist_def]
eq_of_dist_eq_zero := by grind

Comment on lines +207 to +220
variable [TopologicalSpace X] [DiscreteTopology X] [DecidableEq X]

lemma ofDiscreteTopology_dist_def (x y : X) :
letI := ofDiscreteTopology (X := X)
dist x y = if x = y then 0 else 1 :=
rfl

lemma ofDiscreteTopology_uniformSpace_eq_bot :
(MetricSpace.ofDiscreteTopology (X := X)).toUniformSpace = ⊥ :=
PseudoMetricSpace.ofDiscreteTopology_uniformSpace_eq_bot

lemma ofDiscreteTopology_discreteUniformity :
@DiscreteUniformity X (ofDiscreteTopology (X := X)).toUniformSpace :=
PseudoMetricSpace.ofDiscreteTopology_discreteUniformity
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.

Suggested change
variable [TopologicalSpace X] [DiscreteTopology X] [DecidableEq X]
lemma ofDiscreteTopology_dist_def (x y : X) :
letI := ofDiscreteTopology (X := X)
dist x y = if x = y then 0 else 1 :=
rfl
lemma ofDiscreteTopology_uniformSpace_eq_bot :
(MetricSpace.ofDiscreteTopology (X := X)).toUniformSpace = ⊥ :=
PseudoMetricSpace.ofDiscreteTopology_uniformSpace_eq_bot
lemma ofDiscreteTopology_discreteUniformity :
@DiscreteUniformity X (ofDiscreteTopology (X := X)).toUniformSpace :=
PseudoMetricSpace.ofDiscreteTopology_discreteUniformity
section
variable [TopologicalSpace X] [DiscreteTopology X] [DecidableEq X]
attribute [local instance] ofDiscreteTopology
@[grind =] lemma ofDiscreteTopology_dist_def (x y : X) : dist x y = if x = y then 0 else 1 :=
rfl
lemma ofDiscreteTopology_uniformSpace_eq_bot : (ofDiscreteTopology (X := X)).toUniformSpace = ⊥ :=
PseudoMetricSpace.ofDiscreteTopology_uniformSpace_eq_bot
lemma ofDiscreteTopology_discreteUniformity : DiscreteUniformity X :=
PseudoMetricSpace.ofDiscreteTopology_discreteUniformity
end

@kckennylau kckennylau added the awaiting-author A reviewer has asked the author a question or requested changes. label Nov 21, 2025
@mathlib-merge-conflicts
Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 9, 2026
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. merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-topology Topological spaces, uniform spaces, metric spaces, filters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants