Zulip Chat Archive

Stream: new members

Topic: Confused by finiteness


Philippe Duchon (Nov 06 2025 at 16:14):

I am confused about the various notions of finiteness (or is it by coercions?).

In the following example, hovering over the proof state tells me that fixedPoints f is indeed a Set α as I expected, so I don't understand why rewriting fails (there is a long error message but I don't understand it)

import Mathlib

open Function

theorem hcfp (α: Type) [Fintype α] [DecidableEq α] {f: α  α}
  (h: fixedPoints f = ) : Fintype.card (fixedPoints f) = 0 := by
  rw [h]
  sorry

In my original code f had type Equiv.Perm α so that there was an additional coercion to α → α, but this doesn't seem to be the source of the problem.

(Also, I notice there are two different symbols for coercions, and ; I don't think I understand the difference between the two.)

Kevin Buzzard (Nov 06 2025 at 16:22):

(there is a long error message but I don't understand it)

Post it anyway! Plenty of people here will understand it!

Tactic `rewrite` failed: motive is not type correct:
  fun _a => Fintype.card ↑_a = 0

The answer is that you're in constructivist hell. If you're not a constructivist then you can use Nat.card instead of Fintype.card and then the rewrite works fine and you can solve the resulting goal with simp. Or are you specifically interested in a constructivist solution?

Kevin Buzzard (Nov 06 2025 at 16:23):

is speficially for coercion to functions (e.g. from a monoid homomorphism to a function), and is a generic coercion.

Eric Wieser (Nov 06 2025 at 16:25):

rw! (castMode := .all) [h] works

Eric Wieser (Nov 06 2025 at 16:26):

as does simp [h]

Philippe Duchon (Nov 06 2025 at 16:41):

Thanks!

I would certainly not define myself as a constructivist, but I was on the way to using Equiv.Perm.card_fixedPoints, which uses Fintype.card, so that was what I tried to use.

Good to know that simp [h] works - but it still looks a little like black magic to me.

Kevin Buzzard (Nov 06 2025 at 23:04):

Lean doesn't do magic and there's certainly an explanation, but it's technical. I believe that there is some extension of rw in the works that will simply work and not give you this obscure error.

Aaron Liu (Nov 06 2025 at 23:11):

I just remembered there's a better way to do this

import Mathlib

open Function

theorem hcfp (α : Type) [Fintype α] [DecidableEq α] {f : α  α}
    (h : fixedPoints f = ) : Fintype.card (fixedPoints f) = 0 :=
  Fintype.card_congr' (congrArg Set.Elem h)

Antoine Chambert-Loir (Nov 06 2025 at 23:20):

In what sense is it better?

Aaron Liu (Nov 06 2025 at 23:22):

I don't know

Aaron Liu (Nov 06 2025 at 23:22):

it just seemed like using the dedicated lemma would be better


Last updated: Dec 20 2025 at 21:32 UTC