Zulip Chat Archive

Stream: Is there code for X?

Topic: Finsupp generalisations


Sky Wilshaw (Oct 23 2022 at 21:57):

Is there a generalisation of finsupp to things like option or has_bot?

Kevin Buzzard (Oct 23 2022 at 22:11):

What do you mean?

Yaël Dillies (Oct 23 2022 at 22:11):

Finitely supported functions where the support is everything that not "something".

Sky Wilshaw (Oct 23 2022 at 22:13):

Yeah, more precisely, a structure with fields something like

(support : finset α)
(to_fun : α  option M)
(mem_support_to_fun :  (a : α), a  self.support  self.to_fun a  none)

but with all the API that goes alongside finsupp.

Sky Wilshaw (Oct 23 2022 at 22:14):

It's probably rather easy to construct the equivalence to finsupp α (with_zero M) and transport all the lemmas across if I need them,

Sky Wilshaw (Oct 23 2022 at 22:14):

but if the API already exists that would of course be a little nicer.

Kevin Buzzard (Oct 23 2022 at 22:16):

Oh I'm finally there! You want the target to be the option.

Matt Diamond (Oct 23 2022 at 23:50):

would it make sense to have a has_zero instance for option M? or would that conflict with the existing with_zero and with_one functions?

Matt Diamond (Oct 23 2022 at 23:56):

on a side note, this doesn't seem right: image.png

Matt Diamond (Oct 23 2022 at 23:57):

might have to do with the @[to_additive] on the repr for one

Matt Diamond (Oct 23 2022 at 23:59):

@Yaël Dillies I think you added these instances... am I missing something or is there duplication here?

Eric Wieser (Oct 24 2022 at 00:01):

That looks like a mistake indeed

Eric Wieser (Oct 24 2022 at 00:01):

Matt Diamond said:

would it make sense to have a has_zero instance for option M? or would that conflict with the existing with_zero and with_one functions?

I think a better approach would be to redefine finsupp A B as finsupp' A B 0 or something, if we want to go down this path.

Matt Diamond (Oct 24 2022 at 00:02):

makes sense... that would certainly be more flexible

Yaël Dillies (Oct 24 2022 at 07:20):

Whoops! You're right I added one too many.

Sky Wilshaw (Oct 24 2022 at 12:56):

This is a refactor I think I'd be comfortable trying to do if other people think this is a good idea.

Junyan Xu (Oct 24 2022 at 13:31):

Note that #16160 is a similar refactor (and accidentally the goal #15161 is something related to finsupp).

Sky Wilshaw (Oct 26 2022 at 18:15):

I'd like to start writing this PR. The documentation says that I should ask for write access to non-master mathlib branches - could someone please do this for me? My GitHub username is zeramorphic.

Ruben Van de Velde (Oct 26 2022 at 18:21):

@maintainers

Johan Commelin (Oct 26 2022 at 19:02):

@Sky Wilshaw Invitation sent: https://github.com/leanprover-community/mathlib/invitations

Sky Wilshaw (Oct 26 2022 at 19:03):

Thank you!


Last updated: Dec 20 2023 at 11:08 UTC