-
Notifications
You must be signed in to change notification settings - Fork 763
Controlling typing flags #9004
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
Controlling typing flags #9004
Changes from 7 commits
04f278b
ef45cf8
8a7d8d2
5000fb1
79c76ea
7977e0f
55a987d
738eb14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -776,7 +776,9 @@ Simple inductive types | |||||
|
|
||||||
| The types of the constructors have to satisfy a *positivity condition* | ||||||
| (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 | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ``assume_positive`` (see :ref:`gallina-attributes`). | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
|
|
||||||
| .. exn:: The conclusion of @type is not valid; it must be built from @ident. | ||||||
|
|
||||||
|
|
@@ -1500,7 +1502,7 @@ the following attributes names are recognized: | |||||
| (see :ref:`programs`). | ||||||
|
|
||||||
| ``global``, ``local`` | ||||||
| Take no value, analogous to the ``Global`` and ``Local`` flags | ||||||
| Takes no value, analogous to the ``Global`` and ``Local`` flags | ||||||
| (see :ref:`controlling-locality-of-commands`). | ||||||
|
|
||||||
| ``deprecated`` | ||||||
|
|
@@ -1533,6 +1535,29 @@ the following attributes names are recognized: | |||||
| now foo. | ||||||
| Abort. | ||||||
|
|
||||||
| ``check_guarded``, ``assume_guarded`` | ||||||
| Takes no value. Enable/disable the guard checking of fixpoints during a | ||||||
| definition (see also :ref:`controlling-typing-flags`). Works with | ||||||
| :cmd:`Definition`, :cmd:`Fixpoint`, :cmd:`CoFixpoint`, :cmd:`Theorem` | ||||||
| (and its variants). | ||||||
|
|
||||||
| ``check_positive``, ``assume_positive`` | ||||||
| Takes no value. Enable/disable the positivity checking for the declaration | ||||||
| of an inductive type or the productivity checking for a coinductive type | ||||||
| (see also :ref:`controlling-typing-flags`). | ||||||
|
|
||||||
| ``check_universes``, ``type_in_type`` | ||||||
| Takes no value. Enable/disable the checking of universes during a definition | ||||||
| or the declaration of a (co)inductive type. | ||||||
| (see also :ref:`controlling-typing-flags`). | ||||||
|
|
||||||
| .. example:: | ||||||
|
|
||||||
| .. coqtop:: all reset | ||||||
|
|
||||||
| #[assume_guarded] Fixpoint f (n : nat) : False | ||||||
| := f n. | ||||||
|
|
||||||
| .. [1] | ||||||
| This is similar to the expression “*entry* :math:`\{` sep *entry* | ||||||
| :math:`\}`” in standard BNF, or “*entry* :math:`(` sep *entry* | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1202,6 +1202,66 @@ scope of their effect. There are four kinds of commands: | |
| occurs in a section. The :cmd:`Set` and :cmd:`Unset` commands belong to this | ||
| category. | ||
|
|
||
|
|
||
| .. _controlling-typing-flags: | ||
|
|
||
| Controlling Typing Flags | ||
| ---------------------------- | ||
|
|
||
| .. cmd:: Set Guard Checking | ||
| .. cmd:: Unset Guard Checking | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should instead document this as: .. flag:: Guard Checking |
||
|
|
||
| Enable/Disable the guard checking of fixpoints. Warning: this can break the | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flag to control... Use |
||
| consistency of the system, use at your own risk. Decreasing argument can | ||
| still be specified but the decrease is not checked anymore. Unchecked | ||
| fixpoint are printed by :cmd:`Print Assumptions`. | ||
|
|
||
| .. cmd:: Set Positivity Checking | ||
| .. cmd:: Unset Positivity Checking | ||
|
|
||
| Enable/Disable the positivity checking of inductive types and the productivity | ||
| checking of coinductive types. Warning: this can break the consistency of the | ||
| system, use at your own risk. Unchecked (co)inductive types are printed by | ||
| :cmd:`Print Assumptions`. | ||
|
|
||
| .. cmd:: Set Universes Checking | ||
| .. cmd:: Unset Universes Checking | ||
|
|
||
| Enable/Disable the checking of universes, providing a form of "type in type". | ||
| Warning: this breaks the consistency of the system, use at your own risk. | ||
| Constants relying on "type in type" are printed by :cmd:`Print Assumptions`. | ||
|
|
||
| .. cmd:: Print Typing Flags | ||
|
|
||
| Print the status of the three typing flags: check of guard, check of positivity | ||
| and check of universes. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This command is not necessary as it redoes the job of |
||
|
|
||
| .. example:: | ||
|
|
||
| .. coqtop:: all reset | ||
|
|
||
| Unset Guard Checking. | ||
|
|
||
| Print Typing Flags. | ||
|
|
||
| Fixpoint f (n : nat) : False | ||
| := f n. | ||
|
|
||
| Fixpoint ackermann (m n : nat) {struct m} : nat := | ||
| match m with | ||
| | 0 => S n | ||
| | S m => | ||
| match n with | ||
| | 0 => ackermann m 1 | ||
| | S n => ackermann m (ackermann (S m) n) | ||
| end | ||
| end. | ||
|
|
||
| Print Assumptions ackermann. | ||
|
|
||
| Note that the proper way to define the Ackermann function is to use | ||
| well-founded recursion (see :cmd:`Program Fixpoint`). | ||
|
|
||
| .. _exposing-constants-to-ocaml-libraries: | ||
|
|
||
| Exposing constants to OCaml libraries | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
|
|
||
| (* Print Typing Flags. *) | ||
| #[type_in_type, assume_guarded] Fixpoint f' (n : nat) : nat := f' n. | ||
|
|
||
| #[assume_guarded, local] Fixpoint f (n : nat) : nat. | ||
| Proof. | ||
| exact (f n). | ||
| (* Print Typing Flags. *) | ||
| Defined. | ||
|
|
||
| (* Print Typing Flags. *) | ||
|
|
||
| Unset Universes Checking. | ||
|
|
||
| (* Print Tables. *) | ||
| (* Test Universes Checking. *) | ||
|
|
||
| Definition T := Type. | ||
| Fixpoint g (n : nat) : T := T. | ||
|
|
||
| (* Print Typing Flags. *) | ||
| Set Universes Checking. | ||
|
|
||
| #[type_in_type] Fixpoint g1 (n : nat) : T. | ||
| Proof. | ||
| (* Print Typing Flags. *) | ||
| exact T. | ||
| Defined. | ||
| Set Universes Checking. | ||
|
|
||
| Fail Definition g2 (n : nat) : T := T. | ||
| #[type_in_type] Definition g2 (n : nat) : T := T. | ||
| (* Print Typing Flags. *) | ||
|
|
||
| Unset Guard Checking. | ||
| Fail #[check_guarded] Definition e := fix e (n : nat) : nat := e n. | ||
| Definition e := fix e (n : nat) : nat := e n. | ||
| Set Guard Checking. | ||
|
|
||
| #[assumed_positive] Inductive T := | ||
| y : (T -> T) -> T. | ||
|
|
||
| Unset Positivity Checking. | ||
| Inductive Cor := | ||
| | Over : Cor | ||
| | Next : ((Cor -> list nat) -> list nat) -> Cor. | ||
| Set Positivity Checking. | ||
| (* Print Typing Flags. *) | ||
| (* Print Assumptions Cor. *) | ||
|
|
||
|
|
||
|
|
||
| #[check_universes, assume_guarded] Definition e2 : nat -> nat. | ||
| Proof. | ||
| exact (fix e (n : nat) : nat := e n). | ||
| Defined. | ||
| (* Print Typing Flags. *) | ||
| Section b. | ||
| Unset Universes Checking. | ||
| Variable T : let t := Type in (t : t). | ||
| Definition T' := T. | ||
| (* Print Assumptions T'. *) | ||
| (* Print Typing Flags. *) | ||
| End b. | ||
| (* Print Typing Flags. *) | ||
| Set Universes Checking. | ||
| (* Print Assumptions T'. *) | ||
|
|
||
| (* Unset Universes Checking. *) | ||
| #[type_in_type] Inductive T4 := a : let t := Type in (t : t) -> T4. | ||
| Module b. | ||
| Unset Guard Checking. | ||
| Global Unset Universes Checking. | ||
| (* Disable Type In Type. *) | ||
| Definition T := let t := Type in (t : t). | ||
| (* Print Typing Flags. *) | ||
| End b. | ||
| (* Print Typing Flags. *) | ||
| Import b. | ||
| (* Print Typing Flags. *) | ||
| (* About T. *) | ||
| (* Print Assumptions T. *) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the comments or make this an output test. |
||
Uh oh!
There was an error while loading. Please reload this page.