Zulip Chat Archive
Stream: lean4
Topic: Existential quantifier set mem
Brandon Brown (May 18 2021 at 15:15):
In Lean3 there is the shorthand ∃ x ∈ s, p
for some set S and Prop P, which gets translated to under-the-hood. Has anyone implemented this in Lean4 yet?∃ x, x ∈ s ∧ p
Patrick Massot (May 18 2021 at 15:22):
Note this is not what it gets translated to in Lean 3.
Patrick Massot (May 18 2021 at 15:23):
example {α : Type*} {s : set α} {p : Prop} : (∃ x ∈ s, p) ↔ ∃ x, x ∈ s ∧ p :=
iff.rfl -- fails
example {α : Type*} {s : set α} {p : Prop} : (∃ x ∈ s, p) ↔ ∃ (x : α) (h : x ∈ s), p :=
iff.rfl -- works
Brandon Brown (May 18 2021 at 15:24):
Ah thanks
Patrick Massot (May 18 2021 at 15:25):
I'm sorry this isn't answering your question at all, but I thought it was good to know.
Brandon Brown (May 18 2021 at 15:25):
Definitely good to know!
Mario Carneiro (May 18 2021 at 16:17):
Brandon Brown said:
Has anyone implemented this in Lean4 yet?
Kevin implemented something similar to this in his Data.Set.Basic
Kevin Buzzard (May 18 2021 at 16:39):
I stole all of this stuff from other people. Maybe it was @Jason KY. who actually wrote this?
Kevin Buzzard (May 18 2021 at 16:41):
Here's a link. Note that hasLessEq
changed to LE
recently. I will probably port this code to the official mathlib4 repo on Thursday.
Jason KY. (May 18 2021 at 16:44):
| `(∃ $x:ident ∈ $s, $p) => `(∃ $x:ident, $x ∈ $s ∧ $p)`
It seems that I wrote shorthand Brandon is thinking about instead of the lean3 version
Kevin Buzzard (May 18 2021 at 16:45):
Thanks for pointing this out! I will almost certainly change it to the Lean 3 version on Thursday (if I can figure out how to) (hopefully you'll be at Xena Jason :D)
Mario Carneiro (May 18 2021 at 17:38):
The exists-and version is better than exists-exists, but this was a limitation of the way the lean 3 desugaring works
Mario Carneiro (May 18 2021 at 17:39):
the limitation of the lean 4 desugaring is that it has to be defined individually for all binops and binders
Mario Carneiro (May 18 2021 at 17:45):
By the way this macro in Data.Set.Basic
is wrong:
| `({ $x:ident ∈ $s | $p }) => `(setOf (λ $x => $x ∈ $s → $p))
it should use ∧
on the rhs
Eric Wieser (May 18 2021 at 18:13):
So that means every new binder has to introduce new notation for its interaction with le
and mem
?
Eric Wieser (May 18 2021 at 18:14):
Even if that interaction is always "just nest the binders"
Mario Carneiro (May 18 2021 at 18:29):
I think it is possible to separate the two, using something like the index
syntax class introduced in Data.Set.Basic
, but right now the binder group syntax class is rather underdeveloped, I don't think we are ready to handle the desugaring of \exists (x \in A) (y \in B), p
yet
Patrick Massot (May 18 2021 at 18:35):
Mario Carneiro said:
The exists-and version is better than exists-exists, but this was a limitation of the way the lean 3 desugaring works
Oh yes, the Lean 3 version is very painful for teaching. Things got better only thanks to #5440
Last updated: Dec 20 2023 at 11:08 UTC