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
Closed
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Mathlib/Data/Finsupp/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@ theorem support_update_ne_zero [DecidableEq α] (h : b ≠ 0) :
congr; apply Subsingleton.elim
#align finsupp.support_update_ne_zero Finsupp.support_update_ne_zero

@[simp] theorem update_idem (f : α →₀ M) (a : α) (b c : M) :
eric-wieser marked this conversation as resolved.
Show resolved Hide resolved
update (update f a b) a c = update f a c :=
letI := Classical.decEq α
FunLike.coe_injective <| Function.update_idem _ _ _

end Update

/-! ### Declarations about `erase` -/
Expand Down Expand Up @@ -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

letI := Classical.decEq α
ext fun _ => (Function.update_apply _ _ _ _).symm

-- not `simp` as `erase_of_not_mem_support` can prove this
theorem erase_idem (f : α →₀ M) (a : α) :
erase a (erase a f) = erase a f := by
rw [erase_eq_update, erase_eq_update, update_idem]

@[simp] theorem update_erase (f : α →₀ M) (a : α) (b : M) :
update (erase a f) a b = update f a b := by
eric-wieser marked this conversation as resolved.
Show resolved Hide resolved
rw [erase_eq_update, update_idem]

@[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?

rw [erase_eq_update, erase_eq_update, update_idem]

end Erase

/-! ### Declarations about `onFinset` -/
Expand Down