Skip to content

[Merged by Bors] - feat(Data/Finset): add Finset.filter_notMem_eq_sdiff, Finset.map_sdiff - #27340

Closed
staroperator wants to merge 4 commits into
leanprover-community:masterfrom
staroperator:finset_lemmas
Closed

staroperator wants to merge 4 commits into
leanprover-community:masterfrom
staroperator:finset_lemmas

Conversation

@staroperator

@staroperator staroperator commented Jul 22, 2025 •

Copy link
Copy Markdown
Collaborator

Finset.filter_notMem_eq_sdiff is the symmetric correspondence of Finset.filter_mem_eq_inter.


Open in Gitpod

@github-actions github-actions Bot added the t-data Data (lists, quotients, numbers, etc) label Jul 22, 2025
@github-actions

github-actions Bot commented Jul 22, 2025 •

Copy link
Copy Markdown

PR summary bfeab816b7

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ filter_notMem_eq_sdiff
+ map_sdiff

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

@staroperator
staroperator requested review from Parcly-Taxel and YaelDillies and removed request for YaelDillies July 22, 2025 12:30
Comment thread Mathlib/Data/Finset/Basic.lean Outdated

theorem filter_union_right (s : Finset α) : s.filter p ∪ s.filter q = s.filter fun x => p x ∨ q x :=
ext fun x => by simp [mem_filter, mem_union, ← and_or_left]
ext fun _ => by simp only [mem_filter, mem_union, ← and_or_left]

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.

Small hint: Terminal simp calls should not be squeezed. This is important for maintainability. (see the style guide: https://leanprover-community.github.io/contribute/style.html#squeezing-simp-calls)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thank you very much! I didn't know about this before.

@YaelDillies YaelDillies 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 the PR! Unfortunately, your cleanups are polemical and I would rather not merge them. Eg

theorem : returnType := by
  ext; simp

is probably preferrable over

theorem : returnType :=
  ext fun _ := by simp

Can you please revert everything but the titular addition of filter_notMem_eq_sdiff?

In general, you will notice your PRs will have a much easier time if you stick to a single category of changes among "feat", "chore", "refactor". Here you are mixing feat and chore (and the chore part in this PR isn't a clear win).

Comment thread Mathlib/Data/Finset/Basic.lean Outdated
Comment on lines +399 to +400
theorem filter_mem_eq_inter {s t : Finset α} [∀ i, Decidable (i ∈ t)] :
(s.filter fun i => i ∈ t) = s ∩ t :=
ext fun i => by simp [mem_filter, mem_inter]
theorem filter_mem_eq_inter {s t : Finset α} : (s.filter fun i => i ∈ t) = s ∩ t :=
ext fun _ => by simp [mem_filter, mem_inter]

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.

This is a regression. Your new lemma is less general because it talks about a derived ∀ i, Decidable (i ∈ t) rather than a general one

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Interesting. I thought it was unnecessary but it is not.

@YaelDillies YaelDillies added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Jul 23, 2025
@staroperator

Copy link
Copy Markdown
Collaborator Author

Thanks for the PR! Unfortunately, your cleanups are polemical and I would rather not merge them. Eg

theorem : returnType := by
  ext; simp

is probably preferrable over

theorem : returnType :=
  ext fun _ := by simp

Can you please revert everything but the titular addition of filter_notMem_eq_sdiff?

In general, you will notice your PRs will have a much easier time if you stick to a single category of changes among "feat", "chore", "refactor". Here you are mixing feat and chore (and the chore part in this PR isn't a clear win).

OK, I have now reverted everything except the newly added lemmas.

@staroperator staroperator removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Jul 23, 2025

@YaelDillies YaelDillies 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! 🚀

maintainer merge

@github-actions

Copy link
Copy Markdown

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

@ghost ghost added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Jul 23, 2025

@bryangingechen bryangingechen 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!
bors r+

@ghost ghost added ready-to-merge This PR has been sent to bors. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Jul 23, 2025
mathlib-bors Bot pushed a commit that referenced this pull request Jul 23, 2025
…diff` (#27340)

`Finset.filter_notMem_eq_sdiff` is the symmetric correspondence of `Finset.filter_mem_eq_inter`.
@mathlib-bors

mathlib-bors Bot commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

  • CI Success

@mathlib-bors mathlib-bors Bot changed the title feat(Data/Finset): add Finset.filter_notMem_eq_sdiff, Finset.map_sdiff [Merged by Bors] - feat(Data/Finset): add Finset.filter_notMem_eq_sdiff, Finset.map_sdiff Jul 23, 2025
@mathlib-bors mathlib-bors Bot closed this Jul 23, 2025
callesonne pushed a commit to callesonne/mathlib4 that referenced this pull request Jul 24, 2025
…diff` (leanprover-community#27340)

`Finset.filter_notMem_eq_sdiff` is the symmetric correspondence of `Finset.filter_mem_eq_inter`.
hrmacbeth pushed a commit to szqzs/mathlib4 that referenced this pull request Jul 28, 2025
…diff` (leanprover-community#27340)

`Finset.filter_notMem_eq_sdiff` is the symmetric correspondence of `Finset.filter_mem_eq_inter`.
Equilibris pushed a commit to Equilibris/mathlib4 that referenced this pull request Aug 7, 2025
…diff` (leanprover-community#27340)

`Finset.filter_notMem_eq_sdiff` is the symmetric correspondence of `Finset.filter_mem_eq_inter`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants