[Merged by Bors] - feat: add #check' command and tactic, which only show explicit arguments#31194
[Merged by Bors] - feat: add #check' command and tactic, which only show explicit arguments#31194grunweg wants to merge 23 commits intoleanprover-community:masterfrom
#check' command and tactic, which only show explicit arguments#31194Conversation
PR summary f3179c596dImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
@kmill I'm very open to making a PR against Lean core instead, if that is a better solution. |
thorimur
left a comment
There was a problem hiding this comment.
Looks good! :) There's an important comment or two in here about control flow changes which are responsible for the (new) double-logging seen in the tests, and which seem accidental to me.
Besides that, though, it's just refactoring, and we can do that as a chore later if this is really helpful to get in quickly. It seems like a big QoL improvement. :)
Also, another question for the future: should there eventually be some way to see that we're omitting implicit arguments, or does that just get in the way? Ideas if this is a direction we want to pursue:
- (consecutive occurrences of) implicit arguments are replaced by
⋯in the signature - the type signature is followed by something like
3 implicit arguments omittedon a new line - the type signature is followed by
3 implicit arguments omitted, including instances of <names of typeclasses>(without their arguments), in case this would be useful information
Mathlib/Tactic/Check.lean
Outdated
| def checkPrimeInner (tk : Syntax) (term : Term) : TacticM Unit := do | ||
| for c in (← realizeGlobalConstWithInfos term) do | ||
| addCompletionInfo <| .id term c (danglingDot := false) {} none |
There was a problem hiding this comment.
This for loop and addCompletionInfo are shared between the checkPrimes, and (1) we never use term in the rest of the body (2) term is expected to be an ident, something that makes sense when reading at the call site, but is a nonlocal fact here.
So, unless you're anticipating some changes later, I'd suggest:
- inline these first two lines in
elabCheckTacticInner, afterguard(see below) - change the type of these inner functions to
checkPrimeInner (tk : Syntax) (c : Name) : TacticM Unit
We can go further and factor out logInfoAt tk too, which means the type signature could become simply Name → TermElabM MessageData. :)
As with other refactoring suggestions, we can do this after getting it in if you like.
|
This pull request has conflicts, please merge |
|
Thanks for your careful review comments, as usual. I just got back to this PR and addressed your key comments. The refactorings you mention seem useful to have, but I'd be happy to have them in a follow-up. (When working on differential geometry, it is nice to have these --- I was working on a branch containing this, so it's not really urgent to get in, but seems nice to not stall this a lot.) |
|
There have been other discussions about the user experience on zulip, including modifying #check to dim out implicit arguments. My understanding is that we're still iterating on the best way to get this out, and having this available for experimentation could help. I'm happy to stick a comment (that this is experimental) somewhere, if you prefer. |
|
-awaiting-author |
|
Thanks a lot for the refactoring! |
| If `t` is an identifier, then it pretty prints a type declaration form | ||
| for the global constant `t` instead. | ||
| Use `#check' (t)` to pretty print it as an elaborated expression. | ||
|
|
There was a problem hiding this comment.
I think we can omit this, as it's redundant information for the user. I realize it's copied from the #check tactic, but maybe we should delete it there too? Unless you can think of a case for when the user needs to know the difference, of course!
| If `t` is an identifier, then it pretty prints a type declaration form | |
| for the global constant `t` instead. | |
| Use `#check' (t)` to pretty print it as an elaborated expression. |
There was a problem hiding this comment.
Hm, I'm on the fence. On on hand, most users won't care much about the difference --- but making this information discoverable when it is needed seems useful. (I hadn't thought about the different until now --- it makes perfect sense now, but do we want to require this?)
Let's see what a maintainer reviewing this thinks!
|
After the minor documentation suggestions here, I think this is good to go :) I've contributed a refactor here. The code I've introduced stays very close to lean core's
So, I think it's prudent to have another pair of eyes :) maintainer delegate? |
|
🚀 Pull request has been placed on the maintainer queue by thorimur. |
Co-authored-by: Thomas R. Murrills <68410468+thorimur@users.noreply.github.com>
…ments (#31194) In some areas (such as differential geometry), many lemmas have a *lot* of implicit and typeclass arguments. Using `#check foo` to determine which explicit arguments are expected for a given lemma gives output which is painful to read, because the explicit argument is buried among many lines of other output. The `#check'` command and tactic produce very similar output, but with implicit and typeclass arguments omitted. This increases usability a lot. In the future, this could (and should) be unified to the #check command in core, by becoming e.g. `#check +only-explicit`. Until then, let us add this to mathlib to facilitate experimentation of the most useful behaviour. From the project towards geodesics and the Levi-Civita connection. Co-authored-by: Kyle Miller <kymiller@ucsc.edu> Co-authored-by: Patrick Massot <patrickmassot@free.fr> Co-authored-by: thorimur <68410468+thorimur@users.noreply.github.com>
|
Build failed (retrying...): |
…ments (#31194) In some areas (such as differential geometry), many lemmas have a *lot* of implicit and typeclass arguments. Using `#check foo` to determine which explicit arguments are expected for a given lemma gives output which is painful to read, because the explicit argument is buried among many lines of other output. The `#check'` command and tactic produce very similar output, but with implicit and typeclass arguments omitted. This increases usability a lot. In the future, this could (and should) be unified to the #check command in core, by becoming e.g. `#check +only-explicit`. Until then, let us add this to mathlib to facilitate experimentation of the most useful behaviour. From the project towards geodesics and the Levi-Civita connection. Co-authored-by: Kyle Miller <kymiller@ucsc.edu> Co-authored-by: Patrick Massot <patrickmassot@free.fr> Co-authored-by: thorimur <68410468+thorimur@users.noreply.github.com>
|
Pull request successfully merged into master. Build succeeded: |
#check' command and tactic, which only show explicit arguments#check' command and tactic, which only show explicit arguments
…ments (leanprover-community#31194) In some areas (such as differential geometry), many lemmas have a *lot* of implicit and typeclass arguments. Using `#check foo` to determine which explicit arguments are expected for a given lemma gives output which is painful to read, because the explicit argument is buried among many lines of other output. The `#check'` command and tactic produce very similar output, but with implicit and typeclass arguments omitted. This increases usability a lot. In the future, this could (and should) be unified to the #check command in core, by becoming e.g. `#check +only-explicit`. Until then, let us add this to mathlib to facilitate experimentation of the most useful behaviour. From the project towards geodesics and the Levi-Civita connection. Co-authored-by: Kyle Miller <kymiller@ucsc.edu> Co-authored-by: Patrick Massot <patrickmassot@free.fr> Co-authored-by: thorimur <68410468+thorimur@users.noreply.github.com>
In some areas (such as differential geometry), many lemmas have a lot of implicit and typeclass arguments.
Using
#check footo determine which explicit arguments are expected for a given lemma gives output which is painful to read, because the explicit argument is buried among many lines of other output.The
#check'command and tactic produce very similar output, but with implicit and typeclass arguments omitted.This increases usability a lot.
In the future, this could (and should) be unified to the #check command in core, by becoming e.g.
#check +only-explicit. Until then, let us add this to mathlib to facilitate experimentation of the most useful behaviour.From the project towards geodesics and the Levi-Civita connection.
Co-authored-by: Kyle Miller kymiller@ucsc.edu
Co-authored-by: Patrick Massot patrickmassot@free.fr