aboutsummaryrefslogtreecommitdiff
path: root/doc/sphinx/proof-engine
diff options
context:
space:
mode:
Diffstat (limited to 'doc/sphinx/proof-engine')
-rw-r--r--doc/sphinx/proof-engine/detailed-tactic-examples.rst4
-rw-r--r--doc/sphinx/proof-engine/ltac.rst32
-rw-r--r--doc/sphinx/proof-engine/ltac2.rst16
-rw-r--r--doc/sphinx/proof-engine/proof-handling.rst10
-rw-r--r--doc/sphinx/proof-engine/ssreflect-proof-language.rst30
-rw-r--r--doc/sphinx/proof-engine/tactics.rst212
-rw-r--r--doc/sphinx/proof-engine/vernacular-commands.rst961
7 files changed, 443 insertions, 822 deletions
diff --git a/doc/sphinx/proof-engine/detailed-tactic-examples.rst b/doc/sphinx/proof-engine/detailed-tactic-examples.rst
index 0ace9ef5b9..b63ae32311 100644
--- a/doc/sphinx/proof-engine/detailed-tactic-examples.rst
+++ b/doc/sphinx/proof-engine/detailed-tactic-examples.rst
@@ -353,7 +353,7 @@ the optional tactic of the ``Hint Rewrite`` command.
.. coqtop:: in reset
- Require Import Omega.
+ Require Import Lia.
.. coqtop:: in
@@ -367,7 +367,7 @@ the optional tactic of the ``Hint Rewrite`` command.
.. coqtop:: in
- Hint Rewrite g0 g1 g2 using omega : base1.
+ Hint Rewrite g0 g1 g2 using lia : base1.
.. coqtop:: in
diff --git a/doc/sphinx/proof-engine/ltac.rst b/doc/sphinx/proof-engine/ltac.rst
index b2b426ada5..b184311bef 100644
--- a/doc/sphinx/proof-engine/ltac.rst
+++ b/doc/sphinx/proof-engine/ltac.rst
@@ -174,6 +174,14 @@ mode but it can also be used in toplevel definitions as shown below.
ltac_def : `ident` [`ident` ... `ident`] := `ltac_expr`
: `qualid` [`ident` ... `ident`] ::= `ltac_expr`
+Tactics in terms
+~~~~~~~~~~~~~~~~
+
+.. insertprodn term_ltac term_ltac
+
+.. prodn::
+ term_ltac ::= ltac : ( @ltac_expr )
+
.. _ltac-semantics:
Semantics
@@ -258,6 +266,9 @@ following form:
Goal selectors
~~~~~~~~~~~~~~
+.. todo: mention this applies to Print commands and the Info command
+
+
We can restrict the application of a tactic to a subset of the currently
focused goals with:
@@ -471,7 +482,7 @@ Soft cut
~~~~~~~~
Another way of restricting backtracking is to restrict a tactic to a
-single success *a posteriori*:
+single success:
.. tacn:: once @ltac_expr
:name: once
@@ -1712,6 +1723,7 @@ performance issue.
.. coqtop:: reset in
+ Set Warnings "-omega-is-deprecated".
Require Import Coq.omega.Omega.
Ltac mytauto := tauto.
@@ -1774,16 +1786,22 @@ performance issue.
and allow displaying and resetting the profile from tactic scripts for
benchmarking purposes.
+.. warn:: Ltac Profiler encountered an invalid stack (no \
+ self node). This can happen if you reset the profile during \
+ tactic execution
+
+ Currently, :tacn:`reset ltac profile` is not very well-supported,
+ as it clears all profiling information about all tactics, including
+ ones above the current tactic. As a result, the profiler has
+ trouble understanding where it is in tactic execution. This mixes
+ especially poorly with backtracking into multi-success tactics. In
+ general, non-top-level calls to :tacn:`reset ltac profile` should
+ be avoided.
+
You can also pass the ``-profile-ltac`` command line option to ``coqc``, which
turns the :flag:`Ltac Profiling` flag on at the beginning of each document,
and performs a :cmd:`Show Ltac Profile` at the end.
-.. warning::
-
- Note that the profiler currently does not handle backtracking into
- multi-success tactics, and issues a warning to this effect in many cases
- when such backtracking occurs.
-
Run-time optimization tactic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/sphinx/proof-engine/ltac2.rst b/doc/sphinx/proof-engine/ltac2.rst
index 06106a6b4c..35062e0057 100644
--- a/doc/sphinx/proof-engine/ltac2.rst
+++ b/doc/sphinx/proof-engine/ltac2.rst
@@ -510,9 +510,9 @@ Static semantics
****************
During internalization, Coq variables are resolved and antiquotations are
-type-checked as Ltac2 terms, effectively producing a ``glob_constr`` in Coq
+type checked as Ltac2 terms, effectively producing a ``glob_constr`` in Coq
implementation terminology. Note that although it went through the
-type-checking of **Ltac2**, the resulting term has not been fully computed and
+type checking of **Ltac2**, the resulting term has not been fully computed and
is potentially ill-typed as a runtime **Coq** term.
.. example::
@@ -523,12 +523,12 @@ is potentially ill-typed as a runtime **Coq** term.
Ltac2 myconstr () := constr:(nat -> 0).
-Term antiquotations are type-checked in the enclosing Ltac2 typing context
+Term antiquotations are type checked in the enclosing Ltac2 typing context
of the corresponding term expression.
.. example::
- The following will type-check, with type `constr`.
+ The following will type check, with type `constr`.
.. coqdoc::
@@ -539,7 +539,7 @@ expanded by the Coq binders from the term.
.. example::
- The following Ltac2 expression will **not** type-check::
+ The following Ltac2 expression will **not** type check::
`constr:(fun x : nat => ltac2:(exact x))`
`(* Error: Unbound variable 'x' *)`
@@ -583,7 +583,7 @@ Dynamic semantics
*****************
During evaluation, a quoted term is fully evaluated to a kernel term, and is
-in particular type-checked in the current environment.
+in particular type checked in the current environment.
Evaluation of a quoted term goes as follows.
@@ -602,7 +602,7 @@ whole expression will thus evaluate to the term :g:`fun H : nat => H`.
`let tac () := hyp @H in constr:(fun H : nat => ltac2:(tac ()))`
-Many standard tactics perform type-checking of their argument before going
+Many standard tactics perform type checking of their argument before going
further. It is your duty to ensure that terms are well-typed when calling
such tactics. Failure to do so will result in non-recoverable exceptions.
@@ -700,7 +700,7 @@ The following scopes are built-in.
+ parses :n:`c = @term` and produces :n:`constr:(c)`
- This scope can be parameterized by a list of delimiting keys of interpretation
+ This scope can be parameterized by a list of delimiting keys of notation
scopes (as described in :ref:`LocalInterpretationRulesForNotations`),
describing how to interpret the parsed term. For instance, :n:`constr(A, B)`
parses :n:`c = @term` and produces :n:`constr:(c%A%B)`.
diff --git a/doc/sphinx/proof-engine/proof-handling.rst b/doc/sphinx/proof-engine/proof-handling.rst
index 03eebc32f9..cf4d432f64 100644
--- a/doc/sphinx/proof-engine/proof-handling.rst
+++ b/doc/sphinx/proof-engine/proof-handling.rst
@@ -41,8 +41,8 @@ terms are called *proof terms*.
.. _proof-editing-mode:
-Switching on/off the proof editing mode
--------------------------------------------
+Entering and leaving proof editing mode
+---------------------------------------
The proof editing mode is entered by asserting a statement, which typically is
the assertion of a theorem using an assertion command like :cmd:`Theorem`. The
@@ -90,9 +90,7 @@ list of assertion commands is given in :ref:`Assertions`. The command
.. cmd:: Save @ident
:name: Save
- Forces the name of the original goal to be :token:`ident`. This
- command can only be used if the original goal
- was opened using the :cmd:`Goal` command.
+ Forces the name of the original goal to be :token:`ident`.
.. cmd:: Admitted
@@ -821,7 +819,7 @@ in compacted hypotheses:
..
.. image:: ../_static/diffs-coqide-compacted.png
- :alt: coqide with Set Diffs on with compacted hyptotheses
+ :alt: coqide with Set Diffs on with compacted hypotheses
Controlling the effect of proof editing commands
------------------------------------------------
diff --git a/doc/sphinx/proof-engine/ssreflect-proof-language.rst b/doc/sphinx/proof-engine/ssreflect-proof-language.rst
index 90a991794f..4be18ccda9 100644
--- a/doc/sphinx/proof-engine/ssreflect-proof-language.rst
+++ b/doc/sphinx/proof-engine/ssreflect-proof-language.rst
@@ -286,7 +286,7 @@ example, the null and all list function(al)s can be defined as follows:
.. coqtop:: all
Variable d: Set.
- Fixpoint null (s : list d) :=
+ Definition null (s : list d) :=
if s is nil then true else false.
Variable a : d -> bool.
Fixpoint all (s : list d) : bool :=
@@ -1624,9 +1624,15 @@ previous :token:`i_item` have been performed.
The second entry in the :token:`i_view` grammar rule,
``/ltac:(`` :token:`tactic` ``)``, executes :token:`tactic`.
-Notations can be used to name tactics, for example::
+Notations can be used to name tactics, for example
- Notation myop := (ltac:(some ltac code)) : ssripat_scope.
+.. coqtop:: none
+
+ Tactic Notation "my" "ltac" "code" := idtac.
+
+.. coqtop:: in warn
+
+ Notation "'myop'" := (ltac:(my ltac code)) : ssripat_scope.
lets one write just ``/myop`` in the intro pattern. Note the scope
annotation: views are interpreted opening the ``ssripat`` scope.
@@ -2607,7 +2613,7 @@ After the :token:`i_pattern`, a list of binders is allowed.
.. coqtop:: reset none
From Coq Require Import ssreflect.
- From Coq Require Import Omega.
+ From Coq Require Import ZArith Lia.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
@@ -2615,7 +2621,7 @@ After the :token:`i_pattern`, a list of binders is allowed.
.. coqtop:: all
Lemma test : True.
- have H x (y : nat) : 2 * x + y = x + x + y by omega.
+ have H x (y : nat) : 2 * x + y = x + x + y by lia.
A proof term provided after ``:=`` can mention these bound variables
(that are automatically introduced with the given names).
@@ -2625,7 +2631,7 @@ with parentheses even if no type is specified:
.. coqtop:: all restart
- have (x) : 2 * x = x + x by omega.
+ have (x) : 2 * x = x + x by lia.
The :token:`i_item` and :token:`s_item` can be used to interpret the asserted
hypothesis with views (see section :ref:`views_and_reflection_ssr`) or simplify the resulting
@@ -2668,9 +2674,9 @@ context entry name.
Arguments Sub {_} _ _.
Lemma test n m (H : m + 1 < n) : True.
- have @i : 'I_n by apply: (Sub m); omega.
+ have @i : 'I_n by apply: (Sub m); lia.
-Note that the subterm produced by :tacn:`omega` is in general huge and
+Note that the subterm produced by :tacn:`lia` is in general huge and
uninteresting, and hence one may want to hide it.
For this purpose the ``[: name ]`` intro pattern and the tactic
``abstract`` (see :ref:`abstract_ssr`) are provided.
@@ -2680,7 +2686,7 @@ For this purpose the ``[: name ]`` intro pattern and the tactic
.. coqtop:: all abort
Lemma test n m (H : m + 1 < n) : True.
- have [:pm] @i : 'I_n by apply: (Sub m); abstract: pm; omega.
+ have [:pm] @i : 'I_n by apply: (Sub m); abstract: pm; lia.
The type of ``pm`` can be cleaned up by its annotation ``(*1*)`` by just
simplifying it. The annotations are there for technical reasons only.
@@ -2694,7 +2700,7 @@ with have and an explicit term, they must be used as follows:
Lemma test n m (H : m + 1 < n) : True.
have [:pm] @i : 'I_n := Sub m pm.
- by omega.
+ by lia.
In this case the abstract constant ``pm`` is assigned by using it in
the term that follows ``:=`` and its corresponding goal is left to be
@@ -2712,7 +2718,7 @@ makes use of it).
.. coqtop:: all abort
Lemma test n m (H : m + 1 < n) : True.
- have [:pm] @i k : 'I_(n+k) by apply: (Sub m); abstract: pm k; omega.
+ have [:pm] @i k : 'I_(n+k) by apply: (Sub m); abstract: pm k; lia.
Last, notice that the use of intro patterns for abstract constants is
orthogonal to the transparent flag ``@`` for have.
@@ -2963,7 +2969,7 @@ illustrated in the following example.
.. coqtop:: reset none
- From Coq Require Import ssreflect Omega.
+ From Coq Require Import ssreflect Lia.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
diff --git a/doc/sphinx/proof-engine/tactics.rst b/doc/sphinx/proof-engine/tactics.rst
index 19573eee43..8989dd29ab 100644
--- a/doc/sphinx/proof-engine/tactics.rst
+++ b/doc/sphinx/proof-engine/tactics.rst
@@ -51,6 +51,11 @@ specified, the default selector is used.
tactic_invocation : `toplevel_selector` : `tactic`.
: `tactic`.
+.. todo: fully describe selectors. At the moment, ltac has a fairly complete description
+
+.. todo: mention selectors can be applied to some commands, such as
+ Check, Search, SearchHead, SearchPattern, SearchRewrite.
+
.. opt:: Default Goal Selector "@toplevel_selector"
:name: Default Goal Selector
@@ -1870,6 +1875,7 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
Lemma induction_test : forall n:nat, n = n -> n <= n.
intros n H.
induction n.
+ exact (le_n 0).
.. exn:: Not an inductive product.
:undocumented:
@@ -2071,7 +2077,7 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
Now we are in a contradictory context and the proof can be solved.
- .. coqtop:: all
+ .. coqtop:: all abort
inversion H.
@@ -2099,68 +2105,7 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
See also the larger example of :tacn:`dependent induction`
and an explanation of the underlying technique.
-.. tacn:: function induction (@qualid {+ @term})
- :name: function induction
-
- The tactic functional induction performs case analysis and induction
- following the definition of a function. It makes use of a principle
- generated by ``Function`` (see :ref:`advanced-recursive-functions`) or
- ``Functional Scheme`` (see :ref:`functional-scheme`).
- Note that this tactic is only available after a ``Require Import FunInd``.
-
-.. example::
-
- .. coqtop:: reset all
-
- Require Import FunInd.
- Functional Scheme minus_ind := Induction for minus Sort Prop.
- Check minus_ind.
- Lemma le_minus (n m:nat) : n - m <= n.
- functional induction (minus n m) using minus_ind; simpl; auto.
- Qed.
-
-.. note::
- :n:`(@qualid {+ @term})` must be a correct full application
- of :n:`@qualid`. In particular, the rules for implicit arguments are the
- same as usual. For example use :n:`@qualid` if you want to write implicit
- arguments explicitly.
-
-.. note::
- Parentheses around :n:`@qualid {+ @term}` are not mandatory and can be skipped.
-
-.. note::
- :n:`functional induction (f x1 x2 x3)` is actually a wrapper for
- :n:`induction x1, x2, x3, (f x1 x2 x3) using @qualid` followed by a cleaning
- phase, where :n:`@qualid` is the induction principle registered for :g:`f`
- (by the ``Function`` (see :ref:`advanced-recursive-functions`) or
- ``Functional Scheme`` (see :ref:`functional-scheme`)
- command) corresponding to the sort of the goal. Therefore
- ``functional induction`` may fail if the induction scheme :n:`@qualid` is not
- defined. See also :ref:`advanced-recursive-functions` for the function
- terms accepted by ``Function``.
-
-.. note::
- There is a difference between obtaining an induction scheme
- for a function by using :g:`Function` (see :ref:`advanced-recursive-functions`)
- and by using :g:`Functional Scheme` after a normal definition using
- :g:`Fixpoint` or :g:`Definition`. See :ref:`advanced-recursive-functions`
- for details.
-
-.. seealso:: :ref:`advanced-recursive-functions`, :ref:`functional-scheme` and :tacn:`inversion`
-
-.. exn:: Cannot find induction information on @qualid.
- :undocumented:
-
-.. exn:: Not the right number of induction arguments.
- :undocumented:
-
-.. tacv:: functional induction (@qualid {+ @term}) as @simple_intropattern using @term with @bindings_list
-
- Similarly to :tacn:`induction` and :tacn:`elim`, this allows giving
- explicitly the name of the introduced variables, the induction principle, and
- the values of dependent premises of the elimination scheme, including
- *predicates* for mutual induction when :n:`@qualid` is part of a mutually
- recursive definition.
+.. seealso:: :tacn:`functional induction`
.. tacn:: discriminate @term
:name: discriminate
@@ -2667,6 +2612,8 @@ and an explanation of the underlying technique.
assumption.
Qed.
+.. seealso:: :tacn:`functional inversion`
+
.. tacn:: fix @ident @num
:name: fix
@@ -3032,8 +2979,8 @@ following:
For backward compatibility, the notation :n:`in {+ @ident}` performs
the conversion in hypotheses :n:`{+ @ident}`.
-.. tacn:: cbv {* @flag}
- lazy {* @flag}
+.. tacn:: {? @strategy_flag }
+ lazy {? @strategy_flag }
:name: cbv; lazy
These parameterized reduction tactics apply to any goal and perform
@@ -3129,8 +3076,10 @@ the conversion in hypotheses :n:`{+ @ident}`.
.. flag:: NativeCompute Timing
This flag causes all calls to the native compiler to print
- timing information for the compilation, execution, and
- reification phases of native compilation.
+ timing information for the conversion to native code,
+ compilation, execution, and reification phases of native
+ compilation. Timing is printed in units of seconds of
+ wall-clock time.
.. flag:: NativeCompute Profiling
@@ -3180,6 +3129,7 @@ the conversion in hypotheses :n:`{+ @ident}`.
head normal form according to the :math:`\beta`:math:`\delta`:math:`\iota`:math:`\zeta`-reduction rules, i.e. it
reduces the head of the goal until it becomes a product or an
irreducible term. All inner :math:`\beta`:math:`\iota`-redexes are also reduced.
+ The behavior of both :tacn:`hnf` can be tuned using the :cmd:`Arguments` command.
Example: The term :g:`fun n : nat => S n + S n` is not reduced by :n:`hnf`.
@@ -3206,76 +3156,10 @@ the conversion in hypotheses :n:`{+ @ident}`.
The :tacn:`cbn` tactic accepts the same flags as :tacn:`cbv` and
:tacn:`lazy`. The behavior of both :tacn:`simpl` and :tacn:`cbn`
- can be tuned using the Arguments vernacular command as follows:
-
- + A constant can be marked to be never unfolded by :tacn:`cbn` or
- :tacn:`simpl`:
-
- .. example::
-
- .. coqtop:: all
-
- Arguments minus n m : simpl never.
-
- After that command an expression like :g:`(minus (S x) y)` is left
- untouched by the tactics :tacn:`cbn` and :tacn:`simpl`.
-
- + A constant can be marked to be unfolded only if applied to enough
- arguments. The number of arguments required can be specified using the
- ``/`` symbol in the argument list of the :cmd:`Arguments` command.
+ can be tuned using the :cmd:`Arguments` command.
- .. example::
-
- .. coqtop:: all
-
- Definition fcomp A B C f (g : A -> B) (x : A) : C := f (g x).
- Arguments fcomp {A B C} f g x /.
- Notation "f \o g" := (fcomp f g) (at level 50).
-
- After that command the expression :g:`(f \o g)` is left untouched by
- :tacn:`simpl` while :g:`((f \o g) t)` is reduced to :g:`(f (g t))`.
- The same mechanism can be used to make a constant volatile, i.e.
- always unfolded.
-
- .. example::
-
- .. coqtop:: all
-
- Definition volatile := fun x : nat => x.
- Arguments volatile / x.
-
- + A constant can be marked to be unfolded only if an entire set of
- arguments evaluates to a constructor. The ``!`` symbol can be used to mark
- such arguments.
-
- .. example::
-
- .. coqtop:: all
-
- Arguments minus !n !m.
-
- After that command, the expression :g:`(minus (S x) y)` is left untouched
- by :tacn:`simpl`, while :g:`(minus (S x) (S y))` is reduced to :g:`(minus x y)`.
-
- + A special heuristic to determine if a constant has to be unfolded
- can be activated with the following command:
-
- .. example::
-
- .. coqtop:: all
-
- Arguments minus n m : simpl nomatch.
-
- The heuristic avoids to perform a simplification step that would expose a
- match construct in head position. For example the expression
- :g:`(minus (S (S x)) (S y))` is simplified to :g:`(minus (S x) y)`
- even if an extra simplification is possible.
-
- In detail, the tactic :tacn:`simpl` first applies :math:`\beta`:math:`\iota`-reduction. Then, it
- expands transparent constants and tries to reduce further using :math:`\beta`:math:`\iota`-reduction.
- But, when no :math:`\iota` rule is applied after unfolding then
- :math:`\delta`-reductions are not applied. For instance trying to use :tacn:`simpl` on
- :g:`(plus n O) = n` changes nothing.
+ .. todo add "See <subsection about controlling the behavior of reduction strategies>"
+ to TBA section
Notice that only transparent constants whose name can be reused in the
recursive calls are possibly unfolded by :tacn:`simpl`. For instance a
@@ -4003,10 +3887,10 @@ At Coq startup, only the core database is nonempty and can be used.
:arith: This database contains all lemmas about Peano’s arithmetic proved in the
directories Init and Arith.
-:zarith: contains lemmas about binary signed integers from the directories
- theories/ZArith. When required, the module Omega also extends the
- database zarith with a high-cost hint that calls ``omega`` on equations
- and inequalities in ``nat`` or ``Z``.
+:zarith: contains lemmas about binary signed integers from the
+ directories theories/ZArith. The database also contains
+ high-cost hints that call :tacn:`lia` on equations and
+ inequalities in ``nat`` or ``Z``.
:bool: contains lemmas about booleans, mostly from directory theories/Bool.
@@ -4597,42 +4481,6 @@ symbol :g:`=`.
Analogous to :tacn:`dependent rewrite ->` but uses the equality from right to
left.
-Inversion
----------
-
-.. tacn:: functional inversion @ident
- :name: functional inversion
-
- :tacn:`functional inversion` is a tactic that performs inversion on hypothesis
- :n:`@ident` of the form :n:`@qualid {+ @term} = @term` or :n:`@term = @qualid
- {+ @term}` where :n:`@qualid` must have been defined using Function (see
- :ref:`advanced-recursive-functions`). Note that this tactic is only
- available after a ``Require Import FunInd``.
-
- .. exn:: Hypothesis @ident must contain at least one Function.
- :undocumented:
-
- .. exn:: Cannot find inversion information for hypothesis @ident.
-
- This error may be raised when some inversion lemma failed to be generated by
- Function.
-
-
- .. tacv:: functional inversion @num
-
- This does the same thing as :n:`intros until @num` followed by
- :n:`functional inversion @ident` where :token:`ident` is the
- identifier for the last introduced hypothesis.
-
- .. tacv:: functional inversion @ident @qualid
- functional inversion @num @qualid
-
- If the hypothesis :token:`ident` (or :token:`num`) has a type of the form
- :n:`@qualid__1 {+ @term__i } = @qualid__2 {+ @term__j }` where
- :n:`@qualid__1` and :n:`@qualid__2` are valid candidates to
- functional inversion, this variant allows choosing which :token:`qualid`
- is inverted.
-
Classical tactics
-----------------
@@ -4689,18 +4537,6 @@ Automating
The goal is not of the form :g:`t = u`. Especially note that :tacn:`btauto`
doesn't introduce variables into the context on its own.
-.. tacn:: omega
- :name: omega
-
- The tactic :tacn:`omega`, due to Pierre Crégut, is an automatic decision
- procedure for Presburger arithmetic. It solves quantifier-free
- formulas built with `~`, `\\/`, `/\\`, `->` on top of equalities,
- inequalities and disequalities on both the type :g:`nat` of natural numbers
- and :g:`Z` of binary integers. This tactic must be loaded by the command
- ``Require Import Omega``. See the additional documentation about omega
- (see Chapter :ref:`omega`).
-
-
.. tacn:: ring
:name: ring
diff --git a/doc/sphinx/proof-engine/vernacular-commands.rst b/doc/sphinx/proof-engine/vernacular-commands.rst
index b22c5286fe..1759264e87 100644
--- a/doc/sphinx/proof-engine/vernacular-commands.rst
+++ b/doc/sphinx/proof-engine/vernacular-commands.rst
@@ -6,18 +6,28 @@ Vernacular commands
.. _displaying:
Displaying
---------------
+----------
.. _Print:
-.. cmd:: Print @qualid
- :name: Print
+.. cmd:: Print {? Term } @smart_qualid {? @univ_name_list }
+
+ .. insertprodn univ_name_list univ_name_list
+
+ .. prodn::
+ univ_name_list ::= @%{ {* @name } %}
- This command displays on the screen information about the declared or
- defined object referred by :n:`@qualid`.
+ Displays definitions of terms, including opaque terms, for the object :n:`@smart_qualid`.
- Error messages:
+ * :n:`Term` - a syntactic marker to allow printing a term
+ that is the same as one of the various :n:`Print` commands. For example,
+ :cmd:`Print All` is a different command, while :n:`Print Term All` shows
+ information on the object whose name is ":n:`All`".
+
+ * :n:`@univ_name_list` - locally renames the
+ polymorphic universes of :n:`@smart_qualid`.
+ The name `_` means the usual name is printed.
.. exn:: @qualid not a defined object.
:undocumented:
@@ -29,350 +39,146 @@ Displaying
:undocumented:
- .. cmdv:: Print Term @qualid
- :name: Print Term
-
- This is a synonym of :cmd:`Print` :n:`@qualid` when :n:`@qualid`
- denotes a global constant.
-
- .. cmdv:: Print {? Term } @qualid\@@name
-
- This locally renames the polymorphic universes of :n:`@qualid`.
- An underscore means the usual name is printed.
-
-
-.. cmd:: About @qualid
- :name: About
-
- This displays various information about the object
- denoted by :n:`@qualid`: its kind (module, constant, assumption, inductive,
- constructor, abbreviation, …), long name, type, implicit arguments and
- argument scopes. It does not print the body of definitions or proofs.
-
- .. cmdv:: About @qualid\@@name
-
- This locally renames the polymorphic universes of :n:`@qualid`.
- An underscore means the usual name is printed.
-
-
.. cmd:: Print All
This command displays information about the current state of the
environment, including sections and modules.
- .. cmdv:: Inspect @num
- :name: Inspect
-
- This command displays the :n:`@num` last objects of the
- current environment, including sections and modules.
-
- .. cmdv:: Print Section @ident
-
- The name :n:`@ident` should correspond to a currently open section,
- this command displays the objects defined since the beginning of this
- section.
-
-
-.. _flags-options-tables:
-
-Flags, Options and Tables
------------------------------
-
-Coq has many settings to control its behavior. Setting types include flags, options
-and tables:
-
-* A :production:`flag` has a boolean value, such as :flag:`Asymmetric Patterns`.
-* An :production:`option` generally has a numeric or string value, such as :opt:`Firstorder Depth`.
-* A :production:`table` contains a set of strings or qualids.
-* In addition, some commands provide settings, such as :cmd:`Extraction Language`.
-
-.. FIXME Convert "Extraction Language" to an option.
-
-Flags, options and tables are identified by a series of identifiers, each with an initial
-capital letter.
-
-.. cmd:: Set @flag
- :name: Set
-
- Sets :token:`flag` on.
-
-.. cmd:: Unset @flag
- :name: Unset
-
- Sets :token:`flag` off.
-
-.. cmd:: Test @flag
-
- Prints the current value of :token:`flag`.
-
-
-.. cmd:: Set @option {| @num | @string }
- :name: Set @option
-
- Sets :token:`option` to the specified value.
-
-.. cmd:: Unset @option
- :name: Unset @option
-
- Sets :token:`option` to its default value.
-
-.. cmd:: Test @option
-
- Prints the current value of :token:`option`.
-
-.. cmd:: Print Options
-
- Prints the current value of all flags and options, and the names of all tables.
-
+.. cmd:: Inspect @num
-.. cmd:: Add @table {| @string | @qualid }
- :name: Add @table
+ This command displays the :n:`@num` last objects of the
+ current environment, including sections and modules.
- Adds the specified value to :token:`table`.
+.. cmd:: Print Section @qualid
-.. cmd:: Remove @table {| @string | @qualid }
- :name: Remove @table
+ Displays the objects defined since the beginning of the section named :n:`@qualid`.
- Removes the specified value from :token:`table`.
+ .. todo: "A.B" is permitted but unnecessary for modules/sections.
+ should the command just take an @ident?
-.. cmd:: Test @table for {| @string | @qualid }
- :name: Test @table for
-
- Reports whether :token:`table` contains the specified value.
-
-.. cmd:: Print Table @table
- :name: Print Table @table
-
- Prints the values in :token:`table`.
-
-.. cmd:: Test @table
-
- A synonym for :cmd:`Print Table @table`.
-
-.. cmd:: Print Tables
-
- A synonym for :cmd:`Print Options`.
-
-Locality attributes supported by :cmd:`Set` and :cmd:`Unset`
-````````````````````````````````````````````````````````````
-
-The :cmd:`Set` and :cmd:`Unset` commands support the :attr:`local`,
-:attr:`global` and :attr:`export` locality attributes:
-
-* no attribute: the original setting is *not* restored at the end of
- the current module or section.
-* :attr:`local` (an alternative syntax is to use the ``Local``
- prefix): the setting is applied within the current module or
- section. The original value of the setting is restored at the end
- of the current module or section.
-* :attr:`export` (an alternative syntax is to use the ``Export``
- prefix): similar to :attr:`local`, the original value of the setting
- is restored at the end of the current module or section. In
- addition, if the value is set in a module, then :cmd:`Import`\-ing
- the module sets the option or flag.
-* :attr:`global` (an alternative syntax is to use the ``Global``
- prefix): the original setting is *not* restored at the end of the
- current module or section. In addition, if the value is set in a
- file, then :cmd:`Require`\-ing the file sets the option.
-
-Newly opened modules and sections inherit the current settings.
-
-.. note::
+Query commands
+--------------
- The use of the :attr:`global` attribute with the :cmd:`Set` and
- :cmd:`Unset` commands is discouraged. If your goal is to define
- project-wide settings, you should rather use the command-line
- arguments ``-set`` and ``-unset`` for setting flags and options
- (cf. :ref:`command-line-options`).
+Unlike other commands, :production:`query_command`\s may be prefixed with
+a goal selector (:n:`@num:`) to specify which goal context it applies to.
+If no selector is provided,
+the command applies to the current goal. If no proof is open, then the command only applies
+to accessible objects. (see Section :ref:`invocation-of-tactics`).
-.. _requests-to-the-environment:
+.. cmd:: About @smart_qualid {? @univ_name_list }
-Requests to the environment
--------------------------------
+ Displays information about the :n:`@smart_qualid` object, which,
+ if a proof is open, may be a hypothesis of the selected goal,
+ or an accessible theorem, axiom, etc.:
+ its kind (module, constant, assumption, inductive,
+ constructor, abbreviation, …), long name, type, implicit arguments and
+ argument scopes (as set in the definition of :token:`smart_qualid` or
+ subsequently with the :cmd:`Arguments` command). It does not print the body of definitions or proofs.
.. cmd:: Check @term
- This command displays the type of :n:`@term`. When called in proof mode, the
- term is checked in the local context of the current subgoal.
-
- .. cmdv:: @selector: Check @term
-
- This variant specifies on which subgoal to perform typing
- (see Section :ref:`invocation-of-tactics`).
-
+ Displays the type of :n:`@term`. When called in proof mode, the
+ term is checked in the local context of the selected goal.
.. cmd:: Eval @red_expr in @term
- This command performs the specified reduction on :n:`@term`, and displays
- the resulting term with its type. The term to be reduced may depend on
- hypothesis introduced in the first subgoal (if a proof is in
- progress).
+ Performs the specified reduction on :n:`@term` and displays
+ the resulting term with its type. If a proof is open, :n:`@term`
+ may reference hypotheses of the selected goal.
.. seealso:: Section :ref:`performingcomputations`.
.. cmd:: Compute @term
- This command performs a call-by-value evaluation of term by using the
- bytecode-based virtual machine. It is a shortcut for ``Eval vm_compute in``
- :n:`@term`.
+ Evaluates :n:`@term` using the bytecode-based virtual machine.
+ It is a shortcut for :cmd:`Eval` :n:`vm_compute in @term`.
.. seealso:: Section :ref:`performingcomputations`.
+.. cmd:: Search {+ {? - } @search_item } {? {| inside | outside } {+ @qualid } }
-.. cmd:: Print Assumptions @qualid
-
- This commands display all the assumptions (axioms, parameters and
- variables) a theorem or definition depends on. Especially, it informs
- on the assumptions with respect to which the validity of a theorem
- relies.
-
- .. cmdv:: Print Opaque Dependencies @qualid
- :name: Print Opaque Dependencies
-
- Displays the set of opaque constants :n:`@qualid` relies on in addition to
- the assumptions.
-
- .. cmdv:: Print Transparent Dependencies @qualid
- :name: Print Transparent Dependencies
-
- Displays the set of transparent constants :n:`@qualid` relies on
- in addition to the assumptions.
-
- .. cmdv:: Print All Dependencies @qualid
- :name: Print All Dependencies
-
- Displays all assumptions and constants :n:`@qualid` relies on.
-
-
-.. cmd:: Search @qualid
+ .. insertprodn search_item search_item
- This command displays the name and type of all objects (hypothesis of
- the current goal, theorems, axioms, etc) of the current context whose
- statement contains :n:`@qualid`. This command is useful to remind the user
- of the name of library lemmas.
+ .. prodn::
+ search_item ::= @one_term
+ | @string {? % @scope_key }
- .. exn:: The reference @qualid was not found in the current environment.
-
- There is no constant in the environment named qualid.
-
- .. cmdv:: Search @string
-
- If :n:`@string` is a valid identifier, this command
- displays the name and type of all objects (theorems, axioms, etc) of
- the current context whose name contains string. If string is a
- notation’s string denoting some reference :n:`@qualid` (referred to by its
- main symbol as in `"+"` or by its notation’s string as in `"_ + _"` or
- `"_ 'U' _"`, see Section :ref:`notations`), the command works like ``Search`` :n:`@qualid`.
-
- .. cmdv:: Search @string%@ident
+ Displays the name and type of all hypotheses of the
+ selected goal (if any) and theorems of the current context
+ matching :n:`@search_item`\s.
+ It's useful for finding the names of library lemmas.
- The string string must be a notation or the main
- symbol of a notation which is then interpreted in the scope bound to
- the delimiting key :token:`ident` (see Section :ref:`LocalInterpretationRulesForNotations`).
+ * :n:`@one_term` - Search for objects containing a subterm matching the pattern
+ :n:`@one_term` in which holes of the pattern are indicated by `_` or :n:`?@ident`.
+ If the same :n:`?@ident` occurs more than once in the pattern, all occurrences must
+ match the same value.
- .. cmdv:: Search @term_pattern
+ * :n:`@string` - If :n:`@string` is a substring of a valid identifier,
+ search for objects whose name contains :n:`@string`. If :n:`@string` is a notation
+ string associated with a :n:`@qualid`, that's equivalent to :cmd:`Search` :n:`@qualid`.
+ For example, specifying `"+"` or `"_ + _"`, which are notations for `Nat.add`, are equivalent
+ to :cmd:`Search` `Nat.add`.
- This searches for all statements or types of
- definition that contains a subterm that matches the pattern
- :token:`term_pattern` (holes of the pattern are either denoted by `_` or by
- :n:`?@ident` when non linear patterns are expected).
+ * :n:`% @scope` - limits the search to the scope bound to
+ the delimiting key :n:`@scope`, such as, for example, :n:`%nat`.
+ This clause may be used only if :n:`@string` contains a notation string.
+ (see Section :ref:`LocalInterpretationRulesForNotations`)
- .. cmdv:: Search {+ {? -}@term_pattern_string}
+ If you specify multiple :n:`@search_item`\s, all the conditions must be satisfied
+ for the object to be displayed. The minus sign `-` excludes objects that contain
+ the :n:`@search_item`.
- where
- :n:`@term_pattern_string` is a term_pattern, a string, or a string followed
- by a scope delimiting key `%key`. This generalization of ``Search`` searches
- for all objects whose statement or type contains a subterm matching
- :n:`@term_pattern` (or :n:`@qualid` if :n:`@string` is the notation for a reference
- qualid) and whose name contains all string of the request that
- correspond to valid identifiers. If a term_pattern or a string is
- prefixed by `-`, the search excludes the objects that mention that
- term_pattern or that string.
+ Additional clauses:
- .. cmdv:: Search {+ {? -}@term_pattern_string} inside {+ @qualid }
+ * :n:`inside {+ @qualid }` - limit the search to the specified modules
+ * :n:`outside {+ @qualid }` - exclude the specified modules from the search
- This restricts the search to constructions defined in the modules
- named by the given :n:`qualid` sequence.
-
- .. cmdv:: Search {+ {? -}@term_pattern_string} outside {+ @qualid }
-
- This restricts the search to constructions not defined in the modules
- named by the given :n:`qualid` sequence.
-
- .. cmdv:: @selector: Search {+ {? -}@term_pattern_string}
-
- This specifies the goal on which to search hypothesis (see
- Section :ref:`invocation-of-tactics`).
- By default the 1st goal is searched. This variant can
- be combined with other variants presented here.
+ .. exn:: Module/section @qualid not found.
- .. example::
+ There is no constant in the environment named :n:`@qualid`, where :n:`@qualid`
+ is in an `inside` or `outside` clause.
- .. coqtop:: in
+ .. example:: :cmd:`Search` examples
- Require Import ZArith.
+ .. coqtop:: in
- .. coqtop:: all
+ Require Import ZArith.
- Search Z.mul Z.add "distr".
+ .. coqtop:: all
- Search "+"%Z "*"%Z "distr" -positive -Prop.
+ Search Z.mul Z.add "distr".
+ Search "+"%Z "*"%Z "distr" -Prop.
+ Search (?x * _ + ?x * _)%Z outside OmegaLemmas.
- Search (?x * _ + ?x * _)%Z outside OmegaLemmas.
+.. cmd:: SearchHead @one_term {? {| inside | outside } {+ @qualid } }
-.. cmd:: SearchHead @term
+ Displays the name and type of all hypotheses of the
+ selected goal (if any) and theorems of the current context that have the
+ form :n:`{? forall {* @binder }, } {* P__i -> } C` where :n:`@one_term`
+ matches a prefix of `C`. For example, a :n:`@one_term` of `f _ b`
+ matches `f a b`, which is a prefix of `C` when `C` is `f a b c`.
- This command displays the name and type of all hypothesis of the
- current goal (if any) and theorems of the current context whose
- statement’s conclusion has the form `(term t1 .. tn)`. This command is
- useful to remind the user of the name of library lemmas.
+ See :cmd:`Search` for an explanation of the `inside`/`outside` clauses.
- .. example::
+ .. example:: :cmd:`SearchHead` examples
.. coqtop:: reset all
SearchHead le.
-
SearchHead (@eq bool).
- .. cmdv:: SearchHead @term inside {+ @qualid }
-
- This restricts the search to constructions defined in the modules named
- by the given :n:`qualid` sequence.
-
- .. cmdv:: SearchHead @term outside {+ @qualid }
-
- This restricts the search to constructions not defined in the modules
- named by the given :n:`qualid` sequence.
-
- .. exn:: Module/section @qualid not found.
-
- No module :n:`@qualid` has been required (see Section :ref:`compiled-files`).
-
- .. cmdv:: @selector: SearchHead @term
-
- This specifies the goal on which to
- search hypothesis (see Section :ref:`invocation-of-tactics`).
- By default the 1st goal is searched. This variant can be combined
- with other variants presented here.
+.. cmd:: SearchPattern @one_term {? {| inside | outside } {+ @qualid } }
- .. note:: Up to |Coq| version 8.4, ``SearchHead`` was named ``Search``.
+ Displays the name and type of all hypotheses of the
+ selected goal (if any) and theorems of the current context
+ ending with :n:`{? forall {* @binder }, } {* P__i -> } C` that match the pattern
+ :n:`@one_term`.
+ See :cmd:`Search` for an explanation of the `inside`/`outside` clauses.
-.. cmd:: SearchPattern @term
-
- This command displays the name and type of all hypothesis of the
- current goal (if any) and theorems of the current context whose
- statement’s conclusion or last hypothesis and conclusion matches the
- expressionterm where holes in the latter are denoted by `_`.
- It is a variant of :n:`Search @term_pattern` that does not look for subterms
- but searches for statements whose conclusion has exactly the expected
- form, or whose statement finishes by the given series of
- hypothesis/conclusion.
-
- .. example::
+ .. example:: :cmd:`SearchPattern` examples
.. coqtop:: in
@@ -381,123 +187,118 @@ Requests to the environment
.. coqtop:: all
SearchPattern (_ + _ = _ + _).
-
SearchPattern (nat -> bool).
-
SearchPattern (forall l : list _, _ l l).
- Patterns need not be linear: you can express that the same expression
- must occur in two places by using pattern variables `?ident`.
-
-
- .. example::
-
.. coqtop:: all
SearchPattern (?X1 + _ = _ + ?X1).
- .. cmdv:: SearchPattern @term inside {+ @qualid }
+.. cmd:: SearchRewrite @one_term {? {| inside | outside } {+ @qualid } }
- This restricts the search to constructions defined in the modules
- named by the given :n:`qualid` sequence.
+ Displays the name and type of all hypotheses of the
+ selected goal (if any) and theorems of the current context that have the form
+ :n:`{? forall {* @binder }, } {* P__i -> } LHS = RHS` where :n:`@one_term`
+ matches either `LHS` or `RHS`.
- .. cmdv:: SearchPattern @term outside {+ @qualid }
+ See :cmd:`Search` for an explanation of the `inside`/`outside` clauses.
- This restricts the search to constructions not defined in the modules
- named by the given :n:`qualid` sequence.
+ .. example:: :cmd:`SearchRewrite` examples
- .. cmdv:: @selector: SearchPattern @term
+ .. coqtop:: in
- This specifies the goal on which to
- search hypothesis (see Section :ref:`invocation-of-tactics`).
- By default the 1st goal is
- searched. This variant can be combined with other variants presented
- here.
+ Require Import Arith.
+ .. coqtop:: all
-.. cmd:: SearchRewrite @term
+ SearchRewrite (_ + _ + _).
- This command displays the name and type of all hypothesis of the
- current goal (if any) and theorems of the current context whose
- statement’s conclusion is an equality of which one side matches the
- expression term. Holes in term are denoted by “_”.
+.. table:: Search Blacklist @string
+ :name: Search Blacklist
- .. example::
+ Specifies a set of strings used to exclude lemmas from the results of :cmd:`Search`,
+ :cmd:`SearchHead`, :cmd:`SearchPattern` and :cmd:`SearchRewrite` queries. A lemma whose
+ fully-qualified name contains any of the strings will be excluded from the
+ search results. The default blacklisted substrings are ``_subterm``, ``_subproof`` and
+ ``Private_``.
- .. coqtop:: in
+ Use the :cmd:`Add` and :cmd:`Remove` commands to update the set of
+ blacklisted strings.
- Require Import Arith.
- .. coqtop:: all
+.. _requests-to-the-environment:
- SearchRewrite (_ + _ + _).
+Requests to the environment
+-------------------------------
- .. cmdv:: SearchRewrite @term inside {+ @qualid }
+.. cmd:: Print Assumptions @smart_qualid
- This restricts the search to constructions defined in the modules
- named by the given :n:`qualid` sequence.
+ Displays all the assumptions (axioms, parameters and
+ variables) a theorem or definition depends on.
- .. cmdv:: SearchRewrite @term outside {+ @qualid }
+ The message "Closed under the global context" indicates that the theorem or
+ definition has no dependencies.
- This restricts the search to constructions not defined in the modules
- named by the given :n:`qualid` sequence.
+.. cmd:: Print Opaque Dependencies @smart_qualid
- .. cmdv:: @selector: SearchRewrite @term
+ Displays the assumptions and opaque constants that :n:`@smart_qualid` depends on.
- This specifies the goal on which to
- search hypothesis (see Section :ref:`invocation-of-tactics`).
- By default the 1st goal is
- searched. This variant can be combined with other variants presented
- here.
+.. cmd:: Print Transparent Dependencies @smart_qualid
-.. note::
+ Displays the assumptions and transparent constants that :n:`@smart_qualid` depends on.
- .. table:: Search Blacklist @string
- :name: Search Blacklist
+.. cmd:: Print All Dependencies @smart_qualid
- Specifies a set of strings used to exclude lemmas from the results of :cmd:`Search`,
- :cmd:`SearchHead`, :cmd:`SearchPattern` and :cmd:`SearchRewrite` queries. A lemma whose
- fully-qualified name contains any of the strings will be excluded from the
- search results. The default blacklisted substrings are ``_subterm``, ``_subproof`` and
- ``Private_``.
+ Displays all the assumptions and constants :n:`@smart_qualid` depends on.
- Use the :cmd:`Add @table` and :cmd:`Remove @table` commands to update the set of
- blacklisted strings.
+.. cmd:: Locate @smart_qualid
-.. cmd:: Locate @qualid
+ Displays the full name of objects from |Coq|'s various qualified namespaces such as terms,
+ modules and Ltac. It also displays notation definitions.
- This command displays the full name of objects whose name is a prefix
- of the qualified identifier :n:`@qualid`, and consequently the |Coq| module in
- which they are defined. It searches for objects from the different
- qualified namespaces of |Coq|: terms, modules, Ltac, etc.
+ If the argument is:
- .. example::
+ * :n:`@qualid` - displays the full name of objects that
+ end with :n:`@qualid`, thereby showing the module they are defined in.
+ * :n:`@string {? "%" @ident }` - displays the definition of a notation. :n:`@string`
+ can be a single token in the notation such as "`->`" or a pattern that matches the
+ notation. See :ref:`locating-notations`.
- .. coqtop:: all
+ .. todo somewhere we should list all the qualified namespaces
- Locate nat.
+.. cmd:: Locate Term @smart_qualid
- Locate Datatypes.O.
+ Like :cmd:`Locate`, but limits the search to terms
- Locate Init.Datatypes.O.
+.. cmd:: Locate Module @qualid
- Locate Coq.Init.Datatypes.O.
+ Like :cmd:`Locate`, but limits the search to modules
- Locate I.Dont.Exist.
+.. cmd:: Locate Ltac @qualid
- .. cmdv:: Locate Term @qualid
+ Like :cmd:`Locate`, but limits the search to tactics
- As Locate but restricted to terms.
+.. cmd:: Locate Library @qualid
- .. cmdv:: Locate Module @qualid
+ Displays the full name, status and file system path of the module :n:`@qualid`, whether loaded or not.
- As Locate but restricted to modules.
+.. cmd:: Locate File @string
+
+ Displays the file system path of the file ending with :n:`@string`.
+ Typically, :n:`@string` has a suffix such as ``.cmo`` or ``.vo`` or ``.v`` file, such as :n:`Nat.v`.
+
+ .. todo: also works for directory names such as "Data" (parent of Nat.v)
+ also "Data/Nat.v" works, but not a substring match
- .. cmdv:: Locate Ltac @qualid
+.. example:: Locate examples
- As Locate but restricted to tactics.
+ .. coqtop:: all
-.. seealso:: Section :ref:`locating-notations`
+ Locate nat.
+ Locate Datatypes.O.
+ Locate Init.Datatypes.O.
+ Locate Coq.Init.Datatypes.O.
+ Locate I.Dont.Exist.
.. _printing-flags:
@@ -522,35 +323,32 @@ Loading files
|Coq| offers the possibility of loading different parts of a whole
development stored in separate files. Their contents will be loaded as
if they were entered from the keyboard. This means that the loaded
-files are ASCII files containing sequences of commands for |Coq|’s
+files are text files containing sequences of commands for |Coq|’s
toplevel. This kind of file is called a *script* for |Coq|. The standard
(and default) extension of |Coq|’s script files is .v.
-.. cmd:: Load @ident
+.. cmd:: Load {? Verbose } {| @string | @ident }
- This command loads the file named :n:`ident`.v, searching successively in
+ Loads a file. If :n:`@ident` is specified, the command loads a file
+ named :n:`@ident.v`, searching successively in
each of the directories specified in the *loadpath*. (see Section
:ref:`libraries-and-filesystem`)
- Files loaded this way cannot leave proofs open, and the ``Load``
- command cannot be used inside a proof either.
-
- .. cmdv:: Load @string
-
- Loads the file denoted by the string :n:`@string`, where
- string is any complete filename. Then the `~` and .. abbreviations are
- allowed as well as shell variables. If no extension is specified, |Coq|
- will use the default extension ``.v``.
+ If :n:`@string` is specified, it must specify a complete filename.
+ `~` and .. abbreviations are
+ allowed as well as shell variables. If no extension is specified, |Coq|
+ will use the default extension ``.v``.
- .. cmdv:: Load Verbose @ident
- Load Verbose @string
+ Files loaded this way can't leave proofs open, nor can :cmd:`Load`
+ be used inside a proof.
- Display, while loading,
- the answers of |Coq| to each command (including tactics) contained in
- the loaded file.
+ We discourage the use of :cmd:`Load`; use :cmd:`Require` instead.
+ :cmd:`Require` loads `.vo` files that were previously
+ compiled from `.v` files.
- .. seealso:: Section :ref:`controlling-display`.
+ :n:`Verbose` displays the |Coq| output for each command and tactic
+ in the loaded file, as if the commands and tactics were entered interactively.
.. exn:: Can’t find file @ident on loadpath.
:undocumented:
@@ -568,67 +366,50 @@ Compiled files
This section describes the commands used to load compiled files (see
Chapter :ref:`thecoqcommands` for documentation on how to compile a file). A compiled
-file is a particular case of module called *library file*.
-
-
-.. cmd:: Require @qualid
-
- This command looks in the loadpath for a file containing module :n:`@qualid`
- and adds the corresponding module to the environment of |Coq|. As
- library files have dependencies in other library files, the command
- :cmd:`Require` :n:`@qualid` recursively requires all library files the module
- qualid depends on and adds the corresponding modules to the
- environment of |Coq| too. |Coq| assumes that the compiled files have been
- produced by a valid |Coq| compiler and their contents are then not
- replayed nor rechecked.
-
- To locate the file in the file system, :n:`@qualid` is decomposed under the
- form :n:`dirpath.@ident` and the file :n:`@ident.vo` is searched in the physical
- directory of the file system that is mapped in |Coq| loadpath to the
- logical path dirpath (see Section :ref:`libraries-and-filesystem`). The mapping between
- physical directories and logical names at the time of requiring the
- file must be consistent with the mapping used to compile the file. If
- several files match, one of them is picked in an unspecified fashion.
+file is a particular case of a module called a *library file*.
+
+.. cmd:: Require {? {| Import | Export } } {+ @qualid }
+ :name: Require; Require Import; Require Export
- .. cmdv:: Require Import @qualid
- :name: Require Import
+ Loads compiled modules into the |Coq| environment. For each :n:`@qualid`, which has the form
+ :n:`{* @ident__prefix . } @ident`, the command searches for the logical name represented
+ by the :n:`@ident__prefix`\s and loads the compiled file :n:`@ident.vo` from the associated
+ filesystem directory.
- This loads and declares the module :n:`@qualid`
- and its dependencies then imports the contents of :n:`@qualid` as described
- for :cmd:`Import`. It does not import the modules that
- :n:`@qualid` depends on unless these modules were themselves required in module
- :n:`@qualid`
- using :cmd:`Require Export`, or recursively required
- through a series of :cmd:`Require Export`. If the module required has
- already been loaded, :cmd:`Require Import` :n:`@qualid` simply imports it, as
- :cmd:`Import` :n:`@qualid` would.
+ The process is applied recursively to all the loaded files;
+ if they contain :cmd:`Require` commands, those commands are executed as well.
+ The compiled files must have been compiled with the same version of |Coq|.
+ The compiled files are neither replayed nor rechecked.
- .. cmdv:: Require Export @qualid
- :name: Require Export
+ * :n:`Import` - additionally does an :cmd:`Import` on the loaded module, making components defined
+ in the module available by their short names
+ * :n:`Export` - additionally does an :cmd:`Export` on the loaded module, making components defined
+ in the module available by their short names *and* marking them to be exported by the current
+ module
- This command acts as :cmd:`Require Import` :n:`@qualid`,
- but if a further module, say `A`, contains a command :cmd:`Require Export` `B`,
- then the command :cmd:`Require Import` `A` also imports the module `B.`
+ If the required module has already been loaded, :n:`Import` and :n:`Export` make the command
+ equivalent to :cmd:`Import` or :cmd:`Export`.
- .. cmdv:: Require {| Import | Export } {+ @qualid }
+ The loadpath must contain the same mapping used to compile the file
+ (see Section :ref:`libraries-and-filesystem`). If
+ several files match, one of them is picked in an unspecified fashion.
+ Therefore, library authors should use a unique name for each module and
+ users are encouraged to use fully-qualified names
+ or the :cmd:`From ... Require` command to load files.
- This loads the
- modules named by the :token:`qualid` sequence and their recursive
- dependencies. If
- ``Import`` or ``Export`` is given, it also imports these modules and
- all the recursive dependencies that were marked or transitively marked
- as ``Export``.
- .. cmdv:: From @dirpath Require @qualid
- :name: From ... Require ...
+ .. todo common user error on dirpaths see https://github.com/coq/coq/pull/11961#discussion_r402852390
- This command acts as :cmd:`Require`, but picks
- any library whose absolute name is of the form :n:`@dirpath.@dirpath’.@qualid`
- for some :n:`@dirpath’`. This is useful to ensure that the :token:`qualid` library
- comes from a given package by making explicit its absolute root.
+ .. cmd:: From @dirpath Require {? {| Import | Export } } {+ @qualid }
+ :name: From ... Require
- .. exn:: Cannot load qualid: no physical path bound to dirpath.
+ Works like :cmd:`Require`, but loads, for each :n:`@qualid`,
+ the library whose fully-qualified name matches :n:`@dirpath.{* @ident . }@qualid`
+ for some :n:`{* @ident . }`. This is useful to ensure that the :n:`@qualid` library
+ comes from a particular package.
+
+ .. exn:: Cannot load @qualid: no physical path bound to @dirpath.
:undocumented:
.. exn:: Cannot find library foo in loadpath.
@@ -637,7 +418,7 @@ file is a particular case of module called *library file*.
file foo.vo. Either foo.v exists but is not compiled or foo.vo is in a
directory which is not in your LoadPath (see Section :ref:`libraries-and-filesystem`).
- .. exn:: Compiled library @ident.vo makes inconsistent assumptions over library qualid.
+ .. exn:: Compiled library @ident.vo makes inconsistent assumptions over library @qualid.
The command tried to load library file :n:`@ident`.vo that
depends on some specific version of library :n:`@qualid` which is not the
@@ -651,13 +432,13 @@ file is a particular case of module called *library file*.
|Coq| compiled module, or it was compiled with an incompatible
version of |Coq|.
- .. exn:: The file :n:`@ident.vo` contains library dirpath and not library dirpath’.
-
- The library file :n:`@dirpath’` is indirectly required by the
- ``Require`` command but it is bound in the current loadpath to the
- file :n:`@ident.vo` which was bound to a different library name :token:`dirpath` at
- the time it was compiled.
+ .. exn:: The file @ident.vo contains library @qualid__1 and not library @qualid__2.
+ The library :n:`@qualid__2` is indirectly required by a :cmd:`Require` or
+ :cmd:`From ... Require` command. The loadpath maps :n:`@qualid__2` to :n:`@ident.vo`,
+ which was compiled using a loadpath that bound it to :n:`@qualid__1`. Usually
+ the appropriate solution is to recompile :n:`@ident.v` using the correct loadpath.
+ See :ref:`libraries-and-filesystem`.
.. warn:: Require inside a module is deprecated and strongly discouraged. You can Require a module at toplevel and optionally Import it inside another one.
@@ -668,33 +449,26 @@ file is a particular case of module called *library file*.
.. cmd:: Print Libraries
This command displays the list of library files loaded in the
- current |Coq| session. For each of these libraries, it also tells if it
- is imported.
-
+ current |Coq| session.
.. cmd:: Declare ML Module {+ @string }
- This commands loads the OCaml compiled files
- with names given by the :token:`string` sequence
- (dynamic link). It is mainly used to load tactics dynamically. The
- files are searched into the current OCaml loadpath (see the
- command :cmd:`Add ML Path`).
- Loading of OCaml files is only possible under the bytecode version of
- ``coqtop`` (i.e. ``coqtop`` called with option ``-byte``, see chapter
- :ref:`thecoqcommands`), or when |Coq| has been compiled with a
- version of OCaml that supports native Dynlink (≥ 3.11).
+ This commands dynamically loads OCaml compiled code from
+ a :n:`.mllib` file.
+ It is used to load plugins dynamically. The
+ files must be accessible in the current OCaml loadpath (see the
+ command :cmd:`Add ML Path`). The :n:`.mllib` suffix may be omitted.
- .. cmdv:: Local Declare ML Module {+ @string }
+ This command is reserved for plugin developers, who should provide
+ a .v file containing the command. Users of the plugins will then generally
+ load the .v file.
- This variant is not exported to the modules that import the module
- where they occur, even if outside a section.
+ This command supports the :attr:`local` attribute. If present,
+ the listed files are not exported, even if they're outside a section.
.. exn:: File not found on loadpath: @string.
:undocumented:
- .. exn:: Loading of ML object file forbidden in a native Coq.
- :undocumented:
-
.. cmd:: Print ML Modules
@@ -709,7 +483,7 @@ Loadpath
------------
Loadpaths are preferably managed using |Coq| command line options (see
-Section `libraries-and-filesystem`) but there remain vernacular commands to manage them
+Section :ref:`libraries-and-filesystem`) but there remain vernacular commands to manage them
for practical purposes. Such commands are only meant to be issued in
the toplevel, and using them in source files is discouraged.
@@ -719,22 +493,27 @@ the toplevel, and using them in source files is discouraged.
This command displays the current working directory.
-.. cmd:: Cd @string
+.. cmd:: Cd {? @string }
- This command changes the current directory according to :token:`string` which
- can be any valid path.
+ If :n:`@string` is specified, changes the current directory according to :token:`string` which
+ can be any valid path. Otherwise, it displays the current directory.
- .. cmdv:: Cd
- Is equivalent to Pwd.
+.. cmd:: Add LoadPath @string as @dirpath
+ .. insertprodn dirpath dirpath
-.. cmd:: Add LoadPath @string as @dirpath
+ .. prodn::
+ dirpath ::= {* @ident . } @ident
This command is equivalent to the command line option
- :n:`-Q @string @dirpath`. It adds the physical directory string to the current
- |Coq| loadpath and maps it to the logical directory dirpath.
+ :n:`-Q @string @dirpath`. It adds a mapping to the loadpath from
+ the logical name :n:`@dirpath` to the file system directory :n:`@string`.
+ * :n:`@dirpath` is a prefix of a module name. The module name hierarchy
+ follows the file system hierarchy. On Linux, for example, the prefix
+ `A.B.C` maps to the directory :n:`@string/B/C`. Avoid using spaces after a `.` in the
+ path because the parser will interpret that as the end of a command or tactic.
.. cmd:: Add Rec LoadPath @string as @dirpath
@@ -748,42 +527,24 @@ the toplevel, and using them in source files is discouraged.
This command removes the path :n:`@string` from the current |Coq| loadpath.
-.. cmd:: Print LoadPath
+.. cmd:: Print LoadPath {? @dirpath }
- This command displays the current |Coq| loadpath.
-
- .. cmdv:: Print LoadPath @dirpath
-
- Works as :cmd:`Print LoadPath` but displays only
- the paths that extend the :n:`@dirpath` prefix.
+ This command displays the current |Coq| loadpath. If :n:`@dirpath` is specified,
+ displays only the paths that extend that prefix.
.. cmd:: Add ML Path @string
This command adds the path :n:`@string` to the current OCaml
- loadpath (see the command `Declare ML Module`` in Section :ref:`compiled-files`).
+ loadpath (cf. :cmd:`Declare ML Module`).
-.. cmd:: Print ML Path @string
+.. cmd:: Print ML Path
This command displays the current OCaml loadpath. This
command makes sense only under the bytecode version of ``coqtop``, i.e.
using option ``-byte``
- (see the command Declare ML Module in Section :ref:`compiled-files`).
-
-.. _locate-file:
-
-.. cmd:: Locate File @string
-
- This command displays the location of file string in the current
- loadpath. Typically, string is a ``.cmo`` or ``.vo`` or ``.v`` file.
-
-
-.. cmd:: Locate Library @dirpath
-
- This command gives the status of the |Coq| module dirpath. It tells if
- the module is loaded and if not searches in the load path for a module
- of logical name :n:`@dirpath`.
+ (cf. :cmd:`Declare ML Module`).
.. _backtracking:
@@ -806,30 +567,22 @@ interactively, they cannot be part of a vernacular file loaded via
.. exn:: @ident: no such entry.
:undocumented:
- .. cmdv:: Reset Initial
-
- Goes back to the initial state, just after the start
- of the interactive session.
+.. cmd:: Reset Initial
+ Goes back to the initial state, just after the start
+ of the interactive session.
-.. cmd:: Back
- This command undoes all the effects of the last vernacular command.
- Commands read from a vernacular file via a :cmd:`Load` are considered as a
- single command. Proof management commands are also handled by this
- command (see Chapter :ref:`proofhandling`). For that, Back may have to undo more than
- one command in order to reach a state where the proof management
- information is available. For instance, when the last command is a
- :cmd:`Qed`, the management information about the closed proof has been
- discarded. In this case, :cmd:`Back` will then undo all the proof steps up to
- the statement of this proof.
+.. cmd:: Back {? @num }
- .. cmdv:: Back @num
-
- Undo :n:`@num` vernacular commands. As for Back, some extra
- commands may be undone in order to reach an adequate state. For
- instance Back :n:`@num` will not re-enter a closed proof, but rather go just
- before that proof.
+ Undoes all the effects of the last :n:`@num @sentence`\s. If
+ :n:`@num` is not specified, the command undoes one sentence.
+ Sentences read from a `.v` file via a :cmd:`Load` are considered a
+ single sentence. While :cmd:`Back` can undo tactics and commands executed
+ within proof mode, once you exit proof mode, such as with :cmd:`Qed`, all
+ the statements executed within are thereafter considered a single sentence.
+ :cmd:`Back` immediately following :cmd:`Qed` gets you back to the state
+ just after the statement of the proof.
.. exn:: Invalid backtrack.
@@ -850,18 +603,17 @@ interactively, they cannot be part of a vernacular file loaded via
Quitting and debugging
--------------------------
-
.. cmd:: Quit
- This command permits to quit |Coq|.
+ Causes |Coq| to exit. Valid only in coqtop.
.. cmd:: Drop
- This is used mostly as a debug facility by |Coq|’s implementers and does
- not concern the casual user. This command permits to leave |Coq|
- temporarily and enter the OCaml toplevel. The OCaml
- command:
+ This command temporarily enters the OCaml toplevel.
+ It is a debug facility used by |Coq|’s implementers. Valid only in the
+ bytecode version of coqtop.
+ The OCaml command:
::
@@ -886,49 +638,53 @@ Quitting and debugging
(see Section `customization-by-environment-variables`).
-.. TODO : command is not a syntax entry
-
-.. cmd:: Time @command
+.. cmd:: Time @sentence
- This command executes the vernacular command :n:`@command` and displays the
+ Executes :n:`@sentence` and displays the
time needed to execute it.
-.. cmd:: Redirect @string @command
+.. cmd:: Redirect @string @sentence
- This command executes the vernacular command :n:`@command`, redirecting its
- output to ":n:`@string`.out".
+ Executes :n:`@sentence`, redirecting its
+ output to the file ":n:`@string`.out".
-.. cmd:: Timeout @num @command
+.. cmd:: Timeout @num @sentence
- This command executes the vernacular command :n:`@command`. If the command
- has not terminated after the time specified by the :n:`@num` (time
- expressed in seconds), then it is interrupted and an error message is
+ Executes :n:`@sentence`. If the operation
+ has not terminated after :n:`@num` seconds, then it is interrupted and an error message is
displayed.
.. opt:: Default Timeout @num
:name: Default Timeout
- This option controls a default timeout for subsequent commands, as if they
- were passed to a :cmd:`Timeout` command. Commands already starting by a
- :cmd:`Timeout` are unaffected.
+ If set, each :n:`@sentence` is treated as if it was prefixed with :cmd:`Timeout` :n:`@num`,
+ except for :cmd:`Timeout` commands themselves. If unset,
+ no timeout is applied.
-.. cmd:: Fail @command
+.. cmd:: Fail @sentence
For debugging scripts, sometimes it is desirable to know whether a
- command or a tactic fails. If the given :n:`@command` fails, then
- :n:`Fail @command` succeeds (excepts in the case of
- critical errors, like a "stack overflow"), without changing the
- proof state, and in interactive mode, the system prints a message
+ command or a tactic fails. If :n:`@sentence` fails, then
+ :n:`Fail @sentence` succeeds (except for
+ critical errors, such as "stack overflow"), without changing the
+ proof state. In interactive mode, the system prints a message
confirming the failure.
.. exn:: The command has not failed!
- If the given :n:`@command` succeeds, then :n:`Fail @command`
+ If the given :n:`@command` succeeds, then :n:`Fail @sentence`
fails with this error message.
+.. note::
+
+ :cmd:`Time`, :cmd:`Redirect`, :cmd:`Timeout` and :cmd:`Fail` are
+ :production:`control_command`\s. For these commands, attributes and goal
+ selectors, when specified, are part of the :n:`@sentence` argument, and thus come after
+ the control command prefix and before the inner command or tactic. For
+ example: `Time #[ local ] Definition foo := 0.` or `Fail Timeout 10 all: auto.`
.. _controlling-display:
@@ -1010,13 +766,16 @@ as numbers, and for reflection-based tactics. The commands to fine-
tune the reduction strategies and the lazy conversion algorithm are
described first.
-.. cmd:: Opaque {+ @qualid }
+.. cmd:: Opaque {+ @smart_qualid }
+
+ This command accepts the :attr:`global` attribute. By default, the scope
+ of :cmd:`Opaque` is limited to the current section or module.
This command has an effect on unfoldable constants, i.e. on constants
defined by :cmd:`Definition` or :cmd:`Let` (with an explicit body), or by a command
assimilated to a definition such as :cmd:`Fixpoint`, :cmd:`Program Definition`, etc,
or by a proof ended by :cmd:`Defined`. The command tells not to unfold the
- constants in the :n:`@qualid` sequence in tactics using δ-conversion (unfolding
+ constants in the :n:`@smart_qualid` sequence in tactics using δ-conversion (unfolding
a constant is replacing it by its definition).
:cmd:`Opaque` has also an effect on the conversion algorithm of |Coq|, telling
@@ -1024,24 +783,15 @@ described first.
has to check the conversion (see Section :ref:`conversion-rules`) of two distinct
applied constants.
- .. cmdv:: Global Opaque {+ @qualid }
- :name: Global Opaque
-
- The scope of :cmd:`Opaque` is limited to the current section, or current
- file, unless the variant :cmd:`Global Opaque` is used.
-
.. seealso::
Sections :ref:`performingcomputations`, :ref:`tactics-automating`,
:ref:`proof-editing-mode`
- .. exn:: The reference @qualid was not found in the current environment.
-
- There is no constant referred by :n:`@qualid` in the environment.
- Nevertheless, if you asked :cmd:`Opaque` `foo` `bar` and if `bar` does
- not exist, `foo` is set opaque.
+.. cmd:: Transparent {+ @smart_qualid }
-.. cmd:: Transparent {+ @qualid }
+ This command accepts the :attr:`global` attribute. By default, the scope
+ of :cmd:`Transparent` is limited to the current section or module.
This command is the converse of :cmd:`Opaque` and it applies on unfoldable
constants to restore their unfoldability after an Opaque command.
@@ -1054,16 +804,9 @@ described first.
the usual defined constants, whose actual values are of course
relevant in general.
- .. cmdv:: Global Transparent {+ @qualid }
- :name: Global Transparent
-
- The scope of Transparent is limited to the current section, or current
- file, unless the variant :cmd:`Global Transparent` is
- used.
-
.. exn:: The reference @qualid was not found in the current environment.
- There is no constant referred by :n:`@qualid` in the environment.
+ There is no constant named :n:`@qualid` in the environment.
.. seealso::
@@ -1072,63 +815,66 @@ described first.
.. _vernac-strategy:
-.. cmd:: Strategy @level [ {+ @qualid } ]
+.. cmd:: Strategy {+ @strategy_level [ {+ @smart_qualid } ] }
+
+ .. insertprodn strategy_level strategy_level
+
+ .. prodn::
+ strategy_level ::= opaque
+ | @int
+ | expand
+ | transparent
+
+ This command accepts the :attr:`local` attribute, which limits its effect
+ to the current section or module, in which case the section and module
+ behavior is the same as :cmd:`Opaque` and :cmd:`Transparent` (without :attr:`global`).
- This command generalizes the behavior of Opaque and Transparent
+ This command generalizes the behavior of the :cmd:`Opaque` and :cmd:`Transparent`
commands. It is used to fine-tune the strategy for unfolding
constants, both at the tactic level and at the kernel level. This
- command associates a level to the qualified names in the :n:`@qualid`
+ command associates a :n:`@strategy_level` with the qualified names in the :n:`@smart_qualid`
sequence. Whenever two
expressions with two distinct head constants are compared (for
instance, this comparison can be triggered by a type cast), the one
with lower level is expanded first. In case of a tie, the second one
(appearing in the cast type) is expanded.
- .. prodn:: level ::= {| opaque | @num | expand }
-
Levels can be one of the following (higher to lower):
+ ``opaque`` : level of opaque constants. They cannot be expanded by
tactics (behaves like +∞, see next item).
- + :n:`@num` : levels indexed by an integer. Level 0 corresponds to the
+ + :n:`@int` : levels indexed by an integer. Level 0 corresponds to the
default behavior, which corresponds to transparent constants. This
- level can also be referred to as transparent. Negative levels
+ level can also be referred to as ``transparent``. Negative levels
correspond to constants to be expanded before normal transparent
constants, while positive levels correspond to constants to be
expanded after normal transparent constants.
+ ``expand`` : level of constants that should be expanded first (behaves
like −∞)
+ + ``transparent`` : Equivalent to level 0
- .. cmdv:: Local Strategy @level [ {+ @qualid } ]
-
- These directives survive section and module closure, unless the
- command is prefixed by ``Local``. In the latter case, the behavior
- regarding sections and modules is the same as for the :cmd:`Transparent` and
- :cmd:`Opaque` commands.
-
+.. cmd:: Print Strategy @smart_qualid
-.. cmd:: Print Strategy @qualid
-
- This command prints the strategy currently associated to :n:`@qualid`. It
- fails if :n:`@qualid` is not an unfoldable reference, that is, neither a
+ This command prints the strategy currently associated with :n:`@smart_qualid`. It
+ fails if :n:`@smart_qualid` is not an unfoldable reference, that is, neither a
variable nor a constant.
.. exn:: The reference is not unfoldable.
:undocumented:
- .. cmdv:: Print Strategies
+.. cmd:: Print Strategies
- Print all the currently non-transparent strategies.
+ Print all the currently non-transparent strategies.
.. cmd:: Declare Reduction @ident := @red_expr
- This command allows giving a short name to a reduction expression, for
+ Declares a short name for the reduction expression :n:`@red_expr`, for
instance ``lazy beta delta [foo bar]``. This short name can then be used
- in :n:`Eval @ident in` or ``eval`` directives. This command
- accepts the
- ``Local`` modifier, for discarding this reduction name at the end of the
- file or module. For the moment, the name is not qualified. In
+ in :n:`Eval @ident in` or ``eval`` constructs. This command
+ accepts the :attr:`local` attribute, which indicates that the reduction
+ will be discarded at the end of the
+ file or module. The name is not qualified. In
particular declaring the same name in several modules or in several
functor applications will be rejected if these declarations are not
local. The name :n:`@ident` cannot be used directly as an Ltac tactic, but
@@ -1222,6 +968,8 @@ Controlling Typing Flags
Print the status of the three typing flags: guard checking, positivity checking
and universe checking.
+See also :flag:`Cumulative StrictProp` in the |SProp| chapter.
+
.. example::
.. coqtop:: all reset
@@ -1274,14 +1022,15 @@ in support libraries of plug-ins.
.. _exposing-constants-to-ocaml-libraries:
Exposing constants to OCaml libraries
-````````````````````````````````````````````````````````````````
+`````````````````````````````````````
.. cmd:: Register @qualid__1 as @qualid__2
- This command exposes the constant :n:`@qualid__1` to OCaml libraries under
- the name :n:`@qualid__2`. This constant can then be dynamically located
- calling :n:`Coqlib.lib_ref "@qualid__2"`; i.e., there is no need to known
- where is the constant defined (file, module, library, etc.).
+ Makes the constant :n:`@qualid__1` accessible to OCaml libraries under
+ the name :n:`@qualid__2`. The constant can then be dynamically located
+ in OCaml code by
+ calling :n:`Coqlib.lib_ref "@qualid__2"`. The OCaml code doesn't need
+ to know where the constant is defined (what file, module, library, etc.).
As a special case, when the first segment of :n:`@qualid__2` is :g:`kernel`,
the constant is exposed to the kernel. For instance, the `Int63` module
@@ -1291,27 +1040,41 @@ Exposing constants to OCaml libraries
Register bool as kernel.ind_bool.
- This makes the kernel aware of what is the type of boolean values. This
- information is used for instance to define the return type of the
- :g:`#int63_eq` primitive.
+ This makes the kernel aware of the `bool` type, which is used, for example,
+ to define the return type of the :g:`#int63_eq` primitive.
.. seealso:: :ref:`primitive-integers`
Inlining hints for the fast reduction machines
-````````````````````````````````````````````````````````````````
+``````````````````````````````````````````````
.. cmd:: Register Inline @qualid
- This command gives as a hint to the reduction machines (VM and native) that
+ Gives a hint to the reduction machines (VM and native) that
the body of the constant :n:`@qualid` should be inlined in the generated code.
Registering primitive operations
````````````````````````````````
-.. cmd:: Primitive @ident__1 := #@ident__2.
+.. cmd:: Primitive @ident {? : @term } := #@ident__prim
+
+ Makes the primitive type or primitive operator :n:`#@ident__prim` defined in OCaml
+ accessible in |Coq| commands and tactics.
+ For internal use by implementors of |Coq|'s standard library or standard library
+ replacements. No space is allowed after the `#`. Invalid values give a syntax
+ error.
+
+ For example, the standard library files `Int63.v` and `PrimFloat.v` use :cmd:`Primitive`
+ to support, respectively, the features described in :ref:`primitive-integers` and
+ :ref:`primitive-floats`.
+
+ The types associated with an operator must be declared to the kernel before declaring operations
+ that use the type. Do this with :cmd:`Primitive` for primitive types and
+ :cmd:`Register` with the :g:`kernel` prefix for other types. For example,
+ in `Int63.v`, `#int63_type` must be declared before the associated operations.
+
+ .. exn:: The type @ident must be registered before this construction can be typechecked.
+ :undocumented:
- Declares :n:`@ident__1` as the primitive operator :n:`#@ident__2`. When
- running this command, the type of the primitive should be already known by
- the kernel (this is achieved through this command for primitive types and
- through the :cmd:`Register` command with the :g:`kernel` name-space for other
- types).
+ The type must be defined with :cmd:`Primitive` command before this
+ :cmd:`Primitive` command (declaring an operation using the type) will succeed.