Zulip Chat Archive

Stream: new members

Topic: Fintype.card


Janitha Aswedige (Oct 12 2025 at 07:54):

I'm trying to formalize a group theory theorem.

theorem theorem_groups (G : Type*) [Group G] [Fintype G] (n : )
    (h : (Subgroup.center G).index = n) :
     (x : G), Fintype.card {y : G | IsConj x y}  n := by

When I use Nat.card I don't get any errors. But I want to go with Fintype.card as I might want to apply the orbit stabilizer theorem. How do I fix it?

Kenny Lau (Oct 12 2025 at 07:58):

@Janitha looking at the error message is usually helpful.

Kenny Lau (Oct 12 2025 at 07:58):

in this case it is probably complaining about a lack of the needed Fintype instances

Kenny Lau (Oct 12 2025 at 07:59):

if the instances you need are for the statement, then you should add those instances to the assumption

Kenny Lau (Oct 12 2025 at 08:00):

if it's in the proof, then you provide those instances using Subtype.fintype and the classical tactic

Janitha Aswedige (Oct 12 2025 at 08:07):

@Kenny Lau The error message is for the statement of the theorem. When I replace Fintype.card with Nat.card, Lean doesn't complain.

Error:

failed to synthesize
Fintype { y // IsConj x y }

Kenny Lau (Oct 12 2025 at 08:08):

Janitha said:

When I replace Fintype.card with Nat.card, Lean doesn't complain.

yes, Nat.card can be applied to any type, but Fintype.card requires a fintype instance

Kenny Lau (Oct 12 2025 at 08:08):

so add [\forall x, Fintype { y // IsConj x y }] to your instance if you want to use Fintype.card in the statement

Kenny Lau (Oct 12 2025 at 08:10):

people might not realise this, but getting the statements right can be very difficult at first, it's much easier to start with a correctly formulated statement provided by someone else, and work out the proof yourself

Kenny Lau (Oct 12 2025 at 08:11):

I would advise you to actually not use the Fintype stuff in the statement

Kenny Lau (Oct 12 2025 at 08:11):

use Nat.card and replace the Fintype G assumption with Finite G.

Robin Arnez (Oct 12 2025 at 08:12):

With Nat.card and Finite in the statement, you can then start the proof with:

classical
have := Fintype.ofFinite G
simp only [Nat.card_eq_fintype_card]

to get it back to how you had it before

Janitha Aswedige (Oct 12 2025 at 08:13):

Thanks! That fixed it.

theorem theorem_groups (G : Type*) [Group G] [Fintype G] [ x : G, Fintype { y // IsConj x y }] (n : )
    (h : (Subgroup.center G).index = n):
     (x : G), Fintype.card {y : G // IsConj x y}  n := by

If I use Nat.card and replaced the Fintype G assumption with Finite G, how would I use a theorem that uses Fintype.card in its statement?

Kenny Lau (Oct 12 2025 at 08:13):

read the message above you

Kenny Lau (Oct 12 2025 at 08:14):

basically, Lean needs to be guided in every way (as you probably know), and one of the things that is obvious to mathematicians but not to Lean is when things are finite

Kenny Lau (Oct 12 2025 at 08:14):

you need to tell Lean why certain things are finite

Kenny Lau (Oct 12 2025 at 08:14):

as you'll discover very soon

Janitha Aswedige (Oct 12 2025 at 08:38):

@Kenny Lau and @Robin Arnez I completed the proof. Thank you!

Kenny Lau (Oct 12 2025 at 08:38):

well done!

Ruben Van de Velde (Oct 12 2025 at 08:44):

Oh, does docs#Subtype.fintype not fire because of the decidability argument?

Kenny Lau (Oct 12 2025 at 08:45):

yeah, nothing works automatically there

Ruben Van de Velde (Oct 12 2025 at 08:48):

Right, if you add [DecidableEq G], everything works

Kenny Lau (Oct 12 2025 at 08:48):

well, you shouldn't add it to the statement

Ruben Van de Velde (Oct 12 2025 at 08:50):

Sure, yours is more general

Ruben Van de Velde (Oct 12 2025 at 08:50):

Anyway, this is why I use Nat.card

Kenny Lau (Oct 12 2025 at 08:51):

indeed, but the orbit stabiliser theorem is stated with Fintype.card, which should be updated

Ruben Van de Velde (Oct 12 2025 at 08:51):

I'll review your PR to do so (if I don't forget or get distracted) :)

Kenny Lau (Oct 12 2025 at 08:51):

@Janitha do you want to try this?

Janitha Aswedige (Oct 12 2025 at 09:01):

@Kenny Lau please tell me what you want me to try?

Kenny Lau (Oct 12 2025 at 09:02):

@Janitha state and prove a version of MulAction.card_orbit_mul_card_stabilizer_eq_card_group using Nat.card and PR that to mathlib

Janitha Aswedige (Oct 12 2025 at 09:02):

@Kenny Lau sure, I can try that.

Aaron Liu (Oct 12 2025 at 10:02):

Kenny Lau said:

indeed, but the orbit stabiliser theorem is stated with Fintype.card, which should be updated

why? Is the statement wrong?

Kenny Lau (Oct 12 2025 at 10:03):

well Nat.card is more general

Aaron Liu (Oct 12 2025 at 10:07):

not really?

Aaron Liu (Oct 12 2025 at 10:07):

it's the same thing but with junk values

Kenny Lau (Oct 12 2025 at 10:09):

it requires less instances to state, is the main point

Kenny Lau (Oct 12 2025 at 10:09):

e.g. see FiniteField.orderOf_frobeniusAlgHom

Kenny Lau (Oct 12 2025 at 10:10):

K is fintype and L is finite, because the statement talks about frobenius, which requires K to be fintype

Kenny Lau (Oct 12 2025 at 10:10):

but L doesn't need to be fintype, so it should just be finite

Kenny Lau (Oct 12 2025 at 10:10):

now i think frobenius should be updated to only require finite, but that's another PR

Kenny Lau (Oct 12 2025 at 10:11):

@Ruben Van de Velde would you review a PR to change FiniteField.frobeniusAlgHom to finite?

Kenny Lau (Oct 12 2025 at 10:12):

hmm, ok maybe that needs to be considered first, because using Nat.card does make it noncomputable

Aaron Liu (Oct 12 2025 at 10:25):

Kenny Lau said:

but L doesn't need to be fintype, so it should just be finite

That's different, since we aren't computing its card or anything

Aaron Liu (Oct 12 2025 at 10:26):

it just needs to be finite

Kenny Lau (Oct 12 2025 at 10:26):

Module.finrank K L is computing its card tho

Aaron Liu (Oct 12 2025 at 10:27):

that has always been noncomputable

Aaron Liu (Oct 12 2025 at 10:28):

and it's not really possible to make it computable either

Aaron Liu (Oct 12 2025 at 10:28):

since it needs to work with infinite modules over infinite rings

Kenny Lau (Oct 12 2025 at 10:29):

well, MulAction.orbit likewise never has a computable cardinality


Last updated: Dec 20 2025 at 21:32 UTC