Zulip Chat Archive

Stream: new members

Topic: Proving membership to a set builder


Giovanni Mascellani (Dec 10 2024 at 17:52):

Hi, I am trying to find in mathlib4 some fact similar to x ∈ y ↔ a ∈ Finset.Icc a b ∧ f x given that y is defined as {x ∈ Finset.Icc a b | f x}, but I am failing completely. Anybody could give me a hint? Thanks!

Riccardo Brasca (Dec 10 2024 at 17:56):

Can you write a #mwe? Thanks!

Daniel Weber (Dec 10 2024 at 17:57):

Does docs#Finset.mem_filter work?

import Mathlib

example (f : α  Prop) [DecidablePred f] [Preorder α] [LocallyFiniteOrder α] : x  {x  Finset.Icc a b | f x}  x  Finset.Icc a b  f x := by
  exact Finset.mem_filter

Ruben Van de Velde (Dec 10 2024 at 17:59):

Daniel, I think the goal was to help Giovanni ask questions in a way that's easy to answer :)

Yaël Dillies (Dec 10 2024 at 18:02):

Sorry, we currently don't have unified naming around set builder notation. We'll hopefully get there eventually!

Kyle Miller (Dec 10 2024 at 18:07):

A slight definitional equality abuse in Daniel's suggestion is that it's unfolding the definition of membership and SetOf. To go through rewrites, there's docs#Set.mem_setOf_eq

Daniel Weber (Dec 10 2024 at 18:08):

Kyle Miller said:

A slight definitional equality abuse in Daniel's suggestion is that it's unfolding the definition of membership and SetOf. To go through rewrites, there's docs#Set.mem_setOf_eq

This is a Finset, so there's no setOf here

Giovanni Mascellani (Dec 10 2024 at 18:10):

Ok, I got my answer, but for the future would this have worked as a MWE?

import Mathlib
example (x a b : )
  : x  {x  Finset.Icc a b | 10  x}  x  Finset.Icc a b  10  x := by
  sorry

Relatedly, why doesn't this work? It complains that it cannot synthesize Membership ℕ { x // x ∈ filter (fun x ↦ 10 ∣ x) (Icc a b) }:

import Mathlib
example (x a b : ) (y : {x  Finset.Icc a b | 10  x})
  : x  y  x  Finset.Icc a b  10  x := by
  sorry

Thanks again!

Kyle Miller (Dec 10 2024 at 18:15):

#mwe suggests including imports too; a rule of thumb is that the "view in Lean 4 playground" link in the upper right-hand corner of a code block should work.

Giovanni Mascellani (Dec 10 2024 at 18:16):

Good point, I fixed my MWE.

Daniel Weber (Dec 10 2024 at 18:22):

Giovanni Mascellani said:

Relatedly, why doesn't this work? It complains that it cannot synthesize Membership ℕ { x // x ∈ filter (fun x ↦ 10 ∣ x) (Icc a b) }:

import Mathlib
example (x a b : ) (y : {x  Finset.Icc a b | 10  x})
  : x  y  x  Finset.Icc a b  10  x := by
  sorry

Thanks again!

y : {x ∈ Finset.Icc a b | 10 ∣ x} means that y is a term of type {x ∈ Finset.Icc a b | 10 ∣ x}, which means (approximately) that y is a natural number in the set, so x ∈ y doesn't make sense

Daniel Weber (Dec 10 2024 at 18:22):

(deleted)

Giovanni Mascellani (Dec 10 2024 at 18:29):

Right, rookie mistake!

Riccardo Brasca (Dec 10 2024 at 18:32):

Note that

import Mathlib
example (x a b : ) : x  {x  Finset.Icc a b | 10  x}  x  Finset.Icc a b  10  x := by
  exact?

works, suggesting exact Finset.mem_filter.

Giovanni Mascellani (Dec 10 2024 at 18:53):

Right, I had tried apply?, but probably in a context that was broken for other reasons, and forgot to invalidate my assumption when I got the context right.


Last updated: May 02 2025 at 03:31 UTC