-
Notifications
You must be signed in to change notification settings - Fork 34
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
Unifying the syntax of Theorem, Definition, Fixpoint, etc. #42
base: master
Are you sure you want to change the base?
Conversation
I think I would prefer Theorem (and Lemma etc) to be really an alias of Definition, ie when body is provided you get a transparent constant by default and have to use the attribute to get opacity for both Theorem and Definition. |
Thanks for this perspective! I hadn't considered it. I'll add it to the "alternatives" section for now. |
I like this. Wrt the opaque attribute, you could have a sub attrite, eg opaque(tactics) or better unfold(37) or unfold(never), that is another attribute for the tactic level thing, as one could have simpl(never). In some sense, it may the good occasion to disambiguate, and use opaque only for the kernel notion of opacity |
And so aim to deprecate the |
No, changing back and forth is still useful. |
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 am strongly in favor of this.
I especially like that I will now finally be able to use reduction expressions with fixpoints.
|
||
- `opaque` and `transparent` to declare an object opaque or | ||
transparent like `Qed` and `Defined` do (note that this is not the | ||
same as what the `Opaque` and `Transparent` commands do): |
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.
Is this going to cause confusion that we'll regret in the future?
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.
This is the question I'm asking in the "Unresolved questions" section.
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.
IMVHO, I think qed
and defined
would be strictly better names in the current scenario.
Otherwise, please pick fresh words that can be used consistently, and make sense if coq/coq#3389 is accepted.
Ideally, technical terms and their meanings would be in a one-to-one mapping, absent strong reasons for a specific case.
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.
To be entirely fair to @Zimmi48 , this confusion already exists. Qed
makes things opaque, Defined
makes thing transparent (that's all over the documentation, etc…). On the other hand Opaque
makes things “sort-of opaque, somehow, a little, you know…” And this is where the confusion stems from.
And, frankly, #[qed] Definition
is super esoteric.
I wonder what the cost would be to change Opaque
and Transparent
into more honest names instead?
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.
FTR at the coq call I heard seal
and unseal
, for flipping the "Qed opaque" status. We could then keep opacity(number)
for the "other opacity".
# Unresolved questions | ||
|
||
The name of attributes `opaque` and `transparent` may be confusing | ||
with the `Opaque` and `Transparent` commands which are not as strong. |
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.
Let me repeat again my call from six years ago to have more notions of opacity: coq/coq#3389
This is probably beyond the scope of this PR
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.
That's interesting and also echoes the comment of Enrico above. But yes, this is out of scope.
It seems like the main questions to resolve will be about the opacity attribute(s). Considering the suggestions by Enrico and Jason to extend the available opacity options, it would be great to ensure that whatever is decided is compatible with these views for the future of opacity. Regarding the question of the default opacity (no attribute), is there any opposition to Gaëtan's suggestion for the default to always be transparent when a body is provided (even with the |
Are you saying that Theorems are opaque, Definitions are transparent. How can it be simpler than that? |
This is dependent types, proof relevant theorems are normal. |
How does you proposal help wrt this? |
IIUC, in your proposal, the |
No, I meant that |
Wrt HoTT-like users, I don't see how this CEP or the proposal of Gaetan helps. |
I like this, too! In particular it adds a new feature of opaque theorems with explicit bodies using tactics-in-terms (last I checked I don't have a strong opinion on what to do about the various combinations, but I would like at least a recommendation on what sane developments should do to reduce the many options Coq gives. I sort of agree with @gares that |
Perhaps there should be options |
@gares what should end |
There's no default unlike what your phrasing implies. I would just say "Theorem is the same as Definition, you can make the |
I'd say Defined since it is the most common case AFAIK. |
If we imposed this new view, this would be a pretty big change: everything in HoTT is currently |
More precisely @gares, here is a possible path to arrive to what you have in mind:
Leaving several versions (but at the very least one) between each step should give people plenty of time to adapt. Providing a flag would ensure that HoTT people do not have a hard time because of this change. |
I like your plan. Somehow I recall I've seen hott files with Definition/Defined. I ve just checked a few and they look like that. Where did you see Theorem/Defined used extensively? |
At least in UniMath there is a mix of |
I've added the topic to today's call. Regarding transparency attributes, one option that would be compatible with separating the transparency question from the
|
The conclusion of the Coq Call is to go with the plan at #42 (comment) but with attributes |
Sorry for missing the call today; it seems to me that removing the current mechanism will have a huge impact in terms of compat; on the other hand I don't see any technical advantage on knowing that a proof is opaque / transparent at proof opening time. Thus IMO we may weight the cost/benefit ratio here. |
My own estimation of the cost of porting is "pretty small". Indeed, there will be the option of using the attribute selectively or the flag if all theorems in a file / project must be transparent. As for replacing This is why I suggested this plan following Enrico's remarks. I wouldn't have proposed any plan that was strongly disruptive for little gain. |
Well, just the amount of documentation / tutorials, stuff like SF that needs to be adapted seems to be more than "pretty small" to me; but my question really is "why"? Changing the semantics of current code does not help with any problem I can see, on the contrary, that seems to me like a hack in order to workaround bugs in upper layers. As with the other interpretation restrictions I must stay on the technical view that lower layers should not add workarounds for problems in their clients. |
Note that the design does not require to change existing scripts. It happens that having consistent syntax and attributes one can make documents more coherent in their syntax. Should it become an error, a warning, or nothing, to have Definition end with Qed, is orthogonal to the core of this CEP. I agree knowing early if a proof is opaque or not brings no advantage to Coq, as well as supporting := in Theorem is not going to change a users life. Having a uniform syntax and a uniform way to control opacity is just making things easier to explain. |
I don't see how that's possible, if Qed/Defined don't determine opacity you have to replace them somehow no? |
What about already implementing sealed and unsealed attributes? That does not look like a big deal and would provide an immediate gain. (And if we want to go to massive renamings or deprecations, I don't realistically see how to avoid doing it using an automatic tool. As an example, there are already many warnings in the CI which are not addressed and I don't see how they could reasonably be all addressed manually.) |
The idea of choosing sealedness based on if Theorem or Definition was used still feels quite bad to me. Maybe I'm too used to the current system but I do have 1 argument: currently to understand if something is sealed I need to remember the meaning of exactly 2 commands (Qed/Defined) but with this change I would need to know the sealedness of all of Theorem Definition Lemma Example etc |
I agree with Gaëtan that we're spreading state around, and it's always annoying to have to reconciliate disagreeing states. EDIT: and also, since we believe in Curry-Howard, this is making an artificial distinction between two identical concepts. |
As far as I am concerned, I do disagree. I think the head keyword should also be used to set the default sealing state, especially since there is no |
But then how do we know about the ocean of weird "natural-language" keywords that we have in the implementation? And it becomes non-uniform w.r.t. other proof-starting commands like Instance. |
As a reference, I copy how let print_opacity env ref =
match opacity env ref with
| None -> []
| Some s ->
[pr_global ref ++ str " is " ++
match s with
| FullyOpaque -> str "opaque"
| TransparentMaybeOpacified Conv_oracle.Opaque ->
str "basically transparent but considered opaque for reduction"
| TransparentMaybeOpacified lev when Conv_oracle.is_transparent lev ->
str "transparent"
| TransparentMaybeOpacified (Conv_oracle.Level n) ->
str "transparent (with expansion weight " ++ int n ++ str ")"
| TransparentMaybeOpacified Conv_oracle.Expand ->
str "transparent (with minimal expansion weight)"] This suggests that a less breaking alternative to
Also, for reference, there are options |
I'm pretty much against this naming scheme because it mixes concepts at the kernel level (sealed vs. unsealed) that are part of the typing rules and heuristic concepts from the upper layers. |
@silene to support our point, here is a list of definition tokens from the grammar. What are their expected sealedness? No cheating.
|
Sorry, there are parallel discussions and I'm replying here on "mixing two views": it is worrying me also but we also need to take care of common terminological usages in place (including in our own practice). We may try to change the |
Re: default sealedness. @SkySkimmer, @ppedrot: is your proposal that declarations using |
yes |
I'm not opposed to what Gaëtan and Pierre-Marie are arguing for, but here is a proposal for a compromise:
|
I'd prefer being able to read the code without running it. |
It seems to me that just adding general support for Default modalities:
If the command has an attribute, there are 3 cases:
I am not sure how this would work, IMHO it is hard to predict more without going and implementing a proposal, and playing with it a bit. The good news is that I think |
I share @silene 's pain point about |
I just read the proposal again (congrats @Zimmi48 , great writing!), I am thinking that maybe we are trying to do too much. IIRC the main motivation was to have
|
But you cannot use
Yeah, that's one of the disadvantages of this approach :( But at least, the proposed change wouldn't break your current code. |
Feature-wise, having the However, another point of this CEP was to create more uniformity in the syntax. It is my opinion that Coq has too much "accidental" variability and we should strive to remove some. That's one of the motivations for the CEP. I'm also of the opinion that (real) synonyms are fine and consistent with the current "culture" of Coq (without the drawbacks of the accidental variability). That being said, the proposal of Pierre-Marie and Gaëtan is fully compatible with this vision, and therefore I'm also OK with their proposal. I have no opinion about the value of knowing the transparency of a constant without executing the code. The proposal was indeed that Coq would only provide a default transparency for various commands, but that this could be tweaked. It is my impression that the same is currently true with other properties of definitions (if you don't know what options are activated, you won't fully know how the constant is defined)... |
PR coq/coq#19029 experiments adding
It seems that the only real pending question is the default opacity to give to a future support of |
I don't know if it was mentioned in the discussion. To unify the syntax, we would also need a way to tell that a non-mutual #[recursive] Theorem f binders : type := body. or Recursive Theorem f binders : type := body. This would then be applicable also to (Or maybe also adding Added: another way would be to add a new variant of |
To satisfy the three needs given in the motivation of the CEP:
I propose to respectively eventually implement in coq/coq#19029 the following new attributes:
The question of what would be the default opacity of (*) in the CEP, the keyword (**) pedagogy is also flexible: if really needed we can also explain why Coq does not follow the standard conventions. (***) somehow, something is still missing to tell that a theorem which is guarded both inductively and coinductively should be considered as a cofixpoint; for that purpose, a fixannot Would someone be unhappy with this proposal? |
The part of the previous comment about |
Rendered