Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat(frontends/lean/brackets): notation for set replacement #402

Closed
wants to merge 3 commits into from

Conversation

Vierkantor
Copy link
Collaborator

As discussed on Zulip.

This PR introduces notation for set replacement, so that {(f x) | x ∈ s} is equivalent to set.image f s. More generally, {(expr) | binders} parses to something like set_of (λ _x, ∃ binders, expr = _x). The expression needs to be between parentheses to ensure it is not ambiguous with the { id | predicate } notation for separation and to decrease the amount of backtracking. Expressions of the form {(x, y) | (x y : ℕ) (p : x + y < 10)} also work as expected.

@gebner
Copy link
Member

gebner commented Jul 22, 2020

I like it, and the implementation looks good. Is set_of ... the term that we want?

@fpvandoorn
Copy link
Member

{(f x) | x ∈ s} is equivalent to set.image f s

Too bad they are not definitionally equal. But I guess we can have simp lemmas rewriting them.

@Vierkantor
Copy link
Collaborator Author

{(f x) | x ∈ s} is equivalent to set.image f s

Too bad they are not definitionally equal. But I guess we can have simp lemmas rewriting them.

The issue is that the notation expands to ∃ (h : x ∈ s), ... instead of x ∈ s \and ..., right? simp should already fix that with the exists_prop lemma.

@gebner
Copy link
Member

gebner commented Jul 23, 2020

Another option would be to move set.image to the core library. I can't tell at first glance if this would make things easier or harder.

bors r+

bors bot pushed a commit that referenced this pull request Jul 23, 2020
[As discussed on Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Lean.204.20notation).

This PR introduces notation for set replacement, so that `{(f x) | x ∈ s}` is equivalent to `set.image f s`. More generally, `{(expr) | binders}` parses to something like `set_of (λ _x, ∃ binders, expr = _x)`. The expression needs to be between parentheses to ensure it is not ambiguous with the `{ id | predicate }` notation for separation and to decrease the amount of backtracking. Expressions of the form `{(x, y) | (x y : ℕ) (p : x + y < 10)}` also work as expected.
@bors
Copy link

bors bot commented Jul 23, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(frontends/lean/brackets): notation for set replacement [Merged by Bors] - feat(frontends/lean/brackets): notation for set replacement Jul 23, 2020
@bors bors bot closed this Jul 23, 2020
@bors bors bot deleted the set_replacement branch July 23, 2020 10:09
@fpvandoorn
Copy link
Member

Another option would be to move set.image to the core library. I can't tell at first glance if this would make things easier or harder.

set.image is already in core: https://github.com/leanprover-community/lean/blob/05d7184/library/init/data/set.lean#L83

{(f x) | x ∈ s} is equivalent to set.image f s

Too bad they are not definitionally equal. But I guess we can have simp lemmas rewriting them.

The issue is that the notation expands to ∃ (h : x ∈ s), ... instead of x ∈ s \and ..., right? simp should already fix that with the exists_prop lemma.

Correct, then you get something definitionally equal, but presumably you want to actually rewrite it to set.image instead of (the definiens of set.image)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants