Skip to content

Commit

Permalink
proof-stat: admitted proofs count as failing
Browse files Browse the repository at this point in the history
Change `proof-check-chunks' such that Admitted proofs are reported as
failing.
  • Loading branch information
hendriktews committed Jun 19, 2024
1 parent 71c807c commit 0e0170f
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 20 deletions.
4 changes: 2 additions & 2 deletions ci/simple-tests/proof_stat.human.exp-out
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Proof check results for proof_stat.v

4 opaque proofs recognized: 2 successful 2 FAILING
4 opaque proofs recognized: 1 successful 3 FAILING

FAIL a1_equal_4
OK b_equal_6
FAIL b2_equal_6
OK use_admit
FAIL use_admit


2 changes: 1 addition & 1 deletion ci/simple-tests/proof_stat.tap.exp-out
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ TAP version 13
not ok 1 a1_equal_4
ok 2 b_equal_6
not ok 3 b2_equal_6
ok 4 use_admit
not ok 4 use_admit


2 changes: 1 addition & 1 deletion ci/simple-tests/proof_stat.v
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Lemma b2_equal_6 : b = 2 * 3. (* FAIL *)
Proof using. (* this proof should fail *)
Qed.

Lemma use_admit : 0 = 1.
Lemma use_admit : 0 = 1. (* FAIL *)
Proof using. (* this proof succeeds but should count as failing *)
admit.
Admitted.
6 changes: 6 additions & 0 deletions coq/coq-syntax.el
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,12 @@ different."
:type 'string
:group 'coq)

(defcustom coq-omit-cheating-regexp "Admitted"
"Value for `proof-omit-cheating-regexp'.
Very similar to `coq-omit-proof-admit-command', but without the dot."
:type 'regexp
:group 'coq)

;; ----- keywords for font-lock.

(defvar coq-keywords-kill-goal
Expand Down
3 changes: 2 additions & 1 deletion coq/coq.el
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,8 @@ at `proof-assistant-settings-cmds' evaluation time.")
proof-script-definition-end-regexp coq-definition-end-regexp
proof-script-proof-admit-command coq-omit-proof-admit-command
proof-script-cmd-prevents-proof-omission #'coq-cmd-prevents-proof-omission
proof-script-cmd-force-next-proof-kept coq-cmd-force-next-proof-kept)
proof-script-cmd-force-next-proof-kept coq-cmd-force-next-proof-kept
proof-omit-cheating-regexp coq-omit-cheating-regexp)

;; proof-check-report/proof-check-annotate config
(setq
Expand Down
20 changes: 17 additions & 3 deletions doc/PG-adapting.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1289,9 +1289,12 @@ The other material is asserted in the usual way and
opaque proofs it first tries to assert them in the usual way too. If
this succeeds the proof is considered valid. Otherwise the proof is
replaced with @code{proof-script-proof-admit-command} and the proof is
considered invalid. To associate theorem names with opaque proofs, the
function @code{proof-get-proof-info-fn} is called, which is identical
to @code{proof-tree-get-proof-info}, @xref{Proof Tree Elisp
considered invalid. In order to consider Admitted proofs as invalid
ones, proofs whose last command matches
@code{proof-omit-cheating-regexp} count as invalid. To associate
theorem names with opaque proofs, the function
@code{proof-get-proof-info-fn} is called, which is identical to
@code{proof-tree-get-proof-info}, @xref{Proof Tree Elisp
configuration}.

To enable proof status statistics, the omit-proofs feature must be
Expand Down Expand Up @@ -1328,6 +1331,17 @@ This function takes a state as argument as returned by
the proof assistant back to the same state.
@end defvar

@c TEXI DOCSTRING MAGIC: proof-omit-cheating-regexp
@defvar proof-omit-cheating-regexp
Regular expression matching proof closing commands for incomplete proofs.@*
If set, this regular expression is applied to the last command of
opaque proofs. If it matches the proofs counts as invalid for the
proof-status statistics and annotation feature. For Coq this is
used to mark Admitted proofs as invalid.

This option can be left at @samp{nil}.
@end defvar


@node Safe (state-preserving) commands
@section Safe (state-preserving) commands
Expand Down
20 changes: 12 additions & 8 deletions doc/ProofGeneral.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2267,7 +2267,8 @@ in the current buffer, i.e., it generates an overview that shows which
of the opaque proofs in the current buffer are currently valid and
which are failing. When used interactively, the proof status is shown
in the buffer @code{*proof-check-report*} (as long as
@code{proof-check-report-buffer} is not changed).
@code{proof-check-report-buffer} is not changed). Note that incomplete
proofs, i.e., Admitted proofs for Coq, count as invalid.

The command @code{proof-check-annotate} (menu @code{Proof-General ->
Annotate Failing Proofs}) modifies the current buffer and places
Expand All @@ -2285,7 +2286,10 @@ only work for Coq.
Generate an overview about valid and invalid proofs.@*
This command completely processes the current buffer and
generates an overview about all the opaque proofs in it and
whether their proof scripts are valid or invalid.
whether their proof scripts are valid or invalid. Note that
proofs closed with a cheating command (see
@samp{@code{proof-omit-cheating-regexp}}), i.e., Admitted for Coq, count as
invalid.

This command makes sense for a development process where invalid
proofs are permitted and vos compilation and the omit proofs
Expand Down Expand Up @@ -5318,12 +5322,12 @@ The command @code{proof-check-report} (menu @code{Proof-General ->
Check Opaque Proofs}) generates the proof status of all opaque proofs
in the current buffer, i.e., it generates an overview that shows which
of the opaque proofs in the current buffer are currently valid and
which are failing. This command is useful for a development process
where invalid proofs are permitted and vos compilation (@xref{Quick
and inconsistent compilation}) and the omit proofs feature
(@xref{Omitting proofs for speed}) are used to work at the most
interesting or challenging point instead of on the first invalid
proof.
which are failing, where Admitted proofs count as failing. This
command is useful for a development process where invalid proofs are
permitted and vos compilation (@xref{Quick and inconsistent
compilation}) and the omit proofs feature (@xref{Omitting proofs for
speed}) are used to work at the most interesting or challenging point
instead of on the first invalid proof.

The command @code{proof-check-annotate} (menu @code{Proof-General ->
Annotate Failing Proofs}) can then be used to consistently annotate
Expand Down
21 changes: 17 additions & 4 deletions generic/pg-user.el
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,9 @@ errors are silently replaced by
`proof-script-proof-admit-command'. The result is a list of proof
status results, one for each 'proof chunk in the same order. Each
proof-status result is a list of 4 elements as follows.
- 1st: proof status as `t' or `nil'.
- 1st: proof status as `t' or `nil'. Proofs closed with a match
of `proof-omit-cheating-regexp', if defined, count as failing,
i.e., their status is `nil'.
- 2nd: the name of the proof as reported by
`proof-get-proof-info-fn'.
- 3rd: Position of the start of the span containing the theorem
Expand All @@ -762,7 +764,8 @@ proof-status result is a list of 4 elements as follows.
(nth 2 last-item)
(cons 'empty-action-list (nth 3 last-item))))
(vanillas-rev-updated (cons new-last-item (cdr vanillas-rev)))
error)
error
cheated)
;; if this is a proof chunk the next must be no-proof or must not exist
(cl-assert (or (not (eq this-mode 'proof))
(or (eq next-mode 'no-proof) (eq next-mode nil)))
Expand Down Expand Up @@ -813,8 +816,15 @@ proof-status result is a list of 4 elements as follows.
(proof-set-locked-end last-span-end)
(cl-assert (not (cadr (funcall proof-get-proof-info-fn)))
nil "proof-check: still in proof after admitting"))
(when (and proof-omit-cheating-regexp
;; check if somebody cheated - cheated proofs
;; should count as failing
(proof-string-match
proof-omit-cheating-regexp
(mapconcat #'identity (nth 1 last-item) " ")))
(setq cheated t))
(push
(cons (not error)
(cons (not (or error cheated))
(cons (cadr current-proof-state-and-name) proof-start-points))
proof-results)))

Expand Down Expand Up @@ -863,7 +873,10 @@ This function does not (re-)compile required files."
"Generate an overview about valid and invalid proofs.
This command completely processes the current buffer and
generates an overview about all the opaque proofs in it and
whether their proof scripts are valid or invalid.
whether their proof scripts are valid or invalid. Note that
proofs closed with a cheating command (see
`proof-omit-cheating-regexp'), i.e., Admitted for Coq, count as
invalid.
This command makes sense for a development process where invalid
proofs are permitted and vos compilation and the omit proofs
Expand Down
11 changes: 11 additions & 0 deletions generic/proof-config.el
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,17 @@ without surrounding space."
:type 'boolean
:group 'proof-script)

(defcustom proof-omit-cheating-regexp nil
"Regular expression matching proof closing commands for incomplete proofs.
If set, this regular expression is applied to the last command of
opaque proofs. If it matches the proofs counts as invalid for the
proof-status statistics and annotation feature. For Coq this is
used to mark Admitted proofs as invalid.
This option can be left at `nil'."
:type 'regexp
:group 'proof-script)

;; proof-omit-proofs-option is in proof-useropts as user option

(defcustom proof-script-proof-start-regexp nil
Expand Down

0 comments on commit 0e0170f

Please sign in to comment.