This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
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.
feat(tactic/expand_exists): create in namespace & docstring #15732
base: master
Are you sure you want to change the base?
feat(tactic/expand_exists): create in namespace & docstring #15732
Changes from 4 commits
be2038e
715a24f
0154d67
1c81d26
f7efac2
46abb21
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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!