Skip to content

Commit 2a17457

Browse files
committed
feat: missing lemmas about Finsupp.update (#9316)
1 parent 16877b9 commit 2a17457

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Mathlib/Data/Finsupp/Defs.lean

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,23 @@ theorem support_update_ne_zero [DecidableEq α] (h : b ≠ 0) :
600600
congr; apply Subsingleton.elim
601601
#align finsupp.support_update_ne_zero Finsupp.support_update_ne_zero
602602

603+
theorem support_update_subset [DecidableEq α] [DecidableEq M] :
604+
support (f.update a b) ⊆ insert a f.support := by
605+
rw [support_update]
606+
split_ifs
607+
· exact (erase_subset _ _).trans (subset_insert _ _)
608+
· rfl
609+
610+
theorem update_comm (f : α →₀ M) {a₁ a₂ : α} (h : a₁ ≠ a₂) (m₁ m₂ : M) :
611+
update (update f a₁ m₁) a₂ m₂ = update (update f a₂ m₂) a₁ m₁ :=
612+
letI := Classical.decEq α
613+
FunLike.coe_injective <| Function.update_comm h _ _ _
614+
615+
@[simp] theorem update_idem (f : α →₀ M) (a : α) (b c : M) :
616+
update (update f a b) a c = update f a c :=
617+
letI := Classical.decEq α
618+
FunLike.coe_injective <| Function.update_idem _ _ _
619+
603620
end Update
604621

605622
/-! ### Declarations about `erase` -/
@@ -673,6 +690,28 @@ theorem erase_zero (a : α) : erase a (0 : α →₀ M) = 0 := by
673690
classical rw [← support_eq_empty, support_erase, support_zero, erase_empty]
674691
#align finsupp.erase_zero Finsupp.erase_zero
675692

693+
theorem erase_eq_update_zero (f : α →₀ M) (a : α) : f.erase a = update f a 0 :=
694+
letI := Classical.decEq α
695+
ext fun _ => (Function.update_apply _ _ _ _).symm
696+
697+
-- The name matches `Finset.erase_insert_of_ne`
698+
theorem erase_update_of_ne (f : α →₀ M) {a a' : α} (ha : a ≠ a') (b : M) :
699+
erase a (update f a' b) = update (erase a f) a' b := by
700+
rw [erase_eq_update_zero, erase_eq_update_zero, update_comm _ ha]
701+
702+
-- not `simp` as `erase_of_not_mem_support` can prove this
703+
theorem erase_idem (f : α →₀ M) (a : α) :
704+
erase a (erase a f) = erase a f := by
705+
rw [erase_eq_update_zero, erase_eq_update_zero, update_idem]
706+
707+
@[simp] theorem update_erase_eq_update (f : α →₀ M) (a : α) (b : M) :
708+
update (erase a f) a b = update f a b := by
709+
rw [erase_eq_update_zero, update_idem]
710+
711+
@[simp] theorem erase_update_eq_erase (f : α →₀ M) (a : α) (b : M) :
712+
erase a (update f a b) = erase a f := by
713+
rw [erase_eq_update_zero, erase_eq_update_zero, update_idem]
714+
676715
end Erase
677716

678717
/-! ### Declarations about `onFinset` -/

0 commit comments

Comments
 (0)