-
Notifications
You must be signed in to change notification settings - Fork 459
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: more infrastructure for tactic documentation #4490
feat: more infrastructure for tactic documentation #4490
Conversation
Introduces the notion of a tactic alias, which is a syntax specification that is really "the same as" an existing tactic, but needs to be separate for technical reasons. Additionally, tactics can be tagged, and extensibility is first-class. This is a minimal proof of concept for evaluation - missing features include: * Hovers on tactics don't take this new metadata into account * There's not yet a user interface for querying the data internally in Lean
Mathlib CI status (docs):
|
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.
My hotel wifi died and I don't want to get a core dev setup going on phone data, so I'm not 100% sure these code suggestions are right. But this looks fantastic, should do the job very nicely!
Now they don't need to be imported.
@robertylewis I think this should meet your needs now - please give it a whirl at let me know! I don't want to merge before you've had a chance to validate that it supports the workflow that you're looking for. |
I like that, but I'll use |
!bench |
Here are the benchmark results for commit ca52b81. |
!bench |
Here are the benchmark results for commit 55dc835. Benchmark Metric Change
===========================================
- parser instructions 1.5% (918.2 σ) |
@Kha - what do you think? Is that instruction count hit too severe? |
This PR adds a `recommended_spelling` command, which can be used for recording the recommended spelling of a notation (for example, that the recommended spelling of `∧` in identifiers is `and`). This information is then appended to the relevant docstrings for easy lookup. The function `Lean.Elab.Term.Doc.allRecommendedSpellings` may be used to obtain a list of all recommended spellings, for example to create a table that is part of a style guide. In the future, it might be desirable to be able to partition such a table into smaller tables by category. This can be added in a future PR. The implementation is heavily inspired by #4490.
This is the groundwork for a tactic index in generated documentation, as there was in Lean 3. There are a few challenges to getting this to work well in Lean 4:
intro
is specified apart from the default version, but both are the same from a user perspective)For tactic identity, this PR introduces the notion of a tactic alternative, which is a
syntax
specification that is really "the same as" an existing tactic, but needs to be separate for technical reasons. This provides a notion of tactic identity, which we can use as the basis of a tactic index in generated documentation. Alternative forms of tactics are specified using a new@[tactic_alt IDENT]
attribute, applied to the new tactic syntax. It is an error to declare a tactic syntax rule to be an alternative of another one that is itself an alternative. Documentation hovers now take alternatives into account, and display the docs for the canonical name.Tactic tags, created with the
register_tactic_tag
command, specify tags that may be applied to tactics. This is intended to be used by doc-gen and Verso. Tags may be applied using the@[tactic_tag TAG1 TAG2 ...]
attribute on a canonical tactic parser, which may be used in any module to facilitate downstream projects introducing tags that apply to pre-existing tactics. Tags may not be removed, but it's fine to redundantly add them. The collection of tags, and the tactics to which they're applied, can be seen using the#print tactic tags
command.Extension documentation provides a structured way to document extensions to tactics. The resulting documentation is gathered into a bulleted list at the bottom of the tactic's docstring. Extensions are added using the
tactic_extension TAC
command. This can be used when adding new interpretations of a tactic viamacro_rules
, when extending some table or search index used by the tactic, or in any other way. It is a command to facilitate its flexible use with various extension mechanisms.