Lean4
/-- `erase a f` is the finitely supported function equal to `f` except at `a` where it is equal to `0`.
If `a` is not in the support of `f` then `erase a f = f`.
-/
def erase (a : α) (f : α →₀ M) : α →₀ M
where
support :=
haveI := Classical.decEq α
f.support.erase a
toFun
a' :=
haveI := Classical.decEq α
if a' = a then 0 else f a'
mem_support_toFun
a' := by
classical
rw [mem_erase, mem_support_iff]; dsimp
split_ifs with h
· exact ⟨fun H _ => H.1 h, fun H => (H rfl).elim⟩
· exact and_iff_right h