-
Notifications
You must be signed in to change notification settings - Fork 356
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: Finset builder notation #11582
Conversation
777235c to
d9f35cb
Compare
c55d1dc to
d5acd6e
Compare
|
The new notations here intersect a lot with the notations introduced by #6795, so I'm thinking I should be creating a new syntax category |
f7d2f35 to
cad709c
Compare
PR summary 985d7de269
|
| File | Base Count | Head Count | Change |
|---|---|---|---|
| Mathlib.Init.Set | 1 | 2 | +1 (+100.00%) |
Import changes for all files
| Files | Import difference |
|---|---|
Mathlib.Init.Set |
1 |
Declarations diff
+ elabFinsetBuilderIxx
+ elabFinsetBuilderSep
+ elabFinsetBuilderSetOf
+ elabSetBuilder
+ knownToBeFinsetNotSet
You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>The doc-module for script/declarations_diff.sh contains some details about this script.
Given that this is completely orthogonal to the current PR, I will do that in a later PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Generally looks clean to me. Here are some remaining comments
Co-authored-by: Jon Eugster <eugster.jon@gmail.com>
|
maintainer merge |
|
🚀 Pull request has been placed on the maintainer queue by joneugster. |
|
Thanks! bors r+ |
| -- If the expected type is known to be `Set ?α`, give up. If it is not known to be `Set ?α` or | ||
| -- `Finset ?α`, check the expected type of `s`. | ||
| unless ← knownToBeFinsetNotSet expectedType? do | ||
| let ty ← try whnfR (← inferType (← elabTerm s none)) catch _ => throwUnsupportedSyntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's too bad that this elabTerm s none is wasted work. Maybe in a followup it could be saved and then inserted into the Syntax on line 2201 using exprToSyntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense
Define elaborators (but no delaborators) to elaborate the following notations to a `Finset`:
In `Data.Finset.Basic`,
* `{x ∈ s | p x}`
In `Data.Fintype.Basic`,
* `{x | p x}`
* `{x : α | p x}`
* `{x ∉ s | p x}`
* `{x ≠ a | p x}`
In `Order.Interval.Finset.Basic`,
* `{x ≤ a | p x}`
* `{x ≥ a | p x}`
* `{x < a | p x}`
* `{x > a | p x}`
The general heuristic for deciding whether to elaborate a given notation as a `Set` or `Finset` is:
* Check whether the expected type is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't, check whether the expected type of `s` in the notation is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't or there is no `s` in the notation, elaborate as a `Set`.
There is currently a gotcha that elaboration to `Set` is highly preferred because we can't postpone metavariable and override the set elaborator without breaking many existing uses of set builder notation. See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.7Bx.20.E2.88.88.20s.20.7C.20p.20x.7D.20notation.20for.20finset).
|
Build failed (retrying...): |
Define elaborators (but no delaborators) to elaborate the following notations to a `Finset`:
In `Data.Finset.Basic`,
* `{x ∈ s | p x}`
In `Data.Fintype.Basic`,
* `{x | p x}`
* `{x : α | p x}`
* `{x ∉ s | p x}`
* `{x ≠ a | p x}`
In `Order.Interval.Finset.Basic`,
* `{x ≤ a | p x}`
* `{x ≥ a | p x}`
* `{x < a | p x}`
* `{x > a | p x}`
The general heuristic for deciding whether to elaborate a given notation as a `Set` or `Finset` is:
* Check whether the expected type is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't, check whether the expected type of `s` in the notation is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't or there is no `s` in the notation, elaborate as a `Set`.
There is currently a gotcha that elaboration to `Set` is highly preferred because we can't postpone metavariable and override the set elaborator without breaking many existing uses of set builder notation. See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.7Bx.20.E2.88.88.20s.20.7C.20p.20x.7D.20notation.20for.20finset).
|
This PR was included in a batch that was canceled, it will be automatically retried |
Define elaborators (but no delaborators) to elaborate the following notations to a `Finset`:
In `Data.Finset.Basic`,
* `{x ∈ s | p x}`
In `Data.Fintype.Basic`,
* `{x | p x}`
* `{x : α | p x}`
* `{x ∉ s | p x}`
* `{x ≠ a | p x}`
In `Order.Interval.Finset.Basic`,
* `{x ≤ a | p x}`
* `{x ≥ a | p x}`
* `{x < a | p x}`
* `{x > a | p x}`
The general heuristic for deciding whether to elaborate a given notation as a `Set` or `Finset` is:
* Check whether the expected type is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't, check whether the expected type of `s` in the notation is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't or there is no `s` in the notation, elaborate as a `Set`.
There is currently a gotcha that elaboration to `Set` is highly preferred because we can't postpone metavariable and override the set elaborator without breaking many existing uses of set builder notation. See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.7Bx.20.E2.88.88.20s.20.7C.20p.20x.7D.20notation.20for.20finset).
|
Pull request successfully merged into master. Build succeeded: |
Define elaborators (but no delaborators) to elaborate the following notations to a `Finset`:
In `Data.Finset.Basic`,
* `{x ∈ s | p x}`
In `Data.Fintype.Basic`,
* `{x | p x}`
* `{x : α | p x}`
* `{x ∉ s | p x}`
* `{x ≠ a | p x}`
In `Order.Interval.Finset.Basic`,
* `{x ≤ a | p x}`
* `{x ≥ a | p x}`
* `{x < a | p x}`
* `{x > a | p x}`
The general heuristic for deciding whether to elaborate a given notation as a `Set` or `Finset` is:
* Check whether the expected type is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't, check whether the expected type of `s` in the notation is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't or there is no `s` in the notation, elaborate as a `Set`.
There is currently a gotcha that elaboration to `Set` is highly preferred because we can't postpone metavariable and override the set elaborator without breaking many existing uses of set builder notation. See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.7Bx.20.E2.88.88.20s.20.7C.20p.20x.7D.20notation.20for.20finset).
Define elaborators (but no delaborators) to elaborate the following notations to a `Finset`:
In `Data.Finset.Basic`,
* `{x ∈ s | p x}`
In `Data.Fintype.Basic`,
* `{x | p x}`
* `{x : α | p x}`
* `{x ∉ s | p x}`
* `{x ≠ a | p x}`
In `Order.Interval.Finset.Basic`,
* `{x ≤ a | p x}`
* `{x ≥ a | p x}`
* `{x < a | p x}`
* `{x > a | p x}`
The general heuristic for deciding whether to elaborate a given notation as a `Set` or `Finset` is:
* Check whether the expected type is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't, check whether the expected type of `s` in the notation is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't or there is no `s` in the notation, elaborate as a `Set`.
There is currently a gotcha that elaboration to `Set` is highly preferred because we can't postpone metavariable and override the set elaborator without breaking many existing uses of set builder notation. See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.7Bx.20.E2.88.88.20s.20.7C.20p.20x.7D.20notation.20for.20finset).
Define elaborators (but no delaborators) to elaborate the following notations to a `Finset`:
In `Data.Finset.Basic`,
* `{x ∈ s | p x}`
In `Data.Fintype.Basic`,
* `{x | p x}`
* `{x : α | p x}`
* `{x ∉ s | p x}`
* `{x ≠ a | p x}`
In `Order.Interval.Finset.Basic`,
* `{x ≤ a | p x}`
* `{x ≥ a | p x}`
* `{x < a | p x}`
* `{x > a | p x}`
The general heuristic for deciding whether to elaborate a given notation as a `Set` or `Finset` is:
* Check whether the expected type is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't, check whether the expected type of `s` in the notation is `Finset ?α`.
* If it is, elaborate as a `Finset`.
* If it isn't or there is no `s` in the notation, elaborate as a `Set`.
There is currently a gotcha that elaboration to `Set` is highly preferred because we can't postpone metavariable and override the set elaborator without breaking many existing uses of set builder notation. See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.7Bx.20.E2.88.88.20s.20.7C.20p.20x.7D.20notation.20for.20finset).
Define elaborators (but no delaborators) to elaborate the following notations to a
Finset:In
Data.Finset.Basic,{x ∈ s | p x}In
Data.Fintype.Basic,{x | p x}{x : α | p x}{x ∉ s | p x}{x ≠ a | p x}In
Order.Interval.Finset.Basic,{x ≤ a | p x}{x ≥ a | p x}{x < a | p x}{x > a | p x}The general heuristic for deciding whether to elaborate a given notation as a
SetorFinsetis:Finset ?α.Finset.sin the notation isFinset ?α.Finset.sin the notation, elaborate as aSet.There is currently a gotcha that elaboration to
Setis highly preferred because we can't postpone metavariable and override the set elaborator without breaking many existing uses of set builder notation. See Zulip.