-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontends/lean/brackets): notation for set replacement (#402)
[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.
- Loading branch information
1 parent
05cabbd
commit f14974c
Showing
5 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
def successors : set nat := {(x + 1) | x : nat} | ||
lemma successors_correct : successors = {x | ∃ y, y + 1 = x} := rfl | ||
|
||
variables {x' : nat} | ||
|
||
def successors' : set nat := {(x' + 1) | x'} | ||
lemma successors_correct' : successors = successors' := rfl | ||
|
||
def x'' := 0 | ||
|
||
def successors'' : set nat := {(x'' + 1) | x''} | ||
lemma successors_correct'' : successors = successors'' := rfl | ||
|
||
def f : nat -> nat := λ x, x + 1 | ||
|
||
def successors''' : set nat := {(f x) | x} | ||
lemma successors_correct''' : successors = successors''' := rfl | ||
|
||
def between_1_and_5 : set nat := {(x + 1) | x < 5} | ||
lemma between_1_and_5_correct : | ||
between_1_and_5 = {y | ∃ (x : nat) (h : x < 5), x + 1 = y} := rfl | ||
|
||
def triangle : set (nat × nat) := {(x, y) | (x y) (h : x + y < 5)} | ||
lemma triangle_correct : | ||
triangle = {xy | ∃ (x y : nat) (h : x + y < 5), (x, y) = xy} := rfl | ||
|
Empty file.