Zulip Chat Archive

Stream: Is there code for X?

Topic: Bijection between Finset and Fin n


Swarnava Chakraborty (Apr 05 2025 at 14:11):

Is there any way I can construct an explicit bijection between Finset and Fin n , where n is the cardinality of the Finset? Does it already exist?

Riccardo Brasca (Apr 05 2025 at 14:13):

What do you mean by "explicit"? Anyway we have Finset.equivFin and friends.

Riccardo Brasca (Apr 05 2025 at 14:15):

If you want to actually compute with it there is Fintype.truncEquivFin

Swarnava Chakraborty (Apr 06 2025 at 11:46):

Thanks. I am new to Lean and do not really understand the function type notation.My question was how to construct a bijection. What equivFin does is I think gives all the possible bijections, right?

Edward van de Meent (Apr 06 2025 at 11:53):

it does not. it just uses choice to get one

Edward van de Meent (Apr 06 2025 at 11:57):

the notation refers to docs#Equiv, which is a datastructure containing maps either way and a proof that these are left and right inverse to eachother. This means that equivFin contains a map s -> Fin s.card and a map Fin s.card -> s which are eachothers inverse. it produces this map by using choice, so there is no telling what 0:Fin s.card concretely maps to in s.

Edward van de Meent (Apr 06 2025 at 12:07):

truncEquivFin refers to the fact that, because Fintype stores the concrete elements of the type up to permutation, if you choose a permutation, you can also computably get a concrete bijection. This allows for making computable functions which evaluate such a bijection, so long as the return value doesn't change no matter which bijection you pick.


Last updated: May 02 2025 at 03:31 UTC