Zulip Chat Archive

Stream: Is there code for X?

Topic: card of subtype of fintype


David Renshaw (Aug 31 2023 at 19:38):

I'm having difficulty proving foo:

import Mathlib.Data.Fintype.Card
import Mathlib.Data.Finite.Basic

inductive Color : Type where
| red : Color
| blue : Color

theorem foo
    {α : Type} [DecidableEq α] [Fintype α] (n : ) (hs : Fintype.card α = 0)
    : @Fintype.card
       { a : Finset α // (λ s  Color.red) a = Color.red } (Fintype.ofFinite _) = 1 := by
  sorry

It seems like this should be easy -- given a type of cardinality 1, the trivial subtype that takes every element should also have cardinality 1.
But there seem to be issues about definitional equality among various typeclass instances.

Eric Wieser (Aug 31 2023 at 19:40):

What's the reason for the Fintype.ofFinite there?

Eric Wieser (Aug 31 2023 at 19:42):

Isn't the LHS 2 not 1, since there are 212^1 sets?

David Renshaw (Aug 31 2023 at 19:54):

oops

David Renshaw (Aug 31 2023 at 19:54):

corrected -- I meant that Fintype.card α = 0.

David Renshaw (Aug 31 2023 at 19:55):

so there is 20=12^0 = 1 set

David Renshaw (Aug 31 2023 at 19:56):

The Fintype.ofFinite is needed because if I don't explicitly provide an instance I get

failed to synthesize instance
  Fintype { a // (fun s => Color.red) a = Color.red }

Kyle Miller (Aug 31 2023 at 20:04):

You can derive a DecidableEq instance to clean up that Fintype.card:

inductive Color : Type where
  | red : Color
  | blue : Color
  deriving DecidableEq

theorem foo
    {α : Type} [DecidableEq α] [Fintype α] (n : ) (hs : Fintype.card α = 0) :
    Fintype.card { a : Finset α // (λ s  Color.red) a = Color.red } = 1 := by
  sorry

David Renshaw (Aug 31 2023 at 20:07):

ok, so simpler version:

import Mathlib.Data.Fintype.Card
import Mathlib.Data.Finite.Basic

inductive Color : Type where
| red : Color
| blue : Color
deriving DecidableEq

theorem foo'
    {α : Type} [DecidableEq α] [Fintype α] (hs : Fintype.card α = 1)
    : Fintype.card
       { a : α // (λ s  Color.red) a = Color.red } = 1 := by
  sorry

Kyle Miller (Aug 31 2023 at 20:11):

Here's a horrible proof that's at least a proof:

theorem foo
    {α : Type} [DecidableEq α] [Fintype α] (n : ) (hs : Fintype.card α = 0) :
    Fintype.card { a : Finset α // (λ s  Color.red) a = Color.red } = 1 := by
  simp
  convert_to Fintype.card Set.univ = 1
  simp only [Fintype.card_ofFinset, Finset.mem_univ, forall_true_left, forall_const,
    Finset.filter_true_of_mem]
  convert_to Fintype.card (Finset α) = 1
  simp [hs]

Eric Wieser (Aug 31 2023 at 20:43):

For the simpler one:

theorem foo'
    {α : Type} [DecidableEq α] [Fintype α] (hs : Fintype.card α = 1)
    : Fintype.card
       { a : α // (λ s  Color.red) a = Color.red } = 1 := by
  simpa [Fintype.card_subtype, Finset.card_univ]

David Renshaw (Aug 31 2023 at 21:24):

The big stumbling block for me here was the deriving DecidableEq.

Kevin Buzzard (Aug 31 2023 at 21:28):

(two $$ for LaTeX btw)


Last updated: Dec 20 2023 at 11:08 UTC