Skip to content

feat: update operation for FinFun#470

Open
fmontesi wants to merge 4 commits intomainfrom
finfun-update
Open

feat: update operation for FinFun#470
fmontesi wants to merge 4 commits intomainfrom
finfun-update

Conversation

@fmontesi
Copy link
Copy Markdown
Collaborator

@fmontesi fmontesi commented Apr 6, 2026

This PR adds FinFun.update and proves some basic results about the functional interface and support of the resulting function.

@fmontesi fmontesi requested a review from chenson2018 as a code owner April 6, 2026 12:15
namespace Cslib.FinFun

/-- `FinFun` equivalent of `Function.update`. -/
def update [Zero β] [DecidableEq α] [∀ b : β, Decidable (b = 0)] (f : α →₀ β) (a : α) (b : β) :
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.

I wonder if it is worthwhile to introduce a DecidableEqZero class, as the pattern [∀ b : β, Decidable (b = 0)] appears so many times in FinFun.

Comment on lines +67 to +76
/-- Updating a function with a nonempty element yields the same support with, possibly, the addition
of the key. -/
@[scoped grind .]
theorem update_neq_zero_support_eq_union [Zero β] [DecidableEq α] [∀ b : β, Decidable (b = 0)]
(f : α →₀ β) (h : b ≠ 0) :
(f.update a b).support = f.support ∪ {a} := by grind

/-- Updating a key in the support with a nonempty element preserves the support. -/
theorem update_neq_zero_support_eq [Zero β] [DecidableEq α] [∀ b : β, Decidable (b = 0)]
(f : α →₀ β) (h₁ : f a ≠ 0) (h₂ : b ≠ 0) : (f.update a b).support = f.support := by grind
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.

Are these two theorems really necessary given update_support above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants