This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 295
feat(tactic/expand_exists): create in namespace & docstring #15732
Open
0x182d4454fb211940
wants to merge
6
commits into
master
Choose a base branch
from
expand_exists_improvements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
be2038e
feat(tactic/expand_exists): parse docstrings, absolute names
0x182d4454fb211940 715a24f
feat(tactic/expand_exists): apply parsed arguments
0x182d4454fb211940 0154d67
test(tactic/expand_exists): add tests for docstring and namespaces
0x182d4454fb211940 1c81d26
doc(tactic/expand_exists): document namespace & docstring
0x182d4454fb211940 f7efac2
feat(tactic/expand_exists): use `_root_` instead of `@`
0x182d4454fb211940 46abb21
feat(tactic/expand_exists): replace syntax with proposed list syntax
0x182d4454fb211940 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
An alternative syntax -- but this time I'm not sure if it's better --
@[expand_exists [foo "a foo with property bar", bar]]
. This should also avoid anypexpr
/name
ambiguity and is easy enough to parse.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 haven't tried implementing this yet but I'm a bit torn: it seems cleaner but also slightly more verbose and less like other attribute syntaxes. I guess it would be possible to accept both but I think that just adds maintenance burden. I also imagine your proposed syntax could allow for more features more gracefully in future? Again, I'm unsure.
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.
We definitely shouldn't support both
=
and lists. In favor of the list syntax: lists are already used in some attributes (@[derive [class1, class2]]
), and=
is not AFAIK. Against the list syntax, in the no-doc-strings case, it clashes with the syntax for e.g.simps
(@[simps id1 id2 id3]
vs@[expand_exists [id1, id2, id3]]
).Maybe the move is to support both the bare stream of idents (without doc strings at all) and the more verbose list style? Something like
parse (ident* <|> list_of ident_with_opt_string)
, see https://github.com/leanprover-community/lean/blob/22b09be35ef66aece11e6e8f5d114f42b064259b/library/init/meta/interactive_base.lean#L61 .@digama0 any preference here?
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 think the simplest approach would be to simply copy the docstring from the theorem to all generated declarations. That way you don't have to shove a doc string into the middle of an attribute. For lean 4, I would probably be looking at a syntax closer to
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.
Perhaps it makes sense for now to use the docstring with the exists lemma by default, allow the
=
syntax for now to override this, and add a note stating the planned syntax for lean 4?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.
Whatever choice we make here could be retrospectively applied to
simps
, since in principle we could want to set docstrings there too.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.
@robertylewis Interestingly that worked but only the other way around (trying to parse as a list, then falling back to idents). I don't really understand what would cause this behaviour: is there some intentional design decision behind this?
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.
@digama0 One other idea is we could have an auto-generated string saying something like "See
exists_lemma
" provided it has a docstring, though either approach would work. Both are quite easy to implement.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 still don't love the
=
syntax, but this sounds fine to me. It's not really worth quibbling over! I think this is better thansince it's best for doc strings to be self-contained whenever possible, since they show up in hover tooltips.
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 would have expected it to work either way since an ident can't start with
[
. Can't say why without playing around with it myself!