Zulip Chat Archive

Stream: general

Topic: Sets


Wouter Smeenk (Jul 16 2023 at 11:56):

Why is Set ℤ needed here:

import Mathlib.Init.Set

variable {x₁ x₂ x₃
          x₄ x₅ x₆
          x₇ x₈ x₉ s: }

example :  x, x  ({ x₁, x₂, x₃,
                      x₄, x₅, x₆,
                      x₇, x₈, x₉ } : Set )   x = x  False := by
    sorry

If I replace Set ℤ with _ I get:

typeclass instance problem is stuck, it is often due to metavariables
  Insert  (?m.270 x)

Why is this? Is there a better way to create this statement? I want to state something which holds for each of the variables.

Eric Wieser (Jul 16 2023 at 12:01):

Without Set ℤ lean doesn't know whether you mean Set or Finset

Henrik Böving (Jul 16 2023 at 12:01):

Its because all of the notation that you have here is generic. The element of notation can for example also be used for lists and the collection notation could also be used for collections other than mathematical sets (like say HashSets) so Lean cannot know without you telling it that you actually mean a mathematical set here.

For an alternative way you could always use a list and fold over that I guess? But the actual mathlib users might have a better idea

Wouter Smeenk (Jul 16 2023 at 12:10):

Ah this does work indeed:

example :  x, x  [ x₁, x₂, x₃,
                     x₄, x₅, x₆,
                     x₇, x₈, x₉ ]   x = x  False := by
    sorry

Eric Wieser (Jul 16 2023 at 13:02):

What's the problem with your original version?

Wouter Smeenk (Jul 16 2023 at 13:18):

It is more verbose with the Set Z.

Eric Wieser (Jul 16 2023 at 13:38):

Sure, but it's probably easier to prove things about


Last updated: Dec 20 2023 at 11:08 UTC