Skip to content

chore(Data/Set): reduce defeq abuse of Set α = α → Prop - #39110

Closed
SnirBroshi wants to merge 11 commits into
leanprover-community:masterfrom
SnirBroshi:chore/set/reduce-defeq/basics
Closed

SnirBroshi wants to merge 11 commits into
leanprover-community:masterfrom
SnirBroshi:chore/set/reduce-defeq/basics

Conversation

@SnirBroshi

@SnirBroshi SnirBroshi commented May 9, 2026 •

Copy link
Copy Markdown
Collaborator

These are among the first places that would fail if Set α wasn't defeq to α → Prop.


Open in Gitpod

@github-actions

github-actions Bot commented May 9, 2026 •

Copy link
Copy Markdown

PR summary e286da2d98

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ toProp

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

  • +3 new declarations
  • −0 removed declarations
+Set.toProp
+Set.toProp_apply
+Set.toProp_symm_apply

No changes to strong technical debt.

No changes to weak technical debt.

Current commit e286da2d98
Reference commit 6c0d6d2ff8

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

@SnirBroshi SnirBroshi added the t-data Data (lists, quotients, numbers, etc) label May 9, 2026
@SnirBroshi

Copy link
Copy Markdown
Collaborator Author

!bench

@leanprover-radar

leanprover-radar commented May 9, 2026 •

Copy link
Copy Markdown

Benchmark results for e852052 against 043e9e0 are in. No significant results found. @SnirBroshi

  • 🟥 build//instructions: +4.7G (+0.00%)

No significant changes detected.

Comment thread Mathlib/Data/Set/Basic.lean Resolved
Comment thread Mathlib/Logic/Function/Basic.lean Resolved
@SnirBroshi
SnirBroshi requested a review from themathqueen May 10, 2026 07:25
Comment thread Mathlib/Logic/Function/Basic.lean Resolved
Comment thread Mathlib/Data/Set/Basic.lean Outdated

/-- A set of `α`s is equivalent to a predicate on elements of type `α`. -/
@[simps]
def setEquivPredicate (α : Type*) : Set α ≃ (α → Prop) 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.

I know I suggested this name, but what about Set.toProp (or is that too vague?)? Let's have another person comment on this name. Besides that, looks good to me.

maintainer delegate?

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.

Set.toProp or Set.toPredicate would be better here for me. (Set.toPred might work, but would be confused with the predecessor function.) It's a common operation so having a short (but less intuitive) name is better.

Trying to think of different names, I came up with: this is setOf but as an equiv, so Equiv.setOf or setOfEquiv. But neither of those options really seem more meaningful.

@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by themathqueen.

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label May 14, 2026
@themathqueen

themathqueen commented May 14, 2026 •

Copy link
Copy Markdown
Member

How are you finding these btw? I think @urkud has a branch and a PR draft turning Set into a structure (#39211). Do you also have the same? You should probably try to coordinate (maybe open a Zulip thread on this?) so that neither of you end up wasting time and effort on something the other has already done? (so far I don't think there have been any overlaps in the PRs trying to reduce Set defeq abuse, but that might just be luck?)

@SnirBroshi

SnirBroshi commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Basically their PRs were what inspired me to help, and I locally turned Set into a structure and saw what broke.
I haven't explicitly coordinated so far, but I have checked before opening such PRs that they haven't already fixed those instances. Though that was before the "reveal" of the big PR, so now I'm not sure.

(to be clear, I don't have any unpublished progress towards this goal.)

@Vierkantor Vierkantor 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 cleaning this up! I think Set.toProp is a good option. I would slightly prefer Set.toPred(icate) (if @themathqueen agrees). In any case, assuming we can agree on a name this looks good to me. Thanks!

bors d+

@mathlib-bors

mathlib-bors Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

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

@mathlib-triage mathlib-triage Bot added delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels May 15, 2026
@urkud

urkud commented May 16, 2026

Copy link
Copy Markdown
Member

Note that merging this PR will create unneeded merge conflicts with my branch. Please coordinate on Zulip.
bors d-

@mathlib-bors

mathlib-bors Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

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

@mathlib-triage mathlib-triage Bot removed the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label May 16, 2026
@themathqueen

Copy link
Copy Markdown
Member

Coordinating on Zulip wouldn't be a bad idea (please cc me @SnirBroshi when you open the thread).

I don't think the merge conflicts would be bad at all with your branch @urkud (this PR is pretty small). In any case, I think we will want the equivalence defined here.

@SnirBroshi

Copy link
Copy Markdown
Collaborator Author

#PR reviews > #39110 reduce `Set` defeq abuse in `Data/Set/`

(I didn't want to create some big "mathlib4 > let's fix Set defeq abuse" yet)

@themathqueen

Copy link
Copy Markdown
Member

@urkud, pinging you since this PR has been sitting here for three weeks now

@mathlib-triage mathlib-triage Bot assigned TwoFX and unassigned urkud Jun 17, 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 Jul 6, 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 Jul 6, 2026
@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 Jul 17, 2026
@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 Jul 17, 2026
@themathqueen

Copy link
Copy Markdown
Member

Since the bigger refactoring PR has added the definition and stuff that is in this PR, should we close this? Or at least put the awaiting-author label to remove it from the queue (even though it's not actually needing anything from the author)?

@SnirBroshi SnirBroshi closed this Aug 31, 2026
@themathqueen

Copy link
Copy Markdown
Member

Thanks @SnirBroshi :)

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

Labels

t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants