Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat: missing lemmas about Finsupp.update #9316

Closed
wants to merge 7 commits into from

Conversation

eric-wieser
Copy link
Member


Open in Gitpod

@eric-wieser eric-wieser added awaiting-review The author would like community review of the PR awaiting-CI labels Dec 28, 2023
Mathlib/Data/Finsupp/Defs.lean Outdated Show resolved Hide resolved
Mathlib/Data/Finsupp/Defs.lean Outdated Show resolved Hide resolved
@eric-wieser eric-wieser added the easy < 20s of review time. See the lifecycle page for guidelines. label Dec 28, 2023
@@ -673,6 +678,22 @@ theorem erase_zero (a : α) : erase a (0 : α →₀ M) = 0 := by
classical rw [← support_eq_empty, support_erase, support_zero, erase_empty]
#align finsupp.erase_zero Finsupp.erase_zero

theorem update_eq_erase (f : α →₀ M) (a : α) : update f a 0 = f.erase a :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

wouldn't the name update_zero_eq_erase be more explicit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or perhaps erase_eq_update(_zero) after flipping the direction?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. For a surprising reason, the absence of zero doesn't disturb me in the other direction.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've gone for reversing it then

@AntoineChambert-Loir
Copy link
Collaborator

CI/Build fails at Mathlib/Data/Finsupp/Defs.lean:685:9:
error: Finsupp.erase_idem.{u_5, u_1} simp can prove this
I don't how how to fix that except by removing the @[simp] tag before the function.

@jcommelin
Copy link
Member

Thanks 🎉

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review The author would like community review of the PR labels Jan 1, 2024
@@ -673,6 +678,23 @@ theorem erase_zero (a : α) : erase a (0 : α →₀ M) = 0 := by
classical rw [← support_eq_empty, support_erase, support_zero, erase_empty]
#align finsupp.erase_zero Finsupp.erase_zero

theorem erase_eq_update (f : α →₀ M) (a : α) : f.erase a = update f a 0 :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
theorem erase_eq_update (f : α →₀ M) (a : α) : f.erase a = update f a 0 :=
theorem erase_eq_update_zero (f : α →₀ M) (a : α) : f.erase a = update f a 0 :=

for discoverability. I would even consider

Suggested change
theorem erase_eq_update (f : α →₀ M) (a : α) : f.erase a = update f a 0 :=
@[simp]
theorem update_zero_eq_erase (f : α →₀ M) (a : α) : f.erase a = update f a 0 :=

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you mean to flip the direction in that last one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that there was already discussion about this in #9316 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, sorry, I meant it flipped

Mathlib/Data/Finsupp/Defs.lean Outdated Show resolved Hide resolved
Comment on lines 694 to 695
@[simp] theorem erase_update (f : α →₀ M) (a : α) (b : M) :
erase a (update f a b) = erase a f := by
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@[simp] theorem erase_update (f : α →₀ M) (a : α) (b : M) :
erase a (update f a b) = erase a f := by
@[simp] theorem erase_update_self (f : α →₀ M) (a : α) (b : M) :
erase a (update f a b) = erase a f := by

Copy link
Member Author

@eric-wieser eric-wieser Jan 1, 2024

Choose a reason for hiding this comment

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

On Finset this is called erase_insert_eq_erase; shall I change to erase_update_eq_erase?

@eric-wieser
Copy link
Member Author

bors r-

@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jan 1, 2024

Canceled.

@YaelDillies YaelDillies added awaiting-author A reviewer has asked the author a question or requested changes and removed ready-to-merge This PR has been sent to bors. labels Jan 1, 2024
@YaelDillies
Copy link
Collaborator

I think you should

  • add update_erase : update (erase a f) a (f a) = f
  • reverse erase_eq_update_zero to update_zero_eq_erase

Then I'm happy.

@YaelDillies
Copy link
Collaborator

I have been convinced otherwise in DMs.

maintainer merge

Copy link

github-actions bot commented Jan 1, 2024

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

@eric-wieser
Copy link
Member Author

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-author A reviewer has asked the author a question or requested changes labels Jan 1, 2024
mathlib-bors bot pushed a commit that referenced this pull request Jan 1, 2024
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jan 2, 2024

Pull request successfully merged into master.

Build succeeded!

And happy new year! 🎉

@mathlib-bors mathlib-bors bot changed the title feat: missing lemmas about Finsupp.update [Merged by Bors] - feat: missing lemmas about Finsupp.update Jan 2, 2024
@mathlib-bors mathlib-bors bot closed this Jan 2, 2024
@mathlib-bors mathlib-bors bot deleted the eric-wieser/finsupp-update-lemmas branch January 2, 2024 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy < 20s of review time. See the lifecycle page for guidelines. ready-to-merge This PR has been sent to bors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants