Zulip Chat Archive

Stream: new members

Topic: Where is `deriving Fintype` defined?


Michael Fishman (Jun 19 2024 at 15:21):

I want to understand how deriving Fintype creates elems and complete.

How can I find that code?

More generally, for any class, how can I find the code that defines what happens when we deriving that class?

Matthew Ballard (Jun 19 2024 at 15:25):

docs#Lean.Elab.elabDeriving is a good plan to start pulling

Michael Fishman (Jun 19 2024 at 15:26):

Thanks!

Kyle Miller (Jun 19 2024 at 16:48):

https://github.com/leanprover-community/mathlib4/blob/master/Mathlib/Tactic/DeriveFintype.lean

Kyle Miller (Jun 19 2024 at 16:50):

It uses docs#Fintype.ofEquiv with the proxy_equiv% elaborator (see the imports).

Kyle Miller (Jun 19 2024 at 16:52):

This is the main code. The next function is just to make an efficient Fintype instance with a known-at-compile-time list of all elements for "enum" inductive types (types whose constructors all have no arguments).


Last updated: May 02 2025 at 03:31 UTC