Skip to content

refactor(Topology): unclass IsClosed - #45643

Open
felixpernegger wants to merge 3 commits into
leanprover-community:masterfrom
felixpernegger:closeddef
Open

felixpernegger wants to merge 3 commits into
leanprover-community:masterfrom
felixpernegger:closeddef

Conversation

@felixpernegger

@felixpernegger felixpernegger commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Currently, IsClosed is a class, unlike IsOpen and it also doesnt make much sense and isnt widely used as a class. This was suggested by @eric-wieser on Zulip #mathlib4 > Fact instances.

This PR makes it a one-field structure (def would also work, but this prevents defeq abuse...).
Some cleanup is needed, for example when IsClosed was used in an instance, we now need [Fact (IsOpen ....

Originally IsClosed was made a class in mathlib3 in 2021 here.


@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

PR summary 612ca324d3

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ IsNoetherianRing.isClosed_ideal
+ instance : Fact (IsClosed ((generator H H').ker : Set (WithLp 2 (H × H'))))
+ instance : Fact (IsClosed (eigenspace (f : End R M) μ : Set M))
+ instance [IsTopologicalGroup G] {H : Subgroup G} [H_closed : Fact (IsClosed (H : Set G))] :
+ instance [T1Space G] {U : Subgroup G} [DiscreteTopology U] :
+ instance {H : Subgroup G} [ProperSMul G X] [H_closed : Fact (IsClosed (H : Set G))] :
+ instance {I : Ideal R} [I.IsMaximal] : Fact (IsClosed (I : Set R))
+ isClosed_pathComponentOne
- instance (priority := low) IsNoetherianRing.isClosed_ideal
- instance : IsClosed ((generator H H').ker : Set (WithLp 2 (H × H')))
- instance [Group G] [IsTopologicalGroup G] [LocallyPathConnectedSpace G] :
- instance [IsTopologicalGroup G] {H : Subgroup G} [H_closed : IsClosed (H : Set G)] :
- instance {H : Subgroup G} [ProperSMul G X] [H_closed : IsClosed (H : Set G)] : ProperSMul H X
--++ isClosed

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.

Declarations diff (Lean)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 612ca32).

  • +13 new declarations
  • −8 removed declarations
+AddSubgroup.instFactIsClosedCoeOfT1SpaceOfDiscreteTopologySubtypeMem
+ContinuousLinearMap.instFactIsClosedCoeSubmoduleEigenspace
+Ideal.instFactIsClosedCoeOfIsMaximal
-OpenNormalAddSubgroup.instIsClosedCoePathComponentZero
+OpenNormalAddSubgroup.isClosed_pathComponentZero
-OpenNormalSubgroup.instIsClosedCoePathComponentOne
+OpenNormalSubgroup.isClosed_pathComponentOne
+RKHS.Add'.instFactIsClosedWithLpOfNatENNRealProdCoeSubmoduleKerForallGenerator
-RKHS.Add'.instIsClosedWithLpOfNatENNRealProdCoeSubmoduleKerForallGenerator
+Subgroup.instFactIsClosedCoeOfT1SpaceOfDiscreteTopologySubtypeMem
+instCompleteSpaceSubtypeMemSubmoduleOfFactIsClosedCoe
-instCompleteSpaceSubtypeMemSubmoduleOfIsClosedCoe
+instFactIsClosedCoeIdealOfIsNoetherianRing
+instProperSMulSubtypeMemSubgroupOfFactIsClosedCoe
-instProperSMulSubtypeMemSubgroupOfIsClosedCoe
+instProperSMulSubtypeMulOppositeMemSubgroupOpOfIsTopologicalGroupOfFactIsClosedCoe
-instProperSMulSubtypeMulOppositeMemSubgroupOpOfIsTopologicalGroupOfIsClosedCoe
+instProperVAddSubtypeAddOppositeMemAddSubgroupOpOfIsTopologicalAddGroupOfFactIsClosedCoe
-instProperVAddSubtypeAddOppositeMemAddSubgroupOpOfIsTopologicalAddGroupOfIsClosedCoe
+instProperVAddSubtypeMemAddSubgroupOfFactIsClosedCoe
-instProperVAddSubtypeMemAddSubgroupOfIsClosedCoe

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

Current commit 612ca324d3
Reference commit 2094f6de79

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py 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).

@JX-Mo

JX-Mo commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

!radar

@leanprover-radar

leanprover-radar commented Nov 4, 2026 •

Copy link
Copy Markdown

Benchmark results for 612ca32 against 2094f6d are in. No significant results found. @JX-Mo

  • ✅ build//instructions: -5.3G (-0.00%)

Medium changes (1✅, 1🟥)

  • 🟥 build/module/Mathlib.Analysis.CStarAlgebra.GelfandDuality//instructions: +1.2G (+3.50%) (reduced significance based on absolute threshold)
  • ✅ build/module/Mathlib.Topology.Convenient.OpenClosed//instructions: -2.1G (-21.25%) (reduced significance based on absolute threshold)

Small changes (68✅, 13🟥)

  • 81 hidden

@SnirBroshi

Copy link
Copy Markdown
Collaborator

IsClosed is already a one-field structure, so I think the title is a bit misleading.
You're removing it's class status, not refactoring stuff because of defeq abuse.

@felixpernegger

Copy link
Copy Markdown
Contributor Author

sure

@felixpernegger felixpernegger changed the title refactor(Topology): make IsClosed a one-field structure refactor(Topology): unclass IsClosed Nov 4, 2026
@felixpernegger felixpernegger added the awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there label Nov 4, 2026
@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 Nov 7, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants