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

feat: add #help note command #948

Merged
merged 30 commits into from
Oct 27, 2024

Conversation

edegeltje
Copy link
Contributor

@edegeltje edegeltje commented Sep 14, 2024

on zulip it was mentioned that there used to be an easy way to find and/or read library notes, but that this feature no longer works, presumably since lean4.

This PR aims to remedy the situation by introducing the #help note "some tag" command, which displays all library notes marked with the tag "some tag" that are declared before the command, including in imports.

@edegeltje edegeltje changed the title Add check_note command feat:Add check_note command Sep 14, 2024
@edegeltje
Copy link
Contributor Author

awaiting-review

@github-actions github-actions bot added the awaiting-review This PR is ready for review; the author thinks it is ready to be merged. label Sep 20, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Sep 27, 2024

Mathlib CI status (docs):

@fgdorais
Copy link
Collaborator

fgdorais commented Sep 27, 2024

The Mathlib test help_cmd.lean will need to be updated as a result of this. Was this expected?

PS: Thank you for being the first live test of this new Batteries feature that checks whether a Batteries PR will break Mathlib downstream!

@fgdorais fgdorais changed the title feat:Add check_note command feat: add #check_note command Sep 28, 2024
@edegeltje
Copy link
Contributor Author

Was this expected?

when writing this PR i certainly did not take this in consideration, so it was not something i was expecting...
still, looking at how the failing test is written, it is not a surprise it "broke", as its success does indeed depend on what commands start with "#chec" despite that not being the goal of the test.

leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 28, 2024
@fgdorais
Copy link
Collaborator

fgdorais commented Sep 28, 2024

Indeed, that is a poorly designed test. On the other hand, that test's output shows that #check_notes doesn't quite fit with the other #check commands. It fits better with #print commands but not perfectly. Perhaps it should be a #help command? What do you think?

@edegeltje
Copy link
Contributor Author

edegeltje commented Sep 28, 2024

i guess it could be a #help command, but i think #help is in mathlib? i think #show_note is an acceptable alternative name. What mathlib does with #help is their concern, they are free to reuse the code here to get the output, although i don't think this feature fits the expectations of #help...

@fgdorais
Copy link
Collaborator

Actually, it makes sense to move #help here or even to Lean since it's useful to everyone and nothing about it is Mathlib specific. 🤔

@fgdorais
Copy link
Collaborator

The #help command is now in Batteries. This PR can now be adapted as the #help notes subcommand.

@edegeltje edegeltje changed the title feat: add #check_note command feat: add #help note command Oct 16, 2024
@edegeltje
Copy link
Contributor Author

wip

@github-actions github-actions bot added WIP work in progress and removed awaiting-review This PR is ready for review; the author thinks it is ready to be merged. labels Oct 16, 2024
@edegeltje
Copy link
Contributor Author

awaiting-review

@github-actions github-actions bot removed the WIP work in progress label Oct 16, 2024
fgdorais added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 26, 2024
Co-authored-by: François G. Dorais <fgdorais@gmail.com>
@fgdorais
Copy link
Collaborator

This is looking excellent and it now passes Mathlib CI!

One final thing: the command should be in Batteries.Tactic.HelpCmd along with the other #help commands and the module doc there should be updated.

@edegeltje
Copy link
Contributor Author

edegeltje commented Oct 26, 2024

One final thing: the command should be in Batteries.Tactic.HelpCmd along with the other #help commands and the module doc there should be updated.

in my opinion, it is more natural to have the tool here, in order to make sure it is available wherever library notes are...
this is not meant to be a #help command. this is meant to be a command which lets you read library notes. it only became a help command by lack of a better name.

@fgdorais
Copy link
Collaborator

In any case, the module doc at Batteries.Tactic.HelpCmd needs to be updated.

I don't understand why you claim it's not a help command. Just like the other help commands, it's handy for users when writing code but it is not useful as code. That's why HelpCmd is not imported anywhere in Batteries and Mathlib except in the global import files. I don't see why #help note should be any different than the others.

fgdorais added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 26, 2024
@fgdorais
Copy link
Collaborator

fgdorais commented Oct 26, 2024

I'm afraid I must insist on moving to Batteries.Tactic.HelpCmd for maintainability reasons. Your proposed alternative has some issues (1) importing Batteries.Tactic.HelpCmd doesn't import all help commands and (2) importing Batteries.Util.LibraryNotes into Batteries.Tactic.HelpCmd would not pass shake. I see no more practical way around these problems.

@fgdorais fgdorais added awaiting-author Waiting for PR author to address issues and removed awaiting-review This PR is ready for review; the author thinks it is ready to be merged. labels Oct 27, 2024
@edegeltje
Copy link
Contributor Author

@fgdorais how about we put an alias of the command in Batteries.Tactic.HelpCmd? that should fix both issues, and still make sure that the functionality exists wherever you can make library notes. the "original" can then be something like #find_note "label", and there can be a simple macro turning #help note into that...
or does that still give maintainability issues?

@fgdorais
Copy link
Collaborator

That's too hacky for Batteries. Like I said before the reason why help commands like this one aren't available everywhere is that they are only useful for users while writing code, but of no use in the code itself. You will just have to get used to importing help commands while writing a Batteries or Mathlib PR and then deleting the import before submitting.

@edegeltje
Copy link
Contributor Author

awaiting-review

@github-actions github-actions bot added awaiting-review This PR is ready for review; the author thinks it is ready to be merged. and removed awaiting-author Waiting for PR author to address issues labels Oct 27, 2024
@edegeltje
Copy link
Contributor Author

i don't see the issue with having this command always available. AFAIK, it shouldn't be that impactful if these are or aren't imported.

@fgdorais
Copy link
Collaborator

FWIW, I think Batteries.Tactic.HelpCmd would be a nice addition to Mathlib.Init.

fgdorais added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 27, 2024
Batteries/Tactic/HelpCmd.lean Outdated Show resolved Hide resolved
Batteries/Tactic/HelpCmd.lean Outdated Show resolved Hide resolved
Batteries/Tactic/HelpCmd.lean Outdated Show resolved Hide resolved
Co-authored-by: François G. Dorais <fgdorais@gmail.com>
@fgdorais fgdorais added this pull request to the merge queue Oct 27, 2024
Merged via the queue into leanprover-community:main with commit 4d2cb85 Oct 27, 2024
2 checks passed
@edegeltje edegeltje deleted the check-note-command branch October 27, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review This PR is ready for review; the author thinks it is ready to be merged. builds-mathlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants