aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/sphinx/README.rst3
-rw-r--r--doc/sphinx/addendum/canonical-structures.rst18
-rw-r--r--doc/sphinx/addendum/extended-pattern-matching.rst48
-rw-r--r--doc/sphinx/addendum/extraction.rst42
-rw-r--r--doc/sphinx/addendum/generalized-rewriting.rst572
-rw-r--r--doc/sphinx/addendum/implicit-coercions.rst30
-rw-r--r--doc/sphinx/addendum/micromega.rst14
-rw-r--r--doc/sphinx/addendum/miscellaneous-extensions.rst1
-rw-r--r--doc/sphinx/addendum/nsatz.rst103
-rw-r--r--doc/sphinx/addendum/omega.rst43
-rw-r--r--doc/sphinx/addendum/parallel-proof-processing.rst17
-rw-r--r--doc/sphinx/addendum/program.rst34
-rw-r--r--doc/sphinx/addendum/ring.rst88
-rw-r--r--doc/sphinx/addendum/type-classes.rst18
-rw-r--r--doc/sphinx/addendum/universe-polymorphism.rst2
-rw-r--r--doc/sphinx/biblio.bib4
-rw-r--r--doc/sphinx/language/cic.rst18
-rw-r--r--doc/sphinx/language/coq-library.rst5
-rw-r--r--doc/sphinx/language/gallina-extensions.rst17
-rw-r--r--doc/sphinx/language/gallina-specification-language.rst6
-rw-r--r--doc/sphinx/practical-tools/coq-commands.rst25
-rw-r--r--doc/sphinx/practical-tools/coqide.rst29
-rw-r--r--doc/sphinx/practical-tools/utilities.rst75
-rw-r--r--doc/sphinx/proof-engine/detailed-tactic-examples.rst641
-rw-r--r--doc/sphinx/proof-engine/ltac.rst37
-rw-r--r--doc/sphinx/proof-engine/proof-handling.rst2
-rw-r--r--doc/sphinx/proof-engine/ssreflect-proof-language.rst1
-rw-r--r--doc/sphinx/proof-engine/tactics.rst25
-rw-r--r--doc/sphinx/user-extensions/proof-schemes.rst34
-rw-r--r--doc/sphinx/user-extensions/syntax-extensions.rst337
-rw-r--r--doc/stdlib/index-list.html.template3
-rw-r--r--doc/tools/coqrst/coqdomain.py8
32 files changed, 1248 insertions, 1052 deletions
diff --git a/doc/sphinx/README.rst b/doc/sphinx/README.rst
index 32de15ee31..1643baf0e8 100644
--- a/doc/sphinx/README.rst
+++ b/doc/sphinx/README.rst
@@ -239,6 +239,9 @@ In addition to the objects above, the ``coqrst`` Sphinx plugin defines the follo
http://docutils.sourceforge.net/docs/ref/rst/directives.html#generic-admonition
for more details.
+ Optionally, any text immediately following the ``.. example::`` header is
+ used as the example's title.
+
Example::
.. example:: Adding a hint to a database
diff --git a/doc/sphinx/addendum/canonical-structures.rst b/doc/sphinx/addendum/canonical-structures.rst
index 6843e9eaa1..3af3115a59 100644
--- a/doc/sphinx/addendum/canonical-structures.rst
+++ b/doc/sphinx/addendum/canonical-structures.rst
@@ -6,14 +6,14 @@ Canonical Structures
:Authors: Assia Mahboubi and Enrico Tassi
-This chapter explains the basics of Canonical Structure and how they can be used
+This chapter explains the basics of canonical structures and how they can be used
to overload notations and build a hierarchy of algebraic structures. The
examples are taken from :cite:`CSwcu`. We invite the interested reader to refer
to this paper for all the details that are omitted here for brevity. The
interested reader shall also find in :cite:`CSlessadhoc` a detailed description
-of another, complementary, use of Canonical Structures: advanced proof search.
+of another, complementary, use of canonical structures: advanced proof search.
This latter papers also presents many techniques one can employ to tune the
-inference of Canonical Structures.
+inference of canonical structures.
Notation overloading
@@ -38,21 +38,21 @@ of the terms that are compared.
End theory.
End EQ.
-We use Coq modules as name spaces. This allows us to follow the same
+We use Coq modules as namespaces. This allows us to follow the same
pattern and naming convention for the rest of the chapter. The base
-name space contains the definitions of the algebraic structure. To
+namespace contains the definitions of the algebraic structure. To
keep the example small, the algebraic structure ``EQ.type`` we are
defining is very simplistic, and characterizes terms on which a binary
relation is defined, without requiring such relation to validate any
property. The inner theory module contains the overloaded notation ``==``
-and will eventually contain lemmas holding on all the instances of the
+and will eventually contain lemmas holding all the instances of the
algebraic structure (in this case there are no lemmas).
Note that in practice the user may want to declare ``EQ.obj`` as a
coercion, but we will not do that here.
The following line tests that, when we assume a type ``e`` that is in
-theEQ class, then we can relates two of its objects with ``==``.
+theEQ class, we can relate two of its objects with ``==``.
.. coqtop:: all
@@ -312,7 +312,7 @@ The following script registers an ``LEQ`` class for ``nat`` and for the type
constructor ``*``. It also tests that they work as expected.
Unfortunately, these declarations are very verbose. In the following
-subsection we show how to make these declaration more compact.
+subsection we show how to make them more compact.
.. coqtop:: all
@@ -385,7 +385,7 @@ with message "T is not an EQ.type"”.
The other utilities are used to ask |Coq| to solve a specific unification
problem, that will in turn require the inference of some canonical structures.
-They are explained in mode details in :cite:`CSwcu`.
+They are explained in more details in :cite:`CSwcu`.
We now have all we need to create a compact “packager” to declare
instances of the ``LEQ`` class.
diff --git a/doc/sphinx/addendum/extended-pattern-matching.rst b/doc/sphinx/addendum/extended-pattern-matching.rst
index c4f0147728..f7fd4b9146 100644
--- a/doc/sphinx/addendum/extended-pattern-matching.rst
+++ b/doc/sphinx/addendum/extended-pattern-matching.rst
@@ -11,7 +11,7 @@ Extended pattern-matching
This section describes the full form of pattern-matching in |Coq| terms.
-.. |rhs| replace:: right hand side
+.. |rhs| replace:: right hand sides
Patterns
--------
@@ -39,12 +39,12 @@ value. A pattern of the form :n:`pattern | pattern` is called disjunctive. A
list of patterns separated with commas is also considered as a pattern
and is called *multiple pattern*. However multiple patterns can only
occur at the root of pattern-matching equations. Disjunctions of
-*multiple pattern* are allowed though.
+*multiple patterns* are allowed though.
Since extended ``match`` expressions are compiled into the primitive ones,
-the expressiveness of the theory remains the same. Once the stage of
-parsing has finished only simple patterns remain. Re-nesting of
-pattern is performed at printing time. An easy way to see the result
+the expressiveness of the theory remains the same. Once parsing has finished
+only simple patterns remain. The original nesting of the ``match`` expressions
+is recovered at printing time. An easy way to see the result
of the expansion is to toggle off the nesting performed at printing
(use here :opt:`Printing Matching`), then by printing the term with :cmd:`Print`
if the term is a constant, or using the command :cmd:`Check`.
@@ -150,12 +150,12 @@ second one and :g:`false` otherwise. We can write it as follows:
| S n, S m => lef n m
end.
-Note that the first and the second multiple pattern superpose because
+Note that the first and the second multiple pattern overlap because
the couple of values ``O O`` matches both. Thus, what is the result of the
function on those values? To eliminate ambiguity we use the *textual
-priority rule*: we consider patterns ordered from top to bottom, then
-a value is matched by the pattern at the ith row if and only if it is
-not matched by some pattern of a previous row. Thus in the example,O O
+priority rule:* we consider patterns to be ordered from top to bottom. A
+value is matched by the pattern at the ith row if and only if it is
+not matched by some pattern from a previous row. Thus in the example, ``O O``
is matched by the first pattern, and so :g:`(lef O O)` yields true.
Another way to write this function is:
@@ -201,7 +201,7 @@ instance, :g:`max` can be rewritten as follows:
| 0, p | p, 0 => p
end.
-Similarly, factorization of (non necessary multiple) patterns that
+Similarly, factorization of (not necessarily multiple) patterns that
share the same variables is possible by using the notation :n:`{+| @pattern}`.
Here is an example:
@@ -312,7 +312,7 @@ Matching objects of dependent types
The previous examples illustrate pattern matching on objects of non-
dependent types, but we can also use the expansion strategy to
-destructure objects of dependent type. Consider the type :g:`listn` of
+destructure objects of dependent types. Consider the type :g:`listn` of
lists of a certain length:
.. coqtop:: in reset
@@ -353,12 +353,12 @@ Dependent pattern matching
~~~~~~~~~~~~~~~~~~~~~~~~~~
The examples given so far do not need an explicit elimination
-predicate because all the |rhs| have the same type and the strategy
+predicate because all the |rhs| have the same type and Coq
succeeds to synthesize it. Unfortunately when dealing with dependent
-patterns it often happens that we need to write cases where the type
+patterns it often happens that we need to write cases where the types
of the |rhs| are different instances of the elimination predicate. The
-function concat for listn is an example where the branches have
-different type and we need to provide the elimination predicate:
+function :g:`concat` for :g:`listn` is an example where the branches have
+different types and we need to provide the elimination predicate:
.. coqtop:: in
@@ -374,7 +374,7 @@ In general if :g:`m` has type :g:`(I q1 … qr t1 … ts)` where :g:`q1, …, qr
are parameters, the elimination predicate should be of the form :g:`fun y1 … ys x : (I q1 … qr y1 … ys ) => Q`.
In the concrete syntax, it should be written :
-``match m as x in (I _ … _ y1 … ys) return Q with … end``
+``match m as x in (I _ … _ y1 … ys) return Q with … end``.
The variables which appear in the ``in`` and ``as`` clause are new and bounded
in the property :g:`Q` in the return clause. The parameters of the
inductive definitions should not be mentioned and are replaced by ``_``.
@@ -385,9 +385,9 @@ Multiple dependent pattern matching
Recall that a list of patterns is also a pattern. So, when we
destructure several terms at the same time and the branches have
different types we need to provide the elimination predicate for this
-multiple pattern. It is done using the same scheme, each term may be
-associated to an as and in clause in order to introduce a dependent
-product.
+multiple pattern. It is done using the same scheme: each term may be
+associated to an ``as`` clause and an ``in`` clause in order to introduce
+a dependent product.
For example, an equivalent definition for :g:`concat` (even though the
matching on the second term is trivial) would have been:
@@ -414,7 +414,7 @@ length, by writing
| consn n' a y, x => consn (n' + m) a (concat n' y m x)
end.
-I have a copy of :g:`b` in type :g:`listn 0` resp :g:`listn (S n')`.
+we have a copy of :g:`b` in type :g:`listn 0` resp. :g:`listn (S n')`.
.. _match-in-patterns:
@@ -425,7 +425,7 @@ If the type of the matched term is more precise than an inductive
applied to variables, arguments of the inductive in the ``in`` branch can
be more complicated patterns than a variable.
-Moreover, constructors whose type do not follow the same pattern will
+Moreover, constructors whose types do not follow the same pattern will
become impossible branches. In an impossible branch, you can answer
anything but False_rect unit has the advantage to be subterm of
anything.
@@ -448,8 +448,8 @@ Using pattern matching to write proofs
In all the previous examples the elimination predicate does not depend
on the object(s) matched. But it may depend and the typical case is
when we write a proof by induction or a function that yields an object
-of dependent type. An example of proof using match in given in Section
-8.2.3.
+of a dependent type. An example of a proof written using ``match`` is given
+in the description of the tactic :tacn:`refine`.
For example, we can write the function :g:`buildlist` that given a natural
number :g:`n` builds a list of length :g:`n` containing zeros as follows:
@@ -572,7 +572,7 @@ When does the expansion strategy fail?
--------------------------------------
The strategy works very like in ML languages when treating patterns of
-non-dependent type. But there are new cases of failure that are due to
+non-dependent types. But there are new cases of failure that are due to
the presence of dependencies.
The error messages of the current implementation may be sometimes
diff --git a/doc/sphinx/addendum/extraction.rst b/doc/sphinx/addendum/extraction.rst
index cb93d48a41..8c1eacf085 100644
--- a/doc/sphinx/addendum/extraction.rst
+++ b/doc/sphinx/addendum/extraction.rst
@@ -116,13 +116,13 @@ be optimized in order to be efficient (for instance, when using
induction principles we do not want to compute all the recursive calls
but only the needed ones). So the extraction mechanism provides an
automatic optimization routine that will be called each time the user
-want to generate |OCaml| programs. The optimizations can be split in two
+wants to generate an |OCaml| program. The optimizations can be split in two
groups: the type-preserving ones (essentially constant inlining and
reductions) and the non type-preserving ones (some function
abstractions of dummy types are removed when it is deemed safe in order
to have more elegant types). Therefore some constants may not appear in the
resulting monolithic |OCaml| program. In the case of modular extraction,
-even if some inlining is done, the inlined constant are nevertheless
+even if some inlining is done, the inlined constants are nevertheless
printed, to ensure session-independent programs.
Concerning Haskell, type-preserving optimizations are less useful
@@ -185,7 +185,7 @@ The type-preserving optimizations are controlled by the following |Coq| options:
**Inlining and printing of a constant declaration:**
-A user can explicitly ask for a constant to be extracted by two means:
+The user can explicitly ask for a constant to be extracted by two means:
* by mentioning it on the extraction command line
@@ -224,19 +224,18 @@ principles of extraction (logical parts and types).
When an actual extraction takes place, an error is normally raised if the
:cmd:`Extraction Implicit` declarations cannot be honored, that is
-if any of the implicited variables still occurs in the final code.
+if any of the implicit arguments still occurs in the final code.
This behavior can be relaxed via the following option:
.. opt:: Extraction SafeImplicits
Default is on. When this option is off, a warning is emitted
- instead of an error if some implicited variables still occur in the
+ instead of an error if some implicit arguments still occur in the
final code of an extraction. This way, the extracted code may be
obtained nonetheless and reviewed manually to locate the source of the issue
- (in the code, some comments mark the location of these remaining
- implicited variables).
+ (in the code, some comments mark the location of these remaining implicit arguments).
Note that this extracted code might not compile or run properly,
- depending of the use of these remaining implicited variables.
+ depending of the use of these remaining implicit arguments.
Realizing axioms
~~~~~~~~~~~~~~~~
@@ -296,7 +295,7 @@ The number of type variables is checked by the system. For example:
Realizing an axiom via :cmd:`Extract Constant` is only useful in the
case of an informative axiom (of sort ``Type`` or ``Set``). A logical axiom
-have no computational content and hence will not appears in extracted
+has no computational content and hence will not appear in extracted
terms. But a warning is nonetheless issued if extraction encounters a
logical axiom. This warning reminds user that inconsistent logical
axioms may lead to incorrect or non-terminating extracted terms.
@@ -312,7 +311,7 @@ Realizing inductive types
The system also provides a mechanism to specify ML terms for inductive
types and constructors. For instance, the user may want to use the ML
-native boolean type instead of |Coq| one. The syntax is the following:
+native boolean type instead of the |Coq| one. The syntax is the following:
.. cmd:: Extract Inductive @qualid => @string [ {+ @string } ]
@@ -332,10 +331,10 @@ native boolean type instead of |Coq| one. The syntax is the following:
branches in functional form, and then the inductive element to
destruct. For instance, the match branch ``| S n => foo`` gives the
functional form ``(fun n -> foo)``. Note that a constructor with no
- argument is considered to have one unit argument, in order to block
+ arguments is considered to have one unit argument, in order to block
early evaluation of the branch: ``| O => bar`` leads to the functional
form ``(fun () -> bar)``. For instance, when extracting ``nat``
- into |OCaml| ``int``, the code to provide has type:
+ into |OCaml| ``int``, the code to be provided has type:
``(unit->'a)->(int->'a)->int->'a``.
.. caution:: As for :cmd:`Extract Constant`, this command should be used with care:
@@ -371,7 +370,7 @@ Typical examples are the following:
When extracting to |OCaml|, if an inductive constructor or type has arity 2 and
the corresponding string is enclosed by parentheses, and the string meets
|OCaml|'s lexical criteria for an infix symbol, then the rest of the string is
- used as infix constructor or type.
+ used as an infix constructor or type.
.. coqtop:: in
@@ -389,7 +388,7 @@ Avoiding conflicts with existing filenames
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When using :cmd:`Extraction Library`, the names of the extracted files
-directly depends from the names of the |Coq| files. It may happen that
+directly depend on the names of the |Coq| files. It may happen that
these filenames are in conflict with already existing files,
either in the standard library of the target language or in other
code that is meant to be linked with the extracted code.
@@ -475,17 +474,18 @@ type-checker without any ``Obj.magic`` (see examples below).
Some examples
-------------
-We present here two examples of extractions, taken from the
-|Coq| Standard Library. We choose |OCaml| as target language,
-but all can be done in the other dialects with slight modifications.
+We present here two examples of extraction, taken from the
+|Coq| Standard Library. We choose |OCaml| as the target language,
+but everything, with slight modifications, can also be done in the
+other languages supported by extraction.
We then indicate where to find other examples and tests of extraction.
A detailed example: Euclidean division
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The file ``Euclid`` contains the proof of Euclidean division.
-The natural numbers used there are unary integers of type ``nat``,
-defined by two constructors ``O`` and ``S``.
+The natural numbers used here are unary, represented by the type``nat``,
+which is defined by two constructors ``O`` and ``S``.
This module contains a theorem ``eucl_dev``, whose type is::
forall b:nat, b > 0 -> forall a:nat, diveucl a b
@@ -579,7 +579,7 @@ extraction test:
* ``stalmarck`` : https://github.com/coq-contribs/stalmarck
Note that ``continuations`` and ``multiplier`` are a bit particular. They are
-examples of developments where ``Obj.magic`` are needed. This is
-probably due to an heavy use of impredicativity. After compilation, those
+examples of developments where ``Obj.magic`` is needed. This is
+probably due to a heavy use of impredicativity. After compilation, those
two examples run nonetheless, thanks to the correction of the
extraction :cite:`Let02`.
diff --git a/doc/sphinx/addendum/generalized-rewriting.rst b/doc/sphinx/addendum/generalized-rewriting.rst
index e4d24a1f7e..c7df250672 100644
--- a/doc/sphinx/addendum/generalized-rewriting.rst
+++ b/doc/sphinx/addendum/generalized-rewriting.rst
@@ -25,13 +25,12 @@ The work is a complete rewrite of the previous implementation, based
on the type class infrastructure. It also improves on and generalizes
the previous implementation in several ways:
-
-+ User-extensible algorithm. The algorithm is separated in two parts:
- generations of the rewriting constraints (done in ML) and solving of
++ User-extensible algorithm. The algorithm is separated into two parts:
+ generation of the rewriting constraints (written in ML) and solving
these constraints using type class resolution. As type class
resolution is extensible using tactics, this allows users to define
general ways to solve morphism constraints.
-+ Sub-relations. An example extension to the base algorithm is the
++ Subrelations. An example extension to the base algorithm is the
ability to define one relation as a subrelation of another so that
morphism declarations on one relation can be used automatically for
the other. This is done purely using tactics and type class search.
@@ -58,41 +57,41 @@ Relations and morphisms
~~~~~~~~~~~~~~~~~~~~~~~
A parametric *relation* ``R`` is any term of type
-``forall (x1 :T1 ) ... (xn :Tn ), relation A``.
+``forall (x1 : T1) ... (xn : Tn), relation A``.
The expression ``A``, which depends on ``x1 ... xn`` , is called the *carrier*
of the relation and ``R`` is said to be a relation over ``A``; the list
``x1,...,xn`` is the (possibly empty) list of parameters of the relation.
-**Example 1 (Parametric relation):**
+.. example:: Parametric relation
-It is possible to implement finite sets of elements of type ``A`` as
-unordered list of elements of type ``A``.
-The function ``set_eq: forall (A: Type), relation (list A)``
-satisfied by two lists with the same elements is a parametric relation
-over ``(list A)`` with one parameter ``A``. The type of ``set_eq``
-is convertible with ``forall (A: Type), list A -> list A -> Prop.``
+ It is possible to implement finite sets of elements of type ``A`` as
+ unordered lists of elements of type ``A``.
+ The function ``set_eq: forall (A : Type), relation (list A)``
+ satisfied by two lists with the same elements is a parametric relation
+ over ``(list A)`` with one parameter ``A``. The type of ``set_eq``
+ is convertible with ``forall (A : Type), list A -> list A -> Prop.``
An *instance* of a parametric relation ``R`` with n parameters is any term
-``(R t1 ... tn )``.
+``(R t1 ... tn)``.
Let ``R`` be a relation over ``A`` with ``n`` parameters. A term is a parametric
proof of reflexivity for ``R`` if it has type
-``forall (x1 :T1 ) ... (xn :Tn), reflexive (R x1 ... xn )``.
+``forall (x1 : T1) ... (xn : Tn), reflexive (R x1 ... xn)``.
Similar definitions are given for parametric proofs of symmetry and transitivity.
-**Example 2 (Parametric relation (cont.)):**
+.. example:: Parametric relation (continued)
-The ``set_eq`` relation of the previous example can be proved to be
-reflexive, symmetric and transitive. A parametric unary function ``f`` of type
-``forall (x1 :T1 ) ... (xn :Tn ), A1 -> A2`` covariantly respects two parametric relation instances
-``R1`` and ``R2`` if, whenever ``x``, ``y`` satisfy ``R1 x y``, their images (``f x``) and (``f y``)
-satisfy ``R2 (f x) (f y)``. An ``f`` that respects its input and output
-relations will be called a unary covariant *morphism*. We can also say
-that ``f`` is a monotone function with respect to ``R1`` and ``R2`` . The
-sequence ``x1 ... xn`` represents the parameters of the morphism.
+ The ``set_eq`` relation of the previous example can be proved to be
+ reflexive, symmetric and transitive. A parametric unary function ``f`` of type
+ ``forall (x1 : T1) ... (xn : Tn), A1 -> A2`` covariantly respects two parametric relation instances
+ ``R1`` and ``R2`` if, whenever ``x``, ``y`` satisfy ``R1 x y``, their images (``f x``) and (``f y``)
+ satisfy ``R2 (f x) (f y)``. An ``f`` that respects its input and output
+ relations will be called a unary covariant *morphism*. We can also say
+ that ``f`` is a monotone function with respect to ``R1`` and ``R2`` . The
+ sequence ``x1 ... xn`` represents the parameters of the morphism.
Let ``R1`` and ``R2`` be two parametric relations. The *signature* of a
-parametric morphism of type ``forall (x1 :T1 ) ... (xn :Tn ), A1 -> A2``
+parametric morphism of type ``forall (x1 : T1) ... (xn : Tn), A1 -> A2``
that covariantly respects two instances :math:`I_{R_1}` and :math:`I_{R_2}` of ``R1`` and ``R2``
is written :math:`I_{R_1} ++> I_{R_2}`. Notice that the special arrow ++>, which
reminds the reader of covariance, is placed between the two relation
@@ -118,29 +117,29 @@ covariant and contravariant.
An instance of a parametric morphism :math:`f` with :math:`n`
parameters is any term :math:`f \, t_1 \ldots t_n`.
-**Example 3 (Morphisms):**
+.. example:: Morphisms
-Continuing the previous example, let ``union: forall (A: Type), list A -> list A -> list A``
-perform the union of two sets by appending one list to the other. ``union` is a binary
-morphism parametric over ``A`` that respects the relation instance
-``(set_eq A)``. The latter condition is proved by showing:
+ Continuing the previous example, let ``union: forall (A : Type), list A -> list A -> list A``
+ perform the union of two sets by appending one list to the other. ``union` is a binary
+ morphism parametric over ``A`` that respects the relation instance
+ ``(set_eq A)``. The latter condition is proved by showing:
-.. coqtop:: in
+ .. coqtop:: in
- forall (A: Type) (S1 S1’ S2 S2’: list A),
- set_eq A S1 S1’ ->
- set_eq A S2 S2’ ->
- set_eq A (union A S1 S2) (union A S1’ S2’).
+ forall (A : Type) (S1 S1’ S2 S2’ : list A),
+ set_eq A S1 S1’ ->
+ set_eq A S2 S2’ ->
+ set_eq A (union A S1 S2) (union A S1’ S2’).
-The signature of the function ``union A`` is ``set_eq A ==> set_eq A ==> set_eq A``
-for all ``A``.
+ The signature of the function ``union A`` is ``set_eq A ==> set_eq A ==> set_eq A``
+ for all ``A``.
-**Example 4 (Contravariant morphism):**
+.. example:: Contravariant morphisms
-The division function ``Rdiv: R -> R -> R`` is a morphism of signature
-``le ++> le --> le`` where ``le`` is the usual order relation over
-real numbers. Notice that division is covariant in its first argument
-and contravariant in its second argument.
+ The division function ``Rdiv : R -> R -> R`` is a morphism of signature
+ ``le ++> le --> le`` where ``le`` is the usual order relation over
+ real numbers. Notice that division is covariant in its first argument
+ and contravariant in its second argument.
Leibniz equality is a relation and every function is a morphism that
respects Leibniz equality. Unfortunately, Leibniz equality is not
@@ -149,180 +148,178 @@ always the intended equality for a given structure.
In the next section we will describe the commands to register terms as
parametric relations and morphisms. Several tactics that deal with
equality in Coq can also work with the registered relations. The exact
-list of tactic will be given :ref:`in this section <tactics-enabled-on-user-provided-relations>`.
-For instance, the tactic reflexivity can be used to close a goal ``R n n`` whenever ``R``
+list of tactics will be given :ref:`in this section <tactics-enabled-on-user-provided-relations>`.
+For instance, the tactic reflexivity can be used to solve a goal ``R n n`` whenever ``R``
is an instance of a registered reflexive relation. However, the
tactics that replace in a context ``C[]`` one term with another one
related by ``R`` must verify that ``C[]`` is a morphism that respects the
-intended relation. Currently the verification consists in checking
+intended relation. Currently the verification consists of checking
whether ``C[]`` is a syntactic composition of morphism instances that respects some obvious
compatibility constraints.
+.. example:: Rewriting
-**Example 5 (Rewriting):**
-
-Continuing the previous examples, suppose that the user must prove
-``set_eq int (union int (union int S1 S2) S2) (f S1 S2)`` under the
-hypothesis ``H: set_eq int S2 (@nil int)``. It
-is possible to use the ``rewrite`` tactic to replace the first two
-occurrences of ``S2`` with ``@nil int`` in the goal since the
-context ``set_eq int (union int (union int S1 nil) nil) (f S1 S2)``,
-being a composition of morphisms instances, is a morphism. However the
-tactic will fail replacing the third occurrence of ``S2`` unless ``f``
-has also been declared as a morphism.
+ Continuing the previous examples, suppose that the user must prove
+ ``set_eq int (union int (union int S1 S2) S2) (f S1 S2)`` under the
+ hypothesis ``H : set_eq int S2 (@nil int)``. It
+ is possible to use the ``rewrite`` tactic to replace the first two
+ occurrences of ``S2`` with ``@nil int`` in the goal since the
+ context ``set_eq int (union int (union int S1 nil) nil) (f S1 S2)``,
+ being a composition of morphisms instances, is a morphism. However the
+ tactic will fail replacing the third occurrence of ``S2`` unless ``f``
+ has also been declared as a morphism.
Adding new relations and morphisms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A parametric relation :g:`Aeq: forall (y1 : β1 ... ym : βm )`,
-:g:`relation (A t1 ... tn)` over :g:`(A : αi -> ... αn -> Type)` can be
-declared with the following command:
+.. cmd:: Add Parametric Relation (x1 : T1) ... (xn : Tk) : (A t1 ... tn) (Aeq t′1 ... t′m) {? reflexivity proved by refl} {? symmetry proved by sym} {? transitivity proved by trans} as @ident
-.. cmd:: Add Parametric Relation (x1 : T1) ... (xn : Tk) : (A t1 ... tn) (Aeq t′1 ... t′m ) {? reflexivity proved by refl} {? symmetry proved by sym} {? transitivity proved by trans} as @ident
-
-after having required the ``Setoid`` module with the ``Require Setoid``
-command.
+ This command declares a parametric relation :g:`Aeq: forall (y1 : β1 ... ym : βm)`,
+ :g:`relation (A t1 ... tn)` over :g:`(A : αi -> ... αn -> Type)`.
-The :g:`@ident` gives a unique name to the morphism and it is used
-by the command to generate fresh names for automatically provided
-lemmas used internally.
+ The :token:`ident` gives a unique name to the morphism and it is used
+ by the command to generate fresh names for automatically provided
+ lemmas used internally.
-Notice that the carrier and relation parameters may refer to the
-context of variables introduced at the beginning of the declaration,
-but the instances need not be made only of variables. Also notice that
-``A`` is *not* required to be a term having the same parameters as ``Aeq``,
-although that is often the case in practice (this departs from the
-previous implementation).
+ Notice that the carrier and relation parameters may refer to the
+ context of variables introduced at the beginning of the declaration,
+ but the instances need not be made only of variables. Also notice that
+ ``A`` is *not* required to be a term having the same parameters as ``Aeq``,
+ although that is often the case in practice (this departs from the
+ previous implementation).
+ To use this command, you need to first import the module ``Setoid`` using
+ the command ``Require Import Setoid``.
.. cmd:: Add Relation
-In case the carrier and relations are not parametric, one can use this command
-instead, whose syntax is the same except there is no local context.
+ In case the carrier and relations are not parametric, one can use this command
+ instead, whose syntax is the same except there is no local context.
-The proofs of reflexivity, symmetry and transitivity can be omitted if
-the relation is not an equivalence relation. The proofs must be
-instances of the corresponding relation definitions: e.g. the proof of
-reflexivity must have a type convertible to
-:g:`reflexive (A t1 ... tn) (Aeq t′ 1 …t′ n )`.
-Each proof may refer to the introduced variables as well.
+ The proofs of reflexivity, symmetry and transitivity can be omitted if
+ the relation is not an equivalence relation. The proofs must be
+ instances of the corresponding relation definitions: e.g. the proof of
+ reflexivity must have a type convertible to
+ :g:`reflexive (A t1 ... tn) (Aeq t′ 1 …t′ n)`.
+ Each proof may refer to the introduced variables as well.
-**Example 6 (Parametric relation):**
+.. example:: Parametric relation
-For Leibniz equality, we may declare:
+ For Leibniz equality, we may declare:
-.. coqtop:: in
+ .. coqtop:: in
- Add Parametric Relation (A : Type) : A (@eq A)
- [reflexivity proved by @refl_equal A]
- ...
+ Add Parametric Relation (A : Type) : A (@eq A)
+ [reflexivity proved by @refl_equal A]
+ ...
Some tactics (:tacn:`reflexivity`, :tacn:`symmetry`, :tacn:`transitivity`) work only on
relations that respect the expected properties. The remaining tactics
-(`replace`, :tacn:`rewrite` and derived tactics such as :tacn:`autorewrite`) do not
+(:tacn:`replace`, :tacn:`rewrite` and derived tactics such as :tacn:`autorewrite`) do not
require any properties over the relation. However, they are able to
replace terms with related ones only in contexts that are syntactic
compositions of parametric morphism instances declared with the
following command.
-.. cmd:: Add Parametric Morphism (x1 : T1 ) ... (xk : Tk ) : (f t1 ... tn ) with signature sig as @ident
+.. cmd:: Add Parametric Morphism (x1 : T1) ... (xk : Tk) : (f t1 ... tn) with signature sig as @ident
-The command declares ``f`` as a parametric morphism of signature ``sig``. The
-identifier ``id`` gives a unique name to the morphism and it is used as
-the base name of the type class instance definition and as the name of
-the lemma that proves the well-definedness of the morphism. The
-parameters of the morphism as well as the signature may refer to the
-context of variables. The command asks the user to prove interactively
-that ``f`` respects the relations identified from the signature.
+ This command declares ``f`` as a parametric morphism of signature ``sig``. The
+ identifier :token:`ident` gives a unique name to the morphism and it is used as
+ the base name of the type class instance definition and as the name of
+ the lemma that proves the well-definedness of the morphism. The
+ parameters of the morphism as well as the signature may refer to the
+ context of variables. The command asks the user to prove interactively
+ that ``f`` respects the relations identified from the signature.
-**Example 7:**
+.. example::
-We start the example by assuming a small theory over
-homogeneous sets and we declare set equality as a parametric
-equivalence relation and union of two sets as a parametric morphism.
+ We start the example by assuming a small theory over
+ homogeneous sets and we declare set equality as a parametric
+ equivalence relation and union of two sets as a parametric morphism.
-.. coqtop:: in
+ .. coqtop:: in
- Require Export Setoid.
- Require Export Relation_Definitions.
+ Require Export Setoid.
+ Require Export Relation_Definitions.
- Set Implicit Arguments.
+ Set Implicit Arguments.
- Parameter set: Type -> Type.
- Parameter empty: forall A, set A.
- Parameter eq_set: forall A, set A -> set A -> Prop.
- Parameter union: forall A, set A -> set A -> set A.
+ Parameter set : Type -> Type.
+ Parameter empty : forall A, set A.
+ Parameter eq_set : forall A, set A -> set A -> Prop.
+ Parameter union : forall A, set A -> set A -> set A.
- Axiom eq_set_refl: forall A, reflexive _ (eq_set (A:=A)).
- Axiom eq_set_sym: forall A, symmetric _ (eq_set (A:=A)).
- Axiom eq_set_trans: forall A, transitive _ (eq_set (A:=A)).
- Axiom empty_neutral: forall A (S: set A), eq_set (union S (empty A)) S.
+ Axiom eq_set_refl : forall A, reflexive _ (eq_set (A:=A)).
+ Axiom eq_set_sym : forall A, symmetric _ (eq_set (A:=A)).
+ Axiom eq_set_trans : forall A, transitive _ (eq_set (A:=A)).
+ Axiom empty_neutral : forall A (S : set A), eq_set (union S (empty A)) S.
- Axiom union_compat: forall (A : Type),
- forall x x' : set A, eq_set x x' ->
- forall y y' : set A, eq_set y y' ->
- eq_set (union x y) (union x' y').
+ Axiom union_compat :
+ forall (A : Type),
+ forall x x' : set A, eq_set x x' ->
+ forall y y' : set A, eq_set y y' ->
+ eq_set (union x y) (union x' y').
- Add Parametric Relation A : (set A) (@eq_set A)
- reflexivity proved by (eq_set_refl (A:=A))
- symmetry proved by (eq_set_sym (A:=A))
- transitivity proved by (eq_set_trans (A:=A))
- as eq_set_rel.
+ Add Parametric Relation A : (set A) (@eq_set A)
+ reflexivity proved by (eq_set_refl (A:=A))
+ symmetry proved by (eq_set_sym (A:=A))
+ transitivity proved by (eq_set_trans (A:=A))
+ as eq_set_rel.
- Add Parametric Morphism A : (@union A) with
- signature (@eq_set A) ==> (@eq_set A) ==> (@eq_set A) as union_mor.
- Proof.
- exact (@union_compat A).
- Qed.
+ Add Parametric Morphism A : (@union A)
+ with signature (@eq_set A) ==> (@eq_set A) ==> (@eq_set A) as union_mor.
+ Proof.
+ exact (@union_compat A).
+ Qed.
-It is possible to reduce the burden of specifying parameters using
-(maximally inserted) implicit arguments. If ``A`` is always set as
-maximally implicit in the previous example, one can write:
+ It is possible to reduce the burden of specifying parameters using
+ (maximally inserted) implicit arguments. If ``A`` is always set as
+ maximally implicit in the previous example, one can write:
-.. coqtop:: in
+ .. coqtop:: in
- Add Parametric Relation A : (set A) eq_set
- reflexivity proved by eq_set_refl
- symmetry proved by eq_set_sym
- transitivity proved by eq_set_trans
- as eq_set_rel.
+ Add Parametric Relation A : (set A) eq_set
+ reflexivity proved by eq_set_refl
+ symmetry proved by eq_set_sym
+ transitivity proved by eq_set_trans
+ as eq_set_rel.
-.. coqtop:: in
+ .. coqtop:: in
- Add Parametric Morphism A : (@union A) with
- signature eq_set ==> eq_set ==> eq_set as union_mor.
+ Add Parametric Morphism A : (@union A) with
+ signature eq_set ==> eq_set ==> eq_set as union_mor.
-.. coqtop:: in
+ .. coqtop:: in
- Proof. exact (@union_compat A). Qed.
+ Proof. exact (@union_compat A). Qed.
-We proceed now by proving a simple lemma performing a rewrite step and
-then applying reflexivity, as we would do working with Leibniz
-equality. Both tactic applications are accepted since the required
-properties over ``eq_set`` and ``union`` can be established from the two
-declarations above.
+ We proceed now by proving a simple lemma performing a rewrite step and
+ then applying reflexivity, as we would do working with Leibniz
+ equality. Both tactic applications are accepted since the required
+ properties over ``eq_set`` and ``union`` can be established from the two
+ declarations above.
-.. coqtop:: in
+ .. coqtop:: in
- Goal forall (S: set nat),
- eq_set (union (union S empty) S) (union S S).
+ Goal forall (S : set nat),
+ eq_set (union (union S empty) S) (union S S).
-.. coqtop:: in
+ .. coqtop:: in
- Proof. intros. rewrite empty_neutral. reflexivity. Qed.
+ Proof. intros. rewrite empty_neutral. reflexivity. Qed.
-The tables of relations and morphisms are managed by the type class
-instance mechanism. The behavior on section close is to generalize the
-instances by the variables of the section (and possibly hypotheses
-used in the proofs of instance declarations) but not to export them in
-the rest of the development for proof search. One can use the
-cmd:`Existing Instance` command to do so outside the section, using the name of the
-declared morphism suffixed by ``_Morphism``, or use the ``Global`` modifier
-for the corresponding class instance declaration
-(see :ref:`First Class Setoids and Morphisms <first-class-setoids-and-morphisms>`) at
-definition time. When loading a compiled file or importing a module,
-all the declarations of this module will be loaded.
+ The tables of relations and morphisms are managed by the type class
+ instance mechanism. The behavior on section close is to generalize the
+ instances by the variables of the section (and possibly hypotheses
+ used in the proofs of instance declarations) but not to export them in
+ the rest of the development for proof search. One can use the
+ cmd:`Existing Instance` command to do so outside the section, using the name of the
+ declared morphism suffixed by ``_Morphism``, or use the ``Global`` modifier
+ for the corresponding class instance declaration
+ (see :ref:`First Class Setoids and Morphisms <first-class-setoids-and-morphisms>`) at
+ definition time. When loading a compiled file or importing a module,
+ all the declarations of this module will be loaded.
Rewriting and non reflexive relations
@@ -332,31 +329,31 @@ To replace only one argument of an n-ary morphism it is necessary to
prove that all the other arguments are related to themselves by the
respective relation instances.
-**Example 8:**
+.. example::
-To replace ``(union S empty)`` with ``S`` in ``(union (union S empty) S) (union S S)``
-the rewrite tactic must exploit the monotony of ``union`` (axiom ``union_compat``
-in the previous example). Applying ``union_compat`` by hand we are left with the
-goal ``eq_set (union S S) (union S S)``.
+ To replace ``(union S empty)`` with ``S`` in ``(union (union S empty) S) (union S S)``
+ the rewrite tactic must exploit the monotony of ``union`` (axiom ``union_compat``
+ in the previous example). Applying ``union_compat`` by hand we are left with the
+ goal ``eq_set (union S S) (union S S)``.
When the relations associated to some arguments are not reflexive, the
tactic cannot automatically prove the reflexivity goals, that are left
to the user.
-Setoids whose relation are partial equivalence relations (PER) are
-useful to deal with partial functions. Let ``R`` be a PER. We say that an
+Setoids whose relations are partial equivalence relations (PER) are
+useful for dealing with partial functions. Let ``R`` be a PER. We say that an
element ``x`` is defined if ``R x x``. A partial function whose domain
-comprises all the defined elements only is declared as a morphism that
+comprises all the defined elements is declared as a morphism that
respects ``R``. Every time a rewriting step is performed the user must
prove that the argument of the morphism is defined.
-**Example 9:**
+.. example::
-Let ``eqO`` be ``fun x y => x = y /\ x <> 0`` (the
-smaller PER over non zero elements). Division can be declared as a
-morphism of signature ``eq ==> eq0 ==> eq``. Replace ``x`` with
-``y`` in ``div x n = div y n`` opens the additional goal ``eq0 n n``
-that is equivalent to ``n = n /\ n <> 0``.
+ Let ``eqO`` be ``fun x y => x = y /\ x <> 0`` (the
+ smallest PER over non zero elements). Division can be declared as a
+ morphism of signature ``eq ==> eq0 ==> eq``. Replacing ``x`` with
+ ``y`` in ``div x n = div y n`` opens an additional goal ``eq0 n n``
+ which is equivalent to ``n = n /\ n <> 0``.
Rewriting and non symmetric relations
@@ -371,44 +368,44 @@ a contravariant position. In a similar way, replacement in an
hypothesis can be performed only if the replaced term occurs in a
covariant position.
-**Example 10 (Covariance and contravariance):**
-
-Suppose that division over real numbers has been defined as a morphism of signature
-``Z.div: Z.lt ++> Z.lt --> Z.lt`` (i.e. ``Z.div`` is increasing in
-its first argument, but decreasing on the second one). Let ``<``
-denotes ``Z.lt``. Under the hypothesis ``H: x < y`` we have
-``k < x / y -> k < x / x``, but not ``k < y / x -> k < x / x``. Dually,
-under the same hypothesis ``k < x / y -> k < y / y`` holds, but
-``k < y / x -> k < y / y`` does not. Thus, if the current goal is
-``k < x / x``, it is possible to replace only the second occurrence of
-``x`` (in contravariant position) with ``y`` since the obtained goal
-must imply the current one. On the contrary, if ``k < x / x`` is an
-hypothesis, it is possible to replace only the first occurrence of
-``x`` (in covariant position) with ``y`` since the current
-hypothesis must imply the obtained one.
-
-Contrary to the previous implementation, no specific error message
-will be raised when trying to replace a term that occurs in the wrong
-position. It will only fail because the rewriting constraints are not
-satisfiable. However it is possible to use the at modifier to specify
-which occurrences should be rewritten.
-
-As expected, composing morphisms together propagates the variance
-annotations by switching the variance every time a contravariant
-position is traversed.
-
-**Example 11:**
-
-Let us continue the previous example and let us consider
-the goal ``x / (x / x) < k``. The first and third occurrences of
-``x`` are in a contravariant position, while the second one is in
-covariant position. More in detail, the second occurrence of ``x``
-occurs covariantly in ``(x / x)`` (since division is covariant in
-its first argument), and thus contravariantly in ``x / (x / x)``
-(since division is contravariant in its second argument), and finally
-covariantly in ``x / (x / x) < k`` (since ``<``, as every
-transitive relation, is contravariant in its first argument with
-respect to the relation itself).
+.. example:: Covariance and contravariance
+
+ Suppose that division over real numbers has been defined as a morphism of signature
+ ``Z.div : Z.lt ++> Z.lt --> Z.lt`` (i.e. ``Z.div`` is increasing in
+ its first argument, but decreasing on the second one). Let ``<``
+ denote ``Z.lt``. Under the hypothesis ``H : x < y`` we have
+ ``k < x / y -> k < x / x``, but not ``k < y / x -> k < x / x``. Dually,
+ under the same hypothesis ``k < x / y -> k < y / y`` holds, but
+ ``k < y / x -> k < y / y`` does not. Thus, if the current goal is
+ ``k < x / x``, it is possible to replace only the second occurrence of
+ ``x`` (in contravariant position) with ``y`` since the obtained goal
+ must imply the current one. On the contrary, if ``k < x / x`` is an
+ hypothesis, it is possible to replace only the first occurrence of
+ ``x`` (in covariant position) with ``y`` since the current
+ hypothesis must imply the obtained one.
+
+ Contrary to the previous implementation, no specific error message
+ will be raised when trying to replace a term that occurs in the wrong
+ position. It will only fail because the rewriting constraints are not
+ satisfiable. However it is possible to use the at modifier to specify
+ which occurrences should be rewritten.
+
+ As expected, composing morphisms together propagates the variance
+ annotations by switching the variance every time a contravariant
+ position is traversed.
+
+.. example::
+
+ Let us continue the previous example and let us consider
+ the goal ``x / (x / x) < k``. The first and third occurrences of
+ ``x`` are in a contravariant position, while the second one is in
+ covariant position. More in detail, the second occurrence of ``x``
+ occurs covariantly in ``(x / x)`` (since division is covariant in
+ its first argument), and thus contravariantly in ``x / (x / x)``
+ (since division is contravariant in its second argument), and finally
+ covariantly in ``x / (x / x) < k`` (since ``<``, as every
+ transitive relation, is contravariant in its first argument with
+ respect to the relation itself).
Rewriting in ambiguous setoid contexts
@@ -417,15 +414,14 @@ Rewriting in ambiguous setoid contexts
One function can respect several different relations and thus it can
be declared as a morphism having multiple signatures.
-**Example 12:**
-
+.. example::
-Union over homogeneous lists can be given all the
-following signatures: ``eq ==> eq ==> eq`` (``eq`` being the
-equality over ordered lists) ``set_eq ==> set_eq ==> set_eq``
-(``set_eq`` being the equality over unordered lists up to duplicates),
-``multiset_eq ==> multiset_eq ==> multiset_eq`` (``multiset_eq``
-being the equality over unordered lists).
+ Union over homogeneous lists can be given all the
+ following signatures: ``eq ==> eq ==> eq`` (``eq`` being the
+ equality over ordered lists) ``set_eq ==> set_eq ==> set_eq``
+ (``set_eq`` being the equality over unordered lists up to duplicates),
+ ``multiset_eq ==> multiset_eq ==> multiset_eq`` (``multiset_eq``
+ being the equality over unordered lists).
To declare multiple signatures for a morphism, repeat the :cmd:`Add Morphism`
command.
@@ -435,7 +431,7 @@ rewrite request is ambiguous, since it is unclear what relations
should be used to perform the rewriting. Contrary to the previous
implementation, the tactic will always choose the first possible
solution to the set of constraints generated by a rewrite and will not
-try to find *all* possible solutions to warn the user about.
+try to find *all* the possible solutions to warn the user about them.
Commands and tactics
@@ -457,7 +453,7 @@ hint database. For example, the declaration:
.. coqtop:: in
- Add Parametric Relation (x1 : T1) ... (xn : Tk) : (A t1 ... tn) (Aeq t′1 ... t′m)
+ Add Parametric Relation (x1 : T1) ... (xn : Tn) : (A t1 ... tn) (Aeq t′1 ... t′m)
[reflexivity proved by refl]
[symmetry proved by sym]
[transitivity proved by trans]
@@ -468,7 +464,7 @@ is equivalent to an instance declaration:
.. coqtop:: in
- Instance (x1 : T1) ... (xn : Tk) => id : @Equivalence (A t1 ... tn) (Aeq t′1 ... t′m) :=
+ Instance (x1 : T1) ... (xn : Tn) => id : @Equivalence (A t1 ... tn) (Aeq t′1 ... t′m) :=
[Equivalence_Reflexive := refl]
[Equivalence_Symmetric := sym]
[Equivalence_Transitive := trans].
@@ -491,37 +487,37 @@ handled by encoding them as records. In the following example, the
projections of the setoid relation and of the morphism function can be
registered as parametric relations and morphisms.
-**Example 13 (First class setoids):**
+.. example:: First class setoids
-.. coqtop:: in
+ .. coqtop:: in
- Require Import Relation_Definitions Setoid.
+ Require Import Relation_Definitions Setoid.
- Record Setoid: Type :=
- { car: Type;
- eq: car -> car -> Prop;
- refl: reflexive _ eq;
- sym: symmetric _ eq;
- trans: transitive _ eq
- }.
+ Record Setoid : Type :=
+ { car: Type;
+ eq: car -> car -> Prop;
+ refl: reflexive _ eq;
+ sym: symmetric _ eq;
+ trans: transitive _ eq
+ }.
- Add Parametric Relation (s : Setoid) : (@car s) (@eq s)
- reflexivity proved by (refl s)
- symmetry proved by (sym s)
- transitivity proved by (trans s) as eq_rel.
+ Add Parametric Relation (s : Setoid) : (@car s) (@eq s)
+ reflexivity proved by (refl s)
+ symmetry proved by (sym s)
+ transitivity proved by (trans s) as eq_rel.
- Record Morphism (S1 S2:Setoid): Type :=
- { f: car S1 -> car S2;
- compat: forall (x1 x2: car S1), eq S1 x1 x2 -> eq S2 (f x1) (f x2)
- }.
+ Record Morphism (S1 S2 : Setoid) : Type :=
+ { f: car S1 -> car S2;
+ compat: forall (x1 x2 : car S1), eq S1 x1 x2 -> eq S2 (f x1) (f x2)
+ }.
- Add Parametric Morphism (S1 S2 : Setoid) (M : Morphism S1 S2) :
- (@f S1 S2 M) with signature (@eq S1 ==> @eq S2) as apply_mor.
- Proof. apply (compat S1 S2 M). Qed.
+ Add Parametric Morphism (S1 S2 : Setoid) (M : Morphism S1 S2) :
+ (@f S1 S2 M) with signature (@eq S1 ==> @eq S2) as apply_mor.
+ Proof. apply (compat S1 S2 M). Qed.
- Lemma test: forall (S1 S2:Setoid) (m: Morphism S1 S2)
- (x y: car S1), eq S1 x y -> eq S2 (f _ _ m x) (f _ _ m y).
- Proof. intros. rewrite H. reflexivity. Qed.
+ Lemma test : forall (S1 S2 : Setoid) (m : Morphism S1 S2)
+ (x y : car S1), eq S1 x y -> eq S2 (f _ _ m x) (f _ _ m y).
+ Proof. intros. rewrite H. reflexivity. Qed.
.. _tactics-enabled-on-user-provided-relations:
@@ -539,33 +535,32 @@ pass additional arguments such as ``using relation``.
.. tacv:: setoid_reflexivity
:name: setoid_reflexivity
-.. tacv:: setoid_symmetry [in @ident]
+.. tacv:: setoid_symmetry {? in @ident}
:name: setoid_symmetry
.. tacv:: setoid_transitivity
:name: setoid_transitivity
-.. tacv:: setoid_rewrite [@orientation] @term [at @occs] [in @ident]
+.. tacv:: setoid_rewrite {? @orientation} @term {? at @occs} {? in @ident}
:name: setoid_rewrite
-.. tacv:: setoid_replace @term with @term [in @ident] [using relation @term] [by @tactic]
+.. tacv:: setoid_replace @term with @term {? using relation @term} {? in @ident} {? by @tactic}
:name: setoid_replace
-
-The ``using relation`` arguments cannot be passed to the unprefixed form.
-The latter argument tells the tactic what parametric relation should
-be used to replace the first tactic argument with the second one. If
-omitted, it defaults to the ``DefaultRelation`` instance on the type of
-the objects. By default, it means the most recent ``Equivalence`` instance
-in the environment, but it can be customized by declaring
-new ``DefaultRelation`` instances. As Leibniz equality is a declared
-equivalence, it will fall back to it if no other relation is declared
-on a given type.
+ The ``using relation`` arguments cannot be passed to the unprefixed form.
+ The latter argument tells the tactic what parametric relation should
+ be used to replace the first tactic argument with the second one. If
+ omitted, it defaults to the ``DefaultRelation`` instance on the type of
+ the objects. By default, it means the most recent ``Equivalence`` instance
+ in the environment, but it can be customized by declaring
+ new ``DefaultRelation`` instances. As Leibniz equality is a declared
+ equivalence, it will fall back to it if no other relation is declared
+ on a given type.
Every derived tactic that is based on the unprefixed forms of the
tactics considered above will also work up to user defined relations.
For instance, it is possible to register hints for :tacn:`autorewrite` that
-are not proof of Leibniz equalities. In particular it is possible to
+are not proofs of Leibniz equalities. In particular it is possible to
exploit :tacn:`autorewrite` to simulate normalization in a term rewriting
system up to user defined equalities.
@@ -575,39 +570,39 @@ Printing relations and morphisms
.. cmd:: Print Instances
-This command can be used to show the list of currently
-registered ``Reflexive`` (using ``Print Instances Reflexive``), ``Symmetric``
-or ``Transitive`` relations, Equivalences, PreOrders, PERs, and Morphisms
-(implemented as ``Proper`` instances). When the rewriting tactics refuse
-to replace a term in a context because the latter is not a composition
-of morphisms, the :cmd:`Print Instances` command can be useful to understand
-what additional morphisms should be registered.
+ This command can be used to show the list of currently
+ registered ``Reflexive`` (using ``Print Instances Reflexive``), ``Symmetric``
+ or ``Transitive`` relations, Equivalences, PreOrders, PERs, and Morphisms
+ (implemented as ``Proper`` instances). When the rewriting tactics refuse
+ to replace a term in a context because the latter is not a composition
+ of morphisms, the :cmd:`Print Instances` command can be useful to understand
+ what additional morphisms should be registered.
Deprecated syntax and backward incompatibilities
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Due to backward compatibility reasons, the following syntax for the
-declaration of setoids and morphisms is also accepted.
-
.. cmd:: Add Setoid @A @Aeq @ST as @ident
-where ``Aeq`` is a congruence relation without parameters, ``A`` is its carrier
-and ``ST`` is an object of type (``Setoid_Theory A Aeq``) (i.e. a record
-packing together the reflexivity, symmetry and transitivity lemmas).
-Notice that the syntax is not completely backward compatible since the
-identifier was not required.
+ This command for declaring setoids and morphisms is also accepted due
+ to backward compatibility reasons.
+
+ Here ``Aeq`` is a congruence relation without parameters, ``A`` is its carrier
+ and ``ST`` is an object of type (``Setoid_Theory A Aeq``) (i.e. a record
+ packing together the reflexivity, symmetry and transitivity lemmas).
+ Notice that the syntax is not completely backward compatible since the
+ identifier was not required.
.. cmd:: Add Morphism f : @ident
:name: Add Morphism
-The latter command also is restricted to the declaration of morphisms
-without parameters. It is not fully backward compatible since the
-property the user is asked to prove is slightly different: for n-ary
-morphisms the hypotheses of the property are permuted; moreover, when
-the morphism returns a proposition, the property is now stated using a
-bi-implication in place of a simple implication. In practice, porting
-an old development to the new semantics is usually quite simple.
+ This command is restricted to the declaration of morphisms
+ without parameters. It is not fully backward compatible since the
+ property the user is asked to prove is slightly different: for n-ary
+ morphisms the hypotheses of the property are permuted; moreover, when
+ the morphism returns a proposition, the property is now stated using a
+ bi-implication in place of a simple implication. In practice, porting
+ an old development to the new semantics is usually quite simple.
Notice that several limitations of the old implementation have been
lifted. In particular, it is now possible to declare several relations
@@ -657,9 +652,8 @@ in ``Prop`` are implicitly translated to such applications).
Indeed, when rewriting under a lambda, binding variable ``x``, say from ``P x``
to ``Q x`` using the relation iff, the tactic will generate a proof of
``pointwise_relation A iff (fun x => P x) (fun x => Q x)`` from the proof
-of ``iff (P x) (Q x)`` and a constraint of the form Proper
-``(pointwise_relation A iff ==> ?) m`` will be generated for the
-surrounding morphism ``m``.
+of ``iff (P x) (Q x)`` and a constraint of the form ``Proper (pointwise_relation A iff ==> ?) m``
+will be generated for the surrounding morphism ``m``.
Hence, one can add higher-order combinators as morphisms by providing
signatures using pointwise extension for the relations on the
@@ -685,11 +679,11 @@ default. The semantics of the previous :tacn:`setoid_rewrite` implementation
can almost be recovered using the ``at 1`` modifier.
-Sub-relations
+Subrelations
~~~~~~~~~~~~~
-Sub-relations can be used to specify that one relation is included in
-another, so that morphisms signatures for one can be used for the
+Subrelations can be used to specify that one relation is included in
+another, so that morphism signatures for one can be used for the
other. If a signature mentions a relation ``R`` on the left of an
arrow ``==>``, then the signature also applies for any relation ``S`` that is
smaller than ``R``, and the inverse applies on the right of an arrow. One
@@ -702,7 +696,7 @@ two morphisms for conjunction: ``Proper (impl ==> impl ==> impl) and`` and
rewriting constraints arising from a rewrite using ``iff``, ``impl`` or
``inverse impl`` through ``and``.
-Sub-relations are implemented in ``Classes.Morphisms`` and are a prime
+Subrelations are implemented in ``Classes.Morphisms`` and are a prime
example of a mostly user-space extension of the algorithm.
diff --git a/doc/sphinx/addendum/implicit-coercions.rst b/doc/sphinx/addendum/implicit-coercions.rst
index 09faa06765..f134022eb6 100644
--- a/doc/sphinx/addendum/implicit-coercions.rst
+++ b/doc/sphinx/addendum/implicit-coercions.rst
@@ -31,7 +31,7 @@ A class with `n` parameters is any defined name with a type
:g:`forall (x₁:A₁)..(xₙ:Aₙ),s` where ``s`` is a sort. Thus a class with
parameters is considered as a single class and not as a family of
classes. An object of a class ``C`` is any term of type :g:`C t₁ .. tₙ`.
-In addition to these user-classes, we have two abstract classes:
+In addition to these user-defined classes, we have two built-in classes:
* ``Sortclass``, the class of sorts; its objects are the terms whose type is a
@@ -50,11 +50,11 @@ Formally, the syntax of a classes is defined as:
Coercions
---------
-A name ``f`` can be declared as a coercion between a source user-class
+A name ``f`` can be declared as a coercion between a source user-defined class
``C`` with `n` parameters and a target class ``D`` if one of these
conditions holds:
- * ``D`` is a user-class, then the type of ``f`` must have the form
+ * ``D`` is a user-defined class, then the type of ``f`` must have the form
:g:`forall (x₁:A₁)..(xₙ:Aₙ)(y:C x₁..xₙ), D u₁..uₘ` where `m`
is the number of parameters of ``D``.
* ``D`` is ``Funclass``, then the type of ``f`` must have the form
@@ -65,8 +65,8 @@ conditions holds:
We then write :g:`f : C >-> D`. The restriction on the type
of coercions is called *the uniform inheritance condition*.
-.. note:: The abstract class ``Sortclass`` can be used as a source class, but
- the abstract class ``Funclass`` cannot.
+.. note:: The built-in class ``Sortclass`` can be used as a source class, but
+ the built-in class ``Funclass`` cannot.
To coerce an object :g:`t:C t₁..tₙ` of ``C`` towards ``D``, we have to
apply the coercion ``f`` to it; the obtained term :g:`f t₁..tₙ t` is
@@ -95,7 +95,7 @@ We can now declare ``f`` as coercion from ``C'`` to ``D``, since we can
The identity coercions have a special status: to coerce an object
:g:`t:C' t₁..tₖ`
-of ``C'`` towards ``C``, we does not have to insert explicitly ``Id_C'_C``
+of ``C'`` towards ``C``, we do not have to insert explicitly ``Id_C'_C``
since :g:`Id_C'_C t₁..tₖ t` is convertible with ``t``. However we
"rewrite" the type of ``t`` to become an object of ``C``; in this case,
it becomes :g:`C uₙ'..uₖ'` where each ``uᵢ'`` is the result of the
@@ -121,7 +121,7 @@ by the coercions ``f₁..fₖ``. The application of a coercion path to a
term consists of the successive application of its coercions.
-Declaration of Coercions
+Declaring Coercions
-------------------------
.. cmd:: Coercion @qualid : @class >-> @class
@@ -140,8 +140,8 @@ Declaration of Coercions
.. warn:: Ambiguous path.
- When the coercion :token:`qualid` is added to the inheritance graph, non
- valid coercion paths are ignored; they are signaled by a warning
+ When the coercion :token:`qualid` is added to the inheritance graph,
+ invalid coercion paths are ignored; they are signaled by a warning
displaying these paths of the form :g:`[f₁;..;fₙ] : C >-> D`.
.. cmdv:: Local Coercion @qualid : @class >-> @class
@@ -215,7 +215,7 @@ declaration, this constructor is declared as a coercion.
.. cmdv:: Local Identity Coercion @ident : @ident >-> @ident
- Idem but locally to the current section.
+ Same as ``Identity Coercion`` but locally to the current section.
.. cmdv:: SubClass @ident := @type
:name: SubClass
@@ -319,7 +319,7 @@ Coercions and Modules
Since |Coq| version 8.3, the coercions present in a module are activated
only when the module is explicitly imported. Formerly, the coercions
- were activated as soon as the module was required, whatever it was
+ were activated as soon as the module was required, whether it was
imported or not.
This option makes it possible to recover the behavior of the versions of
@@ -387,8 +387,8 @@ We give now an example using identity coercions.
In the case of functional arguments, we use the monotonic rule of
-sub-typing. Approximatively, to coerce :g:`t:forall x:A,B` towards
-:g:`forall x:A',B'`, one have to coerce ``A'`` towards ``A`` and ``B``
+sub-typing. To coerce :g:`t : forall x : A, B` towards
+:g:`forall x : A', B'`, we have to coerce ``A'`` towards ``A`` and ``B``
towards ``B'``. An example is given below:
.. coqtop:: all
@@ -424,8 +424,8 @@ replaced by ``x:A'`` where ``A'`` is the result of the application to
``Sortclass`` if it exists. This case occurs in the abstraction
:g:`fun x:A => t`, universal quantification :g:`forall x:A,B`, global
variables and parameters of (co-)inductive definitions and
-functions. In :g:`forall x:A,B`, such a coercion path may be applied
-to ``B`` also if necessary.
+functions. In :g:`forall x:A,B`, such a coercion path may also be applied
+to ``B`` if necessary.
.. coqtop:: all
diff --git a/doc/sphinx/addendum/micromega.rst b/doc/sphinx/addendum/micromega.rst
index 2407a9051a..d03a31c044 100644
--- a/doc/sphinx/addendum/micromega.rst
+++ b/doc/sphinx/addendum/micromega.rst
@@ -20,7 +20,7 @@ rationals ``Require Import Lqa`` and reals ``Require Import Lra``.
+ :tacn:`nra` is an incomplete proof procedure for non-linear (real or
rational) arithmetic;
+ :tacn:`psatz` ``D n`` where ``D`` is :math:`\mathbb{Z}` or :math:`\mathbb{Q}` or :math:`\mathbb{R}`, and
- ``n`` is an optional integer limiting the proof search depth
+ ``n`` is an optional integer limiting the proof search depth,
is an incomplete proof procedure for non-linear arithmetic.
It is based on John Harrison’s HOL Light
driver to the external prover `csdp` [#]_. Note that the `csdp` driver is
@@ -32,10 +32,10 @@ arithmetic expressions interpreted over a domain :math:`D` ∈ {ℤ, ℚ, ℝ}.
The syntax of the formulas is the following:
.. productionlist:: `F`
- F : A ∣ P ∣ True ∣ False ∣ F 1 ∧ F 2 ∣ F 1 ∨ F 2 ∣ F 1 ↔ F 2 ∣ F 1 → F 2 ∣ ¬ F
- A : p 1 = p 2 ∣ p 1 > p 2 ∣ p 1 < p 2 ∣ p 1 ≥ p 2 ∣ p 1 ≤ p 2
- p : c ∣ x ∣ −p ∣ p 1 − p 2 ∣ p 1 + p 2 ∣ p 1 × p 2 ∣ p ^ n
-
+ F : A ∣ P ∣ True ∣ False ∣ F ∧ F ∣ F ∨ F ∣ F ↔ F ∣ F → F ∣ ¬ F
+ A : p = p ∣ p > p ∣ p < p ∣ p ≥ p ∣ p ≤ p
+ p : c ∣ x ∣ −p ∣ p − p ∣ p + p ∣ p × p ∣ p ^ n
+
where :math:`c` is a numeric constant, :math:`x \in D` is a numeric variable, the
operators :math:`−, +, ×` are respectively subtraction, addition, and product;
:math:`p ^ n` is exponentiation by a constant :math:`n`, :math:`P` is an arbitrary proposition.
@@ -81,11 +81,11 @@ If :math:`-1` belongs to :math:`\mathit{Cone}(S)`, then the conjunction
A proof based on this theorem is called a *positivstellensatz*
refutation. The tactics work as follows. Formulas are normalized into
conjunctive normal form :math:`\bigwedge_i C_i` where :math:`C_i` has the
-general form :math:`(\bigwedge_{j\in S_i} p_j \Join 0) \to \mathit{False})` and
+general form :math:`(\bigwedge_{j\in S_i} p_j \Join 0) \to \mathit{False}` and
:math:`\Join \in \{>,\ge,=\}` for :math:`D\in \{\mathbb{Q},\mathbb{R}\}` and
:math:`\Join \in \{\ge, =\}` for :math:`\mathbb{Z}`.
-For each conjunct :math:`C_i`, the tactic calls a oracle which searches for
+For each conjunct :math:`C_i`, the tactic calls an oracle which searches for
:math:`-1` within the cone. Upon success, the oracle returns a *cone
expression* that is normalized by the ring tactic (see :ref:`theringandfieldtacticfamilies`)
and checked to be :math:`-1`.
diff --git a/doc/sphinx/addendum/miscellaneous-extensions.rst b/doc/sphinx/addendum/miscellaneous-extensions.rst
index b6c35d8fa7..0f2d35d044 100644
--- a/doc/sphinx/addendum/miscellaneous-extensions.rst
+++ b/doc/sphinx/addendum/miscellaneous-extensions.rst
@@ -32,6 +32,7 @@ When the proof ends two constants are defined:
ends with ``Qed``, and transparent if the proof ends with ``Defined``.
.. example::
+
.. coqtop:: all
Require Coq.derive.Derive.
diff --git a/doc/sphinx/addendum/nsatz.rst b/doc/sphinx/addendum/nsatz.rst
index 387d614956..9adeca46fc 100644
--- a/doc/sphinx/addendum/nsatz.rst
+++ b/doc/sphinx/addendum/nsatz.rst
@@ -1,63 +1,55 @@
.. include:: ../preamble.rst
-.. _nsatz:
+.. _nsatz_chapter:
Nsatz: tactics for proving equalities in integral domains
===========================================================
:Author: Loïc Pottier
-The tactic `nsatz` proves goals of the form
+.. tacn:: nsatz
+ :name: nsatz
-:math:`\begin{array}{l}
-\forall X_1,\ldots,X_n \in A,\\
-P_1(X_1,\ldots,X_n) = Q_1(X_1,\ldots,X_n) , \ldots , P_s(X_1,\ldots,X_n) =Q_s(X_1,\ldots,X_n)\\
-\vdash P(X_1,\ldots,X_n) = Q(X_1,\ldots,X_n)\\
-\end{array}`
+ This tactic is for solving goals of the form
-where :math:`P, Q, P₁,Q₁,\ldots,Pₛ, Qₛ` are polynomials and :math:`A` is an integral
-domain, i.e. a commutative ring with no zero divisor. For example, :math:`A`
-can be :math:`\mathbb{R}`, :math:`\mathbb{Z}`, or :math:`\mathbb{Q}`.
-Note that the equality :math:`=` used in these goals can be
-any setoid equality (see :ref:`tactics-enabled-on-user-provided-relations`) , not only Leibnitz equality.
+ :math:`\begin{array}{l}
+ \forall X_1, \ldots, X_n \in A, \\
+ P_1(X_1, \ldots, X_n) = Q_1(X_1, \ldots, X_n), \ldots, P_s(X_1, \ldots, X_n) = Q_s(X_1, \ldots, X_n) \\
+ \vdash P(X_1, \ldots, X_n) = Q(X_1, \ldots, X_n) \\
+ \end{array}`
-It also proves formulas
+ where :math:`P, Q, P_1, Q_1, \ldots, P_s, Q_s` are polynomials and :math:`A` is an integral
+ domain, i.e. a commutative ring with no zero divisors. For example, :math:`A`
+ can be :math:`\mathbb{R}`, :math:`\mathbb{Z}`, or :math:`\mathbb{Q}`.
+ Note that the equality :math:`=` used in these goals can be
+ any setoid equality (see :ref:`tactics-enabled-on-user-provided-relations`) , not only Leibniz equality.
-:math:`\begin{array}{l}
-\forall X_1,\ldots,X_n \in A,\\
-P_1(X_1,\ldots,X_n) = Q_1(X_1,\ldots,X_n) \wedge \ldots \wedge P_s(X_1,\ldots,X_n) =Q_s(X_1,\ldots,X_n)\\
-\rightarrow P(X_1,\ldots,X_n) = Q(X_1,\ldots,X_n)\\
-\end{array}`
+ It also proves formulas
-doing automatic introductions.
+ :math:`\begin{array}{l}
+ \forall X_1, \ldots, X_n \in A, \\
+ P_1(X_1, \ldots, X_n) = Q_1(X_1, \ldots, X_n) \wedge \ldots \wedge P_s(X_1, \ldots, X_n) = Q_s(X_1, \ldots, X_n) \\
+ \rightarrow P(X_1, \ldots, X_n) = Q(X_1, \ldots, X_n) \\
+ \end{array}`
+ doing automatic introductions.
-Using the basic tactic `nsatz`
-------------------------------
-
-
-Load the Nsatz module:
-
-.. coqtop:: all
-
- Require Import Nsatz.
-
-and use the tactic `nsatz`.
+ You can load the ``Nsatz`` module with the command ``Require Import Nsatz``.
More about `nsatz`
---------------------
Hilbert’s Nullstellensatz theorem shows how to reduce proofs of
-equalities on polynomials on a commutative ring :math:`A` with no zero divisor
+equalities on polynomials on a commutative ring :math:`A` with no zero divisors
to algebraic computations: it is easy to see that if a polynomial :math:`P` in
:math:`A[X_1,\ldots,X_n]` verifies :math:`c P^r = \sum_{i=1}^{s} S_i P_i`, with
:math:`c \in A`, :math:`c \not = 0`,
:math:`r` a positive integer, and the :math:`S_i` s in :math:`A[X_1,\ldots,X_n ]`,
then :math:`P` is zero whenever polynomials :math:`P_1,\ldots,P_s` are zero
-(the converse is also true when :math:`A` is an algebraic closed field: the method is
+(the converse is also true when :math:`A` is an algebraically closed field: the method is
complete).
-So, proving our initial problem can reduce into finding :math:`S_1,\ldots,S_s`,
+So, solving our initial problem reduces to finding :math:`S_1, \ldots, S_s`,
:math:`c` and :math:`r` such that :math:`c (P-Q)^r = \sum_{i} S_i (P_i-Q_i)`,
which will be proved by the tactic ring.
@@ -68,34 +60,31 @@ Buchberger algorithm.
This computation is done after a step of *reification*, which is
performed using :ref:`typeclasses`.
-The ``Nsatz`` module defines the tactic `nsatz`, which can be used without
-arguments, or with the syntax:
-
-| nsatz with radicalmax:=num%N strategy:=num%Z parameters:= :n:`{* var}` variables:= :n:`{* var}`
+.. tacv:: nsatz with radicalmax:=@num%N strategy:=@num%Z parameters:=[{*, @ident}] variables:=[{*, @ident}]
-where:
+ Most complete syntax for `nsatz`.
-* `radicalmax` is a bound when for searching r s.t.
- :math:`c (P−Q) r = \sum_{i=1..s} S_i (P i − Q i)`
+ * `radicalmax` is a bound when searching for r such that
+ :math:`c (P−Q) r = \sum_{i=1..s} S_i (P i − Q i)`
-* `strategy` gives the order on variables :math:`X_1,\ldots,X_n` and the strategy
- used in Buchberger algorithm (see :cite:`sugar` for details):
+ * `strategy` gives the order on variables :math:`X_1,\ldots,X_n` and the strategy
+ used in Buchberger algorithm (see :cite:`sugar` for details):
- * strategy = 0: reverse lexicographic order and newest s-polynomial.
- * strategy = 1: reverse lexicographic order and sugar strategy.
- * strategy = 2: pure lexicographic order and newest s-polynomial.
- * strategy = 3: pure lexicographic order and sugar strategy.
+ * strategy = 0: reverse lexicographic order and newest s-polynomial.
+ * strategy = 1: reverse lexicographic order and sugar strategy.
+ * strategy = 2: pure lexicographic order and newest s-polynomial.
+ * strategy = 3: pure lexicographic order and sugar strategy.
-* `parameters` is the list of variables :math:`X_{i_1},\ldots,X_{i_k}` among
- :math:`X_1,\ldots,X_n` which are considered as parameters: computation will be performed with
- rational fractions in these variables, i.e. polynomials are considered
- with coefficients in :math:`R(X_{i_1},\ldots,X_{i_k})`. In this case, the coefficient
- :math:`c` can be a non constant polynomial in :math:`X_{i_1},\ldots,X_{i_k}`, and the tactic
- produces a goal which states that :math:`c` is not zero.
+ * `parameters` is the list of variables :math:`X_{i_1},\ldots,X_{i_k}` among
+ :math:`X_1,\ldots,X_n` which are considered as parameters: computation will be performed with
+ rational fractions in these variables, i.e. polynomials are considered
+ with coefficients in :math:`R(X_{i_1},\ldots,X_{i_k})`. In this case, the coefficient
+ :math:`c` can be a non constant polynomial in :math:`X_{i_1},\ldots,X_{i_k}`, and the tactic
+ produces a goal which states that :math:`c` is not zero.
-* `variables` is the list of the variables in the decreasing order in
- which they will be used in Buchberger algorithm. If `variables` = `(@nil R)`,
- then `lvar` is replaced by all the variables which are not in
- `parameters`.
+ * `variables` is the list of the variables in the decreasing order in
+ which they will be used in the Buchberger algorithm. If `variables` = `(@nil R)`,
+ then `lvar` is replaced by all the variables which are not in
+ `parameters`.
-See file `Nsatz.v` for many examples, especially in geometry.
+See the file `Nsatz.v` for many examples, especially in geometry.
diff --git a/doc/sphinx/addendum/omega.rst b/doc/sphinx/addendum/omega.rst
index 80ce016200..1ed3bffd2c 100644
--- a/doc/sphinx/addendum/omega.rst
+++ b/doc/sphinx/addendum/omega.rst
@@ -8,23 +8,20 @@ Omega: a solver for quantifier-free problems in Presburger Arithmetic
Description of ``omega``
------------------------
-This tactic does not need any parameter:
-
.. tacn:: omega
-:tacn:`omega` solves a goal in Presburger arithmetic, i.e. a universally
-quantified formula made of equations and inequations. Equations may
-be specified either on the type ``nat`` of natural numbers or on
-the type ``Z`` of binary-encoded integer numbers. Formulas on
-``nat`` are automatically injected into ``Z``. The procedure
-may use any hypothesis of the current proof session to solve the goal.
+ :tacn:`omega` is a tactic for solving goals in Presburger arithmetic,
+ i.e. for proving formulas made of equations and inequations over the
+ type ``nat`` of natural numbers or the type ``Z`` of binary-encoded integers.
+ Formulas on ``nat`` are automatically injected into ``Z``. The procedure
+ may use any hypothesis of the current proof session to solve the goal.
-Multiplication is handled by :tacn:`omega` but only goals where at
-least one of the two multiplicands of products is a constant are
-solvable. This is the restriction meant by "Presburger arithmetic".
+ Multiplication is handled by :tacn:`omega` but only goals where at
+ least one of the two multiplicands of products is a constant are
+ solvable. This is the restriction meant by "Presburger arithmetic".
-If the tactic cannot solve the goal, it fails with an error message.
-In any case, the computation eventually stops.
+ If the tactic cannot solve the goal, it fails with an error message.
+ In any case, the computation eventually stops.
.. tacv:: romega
:name: romega
@@ -34,8 +31,7 @@ In any case, the computation eventually stops.
Arithmetical goals recognized by ``omega``
------------------------------------------
-:tacn:`omega` applied only to quantifier-free formulas built from the
-connectors::
+:tacn:`omega` applies only to quantifier-free formulas built from the connectives::
/\ \/ ~ ->
@@ -67,8 +63,8 @@ is generated:
universally quantified, try :tacn:`intros` first; if it contains
existentials quantifiers too, :tacn:`omega` is not strong enough to solve your
goal). This may happen also if your goal contains arithmetical
- operators unknown from :tacn:`omega`. Finally, your goal may be really
- wrong!
+ operators not recognized by :tacn:`omega`. Finally, your goal may be simply
+ not true!
.. exn:: omega: Not a quantifier-free goal.
@@ -145,10 +141,10 @@ Overview of the tactic
~~~~~~~~~~~~~~~~~~~~~~
* The goal is negated twice and the first negation is introduced as an hypothesis.
- * Hypothesis are decomposed in simple equations or inequations. Multiple
+ * Hypotheses are decomposed in simple equations or inequations. Multiple
goals may result from this phase.
* Equations and inequations over ``nat`` are translated over
- ``Z``, multiple goals may result from the translation of substraction.
+ ``Z``, multiple goals may result from the translation of subtraction.
* Equations and inequations are normalized.
* Goals are solved by the OMEGA decision procedure.
* The script of the solution is replayed.
@@ -158,16 +154,15 @@ Overview of the OMEGA decision procedure
The OMEGA decision procedure involved in the :tacn:`omega` tactic uses
a small subset of the decision procedure presented in :cite:`TheOmegaPaper`
-Here is an overview, look at the original paper for more information.
+Here is an overview, refer to the original paper for more information.
* Equations and inequations are normalized by division by the GCD of their
coefficients.
* Equations are eliminated, using the Banerjee test to get a coefficient
equal to one.
- * Note that each inequation defines a half space in the space of real value
- of the variables.
+ * Note that each inequation cuts the Euclidean space in half.
* Inequations are solved by projecting on the hyperspace
- defined by cancelling one of the variable. They are partitioned
+ defined by cancelling one of the variables. They are partitioned
according to the sign of the coefficient of the eliminated
variable. Pairs of inequations from different classes define a
new edge in the projection.
@@ -177,7 +172,7 @@ Here is an overview, look at the original paper for more information.
(success) or there is no more variable to eliminate (failure).
It may happen that there is a real solution and no integer one. The last
-steps of the Omega procedure (dark shadow) are not implemented, so the
+steps of the Omega procedure are not implemented, so the
decision procedure is only partial.
Bugs
diff --git a/doc/sphinx/addendum/parallel-proof-processing.rst b/doc/sphinx/addendum/parallel-proof-processing.rst
index edb8676a5b..8ee8f52227 100644
--- a/doc/sphinx/addendum/parallel-proof-processing.rst
+++ b/doc/sphinx/addendum/parallel-proof-processing.rst
@@ -68,7 +68,7 @@ to modify the proof script accordingly.
Proof blocks and error resilience
--------------------------------------
-|Coq| 8.6 introduced a mechanism for error resiliency: in interactive
+|Coq| 8.6 introduced a mechanism for error resilience: in interactive
mode |Coq| is able to completely check a document containing errors
instead of bailing out at the first failure.
@@ -92,14 +92,14 @@ Caveats
````````
When a vernacular command fails the subsequent error messages may be
-bogus, i.e. caused by the first error. Error resiliency for vernacular
+bogus, i.e. caused by the first error. Error resilience for vernacular
commands can be switched off by passing ``-async-proofs-command-error-resilience off``
to |CoqIDE|.
An incorrect proof block detection can result into an incorrect error
recovery and hence in bogus errors. Proof block detection cannot be
precise for bullets or any other non well parenthesized proof
-structure. Error resiliency can be turned off or selectively activated
+structure. Error resilience can be turned off or selectively activated
for any set of block kind passing to |CoqIDE| one of the following
options:
@@ -127,13 +127,14 @@ the very same button, that can also be used to see the list of errors
and jump to the corresponding line.
If a proof is processed asynchronously the corresponding Qed command
-is colored using a lighter color that usual. This signals that the
+is colored using a lighter color than usual. This signals that the
proof has been delegated to a worker process (or will be processed
lazily if the ``-async-proofs lazy`` option is used). Once finished, the
worker process will provide the proof object, but this will not be
automatically checked by the kernel of the main process. To force the
kernel to check all the proof objects, one has to click the button
-with the gears. Only then are all the universe constraints checked.
+with the gears (Fully check the document) on the top bar.
+Only then all the universe constraints are checked.
Caveats
```````
@@ -149,7 +150,7 @@ To disable this feature, one can pass the ``-async-proofs off`` flag to
default, pass the ``-async-proofs on`` flag to enable it.
Proofs that are known to take little time to process are not delegated
-to a worker process. The threshold can be configure with
+to a worker process. The threshold can be configured with
``-async-proofs-delegation-threshold``. Default is 0.03 seconds.
Batch mode
@@ -157,7 +158,7 @@ Batch mode
When |Coq| is used as a batch compiler by running `coqc` or `coqtop`
-compile, it produces a `.vo` file for each `.v` file. A `.vo` file contains,
-among other things, theorems statements and proofs. Hence to produce a
+among other things, theorem statements and proofs. Hence to produce a
.vo |Coq| need to process all the proofs of the `.v` file.
The asynchronous processing of proofs can decouple the generation of a
@@ -225,5 +226,5 @@ in all the shells from which |Coq| processes will be started. If one
uses just one terminal running the bash shell, then
``export ‘coqworkmgr -j 4‘`` will do the job.
-After that, all |Coq| processes, e.g. `coqide` and `coqc`, will honor the
+After that, all |Coq| processes, e.g. `coqide` and `coqc`, will respect the
limit, globally.
diff --git a/doc/sphinx/addendum/program.rst b/doc/sphinx/addendum/program.rst
index b685e68e43..28fe68d78d 100644
--- a/doc/sphinx/addendum/program.rst
+++ b/doc/sphinx/addendum/program.rst
@@ -38,12 +38,12 @@ obligations which need to be resolved to create the final term.
Elaborating programs
---------------------
-The main difference from |Coq| is that an object in a type T : Set can
-be considered as an object of type { x : T | P} for any wellformed P :
-Prop. If we go from T to the subset of T verifying property P, we must
-prove that the object under consideration verifies it. Russell will
-generate an obligation for every such coercion. In the other
-direction, Russell will automatically insert a projection.
+The main difference from |Coq| is that an object in a type :g:`T : Set` can
+be considered as an object of type :g:`{x : T | P}` for any well-formed
+:g:`P : Prop`. If we go from :g:`T` to the subset of :g:`T` verifying property
+:g:`P`, we must prove that the object under consideration verifies it. Russell
+will generate an obligation for every such coercion. In the other direction,
+Russell will automatically insert a projection.
Another distinction is the treatment of pattern-matching. Apart from
the following differences, it is equivalent to the standard match
@@ -67,7 +67,7 @@ operation (see :ref:`extendedpatternmatching`).
(match x as y return (x = y -> _) with
| 0 => fun H : x = 0 -> t
| S n => fun H : x = S n -> u
- end) (eq_refl n).
+ end) (eq_refl x).
This permits to get the proper equalities in the context of proof
obligations inside clauses, without which reasoning is very limited.
@@ -75,7 +75,7 @@ operation (see :ref:`extendedpatternmatching`).
+ Generation of inequalities. If a pattern intersects with a previous
one, an inequality is added in the context of the second branch. See
for example the definition of div2 below, where the second branch is
- typed in a context where ∀ p, _ <> S (S p).
+ typed in a context where :g:`∀ p, _ <> S (S p)`.
+ Coercion. If the object being matched is coercible to an inductive
type, the corresponding coercion will be automatically inserted. This
also works with the previous mechanism.
@@ -88,7 +88,7 @@ coercions.
This controls the special treatment of pattern-matching generating equalities
and inequalities when using |Program| (it is on by default). All
- pattern-matchings and let-patterns are handled using the standard algorithm
+ pattern-matches and let-patterns are handled using the standard algorithm
of |Coq| (see :ref:`extendedpatternmatching`) when this option is
deactivated.
@@ -108,9 +108,9 @@ typechecker will fall back directly to |Coq|’s usual typing of dependent
pattern-matching if a return or in clause is specified. Likewise, the
if construct is not treated specially by |Program| so boolean tests in
the code are not automatically reflected in the obligations. One can
-use the dec combinator to get the correct hypotheses as in:
+use the :g:`dec` combinator to get the correct hypotheses as in:
-.. coqtop:: none
+.. coqtop:: in
Require Import Program Arith.
@@ -120,7 +120,7 @@ use the dec combinator to get the correct hypotheses as in:
if dec (leb n 0) then 0
else S (pred n).
-The let tupling construct :g:`let (x1, ..., xn) := t in b` does not
+The :g:`let` tupling construct :g:`let (x1, ..., xn) := t in b` does not
produce an equality, contrary to the let pattern construct :g:`let ’(x1,
..., xn) := t in b`. Also, :g:`term :>` explicitly asks the system to
coerce term to its support type. It can be useful in notations, for
@@ -200,7 +200,7 @@ The structural fixpoint operator behaves just like the one of |Coq| (see
:cmd:`Fixpoint`), except it may also generate obligations. It works
with mutually recursive definitions too.
-.. coqtop:: reset none
+.. coqtop:: reset in
Require Import Program Arith.
@@ -264,7 +264,7 @@ Program Lemma
Definition` and use it as the goal afterwards. Otherwise the proof
will be started with the elaborated version as a goal. The
:g:`Program` prefix can similarly be used as a prefix for
- :g:`Variable`, :g:`Hypothesis`, :g:`Axiom` etc...
+ :g:`Variable`, :g:`Hypothesis`, :g:`Axiom` etc.
.. _solving_obligations:
@@ -300,7 +300,7 @@ optional tactic is replaced by the default one if not specified.
Start the proof of the next unsolved obligation.
-.. cmd:: Solve Obligations {? of @ident} {? with @tactic}
+.. cmd:: Solve Obligations {? {? of @ident} with @tactic}
Tries to solve each obligation of ``ident`` using the given ``tactic`` or the default one.
@@ -322,13 +322,13 @@ optional tactic is replaced by the default one if not specified.
.. opt:: Transparent Obligations
- Control whether all obligations should be declared as transparent
+ Controls whether all obligations should be declared as transparent
(the default), or if the system should infer which obligations can be
declared opaque.
.. opt:: Hide Obligations
- Control whether obligations appearing in the
+ Controls whether obligations appearing in the
term should be hidden as implicit arguments of the special
constantProgram.Tactics.obligation.
diff --git a/doc/sphinx/addendum/ring.rst b/doc/sphinx/addendum/ring.rst
index 6a9b343ba8..d5c33dc1d4 100644
--- a/doc/sphinx/addendum/ring.rst
+++ b/doc/sphinx/addendum/ring.rst
@@ -13,7 +13,7 @@ The ring and field tactic families
:Author: Bruno Barras, Benjamin Grégoire, Assia Mahboubi, Laurent Théry [#f1]_
-This chapter presents the tactics dedicated to deal with ring and
+This chapter presents the tactics dedicated to dealing with ring and
field equations.
What does this tactic do?
@@ -36,7 +36,7 @@ is strictly less than the following monomial according to the lexicographic
order. It is an easy theorem to show that every polynomial is equivalent (modulo
the ring properties) to exactly one canonical sum. This canonical sum is called
the normal form of the polynomial. In fact, the actual representation shares
-monomials with same prefixes. So what does ring? It normalizes polynomials over
+monomials with same prefixes. So what does the ``ring`` tactic do? It normalizes polynomials over
any ring or semi-ring structure. The basic use of ``ring`` is to simplify ring
expressions, so that the user does not have to deal manually with the theorems
of associativity and commutativity.
@@ -59,9 +59,8 @@ The variables map
It is frequent to have an expression built with :math:`+` and :math:`\times`,
but rarely on variables only. Let us associate a number to each subterm of a
-ring expression in the Gallina language. For example in the ring |nat|, consider
-the expression:
-
+ring expression in the Gallina language. For example, consider this expression
+in the semiring ``nat``:
::
@@ -104,7 +103,7 @@ Concrete usage in Coq
.. tacn:: ring
The ``ring`` tactic solves equations upon polynomial expressions of a ring
-(or semi-ring) structure. It proceeds by normalizing both hand sides
+(or semi-ring) structure. It proceeds by normalizing both sides
of the equation (w.r.t. associativity, commutativity and
distributivity, constant propagation, rewriting of monomials) and
comparing syntactically the results.
@@ -112,9 +111,9 @@ comparing syntactically the results.
.. tacn:: ring_simplify
``ring_simplify`` applies the normalization procedure described above to
-the terms given. The tactic then replaces all occurrences of the terms
+the given terms. The tactic then replaces all occurrences of the terms
given in the conclusion of the goal by their normal forms. If no term
-is given, then the conclusion should be an equation and both hand
+is given, then the conclusion should be an equation and both
sides are normalized. The tactic can also be applied in a hypothesis.
The tactic must be loaded by ``Require Import Ring``. The ring structures
@@ -187,7 +186,7 @@ Error messages:
.. exn:: Cannot find a declared ring structure for equality @term.
- Same as above is the case of the ``ring`` tactic.
+ Same as above in the case of the ``ring`` tactic.
Adding a ring structure
@@ -198,8 +197,8 @@ carrier set, an equality, and ring operations: ``Ring_theory.ring_theory``
and ``Ring_theory.semi_ring_theory``) satisfies the ring axioms. Semi-
rings (rings without + inverse) are also supported. The equality can
be either Leibniz equality, or any relation declared as a setoid (see
-:ref:`tactics-enabled-on-user-provided-relations`). The definition of ring and semi-rings (see module
-``Ring_theory``) is:
+:ref:`tactics-enabled-on-user-provided-relations`).
+The definitions of ring and semiring (see module ``Ring_theory``) are:
.. coqtop:: in
@@ -305,7 +304,7 @@ The syntax for adding a new ring is
.. cmd:: Add Ring @ident : @term {? ( @ring_mod {* , @ring_mod } )}
-The :n:`@ident` is not relevant. It is just used for error messages. The
+The :n:`@ident` is not relevant. It is used just for error messages. The
:n:`@term` is a proof that the ring signature satisfies the (semi-)ring
axioms. The optional list of modifiers is used to tailor the behavior
of the tactic. The following list describes their syntax and effects:
@@ -386,7 +385,7 @@ sign :n:`@term`
div :n:`@term`
allows ``ring`` and ``ring_simplify`` to use monomials with
- coefficient other than 1 in the rewriting. The term :n:`@term` is a proof
+ coefficients other than 1 in the rewriting. The term :n:`@term` is a proof
that a given division function satisfies the specification of an
euclidean division function (:n:`@term` has to be a proof of
``Ring_theory.div_theory``). For example, this function is called when
@@ -414,13 +413,13 @@ Error messages:
How does it work?
----------------------
-The code of ring is a good example of tactic written using *reflection*.
-What is reflection? Basically, it is writing |Coq| tactics in |Coq|, rather
-than in |OCaml|. From the philosophical point of view, it is
-using the ability of the Calculus of Constructions to speak and reason
-about itself. For the ring tactic we used Coq as a programming
-language and also as a proof environment to build a tactic and to
-prove it correctness.
+The code of ``ring`` is a good example of a tactic written using *reflection*.
+What is reflection? Basically, using it means that a part of a tactic is written
+in Gallina, Coq's language of terms, rather than |Ltac| or |OCaml|. From the
+philosophical point of view, reflection is using the ability of the Calculus of
+Constructions to speak and reason about itself. For the ``ring`` tactic we used
+Coq as a programming language and also as a proof environment to build a tactic
+and to prove its correctness.
The interested reader is strongly advised to have a look at the
file ``Ring_polynom.v``. Here a type for polynomials is defined:
@@ -452,7 +451,7 @@ Polynomials in normal form are defined as:
where ``Pinj n P`` denotes ``P`` in which :math:`V_i` is replaced by :math:`V_{i+n}` ,
and ``PX P n Q`` denotes :math:`P \otimes V_1^n \oplus Q'`, `Q'` being `Q` where :math:`V_i` is replaced by :math:`V_{i+1}`.
-Variables maps are represented by list of ring elements, and two
+Variable maps are represented by lists of ring elements, and two
interpretation functions, one that maps a variables map and a
polynomial to an element of the concrete ring, and the second one that
does the same for normal forms:
@@ -490,18 +489,18 @@ concrete expression `p’`, which is the concrete normal form of `p`. This is su
`p’` |la| |le|
========= ====== ====
-The user do not see the right part of the diagram. From outside, the
-tactic behaves like a |bdi| simplification extended with AC rewriting
-rules. Basically, the proof is only the application of the main
-correctness theorem to well-chosen arguments.
+The user does not see the right part of the diagram. From outside, the
+tactic behaves like a |bdi| simplification extended with rewriting rules
+for associativity and commutativity. Basically, the proof is only the
+application of the main correctness theorem to well-chosen arguments.
Dealing with fields
------------------------
.. tacn:: field
-The ``field`` tactic is an extension of the ``ring`` to deal with rational
-expression. Given a rational expression :math:`F = 0`. It first reduces the
+The ``field`` tactic is an extension of the ``ring`` tactic that deals with rational
+expressions. Given a rational expression :math:`F = 0`. It first reduces the
expression `F` to a common denominator :math:`N/D = 0` where `N` and `D`
are two ring expressions. For example, if we take :math:`F = (1 − 1/x) x − x + 1`, this
gives :math:`N = (x − 1) x − x^2 + x` and :math:`D = x`. It then calls ring to solve
@@ -523,7 +522,7 @@ structures can be declared to the system with the ``Add Field`` command
(in ``plugins/setoid_ring``). It is exported by module ``Rbase``, so
that requiring ``Rbase`` or ``Reals`` is enough to use the field tactics on
real numbers. Rational numbers in canonical form are also declared as
-a field in module ``Qcanon``.
+a field in the module ``Qcanon``.
.. example::
@@ -559,8 +558,8 @@ a field in module ``Qcanon``.
performs the simplification in the conclusion of the
goal, :math:`F_1 = F_2` becomes :math:`N_1 / D_1 = N_2 / D_2`. A normalization step
(the same as the one for rings) is then applied to :math:`N_1`, :math:`D_1`,
- :math:`N_2` and :math:`D_2`. This way, polynomials remain in factorized form during the
- fraction simplifications. This yields smaller expressions when
+ :math:`N_2` and :math:`D_2`. This way, polynomials remain in factorized form during
+ fraction simplification. This yields smaller expressions when
reducing to the same denominator since common factors can be canceled.
.. tacv:: field_simplify [{* @term }]
@@ -657,7 +656,7 @@ The syntax for adding a new field is
.. cmd:: Add Field @ident : @term {? ( @field_mod {* , @field_mod } )}
-The :n:`@ident` is not relevant. It is just used for error
+The :n:`@ident` is not relevant. It is used just for error
messages. :n:`@term` is a proof that the field signature satisfies the
(semi-)field axioms. The optional list of modifiers is used to tailor
the behavior of the tactic.
@@ -704,9 +703,8 @@ it using reflection (see :cite:`Bou97`). Later, it
was rewritten by Patrick Loiseleur: the new tactic does not any
more require ``ACDSimpl`` to compile and it makes use of |bdi|-reduction not
only to replace the rewriting steps, but also to achieve the
-interleaving of computation and reasoning (see :ref:`discussion_reflection`). He also wrote a
-few |ML| code for the ``Add Ring`` command, that allow to register new rings
-dynamically.
+interleaving of computation and reasoning (see :ref:`discussion_reflection`). He also wrote
+some |ML| code for the ``Add Ring`` command that allows registering new rings dynamically.
Proofs terms generated by ring are quite small, they are linear in the
number of :math:`\oplus` and :math:`\otimes` operations in the normalized terms. Type-checking
@@ -733,15 +731,15 @@ Then it is rewritten to ``34 − x + 2 * x + 12``, very far from the expected re
Here rewriting is not sufficient: you have to do some kind of reduction
(some kind of computation) to achieve the normalization.
-The tactic ``ring`` is not only faster than a classical one: using
-reflection, we get for free integration of computation and reasoning
-that would be very complex to implement in the classic fashion.
+The tactic ``ring`` is not only faster than the old one: by using
+reflection, we get for free the integration of computation and reasoning
+that would be very difficult to implement without it.
Is it the ultimate way to write tactics? The answer is: yes and no.
-The ``ring`` tactic uses intensively the conversion rule of |Cic|, that is
-replaces proof by computation the most as it is possible. It can be
-useful in all situations where a classical tactic generates huge proof
-terms. Symbolic Processing and Tautologies are in that case. But there
+The ``ring`` tactic intensively uses the conversion rules of the Calculus of
+Inductive Constructions, i.e. it replaces proofs by computations as much as possible.
+It can be useful in all situations where a classical tactic generates huge proof
+terms, like symbolic processing and tautologies. But there
are also tactics like ``auto`` or ``linear`` that do many complex computations,
using side-effects and backtracking, and generate a small proof term.
Clearly, it would be significantly less efficient to replace them by
@@ -750,12 +748,12 @@ tactics using reflection.
Another idea suggested by Benjamin Werner: reflection could be used to
couple an external tool (a rewriting program or a model checker)
with |Coq|. We define (in |Coq|) a type of terms, a type of *traces*, and
-prove a correction theorem that states that *replaying traces* is safe
-w.r.t some interpretation. Then we let the external tool do every
+prove a correctness theorem that states that *replaying traces* is safe
+with respect to some interpretation. Then we let the external tool do every
computation (using side-effects, backtracking, exception, or others
features that are not available in pure lambda calculus) to produce
-the trace: now we can check in |Coq| that the trace has the expected
-semantic by applying the correction lemma.
+the trace. Now we can check in |Coq| that the trace has the expected
+semantics by applying the correctness theorem.
diff --git a/doc/sphinx/addendum/type-classes.rst b/doc/sphinx/addendum/type-classes.rst
index 68b5b9d6fe..b7946c6451 100644
--- a/doc/sphinx/addendum/type-classes.rst
+++ b/doc/sphinx/addendum/type-classes.rst
@@ -120,7 +120,7 @@ Following the previous example, one can write:
Generalizable Variables A B C.
- Definition neqb_impl `{eqa : EqDec A} (x y : A) := negb (eqb x y).
+ Definition neqb_implicit `{eqa : EqDec A} (x y : A) := negb (eqb x y).
Here ``A`` is implicitly generalized, and the resulting function is
equivalent to the one above.
@@ -193,7 +193,7 @@ superclasses as a binding context:
Class Ord `(E : EqDec A) := { le : A -> A -> bool }.
Contrary to Haskell, we have no special syntax for superclasses, but
-this declaration is morally equivalent to:
+this declaration is equivalent to:
::
@@ -248,7 +248,7 @@ properties, e.g.:
This declares singleton classes for reflexive and transitive relations,
(see the :ref:`singleton class <singleton-class>` variant for an
-explanation). These may be used as part of other classes:
+explanation). These may be used as parts of other classes:
.. coqtop:: all
@@ -346,7 +346,7 @@ few other commands related to type classes.
.. cmd:: Existing Instance {+ @ident} [| priority]
- This commands adds an arbitrary list of constants whose type ends with
+ This command adds an arbitrary list of constants whose type ends with
an applied type class to the instance database with an optional
priority. It can be used for redeclaring instances at the end of
sections, or declaring structure projections as instances. This is
@@ -387,14 +387,14 @@ few other commands related to type classes.
+ When called with specific databases (e.g. with), typeclasses eauto
allows shelved goals to remain at any point during search and treat
- typeclasses goals like any other.
+ typeclass goals like any other.
+ The transparency information of databases is used consistently for
all hints declared in them. It is always used when calling the
- unifier. When considering the local hypotheses, we use the transparent
+ unifier. When considering local hypotheses, we use the transparent
state of the first hint database given. Using an empty database
(created with :cmd:`Create HintDb` for example) with unfoldable variables and
- constants as the first argument of typeclasses eauto hence makes
+ constants as the first argument of ``typeclasses eauto`` hence makes
resolution with the local hypotheses use full conversion during
unification.
@@ -461,8 +461,8 @@ Options
.. opt:: Typeclasses Dependency Order
This option (on by default since 8.6) respects the dependency order
- between subgoals, meaning that subgoals which are depended on by other
- subgoals come first, while the non-dependent subgoals were put before
+ between subgoals, meaning that subgoals on which other subgoals depend
+ come first, while the non-dependent subgoals were put before
the dependent ones previously (Coq 8.5 and below). This can result in
quite different performance behaviors of proof search.
diff --git a/doc/sphinx/addendum/universe-polymorphism.rst b/doc/sphinx/addendum/universe-polymorphism.rst
index 6e7ccba63c..f245fab5ca 100644
--- a/doc/sphinx/addendum/universe-polymorphism.rst
+++ b/doc/sphinx/addendum/universe-polymorphism.rst
@@ -72,7 +72,7 @@ different. This can be seen when the :opt:`Printing Universes` option is on:
Now :g:`pidentity` is used at two different levels: at the head of the
application it is instantiated at ``Top.3`` while in the argument position
it is instantiated at ``Top.4``. This definition is only valid as long as
-``Top.4`` is strictly smaller than ``Top.3``, as show by the constraints. Note
+``Top.4`` is strictly smaller than ``Top.3``, as shown by the constraints. Note
that this definition is monomorphic (not universe polymorphic), so the
two universes (in this case ``Top.3`` and ``Top.4``) are actually global
levels.
diff --git a/doc/sphinx/biblio.bib b/doc/sphinx/biblio.bib
index 3574bf6750..9cfcd7ae64 100644
--- a/doc/sphinx/biblio.bib
+++ b/doc/sphinx/biblio.bib
@@ -1,7 +1,7 @@
@String{jfp = "Journal of Functional Programming"}
@String{lncs = "Lecture Notes in Computer Science"}
@String{lnai = "Lecture Notes in Artificial Intelligence"}
-@String{SV = "{Sprin-ger-Verlag}"}
+@String{SV = "{Springer-Verlag}"}
@InCollection{Asp00,
Title = {Proof General: A Generic Tool for Proof Development},
@@ -258,7 +258,7 @@ s},
@InProceedings{Luttik97specificationof,
author = {Sebastiaan P. Luttik and Eelco Visser},
booktitle = {2nd International Workshop on the Theory and Practice of Algebraic Specifications (ASF+SDF'97), Electronic Workshops in Computing},
- publisher = {Springer-Verlag},
+ publisher = SV,
title = {Specification of Rewriting Strategies},
year = {1997}
}
diff --git a/doc/sphinx/language/cic.rst b/doc/sphinx/language/cic.rst
index 721dc80b18..a63400103f 100644
--- a/doc/sphinx/language/cic.rst
+++ b/doc/sphinx/language/cic.rst
@@ -723,6 +723,7 @@ each :math:`T` in :math:`(t:T)∈Γ_I` can be written as: :math:`∀Γ_P,∀Γ_{
the sort of the inductive type t (not to be confused with :math:`\Sort` which is the set of sorts).
.. example::
+
The declaration for parameterized lists is:
.. math::
@@ -741,6 +742,7 @@ the sort of the inductive type t (not to be confused with :math:`\Sort` which is
| cons : A -> list A -> list A.
.. example::
+
The declaration for a mutual inductive definition of tree and forest
is:
@@ -763,6 +765,7 @@ the sort of the inductive type t (not to be confused with :math:`\Sort` which is
| consf : tree -> forest -> forest.
.. example::
+
The declaration for a mutual inductive definition of even and odd is:
.. math::
@@ -811,6 +814,7 @@ contains an inductive declaration.
E[Γ] ⊢ c : C
.. example::
+
Provided that our environment :math:`E` contains inductive definitions we showed before,
these two inference rules above enable us to conclude that:
@@ -919,6 +923,7 @@ condition* for a constant :math:`X` in the following cases:
.. example::
+
For instance, if one considers the following variant of a tree type
branching over the natural numbers:
@@ -985,6 +990,7 @@ the Type hierarchy.
.. example::
+
It is well known that the existential quantifier can be encoded as an
inductive definition. The following declaration introduces the second-
order existential quantifier :math:`∃ X.P(X)`.
@@ -1102,6 +1108,7 @@ sorts at each instance of a pattern-matching (see Section :ref:`Destructors`). A
an example, let us consider the following definition:
.. example::
+
.. coqtop:: in
Inductive option (A:Type) : Type :=
@@ -1118,6 +1125,7 @@ if :g:`option` is applied to a type in :math:`\Prop`, then, the result is not se
if set in :math:`\Prop`.
.. example::
+
.. coqtop:: all
Check (fun A:Set => option A).
@@ -1126,6 +1134,7 @@ if set in :math:`\Prop`.
Here is another example.
.. example::
+
.. coqtop:: in
Inductive prod (A B:Type) : Type := pair : A -> B -> prod A B.
@@ -1136,6 +1145,7 @@ none in :math:`\Type`, and in :math:`\Type` otherwise. In all cases, the three k
eliminations schemes are allowed.
.. example::
+
.. coqtop:: all
Check (fun A:Set => prod A).
@@ -1324,6 +1334,7 @@ the extraction mechanism. Assume :math:`A` and :math:`B` are two propositions, a
logical disjunction :math:`A ∨ B` is defined inductively by:
.. example::
+
.. coqtop:: in
Inductive or (A B:Prop) : Prop :=
@@ -1334,6 +1345,7 @@ The following definition which computes a boolean value by case over
the proof of :g:`or A B` is not accepted:
.. example::
+
.. coqtop:: all
Fail Definition choice (A B: Prop) (x:or A B) :=
@@ -1357,6 +1369,7 @@ property which are provably different, contradicting the proof-
irrelevance property which is sometimes a useful axiom:
.. example::
+
.. coqtop:: all
Axiom proof_irrelevance : forall (P : Prop) (x y : P), x=y.
@@ -1390,6 +1403,7 @@ be used for rewriting not only in logical propositions but also in any
type.
.. example::
+
.. coqtop:: all
Print eq_rec.
@@ -1421,6 +1435,7 @@ We write :math:`\{c\}^P` for :math:`\{c:C\}^P` with :math:`C` the type of :math:
.. example::
+
The following term in concrete syntax::
match t as l return P' with
@@ -1485,6 +1500,7 @@ definition :math:`\ind{r}{Γ_I}{Γ_C}` with :math:`Γ_C = [c_1 :C_1 ;…;c_n :C_
.. example::
+
Below is a typing rule for the term shown in the previous example:
.. inference:: list example
@@ -1634,6 +1650,7 @@ The following definitions are correct, we enter them using the :cmd:`Fixpoint`
command and show the internal representation.
.. example::
+
.. coqtop:: all
Fixpoint plus (n m:nat) {struct n} : nat :=
@@ -1810,6 +1827,7 @@ option ``-impredicative-set``. For example, using the ordinary `coqtop`
command, the following is rejected,
.. example::
+
.. coqtop:: all
Fail Definition id: Set := forall X:Set,X->X.
diff --git a/doc/sphinx/language/coq-library.rst b/doc/sphinx/language/coq-library.rst
index 52c56d2bd2..9de30e2190 100644
--- a/doc/sphinx/language/coq-library.rst
+++ b/doc/sphinx/language/coq-library.rst
@@ -848,6 +848,7 @@ Notation Interpretation Precedence Associativity
.. example::
+
.. coqtop:: all reset
Require Import ZArith.
@@ -887,6 +888,7 @@ Notation Interpretation
=============== ===================
.. example::
+
.. coqtop:: all reset
Require Import Reals.
@@ -906,6 +908,7 @@ tactics (see Chapter :ref:`tactics`), there are also:
Proves that two real integer constants are different.
.. example::
+
.. coqtop:: all reset
Require Import DiscrR.
@@ -919,6 +922,7 @@ tactics (see Chapter :ref:`tactics`), there are also:
Allows unfolding the ``Rabs`` constant and splits corresponding conjunctions.
.. example::
+
.. coqtop:: all reset
Require Import Reals.
@@ -933,6 +937,7 @@ tactics (see Chapter :ref:`tactics`), there are also:
corresponding to the condition on each operand of the product.
.. example::
+
.. coqtop:: all reset
Require Import Reals.
diff --git a/doc/sphinx/language/gallina-extensions.rst b/doc/sphinx/language/gallina-extensions.rst
index d9b2490452..7dd0a6e383 100644
--- a/doc/sphinx/language/gallina-extensions.rst
+++ b/doc/sphinx/language/gallina-extensions.rst
@@ -70,7 +70,9 @@ generates a variant type definition with just one constructor:
To build an object of type :n:`@ident`, one should provide the constructor
:n:`@ident₀` with the appropriate number of terms filling the fields of the record.
-.. example:: Let us define the rational :math:`1/2`:
+.. example::
+
+ Let us define the rational :math:`1/2`:
.. coqtop:: in
@@ -781,7 +783,8 @@ Section :ref:`gallina-definitions`).
.. cmd:: Section @ident
- This command is used to open a section named `ident`.
+ This command is used to open a section named :token:`ident`.
+ Section names do not need to be unique.
.. cmd:: End @ident
@@ -1848,15 +1851,15 @@ are named as expected.
.. example:: (continued)
-.. coqtop:: all
+ .. coqtop:: all
- Arguments p [s t] _ [u] _: rename.
+ Arguments p [s t] _ [u] _: rename.
- Check (p r1 (u:=c)).
+ Check (p r1 (u:=c)).
- Check (p (s:=a) (t:=b) r1 (u:=c) r2).
+ Check (p (s:=a) (t:=b) r1 (u:=c) r2).
- Fail Arguments p [s t] _ [w] _ : assert.
+ Fail Arguments p [s t] _ [w] _ : assert.
.. _displaying-implicit-args:
diff --git a/doc/sphinx/language/gallina-specification-language.rst b/doc/sphinx/language/gallina-specification-language.rst
index 8250b4b3d6..da5cd00d72 100644
--- a/doc/sphinx/language/gallina-specification-language.rst
+++ b/doc/sphinx/language/gallina-specification-language.rst
@@ -758,6 +758,7 @@ Simple inductive types
the case of annotated inductive types — cf. next section).
.. example::
+
The set of natural numbers is defined as:
.. coqtop:: all
@@ -976,6 +977,7 @@ Mutually defined inductive types
reason, the parameters must be strictly the same for each inductive types.
.. example::
+
The typical example of a mutual inductive data type is the one for trees and
forests. We assume given two types :g:`A` and :g:`B` as variables. It can
be declared the following way.
@@ -1048,6 +1050,7 @@ of the type.
For co-inductive types, the only elimination principle is case analysis.
.. example::
+
An example of a co-inductive type is the type of infinite sequences of
natural numbers, usually called streams.
@@ -1067,6 +1070,7 @@ Definition of co-inductive predicates and blocks of mutually
co-inductive definitions are also allowed.
.. example::
+
An example of a co-inductive predicate is the extensional equality on
streams:
@@ -1129,6 +1133,7 @@ constructions.
.. example::
+
One can define the addition function as :
.. coqtop:: all
@@ -1201,6 +1206,7 @@ constructions.
inductive types.
.. example::
+
The size of trees and forests can be defined the following way:
.. coqtop:: all
diff --git a/doc/sphinx/practical-tools/coq-commands.rst b/doc/sphinx/practical-tools/coq-commands.rst
index ad1f0caa60..0f51b3eba3 100644
--- a/doc/sphinx/practical-tools/coq-commands.rst
+++ b/doc/sphinx/practical-tools/coq-commands.rst
@@ -25,7 +25,7 @@ In the interactive mode, also known as the |Coq| toplevel, the user can
develop his theories and proofs step by step. The |Coq| toplevel is run
by the command ``coqtop``.
-They are two different binary images of |Coq|: the byte-code one and the
+There are two different binary images of |Coq|: the byte-code one and the
native-code one (if OCaml provides a native-code compiler for
your platform, which is supposed in the following). By default,
``coqtop`` executes the native-code version; run ``coqtop.byte`` to get
@@ -43,10 +43,11 @@ The ``coqc`` command takes a name *file* as argument. Then it looks for a
vernacular file named *file*.v, and tries to compile it into a
*file*.vo file (See :ref:`compiled-files`).
-.. caution:: The name *file* should be a
- regular |Coq| identifier, as defined in Section :ref:'TODO-1.1'. It should contain
- only letters, digits or underscores (_). For instance, ``/bar/foo/toto.v`` is valid, but
- ``/bar/foo/to-to.v`` is invalid.
+.. caution::
+
+ The name *file* should be a regular |Coq| identifier as defined in Section :ref:`lexical-conventions`.
+ It should contain only letters, digits or underscores (_). For example ``/bar/foo/toto.v`` is valid,
+ but ``/bar/foo/to-to.v`` is not.
Customization at launch time
@@ -59,8 +60,8 @@ When |Coq| is launched, with either ``coqtop`` or ``coqc``, the
resource file ``$XDG_CONFIG_HOME/coq/coqrc.xxx``, if it exists, will
be implicitly prepended to any document read by Coq, whether it is an
interactive session or a file to compile. Here, ``$XDG_CONFIG_HOME``
-is the configuration directory of the user (by default its home
-directory ``~/.config``) and ``xxx`` is the version number (e.g. 8.8). If
+is the configuration directory of the user (by default it's ``~/.config``)
+and ``xxx`` is the version number (e.g. 8.8). If
this file is not found, then the file ``$XDG_CONFIG_HOME/coqrc`` is
searched. If not found, it is the file ``~/.coqrc.xxx`` which is searched,
and, if still not found, the file ``~/.coqrc``. If the latter is also
@@ -140,15 +141,15 @@ and ``coqtop``, unless stated otherwise:
:-l *file*, -load-vernac-source *file*: Load and execute the |Coq|
script from *file.v*.
:-lv *file*, -load-vernac-source-verbose *file*: Load and execute the
- |Coq| script from *file.v*. Output its content on the standard input as
+ |Coq| script from *file.v*. Write its contents to the standard output as
it is executed.
:-load-vernac-object dirpath: Load |Coq| compiled library dirpath. This
is equivalent to runningRequire dirpath.
:-require dirpath: Load |Coq| compiled library dirpath and import it.
This is equivalent to running Require Import dirpath.
:-batch: Exit just after argument parsing. Available for `coqtop` only.
-:-compile *file.v*: Compile file *file.v* into *file.vo*. This options
- imply -batch (exit just after argument parsing). It is available only
+:-compile *file.v*: Compile file *file.v* into *file.vo*. This option
+ implies -batch (exit just after argument parsing). It is available only
for `coqtop`, as this behavior is the purpose of `coqc`.
:-compile-verbose *file.v*: Same as -compile but also output the
content of *file.v* as it is compiled.
@@ -237,7 +238,7 @@ relative paths in object files ``-Q`` and ``-R`` have exactly the same meaning.
unless explicitly required.
:-o: At exit, print a summary about the context. List the names of all
assumptions and variables (constants without body).
-:-silent: Do not write progress information in standard output.
+:-silent: Do not write progress information to the standard output.
Environment variable ``$COQLIB`` can be set to override the location of
the standard library.
@@ -253,7 +254,7 @@ set of reflexive transitive dependencies of set :math:`S`. Then:
context without type-checking. Basic integrity checks (checksums) are
nonetheless performed.
-As a rule of thumb, the -admit can be used to tell that some libraries
+As a rule of thumb, -admit can be used to tell Coq that some libraries
have already been checked. So ``coqchk A B`` can be split in ``coqchk A`` &&
``coqchk B -admit A`` without type-checking any definition twice. Of
course, the latter is slightly slower since it makes more disk access.
diff --git a/doc/sphinx/practical-tools/coqide.rst b/doc/sphinx/practical-tools/coqide.rst
index f9903e6104..f7f442092f 100644
--- a/doc/sphinx/practical-tools/coqide.rst
+++ b/doc/sphinx/practical-tools/coqide.rst
@@ -27,7 +27,7 @@ is shown in the figure :ref:`CoqIDE main screen <coqide_mainscreen>`.
At the top is a menu bar, and a tool bar
below it. The large window on the left is displaying the various
*script buffers*. The upper right window is the *goal window*, where
-goals to prove are displayed. The lower right window is the *message
+goals to be proven are displayed. The lower right window is the *message
window*, where various messages resulting from commands are displayed.
At the bottom is the status bar.
@@ -62,8 +62,8 @@ In the figure :ref:`CoqIDE main screen <coqide_mainscreen>`,
the running buffer is `Fermat.v`, all commands until
the ``Theorem`` have been already executed, and the user tried to go
forward executing ``Induction n``. That command failed because no such
-tactic exists (tactics are now in lowercase…), and the wrong word is
-underlined.
+tactic exists (names of standard tactics are written in lowercase),
+and the failing command is underlined.
Notice that the processed part of the running buffer is not editable. If
you ever want to modify something you have to go backward using the up
@@ -82,8 +82,8 @@ background in the error background color (pink by default). The same
characterization of error-handling applies when running several commands using
the "goto" button.
-If you ever try to execute a command which happens to run during a
-long time, and would like to abort it before its termination, you may
+If you ever try to execute a command that runs for a long time
+and would like to abort it before it terminates, you may
use the interrupt button (the white cross on a red circle).
There are other buttons on the |CoqIDE| toolbar: a button to save the running
@@ -141,11 +141,10 @@ Vernacular commands, templates
The Templates menu allows using shortcuts to insert vernacular
commands. This is a nice way to proceed if you are not sure of the
-spelling of the command you want.
+syntax of the command you want.
-Moreover, this menu offers some *templates* which will automatic
-insert a complex command like ``Fixpoint`` with a convenient shape for its
-arguments.
+Moreover, from this menu you can automatically insert templates of complex
+commands like ``Fixpoint`` that you can conveniently fill afterwards.
Queries
------------
@@ -177,7 +176,7 @@ The `Compile` menu offers direct commands to:
Customizations
-------------------
-You may customize your environment using menu Edit/Preferences. A new
+You may customize your environment using the menu Edit/Preferences. A new
window will be displayed, with several customization sections
presented as a notebook.
@@ -189,7 +188,7 @@ automatic saving of files, by periodically saving the contents into
files named `#f#` for each opened file `f`. You may also activate the
*revert* feature: in case a opened file is modified on the disk by a
third party, |CoqIDE| may read it again for you. Note that in the case
-you edited that same file, you will be prompt to choose to either
+you edited that same file, you will be prompted to choose to either
discard your changes or not. The File charset encoding choice is
described below in :ref:`character-encoding-saved-files`.
@@ -209,7 +208,7 @@ Notice that these settings are saved in the file `.coqiderc` of your
home directory.
A Gtk2 accelerator keymap is saved under the name `.coqide.keys`. It
-is not recommanded to edit this file manually: to modify a given menu
+is not recommended to edit this file manually: to modify a given menu
shortcut, go to the corresponding menu item without releasing the
mouse button, press the key you want for the new shortcut, and release
the mouse button afterwards. If your system does not allow it, you may
@@ -240,14 +239,14 @@ mathematical symbols ∀ and ∃, you may define:
There exists a small set of such notations already defined, in the
file `utf8.v` of Coq library, so you may enable them just by
-``Require utf8`` inside |CoqIDE|, or equivalently, by starting |CoqIDE| with
-``coqide -l utf8``.
+``Require Import Unicode.Utf8`` inside |CoqIDE|, or equivalently,
+by starting |CoqIDE| with ``coqide -l utf8``.
However, there are some issues when using such Unicode symbols: you of
course need to use a character font which supports them. In the Fonts
section of the preferences, the Preview line displays some Unicode
symbols, so you could figure out if the selected font is OK. Related
-to this, one thing you may need to do is choose whether GTK+ should
+to this, one thing you may need to do is choosing whether GTK+ should
use antialiased fonts or not, by setting the environment variable
`GDK_USE_XFT` to 1 or 0 respectively.
diff --git a/doc/sphinx/practical-tools/utilities.rst b/doc/sphinx/practical-tools/utilities.rst
index bdaa2aa1a2..e779515a00 100644
--- a/doc/sphinx/practical-tools/utilities.rst
+++ b/doc/sphinx/practical-tools/utilities.rst
@@ -218,6 +218,7 @@ file timing data:
On ``Mac OS``, this works best if you’ve installed ``gnu-time``.
.. example::
+
For example, the output of ``make TIMED=1`` may look like
this:
@@ -295,6 +296,7 @@ file timing data:
files which take effectively no time to compile.
.. example::
+
For example, the output table from
``make print-pretty-timed-diff`` may look like this:
@@ -318,6 +320,7 @@ line timing data:
line-by-line timing information.
.. example::
+
For example, running ``make all TIMING=1`` may result in a file like this:
::
@@ -345,6 +348,7 @@ line timing data:
This target requires python to build the table.
.. example::
+
For example, running ``print-pretty-single-time-diff`` might give a table like this:
::
@@ -434,7 +438,7 @@ To build, say, two targets foo.vo and bar.vo in parallel one can use
For users of coq_makefile with version < 8.7
- + Support for “sub-directory” is deprecated. To perform actions before
+ + Support for "subdirectory" is deprecated. To perform actions before
or after the build (like invoking ``make`` on a subdirectory) one can hook
in pre-all and post-all extension points.
+ ``-extra-phony`` and ``-extra`` are deprecated. To provide additional target
@@ -442,10 +446,10 @@ To build, say, two targets foo.vo and bar.vo in parallel one can use
-Modules dependencies
+Module dependencies
--------------------
-In order to compute modules dependencies (so to use ``make``), |Coq| comes
+In order to compute module dependencies (so to use ``make``), |Coq| comes
with an appropriate tool, ``coqdep``.
``coqdep`` computes inter-module dependencies for |Coq| and |OCaml|
@@ -460,7 +464,7 @@ command ``Declare ML Module``.
Dependencies of |OCaml| modules are computed by looking at
`open` commands and the dot notation *module.value*. However, this is
done approximately and you are advised to use ``ocamldep`` instead for the
-|OCaml| modules dependencies.
+|OCaml| module dependencies.
See the man page of ``coqdep`` for more details and options.
@@ -478,9 +482,9 @@ coqdoc is a documentation tool for the proof assistant |Coq|, similar to
``javadoc`` or ``ocamldoc``. The task of coqdoc is
-#. to produce a nice |Latex| and/or HTML document from the |Coq|
- sources, readable for a human and not only for the proof assistant;
-#. to help the user navigating in his own (or third-party) sources.
+#. to produce a nice |Latex| and/or HTML document from |Coq| source files,
+ readable for a human and not only for the proof assistant;
+#. to help the user navigate his own (or third-party) sources.
@@ -491,7 +495,7 @@ Documentation is inserted into |Coq| files as *special comments*. Thus
your files will compile as usual, whether you use coqdoc or not. coqdoc
presupposes that the given |Coq| files are well-formed (at least
lexically). Documentation starts with ``(**``, followed by a space, and
-ends with the pending ``*)``. The documentation format is inspired by Todd
+ends with ``*)``. The documentation format is inspired by Todd
A. Coram’s *Almost Free Text (AFT)* tool: it is mainly ``ASCII`` text with
some syntax-light controls, described below. coqdoc is robust: it
shouldn’t fail, whatever the input is. But remember: “garbage in,
@@ -507,7 +511,7 @@ quoted code (thus you can quote a term like ``fun x => u`` by writing ``[fun
x => u]``). Inside quotations, the code is pretty-printed in the same
way as it is in code parts.
-Pre-formatted vernacular is enclosed by ``[[`` and ``]]``. The former must be
+Preformatted vernacular is enclosed by ``[[`` and ``]]``. The former must be
followed by a newline and the latter must follow a newline.
@@ -533,7 +537,7 @@ or
It gives the |Latex| and HTML texts to be produced for the given |Coq|
-token. One of the |Latex| or HTML text may be omitted, causing the
+token. Either the |Latex| or the HTML rule may be omitted, causing the
default pretty-printing to be used for this token.
The printing for one token can be removed with
@@ -546,12 +550,12 @@ The printing for one token can be removed with
Initially, the pretty-printing table contains the following mapping:
-==== === ==== ===== === ==== ==== ===
-`->` → `<-` ← `*` ×
-`<=` ≤ `>=` ≥ `=>` ⇒
-`<>` ≠ `<->` ↔ `|-` ⊢
-`\/` ∨ `/\\` ∧ `~` ¬
-==== === ==== ===== === ==== ==== ===
+===== === ==== ===== === ==== ==== ===
+`->` → `<-` ← `*` ×
+`<=` ≤ `>=` ≥ `=>` ⇒
+`<>` ≠ `<->` ↔ `|-` ⊢
+`\\/` ∨ `/\\` ∧ `~` ¬
+===== === ==== ===== === ==== ==== ===
Any of these can be overwritten or suppressed using the printing
commands.
@@ -573,10 +577,9 @@ commands.
Sections
++++++++
-Sections are introduced by 1 to 4 leading stars (i.e. at the beginning
-of the line) followed by a space. One star is a section, two stars a
-sub-section, etc. The section title is given on the remaining of the
-line.
+Sections are introduced by 1 to 4 asterisks at the beginning of a line
+followed by a space and the title of the section. One asterisk is a section,
+two a subsection, etc.
.. example::
@@ -624,7 +627,7 @@ More than 4 leading dashes produce a horizontal rule.
Emphasis.
+++++++++
-Text can be italicized by placing it in underscores. A non-identifier
+Text can be italicized by enclosing it in underscores. A non-identifier
character must precede the leading underscore and follow the trailing
underscore, so that uses of underscores in names aren’t mistaken for
emphasis. Usually, these are spaces or punctuation.
@@ -679,16 +682,16 @@ Hyperlinks can be inserted into the HTML output, so that any
identifier is linked to the place of its definition.
``coqc file.v`` automatically dumps localization information in
-``file.glob`` or appends it to a file specified using option ``--dump-glob
+``file.glob`` or appends it to a file specified using the option ``--dump-glob
file``. Take care of erasing this global file, if any, when starting
the whole compilation process.
Then invoke coqdoc or ``coqdoc --glob-from file`` to tell coqdoc to look
-for name resolutions into the file ``file`` (it will look in ``file.glob``
+for name resolutions in the file ``file`` (it will look in ``file.glob``
by default).
-Identifiers from the |Coq| standard library are linked to the Coq web
-site at `<http://coq.inria.fr/library/>`_. This behavior can be changed
+Identifiers from the |Coq| standard library are linked to the Coq website
+`<http://coq.inria.fr/library/>`_. This behavior can be changed
using command line options ``--no-externals`` and ``--coqlib``; see below.
@@ -731,12 +734,12 @@ file (even if it starts with a ``-``). |Coq| files are identified by the
suffixes ``.v`` and ``.g`` and |Latex| files by the suffix ``.tex``.
-:HTML output: This is the default output. One HTML file is created for
+:HTML output: This is the default output format. One HTML file is created for
each |Coq| file given on the command line, together with a file
``index.html`` (unless ``option-no-index is passed``). The HTML pages use a
style sheet named ``style.css``. Such a file is distributed with coqdoc.
:|Latex| output: A single |Latex| file is created, on standard
- output. It can be redirected to a file with option ``-o``. The order of
+ output. It can be redirected to a file using the option ``-o``. The order of
files on the command line is kept in the final document. |Latex|
files given on the command line are copied ‘as is’ in the final
document . DVI and PostScript can be produced directly with the
@@ -762,15 +765,15 @@ Command line options
:-o file, --output file: Redirect the output into the file ‘file’
(meaningless with ``-html``).
:-d dir, --directory dir: Output files into directory ‘dir’ instead of
- current directory (option ``-d`` does not change the filename specified
- with option ``-o``, if any).
+ the current directory (option ``-d`` does not change the filename specified
+ with the option ``-o``, if any).
:--body-only: Suppress the header and trailer of the final document.
Thus, you can insert the resulting document into a larger one.
:-p string, --preamble string: Insert some material in the |Latex|
preamble, right before ``\begin{document}`` (meaningless with ``-html``).
:--vernac-file file,--tex-file file: Considers the file ‘file’
respectively as a ``.v`` (or ``.g``) file or a ``.tex`` file.
- :--files-from file: Read file names to process in file ‘file’ as if
+ :--files-from file: Read file names to be processed from the file ‘file’ as if
they were given on the command line. Useful for program sources split
up into several directories.
:-q, --quiet: Be quiet. Do not print anything except errors.
@@ -781,7 +784,7 @@ Command line options
**Index options**
- Default behavior is to build an index, for the HTML output only,
+ The default behavior is to build an index, for the HTML output only,
into ``index.html``.
:--no-index: Do not output the index.
@@ -802,7 +805,7 @@ Command line options
contents.
-**Hyperlinks options**
+**Hyperlink options**
:--glob-from file: Make references using |Coq| globalizations from file
file. (Such globalizations are obtained with Coq option ``-dump-glob``).
@@ -858,9 +861,9 @@ Command line options
The behavior of options ``-g`` and ``-l`` can be locally overridden using the
``(* begin show *) … (* end show *)`` environment (see above).
- There are a few options to drive the parsing of comments:
+ There are a few options that control the parsing of comments:
- :--parse-comments: Parses regular comments delimited by ``(*`` and ``*)`` as
+ :--parse-comments: Parse regular comments delimited by ``(*`` and ``*)`` as
well. They are typeset inline.
:--plain-comments: Do not interpret comments, simply copy them as
plain-text.
@@ -870,7 +873,7 @@ Command line options
**Language options**
- Default behavior is to assume ASCII 7 bits input files.
+ The default behavior is to assume ASCII 7 bit input files.
:-latin1, --latin1: Select ISO-8859-1 input files. It is equivalent to
--inputenc latin1 --charset iso-8859-1.
@@ -935,7 +938,7 @@ macros:
Embedded Coq phrases inside |Latex| documents
---------------------------------------------
-When writing a documentation about a proof development, one may want
+When writing documentation about a proof development, one may want
to insert |Coq| phrases inside a |Latex| document, possibly together
with the corresponding answers of the system. We provide a mechanical
way to process such |Coq| phrases embedded in |Latex| files: the ``coq-tex``
diff --git a/doc/sphinx/proof-engine/detailed-tactic-examples.rst b/doc/sphinx/proof-engine/detailed-tactic-examples.rst
index 84810ddba5..225df8d54c 100644
--- a/doc/sphinx/proof-engine/detailed-tactic-examples.rst
+++ b/doc/sphinx/proof-engine/detailed-tactic-examples.rst
@@ -25,7 +25,7 @@ argument an hypothesis to generalize. It uses the JMeq datatype
defined in Coq.Logic.JMeq, hence we need to require it before. For
example, revisiting the first example of the inversion documentation:
-.. coqtop:: in
+.. coqtop:: in reset
Require Import Coq.Logic.JMeq.
@@ -63,6 +63,10 @@ to use an heterogeneous equality to relate the new hypothesis to the
old one (which just disappeared here). However, the tactic works just
as well in this case, e.g.:
+.. coqtop:: none
+
+ Abort.
+
.. coqtop:: in
Variable Q : forall (n m : nat), Le n m -> Prop.
@@ -80,7 +84,7 @@ to recover the needed equalities. Also, some subgoals should be
directly solved because of inconsistent contexts arising from the
constraints on indexes. The nice thing is that we can make a tactic
based on discriminate, injection and variants of substitution to
-automatically do such simplifications (which may involve the K axiom).
+automatically do such simplifications (which may involve the axiom K).
This is what the ``simplify_dep_elim`` tactic from ``Coq.Program.Equality``
does. For example, we might simplify the previous goals considerably:
@@ -101,9 +105,9 @@ are ``dependent induction`` and ``dependent destruction`` that do induction or
simply case analysis on the generalized hypothesis. For example we can
redo what we’ve done manually with dependent destruction:
-.. coqtop:: in
+.. coqtop:: none
- Require Import Coq.Program.Equality.
+ Abort.
.. coqtop:: in
@@ -122,9 +126,9 @@ destructed hypothesis actually appeared in the goal, the tactic would
still be able to invert it, contrary to dependent inversion. Consider
the following example on vectors:
-.. coqtop:: in
+.. coqtop:: none
- Require Import Coq.Program.Equality.
+ Abort.
.. coqtop:: in
@@ -167,7 +171,7 @@ predicates on a real example. We will develop an example application
to the theory of simply-typed lambda-calculus formalized in a
dependently-typed style:
-.. coqtop:: in
+.. coqtop:: in reset
Inductive type : Type :=
| base : type
@@ -226,11 +230,15 @@ name. A term is either an application of:
Once we have this datatype we want to do proofs on it, like weakening:
-.. coqtop:: in undo
+.. coqtop:: in
Lemma weakening : forall G D tau, term (G ; D) tau ->
forall tau', term (G , tau' ; D) tau.
+.. coqtop:: none
+
+ Abort.
+
The problem here is that we can’t just use induction on the typing
derivation because it will forget about the ``G ; D`` constraint appearing
in the instance. A solution would be to rewrite the goal as:
@@ -241,6 +249,10 @@ in the instance. A solution would be to rewrite the goal as:
forall G D, (G ; D) = G' ->
forall tau', term (G, tau' ; D) tau.
+.. coqtop:: none
+
+ Abort.
+
With this proper separation of the index from the instance and the
right induction loading (putting ``G`` and ``D`` after the inducted-on
hypothesis), the proof will go through, but it is a very tedious
@@ -252,6 +264,7 @@ back automatically. Indeed we can simply write:
.. coqtop:: in
Require Import Coq.Program.Tactics.
+ Require Import Coq.Program.Equality.
.. coqtop:: in
@@ -308,17 +321,14 @@ it can be used directly.
apply weak, IHterm.
-If there is an easy first-order solution to these equations as in this
-subgoal, the ``specialize_eqs`` tactic can be used instead of giving
-explicit proof terms:
-
-.. coqtop:: all
+Now concluding this subgoal is easy.
- specialize_eqs IHterm.
+.. coqtop:: in
-This concludes our example.
+ constructor; apply IHterm; reflexivity.
-See also: The :tacn:`induction`, :tacn:`case`, and :tacn:`inversion` tactics.
+.. seealso::
+ The :tacn:`induction`, :tacn:`case`, and :tacn:`inversion` tactics.
autorewrite
@@ -331,79 +341,81 @@ involves conditional rewritings and shows how to deal with them using
the optional tactic of the ``Hint Rewrite`` command.
-Example 1: Ackermann function
+.. example:: Ackermann function
-.. coqtop:: in
+ .. coqtop:: in reset
- Reset Initial.
+ Require Import Arith.
-.. coqtop:: in
+ .. coqtop:: in
- Require Import Arith.
+ Variable Ack : nat -> nat -> nat.
-.. coqtop:: in
+ .. coqtop:: in
- Variable Ack : nat -> nat -> nat.
+ Axiom Ack0 : forall m:nat, Ack 0 m = S m.
+ Axiom Ack1 : forall n:nat, Ack (S n) 0 = Ack n 1.
+ Axiom Ack2 : forall n m:nat, Ack (S n) (S m) = Ack n (Ack (S n) m).
-.. coqtop:: in
+ .. coqtop:: in
- Axiom Ack0 : forall m:nat, Ack 0 m = S m.
- Axiom Ack1 : forall n:nat, Ack (S n) 0 = Ack n 1.
- Axiom Ack2 : forall n m:nat, Ack (S n) (S m) = Ack n (Ack (S n) m).
+ Hint Rewrite Ack0 Ack1 Ack2 : base0.
-.. coqtop:: in
+ .. coqtop:: all
- Hint Rewrite Ack0 Ack1 Ack2 : base0.
+ Lemma ResAck0 : Ack 3 2 = 29.
-.. coqtop:: all
+ .. coqtop:: all
- Lemma ResAck0 : Ack 3 2 = 29.
+ autorewrite with base0 using try reflexivity.
-.. coqtop:: all
+.. example:: MacCarthy function
- autorewrite with base0 using try reflexivity.
+ .. coqtop:: in reset
-Example 2: Mac Carthy function
+ Require Import Omega.
-.. coqtop:: in
+ .. coqtop:: in
- Require Import Omega.
+ Variable g : nat -> nat -> nat.
-.. coqtop:: in
+ .. coqtop:: in
- Variable g : nat -> nat -> nat.
+ Axiom g0 : forall m:nat, g 0 m = m.
+ Axiom g1 : forall n m:nat, (n > 0) -> (m > 100) -> g n m = g (pred n) (m - 10).
+ Axiom g2 : forall n m:nat, (n > 0) -> (m <= 100) -> g n m = g (S n) (m + 11).
-.. coqtop:: in
+ .. coqtop:: in
- Axiom g0 : forall m:nat, g 0 m = m.
- Axiom g1 : forall n m:nat, (n > 0) -> (m > 100) -> g n m = g (pred n) (m - 10).
- Axiom g2 : forall n m:nat, (n > 0) -> (m <= 100) -> g n m = g (S n) (m + 11).
+ Hint Rewrite g0 g1 g2 using omega : base1.
+ .. coqtop:: in
-.. coqtop:: in
+ Lemma Resg0 : g 1 110 = 100.
- Hint Rewrite g0 g1 g2 using omega : base1.
+ .. coqtop:: out
-.. coqtop:: in
+ Show.
- Lemma Resg0 : g 1 110 = 100.
+ .. coqtop:: all
-.. coqtop:: out
+ autorewrite with base1 using reflexivity || simpl.
- Show.
+ .. coqtop:: none
-.. coqtop:: all
+ Qed.
- autorewrite with base1 using reflexivity || simpl.
+ .. coqtop:: all
-.. coqtop:: all
+ Lemma Resg1 : g 1 95 = 91.
- Lemma Resg1 : g 1 95 = 91.
+ .. coqtop:: all
-.. coqtop:: all
+ autorewrite with base1 using reflexivity || simpl.
- autorewrite with base1 using reflexivity || simpl.
+ .. coqtop:: none
+ Qed.
.. _quote:
@@ -419,7 +431,7 @@ the form ``(f t)``. ``L`` must have a constructor of type: ``A -> L``.
Here is an example:
-.. coqtop:: in
+.. coqtop:: in reset
Require Import Quote.
@@ -461,16 +473,11 @@ corresponding left-hand side and call yourself recursively on sub-
terms. If there is no match, we are at a leaf: return the
corresponding constructor (here ``f_const``) applied to the term.
-
-Error messages:
-
-
-#. quote: not a simple fixpoint
+.. exn:: quote: not a simple fixpoint
Happens when ``quote`` is not able to perform inversion properly.
-
Introducing variables map
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -553,7 +560,13 @@ example, this is the case for the :tacn:`ring` tactic. Then one must provide to
is ``[O S]`` then closed natural numbers will be considered as constants
and other terms as variables.
-Example:
+.. coqtop:: in reset
+
+ Require Import Quote.
+
+.. coqtop:: in
+
+ Parameters A B C : Prop.
.. coqtop:: in
@@ -594,8 +607,9 @@ Example:
quote interp_f [ B C iff ].
-Warning: Since function inversion is undecidable in general case,
-don’t expect miracles from it!
+.. warning::
+ Since functional inversion is undecidable in the general case,
+ don’t expect miracles from it!
.. tacv:: quote @ident in @term using @tactic
@@ -607,25 +621,28 @@ don’t expect miracles from it!
Same as above, but will use the additional ``ident`` list to chose
which subterms are constants (see above).
-See also: comments of source file ``plugins/quote/quote.ml``
+.. seealso::
+ Comments from the source file ``plugins/quote/quote.ml``
-See also: the :tacn:`ring` tactic.
+.. seealso::
+ The :tacn:`ring` tactic.
-Using the tactical language
+Using the tactic language
---------------------------
About the cardinality of the set of natural numbers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A first example which shows how to use pattern matching over the
-proof contexts is the proof that natural numbers have more than two
-elements. The proof of such a lemma can be done as follows:
+The first example which shows how to use pattern matching over the
+proof context is a proof of the fact that natural numbers have more
+than two elements. This can be done as follows:
-.. coqtop:: in
+.. coqtop:: in reset
- Lemma card_nat : ~ (exists x : nat, exists y : nat, forall z:nat, x = z \/ y = z).
+ Lemma card_nat :
+ ~ exists x : nat, exists y : nat, forall z:nat, x = z \/ y = z.
Proof.
.. coqtop:: in
@@ -637,8 +654,8 @@ elements. The proof of such a lemma can be done as follows:
elim (Hy 0); elim (Hy 1); elim (Hy 2); intros;
match goal with
- | [_:(?a = ?b),_:(?a = ?c) |- _ ] =>
- cut (b = c); [ discriminate | transitivity a; auto ]
+ | _ : ?a = ?b, _ : ?a = ?c |- _ =>
+ cut (b = c); [ discriminate | transitivity a; auto ]
end.
.. coqtop:: in
@@ -651,16 +668,14 @@ solved by a match goal structure and, in particular, with only one
pattern (use of non-linear matching).
-Permutation on closed lists
+Permutations of lists
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Another more complex example is the problem of permutation on closed
-lists. The aim is to show that a closed list is a permutation of
-another one.
-
-First, we define the permutation predicate as shown here:
+A more complex example is the problem of permutations of
+lists. The aim is to show that a list is a permutation of
+another list.
-.. coqtop:: in
+.. coqtop:: in reset
Section Sort.
@@ -670,205 +685,179 @@ First, we define the permutation predicate as shown here:
.. coqtop:: in
- Inductive permut : list A -> list A -> Prop :=
- | permut_refl : forall l, permut l l
- | permut_cons : forall a l0 l1, permut l0 l1 -> permut (a :: l0) (a :: l1)
- | permut_append : forall a l, permut (a :: l) (l ++ a :: nil)
- | permut_trans : forall l0 l1 l2, permut l0 l1 -> permut l1 l2 -> permut l0 l2.
+ Inductive perm : list A -> list A -> Prop :=
+ | perm_refl : forall l, perm l l
+ | perm_cons : forall a l0 l1, perm l0 l1 -> perm (a :: l0) (a :: l1)
+ | perm_append : forall a l, perm (a :: l) (l ++ a :: nil)
+ | perm_trans : forall l0 l1 l2, perm l0 l1 -> perm l1 l2 -> perm l0 l2.
.. coqtop:: in
End Sort.
-A more complex example is the problem of permutation on closed lists.
-The aim is to show that a closed list is a permutation of another one.
First, we define the permutation predicate as shown above.
-
.. coqtop:: none
Require Import List.
-.. coqtop:: all
-
- Ltac Permut n :=
- match goal with
- | |- (permut _ ?l ?l) => apply permut_refl
- | |- (permut _ (?a :: ?l1) (?a :: ?l2)) =>
- let newn := eval compute in (length l1) in
- (apply permut_cons; Permut newn)
- | |- (permut ?A (?a :: ?l1) ?l2) =>
- match eval compute in n with
- | 1 => fail
- | _ =>
- let l1' := constr:(l1 ++ a :: nil) in
- (apply (permut_trans A (a :: l1) l1' l2);
- [ apply permut_append | compute; Permut (pred n) ])
- end
- end.
-
-
-.. coqtop:: all
-
- Ltac PermutProve :=
- match goal with
- | |- (permut _ ?l1 ?l2) =>
- match eval compute in (length l1 = length l2) with
- | (?n = ?n) => Permut n
- end
- end.
-
-Next, we can write naturally the tactic and the result can be seen
-above. We can notice that we use two top level definitions
-``PermutProve`` and ``Permut``. The function to be called is
-``PermutProve`` which computes the lengths of the two lists and calls
-``Permut`` with the length if the two lists have the same
-length. ``Permut`` works as expected. If the two lists are equal, it
-concludes. Otherwise, if the lists have identical first elements, it
-applies ``Permut`` on the tail of the lists. Finally, if the lists
-have different first elements, it puts the first element of one of the
-lists (here the second one which appears in the permut predicate) at
-the end if that is possible, i.e., if the new first element has been
-at this place previously. To verify that all rotations have been done
-for a list, we use the length of the list as an argument for Permut
-and this length is decremented for each rotation down to, but not
-including, 1 because for a list of length ``n``, we can make exactly
-``n−1`` rotations to generate at most ``n`` distinct lists. Here, it
-must be noticed that we use the natural numbers of Coq for the
-rotation counter. In :ref:`ltac-syntax`, we can
-see that it is possible to use usual natural numbers but they are only
-used as arguments for primitive tactics and they cannot be handled, in
-particular, we cannot make computations with them. So, a natural
-choice is to use Coq data structures so that Coq makes the
-computations (reductions) by eval compute in and we can get the terms
-back by match.
-
-With ``PermutProve``, we can now prove lemmas as follows:
-
.. coqtop:: in
- Lemma permut_ex1 : permut nat (1 :: 2 :: 3 :: nil) (3 :: 2 :: 1 :: nil).
+ Ltac perm_aux n :=
+ match goal with
+ | |- (perm _ ?l ?l) => apply perm_refl
+ | |- (perm _ (?a :: ?l1) (?a :: ?l2)) =>
+ let newn := eval compute in (length l1) in
+ (apply perm_cons; perm_aux newn)
+ | |- (perm ?A (?a :: ?l1) ?l2) =>
+ match eval compute in n with
+ | 1 => fail
+ | _ =>
+ let l1' := constr:(l1 ++ a :: nil) in
+ (apply (perm_trans A (a :: l1) l1' l2);
+ [ apply perm_append | compute; perm_aux (pred n) ])
+ end
+ end.
-.. coqtop:: in
+Next we define an auxiliary tactic ``perm_aux`` which takes an argument
+used to control the recursion depth. This tactic behaves as follows. If
+the lists are identical (i.e. convertible), it concludes. Otherwise, if
+the lists have identical heads, it proceeds to look at their tails.
+Finally, if the lists have different heads, it rotates the first list by
+putting its head at the end if the new head hasn't been the head previously. To check this, we keep track of the
+number of performed rotations using the argument ``n``. We do this by
+decrementing ``n`` each time we perform a rotation. It works because
+for a list of length ``n`` we can make exactly ``n - 1`` rotations
+to generate at most ``n`` distinct lists. Notice that we use the natural
+numbers of Coq for the rotation counter. From :ref:`ltac-syntax` we know
+that it is possible to use the usual natural numbers, but they are only
+used as arguments for primitive tactics and they cannot be handled, so,
+in particular, we cannot make computations with them. Thus the natural
+choice is to use Coq data structures so that Coq makes the computations
+(reductions) by ``eval compute in`` and we can get the terms back by match.
+
+.. coqtop:: in
+
+ Ltac solve_perm :=
+ match goal with
+ | |- (perm _ ?l1 ?l2) =>
+ match eval compute in (length l1 = length l2) with
+ | (?n = ?n) => perm_aux n
+ end
+ end.
- Proof. PermutProve. Qed.
+The main tactic is ``solve_perm``. It computes the lengths of the two lists
+and uses them as arguments to call ``perm_aux`` if the lengths are equal (if they
+aren't, the lists cannot be permutations of each other). Using this tactic we
+can now prove lemmas as follows:
.. coqtop:: in
- Lemma permut_ex2 : permut nat
- (0 :: 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: 9 :: nil)
- (0 :: 2 :: 4 :: 6 :: 8 :: 9 :: 7 :: 5 :: 3 :: 1 :: nil).
-
- Proof. PermutProve. Qed.
+ Lemma solve_perm_ex1 :
+ perm nat (1 :: 2 :: 3 :: nil) (3 :: 2 :: 1 :: nil).
+ Proof. solve_perm. Qed.
+.. coqtop:: in
+ Lemma solve_perm_ex2 :
+ perm nat
+ (0 :: 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: 9 :: nil)
+ (0 :: 2 :: 4 :: 6 :: 8 :: 9 :: 7 :: 5 :: 3 :: 1 :: nil).
+ Proof. solve_perm. Qed.
Deciding intuitionistic propositional logic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. _decidingintuitionistic1:
-
-.. coqtop:: all
-
- Ltac Axioms :=
- match goal with
- | |- True => trivial
- | _:False |- _ => elimtype False; assumption
- | _:?A |- ?A => auto
- end.
-
-.. _decidingintuitionistic2:
-
-.. coqtop:: all
-
- Ltac DSimplif :=
- repeat
- (intros;
- match goal with
- | id:(~ _) |- _ => red in id
- | id:(_ /\ _) |- _ =>
- elim id; do 2 intro; clear id
- | id:(_ \/ _) |- _ =>
- elim id; intro; clear id
- | id:(?A /\ ?B -> ?C) |- _ =>
- cut (A -> B -> C);
- [ intro | intros; apply id; split; assumption ]
- | id:(?A \/ ?B -> ?C) |- _ =>
- cut (B -> C);
- [ cut (A -> C);
- [ intros; clear id
- | intro; apply id; left; assumption ]
- | intro; apply id; right; assumption ]
- | id0:(?A -> ?B),id1:?A |- _ =>
- cut B; [ intro; clear id0 | apply id0; assumption ]
- | |- (_ /\ _) => split
- | |- (~ _) => red
- end).
-
-.. coqtop:: all
-
- Ltac TautoProp :=
- DSimplif;
- Axioms ||
- match goal with
- | id:((?A -> ?B) -> ?C) |- _ =>
- cut (B -> C);
- [ intro; cut (A -> B);
- [ intro; cut C;
- [ intro; clear id | apply id; assumption ]
- | clear id ]
- | intro; apply id; intro; assumption ]; TautoProp
- | id:(~ ?A -> ?B) |- _ =>
- cut (False -> B);
- [ intro; cut (A -> False);
- [ intro; cut B;
- [ intro; clear id | apply id; assumption ]
- | clear id ]
- | intro; apply id; red; intro; assumption ]; TautoProp
- | |- (_ \/ _) => (left; TautoProp) || (right; TautoProp)
- end.
-
-The pattern matching on goals allows a complete and so a powerful
-backtracking when returning tactic values. An interesting application
-is the problem of deciding intuitionistic propositional logic.
-Considering the contraction-free sequent calculi LJT* of Roy Dyckhoff
-:cite:`Dyc92`, it is quite natural to code such a tactic
-using the tactic language as shown on figures: :ref:`Deciding
-intuitionistic propositions (1) <decidingintuitionistic1>` and
-:ref:`Deciding intuitionistic propositions (2)
-<decidingintuitionistic2>`. The tactic ``Axioms`` tries to conclude
-using usual axioms. The tactic ``DSimplif`` applies all the reversible
-rules of Dyckhoff’s system. Finally, the tactic ``TautoProp`` (the
-main tactic to be called) simplifies with ``DSimplif``, tries to
-conclude with ``Axioms`` and tries several paths using the
-backtracking rules (one of the four Dyckhoff’s rules for the left
-implication to get rid of the contraction and the right or).
-
-For example, with ``TautoProp``, we can prove tautologies like those:
-
-.. coqtop:: in
-
- Lemma tauto_ex1 : forall A B:Prop, A /\ B -> A \/ B.
+Pattern matching on goals allows a powerful backtracking when returning tactic
+values. An interesting application is the problem of deciding intuitionistic
+propositional logic. Considering the contraction-free sequent calculi LJT* of
+Roy Dyckhoff :cite:`Dyc92`, it is quite natural to code such a tactic using the
+tactic language as shown below.
-.. coqtop:: in
-
- Proof. TautoProp. Qed.
-
-.. coqtop:: in
+.. coqtop:: in reset
- Lemma tauto_ex2 :
- forall A B:Prop, (~ ~ B -> B) -> (A -> B) -> ~ ~ A -> B.
+ Ltac basic :=
+ match goal with
+ | |- True => trivial
+ | _ : False |- _ => contradiction
+ | _ : ?A |- ?A => assumption
+ end.
.. coqtop:: in
- Proof. TautoProp. Qed.
+ Ltac simplify :=
+ repeat (intros;
+ match goal with
+ | H : ~ _ |- _ => red in H
+ | H : _ /\ _ |- _ =>
+ elim H; do 2 intro; clear H
+ | H : _ \/ _ |- _ =>
+ elim H; intro; clear H
+ | H : ?A /\ ?B -> ?C |- _ =>
+ cut (A -> B -> C);
+ [ intro | intros; apply H; split; assumption ]
+ | H: ?A \/ ?B -> ?C |- _ =>
+ cut (B -> C);
+ [ cut (A -> C);
+ [ intros; clear H
+ | intro; apply H; left; assumption ]
+ | intro; apply H; right; assumption ]
+ | H0 : ?A -> ?B, H1 : ?A |- _ =>
+ cut B; [ intro; clear H0 | apply H0; assumption ]
+ | |- _ /\ _ => split
+ | |- ~ _ => red
+ end).
+
+.. coqtop:: in
+
+ Ltac my_tauto :=
+ simplify; basic ||
+ match goal with
+ | H : (?A -> ?B) -> ?C |- _ =>
+ cut (B -> C);
+ [ intro; cut (A -> B);
+ [ intro; cut C;
+ [ intro; clear H | apply H; assumption ]
+ | clear H ]
+ | intro; apply H; intro; assumption ]; my_tauto
+ | H : ~ ?A -> ?B |- _ =>
+ cut (False -> B);
+ [ intro; cut (A -> False);
+ [ intro; cut B;
+ [ intro; clear H | apply H; assumption ]
+ | clear H ]
+ | intro; apply H; red; intro; assumption ]; my_tauto
+ | |- _ \/ _ => (left; my_tauto) || (right; my_tauto)
+ end.
+
+The tactic ``basic`` tries to reason using simple rules involving truth, falsity
+and available assumptions. The tactic ``simplify`` applies all the reversible
+rules of Dyckhoff’s system. Finally, the tactic ``my_tauto`` (the main
+tactic to be called) simplifies with ``simplify``, tries to conclude with
+``basic`` and tries several paths using the backtracking rules (one of the
+four Dyckhoff’s rules for the left implication to get rid of the contraction
+and the right ``or``).
+
+Having defined ``my_tauto``, we can prove tautologies like these:
+
+.. coqtop:: in
+
+ Lemma my_tauto_ex1 :
+ forall A B : Prop, A /\ B -> A \/ B.
+ Proof. my_tauto. Qed.
+
+.. coqtop:: in
+
+ Lemma my_tauto_ex2 :
+ forall A B : Prop, (~ ~ B -> B) -> (A -> B) -> ~ ~ A -> B.
+ Proof. my_tauto. Qed.
Deciding type isomorphisms
~~~~~~~~~~~~~~~~~~~~~~~~~~
-A more tricky problem is to decide equalities between types and modulo
+A more tricky problem is to decide equalities between types modulo
isomorphisms. Here, we choose to use the isomorphisms of the simply
typed λ-calculus with Cartesian product and unit type (see, for
example, :cite:`RC95`). The axioms of this λ-calculus are given below.
@@ -915,112 +904,104 @@ example, :cite:`RC95`). The axioms of this λ-calculus are given below.
End Iso_axioms.
+.. coqtop:: in
+ Ltac simplify_type ty :=
+ match ty with
+ | ?A * ?B * ?C =>
+ rewrite <- (Ass A B C); try simplify_type_eq
+ | ?A * ?B -> ?C =>
+ rewrite (Cur A B C); try simplify_type_eq
+ | ?A -> ?B * ?C =>
+ rewrite (Dis A B C); try simplify_type_eq
+ | ?A * unit =>
+ rewrite (P_unit A); try simplify_type_eq
+ | unit * ?B =>
+ rewrite (Com unit B); try simplify_type_eq
+ | ?A -> unit =>
+ rewrite (AR_unit A); try simplify_type_eq
+ | unit -> ?B =>
+ rewrite (AL_unit B); try simplify_type_eq
+ | ?A * ?B =>
+ (simplify_type A; try simplify_type_eq) ||
+ (simplify_type B; try simplify_type_eq)
+ | ?A -> ?B =>
+ (simplify_type A; try simplify_type_eq) ||
+ (simplify_type B; try simplify_type_eq)
+ end
+ with simplify_type_eq :=
+ match goal with
+ | |- ?A = ?B => try simplify_type A; try simplify_type B
+ end.
-.. _typeisomorphism1:
-
-.. coqtop:: all
-
- Ltac DSimplif trm :=
- match trm with
- | (?A * ?B * ?C) =>
- rewrite <- (Ass A B C); try MainSimplif
- | (?A * ?B -> ?C) =>
- rewrite (Cur A B C); try MainSimplif
- | (?A -> ?B * ?C) =>
- rewrite (Dis A B C); try MainSimplif
- | (?A * unit) =>
- rewrite (P_unit A); try MainSimplif
- | (unit * ?B) =>
- rewrite (Com unit B); try MainSimplif
- | (?A -> unit) =>
- rewrite (AR_unit A); try MainSimplif
- | (unit -> ?B) =>
- rewrite (AL_unit B); try MainSimplif
- | (?A * ?B) =>
- (DSimplif A; try MainSimplif) || (DSimplif B; try MainSimplif)
- | (?A -> ?B) =>
- (DSimplif A; try MainSimplif) || (DSimplif B; try MainSimplif)
- end
- with MainSimplif :=
- match goal with
- | |- (?A = ?B) => try DSimplif A; try DSimplif B
- end.
-
-.. coqtop:: all
+.. coqtop:: in
- Ltac Length trm :=
- match trm with
- | (_ * ?B) => let succ := Length B in constr:(S succ)
- | _ => constr:(1)
- end.
+ Ltac len trm :=
+ match trm with
+ | _ * ?B => let succ := len B in constr:(S succ)
+ | _ => constr:(1)
+ end.
-.. coqtop:: all
+.. coqtop:: in
Ltac assoc := repeat rewrite <- Ass.
+.. coqtop:: in
-.. _typeisomorphism2:
-
-.. coqtop:: all
-
- Ltac DoCompare n :=
- match goal with
- | [ |- (?A = ?A) ] => reflexivity
- | [ |- (?A * ?B = ?A * ?C) ] =>
- apply Cons; let newn := Length B in
- DoCompare newn
- | [ |- (?A * ?B = ?C) ] =>
- match eval compute in n with
- | 1 => fail
- | _ =>
- pattern (A * B) at 1; rewrite Com; assoc; DoCompare (pred n)
- end
- end.
-
-.. coqtop:: all
+ Ltac solve_type_eq n :=
+ match goal with
+ | |- ?A = ?A => reflexivity
+ | |- ?A * ?B = ?A * ?C =>
+ apply Cons; let newn := len B in solve_type_eq newn
+ | |- ?A * ?B = ?C =>
+ match eval compute in n with
+ | 1 => fail
+ | _ =>
+ pattern (A * B) at 1; rewrite Com; assoc; solve_type_eq (pred n)
+ end
+ end.
- Ltac CompareStruct :=
- match goal with
- | [ |- (?A = ?B) ] =>
- let l1 := Length A
- with l2 := Length B in
- match eval compute in (l1 = l2) with
- | (?n = ?n) => DoCompare n
- end
- end.
+.. coqtop:: in
-.. coqtop:: all
+ Ltac compare_structure :=
+ match goal with
+ | |- ?A = ?B =>
+ let l1 := len A
+ with l2 := len B in
+ match eval compute in (l1 = l2) with
+ | ?n = ?n => solve_type_eq n
+ end
+ end.
- Ltac IsoProve := MainSimplif; CompareStruct.
+.. coqtop:: in
+ Ltac solve_iso := simplify_type_eq; compare_structure.
-The tactic to judge equalities modulo this axiomatization can be
-written as shown on these figures: :ref:`type isomorphism tactic (1)
-<typeisomorphism1>` and :ref:`type isomorphism tactic (2)
-<typeisomorphism2>`. The algorithm is quite simple. Types are reduced
-using axioms that can be oriented (this done by ``MainSimplif``). The
-normal forms are sequences of Cartesian products without Cartesian
-product in the left component. These normal forms are then compared
-modulo permutation of the components (this is done by
-``CompareStruct``). The main tactic to be called and realizing this
-algorithm isIsoProve.
+The tactic to judge equalities modulo this axiomatization is shown above.
+The algorithm is quite simple. First types are simplified using axioms that
+can be oriented (this is done by ``simplify_type`` and ``simplify_type_eq``).
+The normal forms are sequences of Cartesian products without Cartesian product
+in the left component. These normal forms are then compared modulo permutation
+of the components by the tactic ``compare_structure``. If they have the same
+lengths, the tactic ``solve_type_eq`` attempts to prove that the types are equal.
+The main tactic that puts all these components together is called ``solve_iso``.
-Here are examples of what can be solved by ``IsoProve``.
+Here are examples of what can be solved by ``solve_iso``.
.. coqtop:: in
- Lemma isos_ex1 :
- forall A B:Set, A * unit * B = B * (unit * A).
+ Lemma solve_iso_ex1 :
+ forall A B : Set, A * unit * B = B * (unit * A).
Proof.
- intros; IsoProve.
+ intros; solve_iso.
Qed.
.. coqtop:: in
- Lemma isos_ex2 :
- forall A B C:Set,
- (A * unit -> B * (C * unit)) = (A * unit -> (C -> unit) * C) * (unit -> A -> B).
+ Lemma solve_iso_ex2 :
+ forall A B C : Set,
+ (A * unit -> B * (C * unit)) =
+ (A * unit -> (C -> unit) * C) * (unit -> A -> B).
Proof.
- intros; IsoProve.
+ intros; solve_iso.
Qed.
diff --git a/doc/sphinx/proof-engine/ltac.rst b/doc/sphinx/proof-engine/ltac.rst
index dc355fa013..6fbb2fac6d 100644
--- a/doc/sphinx/proof-engine/ltac.rst
+++ b/doc/sphinx/proof-engine/ltac.rst
@@ -144,10 +144,11 @@ mode but it can also be used in toplevel definitions as shown below.
: | `integer` (< | <= | > | >=) `integer`
selector : [`ident`]
: | `integer`
- : (`integer` | `integer` - `integer`), ..., (`integer` | `integer` - `integer`)
+ : | (`integer` | `integer` - `integer`), ..., (`integer` | `integer` - `integer`)
toplevel_selector : `selector`
- : | `all`
- : | `par`
+ : | all
+ : | par
+ : | !
.. productionlist:: coq
top : [Local] Ltac `ltac_def` with ... with `ltac_def`
@@ -177,7 +178,7 @@ Sequence
A sequence is an expression of the following form:
-.. tacn:: @expr ; @expr
+.. tacn:: @expr__1 ; @expr__2
:name: ltac-seq
The expression :n:`@expr__1` is evaluated to :n:`v__1`, which must be
@@ -207,11 +208,11 @@ following form:
were given. For instance, ``[> | auto]`` is a shortcut for ``[> idtac | auto
]``.
- .. tacv:: [> {*| @expr} | @expr .. | {*| @expr}]
+ .. tacv:: [> {*| @expr__i} | @expr .. | {*| @expr__j}]
- In this variant, token:`expr` is used for each goal coming after those
- covered by the first list of :n:`@expr` but before those coevered by the
- last list of :n:`@expr`.
+ In this variant, :n:`@expr` is used for each goal coming after those
+ covered by the list of :n:`@expr__i` but before those covered by the
+ list of :n:`@expr__j`.
.. tacv:: [> {*| @expr} | .. | {*| @expr}]
@@ -225,11 +226,11 @@ following form:
tactic is not run at all. A tactic which expects multiple goals, such as
``swap``, would act as if a single goal is focused.
- .. tacv:: expr ; [{*| @expr}]
+ .. tacv:: @expr__0 ; [{*| @expr__i}]
This variant of local tactic application is paired with a sequence. In this
- variant, there must be as many :n:`@expr` in the list as goals generated
- by the application of the first :n:`@expr` to each of the individual goals
+ variant, there must be as many :n:`@expr__i` as goals generated
+ by the application of :n:`@expr__0` to each of the individual goals
independently. All the above variants work in this form too.
Formally, :n:`@expr ; [ ... ]` is equivalent to :n:`[> @expr ; [> ... ] .. ]`.
@@ -247,20 +248,20 @@ focused goals with:
We can also use selectors as a tactical, which allows to use them nested
in a tactic expression, by using the keyword ``only``:
- .. tacv:: only selector : expr
+ .. tacv:: only @selector : @expr
:name: only ... : ...
- When selecting several goals, the tactic expr is applied globally to all
+ When selecting several goals, the tactic :token:`expr` is applied globally to all
selected goals.
.. tacv:: [@ident] : @expr
- In this variant, :n:`@expr` is applied locally to a goal previously named
+ In this variant, :token:`expr` is applied locally to a goal previously named
by the user (see :ref:`existential-variables`).
.. tacv:: @num : @expr
- In this variant, :n:`@expr` is applied locally to the :token:`num`-th goal.
+ In this variant, :token:`expr` is applied locally to the :token:`num`-th goal.
.. tacv:: {+, @num-@num} : @expr
@@ -271,13 +272,13 @@ focused goals with:
.. tacv:: all: @expr
:name: all: ...
- In this variant, :n:`@expr` is applied to all focused goals. ``all:`` can only
+ In this variant, :token:`expr` is applied to all focused goals. ``all:`` can only
be used at the toplevel of a tactic expression.
.. tacv:: !: @expr
- In this variant, if exactly one goal is focused :n:`expr` is
- applied to it. Otherwise the tactical fails. ``!:`` can only be
+ In this variant, if exactly one goal is focused, :token:`expr` is
+ applied to it. Otherwise the tactic fails. ``!:`` can only be
used at the toplevel of a tactic expression.
.. tacv:: par: @expr
diff --git a/doc/sphinx/proof-engine/proof-handling.rst b/doc/sphinx/proof-engine/proof-handling.rst
index 44376080c3..a9d0c16376 100644
--- a/doc/sphinx/proof-engine/proof-handling.rst
+++ b/doc/sphinx/proof-engine/proof-handling.rst
@@ -375,6 +375,7 @@ or focus the next one.
The following example script illustrates all these features:
.. example::
+
.. coqtop:: all
Goal (((True /\ True) /\ True) /\ True) /\ True.
@@ -511,6 +512,7 @@ Requesting information
:token:`ident`
.. example::
+
.. coqtop:: all
Show Match nat.
diff --git a/doc/sphinx/proof-engine/ssreflect-proof-language.rst b/doc/sphinx/proof-engine/ssreflect-proof-language.rst
index 6fb73a030f..8a2fc3996a 100644
--- a/doc/sphinx/proof-engine/ssreflect-proof-language.rst
+++ b/doc/sphinx/proof-engine/ssreflect-proof-language.rst
@@ -4632,6 +4632,7 @@ bookkeeping steps.
.. example::
+
The following example use the ``~~`` prenex notation for boolean negation:
diff --git a/doc/sphinx/proof-engine/tactics.rst b/doc/sphinx/proof-engine/tactics.rst
index 9b4d724e02..fdb04bf9a0 100644
--- a/doc/sphinx/proof-engine/tactics.rst
+++ b/doc/sphinx/proof-engine/tactics.rst
@@ -207,6 +207,7 @@ Applying theorems
useful to advanced users.
.. example::
+
.. coqtop:: reset all
Inductive Option : Set :=
@@ -281,7 +282,7 @@ Applying theorems
:g:`t`:sub:`n` in the goal. See :tacn:`pattern` to transform the goal so that it
gets the form :g:`(fun x => Q) u`:sub:`1` :g:`...` :g:`u`:sub:`n`.
- .. exn:: Unable to unify ... with ... .
+ .. exn:: Unable to unify @term with @term.
The apply tactic failed to match the conclusion of :token:`term` and the
current goal. You can help the apply tactic by transforming your goal with
@@ -366,6 +367,7 @@ Applying theorems
.. warn:: When @term contains more than one non dependent product the tactic lapply only takes into account the first product.
.. example::
+
Assume we have a transitive relation ``R`` on ``nat``:
.. coqtop:: reset in
@@ -837,6 +839,7 @@ quantified variables or hypotheses until the goal is not any more a
quantification or an implication.
.. example::
+
.. coqtop:: all
Goal forall A B C:Prop, A \/ B /\ C -> (A -> C) -> C.
@@ -958,6 +961,7 @@ quantification or an implication.
.. exn:: Cannot move @ident after @ident : it depends on @ident.
.. example::
+
.. coqtop:: all
Goal forall x :nat, x = 0 -> forall z y:nat, y=y-> 0=x.
@@ -1082,6 +1086,7 @@ The name of the hypothesis in the proof-term, however, is left unchanged.
obtain atomic ones.
.. example::
+
.. coqtop:: all
Goal forall A B C:Prop, A /\ B /\ C \/ B /\ C \/ C /\ A -> C.
@@ -1252,6 +1257,7 @@ Controlling the proof flow
respect to some term.
.. example::
+
.. coqtop:: reset none
Goal forall x y:nat, 0 <= x + y + y.
@@ -1567,6 +1573,7 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
performs induction using this subterm.
.. example::
+
.. coqtop:: reset all
Lemma induction_test : forall n:nat, n = n -> n <= n.
@@ -1636,6 +1643,7 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
those are generalized as well in the statement to prove.
.. example::
+
.. coqtop:: reset all
Lemma comm x y : x + y = y + x.
@@ -1744,6 +1752,7 @@ analysis on inductive or co-inductive objects (see :ref:`inductive-definitions`)
still get enough information in the proofs.
.. example::
+
.. coqtop:: reset all
Lemma le_minus : forall n:nat, n < 1 -> n = 0.
@@ -1809,6 +1818,7 @@ and an explanation of the underlying technique.
Note that this tactic is only available after a ``Require Import FunInd``.
.. example::
+
.. coqtop:: reset all
Require Import FunInd.
@@ -2856,6 +2866,7 @@ the conversion in hypotheses :n:`{+ @ident}`.
+ A constant can be marked to be never unfolded by ``cbn`` or ``simpl``:
.. example::
+
.. coqtop:: all
Arguments minus n m : simpl never.
@@ -2868,6 +2879,7 @@ the conversion in hypotheses :n:`{+ @ident}`.
``/`` symbol in the argument list of the :cmd:`Arguments` vernacular command.
.. example::
+
.. coqtop:: all
Definition fcomp A B C f (g : A -> B) (x : A) : C := f (g x).
@@ -2880,6 +2892,7 @@ the conversion in hypotheses :n:`{+ @ident}`.
always unfolded.
.. example::
+
.. coqtop:: all
Definition volatile := fun x : nat => x.
@@ -2890,6 +2903,7 @@ the conversion in hypotheses :n:`{+ @ident}`.
such arguments.
.. example::
+
.. coqtop:: all
Arguments minus !n !m.
@@ -3180,6 +3194,7 @@ where :tacn:`auto` uses simple :tacn:`apply`). As a consequence, :tacn:`eauto`
can solve such a goal:
.. example::
+
.. coqtop:: all
Hint Resolve ex_intro.
@@ -3748,6 +3763,7 @@ The following goal can be proved by :tacn:`tauto` whereas :tacn:`auto` would
fail:
.. example::
+
.. coqtop:: reset all
Goal forall (x:nat) (P:nat -> Prop), x = 0 \/ P x -> x <> 0 -> P x.
@@ -3904,6 +3920,7 @@ equality must contain all the quantified variables in order for congruence to
match against it.
.. example::
+
.. coqtop:: reset all
Theorem T (A:Type) (f:A -> A) (g: A -> A -> A) a b: a=(f a) -> (g b (f a))=(f (f a)) -> (g a b)=(f (g b a)) -> (g a b)=a.
@@ -3935,7 +3952,7 @@ match against it.
discriminable equality but this proof could not be built in Coq because of
dependently-typed functions.
-.. exn:: Goal is solvable by congruence but some arguments are missing. Try congruence with ..., replacing metavariables by arbitrary terms.
+.. exn:: Goal is solvable by congruence but some arguments are missing. Try congruence with {+ @term}, replacing metavariables by arbitrary terms.
The decision procedure could solve the goal with the provision that additional
arguments are supplied for some partially applied constructors. Any term of an
@@ -3979,7 +3996,7 @@ succeeds, and results in an error otherwise.
This tactic checks whether its arguments are unifiable, potentially
instantiating existential variables.
-.. exn:: Not unifiable.
+.. exn:: Unable to unify @term with @term.
.. tacv:: unify @term @term with @ident
@@ -4315,6 +4332,7 @@ declare new field structures. All declared field structures can be
printed with the Print Fields command.
.. example::
+
.. coqtop:: reset all
Require Import Reals.
@@ -4426,6 +4444,7 @@ Simple tactic macros
A simple example has more value than a long explanation:
.. example::
+
.. coqtop:: reset all
Ltac Solve := simpl; intros; auto.
diff --git a/doc/sphinx/user-extensions/proof-schemes.rst b/doc/sphinx/user-extensions/proof-schemes.rst
index 838926d651..ab1edc0b27 100644
--- a/doc/sphinx/user-extensions/proof-schemes.rst
+++ b/doc/sphinx/user-extensions/proof-schemes.rst
@@ -40,8 +40,7 @@ induction for objects in type `identᵢ`.
Induction scheme for tree and forest.
- The definition of principle of mutual induction for tree and forest
- over the sort Set is defined by the command:
+ A mutual induction principle for tree and forest in sort ``Set`` can be defined using the command
.. coqtop:: none
@@ -193,10 +192,12 @@ command generates the induction principle for each `identᵢ`, following
the recursive structure and case analyses of the corresponding function
identᵢ’.
-Remark: There is a difference between obtaining an induction scheme by
-using ``Functional Scheme`` on a function defined by ``Function`` or not.
-Indeed, ``Function`` generally produces smaller principles, closer to the
-definition written by the user.
+.. warning::
+
+ There is a difference between induction schemes generated by the command
+ :cmd:`Functional Scheme` and these generated by the :cmd:`Function`. Indeed,
+ :cmd:`Function` generally produces smaller principles that are closer to how
+ a user would implement them. See :ref:`advanced-recursive-functions` for details.
.. example::
@@ -257,11 +258,6 @@ definition written by the user.
auto with arith.
Qed.
- Remark: There is a difference between obtaining an induction scheme
- for a function by using ``Function`` (see :ref:`advanced-recursive-functions`) and by using
- ``Functional Scheme`` after a normal definition using ``Fixpoint`` or
- ``Definition``. See :ref:`advanced-recursive-functions` for details.
-
.. example::
Induction scheme for tree_size.
@@ -298,15 +294,15 @@ definition written by the user.
| cons t f' => (tree_size t + forest_size f')
end.
- Remark: Function generates itself non mutual induction principles
- tree_size_ind and forest_size_ind:
+ Notice that the induction principles ``tree_size_ind`` and ``forest_size_ind``
+ generated by ``Function`` are not mutual.
.. coqtop:: all
Check tree_size_ind.
- The definition of mutual induction principles following the recursive
- structure of `tree_size` and `forest_size` is defined by the command:
+ Mutual induction principles following the recursive structure of ``tree_size``
+ and ``forest_size`` can be generated by the following command:
.. coqtop:: all
@@ -352,10 +348,8 @@ having inverted the instance with the tactic `inversion`.
.. example::
- Let us consider the relation `Le` over natural numbers and the following
- variable:
-
- .. original LaTeX had "Variable" instead of "Axiom", which generates an ugly warning
+ Consider the relation `Le` over natural numbers and the following
+ parameter ``P``:
.. coqtop:: all
@@ -363,7 +357,7 @@ having inverted the instance with the tactic `inversion`.
| LeO : forall n:nat, Le 0 n
| LeS : forall n m:nat, Le n m -> Le (S n) (S m).
- Axiom P : nat -> nat -> Prop.
+ Parameter P : nat -> nat -> Prop.
To generate the inversion lemma for the instance `(Le (S n) m)` and the
sort `Prop`, we do:
diff --git a/doc/sphinx/user-extensions/syntax-extensions.rst b/doc/sphinx/user-extensions/syntax-extensions.rst
index dcefa293b1..d92b9a6794 100644
--- a/doc/sphinx/user-extensions/syntax-extensions.rst
+++ b/doc/sphinx/user-extensions/syntax-extensions.rst
@@ -50,11 +50,11 @@ A notation is always surrounded by double quotes (except when the
abbreviation has the form of an ordinary applicative expression;
see :ref:`Abbreviations`). The notation is composed of *tokens* separated by
spaces. Identifiers in the string (such as ``A`` and ``B``) are the *parameters*
-of the notation. They must occur at least once each in the denoted term. The
+of the notation. Each of them must occur at least once in the denoted term. The
other elements of the string (such as ``/\``) are the *symbols*.
An identifier can be used as a symbol but it must be surrounded by
-simple quotes to avoid the confusion with a parameter. Similarly,
+single quotes to avoid the confusion with a parameter. Similarly,
every symbol of at least 3 characters and starting with a simple quote
must be quoted (then it starts by two single quotes). Here is an
example.
@@ -119,7 +119,7 @@ command understands. Here is how the previous examples refine.
Notation "A /\ B" := (and A B) (at level 80, right associativity).
Notation "A \/ B" := (or A B) (at level 85, right associativity).
-By default, a notation is considered non associative, but the
+By default, a notation is considered non-associative, but the
precedence level is mandatory (except for special cases whose level is
canonical). The level is either a number or the phrase ``next level``
whose meaning is obvious.
@@ -139,14 +139,14 @@ instance define prefix notations.
Notation "~ x" := (not x) (at level 75, right associativity).
One can also define notations for incomplete terms, with the hole
-expected to be inferred at typing time.
+expected to be inferred during typechecking.
.. coqtop:: in
Notation "x = y" := (@eq _ x y) (at level 70, no associativity).
One can define *closed* notations whose both sides are symbols. In this case,
-the default precedence level for the inner subexpression is 200, and the default
+the default precedence level for the inner sub-expression is 200, and the default
level for the notation itself is 0.
.. coqtop:: in
@@ -186,13 +186,13 @@ rules. Some simple left factorization work has to be done. Here is an example.
Notation "x < y < z" := (x < y /\ y < z) (at level 70).
In order to factorize the left part of the rules, the subexpression
-referred by ``y`` has to be at the same level in both rules. However the
+referred to by ``y`` has to be at the same level in both rules. However the
default behavior puts ``y`` at the next level below 70 in the first rule
-(``no associativity`` is the default), and at the level 200 in the second
+(``no associativity`` is the default), and at level 200 in the second
rule (``level 200`` is the default for inner expressions). To fix this, we
need to force the parsing level of ``y``, as follows.
-.. coqtop:: all
+.. coqtop:: in
Notation "x < y" := (lt x y) (at level 70).
Notation "x < y < z" := (x < y /\ y < z) (at level 70, y at next level).
@@ -209,7 +209,7 @@ of Coq predefined notations can be found in the chapter on :ref:`thecoqlibrary`.
.. cmd:: Print Grammar pattern.
This displays the state of the subparser of patterns (the parser used in the
- grammar of the match with constructions).
+ grammar of the ``match with`` constructions).
Displaying symbolic notations
@@ -283,7 +283,7 @@ the possible following elements delimited by single quotes:
(4 spaces in the example)
- well-bracketed pairs of tokens of the form ``'[hv '`` and ``']'`` are
- translated into horizontal-orelse-vertical printing boxes; if the
+ translated into horizontal-or-else-vertical printing boxes; if the
content of the box does not fit on a single line, then every breaking
point forces a newline and an extra indentation of the number of
spaces given after the “ ``[``” is applied at the beginning of each
@@ -295,7 +295,7 @@ the possible following elements delimited by single quotes:
of the box, and an extra indentation of the number of spaces given
after the “``[``” is applied at the beginning of each newline
-Notations do not survive the end of sections. No typing of the denoted
+Notations disappear when a section is closed. No typing of the denoted
expression is performed at definition time. Type-checking is done only
at the time of use of the notation.
@@ -350,7 +350,7 @@ Simultaneous definition of terms and notations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks to reserved notations, the inductive, co-inductive, record, recursive and
-corecursive definitions can benefit of customized notations. To do this, insert
+corecursive definitions can benefit from customized notations. To do this, insert
a ``where`` notation clause after the definition of the (co)inductive type or
(co)recursive term (or after the definition of each of them in case of mutual
definitions). The exact syntax is given by :token:`decl_notation` for inductive,
@@ -359,17 +359,23 @@ for records. Here are examples:
.. coqtop:: in
- Inductive and (A B:Prop) : Prop := conj : A -> B -> A /\ B
- where "A /\ B" := (and A B).
+ Reserved Notation "A & B" (at level 80).
+
+.. coqtop:: in
+
+ Inductive and' (A B : Prop) : Prop := conj' : A -> B -> A & B
+ where "A & B" := (and' A B).
+
+.. coqtop:: in
- Fixpoint plus (n m:nat) {struct n} : nat :=
- match n with
- | O => m
- | S p => S (p+m)
- end
+ Fixpoint plus (n m : nat) {struct n} : nat :=
+ match n with
+ | O => m
+ | S p => S (p+m)
+ end
where "n + m" := (plus n m).
-Displaying informations about notations
+Displaying information about notations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. opt:: Printing Notations
@@ -519,7 +525,7 @@ is just an identifier, one could have said
``p at level 99 as strict pattern``.
Note also that in the absence of a ``as ident``, ``as strict pattern`` or
-``as pattern`` modifiers, the default is to consider subexpressions occurring
+``as pattern`` modifiers, the default is to consider sub-expressions occurring
in binding position and parsed as terms to be ``as ident``.
.. _NotationsWithBinders:
@@ -565,7 +571,7 @@ confused with the three-dots notation “``…``” used in this manual to denot
a sequence of arbitrary size.
On the left-hand side, the part “``x s .. s y``” of the notation parses
-any number of times (but at least one time) a sequence of expressions
+any number of times (but at least once) a sequence of expressions
separated by the sequence of tokens ``s`` (in the example, ``s`` is just “``;``”).
The right-hand side must contain a subterm of the form either
@@ -608,7 +614,7 @@ Notations with recursive patterns involving binders
Recursive notations can also be used with binders. The basic example
is:
-.. coqtop:: all
+.. coqtop:: in
Notation "'exists' x .. y , p" :=
(ex (fun x => .. (ex (fun y => p)) ..))
@@ -627,7 +633,7 @@ repeatedly nested as many times as the number of binders generated. If ever the
generalization operator ``'`` (see :ref:`implicit-generalization`) is
used in the binding list, the added binders are taken into account too.
-Binders parsing exist in two flavors. If ``x`` and ``y`` are marked as binder,
+There are two flavors of binder parsing. If ``x`` and ``y`` are marked as binder,
then a sequence such as :g:`a b c : T` will be accepted and interpreted as
the sequence of binders :g:`(a:T) (b:T) (c:T)`. For instance, in the
notation above, the syntax :g:`exists a b : nat, a = b` is valid.
@@ -650,7 +656,7 @@ example of recursive notation with closed binders:
A recursive pattern for binders can be used in position of a recursive
pattern for terms. Here is an example:
-.. coqtop:: in
+.. coqtop:: in
Notation "'FUNAPP' x .. y , f" :=
(fun x => .. (fun y => (.. (f x) ..) y ) ..)
@@ -691,6 +697,157 @@ side. E.g.:
Notation "'apply_id' f a1 .. an" := (.. (f a1) .. an)
(at level 10, f ident, a1, an at level 9).
+Custom entries
+~~~~~~~~~~~~~~
+
+.. cmd:: Declare Custom Entry @ident
+
+ This command allows to define new grammar entries, called *custom
+ entries*, that can later be referred to using the entry name
+ :n:`custom @ident`.
+
+.. example::
+
+ For instance, we may want to define an ad hoc
+ parser for arithmetical operations and proceed as follows:
+
+ .. coqtop:: all
+
+ Inductive Expr :=
+ | One : Expr
+ | Mul : Expr -> Expr -> Expr
+ | Add : Expr -> Expr -> Expr.
+
+ Declare Custom Entry expr.
+ Notation "[ e ]" := e (e custom expr at level 2).
+ Notation "1" := One (in custom expr at level 0).
+ Notation "x y" := (Mul x y) (in custom expr at level 1, left associativity).
+ Notation "x + y" := (Add x y) (in custom expr at level 2, left associativity).
+ Notation "( x )" := x (in custom expr, x at level 2).
+ Notation "{ x }" := x (in custom expr, x constr).
+ Notation "x" := x (in custom expr at level 0, x ident).
+
+ Axiom f : nat -> Expr.
+ Check fun x y z => [1 + y z + {f x}].
+ Unset Printing Notations.
+ Check fun x y z => [1 + y z + {f x}].
+ Set Printing Notations.
+ Check fun e => match e with
+ | [1 + 1] => [1]
+ | [x y + z] => [x + y z]
+ | y => [y + e]
+ end.
+
+Custom entries have levels, like the main grammar of terms and grammar
+of patterns have. The lower level is 0 and this is the level used by
+default to put rules delimited with tokens on both ends. The level is
+left to be inferred by Coq when using :n:`in custom @ident`. The
+level is otherwise given explicitly by using the syntax
+:n:`in custom @ident at level @num`, where :n:`@num` refers to the level.
+
+Levels are cumulative: a notation at level ``n`` of which the left end
+is a term shall use rules at level less than ``n`` to parse this
+sub-term. More precisely, it shall use rules at level strictly less
+than ``n`` if the rule is declared with ``right associativity`` and
+rules at level less or equal than ``n`` if the rule is declared with
+``left associativity``. Similarly, a notation at level ``n`` of which
+the right end is a term shall use by default rules at level strictly
+less than ``n`` to parse this sub-term if the rule is declared left
+associative and rules at level less or equal than ``n`` if the rule is
+declared right associative. This is what happens for instance in the
+rule
+
+.. coqtop:: in
+
+ Notation "x + y" := (Add x y) (in custom expr at level 2, left associativity).
+
+where ``x`` is any expression parsed in entry
+``expr`` at level less or equal than ``2`` (including, recursively,
+the given rule) and ``y`` is any expression parsed in entry ``expr``
+at level strictly less than ``2``.
+
+Rules associated to an entry can refer different sub-entries. The
+grammar entry name ``constr`` can be used to refer to the main grammar
+of term as in the rule
+
+.. coqtop:: in
+
+ Notation "{ x }" := x (in custom expr at level 0, x constr).
+
+which indicates that the subterm ``x`` should be
+parsed using the main grammar. If not indicated, the level is computed
+as for notations in ``constr``, e.g. using 200 as default level for
+inner sub-expressions. The level can otherwise be indicated explicitly
+by using ``constr at level n`` for some ``n``, or ``constr at next
+level``.
+
+Conversely, custom entries can be used to parse sub-expressions of the
+main grammar, or from another custom entry as is the case in
+
+.. coqtop:: in
+
+ Notation "[ e ]" := e (e custom expr at level 2).
+
+to indicate that ``e`` has to be parsed at level ``2`` of the grammar
+associated to the custom entry ``expr``. The level can be omitted, as in
+
+.. coqtop:: in
+
+ Notation "[ e ]" := e (e custom expr)`.
+
+in which case Coq tries to infer it.
+
+In the absence of an explicit entry for parsing or printing a
+sub-expression of a notation in a custom entry, the default is to
+consider that this sub-expression is parsed or printed in the same
+custom entry where the notation is defined. In particular, if ``x at
+level n`` is used for a sub-expression of a notation defined in custom
+entry ``foo``, it shall be understood the same as ``x custom foo at
+level n``.
+
+In general, rules are required to be *productive* on the right-hand
+side, i.e. that they are bound to an expression which is not
+reduced to a single variable. If the rule is not productive on the
+right-hand side, as it is the case above for
+
+.. coqtop:: in
+
+ Notation "( x )" := x (in custom expr at level 0, x at level 2).
+
+and
+
+.. coqtop:: in
+
+ Notation "{ x }" := x (in custom expr at level 0, x constr).
+
+it is used as a *grammar coercion* which means that it is used to parse or
+print an expression which is not available in the current grammar at the
+current level of parsing or printing for this grammar but which is available
+in another grammar or in another level of the current grammar. For instance,
+
+.. coqtop:: in
+
+ Notation "( x )" := x (in custom expr at level 0, x at level 2).
+
+tells that parentheses can be inserted to parse or print an expression
+declared at level ``2`` of ``expr`` whenever this expression is
+expected to be used as a subterm at level 0 or 1. This allows for
+instance to parse and print :g:`Add x y` as a subterm of :g:`Mul (Add
+x y) z` using the syntax ``(x + y) z``. Similarly,
+
+.. coqtop:: in
+
+ Notation "{ x }" := x (in custom expr at level 0, x constr).
+
+gives a way to let any arbitrary expression which is not handled by the
+custom entry ``expr`` be parsed or printed by the main grammar of term
+up to the insertion of a pair of curly brackets.
+
+.. cmd:: Print Grammar @ident.
+
+ This displays the state of the grammar for terms and grammar for
+ patterns associated to the custom entry :token:`ident`.
+
Summary
~~~~~~~
@@ -699,8 +856,8 @@ Summary
Syntax of notations
+++++++++++++++++++
-The different syntactic variants of the command Notation are given on the
-following figure. The optional :production:`scope` is described in
+The different syntactic forms taken by the commands declaring
+notations are given below. The optional :production:`scope` is described in
:ref:`Scopes`.
.. productionlist:: coq
@@ -711,22 +868,32 @@ following figure. The optional :production:`scope` is described in
: | CoInductive `ind_body` [`decl_notation`] with … with `ind_body` [`decl_notation`].
: | Fixpoint `fix_body` [`decl_notation`] with … with `fix_body` [`decl_notation`].
: | CoFixpoint `cofix_body` [`decl_notation`] with … with `cofix_body` [`decl_notation`].
+ : | [Local] Declare Custom Entry `ident`.
decl_notation : [where `string` := `term` [: `scope`] and … and `string` := `term` [: `scope`]].
- modifiers : at level `natural`
- : | `ident` , … , `ident` at level `natural` [`binderinterp`]
+ modifiers : at level `num`
+ : in custom `ident`
+ : in custom `ident` at level `num`
+ : | `ident` , … , `ident` at level `num` [`binderinterp`]
: | `ident` , … , `ident` at next level [`binderinterp`]
- : | `ident` ident
- : | `ident` global
- : | `ident` bigint
- : | `ident` [strict] pattern [at level `natural`]
- : | `ident` binder
- : | `ident` closed binder
+ : | `ident` `explicit_subentry`
: | left associativity
: | right associativity
: | no associativity
: | only parsing
: | only printing
: | format `string`
+ explicit_subentry : ident
+ : | global
+ : | bigint
+ : | [strict] pattern [at level `num`]
+ : | binder
+ : | closed binder
+ : | constr [`binderinterp`]
+ : | constr at level `num` [`binderinterp`]
+ : | constr at next level [`binderinterp`]
+ : | custom [`binderinterp`]
+ : | custom at level `num` [`binderinterp`]
+ : | custom at next level [`binderinterp`]
binderinterp : as ident
: | as pattern
: | as strict pattern
@@ -734,10 +901,11 @@ following figure. The optional :production:`scope` is described in
.. note:: No typing of the denoted expression is performed at definition
time. Type-checking is done only at the time of use of the notation.
-.. note:: Many examples of Notation may be found in the files composing
+.. note:: Some examples of Notation may be found in the files composing
the initial state of Coq (see directory :file:`$COQLIB/theories/Init`).
-.. note:: The notation ``"{ x }"`` has a special status in such a way that
+.. note:: The notation ``"{ x }"`` has a special status in the main grammars of
+ terms and patterns so that
complex notations of the form ``"x + { y }"`` or ``"x * { y }"`` can be
nested with correct precedences. Especially, every notation involving
a pattern of the form ``"{ x }"`` is parsed as a notation where the
@@ -754,22 +922,27 @@ following figure. The optional :production:`scope` is described in
Persistence of notations
++++++++++++++++++++++++
-Notations do not survive the end of sections.
+Notations disappear when a section is closed.
.. cmd:: Local Notation @notation
Notations survive modules unless the command ``Local Notation`` is used instead
of :cmd:`Notation`.
+.. cmd:: Local Declare Custom Entry @ident
+
+ Custom entries survive modules unless the command ``Local Declare
+ Custom Entry`` is used instead of :cmd:`Declare Custom Entry`.
+
.. _Scopes:
Interpretation scopes
----------------------
An *interpretation scope* is a set of notations for terms with their
-interpretation. Interpretation scopes provide a weak, purely
-syntactical form of notations overloading: the same notation, for
-instance the infix symbol ``+`` can be used to denote distinct
+interpretations. Interpretation scopes provide a weak, purely
+syntactical form of notation overloading: the same notation, for
+instance the infix symbol ``+``, can be used to denote distinct
definitions of the additive operator. Depending on which interpretation
scopes are currently open, the interpretation is different.
Interpretation scopes can include an interpretation for numerals and
@@ -780,7 +953,7 @@ See :ref:`above <NotationSyntax>` for the syntax of notations including the
possibility to declare them in a given scope. Here is a typical example which
declares the notation for conjunction in the scope ``type_scope``.
-.. coqdoc::
+.. coqtop:: in
Notation "A /\ B" := (and A B) : type_scope.
@@ -790,10 +963,10 @@ declares the notation for conjunction in the scope ``type_scope``.
Global interpretation rules for notations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-At any time, the interpretation of a notation for term is done within
+At any time, the interpretation of a notation for a term is done within
a *stack* of interpretation scopes and lonely notations. In case a
notation has several interpretations, the actual interpretation is the
-one defined by (or in) the more recently declared (or open) lonely
+one defined by (or in) the more recently declared (or opened) lonely
notation (or interpretation scope) which defines this notation.
Typically if a given notation is defined in some scope ``scope`` but has
also an interpretation not assigned to a scope, then, if ``scope`` is open
@@ -819,7 +992,7 @@ lonely notations. These scopes, in opening order, are ``core_scope``,
stack by using the command :n:`Close Scope @scope`.
Notice that this command does not only cancel the last :n:`Open Scope @scope`
- but all the invocations of it.
+ but all its invocations.
.. note:: ``Open Scope`` and ``Close Scope`` do not survive the end of sections
where they occur. When defined outside of a section, they are exported
@@ -899,11 +1072,11 @@ Binding arguments of a constant to an interpretation scope
the scope is limited to the argument itself. It does not propagate to
subterms but the subterms that, after interpretation of the notation,
turn to be themselves arguments of a reference are interpreted
- accordingly to the arguments scopes bound to this reference.
+ accordingly to the argument scopes bound to this reference.
.. cmdv:: Arguments @qualid : clear scopes
- Arguments scopes can be cleared with :n:`Arguments @qualid : clear scopes`.
+ This command can be used to clear argument scopes of :token:`qualid`.
.. cmdv:: Arguments @qualid {+ @name%scope} : extra scopes
@@ -1010,7 +1183,7 @@ The ``function_scope`` interpretation scope
.. index:: function_scope
-The scope ``function_scope`` also has a special status.
+The scope ``function_scope`` also has a special status.
It is temporarily activated each time the argument of a global reference is
recognized to be a ``Funclass`` istance, i.e., of type :g:`forall x:A, B` or
:g:`A -> B`.
@@ -1025,34 +1198,34 @@ Scopes` or :cmd:`Print Scope`.
``type_scope``
This scope includes infix * for product types and infix + for sum types. It
- is delimited by key ``type``, and bound to the coercion class
+ is delimited by the key ``type``, and bound to the coercion class
``Sortclass``, as described above.
``function_scope``
- This scope is delimited by key ``function``, and bound to the coercion class
+ This scope is delimited by the key ``function``, and bound to the coercion class
``Funclass``, as described above.
``nat_scope``
This scope includes the standard arithmetical operators and relations on type
nat. Positive numerals in this scope are mapped to their canonical
- representent built from :g:`O` and :g:`S`. The scope is delimited by key
+ representent built from :g:`O` and :g:`S`. The scope is delimited by the key
``nat``, and bound to the type :g:`nat` (see above).
``N_scope``
This scope includes the standard arithmetical operators and relations on
- type :g:`N` (binary natural numbers). It is delimited by key ``N`` and comes
+ type :g:`N` (binary natural numbers). It is delimited by the key ``N`` and comes
with an interpretation for numerals as closed terms of type :g:`N`.
``Z_scope``
This scope includes the standard arithmetical operators and relations on
- type :g:`Z` (binary integer numbers). It is delimited by key ``Z`` and comes
- with an interpretation for numerals as closed term of type :g:`Z`.
+ type :g:`Z` (binary integer numbers). It is delimited by the key ``Z`` and comes
+ with an interpretation for numerals as closed terms of type :g:`Z`.
``positive_scope``
This scope includes the standard arithmetical operators and relations on
type :g:`positive` (binary strictly positive numbers). It is delimited by
key ``positive`` and comes with an interpretation for numerals as closed
- term of type :g:`positive`.
+ terms of type :g:`positive`.
``Q_scope``
This scope includes the standard arithmetical operators and relations on
@@ -1069,20 +1242,20 @@ Scopes` or :cmd:`Print Scope`.
``real_scope``
This scope includes the standard arithmetical operators and relations on
- type :g:`R` (axiomatic real numbers). It is delimited by key ``R`` and comes
+ type :g:`R` (axiomatic real numbers). It is delimited by the key ``R`` and comes
with an interpretation for numerals using the :g:`IZR` morphism from binary
integer numbers to :g:`R`.
``bool_scope``
- This scope includes notations for the boolean operators. It is delimited by
+ This scope includes notations for the boolean operators. It is delimited by the
key ``bool``, and bound to the type :g:`bool` (see above).
``list_scope``
- This scope includes notations for the list operators. It is delimited by key
+ This scope includes notations for the list operators. It is delimited by the key
``list``, and bound to the type :g:`list` (see above).
``core_scope``
- This scope includes the notation for pairs. It is delimited by key ``core``.
+ This scope includes the notation for pairs. It is delimited by the key ``core``.
``string_scope``
This scope includes notation for strings as elements of the type string.
@@ -1101,7 +1274,7 @@ Scopes` or :cmd:`Print Scope`.
the ASCII code 34), all of them being represented in the type :g:`ascii`.
-Displaying informations about scopes
+Displaying information about scopes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. cmd:: Print Visibility
@@ -1109,7 +1282,7 @@ Displaying informations about scopes
This displays the current stack of notations in scopes and lonely
notations that is used to interpret a notation. The top of the stack
is displayed last. Notations in scopes whose interpretation is hidden
- by the same notation in a more recently open scope are not displayed.
+ by the same notation in a more recently opened scope are not displayed.
Hence each notation is displayed only once.
.. cmdv:: Print Visibility @scope
@@ -1122,13 +1295,13 @@ Displaying informations about scopes
.. cmd:: Print Scopes
This displays all the notations, delimiting keys and corresponding
- class of all the existing interpretation scopes. It also displays the
+ classes of all the existing interpretation scopes. It also displays the
lonely notations.
.. cmdv:: Print Scope @scope
:name: Print Scope
- This displays all the notations defined in interpretation scope :token:`scope`.
+ This displays all the notations defined in the interpretation scope :token:`scope`.
It also displays the delimiting key if any and the class to which the
scope is bound, if any.
@@ -1170,13 +1343,13 @@ Abbreviations
much as possible by the Coq printers unless the modifier ``(only
parsing)`` is given.
- Abbreviations are bound to an absolute name as an ordinary definition
- is, and they can be referred by qualified names too.
+ An abbreviation is bound to an absolute name as an ordinary definition is
+ and it also can be referred to by a qualified name.
Abbreviations are syntactic in the sense that they are bound to
expressions which are not typed at the time of the definition of the
- abbreviation but at the time it is used. Especially, abbreviations can
- be bound to terms with holes (i.e. with “``_``”). For example:
+ abbreviation but at the time they are used. Especially, abbreviations
+ can be bound to terms with holes (i.e. with “``_``”). For example:
.. coqtop:: none reset
@@ -1186,13 +1359,16 @@ Abbreviations
.. coqtop:: in
Definition explicit_id (A:Set) (a:A) := a.
+
+ .. coqtop:: in
+
Notation id := (explicit_id _).
.. coqtop:: all
Check (id 0).
- Abbreviations do not survive the end of sections. No typing of the
+ Abbreviations disappear when a section is closed. No typing of the
denoted expression is performed at definition time. Type-checking is
done only at the time of use of the abbreviation.
@@ -1201,13 +1377,12 @@ Abbreviations
Tactic Notations
-----------------
-Tactic notations allow to customize the syntax of the tactics of the
-tactic language. Tactic notations obey the following syntax:
+Tactic notations allow to customize the syntax of tactics. They have the following syntax:
.. productionlist:: coq
tacn : Tactic Notation [`tactic_level`] [`prod_item` … `prod_item`] := `tactic`.
prod_item : `string` | `tactic_argument_type`(`ident`)
- tactic_level : (at level `natural`)
+ tactic_level : (at level `num`)
tactic_argument_type : ident | simple_intropattern | reference
: | hyp | hyp_list | ne_hyp_list
: | constr | uconstr | constr_list | ne_constr_list
@@ -1224,7 +1399,7 @@ tactic language. Tactic notations obey the following syntax:
a terminal symbol, i.e. a string, for the first production item. The
tactic level indicates the parsing precedence of the tactic notation.
This information is particularly relevant for notations of tacticals.
- Levels 0 to 5 are available (default is 0).
+ Levels 0 to 5 are available (default is 5).
.. cmd:: Print Grammar tactic
@@ -1251,7 +1426,7 @@ tactic language. Tactic notations obey the following syntax:
* - ``simple_intropattern``
- intro_pattern
- - an intro_pattern
+ - an intro pattern
- intros
* - ``hyp``
@@ -1305,7 +1480,7 @@ tactic language. Tactic notations obey the following syntax:
-
.. note:: In order to be bound in tactic definitions, each syntactic
- entry for argument type must include the case of simple L tac
+ entry for argument type must include the case of a simple |Ltac|
identifier as part of what it parses. This is naturally the case for
``ident``, ``simple_intropattern``, ``reference``, ``constr``, ... but not for ``integer``.
This is the reason for introducing a special entry ``int_or_var`` which
@@ -1319,16 +1494,16 @@ tactic language. Tactic notations obey the following syntax:
.. cmdv:: Local Tactic Notation
- Tactic notations do not survive the end of sections. They survive
- modules unless the command Local Tactic Notation is used instead of
- Tactic Notation.
+ Tactic notations disappear when a section is closed. They survive when
+ a module is closed unless the command ``Local Tactic Notation`` is used instead
+ of :cmd:`Tactic Notation`.
.. rubric:: Footnotes
.. [#and_or_levels] which are the levels effectively chosen in the current
implementation of Coq
-.. [#no_associativity] Coq accepts notations declared as ``no associative`` but the parser on
- which Coq is built, namely Camlp4, currently does not implement the
- ``no associativity`` and replaces it by a ``left associativity``; hence it is
- the same for Coq: ``no associativity`` is in fact ``left associativity``.
+.. [#no_associativity] Coq accepts notations declared as non-associative but the parser on
+ which Coq is built, namely Camlp5, currently does not implement ``no associativity`` and
+ replaces it with ``left associativity``; hence it is the same for Coq: ``no associativity``
+ is in fact ``left associativity`` for the purposes of parsing
diff --git a/doc/stdlib/index-list.html.template b/doc/stdlib/index-list.html.template
index 8c09b23a5a..f448248468 100644
--- a/doc/stdlib/index-list.html.template
+++ b/doc/stdlib/index-list.html.template
@@ -498,6 +498,9 @@ through the <tt>Require Import</tt> command.</p>
<dd>
theories/Strings/Ascii.v
theories/Strings/String.v
+ theories/Strings/BinaryString.v
+ theories/Strings/HexString.v
+ theories/Strings/OctalString.v
</dd>
<dt> <b>Reals</b>:
diff --git a/doc/tools/coqrst/coqdomain.py b/doc/tools/coqrst/coqdomain.py
index c9487abf03..e6b71a8293 100644
--- a/doc/tools/coqrst/coqdomain.py
+++ b/doc/tools/coqrst/coqdomain.py
@@ -571,6 +571,9 @@ class ExampleDirective(BaseAdmonition):
http://docutils.sourceforge.net/docs/ref/rst/directives.html#generic-admonition
for more details.
+ Optionally, any text immediately following the ``.. example::`` header is
+ used as the example's title.
+
Example::
.. example:: Adding a hint to a database
@@ -583,13 +586,14 @@ class ExampleDirective(BaseAdmonition):
"""
node_class = nodes.admonition
directive_name = "example"
+ optional_arguments = 1
def run(self):
# ‘BaseAdmonition’ checks whether ‘node_class’ is ‘nodes.admonition’,
# and uses arguments[0] as the title in that case (in other cases, the
# title is unset, and it is instead set in the HTML visitor).
- assert not self.arguments # Arguments have been parsed as content
- self.arguments = ['Example']
+ assert len(self.arguments) <= 1
+ self.arguments = [": ".join(['Example'] + self.arguments)]
self.options['classes'] = ['admonition', 'note']
return super().run()