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: notation3
delaborator generation
#4533
Conversation
@digama0 It's still in CI, but in my local testing it seems to work. It's an extension to the I'm trying to add some usability improvement to mathlib in time for the Lean workshop at MSRI that starts next week, so it would be helpful having an expedited review, though worst case we could use a custom branch of mathlib for TPIL. |
notation3"c["(l", "* => foldr (h t => List.cons h t) List.nil)"]" => | ||
Cycle.formPerm (↑l) (Cycle.nodup_coe_iff.mpr _) | ||
notation3 "c["(l", "* => foldr (h t => List.cons h t) List.nil)"]" => | ||
Cycle.formPerm (Cycle.ofList l) (Iff.mpr Cycle.nodup_coe_iff _) |
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.
Just to explain: the Syntax
needs to get turned into an Expr
pattern for use in the delaborator, and pattern construction needs to be able to walk along the syntax without elaborating it. The walker only handles just enough Syntax features to be useful, and that does not include ↑
or dot notation.
This is not necessary for the syntax to work, but this change causes notation3
to generate a delaborator. set_option trace.notation3 true
gives some information about its successes and failures.
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 looks like the syntax here could be reconstructed from the elaborated expression though, although maybe you can't even elaborate this expression in context?
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.
I'd thought about trying to elaborate the expressions to generate patterns, but then I wasn't sure if there'd be other things that would introduce into the expressions that'd get in the way of being a pattern, like maybe the elaborator might fill in some instance arguments with instances it wouldn't choose for some concrete arguments. With this syntax walker, I felt more confidant that it's doing the right thing in the cases it accepts.
The code's set up where you can swap out mkExprMatcher
for a fancier implementation
What fraction of existing |
In principle there should only be three that don't work right now. The notation for I'll take a look at them all tomorrow more carefully once I have a compiled mathlib. |
@digama0 I added a |
@digama0 It builds, and I did a spot check for each notation to see that they delaborate, especially the Lesbegue integral notation (no need for its unexpanders now). |
da9e50d
to
38b4cc4
Compare
As I discussed with @kmill privately, I have a rewrite of large parts of this code to move more of the matcher algorithm to compile time. But this implementation sets bar for the intended behavior of the delaborator, and I have no complaints about the code itself. So let's get this in the hands of mathlib users. bors r+ |
Conflicts bors r- |
Canceled. |
bors r+ |
👎 Rejected by label |
bors r+ |
Gives the `notation3` command the ability to generate a delaborator in most common situations. When it succeeds, `notation3`-defined syntax is pretty printable. Examples: ``` (⋃ (i : ι) (i' : ι'), s i i') = ⋃ (i' : ι') (i : ι), s i i' (⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ (a : α), g a ∂μ) = ∫⁻ (a : α), f a ∂μ ``` Co-authored-by: Mario Carneiro <di.gama@gmail.com>
Pull request successfully merged into master. Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
notation3
delaborator generationnotation3
delaborator generation
Gives the `notation3` command the ability to generate a delaborator in most common situations. When it succeeds, `notation3`-defined syntax is pretty printable. Examples: ``` (⋃ (i : ι) (i' : ι'), s i i') = ⋃ (i' : ι') (i : ι), s i i' (⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ (a : α), g a ∂μ) = ∫⁻ (a : α), f a ∂μ ``` Co-authored-by: Mario Carneiro <di.gama@gmail.com>
Gives the
notation3
command the ability to generate a delaborator in most common situations. When it succeeds,notation3
-defined syntax is pretty printable.Examples: