Warn on Qed Let declaration - #17205
Conversation
silene
left a comment
There was a problem hiding this comment.
This is bad. Turning the Let Qed tests into Let Defined ones makes it impossible to interactively navigate the files. For the sake of your sanity, I won't even copy-paste what Coqide looks like at that point.
It is better to disable the warning for these files and keep Let Qed. Hopefully, one day we have an actual command or attribute that make it possible to discard definitions from sections.
I don't see a way to have it make sense. |
Why? We already have a |
Actually this what the actual implementation does, then replays some stuff, IIRC, no? |
We could do something like the current Qed hack for Opaque variables, or only omit the bodies when printing the goal. It makes more sense for Opaque as that's not supposed to be as strong as Qed.
How is that related? I don't think I understand what you mean by "discard definitions from sections". |
|
I mean this: Section Foo.
Example foo : True.
Proof. exact I. Qed.
End Foo.
Reset Foo.
About foo.
(* foo not a defined object. *) |
|
That's great but what about when the user does: Section Foo.
Example foo : True.
Proof. exact I. Qed.
Definition bar : True.
Proof. apply foo. Defined.
End Foo.What is the definition of bar? |
|
There is no definition of |
|
So what you really want is a way to abort a section? |
|
That is another way to phrase it, yes. (Was "discard" really that strange a concept?) |
|
For me it was the phrasing as "discard definitions from sections" instead of "discard sections", the first one sounds like it is about discarding a subset of the section at least in the context of this PR. |
|
But to let @SkySkimmer make progress on this PR, you are suggesting to implement that feature before this one so that the behavior of the examples in the file are adequate? |
|
Not at all. I am suggesting that the changes to |
f303b3b to
c138405
Compare
I made a section per example instead, that way they don't interfere with each other. |
c138405 to
f4de42c
Compare
|
ping @silene about the new state of the PR |
|
I am fine with the way the examples are written. (I suppose that, in the long run, we should stop storing |
|
changed doc |
|
@coqbot merge now |
jfehrle
left a comment
There was a problem hiding this comment.
A few more wording suggestions
|
|
||
| .. warn:: @ident is declared opaque but this is not fully respected inside the section and not at all outside the section. | ||
|
|
||
| Terminating the proof for a :cmd:`Let` with :cmd:`Qed` with `Let` is not recommended. |
There was a problem hiding this comment.
a :cmd:`Let` with :cmd:`Qed` with `Let` -> a :cmd:`Let` with :cmd:`Qed`
| the body when checking, and it will be treated the same as a | ||
| :cmd:`Defined` `Let` when the section is closed. |
There was a problem hiding this comment.
the body when checking, and it will be treated the same as a
:cmd:`Defined` `Let` when the section is closed.
->
the body when checking. When the section is closed,
it will be treated as if :cmd:`Defined` had been specified.
(the same as a :cmd:`Defined` `Let` seemed awkward.)
Introduced in rocq-prover/rocq#17205
Introduced in rocq-prover/rocq#17205 Using `Local Lemma` is not satisfying (exposes the lemma and require manual introduction of hints). Replacing `Qed` with `Defined` doesn't seem to incur a noticable slowdown but clutters the proof context with bodies of the lemmas. So silencing the warning for now until Coq offers a way to automatically do the `clearbody` at beginning of each proof.
|
User report: the feature is indeed used in MathComp. Replacing What about having Otherwise, would it make sense to add an attribute |
Wouldn't that be the same as using Lemma with Qed? If that's what you want why not use Lemma?
That would be OK IMO |
|
While we're at it, I think it would be great to have attributes for Let declarations that allow to control their inlining at section closure. Such a mechanism seems to have a cross-section with the topic discussed here. |
No, |
Introduced in rocq-prover/rocq#17205 Using `Local Lemma` is not satisfying (exposes the lemma and require manual introduction of hints). Replacing `Qed` with `Defined` doesn't seem to incur a noticable slowdown but clutters the proof context with bodies of the lemmas. So silencing the warning for now until Coq offers a way to automatically do the `clearbody` at beginning of each proof.
Introduced in rocq-prover/rocq#17205 Using `Local Lemma` is not satisfying (exposes the lemma and require manual introduction of hints). Replacing `Qed` with `Defined` doesn't seem to incur a noticable slowdown but clutters the proof context with bodies of the lemmas. So silencing the warning for now until Coq offers a way to automatically do the `clearbody` at beginning of each proof.
|
Maybe an idle talk, but would it make sense to add an opaque flag also to local definitions, that is to have the additional typing rule: which, in other words, means to internalize the usual substitution as an explicit constructor of the syntax? |
|
How would it reduce? |
|
I guess we can consider that it reduces to Or we may also imagine that it is blocked (as it would be for a global definition), providing some proof-irrelevance, that is identifying |
|
BTW, what is the attribute to make opaque a |
But then isn't there no difference between
The point of clearbody is that it is not opaque, it is some adhoc thing for section letins. |
Yes, no difference except that one is a beta-redex and the other an explicit substitution. With an explicit substitution, one can directly simulate a context |
|
Is this the "ad hoc" thing you are mentioning? |
|
I still have my question: is there an attribute to tell that |
|
Isn't that basically rocq-prover/rfcs#42 ? |
|
Wouldn't it be more consistent to grant variable opacity for all declarations and not only for interactively proved declarations? Alternatively. would there be compatibility issues at making a Qed-ed or clearbody-ed local definition opaque for all the rest of the section? |
If only a decision is needed to at least already implement sealed/unsealed from rocq-prover/rfcs#42, I propose we take it! |
|
For the record, that is not a problem, but |
cf #10459