Zulip Chat Archive

Stream: mathlib4

Topic: Finite Option


Thomas Vigouroux (Jul 25 2024 at 15:07):

Hi, I needed to have Finite (Option T) at some point in a proof, and I ended up writing a proof of that. Is it interesting to have that in lean4 ? I am willing to open a PR

Yaël Dillies (Jul 25 2024 at 15:10):

docs#Finite is in Mathlib. Are you sure you are in the right stream?

Thomas Vigouroux (Jul 25 2024 at 15:10):

Woops probably not indeed

Thomas Vigouroux (Jul 25 2024 at 15:11):

I can't change stream though, do you want me to close this one and open another in #mathlib4 ?

Notification Bot (Jul 25 2024 at 15:13):

This topic was moved here from #lean4 > Finite Option by Floris van Doorn.

Thomas Vigouroux (Jul 25 2024 at 15:14):

Thanks !

Floris van Doorn (Jul 25 2024 at 15:15):

docs#instFintypeOption is probably what you want?

Floris van Doorn (Jul 25 2024 at 15:15):

Oh, you meant actually the Finite version of that. yeah, that would be useful. Please open a PR.

Thomas Vigouroux (Jul 25 2024 at 15:15):

Hmmm, for some reason I could not find it...

Thomas Vigouroux (Jul 25 2024 at 15:16):

Then my question is settled :wink:, thanks !

Notification Bot (Jul 25 2024 at 15:16):

Thomas Vigouroux has marked this topic as resolved.

Floris van Doorn (Jul 25 2024 at 15:17):

I think it is still useful to add a finite instance as well. This now fails:

import Mathlib

variable (T : Type*) [Finite T]
#synth Finite (Option T)

Thomas Vigouroux (Jul 25 2024 at 15:18):

As you wish
I think that my proof of Finite (Option T) is a bit long though

Floris van Doorn (Jul 25 2024 at 15:22):

You should be reusing the existing Fintype instance. Or use docs#finSuccEquiv + docs#Equiv.optionCongr .
But this works:

import Mathlib

instance (T : Type*) [Finite T] : Finite (Option T) :=
  have := Fintype.ofFinite T
  inferInstance

#min_imports -- Mathlib.Data.Fintype.Option

Please PR this!

Notification Bot (Jul 25 2024 at 15:23):

Thomas Vigouroux has marked this topic as unresolved.

Thomas Vigouroux (Jul 25 2024 at 15:23):

Will do !

Thomas Vigouroux (Jul 25 2024 at 15:23):

Will do !

Kevin Buzzard (Jul 25 2024 at 15:33):

@Thomas Vigouroux that's one reason why we don't encourage resolving topics -- it can break stuff :-) But the option is there and can't be switched off so basically it seems to be a hopeless cause.

Thomas Vigouroux (Jul 25 2024 at 15:33):

Sorry about that !

Notification Bot (Jul 25 2024 at 16:14):

Yaël Dillies has marked this topic as unresolved.


Last updated: May 02 2025 at 03:31 UTC