Skip to content

refactor(Data/Finsupp): deprecate direct single ↔ Set.indicator shortcuts, add indicator_eq_set_indicator#34182

Open
IlPreteRosso wants to merge 16 commits intoleanprover-community:masterfrom
IlPreteRosso:FinsuppSingle
Open

refactor(Data/Finsupp): deprecate direct single ↔ Set.indicator shortcuts, add indicator_eq_set_indicator#34182
IlPreteRosso wants to merge 16 commits intoleanprover-community:masterfrom
IlPreteRosso:FinsuppSingle

Conversation

@IlPreteRosso
Copy link
Copy Markdown
Contributor

@IlPreteRosso IlPreteRosso commented Jan 20, 2026

Routes Finsupp.single ↔ Set.indicator through Pi.single instead of direct shortcuts.

Adds indicator_eq_set_indicator bridging Finsupp.indicator and Set.indicator for non-dependent functions. Deprecates single_eq_set_indicator and single_eq_indicator — users should compose through single_eq_pi_single + Set.indicator_singleton instead. Golfs single_eq_update via single_eq_pi_single.

Continues #34083.

@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 Jan 20, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 20, 2026

PR summary cd8272a9d5

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Data.Finsupp.Single 439 447 +8 (+1.82%)
Mathlib.Data.Finsupp.Indicator 440 448 +8 (+1.82%)
Import changes for all files
Files Import difference
33 files Mathlib.Algebra.BigOperators.Associated Mathlib.Algebra.BigOperators.Finsupp.Basic Mathlib.Algebra.BigOperators.Finsupp.Fin Mathlib.Algebra.FreeAbelianGroup.Finsupp Mathlib.Algebra.FreeAbelianGroup.UniqueSums Mathlib.Algebra.FreeMonoid.UniqueProds Mathlib.Algebra.Group.Finsupp Mathlib.Algebra.Group.Subgroup.Finsupp Mathlib.Algebra.Group.Submonoid.Finsupp Mathlib.Algebra.Group.UniqueProds.Basic Mathlib.Algebra.GroupWithZero.Torsion Mathlib.Algebra.Order.Antidiag.Finsupp Mathlib.Algebra.Order.Floor.Div Mathlib.Algebra.Star.BigOperators Mathlib.Combinatorics.Enumerative.Partition.Basic Mathlib.Combinatorics.Enumerative.Partition Mathlib.Data.DFinsupp.Notation Mathlib.Data.Finset.Finsupp Mathlib.Data.Finsupp.BigOperators Mathlib.Data.Finsupp.Ext Mathlib.Data.Finsupp.NeLocus Mathlib.Data.Finsupp.Pointwise Mathlib.Data.Finsupp.SMulWithZero Mathlib.Data.List.ToFinsupp Mathlib.Data.ZMod.Units Mathlib.RingTheory.Localization.NumDen Mathlib.RingTheory.UniqueFactorizationDomain.Basic Mathlib.RingTheory.UniqueFactorizationDomain.FactorSet Mathlib.RingTheory.UniqueFactorizationDomain.Finite Mathlib.RingTheory.UniqueFactorizationDomain.GCDMonoid Mathlib.RingTheory.UniqueFactorizationDomain.Multiplicative Mathlib.RingTheory.UniqueFactorizationDomain.Nat Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors
1
Mathlib.Data.Finsupp.Fintype 2
4 files Mathlib.Data.Finsupp.Fin Mathlib.Data.Finsupp.Indicator Mathlib.Data.Finsupp.Notation Mathlib.Data.Finsupp.Single
8

Declarations diff

+ indicator_eq_set_indicator
+ indicator_singleton
+ set_indicator_singleton
- Set.indicator_singleton_eq

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

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

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


No changes to technical debt.

You can run this locally as

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

@github-actions github-actions bot added t-data Data (lists, quotients, numbers, etc) easy < 20s of review time. See the lifecycle page for guidelines. labels Jan 20, 2026
eric-wieser
eric-wieser previously approved these changes Jan 20, 2026
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.

Please update the PR title; this commit does not add anything, it just golfs!

bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jan 20, 2026

✌️ IlPreteRosso can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ghost ghost added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Jan 20, 2026
@eric-wieser
Copy link
Copy Markdown
Member

bors d-

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jan 20, 2026

🚫 All delegations have been removed from this PR. To re-add a delegation, reply with bors d+ (to delegate the PR author) or bors d=list,of,github,usernames to delegate multiple users.

@ghost ghost removed the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Jan 20, 2026
Comment thread Mathlib/Data/Finsupp/Single.lean Outdated
@eric-wieser eric-wieser dismissed their stale review January 21, 2026 00:13

See above

@eric-wieser eric-wieser added the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 21, 2026
Comment thread Mathlib/Data/Finsupp/Single.lean Outdated
@IlPreteRosso
Copy link
Copy Markdown
Contributor Author

@eric-wieser We have

theorem mulIndicator_singleton (i : ι) (f : ι → M) :
    Set.mulIndicator {i} f = Pi.mulSingle i (f i) := by

in Mathlib.Algebra.Group.Indicator, with @[to_additive]. In fact this was added to Mathlib by my previous PR #34083

We don't have the coe version of this in Mathlib.Data.Finsupp.Single, only the one specialized to constant function.

For this PR I wanted to add this coe statement in Finsupp.

@IlPreteRosso
Copy link
Copy Markdown
Contributor Author

IlPreteRosso commented Jan 21, 2026

@eric-wieser I added all the versions in question please let me know which one we want and in what direction, I'm a bit confused by the similar theorem names and files.

One thing is that single_eq_set_indicator is originally in Mathlib, and needs generalization. For the directions I just followed the context.

My intention was simple, I saw theorems A c = B c taking in a constant function c, I stated A f = B f, for general f, in the same direction and in the same namespace, with the same type signature, and then golfed the constant version using the general version.

@github-actions github-actions bot added WIP Work in progress and removed awaiting-author A reviewer has asked the author a question or requested changes. labels Jan 21, 2026
Comment thread Mathlib/Data/Finsupp/Indicator.lean Outdated
@IlPreteRosso IlPreteRosso changed the title feat(Data/Finsupp/Single): add Set.indicator_singleton_eq feat(Data/Finsupp/Single, Data/Finsupp/Indicator): Add set_indicator_singleton, indicator_singleton; golfed single_eq_set_indicator, single_eq_indicator Jan 21, 2026
Comment thread Mathlib/Data/Finsupp/Indicator.lean
Comment thread Mathlib/Data/Finsupp/Single.lean Outdated
Comment on lines 65 to 69
Set.indicator {a} f = ⇑(single a (f a)) := by
classical
ext x
simp only [Set.indicator, Set.mem_singleton_iff, single_apply, @eq_comm _ a]
split_ifs with h <;> simp [h]
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser Jan 21, 2026

Choose a reason for hiding this comment

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

This has a much shorter proof which I think is classical rw [Set.indicator_singleton, Finsupp.single_eq_pi_single].

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.

Set.indicator_singleton changes import Mathlib.Algebra.Notation.Indicator to import Mathlib.Algebra.Group.Indicator, need to move single_eq_pi_single to before set_indicator_singleton within Single.lean. Then set_indicator_singleton is golfed. Also golfed the relocated single_eq_pi_single.

@eric-wieser
Copy link
Copy Markdown
Member

In fact this was added to Mathlib by my previous PR #34083

Sorry about this, indeed the lemma I was asking for is already there!

One thing is that single_eq_set_indicator is originally in Mathlib, and needs generalization. For the directions I just followed the context.

I would actually lean towards deprecating it, and making the user rewrite through Finsupp.single_eq_pi_single then Set.indicator_singleton, or via Finsupp.indicator_singleton followed by a seemingly missing lemma linking Finsupp.indicator and Set.indicator.

Generally I would think of theorems as filling out the edges of a hypercube, not as also filling every possible diagonal.

@eric-wieser
Copy link
Copy Markdown
Member

Let's see what @urkud thinks

@github-actions github-actions bot added the large-import Automatically added label for PRs with a significant increase in transitive imports label Jan 21, 2026
@IlPreteRosso
Copy link
Copy Markdown
Contributor Author

@eric-wieser No worries! I'll wait for more input then. Also as my earlier reply

Set.indicator_singleton changes import

Now bot added large-import warning. So a trade off between golf and import.

Generally I would think of theorems as filling out the edges of a hypercube, not as also filling every possible diagonal.

I like this way of thinking.

@ocfnash ocfnash removed the easy < 20s of review time. See the lifecycle page for guidelines. label Jan 21, 2026
@IlPreteRosso
Copy link
Copy Markdown
Contributor Author

@urkud Sorry to tag you again, just in case you missed the previous tag

@urkud
Copy link
Copy Markdown
Member

urkud commented Jan 30, 2026

I'm sorry for the delay. I'll look into this over the weekend.

@IlPreteRosso
Copy link
Copy Markdown
Contributor Author

IlPreteRosso commented Feb 6, 2026

Hi @urkud, sorry to tag you again, just would like to remind you that here's still a PR awaiting your review.

@mathlib-triage mathlib-triage bot assigned TwoFX and unassigned eric-wieser and urkud Mar 22, 2026
@github-actions github-actions bot removed the large-import Automatically added label for PRs with a significant increase in transitive imports label Apr 3, 2026
@IlPreteRosso IlPreteRosso changed the title feat(Data/Finsupp/Single, Data/Finsupp/Indicator): Add set_indicator_singleton, indicator_singleton; golfed single_eq_set_indicator, single_eq_indicator feat/deprecation(Data/Finsupp): add indicator_eq_set_indicator, deprecate single_eq_set_indicator and single_eq_indicator Apr 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

✅ PR Title Formatted Correctly

The title of this PR has been updated to match our commit style conventions.
Thank you!

@IlPreteRosso IlPreteRosso changed the title feat/deprecation(Data/Finsupp): add indicator_eq_set_indicator, deprecate single_eq_set_indicator and single_eq_indicator feat/deprecation(Data/Finsupp): add indicator_eq_set_indicator, deprecate direct Finsupp.single ↔ Set.indicator shortcuts Apr 3, 2026
@IlPreteRosso IlPreteRosso changed the title feat/deprecation(Data/Finsupp): add indicator_eq_set_indicator, deprecate direct Finsupp.single ↔ Set.indicator shortcuts refactor(Data/Finsupp): deprecate direct single ↔ Set.indicator shortcuts, add indicator_eq_set_indicator Apr 3, 2026
@IlPreteRosso
Copy link
Copy Markdown
Contributor Author

@eric-wieser Updated per your suggestion — single_eq_set_indicator and single_eq_indicator are now deprecated, routing through Pi.single instead. Also added the missing indicator_eq_set_indicator bridge between Finsupp.indicator and Set.indicator.

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

Labels

new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants