Skip to content

Controlling typing flags - #9004

Closed
SimonBoulier wants to merge 8 commits into
rocq-prover:masterfrom
SimonBoulier:typing_flags2
Closed

Controlling typing flags#9004
SimonBoulier wants to merge 8 commits into
rocq-prover:masterfrom
SimonBoulier:typing_flags2

Conversation

@SimonBoulier

Copy link
Copy Markdown
Contributor

This PR allows to locally (with attributes) / globally (with Set/Unset commands) enable and disable:

  • the guard checking
  • the positivity checking
  • the check of universes (providing "type in type")

For this, the check_guarded typing flag is split into check_guarded and check_positive.

For the moment the syntax of commands is: Set Guard Checking, Unset Guard Checking, Set/Unset Positivity Checking, Set/Unset Universes Checking.
And for attributes: check_guarded, assume_guarded, check_positive, assume_positive, check_universes, type_in_type.

This PR also adds a Print Typing Flags command which prints the status of those three flags, and improves a bit the output of Print Assumptions.

E.g.

#[type_in_type] Definition T := let t := Type in (t : t).

Unset Guard Checking.
Fixpoint e (n : nat) : nat := e n.

Print Typing Flags.

Kind: feature

  • Added / updated test-suite
  • Corresponding documentation was added / updated (including any warning and error messages added / removed / modified).
  • Entry added in CHANGES.md.

Any comment welcome.

@coqbot coqbot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Nov 15, 2018
Comment thread printing/printer.ml Outdated

let pr_typing_flags flags =
str "check_guarded: " ++ bool flags.check_guarded
++ str "\ncheck_positive: " ++ bool flags.check_positive

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an fnl() instead of \n.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, you can encapsulate the code into a box (e.g. a v 0 (...) to ensure that the fnl will align the next check exactly under the first check and not under the beginning of the box which encapsulates the call to pr_typing_flags (even if they probably coincide as the code is currently).

Import b.
(* Print Typing Flags. *)
(* About T. *)
(* Print Assumptions T. *)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the comments or make this an output test.

Comment thread vernac/comFixpoint.ml
let evd = Evd.from_ctx ctx in
Lemmas.start_proof_with_initialization (local,poly,DefinitionBody Fixpoint)
evd pl (Some(false,indexes,init_tac)) thms None (Lemmas.mk_hook (fun _ _ -> ()))
evd pl (Some(false,indexes,init_tac)) thms None (Lemmas.mk_hook (fun _ _ -> Global.set_typing_flags original_typing_flag))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems quite fragile. Let's try to come up with a better model for how to do this kind of thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should be handled more like how Program Mode is done.
OTOH

Require Import Program.Tactics.
Program Lemma foo : Type.
Proof.
  Test Program Mode. (* off *)

so that doesn't quite work.

In general attributes which act by setting a global option seem difficult to get right especially with proof-starting commands like Lemma.

Does it even make sense to have these typing flags in the global environment? Maybe we should pass them through the constant_entry/mind_entry/etc.This would mean handling them more like universe polymorphism, with an option which is used only to get the default value of the attribute. start_proof takes a goal_kind, if we put typing flags in there we may be able to make it work in the proof too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do other coq devs have any opinion?
Is it blocking or is it an "improvement request"?
Is goal_kind the right place for typing flags?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The right place will be in Declare.CInfo.t once #12372 is finished.

@Zimmi48 Zimmi48 added the kind: feature New user-facing feature request or implementation. label Nov 19, 2018
Comment thread doc/sphinx/language/gallina-specification-language.rst Outdated
(see Section :ref:`positivity`). This condition ensures the soundness of
the inductive definition.
the inductive definition. The positivity checking can be disable using
the command :cmd:`Unset Positivity Checking` or the attribute

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the command :cmd:`Unset Positivity Checking` or the attribute
the flag :flag:`Positivity Checking` or the attribute

the inductive definition.
the inductive definition. The positivity checking can be disable using
the command :cmd:`Unset Positivity Checking` or the attribute
``assume_positive`` (see :ref:`gallina-attributes`).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to show a small example, which may also help explaining what the use cases are. Actually, since you have put this example in another section, a link to this section would also be fine (use .. seealso::).

----------------------------

.. cmd:: Set Guard Checking
.. cmd:: Unset Guard Checking

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should instead document this as:

.. flag:: Guard Checking

.. cmd:: Set Guard Checking
.. cmd:: Unset Guard Checking

Enable/Disable the guard checking of fixpoints. Warning: this can break the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flag to control...

Use .. warning::

.. cmd:: Print Typing Flags

Print the status of the three typing flags: check of guard, check of positivity
and check of universes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command is not necessary as it redoes the job of Test Universe Checking, Test Positivity Checking, Test Guard Checking.

Co-Authored-By: Théo Zimmermann <theo.zimmermann@univ-paris-diderot.fr>
@SimonBoulier

Copy link
Copy Markdown
Contributor Author

The part without attributes has been merged.

ejgallego added a commit to ejgallego/coq that referenced this pull request Jun 25, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Jun 25, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Jun 29, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Jun 30, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Jul 1, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Jul 2, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Jul 20, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Oct 15, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
@ejgallego

Copy link
Copy Markdown
Contributor

Rest implemented in #12586

ejgallego added a commit to ejgallego/coq that referenced this pull request Oct 16, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Oct 19, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Nov 18, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Nov 18, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Nov 18, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Nov 19, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Nov 20, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Nov 20, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
ejgallego added a commit to ejgallego/coq that referenced this pull request Nov 26, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.
gares pushed a commit to gares/coq that referenced this pull request Nov 28, 2020
We use the new `Declare.Info` structure to uniformly add properties to
the handling of constants. In this case, per-constant typing flags.

The internal code may want to see some further refactoring, including
pushing the flags down to `Safe_typing.add_constant` , but the changes
in the interface should be definitive.

This will allow rocq-prover#12539 and rocq-prover#9004 using attributes.

(cherry picked from commit b531ef3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: feature New user-facing feature request or implementation. needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants