Skip to content

feat: use IsApply for ContinuousMap - #45093

Open
EtienneC30 wants to merge 37 commits into
leanprover-community:masterfrom
EtienneC30:apply-continuous
Open

EtienneC30 wants to merge 37 commits into
leanprover-community:masterfrom
EtienneC30:apply-continuous

Conversation

@EtienneC30

@EtienneC30 EtienneC30 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

@EtienneC30 EtienneC30 added the t-topology Topological spaces, uniform spaces, metric spaces, filters label Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

PR summary a81cdf663b

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ add_apply
+ coeFnAddMonoidHom
+ coe_add
+ coe_neg
+ coe_nsmul
+ coe_sub
+ coe_sum
+ coe_vadd
+ coe_zero
+ coe_zsmul
+ instance [CommMonoid β] [ContinuousMul β] : CommMonoid C(α, β) := fast_instance% FunLike.commMonoid
+ instance [Div β] [ContinuousDiv β] : IsDivApply C(α, β)
+ instance [Group β] [IsTopologicalGroup β] : Group C(α, β) := fast_instance% FunLike.group
+ instance [Group β] [IsTopologicalGroup β] : IsPowApply ℤ C(α, β)
+ instance [IntCast β] : IsIntCastApply C(α, β)
+ instance [Inv β] [ContinuousInv β] : IsInvApply C(α, β)
+ instance [Monoid β] [ContinuousMul β] : IsPowApply ℕ C(α, β)
+ instance [Monoid β] [ContinuousMul β] : Monoid C(α, β) := fast_instance% FunLike.monoid
+ instance [Mul β] [ContinuousMul β] : IsMulApply C(α, β)
+ instance [NatCast β] : IsNatCastApply C(α, β)
+ instance [One β] : IsOneApply C(α, β)
+ instance [SMul R M] [ContinuousConstSMul R M] : IsSMulApply R C(α, M)
+ instance [Semigroup β] [ContinuousMul β] : Semigroup C(α, β) := fast_instance% FunLike.semigroup
+ neg_apply
+ nsmul_apply
+ sub_apply
+ sum_apply
+ vadd_apply
+ zero_apply
+ zsmul_apply
- instance [CommMonoid β] [ContinuousMul β] : CommMonoid C(α, β) := fast_instance%
- instance [Group β] [IsTopologicalGroup β] : Group C(α, β) := fast_instance%
- instance [Monoid β] [ContinuousMul β] : Monoid C(α, β) := fast_instance%
- instance [Semigroup β] [ContinuousMul β] : Semigroup C(α, β) := fast_instance%

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 a81cdf6).

  • +16 new declarations
  • −2 removed declarations
-ContinuousMap.coeFnAddMonoidHom_apply
-ContinuousMap.coeFnMonoidHom_apply
+ContinuousMap.instIsAddApply
+ContinuousMap.instIsDivApply
+ContinuousMap.instIsIntCastApply
+ContinuousMap.instIsInvApply
+ContinuousMap.instIsMulApply
+ContinuousMap.instIsNSMulApplyInt
+ContinuousMap.instIsNSMulApplyNat
+ContinuousMap.instIsNatCastApply
+ContinuousMap.instIsNegApply
+ContinuousMap.instIsOneApply
+ContinuousMap.instIsPowApplyInt
+ContinuousMap.instIsPowApplyNat
+ContinuousMap.instIsSMulApply
+ContinuousMap.instIsSubApply
+ContinuousMap.instIsVAddApply
+ContinuousMap.instIsZeroApply

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

Current commit a81cdf663b
Reference commit 401d9e6852

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

@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 20, 2026
@EtienneC30
EtienneC30 marked this pull request as ready for review October 20, 2026 19:18
@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 21, 2026
@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 21, 2026
@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 21, 2026
@mathlib-dependent-issues

mathlib-dependent-issues Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

@grunweg grunweg left a comment

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.

Thanks for doing this. I have only minor comments.

(f ^ n) x = f x ^ n :=
rfl
@[deprecated (since := "2026-10-20")] alias coe_nsmul := FunLike.coe_smul
@[to_additive existing, deprecated (since := "2026-10-20")] alias coe_pow := FunLike.coe_pow

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.

Do these declarations differ in their order of implicit arguments? (Do we care? Can we make the deprecation indicate this, e.g. via +typeChanged.)

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.

In general, these names are somewhat common among other classes: should we mark more of these aliasses are protected?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In #45081 Moritz indeed deprecated with +typeChanged instead of just putting an alias. Here it is actually the explicit arguments that are swapped for some reason. But among all the fixes I had to do they were all in simp or rw calls, so the arguments were not the issue.

To answer your second question, in most cases the coe_smul lemmas should not be protected but deprecated in favor of the right IsApply class.

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.

I agree about the deprecation. My question is: should we have a deprecated alias or a deprecated protected alias? If the latter ends up nicer, I think we should do the latter. (Perhaps it doesn't work, I haven't tested.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think there is no need to protect the coe lemmas because the corresponding FunLike ones are in the FunLike namespace which is never opened. However the apply lemmas should be protected because the corresponding FunLike lemmas do not have a namespace.

theorem mul_apply [Mul β] [ContinuousMul β] (f g : C(α, β)) (x : α) : (f * g) x = f x * g x :=
rfl
@[deprecated (since := "2026-10-20")] alias coe_add := FunLike.coe_add
@[to_additive existing, deprecated (since := "2026-10-20")] alias coe_mul := FunLike.coe_mul

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.

For instance, should these be protected? (Though I gather that this will be written explicitly much less.)

@grunweg grunweg self-assigned this Oct 21, 2026
@grunweg grunweg added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 21, 2026
@EtienneC30 EtienneC30 removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 23, 2026
Comment on lines 449 to +452
def coeFnRingHom {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] [Semiring β]
[IsTopologicalSemiring β] : C(α, β) →+* α → β :=
{ (coeFnMonoidHom : C(α, β) →* _),
(coeFnAddMonoidHom : C(α, β) →+ _) with }
{ (FunLike.coeMonoidHom _ _ _ : C(α, β) →* _),
(FunLike.coeAddMonoidHom _ _ _ : C(α, β) →+ _) with }

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 this should be an abstract definition for FunLike in the file for rings

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.

Done in #45295

@mcdoll mcdoll added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 25, 2026
@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 26, 2026
@EtienneC30 EtienneC30 removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 26, 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 Oct 27, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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 28, 2026

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

blocked-by-other-PR This PR depends on another PR (this label is automatically 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.

3 participants