Zulip Chat Archive

Stream: Is there code for X?

Topic: Extending a finsupp from a type σ to Option σ


Antoine Chambert-Loir (Mar 19 2025 at 23:41):

For e : σ →₀ ℕ and m : ℕ, there is a unique f : Option σ →₀ ℕthat extends e and maps none to m, for example one can set f := embDomain Function.Embedding.some e + Finsupp.single none m. Is there a simpler way to get it?
In particular, that method uses that has an addition, and this is obviously irrelevant.

Antoine Chambert-Loir (Mar 19 2025 at 23:42):

(This is something I fell upon in #20495.)

Eric Wieser (Mar 19 2025 at 23:56):

You can use update instead of addition

Eric Wieser (Mar 19 2025 at 23:57):

But defining this from scratch to be Option.elim is likely better

Antoine Chambert-Loir (Mar 20 2025 at 07:22):

Does it make sense to add the construction and a few lemmas around docs#Finsupp.some ?

Antoine Chambert-Loir (Mar 20 2025 at 08:02):

In any case, I adjusted #20495, see
https://github.com/leanprover-community/mathlib4/blob/3f3d91282978cae413d2503f13799a56a5afc626/Mathlib/Data/Finsupp/Basic.lean#L756-L766


Last updated: May 02 2025 at 03:31 UTC