Experiment the addition of sealed/defined attributes - #19029
Conversation
b5d663f to
e3c91ca
Compare
e3c91ca to
3e40fa2
Compare
|
Draft PR, removing the milestone. |
3e40fa2 to
f881a75
Compare
f881a75 to
6b63e32
Compare
herbelin
left a comment
There was a problem hiding this comment.
Thanks for the comments
| This can be used to define a term incrementally, in particular by relying on the :tacn:`refine` tactic. | ||
| In this case, the proof should be terminated with :cmd:`Defined` in order to define a :term:`constant` | ||
| for which the computational behavior is relevant. See :ref:`proof-editing-mode`. | ||
| In this case, the proof should normally be terminated with :cmd:`Defined`. See :ref:`proof-editing-mode`. |
There was a problem hiding this comment.
Yes, but we are talking here about definitions and Qed is unusual both in mathematical practice and in Coq scripts.
| --------------------------- | ||
|
|
||
| Definitions and theorems associate terms of some type to a name. In | ||
| the case of a definition (or assimilated, like :cmd:`Fixpoint` or |
| Definitions and theorems associate terms of some type to a name. In | ||
| the case of a definition (or assimilated, like :cmd:`Fixpoint` or | ||
| :cmd:`CoFixpoint`), the term is the body of the definition and the | ||
| type is the type of the body. In the case of a theorem (or | ||
| assimilated), the term is the proof and the type is the statement. |
There was a problem hiding this comment.
I moved the paragraph at the beginning of the section. Tell me what you think about it.
I did not rephrase it though because it is important I think to let open the idea that a definition can be build by tactics and a proof as a term.
| This attribute tells to prevent the unfoldability of a definition, | ||
| so that the definition behaves like an abstract definition. |
There was a problem hiding this comment.
I don't know what happend in my mind when I wrote the comment.
What I want to say is that it is more than preventing unfolding (which Opaque does in some sense). In the absence of a better choice, I reused "prevents the unfoldability of a definition".
| This command accepts the :attr:`program`, | ||
| :attr:`bypass_check(universes)`, and :attr:`bypass_check(guard)` attributes. | ||
| It also accepts the :attr:`sealed` attribute placed just before the | ||
| name (or names) defined by the fixpoint. |
| | REPLACE quoted_attributes ident_decl binders_fixannot type_cstr OPT [ ":=" lconstr ] decl_notations | ||
| | WITH quoted_attributes ident_decl binders_fixannot type_cstr OPT [ ":=" lconstr ] decl_notations |
| fix_definition: [ | ||
| | REPLACE ident_decl binders_fixannot type_cstr OPT [ ":=" lconstr ] decl_notations | ||
| | WITH ident_decl binders_fixannot type_cstr OPT [ ":=" lconstr ] decl_notations | ||
| | REPLACE quoted_attributes ident_decl binders_fixannot type_cstr OPT [ ":=" lconstr ] decl_notations | ||
| | WITH quoted_attributes ident_decl binders_fixannot type_cstr OPT [ ":=" lconstr ] decl_notations | ||
| ] | ||
|
|
||
| cofix_definition: [ | ||
| | REPLACE ident_decl binders type_cstr OPT [ ":=" lconstr ] decl_notations | ||
| | WITH ident_decl binders type_cstr OPT [ ":=" lconstr ] decl_notations | ||
| | REPLACE quoted_attributes ident_decl binders type_cstr OPT [ ":=" lconstr ] decl_notations | ||
| | WITH quoted_attributes ident_decl binders type_cstr OPT [ ":=" lconstr ] decl_notations | ||
| ] |
…in module parameter.
…int. Also adding some missing supported attributes.
…transparent. The main changes are: - "opaque" is now part of the Declare.CInfo.t (one per component of the proof) - at Qed/Defined time, a check is done to determine if there is an attribute which takes precedence over the Qed/Defined keyword; - for non-interactive declaration, Definition is transparent by default and (assuming the syntax provided as in rocq-prover#19301) Theorem requires an explicit attribute. - the attribute can be set both globally (before the command name) and locally (just before the names declared by the command)
Co-Authored-By: Jim Fehrle <jim.fehrle@gmail.com> Co-Authored-By: Zimmi48 <Zimmi48@users.noreply.github.com>
Done.
I added a commit experimenting this (to be eventually squashed if we adopt it). |
| New attributes :attr:`sealed` and :attr:`defined` allow to change | ||
| the default opacity (now called sealing to prevent the confusion | ||
| with the notion of opacity implemented by the command :cmd:`Opaque`) | ||
| of a definition or theorem |
There was a problem hiding this comment.
| New attributes :attr:`sealed` and :attr:`defined` allow to change | |
| the default opacity (now called sealing to prevent the confusion | |
| with the notion of opacity implemented by the command :cmd:`Opaque`) | |
| of a definition or theorem | |
| Attributes :attr:`sealed` and :attr:`defined` to set | |
| the opacity of a definition or theorem. :attr:`sealed` makes the object | |
| immutably opaque, unlike the :cmd:`Opaque` command, which makes | |
| an object mutably opaque |
Some of the wording was not idiomatic
Also "the confusion with the notion of opacity" doesn't tell you what the difference in notions is, so vague
|
The "needs: rebase" label was set more than 30 days ago. If the PR is not rebased in 30 days, it will be automatically closed. |
|
This PR was not rebased after 30 days despite the warning, it is now closed. |
The PR experiments the implementation of a proposal related to rocq-prover/rfcs#42. It adds attributes
sealedanddefinedthat allow to indicate the opacity of a definition defined non-interactively.When used in an interactive proof,
sealedanddefinedtake precedence overQedandDefined. Consequently, using an attribute in interactive mode allows to matchDefinitionwithDefinedandTheoremwithQedwithout impacting the opacity (since it is the attribute which takes precedence).In non-interactive mode, a
Definitionis declared defined in the absence of an atttribute whileTheoremmandatorily requires an attribute (however, the syntaxTheorem :=itself is eventually provided only in #19301).The main technical change is that the "opaque" value is now part of the
Declare.CInfo.twhile it was before passed as a standalone argument or stored in the program obligation state.Here are some examples:
Pending questions:
Fixpoint #[sealed] foo ...) or also in front of commands (as in#[sealed] Fixpoint foo ...) [but easier to done once Unifying the syntax of Definition, Theorem, Fixpoint and CoFixpoint (CEP #42) #19301 is merged]: now added also in frontDepends on: