Skip to content
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

ProofGeneral does not handle "Proof term." directives #681

Closed
RalfJung opened this issue Jan 6, 2023 · 11 comments
Closed

ProofGeneral does not handle "Proof term." directives #681

RalfJung opened this issue Jan 6, 2023 · 11 comments

Comments

@RalfJung
Copy link

RalfJung commented Jan 6, 2023

Consider the following proof script:

Definition sth (n : nat) := True.
Lemma sth_all n : sth n. Proof. exact I. Qed.
Lemma sth_0 : sth 0. Proof sth_all 0.
Lemma sth_1 : sth 1. Proof sth_all 1.

ProofGeneral seems to be confused by these (very rarely used) Proof term. statements: when I step after that Proof sth_all 0. (directly giving the proof term instead of using tactics), it still shows an open goal. When I step to the end of the file it complains about nested proofs, but there are no nested proofs here. It then also shows an error, "Attempt to save an incomplete proof".

The same script works fine when being fed directly to coqc.

@erikmd
Copy link
Member

erikmd commented Jan 10, 2023

Thanks @RalfJung !

I know the Proof term. vernacular and use it sometimes, it's true that you found a workaround with the exact tactic but this is definitely something to fix!
Don't have the time to investigate, Cc-ing @ProofGeneral/core just in case… if another maintainer can take a look sooner.

Thanks again!

@Matafou
Copy link
Contributor

Matafou commented Jan 10, 2023

Hi.
Proof term is more or less supported (even indentation-wise), but this is indeed yet another instance of the known bug #568 that the goals buffer sometimes do not updated (here it should become empty).

@RalfJung
Copy link
Author

No I think this is not just a stale goal buffer issue. If I step all the way to the end of the file, I get an error: "Attempt to save an incomplete proof", even though the script completes when run via coqc. I also get warnings about nested proofs. So it does seem like PG is actually confused and got Coq into a wrong state. It seems as if only Proof. is sent to Coq, and the term is omitted.

@Matafou
Copy link
Contributor

Matafou commented Jan 10, 2023

I can't reproduce. Can you check your pg version and also if the coqtop pg is using is the one you think? It seems to work with coq-8.15.

@RalfJung
Copy link
Author

RalfJung commented Jan 31, 2023

This is with PG 8416875, Coq 8.16.1.

To reproduce:

  • open a file with the example script
  • C-c C-b

Then it prints two warnings:

Warning (comp): pg-user.el:489:41: Warning: docstring wider than 80 characters Disable showing Disable logging
Warning (proof-script): found second proof start at line 4 - are there nested proofs? Disable showing Disable logging

(the first warning disappears when I repeat this; I had quite a few such warnings the last weeks but they all seem to show up only once)
and an error

Error:  (in proof sth_1): Attempt to save an incomplete proof

My custom settings are

 '(coq-compile-before-require t)
 '(coq-compile-parallel-in-background t)
 '(coq-compile-quick 'no-quick)
 '(coq-compile-vos 'vos)
 '(coq-one-command-per-line nil)
 '(proof-follow-mode 'followdown)
 '(proof-next-command-insert-space nil)
 '(proof-omit-proofs-configured t)
 '(proof-omit-proofs-option t)
 '(proof-splash-enable nil)
 '(proof-three-window-enable t)
 '(proof-three-window-mode-policy 'hybrid)

@Matafou
Copy link
Contributor

Matafou commented Jan 31, 2023

OK. I can reproduce. This is rather strange. The following coqtop text session produces the error.

  • Notice that from Lemma sth_0 I paste each command one after the other.
  • Notice that I insert Set Silent/Unset Silent. at some points and that the error doe not occur if I don't.

Is this a coq bug? Why would Set Silent change the semantics?

Welcome to Coq 8.16.1

Coq < Definition sth (n : nat) := True.
sth is defined

Coq < Lemma sth_all n : sth n. Proof. exact I. Qed.
1 goal
  
  n : nat
  ============================
  sth n


No more goals.


Coq < Set Silent.

Coq < Lemma sth_0 : sth 0.

sth_0 < Proof sth_all 0.

Coq < Lemma sth_1 : sth 1. 

sth_1 < Unset Silent.

sth_1 < Proof sth_all 1.
Toplevel input, characters 0-16:
> Proof sth_all 1.
> ^^^^^^^^^^^^^^^^
Error:  (in proof sth_1): Attempt to save an incomplete proof

sth_1 < 

@Matafou
Copy link
Contributor

Matafou commented Jan 31, 2023

Or is it that the Proof command must happen exactly after the Lemma?

@RalfJung
Copy link
Author

Or is it that the Proof command must happen exactly after the Lemma?

Yeah that's what it looks like to me.

@Matafou
Copy link
Contributor

Matafou commented Jan 31, 2023

Mmh that is a strange semantics. How is it even checked by Coq?
I don't see any easy fix to this. Even a Print command between the 2 commands breaks the script.

@Matafou
Copy link
Contributor

Matafou commented Feb 1, 2023

Ho this is a known problem, even in Coq documentation. See #498. This coq feature is deprecated in coq's documentation.
I think we can close this bug report as duplicate of won't fix known bug.

@Matafou
Copy link
Contributor

Matafou commented Feb 1, 2023

@Matafou Matafou closed this as completed Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants