Conversation
ctchou
reviewed
Apr 7, 2026
| namespace Cslib.FinFun | ||
|
|
||
| /-- `FinFun` equivalent of `Function.update`. -/ | ||
| def update [Zero β] [DecidableEq α] [∀ b : β, Decidable (b = 0)] (f : α →₀ β) (a : α) (b : β) : |
Collaborator
There was a problem hiding this comment.
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 |
Collaborator
There was a problem hiding this comment.
Are these two theorems really necessary given update_support above?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
FinFun.updateand proves some basic results about the functional interface and support of the resulting function.